Подход к стадии бета

Подход к стадии бета

--- main.ino
+++ main.ino
@@ -1,10 +1,15 @@
 #include <EEPROM.h>
+#include <Time.h>
 #include <Wire.h>
+#include <DS1307RTC.h>
 #include <LiquidCrystal_I2C.h>

-#define VERSION "0.2(a)"
-
-static byte	bat_icon[8]	= {
+LiquidCrystal_I2C lcd(0x27,16,2); // Инициализация дисплея (адрес, количество символов, количество строк)
+
+#define VERSION "0.8(a)"
+#define DEBUG
+
+static byte	bat_icon[8] = {
 	B01110,
 	B11111,
 	B11111,
@@ -15,22 +20,15 @@
 	B11111
 };

-static byte	bat_in_icon[8]	= {
-	B01110,
-	B11111,
-	B10101,
-	B10101,
-	B10101,
-	B10001,
-	B10101,
-	B11111
-};
-
-LiquidCrystal_I2C lcd(0x27,16,2);	// Инициализация дисплея (адрес, количество символов, количество строк)
-
 struct sys_conf {
-	byte	password[6],		// Пароль, для отключения сигнала
-			red_speed,			// Включать ли красный свет при уменьшении скорости
+	int		password[6];		// Пароль, для отключения сигнала
+
+	int		BUTTON_OK,
+			BUTTON_UP,
+			BUTTON_DOWN,
+			BUTTON_SIGNAL;
+
+	byte	red_speed,			// Включать ли красный свет при уменьшении скорости
 			time_to_slpeep,		// Время, после которого компьютер уснёт (минуты)
 			auto_led,			// Включать подсветку экрана по датчику света или нет
 			auto_headlights;	// Включать фару по датчику света или нет
@@ -39,26 +37,24 @@
 			max_speed;
 };

+/*Стандартные значения*/
+#define WHEEL_LENGTH	0.193	// Длина окружности колеса в метрах
+#define BIP_DELAY		4		// Сколько итераций пищать (* 500 / 10000)
+
+/*Аналоговые выводы*/
+#define ACTION_BUTTON	6
+#define LIGHT_SENSOR	7
+
+/*Цифровые выводы*/
+#define BIP				9
+#define DISPLAY_LIGHT	10
+#define VIBRO_SENSOR	7
+
 /*Системные макросы*/
-#define BUTTON_PRESS	LOW
-
-/*Стандартные значения*/
-#define WHEEL_LENGTH	2.050	// Длина окружности колеса в метрах
-#define BIP_DELAY		4		// Сколько итераций пищать (* 500 / 10000)
-
-/*Аналоговые выводы*/
-#define ACTION_BUTTON	2
-#define BUTTON_OK		256
-#define BUTTON_LEFT		680
-#define BUTTON_RIGHT	341
-
-/*Цифровые выводы*/
-#define BIP				4
-#define BUTTON_CANCEL	341
-#define BUTTON_SIGNAL	341
-
-bool			alarm_state		= false,	// Для сигнализации
-				bat_external	= true;
+#define SWITCH_NEXT		150		// Врямя в мс до переключения на следующий пункт при зажатой кнопке
+#define LONG_PRESS		2000	// Время долгого нажатия кнопки
+
+bool			alarm_state		= false;	// Для сигнализации

 unsigned long	lastturn;	// Время последнего обращения

@@ -68,47 +64,300 @@
 byte			bat_percent		= 100,
 				system_state	= 0;

-#define LOAD_STATE		0
-#define SPEED_STATE		1
-#define MENU_STATE		2
-#define SETTINGS_STATE	3
-
-sys_conf		btc_config;	// Конфигурация системы
-
-unsigned int key_pressed() {
-	int key;
-
+#define SPEED_STATE		0
+#define MENU_STATE		1
+#define SETTINGS_STATE	2
+
+sys_conf		btc_config; // Конфигурация системы
+
+void setup() {
+	#ifdef DEBUG
+	Serial.begin(9600);
+	#endif
+
+	/*Инициализация дисплея*/
+	lcd.begin();
+	pinMode(DISPLAY_LIGHT, OUTPUT);
+	pinMode(VIBRO_SENSOR, OUTPUT);
+	analogWrite(DISPLAY_LIGHT, 175);	// Включение подсветки
+
+	lcd.print("Loading system..");
+	lcd.setCursor(0, 1);
+	lcd.print("Version: ");
+	lcd.print(VERSION);
+
+	tone(BIP, 100, 250);
+	delay(250);
+	tone(BIP, 100, 250);
+	delay(1000);
+
+	setSyncProvider(RTC.get);			// Для времени
+
+	/*Инициализация выводов для сигнала*/
+	pinMode(BIP, OUTPUT);
+
+	/*Прерывание на 2-ом цифровом канале для сигнализации*/
+	attachInterrupt(0, alarm, CHANGE);
+
+	/*Прерывание на 3-ем цифровом канале для подсчёта скорости*/
+	// attachInterrupt(1, speed, CHANGE);
+
+	lcd.createChar(0, bat_icon);
+
+	#ifdef FIRST_ON
+	sys_conf load_to_eeprom;
+
+	load_to_eeprom.password[0]		= 1;
+	load_to_eeprom.password[1]		= 2;
+	load_to_eeprom.password[2]		= 3;
+	load_to_eeprom.password[3]		= 4;
+	load_to_eeprom.red_speed		= true;
+	load_to_eeprom.time_to_slpeep = 5;
+	load_to_eeprom.auto_led		 = true;
+	load_to_eeprom.auto_headlights	= true;
+	load_to_eeprom.distance		 = 0.0;
+	load_to_eeprom.max_speed		= 0.0;
+
+	WriteSysConfEEPROM(load_to_eeprom, 0);
+	lcd.print("All OK!");
+	#endif
+	colibration();
+}
+
+/*Interrupt zone start*/
+void alarm() {	// Сигнализация
+	if ((!alarm_state) && (system_state == 1)) {
+		alarm_state = true;
+
+		for (int	i = 0; i < BIP_DELAY; i++) {
+			tone(BIP, 750);
+			delay(500);
+			tone(BIP, 300);
+			delay(500);
+		}
+		noTone(BIP);
+		alarm_state = false;
+	}
+}
+
+void speed() {	// Подсчёт скорости
+	if ((millis() - lastturn) > 80) { // Защита от случайных измерений (основано на том, что велосипед не будет ехать быстрее 120 кмч)
+		speed_now = WHEEL_LENGTH / ((float)(millis() - lastturn) / 1000) * 3.6; // Расчет скорости, км/ч
+		lastturn	= millis();													 // Запомнить время последнего оборота
+		distance	= distance + WHEEL_LENGTH / 1000;							 // Прибавляем длину колеса к дистанции при каждом обороте
+	}
+}
+/*Interrupt zone end*/
+
+void loop() {
+	first_on();
+	if (system_state == SPEED_STATE) {
+		road_mode();
+	}
+
+	if (system_state == MENU_STATE) {
+		#ifdef DEBUG
+		char menu_array[5][15]	= {
+		#else
+		char menu_array[4][15]	= {
+		#endif
+			"Sleep",
+			"Speedometr",
+			"Statistik",
+		#ifdef DEBUG
+			"Settings",
+			"Self test"
+		#else
+			"Settings"
+		#endif
+		};
+
+		#ifdef DEBUG
+		switch (display_list(5, menu_array)) {
+		#else
+		switch (display_list(4, menu_array)) {
+		#endif
+			case 0:	alarm_mode();
+					break;
+			case 1: system_state	= SPEED_STATE;
+					break;
+
+			case 3: system_state	= SETTINGS_STATE;
+					break;
+
+			#ifdef DEBUG
+			case 4: self_test();
+					break;
+			#endif
+		}
+	}
+
+	if (system_state == SETTINGS_STATE) {
+		char settings_array[6][15]	= {
+			"Password",
+			"Display",
+			"Light settings",
+			"Time setting",
+			"About system",
+			"Back"
+		};
+
+		switch (display_list(6, settings_array)) {
+			case 0: if (read_password())
+						input_password();
+					break;
+
+			case 3:	TimeElements	t_n;
+					time_t			timeVal;
+					t_n.Second	= 0;
+					t_n.Hour	= input_int_number("Input hour", 0, 23);
+					t_n.Minute	= input_int_number("Input minutes", 0, 59);
+					t_n.Day		= input_int_number("Input day", 1, 31);
+					t_n.Month	= input_int_number("Input month", 1, 12);
+					t_n.Year	= input_int_number("Input year", 15, 20) + 30;
+					timeVal		= makeTime(t_n);
+					RTC.set(timeVal);
+					setTime(timeVal);
+					break;
+
+			case 5: system_state	= MENU_STATE;
+					break;
+		}
+	}
+}
+
+void alarm_mode() {
+	lcd.clear();
+	lcd.print(" Stand By Mode");
+	digitalWrite(DISPLAY_LIGHT, LOW);
+	digitalWrite(VIBRO_SENSOR, HIGH);
+	alarm_state		= false;
+	system_state	= 1;
 	while (true) {
-
-		while ((key = analogRead(ACTION_BUTTON)) > 1000);
+		while (analogRead(ACTION_BUTTON) < 5);
+		if (read_password())
+			break;
+	}
+	digitalWrite(VIBRO_SENSOR, LOW);
+}
+
+byte input_int_number(const char *text, byte min_num, byte max_num) {	// Ввод целочисленного числа
+	lcd.clear();
+	lcd.print(text);
+
+	int		key_now;
+
+	byte	same_num = min_num;
+
+	while (true) {
+		lcd.setCursor(0, 1);
+		lcd.print("   ");
+
+		lcd.setCursor(0, 1);
+		lcd.print(same_num);
+		key_now	= key_pressed();
+
+		if (key_now == btc_config.BUTTON_UP) {
+			if (same_num == max_num) {
+				same_num	= min_num;
+			} else {
+				same_num++;
+			}
+		} else if (key_now == btc_config.BUTTON_DOWN) {
+			if (same_num == min_num) {
+				same_num	= max_num;
+			} else {
+				same_num--;
+			}
+		} else if (key_now == btc_config.BUTTON_OK) {
+			return same_num;
+		}
+	}
+}
+
+float input_float_number(char text[], float min_num, float max_num) {	// Ввод числа с точкой
+	lcd.clear();
+	lcd.print(text);
+
+	float	same_num = min_num;
+
+	int		key_now;
+
+	while (true) {
+		lcd.setCursor(0, 1);
+		lcd.print("                ");
+		lcd.setCursor(0, 1);
+		lcd.print(same_num);
+
+		key_now	= key_pressed();
+
+		if (key_now == btc_config.BUTTON_UP) {
+			if ((same_num + 0.1) > max_num) {
+				same_num	= min_num;
+			} else {
+				same_num	+= 0.1;
+			}
+		} else if (key_now == btc_config.BUTTON_DOWN) {
+			if ((same_num - 0.1) < min_num) {
+				same_num	= max_num;
+			} else {
+				same_num	-= 0.1;
+			}
+		} else if (key_now == btc_config.BUTTON_OK) {
+			return same_num;
+		}
+	}
+}
+
+void sys_watch() {
+	if (analogRead(LIGHT_SENSOR) > 600) {
+		digitalWrite(DISPLAY_LIGHT, LOW);
+	} else {
+		digitalWrite(DISPLAY_LIGHT, HIGH);
+	}
+}
+
+void stand_by_mode() {
+
+}
+
+unsigned int key_pressed() {	// Определение нажатой кнопки
+	int	key,
+		delay_time	= 0;
+
+	while (true) {
+		sys_watch();
+
+		key	= analogRead(ACTION_BUTTON);

 		#ifdef DEBUG
 		Serial.println(key);
 		#endif

-		if ((key >= BUTTON_OK - 10) && (key <= BUTTON_OK + 10)) {
-			key	= BUTTON_OK;
+		if ((key >= btc_config.BUTTON_OK - 5) && (key <= btc_config.BUTTON_OK + 5)) {
+			key = btc_config.BUTTON_OK;
 			break;
-		} else if ((key >= BUTTON_LEFT - 10) && (key <= BUTTON_LEFT + 10)) {
-			key	= BUTTON_LEFT;
+		} else if ((key >= btc_config.BUTTON_UP - 5) && (key <= btc_config.BUTTON_UP + 5)) {
+			key = btc_config.BUTTON_UP;
 			break;
-		} else if ((key >= BUTTON_RIGHT - 10) && (key <= BUTTON_RIGHT + 10)) {
-			key	= BUTTON_RIGHT;
+		} else if ((key >= btc_config.BUTTON_DOWN - 5) && (key <= btc_config.BUTTON_DOWN + 5)) {
+			key = btc_config.BUTTON_DOWN;
 			break;
 		}
 	}

-	while (analogRead(ACTION_BUTTON) < 1000);
-
-	delay(10);
+	while ((analogRead(ACTION_BUTTON) > 5) && (delay_time < SWITCH_NEXT)) {	// Ожидание зажатия
+		delay(1);
+		delay_time++;
+	}

 	return key;
 }

 void road_mode() {	// Режим спидометра
-	float	speed_old	= 0.0;
-
-	int		wait_key	= 0;
+	float	speed_old = 0.1;
+
+	int		key_now;

 	lcd.clear();
 	lcd.print("km/h: ");
@@ -119,17 +368,36 @@
 	lcd.setCursor(15, 1);
 	lcd.write(0);

-	while (system_state	== SPEED_STATE) {
+	while (system_state == SPEED_STATE) {
 		if (speed_old > speed_now) {
 			lcd.setCursor(5, 0);
-			lcd.print("    ");
-		}
-		lcd.setCursor(5, 0);
-		lcd.print(speed_now);
-		speed_old	= speed_now;
-
+			lcd.print("		");
+		}
+
+		if (speed_old != speed_now) {
+			lcd.setCursor(5, 0);
+			lcd.print(speed_now);
+			speed_old	= speed_now;
+		}
+
+		/*TIME START*/
 		lcd.setCursor(11, 0);
-		lcd.print("00:00");
+
+		if (hour() < 10) {
+			lcd.print("0");
+		}
+
+		lcd.print(hour());
+		lcd.print(":");
+
+		lcd.setCursor(14, 0);
+
+		if (minute() < 10) {
+			lcd.print("0");
+		}
+
+		lcd.print(minute());
+		/*TIME END*/

 		lcd.setCursor(3, 1);
 		lcd.print(distance);
@@ -141,19 +409,35 @@
 			lcd.print(" ");
 			lcd.print(bat_percent);
 		} else if (bat_percent > 10){
-			lcd.print("  ");
+			lcd.print("	");
 			lcd.print(bat_percent);
 		}

-		for (wait_key	= 0; wait_key < 500; wait_key++, delay(1)) {
-			if ((analogRead(ACTION_BUTTON) >= BUTTON_OK - 10) && (analogRead(ACTION_BUTTON) <= BUTTON_OK + 10)) {
-				while (analogRead(ACTION_BUTTON) < 1000);
-				delay(50);
-				lcd.clear();
-				system_state	= MENU_STATE;
-				break;
-			}
-		}
+		key_now	= analogRead(ACTION_BUTTON);
+
+		#ifdef DEBUG
+		Serial.print("Key in road_mode: ");
+		Serial.println(key_now);
+		#endif
+
+		if ((key_now >= btc_config.BUTTON_OK - 5) && (key_now <= btc_config.BUTTON_OK + 5)) {
+			while (analogRead(ACTION_BUTTON) > 5);
+			delay(50);
+			lcd.clear();
+			system_state	= MENU_STATE;
+			break;
+		}
+
+		sys_watch();
+	}
+}
+
+void first_on() {
+	lcd.clear();
+	lcd.print("Hello!");
+
+	for (byte	i = 0; i < 255; i++, delay(4)) {
+		analogWrite(DISPLAY_LIGHT, i);
 	}
 }

@@ -162,6 +446,8 @@

 	byte	selected		= 0,
 			on_display		= 0;
+
+	int	 key_now;

 	bool	key_pressed_ok	= true;

@@ -170,10 +456,10 @@
 			if (selected == on_display) {
 				lcd.setCursor(0,0);
 				lcd.print(">");
-				lcd.setCursor(0,1);
+				lcd.setCursor(0,1);
 				lcd.print(" ");
 			} else {
-				lcd.setCursor(0,1);
+				lcd.setCursor(0,1);
 				lcd.print(">");
 				lcd.setCursor(0,0);
 				lcd.print(" ");
@@ -190,82 +476,41 @@

 		key_pressed_ok	= true;

-		switch (key_pressed()) {
-
-			case BUTTON_OK:		return selected;
-								break;
-
-			case BUTTON_LEFT:	if (selected != 0) {
-									if (selected == on_display) {
-										lcd.clear();
-										on_display	-= 2;
-									}
-
-									selected--;
-								}
-								break;
-
-			case BUTTON_RIGHT:	if (selected < all_element - 1) {
-									if (selected == (on_display + 1)) {
-										lcd.clear();
-										on_display	+= 2;
-									}
-
-									selected++;
-								}
-								break;
-
-			default:			key_pressed_ok	= false;
-								break;
-		}
-	}
-}
-
-void setup() {
-	#ifdef DEBUG
-	Serial.begin(9600);
-	#endif
-
-	/*Инициализация дисплея*/
-	lcd.begin();
-	// lcd.backlight();
-
-	/*Инициализация выводов для сигнала*/
-	pinMode(BIP, OUTPUT);
-	digitalWrite(BIP, LOW);
-
-	/*Прерывание на 2-ом цифровом канале для сигнализации*/
-	attachInterrupt(0, alarm, CHANGE);
-
-	/*Прерывание на 3-ем цифровом канале для подсчёта скорости*/
-	attachInterrupt(1, speed, CHANGE);
-
-	lcd.createChar(0, bat_icon);
-
-	#ifdef FIRST_ON
-	sys_conf load_to_eeprom;
-
-	load_to_eeprom.password[0]		= 1;
-	load_to_eeprom.password[1]		= 2;
-	load_to_eeprom.password[2]		= 3;
-	load_to_eeprom.password[3]		= 4;
-	load_to_eeprom.red_speed		= true;
-	load_to_eeprom.time_to_slpeep	= 5;
-	load_to_eeprom.auto_led			= true;
-	load_to_eeprom.auto_headlights	= true;
-	load_to_eeprom.distance			= 0.0;
-	load_to_eeprom.max_speed		= 0.0;
-
-	WriteSysConfEEPROM(load_to_eeprom, 0);
-	lcd.print("All OK!");
-	#endif
-}
-
-void WriteSysConfEEPROM(sys_conf str, int base) {	// Запись и чтение выполнены великолепным программистом Виктором Охотниковым
+		key_now = key_pressed();
+		Serial.print("key_now: ");
+		Serial.println(key_now);
+
+		if (key_now == btc_config.BUTTON_OK) {
+			return selected;
+		} else if (key_now == btc_config.BUTTON_UP) {
+			if (selected != 0) {
+				if (selected == on_display) {
+					lcd.clear();
+					on_display	-= 2;
+				}
+
+				selected--;
+			}
+		} else if (key_now == btc_config.BUTTON_DOWN) {
+			if (selected < all_element - 1) {
+				if (selected == (on_display + 1)) {
+					lcd.clear();
+					on_display	+= 2;
+				}
+
+				selected++;
+			}
+		} else {
+			key_pressed_ok	= false;
+		}
+	}
+}
+
+void WriteSysConfEEPROM(sys_conf str, int base) { // Запись и чтение выполнены великолепным программистом Виктором Охотниковым
 	char	*c;
-	int		structSize = sizeof(sys_conf);
-
-	c	= (char *) &str;
+	int	 structSize = sizeof(sys_conf);
+
+	c = (char *) &str;

 	for(int i = 0; i < structSize; i++) {
 		EEPROM.write(i+base, *c);
@@ -275,9 +520,9 @@

 void ReadSysConfEEPROM(sys_conf *str, int base) {
 	char	*c;
-	int		structSize = sizeof(sys_conf);
-
-	c	= (char *) str;
+	int	 structSize = sizeof(sys_conf);
+
+	c = (char *) str;

 	for(int i = 0; i < structSize; i++) {
 		*c = EEPROM.read(i+base);
@@ -285,87 +530,14 @@
 	}
 }

-void loop() {
-	if (system_state == LOAD_STATE) {
-		lcd.clear();
-		lcd.print("Loading system..");
-		lcd.setCursor(0, 1);
-		lcd.print("Version: ");
-		lcd.print(VERSION);
-		delay(3000);
-		system_state	= SPEED_STATE;
-	}
-
-	if (system_state == SPEED_STATE) {
-		road_mode();
-	}
-
-	if (system_state == MENU_STATE) {
-		char menu_array[3][15]	= {
-			"Speedometr",
-			"Statistik",
-			"Settings"
-		};
-
-		switch (display_list(3, menu_array)) {
-			case 0:	system_state	= SPEED_STATE;
-					break;
-
-			case 2:	system_state	= SETTINGS_STATE;
-					break;
-		}
-	}
-
-	if (system_state == SETTINGS_STATE) {
-		char settings_array[3][15]	= {
-			"Password",
-			"About system",
-			"Back"
-		};
-
-		switch (display_list(3, settings_array)) {
-			case 0:	input_password();
-					break;
-
-			case 2:	system_state	= MENU_STATE;
-					break;
-		}
-	}
-}
-
-void alarm() {	// Сигнализация
-	if ((!alarm_state) && (system_state == 1)) {
-		alarm_state	= true;
-
-		for (int	i = 0; i < BIP_DELAY; i++) {
-			digitalWrite(BIP, HIGH);
-			delay(250);
-			digitalWrite(BIP, LOW);
-			delay(250);
-		}
-
-		alarm_state	= false;
-	}
-}
-
-void speed() {	// Подсчёт скорости
-	if ((millis() - lastturn) > 80) {	// Защита от случайных измерений (основано на том, что велосипед не будет ехать быстрее 120 кмч)
-		speed_now	= WHEEL_LENGTH / ((float)(millis() - lastturn) / 1000) * 3.6;	// Расчет скорости, км/ч
-		lastturn	= millis();														// Запомнить время последнего оборота
-		distance	= distance + WHEEL_LENGTH / 1000;								// Прибавляем длину колеса к дистанции при каждом обороте
-	}
-}
-
-
-
 void input_password() {
 	lcd.clear();			// Очистка экрана
 	lcd.print("New password");

-	lcd.setCursor(1, 0);	// Установка указателя в левый верхний угол
+	lcd.setCursor(0, 1);	// Установка указателя в левый верхний угол
 	lcd.print("Password: ");

-	for (byte	i	= 0; i < 6; i++) {
+	for (byte i = 0; i < 6; i++) {
 		btc_config.password[i]	= key_pressed();
 		lcd.print("*");
 	}
@@ -376,17 +548,17 @@
 }

 bool read_password() {
-	bool	wrong	= false;
+	bool	wrong = false;

 	lcd.clear();			// Очистка экрана
 	lcd.print("Current password");

-	lcd.setCursor(1, 0);	// Установка указателя в левый верхний угол
+	lcd.setCursor(0, 1);	// Установка указателя в левый верхний угол
 	lcd.print("Password: ");

-	for (byte	i	= 0; i < 6; i++) {
+	for (byte i = 0; i < 6; i++) {
 		if (btc_config.password[i]	!= key_pressed()) {
-			wrong	= true;
+			wrong = true;
 		}

 		lcd.print("*");
@@ -395,9 +567,98 @@
 	lcd.clear();
 	if (wrong) {
 		lcd.print("Incorrect!");
+		delay(2000);
+		return	false;
 	} else {
 		lcd.print("Pass!");
-	}
-
-	delay(2000);
-}+		delay(2000);
+		return	true;
+	}
+
+	return false;
+}
+
+void colibration() {
+	byte	key_num = 0;
+
+	while (key_num != 3) {
+		while (analogRead(ACTION_BUTTON) > 5);
+		lcd.clear();
+
+		if (key_num == 0) {
+			lcd.print("Press OK key");
+			lcd.setCursor(0, 1);
+
+			while ((btc_config.BUTTON_OK = analogRead(ACTION_BUTTON)) < 5);
+
+			lcd.print(btc_config.BUTTON_OK);
+			key_num++;
+			continue;
+		}
+
+		if (key_num == 1) {
+			lcd.print("Press UP key");
+			lcd.setCursor(0, 1);
+
+			while ((btc_config.BUTTON_UP = analogRead(ACTION_BUTTON)) < 5);
+
+			lcd.print(btc_config.BUTTON_UP);
+			key_num++;
+			continue;
+		}
+
+		if (key_num == 2) {
+			lcd.print("Press DOWN key");
+			lcd.setCursor(0, 1);
+
+			while ((btc_config.BUTTON_DOWN = analogRead(ACTION_BUTTON)) < 5);
+
+			lcd.print(btc_config.BUTTON_DOWN);
+			key_num++;
+			continue;
+		}
+
+		/*if (key_num == 0) {
+			lcd.print("Press OK key");
+			lcd.setCursor(1, 0);
+
+			while ((btc_config.BUTTON_OK = analogRead(ACTION_BUTTON)) < 5);
+
+			lcd.print(btc_config.BUTTON_OK);
+			key_num++;
+		}*/
+
+	}
+
+	while (analogRead(ACTION_BUTTON) > 5);
+}
+
+#ifdef DEBUG
+void self_test() {
+	lcd.clear();
+	lcd.print("Light sensor");
+
+	while (analogRead(ACTION_BUTTON) < 5) {
+		lcd.setCursor(0, 1);
+		lcd.print("    ");
+		lcd.setCursor(0, 1);
+		lcd.print(analogRead(LIGHT_SENSOR));
+		delay(500);
+	}
+
+	lcd.clear();
+	lcd.print("Key test");
+
+	while (analogRead(ACTION_BUTTON) > 5);
+
+	while (analogRead(ACTION_BUTTON) != btc_config.BUTTON_OK) {
+		lcd.setCursor(0, 1);
+		lcd.print("    ");
+		lcd.setCursor(0, 1);
+		lcd.print(analogRead(ACTION_BUTTON));
+		delay(500);
+	}
+
+	while (analogRead(ACTION_BUTTON) > 5);
+}
+#endif


correct min repeat wrong macro assignment for GICABLE (#494)

GICABLE "repeat" was assigned to GICABLE_BITS instead of GICABLE_MIN_REPEAT

--- examples/IRMQTTServer/IRMQTTServer.ino
+++ examples/IRMQTTServer/IRMQTTServer.ino
@@ -1261,7 +1261,7 @@
     case GICABLE:  // 43
       if (bits == 0)
         bits = GICABLE_BITS;
-      repeat = std::max(repeat, (uint16_t) GICABLE_BITS);
+      repeat = std::max(repeat, (uint16_t) GICABLE_MIN_REPEAT);
       irsend.sendGICable(code, bits, repeat);
       break;
 #endif


Flush in the busy loop so the interrupt is faster

--- examples/SDCardLogger/SDCardLogger.ino
+++ examples/SDCardLogger/SDCardLogger.ino
@@ -12,7 +12,6 @@
   str = radiationWatch.printStatus();
   Serial.println(str);
   dataFile.println(str);
-  dataFile.flush();
 }

 void setup()
@@ -44,4 +43,5 @@
 void loop()
 {
   radiationWatch.loop();
+  dataFile.flush();
 }


update 2Network example

update 2Network example

--- examples/DMX2Ethernet/DMX2Ethernet.ino
+++ examples/DMX2Ethernet/DMX2Ethernet.ino
@@ -43,10 +43,14 @@
 #if defined ( ETHERNET_SHIELD_V2 )
 #include <Ethernet2.h>
 #include <EthernetUdp2.h>
+#include <utility/w5500.h>
 #else
 #include <Ethernet.h>
 #include <EthernetUdp.h>
+#include <utility/w5100.h>
 #endif
+
+#include <IPAddress.h>

 #include <LXDMXEthernet.h>
@@ -67,19 +71,16 @@

 #define USE_DHCP 1
 #define USE_SACN 1
-
-//  Uncomment to use multicast, which requires extended Ethernet library
-//  see note in LXDMXEthernet.h file about method added to library
-
-#define USE_MULTICAST 1
+// comment out next line for unicast sACN
+//#define USE_MULTICAST 1

 #define MAC_ADDRESS 0x90, 0xA2, 0xDA, 0x10, 0x6C, 0xA8
 #define IP_ADDRESS 192,168,1,20
 #define GATEWAY_IP 192,168,1,1
 #define SUBNET_MASK 255,255,255,0
 #define BROADCAST_IP 192,168,1,255
-
-#define TARGET_IP 192,168,1,12
+// this is the IP address to which output packets are sent, unless multicast is used
+#define TARGET_IP 192,168,1,255

 // this sketch flashes an indicator led:
 #define LED_PIN 3
@@ -176,8 +177,8 @@
   LXSerialDMX.startInput();

   if ( use_multicast ) {
-    //eUDP.begin(interface->dmxPort());
-    eUDP.beginMulticast(send_address,  interface->dmxPort());
+    //eUDP.beginMulticast(send_address,  interface->dmxPort() - 1);
+    eUDP.begin(interface->dmxPort());
   } else {
     eUDP.begin(interface->dmxPort());
   }
@@ -206,12 +207,10 @@
     for(int i=1; i<=got_dmx; i++) {
       interface->setSlot(i, LXSerialDMX.getSlot(i));
     }
-    if ( got_dmx > 500 ) {
-      analogWrite(LED_PIN, interface->getSlot(2));
-    }
+    blinkLED();

     interface->sendDMX(&eUDP, send_address);
-
+
     got_dmx = 0;
   } else {
     digitalWrite(LED_PIN, LOW);


Clean up SpeedTest output, avoid div-by-0 (#8340)

Use a formatting function to give more human-readable output formats
for flash bandwidth.  When the test starts and ends in less than one
millisecond, report as "Infinite".

Sample output:
````
Creating 512KB file, may take a while...
==> Time to write 512KB in 256b chunks = 6641 milliseconds
==> Created file size = 524288
Reading 512KB file sequentially in 256b chunks
==> Time to read 512KB sequentially in 256b chunks = 211 milliseconds = 2.48 MB/s
Reading 512KB file MISALIGNED in flash and RAM sequentially in 256b chunks
==> Time to read 512KB sequentially MISALIGNED in flash and RAM in 256b chunks = 212 milliseconds = 2.47 MB/s
Reading 512KB file in reverse by 256b chunks
==> Time to read 512KB in reverse in 256b chunks = 367 milliseconds = 1.43 MB/s
Writing 64K file in 1-byte chunks
==> Time to write 64KB in 1b chunks = 1249 milliseconds = 52.47 KB/s
Reading 64K file in 1-byte chunks
==> Time to read 64KB in 1b chunks = 296 milliseconds = 221.41 KB/s
````

--- libraries/LittleFS/examples/SpeedTest/SpeedTest.ino
+++ libraries/LittleFS/examples/SpeedTest/SpeedTest.ino
@@ -13,6 +13,25 @@

 // How large of a file to test
 #define TESTSIZEKB 512
+
+// Format speed in bytes/second.  Static buffer so not re-entrant safe
+const char *rate(unsigned long start, unsigned long stop, unsigned long bytes) {
+  static char buff[64];
+  if (stop == start) {
+    strcpy_P(buff, PSTR("Inf b/s"));
+  } else {
+    unsigned long delta = stop - start;
+    float r = 1000.0 * (float)bytes / (float)delta;
+    if (r >= 1000000.0) {
+      sprintf_P(buff, PSTR("%0.2f MB/s"), r / 1000000.0);
+    } else if (r >= 1000.0) {
+      sprintf_P(buff, PSTR("%0.2f KB/s"), r / 1000.0);
+    } else {
+      sprintf_P(buff, PSTR("%d bytes/s"), (int)r);
+    }
+  }
+  return buff;
+}

 void DoTest(FS *fs) {
   if (!fs->format()) {
@@ -30,7 +49,7 @@
   }

   Serial.printf("Creating %dKB file, may take a while...\n", TESTSIZEKB);
-  long start = millis();
+  unsigned long start = millis();
   File f = fs->open("/testwrite.bin", "w");
   if (!f) {
     Serial.printf("Unable to open file for writing, aborting\n");
@@ -42,8 +61,8 @@
     }
   }
   f.close();
-  long stop = millis();
-  Serial.printf("==> Time to write %dKB in 256b chunks = %ld milliseconds\n", TESTSIZEKB, stop - start);
+  unsigned long stop = millis();
+  Serial.printf("==> Time to write %dKB in 256b chunks = %lu milliseconds\n", TESTSIZEKB, stop - start);

   f = fs->open("/testwrite.bin", "r");
   Serial.printf("==> Created file size = %d\n", f.size());
@@ -59,7 +78,7 @@
   }
   f.close();
   stop = millis();
-  Serial.printf("==> Time to read %dKB sequentially in 256b chunks = %ld milliseconds = %ld bytes/s\n", TESTSIZEKB, stop - start, TESTSIZEKB * 1024 / (stop - start) * 1000);
+  Serial.printf("==> Time to read %dKB sequentially in 256b chunks = %lu milliseconds = %s\n", TESTSIZEKB, stop - start, rate(start, stop, TESTSIZEKB * 1024));

   Serial.printf("Reading %dKB file MISALIGNED in flash and RAM sequentially in 256b chunks\n", TESTSIZEKB);
   start = millis();
@@ -72,8 +91,7 @@
   }
   f.close();
   stop = millis();
-  Serial.printf("==> Time to read %dKB sequentially MISALIGNED in flash and RAM in 256b chunks = %ld milliseconds = %ld bytes/s\n", TESTSIZEKB, stop - start, TESTSIZEKB * 1024 / (stop - start) * 1000);
-
+  Serial.printf("==> Time to read %dKB sequentially MISALIGNED in flash and RAM in 256b chunks = %lu milliseconds = %s\n", TESTSIZEKB, stop - start, rate(start, stop, TESTSIZEKB * 1024));

   Serial.printf("Reading %dKB file in reverse by 256b chunks\n", TESTSIZEKB);
   start = millis();
@@ -92,8 +110,7 @@
   }
   f.close();
   stop = millis();
-  Serial.printf("==> Time to read %dKB in reverse in 256b chunks = %ld milliseconds = %ld bytes/s\n", TESTSIZEKB, stop - start, TESTSIZEKB * 1024 / (stop - start) * 1000);
-
+  Serial.printf("==> Time to read %dKB in reverse in 256b chunks = %lu milliseconds = %s\n", TESTSIZEKB, stop - start, rate(start, stop, TESTSIZEKB * 1024));

   Serial.printf("Writing 64K file in 1-byte chunks\n");
   start = millis();
@@ -103,7 +120,7 @@
   }
   f.close();
   stop = millis();
-  Serial.printf("==> Time to write 64KB in 1b chunks = %ld milliseconds = %ld bytes/s\n", stop - start, 65536 / (stop - start) * 1000);
+  Serial.printf("==> Time to write 64KB in 1b chunks = %lu milliseconds = %s\n", stop - start, rate(start, stop, 65536));

   Serial.printf("Reading 64K file in 1-byte chunks\n");
   start = millis();
@@ -114,9 +131,7 @@
   }
   f.close();
   stop = millis();
-  Serial.printf("==> Time to read 64KB in 1b chunks = %ld milliseconds = %ld bytes/s\n", stop - start, 65536 / (stop - start) * 1000);
-
-
+  Serial.printf("==> Time to read 64KB in 1b chunks = %lu milliseconds = %s\n", stop - start, rate(start, stop, 65536));
 }

 void setup() {


fix code

fix code

--- little-switches/arduino/3_setup-rel/3_setup-rel.ino
+++ little-switches/arduino/3_setup-rel/3_setup-rel.ino
@@ -15,8 +15,6 @@
 long t6 = 0;
 long t7 = 0;
 long t8 = 0;
-long t9 = 0;
-long t0 = 0;

 int tempo = 0;

@@ -32,19 +30,17 @@
   pinMode(6,OUTPUT);
   pinMode(7,OUTPUT);
   pinMode(8,OUTPUT);
-  pinMode(9,OUTPUT);
   pinMode(A0,OUTPUT);
   pinMode(A1,OUTPUT);

-  digitalWrite(2,LOW);
-  digitalWrite(4,LOW);
-  digitalWrite(5,LOW);
-  digitalWrite(6,LOW);
-  digitalWrite(7,LOW);
-  digitalWrite(8,LOW);
-  digitalWrite(9,LOW);
-  digitalWrite(A0,LOW);
-  digitalWrite(A1,LOW);
+  digital(2,OUTPUT);
+  pinMode(4,OUTPUT);
+  pinMode(5,OUTPUT);
+  pinMode(6,OUTPUT);
+  pinMode(7,OUTPUT);
+  pinMode(8,OUTPUT);
+  pinMode(A0,OUTPUT);
+  pinMode(A1,OUTPUT);

 }

@@ -52,11 +48,81 @@
   tempo = map(analogRead(pot),0,1023,50,200);

   if (keyboard.available()) {
-
+
+    // read the next key
     char c = keyboard.read();

-    Serial.println(c);
+    // check for some of the special keys
+    if (c == '1') {
+      digitalWrite(2,HIGH);
+      t1 = millis();
+    }
+    else if (c == '2') {
+      digitalWrite(4,HIGH);
+      t2 = millis();
+    }
+    else if (c == '3') {
+      digitalWrite(5,HIGH);
+      t3 = millis();
+    }
+    else if (c == '4') {
+      digitalWrite(6,HIGH);
+      t4 = millis();
+    }
+    else if (c == '5') {
+      digitalWrite(7,HIGH);
+      t5 = millis();
+    }
+    else if (c == '6') {
+      digitalWrite(8,HIGH);
+      t6 = millis();
+    }
+    else if (c == '7') {
+      digitalWrite(A0,HIGH);
+      t7 = millis();
+    }
+    else if (c == '8') {
+      digitalWrite(A1,HIGH);
+      t8 = millis();
+    }
+    else if (c == '9') {
+      digitalWrite(A2,HIGH);
+      t9 = millis();
+    }
+    else if (c == '0') {
+      digitalWrite(A3,HIGH);
+      t0 = millis();
+    }
+    else {
+      Serial.print(c);
+    }
   }

+  else {
+    if ((millis() - t1) > tempo) {
+      digitalWrite(2,LOW);
+    }
+    if ((millis() - t2) > tempo) {
+      digitalWrite(4,LOW);
+    }
+    if ((millis() - t3) > tempo) {
+      digitalWrite(5,LOW);
+    }
+    if ((millis() - t4) > tempo) {
+      digitalWrite(6,LOW);
+    }
+    if ((millis() - t5) > tempo) {
+      digitalWrite(7,LOW);
+    }
+    if ((millis() - t6) > tempo) {
+      digitalWrite(8,LOW);
+    }
+    if ((millis() - t7) > tempo) {
+      digitalWrite(A0,LOW);
+    }
+    if ((millis() - t8) > tempo) {
+      digitalWrite(A1,LOW);
+    }

+  }
 }


bug fixed

bug fixed

--- arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot_waffle/turtlebot3_core/turtlebot3_core.ino
+++ arduino/opencr_arduino/opencr/libraries/turtlebot3/turtlebot_waffle/turtlebot3_core/turtlebot3_core.ino
@@ -184,10 +184,7 @@
     publishImuMsg();
     tTime[3] = millis();
   }
-
-  publishSensorStateMsg();
-  publishDriveInformation();
-
+
   // Check push button pressed for simple test drive
   checkPushButtonState();


add full scale generator code

add full scale generator code

--- examples/UNTZtrument_Step_Seq/UNTZtrument_Step_Seq.ino
+++ examples/UNTZtrument_Step_Seq/UNTZtrument_Step_Seq.ino
@@ -27,6 +27,7 @@
 // switch grids on measure bars so you you can change earlier than at the end of a grid, less waiting.
 // Add some multi colored LED underneath to dance to the music
 // add eeprom write progress bar
+// store beat sequences that can be used instead of a fixed beat on a measure, allows for more complex beats to be used.

 #include <Wire.h>
 #include <EEPROM.h>
@@ -219,45 +220,191 @@
 };

 /*
-// could store these at 16 bit numbers with byte length embedded in the top 4 bits
- static const uint8_t majorScale[7] = {
- 0,2,4,5,7,9,11};
- static const uint8_t minorScale[7] = {
- 0,2,3,5,7,8,10};
- static const uint8_t chromaticScale[12] = {
- 0,1,2,3,4,5,6,7,8,9,10,11};
- static const uint8_t bluesScale[] = {
- 0,3,5,6,7,10};
- static const uint8_t bluesdiminishedScale[]={
- 0,1,3,4,6,7,9,10};
- static const uint8_t fullMinorScale[]={
- 0,2,3,5,7,8,9,10,11};
- static const uint8_t harmonicMajorScale[]={
- 0,2,4,5,7,8,11};
- static const uint8_t harmonicMinorScale[]={
- 0,2,3,5,7,8,11};
- static const uint8_t jazzminorScale[]={
- 0,2,3,5,7,9,11};
- static const uint8_t hawaiianScale[]={
- 0,2,3,7,9,11};
- static const uint8_t orientalScale[]={
- 0,1,4,5,6,9,10};
- static const uint8_t majorMinotScale[]={
- 0,2,4,5,6,7,10};
-
- uint8_t notes[MAX_MIDI_NOTES];
-
- void makenotes(uint8_t * scale, uint8_t length)
- {
- for (int index = 0; index < MAX_MIDI_NOTES/2; index++)
- {
- uint8_t scale_offset = ((index / length) * 12);
- uint8_t index_wrap = (index % length);
- notes[MAX_MIDI_NOTES/2 + index] = MIDI_MIDDLE_C - (12 - scale[length - 1 - index_wrap]) - scale_offset;
- notes[MAX_MIDI_NOTES/2 - index - 1] = MIDI_MIDDLE_C + scale[index_wrap] + scale_offset;
- }
- }
- */
+// ConsoleApplication1.cpp : main project file.
+
+#include "stdafx.h"
+
+using namespace System;
+
+#define uint8_t unsigned char
+#define MIDI_MIDDLE_C 60
+#define MAX_MIDI_NOTES 56
+uint8_t notes[MAX_MIDI_NOTES];
+
+// todo need to store these at 16 bit numbers with byte length embedded in the top 4 bits, or store unpacked in program memory
+static const uint8_t majorScale[7] = {
+	0, 2, 4, 5, 7, 9, 11 };
+static const uint8_t minorScale[7] = {
+	0, 2, 3, 5, 7, 8, 10 };
+static const uint8_t chromaticScale[12] = {
+	0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
+static const uint8_t bluesScale[] = {
+	0, 3, 5, 6, 7, 10 };
+static const uint8_t bluesDiminishedScale[] = {
+	0, 1, 3, 4, 6, 7, 9, 10 };
+static const uint8_t fullMinorScale[] = {
+	0, 2, 3, 5, 7, 8, 9, 10, 11 };
+static const uint8_t harmonicMajorScale[] = {
+	0, 2, 4, 5, 7, 8, 11 };
+static const uint8_t harmonicMinorScale[] = {
+	0, 2, 3, 5, 7, 8, 11 };
+static const uint8_t jazzMinorScale[] = {
+	0, 2, 3, 5, 7, 9, 11 };
+static const uint8_t hawaiianScale[] = {
+	0, 2, 3, 7, 9, 11 };
+static const uint8_t orientalScale[] = {
+	0, 1, 4, 5, 6, 9, 10 };
+static const uint8_t majorMinorScale[] = {
+	0, 2, 4, 5, 6, 7, 10 };
+
+
+static const uint8_t genusChromaticum[] = {
+	0, 1, 3, 4, 5, 7, 8, 9, 11 };
+static const uint8_t dorian[] = {
+	0, 2, 3, 5, 7, 9, 10 };
+static const uint8_t indian[] = {
+	0, 1, 1, 4, 5, 8, 10 };
+static const uint8_t locrian[] = {
+	0, 1, 3, 5, 6, 8, 10 };
+static const uint8_t lydian[] = {
+	0, 2, 4, 6, 7, 9, 10 };
+static const uint8_t melodicMinor[] = {
+	0, 2, 3, 5, 7, 8, 9, 10, 11 };
+static const uint8_t mixolydian[] = {
+	0, 2, 4, 5, 7, 9, 10 };
+static const uint8_t pentatonic[] = {
+	0, 2, 4, 7, 9 };
+static const uint8_t phrygian[] = {
+	0, 1, 3, 5, 7, 8, 10 };
+static const uint8_t turkish[] = {
+	0, 1, 3, 5, 7, 10, 11 };
+static const uint8_t wholeHalf[] = {
+	0, 2, 3, 4, 5, 7, 9, 10, 11 };
+static const uint8_t wholeTone[] = {
+	0, 2, 4, 6, 8, 10 };
+static const uint8_t spanish[] = {
+	0, 1, 3, 4, 5, 6, 8, 10 };
+static const uint8_t pelog[] = {
+	0, 1, 3, 4, 7, 8 };
+static const uint8_t kumoi[] = {
+	0, 2, 3, 7, 9 };
+static const uint8_t iwato[] = {
+	0, 1, 5, 6, 10 };
+static const uint8_t inSen[] = {
+	0, 1, 5, 7, 10 };
+static const uint8_t hirojoshi[] = {
+	0, 2, 3, 7, 8 };
+static const uint8_t hungarianMinor[] = {
+	0, 2, 3, 6, 7, 8, 11 };
+static const uint8_t bhairav[] = {
+	0, 1, 4, 5, 7, 8, 11 };
+static const uint8_t superLocrian[] = {
+	0, 1, 3, 4, 6, 8, 10 };
+static const uint8_t minorPentatonic[] = {
+	0, 3, 5, 7, 10 };
+
+void makenotes(uint8_t * scale, uint8_t length)
+{
+	for (int index = 0; index < MAX_MIDI_NOTES / 2; index++)
+	{
+		uint8_t scale_offset = ((index / length) * 12);
+		uint8_t index_wrap = (index % length);
+		notes[MAX_MIDI_NOTES / 2 + index] = MIDI_MIDDLE_C - (12 - scale[length - 1 - index_wrap]) - scale_offset;
+		notes[MAX_MIDI_NOTES / 2 - index - 1] = MIDI_MIDDLE_C + scale[index_wrap] + scale_offset;
+	}
+}
+
+void printnotes(String ^name)
+{
+	int index;
+
+	//Console::Write(name);
+	Console::Write("{");
+	for ( index = 0; index < MAX_MIDI_NOTES - 1; index++)
+	{
+		Console::Write(notes[index]);
+		Console::Write(", ");
+	}
+	Console::Write(notes[index]);
+	Console::WriteLine("} ,");
+}
+
+int main(array<System::String ^> ^args)
+{
+	Console::Write("scales[MAX_SCALES][MAX_MIDI_NOTES] = {");
+	makenotes((uint8_t *)majorScale, sizeof(majorScale));
+	printnotes("majorScale");
+	makenotes((uint8_t *)minorScale, sizeof(minorScale));
+	printnotes("minorScale");
+	makenotes((uint8_t *)chromaticScale, sizeof(chromaticScale));
+	printnotes("chromaticScale");
+	makenotes((uint8_t *)bluesScale, sizeof(bluesScale));
+	printnotes("bluesScale");
+	makenotes((uint8_t *)bluesDiminishedScale, sizeof(bluesDiminishedScale));
+	printnotes("bluesDiminishedScale");
+	makenotes((uint8_t *)fullMinorScale, sizeof(fullMinorScale));
+	printnotes("fullMinorScale");
+	makenotes((uint8_t *)harmonicMajorScale, sizeof(harmonicMajorScale));
+	printnotes("harmonicMajorScale");
+	makenotes((uint8_t *)harmonicMinorScale, sizeof(harmonicMinorScale));
+	printnotes("harmonicMinorScale");
+	makenotes((uint8_t *)jazzMinorScale, sizeof(jazzMinorScale));
+	printnotes("jazzMinorScale");
+	makenotes((uint8_t *)hawaiianScale, sizeof(hawaiianScale));
+	printnotes("hawaiianScale");
+	makenotes((uint8_t *)orientalScale, sizeof(orientalScale));
+	printnotes("orientalScale");
+	makenotes((uint8_t *)majorMinorScale, sizeof(majorMinorScale));
+	printnotes("majorMinorScale");
+
+	makenotes((uint8_t *)genusChromaticum, sizeof(genusChromaticum));
+	printnotes("genusChromaticum");
+	makenotes((uint8_t *)dorian, sizeof(dorian));
+	printnotes("dorian");
+	makenotes((uint8_t *)indian, sizeof(indian));
+	printnotes("indian");
+	makenotes((uint8_t *)locrian, sizeof(locrian));
+	printnotes("locrian");
+	makenotes((uint8_t *)lydian, sizeof(lydian));
+	printnotes("lydian");
+	makenotes((uint8_t *)melodicMinor, sizeof(melodicMinor));
+	printnotes("melodicMinor");
+	makenotes((uint8_t *)mixolydian, sizeof(mixolydian));
+	printnotes("mixolydian");
+	makenotes((uint8_t *)pentatonic, sizeof(pentatonic));
+	printnotes("pentatonic");
+	makenotes((uint8_t *)phrygian, sizeof(phrygian));
+	printnotes("phrygian");
+	makenotes((uint8_t *)turkish, sizeof(turkish));
+	printnotes("turkish");
+	makenotes((uint8_t *)wholeHalf, sizeof(wholeHalf));
+	printnotes("wholeHalf");
+	makenotes((uint8_t *)wholeTone, sizeof(wholeTone));
+	printnotes("wholeTone");
+	makenotes((uint8_t *)spanish, sizeof(spanish));
+	printnotes("spanish");
+	makenotes((uint8_t *)pelog, sizeof(pelog));
+	printnotes("pelog");
+	makenotes((uint8_t *)kumoi, sizeof(kumoi));
+	printnotes("kumoi");
+	makenotes((uint8_t *)iwato, sizeof(iwato));
+	printnotes("iwato");
+	makenotes((uint8_t *)inSen, sizeof(inSen));
+	printnotes("inSen");
+	makenotes((uint8_t *)hirojoshi, sizeof(hirojoshi));
+	printnotes("hirojoshi");
+	makenotes((uint8_t *)hungarianMinor, sizeof(hungarianMinor));
+	printnotes("hungarianMinor");
+	makenotes((uint8_t *)bhairav, sizeof(bhairav));
+	printnotes("bhairav");
+	makenotes((uint8_t *)superLocrian, sizeof(superLocrian));
+	printnotes("superLocrian");
+	makenotes((uint8_t *)minorPentatonic, sizeof(minorPentatonic));
+	printnotes("minorPentatonic");
+	Console::Write("};");
+	return 0;
+}
+*/

 void saveToEEPROM(int eepromAddress, uint8_t * source, int length)
 {


New lights initalizer

New lights initalizer

--- mutually-assured-destruction.ino
+++ mutually-assured-destruction.ino
@@ -19,28 +19,30 @@
 #define LED 13
 #define RELAY_0_PIN 10
 #define RELAY_1_PIN 9
-#define NEOPIXEL_PIN 8
+#define NEOPIXEL_PIN_A 8
+#define NEOPIXEL_PIN_B -1
 #define NEOPIXEL_COUNT 12
-
 #define FIRE_BURST_SHORT_DURATION 200
-

 void setup() {
   // put your setup code here, to run once:

 	Serial.begin(9600);
-        Serial.println("It's a MAD World!");

 	relay_setup();

+        Serial.println("It's a MAD World!");
+
 	digitalWrite(LED, HIGH);
-	delay(2500);
+	delay(1000);
 	digitalWrite(LED, LOW);
-	delay(2500);
+	delay(1000);

-	lights = new Lights(NEOPIXEL_PIN, NEOPIXEL_COUNT);
+	lights = new Lights(NEOPIXEL_PIN_A, NEOPIXEL_PIN_B, NEOPIXEL_COUNT);
+        lights->on();

         remote = new RemoteControl(-1);  // note pin is specified in class
+

 }

@@ -62,6 +64,7 @@
   } else if ( remote->last_command == RemoteCommandStart ) {

      stopped = 0;
+     lights->on();

   }

@@ -86,6 +89,7 @@

   r0->loop();
   r1->loop();
+  lights->loop();

   if ( c ) {
    // clear last command


Update example

Update example

--- examples/Boards_GSM/SIM800_SIM900/SIM800_SIM900.ino
+++ examples/Boards_GSM/SIM800_SIM900/SIM800_SIM900.ino
@@ -17,20 +17,8 @@
  * This example shows how to use SIM800 or SIM900 modem series
  * to connect your project to Blynk.
  *
- * TinyGSM Getting Started guide:
+ * Attention! Please check out TinyGSM guide:
  *   http://tiny.cc/tiny-gsm-readme
- *
- * Attention!
- *   1. Using your phone:
- *       Disable PIN code on the SIM card
- *       Check your ballance
- *       Check that APN,User,Pass are correct and you have internet
- *   2. Ensure the sim card is correctly inserted into the module
- *   3. Provide a good, stable power supply (up to 2A)
- *      (4.0-4.2V or 5V according to your module documentation)
- *   4. Provide good, stable serial connection
- *      (Hardware Serial is recommended)
- *   5. Check if GSM antenna is attached
  *
  * WARNING: SIM module support is for BETA testing.
  *


Brian's Version

Brian's Version

--- Teensy-Reactor-Controller.ino
+++ Teensy-Reactor-Controller.ino
@@ -27,13 +27,9 @@

 // Prototypes for the commands.
 command(setPurge);
-command(setAutoPurge);

 // Create a Flag to tell the main loop when the StartPin interrupt has been triggered.
 boolean StartPinFlag = false;
-
-// Create a Flag to tell if AutoPurge is on.
-boolean AutoPurgeFlag = false;

 // Sets the trigger edge for the StartPin signal. 0 is falling, 1 is rising. I am making it
 // an int instead of a define so that you can for instance have a command that changes which
@@ -68,7 +64,6 @@
   // Register the commands created to attach running the function with receiving a starting string over USB Serial.
   // Third argument is a description to be displayed when you send the command ListCommands.
   registerCommand("SetPurge", setPurge, "Set Purge Valve State (0/1)");
-  registerCommand("SetAutoPurge", setAutoPurge, "Sets the Purve Valve to purge automatically after GC takes a sample");
 }

 elapsedMillis elapsed;
@@ -150,27 +145,4 @@

   // and if the argument isn't 0 or 1, return an error.
   else Serial.println("ERROR: Purge valve state invalid (must be 0 or 1).");
-}
-
-
-command(setAutoPurge) {
-  // A quick check that the number of arguments received is correct.
-  // Does not include the command name in the number of arguments.
-  if (numArgs() != 1) {
-    Serial.println("ERROR: SetPurge expects 1 argument, received " + String(numArgs()) + ".");
-    return;
-  }
-
-  // Create a place to put the argument into a real value.
-  int AutoPurgeState = intArg(1);
-
-  // Sets AutoPurgeFlag as true or false to determine whether to initialize AutoPurge sequence.
-  if (AutoPurgeState == 0) {
-    AutoPurgeFlag = false;
-    Serial.println("AutoPurge is set to OFF.")
-  }
-  else if (AutoPurgeState == 1) {
-    AutoPurgeFlag = true;
-    Serial.println("AutoPurge is set to ON.")
-  }
 }


wrk mode

wrk mode

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -251,7 +251,7 @@

   lcd.clear();
   lcd.setCursor(0, 0);
-  lcd.print("Setup :");
+  lcd.print("Setup");
   lcd.setCursor(0, 1);
   lcd.print("Press any button");

@@ -260,14 +260,18 @@

   lcd.clear();
   lcd.setCursor(0, 0);
-  lcd.print("Select pwr src :");
+  lcd.print("Select pwr src");
   lcd.setCursor(0, 1);
   lcd.print("ON: TV OFF: USB");

   boolean pwrSrc = initialise_pwr_src_select();
+
   lcd.clear();
   lcd.setCursor(0, 0);
-  lcd.print(pwrSrc);
+  lcd.print("Select wrk mode");
+  lcd.setCursor(0, 1);
+  lcd.print("ON: TV + thermostat,  OFF: thermostat");
+  lcd.autoscroll();

 /*


extracted "oscillateGently" function from loop()

--- servo-turning-sine-wave/servo-turning-sine-wave.ino
+++ servo-turning-sine-wave/servo-turning-sine-wave.ino
@@ -46,6 +46,11 @@
 }

 void loop()
+{
+  oscillateGently();
+}
+
+void oscillateGently()
 {
   delay(TURN_AROUND_DELAY);
   //  Serial.println("------------------------------------------------------------");


Update UltrasonicHCSR04NewPing.ino

Update UltrasonicHCSR04NewPing.ino

--- UltraSonicRangeFinder/UltraSonicHC-Sr04/NewPing/UltrasonicHCSR04NewPing.ino
+++ UltraSonicRangeFinder/UltraSonicHC-Sr04/NewPing/UltrasonicHCSR04NewPing.ino
@@ -2,7 +2,7 @@

 #define TRIGGER_PIN 12
 #define ECHO_PIN 11
-#define MAX_DISTANCE 300
+#define MAX_DISTANCE 1000

 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

@@ -13,6 +13,10 @@
 void loop() {
    delay(50);
    unsigned int uS = sonar.ping_cm();
+   //Between 3 meters - 10 meters, just assume it is 3 meters
+   if(uS> 300){
+    uS = 300;
+   }
    Serial.print(uS);
    Serial.println("cm");
 }


comments

comments

--- vibrate_alarm_clock_2.ino
+++ vibrate_alarm_clock_2.ino
@@ -5,6 +5,7 @@

 #include "LowPower.h"

+//These two refer to the same pin
 #define LEFT_BUTTON_INT_PIN INT1
 #define LEFT_BUTTON_NORM_PIN 3


Bluetooth and HR added

Bluetooth and HR added

--- acelaso.ino/acelaso.ino.ino
+++ acelaso.ino/acelaso.ino.ino
@@ -13,7 +13,7 @@
 int FRAMAddress = 80; //I2C Address for FRAM
 int interval = 500; //500 ms between advertisement transmission
 int ExpanderAddress = B0111000;
-int samples = TMP006_CFG_8SAMPLE; // # of samples per reading, can be 1/2/4/8/16
+int samples = TMP006_CFG_8SAMPLE; // # of samples per reading, can be 1 / 2 / 4 / 8 / 16
 int lastButtonState = LOW;
 long button_holdtime = 2000;
 int ledflash = 5;
@@ -32,7 +32,6 @@
 #define ON 1
 #define OFF 0

-//------------------------------------------------------------------
 const int SAMPLES_TO_AVERAGE = 5; // samples for smoothing 1 to 10 seem useful 5 is default
 // increase for smoother waveform (with less resolution - slower!)
 int binOut; // 1 or 0 depending on state of heartbeat
@@ -41,15 +40,10 @@
 unsigned long IR1;        // read value from infrared LED1
 unsigned long IR2;       // read value from infrared LED2
 unsigned long IR_total;     // IR LED reads added together
-
-const int portForSI114 = 1;        // change to the JeeNode port number used
-PortI2C myBus (portForSI114);
-PulsePlug pulse (myBus);
-//------------------------------------------------------------------
-
+unsigned int resp, als_vis, als_ir, ps1, ps2, ps3;

 void setup()
-{
+{
   override_uart_limit = true;

   //Wire.begin(); // join i2c bus (address optional for master)
@@ -84,8 +78,8 @@

   //Init Heart Rate Sensor
   //initPulseSensor();
-
-    LED_OFF();
+
+  LED_OFF();
 }

 void expanderWrite(int i2caddr, byte data)
@@ -98,6 +92,7 @@
 void RFduinoBLE_onConnect() {
   Serial.println("RFduino BLE connection successful");
   BLUE_LED_ON();
+  state = POLL_SENSORS;
 }

 void RFduinoBLE_onDisconnect() {
@@ -113,7 +108,7 @@
     GREEN_LED_ON();
   }
   else {
-   LED_OFF();
+    LED_OFF();
   }
 }

@@ -124,8 +119,8 @@
 }

 void RFduinoBLE_onRSSI(int rssi) {
-  Serial.print("RFduino BLE RSSI: ");
-  Serial.println(rssi); // print rssi value via serial
+  //  Serial.print("RFduino BLE RSSI: ");
+  //  Serial.println(rssi); // print rssi value via serial
 }

 void LED_OFF() {
@@ -136,16 +131,16 @@
   expanderWrite(ExpanderAddress, 0x00);
 }

+void GREEN_LED_ON() {
+  expanderWrite(ExpanderAddress, 0xF7);
+}
+
 void RED_LED_ON() {
-  expanderWrite(ExpanderAddress, 0xFE);
+  expanderWrite(ExpanderAddress, 0xEF);
 }

 void BLUE_LED_ON() {
-  expanderWrite(ExpanderAddress, 0xFD);
-}
-
-void GREEN_LED_ON() {
-  expanderWrite(ExpanderAddress, 0xFB);
+  expanderWrite(ExpanderAddress, 0xDF);
 }

 void LED_FLASH() {      //Flash Green LED for a few seconds
@@ -161,6 +156,66 @@
 //--------------------------------------------------------------------------------------------
 // New Code Section for Heart Rate

+int SI1146_Test(int i2caddr) {
+  int id;
+  id = HR_read_reg(SI114_REG_PART_ID, 1);
+  Serial.print("Part id: ");  Serial.println(id);
+  if (id == 0x46)
+    return 1; // look for SI1145
+  //DEVICE FOUND Reset SI1146 Registers
+  return 0;
+}
+
+//This was get reg, num_data is number of bytes to return
+char HR_read_reg(unsigned char address, int num_data) // Read a Register
+{
+  Wire.beginTransmission(HRAddress);
+  Wire.write(address);
+  Wire.endTransmission();
+  Wire.requestFrom(HRAddress, num_data);
+  while (Wire.available() < num_data);
+  return Wire.read();
+}
+
+//This was set reg
+void HR_write_reg(byte address, byte val) {  // Write a resigter
+  Wire.beginTransmission(HRAddress);
+  Wire.write(address);
+  Wire.write(val);
+  Wire.endTransmission();
+}
+
+byte HR_read_param(byte addr) {
+  // read from parameter ram
+  Wire.beginTransmission(HRAddress);
+  Wire.write(SI114_REG_COMMAND);
+  Wire.write(0x80 | addr);
+  Wire.endTransmission();
+  return HR_read_reg(SI114_REG_PARAM_RD, 1);
+}
+
+void HR_write_param(byte addr, byte val) {
+  // write to parameter ram
+  Wire.beginTransmission(HRAddress);
+  Wire.write(SI114_REG_PARAM_WR);
+  Wire.write(val);
+  // auto-increments into SI114_REG_COMMAND
+  Wire.write(0xA0 | addr); // PARAM_SET
+  Wire.endTransmission();
+}
+
+void fetchLedData() {
+  // read only the LED registers as lsb-msb pairs of bytes
+  Wire.beginTransmission(HRAddress);
+  Wire.write(SI114_REG_PS1_DATA0);
+  Wire.endTransmission();
+  byte* p = (byte*) &resp;
+  Wire.requestFrom(HRAddress, 6);
+  while (Wire.available() < 6);
+  p = (byte*) Wire.read();
+  Wire.endTransmission();
+}
+
 float smooth(float data, float filterVal, float smoothedVal) {

   if (filterVal > 1) {     // check to make sure param's are within range
@@ -179,9 +234,13 @@
   static int foundNewFinger, red_signalSize, red_smoothValley;
   static long red_valley, red_Peak, red_smoothRedPeak, red_smoothRedValley,
          red_HFoutput, red_smoothPeak; // for PSO2 calc
-  static  int IR_valley = 0, IR_peak = 0, IR_smoothPeak, IR_smoothValley, binOut, lastBinOut, BPM;
-  static unsigned long lastTotal, lastMillis, IRtotal, valleyTime = millis(), lastValleyTime = millis(), peakTime = millis(), lastPeakTime = millis(), lastBeat, beat;
-  static float IR_baseline, red_baseline, IR_HFoutput, IR_HFoutput2, shiftedOutput, LFoutput, hysterisis;
+  static  int IR_valley = 0, IR_peak = 0, IR_smoothPeak, IR_smoothValley,
+              binOut, lastBinOut, BPM;
+  static unsigned long lastTotal, lastMillis, IRtotal, valleyTime =
+    millis(), lastValleyTime = millis(), peakTime = millis(), lastPeakTime =
+                                 millis(), lastBeat, beat;
+  static float IR_baseline, red_baseline, IR_HFoutput, IR_HFoutput2,
+         shiftedOutput, LFoutput, hysterisis;

   unsigned long total = 0, start;
   int i = 0;
@@ -193,10 +252,10 @@
   start = millis();

   while (i < SAMPLES_TO_AVERAGE) {
-    pulse.fetchLedData();
-    red += pulse.ps1;
-    IR1 += pulse.ps2;
-    IR2 += pulse.ps3;
+    fetchLedData();
+    red += ps1;
+    IR1 += ps2;
+    IR2 += ps3;
     i++;
   }

@@ -224,7 +283,7 @@
   else if (total > 20000L) {   // main running function

     // baseline is the moving average of the signal - the middle of the waveform
-    // the idea here is to keep track of a high frequency signal, HFoutput and a
+    // the idea here is to keep track of a high frequency signal, HF outputand a
     // low frequency signal, LFoutput
     // The LF signal is shifted downward slightly downward (heartbeats are negative peaks)
     // The high freq signal has some hysterisis added.
@@ -249,10 +308,12 @@

     // default reset - only if reset fails to occur for 1800 ms
     if (millis() - lastPeakTime > 1800) { // reset peak detector slower than lowest human HB
-      IR_smoothPeak =  smooth((float)IR_peak, 0.6, (float)IR_smoothPeak);  // smooth peaks
+      IR_smoothPeak =  smooth((float)IR_peak, 0.6, (float)IR_smoothPeak);
+      // smooth peaks
       IR_peak = 0;

-      red_smoothPeak =  smooth((float)red_Peak, 0.6, (float)red_smoothPeak);  // smooth peaks
+      red_smoothPeak =  smooth((float)red_Peak, 0.6,
+                               (float)red_smoothPeak);  // smooth peaks
       red_Peak = 0;

       lastPeakTime = millis();
@@ -270,7 +331,8 @@

     if (millis() - lastValleyTime > 1800) { // insure reset slower than lowest human HB
-      IR_smoothValley =  smooth((float)IR_valley, 0.6, (float)IR_smoothValley);  // smooth valleys
+      IR_smoothValley =  smooth((float)IR_valley, 0.6,
+                                (float)IR_smoothValley);  // smooth valleys
       IR_valley = 0;
       lastValleyTime = millis();
     }
@@ -288,11 +350,13 @@
       binOut = 1;
       //   Serial.println("\t1");
       hysterisis = -hysterisis;
-      IR_smoothValley =  smooth((float)IR_valley, 0.99, (float)IR_smoothValley);  // smooth valleys
+      IR_smoothValley =  smooth((float)IR_valley, 0.99,
+                                (float)IR_smoothValley);  // smooth valleys
       IR_signalSize = IR_smoothPeak - IR_smoothValley;
       IR_valley = 0x7FFF;

-      red_smoothValley =  smooth((float)red_valley, 0.99, (float)red_smoothValley);  // smooth valleys
+      red_smoothValley =  smooth((float)red_valley, 0.99,
+                                 (float)red_smoothValley);  // smooth valleys
       red_signalSize = red_smoothPeak - red_smoothValley;
       red_valley = 0x7FFF;

@@ -303,10 +367,12 @@
       Serial.println("\t0");
       lastBinOut = binOut;
       binOut = 0;
-      IR_smoothPeak =  smooth((float)IR_peak, 0.99, (float)IR_smoothPeak);  // smooth peaks
+      IR_smoothPeak =  smooth((float)IR_peak, 0.99, (float)IR_smoothPeak);
+      // smooth peaks
       IR_peak = 0;

-      red_smoothPeak =  smooth((float)red_Peak, 0.99, (float)red_smoothPeak);  // smooth peaks
+      red_smoothPeak =  smooth((float)red_Peak, 0.99,
+                               (float)red_smoothPeak);  // smooth peaks
       red_Peak = 0;
       lastPeakTime = millis();
     }
@@ -326,78 +392,70 @@
       Serial.print(IR_signalSize);
       Serial.print("\t PSO2 ");
       Serial.println(((float)red_baseline / (float)(IR_baseline / 2)), 3);
-    }
-  }
-}
-
+      RFduinoBLE.sendFloat(0x08);
+      delay(75);
+      RFduinoBLE.sendByte(BPM);
+      delay(75);
+    }
+  }
+}
 void initPulseSensor() {

-  pulse.setReg(PulsePlug::HW_KEY, 0x17);
-  // pulse.setReg(pulse::COMMAND, pulse::RESET_Cmd);
+  HR_write_reg(SI114_REG_HW_KEY, 0x17);
+  // HR_write_reg(pulse::COMMAND, pulse::RESET_Cmd);

   Serial.print("PART: ");
-  Serial.print(pulse.getReg(PulsePlug::PART_ID));
+  Serial.print(HR_read_reg(SI114_REG_PART_ID, 1));
   Serial.print(" REV: ");
-  Serial.print(pulse.getReg(PulsePlug::REV_ID));
+  Serial.print(HR_read_reg(SI114_REG_REV_ID, 1));
   Serial.print(" SEQ: ");
-  Serial.println(pulse.getReg(PulsePlug::SEQ_ID));
-
-  pulse.setReg(PulsePlug::INT_CFG, 0x03);       // turn on interrupts
-  pulse.setReg(PulsePlug::IRQ_ENABLE, 0x10);    // turn on interrupt on PS3
-  pulse.setReg(PulsePlug::IRQ_MODE2, 0x01);     // interrupt on ps3 measurement
-  pulse.setReg(PulsePlug::MEAS_RATE, 0x84);     // see datasheet
-  pulse.setReg(PulsePlug::ALS_RATE, 0x08);      // see datasheet
-  pulse.setReg(PulsePlug::PS_RATE, 0x08);       // see datasheet
-  pulse.setReg(PulsePlug::PS_LED21, 0x66 );      // LED current for LEDs 1 (red) & 2 (IR1)
-  pulse.setReg(PulsePlug::PS_LED3, 0x06);        // LED current for LED 3 (IR2)
+  Serial.println(HR_read_reg(SI114_REG_SEQ_ID, 1));
+
+  HR_write_reg(SI114_REG_IRQ_CFG, 0x03);       // turn on interrupts
+  HR_write_reg(SI114_REG_IRQ_ENABLE, 0x10);    // turn on interrupt on PS3
+  HR_write_reg(SI114_REG_IRQ_MODE2, 0x01);     // interrupt on ps3 measurement
+  HR_write_reg(SI114_REG_MEAS_RATE, 0x84);     // see datasheet
+  HR_write_reg(SI114_REG_ALS_RATE, 0x08);      // see datasheet
+  HR_write_reg(SI114_REG_PS_RATE, 0x08);       // see datasheet
+  HR_write_reg(SI114_REG_PS_LED21, 0x66 );      // LED current for LEDs 1 (red) & 2 (IR1)
+  HR_write_reg(SI114_REG_PS_LED3, 0x06);        // LED current for LED 3 (IR2)

   Serial.print( "PS_LED21 = ");
-  Serial.println(pulse.getReg(PulsePlug::PS_LED21), BIN);
+  Serial.println(HR_read_reg(SI114_REG_PS_LED21, 1), BIN);
   Serial.print("CHLIST = ");
-  Serial.println(pulse.readParam(0x01), BIN);
-
-  pulse.writeParam(PulsePlug::PARAM_CH_LIST, 0x77);         // all measurements on
+  Serial.println(HR_read_param(0x01), BIN);
+
+  HR_write_param(SI114_PARAM_CH_LIST, 0x77);         // all measurements on

   // increasing PARAM_PS_ADC_GAIN will increase the LED on time and ADC window
   // you will see increase in brightness of visible LED's, ADC output, & noise
   // datasheet warns not to go beyond 4 because chip or LEDs may be damaged
-  pulse.writeParam(PulsePlug::PARAM_PS_ADC_GAIN, 0x00);
-
-  pulse.writeParam(PulsePlug::PARAM_PSLED12_SELECT, 0x21);  // select LEDs on for readings see datasheet
-  pulse.writeParam(PulsePlug::PARAM_PSLED3_SELECT, 0x04);   //  3 only
-  pulse.writeParam(PulsePlug::PARAM_PS1_ADCMUX, 0x03);      // PS1 photodiode select
-  pulse.writeParam(PulsePlug::PARAM_PS2_ADCMUX, 0x03);      // PS2 photodiode select
-  pulse.writeParam(PulsePlug::PARAM_PS3_ADCMUX, 0x03);      // PS3 photodiode select
-
-  pulse.writeParam(PulsePlug::PARAM_PS_ADC_COUNTER, B01110000);    // B01110000 is default
-  pulse.setReg(PulsePlug::COMMAND, PulsePlug::PSALS_AUTO_Cmd);     // starts an autonomous read loop
-  Serial.println(pulse.getReg(PulsePlug::CHIP_STAT), HEX);
+  HR_write_param(SI114_PARAM_PS_ADC_GAIN, 0x03);
+
+  HR_write_param(SI114_PARAM_PSLED12_SELECT, 0x21);  // select LEDs on for readings see datasheet
+  HR_write_param(SI114_PARAM_PSLED3_SELECT, 0x04);   //  3 only
+  HR_write_param(SI114_PARAM_PS1_ADC_MUX, 0x03);      // PS1 photodiode select
+  HR_write_param(SI114_PARAM_PS2_ADC_MUX, 0x03);      // PS2 photodiode select
+  HR_write_param(SI114_PARAM_PS3_ADC_MUX, 0x03);      // PS3 photodiode select
+
+  HR_write_param(SI114_PARAM_PS_ADC_COUNTER, B01110000);    // B01110000 is default
+  HR_write_reg(SI114_REG_COMMAND, B00001111);     // starts an autonomous read loop
+  Serial.println(HR_read_reg(SI114_REG_CHIP_STAT, 1), HEX);
   Serial.print("end init");
 }

-//--------------------------------------------------------------------------------------------
-//int SI1146_Test(int i2caddr) {
-//  int id;
-//  Wire.beginTransmission(i2caddr);
-//  id = Wire.read(SI114_REG_PART_ID);
-//  Wire.endTransmission();
-//  if (id == 0x46)
-//    return 1; // look for SI1145
-//  //DEVICE FOUND Reset SI1146 Registers
-//  return 0;
-//}
-
-//--------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------

 void loop() {
   Serial.println("Top of Main");

   //Detect button Press
   if (RFduino_pinWoke(3)) {
-    RFduino_resetPinWake(3); // reset state of pin that caused wakeup (Must do this)
+    //RFduino_resetPinWake(3); // reset state of pin that caused wakeup (Must do this)
     Serial.println("Button Press!");
     state = BLUETOOTH;
     delay(2500);
+    RFduino_resetPinWake(3); // reset state of pin that caused wakeup (Must do this)
   }

   //Poll Sensors if time expired
@@ -409,23 +467,48 @@

     //Heart Rate Monitor Read
     Wire.beginTransmission(HRAddress);  // transmit to SI1146 Heart Rate Monitor device #96 (0x60)
-    //readPulseSensor();
+    Serial.println("Heart Rate Read Attempt");
+    readPulseSensor();
     //---> Insert into FRAM
-

     // Grab temperature measurements and print them.
     float objt = tmp006.readObjTempC();
-    Serial.print("Object Temperature: "); Serial.print(objt); Serial.println("*C");
+    objt = objt * (9 / 5) + 32;
+    Serial.print("Object Temperature: "); Serial.print(objt);
+    Serial.println("*F");
     float diet = tmp006.readDieTempC();
-    Serial.print("Die Temperature: "); Serial.print(diet); Serial.println("*C");
+    diet = diet * (9 / 5) + 32;
+    Serial.print("Die Temperature: "); Serial.print(diet);
+    Serial.println("*F");
+    RFduinoBLE.sendByte(0x05);
+    delay(75);
     RFduinoBLE.sendFloat(objt);
+    delay(75);
+    RFduinoBLE.sendByte(0x06);
+    delay(75);
+    RFduinoBLE.sendFloat(diet);
+    delay(75);
+
     //---> Insert into FRAM

     //Galvanic Skin Response Read
     float gsr = analogRead(4);
     Serial.print("Galvanic Skin Response: "); Serial.println(gsr);
+    RFduinoBLE.sendByte(0x07);
+    delay(75);
     RFduinoBLE.sendFloat(gsr);
+    delay(75);
     //---> Insert into FRAM
+
+    //    // Add Floats together to send in a single BLE.send
+    //   char output[4];
+    //    //first we add the time stamp (4 bytes)
+    //   long objt_long = objt;
+    //
+    //    for (int j = 0; j < 4; j++){
+    //      output[4-j]=(char)(objt_long >> (8*j) & 0xFF);
+    //    }
+    //    RFduinoBLE.send(objt);

     //Reset State
     state = POLL_SENSORS;
@@ -439,12 +522,6 @@
     delay(1000);
     LED_OFF();
     delay(1000);
-
-    Serial.println("Heart Rate Read Attempt");
-    readPulseSensor();
-
-    //    SI1146_Test(HRAddress);
-
     RED_LED_ON();
     delay(1000);
     LED_OFF();
@@ -474,8 +551,6 @@

   Serial.println("Bottom of Main");
   //Sleep for 5 minutes or until interrupt
-  RFduino_ULPDelay(MINUTES(1));
-
-}
-
-
+  RFduino_ULPDelay(SECONDS(10));
+
+}


Set pin mode of brake pin in MoveSteeringSerial to output.

--- MoveActuator/MoveSteeringSerial/MoveSteeringSerial.ino
+++ MoveActuator/MoveSteeringSerial/MoveSteeringSerial.ino
@@ -4,7 +4,7 @@
 Servo steer, brake;
 void setup() {
   // put your setup code here, to run once:
-  brake.attach(BRAKE_OUT_PIN);
+  pinMode(BRAKE_OUT_PIN, OUTPUT);
   steer.attach(STEER_OUT_PIN);
   Serial.begin(9600);
 }


code formatting

code formatting

--- BuggyTracker/BuggyTracker.ino
+++ BuggyTracker/BuggyTracker.ino
@@ -19,9 +19,9 @@
 //#define timeBetweenRounds 1800L // 30 minutes

 #if DEBUG
-  #define timeBetweenRounds 7L // 16 seconds (two wakelock periods) for testing
+#define timeBetweenRounds 7L // 16 seconds (two wakelock periods) for testing
 #else
-  #define timeBetweenRounds 300L // 5 minutes
+#define timeBetweenRounds 300L // 5 minutes
 #endif
 long curDistance = 0;
 #define LED  13
@@ -38,26 +38,26 @@

 void setup()
 {
-//  pinMode(LED, OUTPUT);
+  //  pinMode(LED, OUTPUT);

   attachInterrupt(interupt, BtnDownCB, FALLING );

   // Call the function to enable low power consumption
-  #if !NORMALPOW
-    ble_low_power();
-  #else
-   Serial.begin(9600);
-  #endif
+#if !NORMALPOW
+  ble_low_power();
+#else
+  Serial.begin(9600);
+#endif
   time =1; // init the time to 1, to make it different from 0
   // If you are using the Blend, uncomment below
   ble_set_pins(6, 7);
-   ble_set_name("Stroller");
+  ble_set_name("Stroller");

   // Init. and start BLE library.
   ble_begin();

   // prepare SD data logging!
-//
+  //
   if (!SD.begin(10, 11, 12, 13)) { // important: this is custom code for the leonardo, see https://learn.adafruit.com/adafruit-data-logger-shield/for-the-mega-and-leonardo

   }
@@ -65,37 +65,37 @@

     // Open up the file we're going to log to!
     dataFile = SD.open("datalog.txt", FILE_WRITE);
-     runs=SD.open("run.txt",FILE_WRITE);
+    runs=SD.open("run.txt",FILE_WRITE);
   }

-//  setSyncProvider(RTC.get);
+  //  setSyncProvider(RTC.get);
 }

-  ISR(WDT_vect)
-  {
-    #if DEBUG
-    if (ble_connected()) {
-            ble_write_bytes((unsigned char *)"wakelock",8);
+ISR(WDT_vect)
+{
+#if DEBUG
+  if (ble_connected()) {
+    ble_write_bytes((unsigned char *)"wakelock",8);

-    }
-    #endif
-    time = time +8;
-
   }
+#endif
+  time = time +8;
+
+}

 void stroller_ble_print() {
-  #if NORMALPOW
-    Serial.println("printing distance");
-  #endif
+#if NORMALPOW
+  Serial.println("printing distance");
+#endif
   if (ble_connected()) {
-              char output[26];
-            // length of output should be: 5 fixed, 10 time, 10 distance, but must be one longer?!?
-         sprintf(output,"D:%10lu:%10lu\n\n",time,curDistance);
-
-          ble_write_bytes((unsigned char *)output,26);
+    char output[26];
+    // length of output should be: 5 fixed, 10 time, 10 distance, but must be one longer?!?
+    sprintf(output,"D:%10lu:%10lu\n\n",time,curDistance);
+
+    ble_write_bytes((unsigned char *)output,26);
   }
 }

@@ -104,58 +104,56 @@
 {

   if (hadRound== 1) {
-    #if NORMALPOW
+#if NORMALPOW
     Serial.println("had round");
-  #endif
+#endif
     // compare the time of the last logged or the current logged value
     // the actual calculation
-      if (beginRun==0) {
-        beginRun=time;
-      }
-      if (lastMeasurement == 0 ){
-        lastMeasurement = time;
+    if (beginRun==0) {
+      beginRun=time;
+    }
+    if (lastMeasurement == 0 ){
+      lastMeasurement = time;
+    }
+    curDistance = curDistance + distance;
+    //
+    //      // write to SD card
+
+    ////      // here, we can write the full, readable timestamp:
+    char output[25];
+    // length of output should be: 5 fixed, 10 time, 10 distance;
+    sprintf(output,"R:%10lu:%10lu\n",time,curDistance);
+    dataFile.write(output,25);
+    dataFile.flush();
+
+    byte reset= 0;
+#if DEBUG
+    if (ble_connected()) {
+      char temp[32];
+      sprintf(temp,"resetting:%10lu:%10lu\n",lastMeasurement,time);
+      ble_write_bytes( (unsigned char *)temp,32);
+    }
+#endif
+    if ((time-lastMeasurement)>timeBetweenRounds) {
+#if DEBUG
+      if (ble_connected()) {
+        ble_write_bytes( (unsigned char *)"reset\n",6);
       }
-      curDistance = curDistance + distance;
-//
-//      // write to SD card
-
-////      // here, we can write the full, readable timestamp:
-              char output[25];
-            // length of output should be: 5 fixed, 10 time, 10 distance;
-            sprintf(output,"R:%10lu:%10lu\n",time,curDistance);
-            dataFile.write(output,25);
-            dataFile.flush();
-
-      byte reset= 0;
-              #if DEBUG
-          if (ble_connected()) {
-                      char temp[32];
-            sprintf(temp,"resetting:%10lu:%10lu\n",lastMeasurement,time);
-             ble_write_bytes( (unsigned char *)temp,32);
-          }
-        #endif
-      if ((time-lastMeasurement)>timeBetweenRounds) {
-              #if DEBUG
-          if (ble_connected()) {
-
-
-             ble_write_bytes( (unsigned char *)"reset\n",6);
-          }
-        #endif
-          reset=1;
-          char result[37];
-          // length of output should be: 7 fixed, 10 begin, 10 time , 10 distance;
-          sprintf(result,"Run:%10lu:%10lu:%10lu\n",beginRun,time,curDistance);
-          runs.write(result,37);
-        runs.flush();
-        curDistance=distance;
-        beginRun=millis();
-      }
-        #if DEBUG
-          stroller_ble_print();
-        #endif
-          lastMeasurement = time;
-          hadRound=0;
+#endif
+      reset=1;
+      char result[37];
+      // length of output should be: 7 fixed, 10 begin, 10 time , 10 distance;
+      sprintf(result,"Run:%10lu:%10lu:%10lu\n",beginRun,time,curDistance);
+      runs.write(result,37);
+      runs.flush();
+      curDistance=distance;
+      beginRun=millis();
+    }
+#if DEBUG
+    stroller_ble_print();
+#endif
+    lastMeasurement = time;
+    hadRound=0;

   }
   if (ble_available() )
@@ -165,7 +163,7 @@
     {
       temp = ble_read();
       if ('r' == temp) { // read comand from smartphone)
-          stroller_ble_print();
+        stroller_ble_print();
       }
       else if ( 'c' == temp ) { // aCcept or commit command from smartphone, later used for resetting
         curDistance=0;
@@ -174,10 +172,10 @@
       }
     }
   }
-//  delay(50);
+  //  delay(50);
 #if DEBUG
   digitalWrite(LED,LOW);
-  #endif
+#endif
   ble_do_events();
 }

@@ -185,11 +183,12 @@
 {
   PRR0 = 0x00;  // Power Reduction Register: open timer
   PRR1 = 0x00;
-  #if DEBUG
+#if DEBUG
   digitalWrite(LED,HIGH);
-    #endif
+#endif
   hadRound = 1;
 }

+


Can disable the gamepad mode

Can disable the gamepad mode

--- arduino/dudrack/dudrack.ino
+++ arduino/dudrack/dudrack.ino
@@ -5,6 +5,8 @@
 #include <HID-Project.h>

 #define OUTPUT_TO_SERIAL 0
+
+#define ENABLE_GAMEPAD 1

 #define NUM_REPORT_KEYS 6

@@ -27,30 +29,32 @@

 #define MODE_NEUTRAL 0
 #define MODE_DUDRACK 1
-#define MODE_STG 2
+#define MODE_GAMEPAD 2
 #define MODE_COUNT 3

 #define MAPPING_NEUTRAL 0
 #define MAPPING_HENKAN 1
 #define MAPPING_COUNT 2

-#define STICK_NEUTRAL 0
-#define STICK_DOWN 0x7000
-#define STICK_UP -0x7000
-#define STICK_LEFT -0x7000
-#define STICK_RIGHT 0x7000
-
-#define STICK_DOWN_KEY  KEY_K
-#define STICK_UP_KEY    KEY_I
-#define STICK_LEFT_KEY  KEY_J
-#define STICK_RIGHT_KEY KEY_L
-#define BUTTON_1_KEY    KEY_D
-#define BUTTON_2_KEY    KEY_F
-#define BUTTON_3_KEY    KEY_G
-#define BUTTON_4_KEY    KEY_S
-#define BUTTON_5_KEY    KEY_MUHENKAN
-#define BUTTON_6_KEY    KEY_HENKAN
-#define BUTTON_7_KEY    KEY_SPACE
+#if ENABLE_GAMEPAD
+#   define STICK_NEUTRAL 0
+#   define STICK_DOWN 0x7FFF
+#   define STICK_UP -0x7FFF
+#   define STICK_LEFT -0x7FFF
+#   define STICK_RIGHT 0x7FFF
+
+#   define STICK_DOWN_KEY  KEY_HENKAN
+#   define STICK_UP_KEY    KEY_I
+#   define STICK_LEFT_KEY  KEY_J
+#   define STICK_RIGHT_KEY KEY_O
+#   define BUTTON_1_KEY    KEY_D
+#   define BUTTON_2_KEY    KEY_F
+#   define BUTTON_3_KEY    KEY_G
+#   define BUTTON_4_KEY    KEY_S
+#   define BUTTON_5_KEY    KEY_LEFT_ALT
+#   define BUTTON_6_KEY    KEY_MUHENKAN
+#   define BUTTON_7_KEY    KEY_SPACE
+#endif

 USB    Usb;
 USBHub Hub(&Usb);
@@ -153,12 +157,14 @@
     bool noMouseMoveBetweenRightEvents = false;
 } mouseState;

+#if ENABLE_GAMEPAD
 struct {
     bool downPressed = false;
     bool upPressed = false;
     bool leftPressed = false;
     bool rightPressed = false;
 } gamepadState;
+#endif

 void releaseLeftShift() {
     if (!keyboardState.muhenkanPressed
@@ -173,13 +179,16 @@
     keyboardState.muhenkanPressed = false;
     keyboardState.spacePressed = false;

+    Keyboard.releaseAll();
+
+#if ENABLE_GAMEPAD
     gamepadState.downPressed = false;
     gamepadState.upPressed = false;
     gamepadState.leftPressed = false;
     gamepadState.rightPressed = false;

-    Keyboard.releaseAll();
     Gamepad.releaseAll();
+#endif
 }

 bool handleModeSwitch(uint8_t mod, KeyboardKeycode key) {
@@ -198,7 +207,9 @@
                 return true;

             case KEY_3:
-                keyboardState.currentMode = MODE_STG;
+#if ENABLE_GAMEPAD
+                keyboardState.currentMode = MODE_GAMEPAD;
+#endif

                 return true;
         }
@@ -280,7 +291,8 @@
     }
 }

-void stgKeyDown(KeyboardKeycode key) {
+#if ENABLE_GAMEPAD
+void gamepadKeyDown(KeyboardKeycode key) {
     switch (key) {
         case STICK_DOWN_KEY:
             gamepadState.downPressed = true;
@@ -345,7 +357,7 @@
     Gamepad.write();
 }

-void stgKeyUp(KeyboardKeycode key) {
+void gamepadKeyUp(KeyboardKeycode key) {
     switch (key) {
         case STICK_DOWN_KEY:
             gamepadState.downPressed = false;
@@ -409,6 +421,7 @@

     Gamepad.write();
 }
+#endif

 class : public KeyboardReportParser {
 public:
@@ -504,9 +517,11 @@
                 dudrackKeyDown(key);
                 return;

-            case MODE_STG:
-                stgKeyDown(key);
+#if ENABLE_GAMEPAD
+            case MODE_GAMEPAD:
+                gamepadKeyDown(key);
                 return;
+#endif
         }
     }

@@ -527,9 +542,11 @@
                 dudrackKeyUp(key);
                 return;

-            case MODE_STG:
-                stgKeyUp(key);
+#if ENABLE_GAMEPAD
+            case MODE_GAMEPAD:
+                gamepadKeyUp(key);
                 return;
+#endif
         }
     }
 } keyboardReportParser;
@@ -606,7 +623,10 @@

     Mouse.begin();
     Keyboard.begin();
+
+#if ENABLE_GAMEPAD
     Gamepad.begin();
+#endif
 }

 void loop() {


Using value to output brightness

Using value to output brightness


fix typo in current_sketch.ino

fix typo in current_sketch.ino

--- src/current_sketch.ino
+++ src/current_sketch.ino
@@ -1,4 +1,4 @@
-#include "LedControl.h"
+#include <LedControl.h>
 #include <Wire.h>
 #include <LiquidCrystal_I2C.h>


de-tabify

de-tabify

--- examples/raw-feather/raw-feather.ino
+++ examples/raw-feather/raw-feather.ino
@@ -5,33 +5,33 @@
 Module:  raw-feather.ino

 Function:
-	Slightly improved Raw test example, for Adafruit Feather M0 LoRa
+        Slightly improved Raw test example, for Adafruit Feather M0 LoRa

 Version:
-	V0.7.0	Tue Jan 23 2018 10:25:50 chwon	Edit level 2
+        V0.7.0	Tue Jan 23 2018 10:25:50 chwon	Edit level 2

 Copyright notice:
-	This file copyright (C) 2017, 2018 by
-
-		MCCI Corporation
-		3520 Krums Corners Road
-		Ithaca, NY  14850
-
-	An unpublished work.  All rights reserved.
-
-	This file is proprietary information, and may not be disclosed or
-	copied without the prior permission of MCCI Corporation.
+        This file copyright (C) 2017, 2018 by
+
+                MCCI Corporation
+                3520 Krums Corners Road
+                Ithaca, NY  14850
+
+        An unpublished work.  All rights reserved.
+
+        This file is proprietary information, and may not be disclosed or
+        copied without the prior permission of MCCI Corporation.

 Author:
-	Matthijs Kooijman  2015
-	Terry Moore, MCCI Corporation	April 2017
+        Matthijs Kooijman  2015
+        Terry Moore, MCCI Corporation	April 2017

 Revision history:
    0.5.0  Sat Apr  1 2017 22:26:22  tmm
-	Module created.
+        Module created.

    0.7.0  Tue Jan 23 2018 10:25:50  chwon
-	Add Catena 4551 platform support.
+        Add Catena 4551 platform support.

 */

@@ -122,19 +122,19 @@
 };

 void lmic_printf(const char *fmt, ...) {
-	if (! Serial.dtr())
-		return;
-
-	char buf[256];
-	va_list ap;
-
-	va_start(ap, fmt);
-	(void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
-	va_end(ap);
-
-	// in case we overflowed:
-	buf[sizeof(buf) - 1] = '\0';
-	if (Serial.dtr()) Serial.print(buf);
+        if (! Serial.dtr())
+                return;
+
+        char buf[256];
+        va_list ap;
+
+        va_start(ap, fmt);
+        (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+        va_end(ap);
+
+        // in case we overflowed:
+        buf[sizeof(buf) - 1] = '\0';
+        if (Serial.dtr()) Serial.print(buf);
 }

 osjob_t txjob;
@@ -281,27 +281,27 @@
   uint32_t uBandwidth;

   if (! fDownlink)
-	{
-	if (kUplinkChannel < 64)
-		{
-		LMIC.freq = US915_125kHz_UPFBASE +
-			    kUplinkChannel * US915_125kHz_UPFSTEP;
-		uBandwidth = 125;
-		}
-	else
-		{
-		LMIC.freq = US915_500kHz_UPFBASE +
-			    (kUplinkChannel - 64) * US915_500kHz_UPFSTEP;
-		uBandwidth = 500;
-		}
-	}
+        {
+        if (kUplinkChannel < 64)
+                {
+                LMIC.freq = US915_125kHz_UPFBASE +
+                            kUplinkChannel * US915_125kHz_UPFSTEP;
+                uBandwidth = 125;
+                }
+        else
+                {
+                LMIC.freq = US915_500kHz_UPFBASE +
+                            (kUplinkChannel - 64) * US915_500kHz_UPFSTEP;
+                uBandwidth = 500;
+                }
+        }
   else
-	{
-	// downlink channel
-	LMIC.freq = US915_500kHz_DNFBASE +
-		    kDownlinkChannel * US915_500kHz_DNFSTEP;
-	uBandwidth = 500;
-	}
+        {
+        // downlink channel
+        LMIC.freq = US915_500kHz_DNFBASE +
+                    kDownlinkChannel * US915_500kHz_DNFSTEP;
+        uBandwidth = 500;
+        }

   // Use a suitable spreading factor
   if (uBandwidth < 500)
@@ -339,27 +339,27 @@
   uint32_t uBandwidth;

   if (! fDownlink)
-	{
-	if (kUplinkChannel < 64)
-		{
-		LMIC.freq = AU921_125kHz_UPFBASE +
-			    kUplinkChannel * AU921_125kHz_UPFSTEP;
-		uBandwidth = 125;
-		}
-	else
-		{
-		LMIC.freq = AU921_500kHz_UPFBASE +
-			    (kUplinkChannel - 64) * AU921_500kHz_UPFSTEP;
-		uBandwidth = 500;
-		}
-	}
+        {
+        if (kUplinkChannel < 64)
+                {
+                LMIC.freq = AU921_125kHz_UPFBASE +
+                            kUplinkChannel * AU921_125kHz_UPFSTEP;
+                uBandwidth = 125;
+                }
+        else
+                {
+                LMIC.freq = AU921_500kHz_UPFBASE +
+                            (kUplinkChannel - 64) * AU921_500kHz_UPFSTEP;
+                uBandwidth = 500;
+                }
+        }
   else
-	{
-	// downlink channel
-	LMIC.freq = AU921_500kHz_DNFBASE +
-		    kDownlinkChannel * AU921_500kHz_DNFSTEP;
-	uBandwidth = 500;
-	}
+        {
+        // downlink channel
+        LMIC.freq = AU921_500kHz_DNFBASE +
+                    kDownlinkChannel * AU921_500kHz_DNFSTEP;
+        uBandwidth = 500;
+        }

   // Use a suitable spreading factor
   if (uBandwidth < 500)
@@ -394,11 +394,11 @@
         // default tx power for AS: 21 dBm
         LMIC.txpow = 16;

-	if (LMIC_COUNTRY_CODE == LMIC_COUNTRY_CODE_JP)
-		{
-		LMIC.lbt_ticks = us2osticks(AS923JP_LBT_US);
+        if (LMIC_COUNTRY_CODE == LMIC_COUNTRY_CODE_JP)
+                {
+                LMIC.lbt_ticks = us2osticks(AS923JP_LBT_US);
                 LMIC.lbt_dbmax = AS923JP_LBT_DB_MAX;
-		}
+                }
 #elif defined(CFG_in866)
 // make it easier for test, by pull the parameters up to the top of the
 // block. Ideally, we'd use the serial port to drive this; or have
@@ -415,7 +415,7 @@
         LMIC.freq = IN866_F1 + kChannel * 200000;
         uBandwidth = 125;

-	LMIC.datarate = IN866_DR_SF7;         // DR7
+        LMIC.datarate = IN866_DR_SF7;         // DR7
         // default tx power for IN: 30 dBm
         LMIC.txpow = IN866_TX_EIRP_MAX_DBM;
 #else


COH-71: selecting correct (minimum) DS18B20 precision

--- COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
+++ COHEAT2015/20160316-COHEAT-M1/COHEAT-M1/COHEAT-M1.ino
@@ -274,8 +274,9 @@
 OTV0P2BASE::MinimalOneWire<> MinOW_DEFAULT;
 #endif

-#if defined(SENSOR_EXTERNAL_DS18B20_ENABLE_0) // Enable sensor zero.
-OTV0P2BASE::TemperatureC16_DS18B20 extDS18B20_0(MinOW_DEFAULT);
+#if defined(SENSOR_EXTERNAL_DS18B20_ENABLE_0)
+// External (return pipe) DS18B20 temperature, 9 bit (0.5C) precision.
+OTV0P2BASE::TemperatureC16_DS18B20 extDS18B20_0(MinOW_DEFAULT, OTV0P2BASE::TemperatureC16_DS18B20::MIN_PRECISION);
 #endif

 #if defined(ENABLE_PRIMARY_TEMP_SENSOR_SHT21)
@@ -288,11 +289,6 @@
 // Ambient/room temperature sensor, usually on main board.
 #if defined(ENABLE_PRIMARY_TEMP_SENSOR_SHT21)
 OTV0P2BASE::RoomTemperatureC16_SHT21 TemperatureC16; // SHT21 impl.
-#elif defined(ENABLE_PRIMARY_TEMP_SENSOR_DS18B20)
-#if defined(ENABLE_MINIMAL_ONEWIRE_SUPPORT)
-// DSB18B20 temperature impl, with slightly reduced precision to improve speed.
-OTV0P2BASE::TemperatureC16_DS18B20 TemperatureC16(MinOW_DEFAULT, 0, OTV0P2BASE::TemperatureC16_DS18B20::MAX_PRECISION - 1);
-#endif
 #else // Don't use TMP112 if SHT21 or DS18B20 are selected.
 OTV0P2BASE::RoomTemperatureC16_TMP112 TemperatureC16;
 #endif


fix version number

fix version number

--- firmware/examples/1_RGBPongClock.ino
+++ firmware/examples/1_RGBPongClock.ino
@@ -33,7 +33,7 @@
 extern char* itoa(int a, char* buffer, unsigned char radix);

-#define		RGBPCversion	"V1.2"
+#define		RGBPCversion	"V1.1.2"

 //#define DEBUGME


Compile error fixed, fine tuning analogReads.

--- Code/Pianoduino/Pianoduino.ino
+++ Code/Pianoduino/Pianoduino.ino
@@ -83,7 +83,7 @@
 static const byte drumsThreshold [] = {
   40
 };//Drums threshold, snaredrum,...
-static const byte analogThreshold = 1;
+static const byte analogThreshold = 1;//Controls Threshold
 //#define debug //Uncomment to debug
 //***************************************************************//

@@ -148,6 +148,10 @@
     buttonState[i] = 0;
   }

+  for (i = 0; i < (sizeof(muxEn) / sizeof(byte)) * 8); i++){
+    analogvalue[i] = 0 ;
+  }
+
   readAnalog(); //Read the initial value of the knobs
   transpose(trans); //Set the octave to the initial value.
   digitalWrite(loadPin, HIGH); //On HIGH is read ready
@@ -243,7 +247,7 @@
       tmp = map(analogRead(muxReadPin), 0, 1023, 0, 127);
       if (i * 8 + y < 15) {
         //If the value is greater or smaller than the actual value plus or minus the threshold send the change value.
-        if (tmp > analogValue[i * 8 + y] + analogThreshold || tmp < analogValue[i * 8 + y] - analogThreshold  ) {
+        if (tmp > (analogValue[i * 8 + y] + analogThreshold) || tmp < (analogValue[i * 8 + y] - analogThreshold  )) {

           analogValue[i * 8 + y] = tmp;
           //Send message with the knoobs value
@@ -252,7 +256,7 @@
       }
       else if(tmp > drumsThreshold[(i * 8 + y)%15]){
         //Send message with the drums value
-        noteOn(drumChannel, drumNotes[(i * 8 + y)%15], tmp);
+        noteOn(drumsChannel, drumNotes[(i * 8 + y)%15], tmp);
       }
     }
   }


version change

version change

--- ArduCAM_OSD/OSD_Panels.ino
+++ ArduCAM_OSD/OSD_Panels.ino
@@ -12,7 +12,7 @@
 void panLogo(){
 	osd.setPanel(5, 5);
 	osd.openPanel();
-	osd.printf_P(PSTR("\xb0\xb1\xb2\xb3\xb4|\xb5\xb6\xb7\xb8\xb9|MinimOSD-Extra 2.4 | r623 MP|"));
+	osd.printf_P(PSTR("MatrixPilot|MinimOSD-Extra 2.4 | r624|"));
 	//osd.printf_P(PSTR("Waiting for communication"));
 	osd.closePanel();
 }


Revised RGB firmware to maintain approximately constant power

--- eeZeeRGB/firmware/Arduino_WS2812/Arduino_WS2812.ino
+++ eeZeeRGB/firmware/Arduino_WS2812/Arduino_WS2812.ino
@@ -36,9 +36,9 @@
   leds.show();
 }

-#define DELAY 50
+#define DELAY 60
 #define MINCOLOR 0
-#define MAXCOLOR 20
+#define MAXCOLOR 40

 uint8_t r = MAXCOLOR; // start with red
 uint8_t g = MINCOLOR;
@@ -47,38 +47,20 @@
 void loop()
 {

-  // Red to Red+Blue
-  for (b = MINCOLOR; b < MAXCOLOR; b++) {
+  // Red to Red+Blue to Blue
+  for (r = MAXCOLOR, b = MINCOLOR; b < MAXCOLOR; r--, b++) {
     leds.setPixelColor(0, r, g, b);
     leds.show();
     delay(DELAY);
   }
-  // Red+Blue to Blue
-  for (r = MAXCOLOR; r > MINCOLOR; r--) {
+  // Blue to Blue+Green to Green
+  for (b = MAXCOLOR, g = MINCOLOR; g < MAXCOLOR; b--, g++) {
     leds.setPixelColor(0, r, g, b);
     leds.show();
     delay(DELAY);
   }
-  // Blue to Blue+Green
-  for (g = MINCOLOR; g < MAXCOLOR; g++) {
-    leds.setPixelColor(0, r, g, b);
-    leds.show();
-    delay(DELAY);
-  }
-  // Blue+Green to Green
-  for (b = MAXCOLOR; b > MINCOLOR; b--) {
-    leds.setPixelColor(0, r, g, b);
-    leds.show();
-    delay(DELAY);
-  }
-  // Green to Red+Green
-  for (r = MINCOLOR; r < MAXCOLOR; r++) {
-    leds.setPixelColor(0, r, g, b);
-    leds.show();
-    delay(DELAY);
-  }
-  // Red+Green to Red
-  for (g = MAXCOLOR; g > MINCOLOR; g--) {
+  // Green to Red+Green to Red
+  for (g = MAXCOLOR, r = MINCOLOR; r < MAXCOLOR; g--, r++) {
     leds.setPixelColor(0, r, g, b);
     leds.show();
     delay(DELAY);