Skip to content

Instantly share code, notes, and snippets.

View dmiddlecamp's full-sized avatar

David Middlecamp dmiddlecamp

View GitHub Profile
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Collections.Generic;
public class SSEvent {
public string Name { get; set; }
public string Data { get; set; }
@dmiddlecamp
dmiddlecamp / main.ino
Created July 18, 2015 19:54
Photon Audio Example
#define MICROPHONE_PIN A5
#define AUDIO_BUFFER_MAX 8192
int audioStartIdx = 0, audioEndIdx = 0;
uint16_t audioBuffer[AUDIO_BUFFER_MAX];
uint16_t txBuffer[AUDIO_BUFFER_MAX];
// version without timers
unsigned long lastRead = micros();
@dmiddlecamp
dmiddlecamp / WifiScan.cpp
Created April 25, 2014 15:46
WifiScanner example firmware for the core
#include "WifiScan.h"
#include "application.h"
void parseScanResultToJson(WifiScanResults_t result, char *line);
void bytesToHex(unsigned char *data, int length, char* buffer);
void wipeStr(char *str, int len) {
for(int i = 0; i < len ;i++) {
str[i] = 0;
}
bool state = false;
void setup() {
pinMode(D7, OUTPUT);
Particle.keepAlive(1.5 * 60);
//Serial1.begin(9600); // crashes, uncomment to run normally.
Particle.function("test", doTest);
@dmiddlecamp
dmiddlecamp / emailDemo.cpp
Created February 11, 2014 20:04
A pretty rough example for sending an emil!
#define SMTP_SERVER "smtp.yourserver.com"
#define SMTP_USER_BASE64 "base64_encode_your_user"
#define SMTP_PASS_BASE64 "base64_encode_your_pass"
#define SMTP_FROM_EMAIL "email@from.com"
#define SMTP_TO_EMAIL "email@to.com"
#define SMTP_SUBJECT "Email from a Core!"
#define SMTP_BODY "Body body body"
#include "application.h"
@dmiddlecamp
dmiddlecamp / TempSensor.h
Created April 23, 2014 17:18
OneWire Temp - Multiple Sensors
#include "application.h"
class TempSensor {
public:
char *id ;
uint8_t rom[8];
float value ;
int updated ;
};
#include "HttpClient.h"
#define LOGGING
#define TIMEOUT 5000 // Allow maximum 5s between data packets.
/**
* Constructor.
*/
HttpClient::HttpClient()
{
#define STARTING_LATITUDE_LONGITUDE_ALTITUDE NULL
uint8_t internalANT[]={0xB5,0x62,0x06,0x13,0x04,0x00,0x00,0x00,0xF0,0x7D,0x8A,0x2A};
uint8_t externalANT[]={0xB5,0x62,0x06,0x13,0x04,0x00,0x01,0x00,0xF0,0x7D,0x8B,0x2E};
...
setup() {
#define MICROPHONE_PIN A5
#define AUDIO_BUFFER_MAX 8192
int audioStartIdx = 0, audioEndIdx = 0;
uint16_t audioBuffer[AUDIO_BUFFER_MAX];
uint16_t txBuffer[AUDIO_BUFFER_MAX];
// version without timers
unsigned long lastRead = micros();
@dmiddlecamp
dmiddlecamp / Adafruit_GPS.cpp
Last active April 21, 2018 05:07
Spark GPS demo with Adafruit Ultimate GPS breakout
/***********************************
This is our GPS library
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information
All text above must be included in any redistribution