Skip to content

Instantly share code, notes, and snippets.

View nadavmatalon's full-sized avatar

Nadav Matalon nadavmatalon

View GitHub Profile

GITHUB COMMANDS

COMMAND ACTION NOTES
git init initialize a local repo
git status shows current repo status
git status -s shows current repo status: abbreviated version
git remote add remoteName remoteURL adds a remote with given name & destination URL
git remote lists all remotes
git remote -v lists all remotes & destination URLs
@nadavmatalon
nadavmatalon / Arduino_Assign_Default_Parm_Val.ino
Last active October 6, 2016 15:10
Arduino: Assigning Default Parameter Value
void test(int val1, int val2=2);
void setup() {
Serial.begin(9600);
test(10,11);
test(12);
}
void loop() {}
// Must be run on Arduino.org IDE (> V1.7.11)
#include <Wire.h>
#include <ArduinoWiFi.h>
void setup() {
Wifi.begin();
Serial.begin(9600);
}
// Code Author: Mikal Hart
// Code Source: http://arduiniana.org/libraries/pstring/
// Direct use (no constructor):
char buffer[30];
float pi 3.14159;
PString(buffer, sizeof(buffer), pi);
// Construct an object:
char buffer[50];
// Code Author: Mikal Hart
// Code Source: http://arduiniana.org/libraries/streaming/
Serial << "Counter: " << counter;
lcd << "Temp: " << t.get_temperature() << " degrees";
my_pstring << "Hello World!" << endl;
Serial << "Byte value: " << _HEX(b) << endl;
// http://playground.arduino.cc/Main/I2cScanner
// -------------
// i2c_scanner
// -------------
#include <Wire.h>
void setup() {
Wire.begin();
@nadavmatalon
nadavmatalon / mapf.ino
Created October 12, 2016 15:13
ARDUINO: MAP FLOAT FUNCTION
double mapf(double val, double in_min, double in_max, double out_min, double out_max) {
return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@nadavmatalon
nadavmatalon / update_bits.ino
Last active October 25, 2016 14:42
ARDUINO: Update Specific Bits in a Byte
byte _config = 0x00; // byte to be updated
typedef enum:byte {
MODE_MASK = 0x0C, // 12 - B00001100 (set all bits to be changed - and only them - to 1)
MODE_1 = 0x00, // 0 - B00000000 (Defualt)
MODE_2 = 0x08 // 8 - B00001000
} dev_mode_t;
void setDevMode(dev_mode_t newMode) { // PARAMS: MODE_1 / MODE_2
setConfig((_config & ~MODE_MASK) | (newMode & MODE_MASK));
@nadavmatalon
nadavmatalon / preprocessor_bug_fix.ino
Last active October 14, 2016 18:03
ARDUINO: Preprocessor Bug Fix
// preprocessor bug fix (place at the very top of the arduino code)
#if 1
__asm volatile ("nop");
#endif
@nadavmatalon
nadavmatalon / wswire.md
Last active October 24, 2016 19:08
WSWire
  1. I2C Communications Library

This library uses the 'WSWire' library for I2C communication between the contoller IC (Master) and the ADS1110 (Slave), so it is NECESSARY to have it installed prior to using the current libraty.

Alternatively, if you wish to use the 'Wire' - or any other I2C library for that matter - simply change the following line the the ADS1110.h file:

#include <WSWire.h>

to this: