HomePage RecentChanges Teensy Console Input

Combining Teensy Console and Serial and Teensy EEPROM Config allows you to write a powerful configuration system that can be changed via serial console(s).

#!C

// ... (see data setup in console and EEPROM config)

void setup() {
...
}

void loop() {
	processConsole();  // Process your command inputs
        ... do other stuff ...
}

// TODO - you should use define for your serial, e.g. #define bluetooth Serial2
void processConsole() {
	// Support for multiple console inputs - e.g. Serial and Serial2
	while (Serial.available() || Serial2.available()) {
		if (Serial.available())
			doCommand(&Serial);
		if (Serial2.available())
			doCommand(&Serial2);
	}
}

void doCommand(Stream *local) {
	long d;		// Integer In
	String s;	// String In

	char in = local->read();

	switch (in) {
		case '\r':
		case '\n':
				break;
		case 'h':	   // Help
			showHelp();
			break;
		case 'T': // SET TIME
			d = local->parseInt();
			if (d > 10000) {
				Teensy3Clock.set(d);
				setTime(d);
				consolePrint(F("NOTE: Time has been updated - UTC\r\n"));
			}
			else {
				consolePrint(F("ERROR: Invalid time update - UTC\r\n"));
			}
			break;
		case 'b':	// Brightness -255..255
			d = local->parseInt();
			if ( (d >= -255) && (d <= 255) ) {
				config.displayBright = d;
				writeConfig();
				displayBright();
			}
			break;
	}
}

// Show help INCLUDING existing values
void showHelp() {
	consolePrint(F("# HELP...\r\n"));
	consolePrint(F("#  T{nn}        Set time.        Current=%u\r\n"), now());
	consolePrint(F("#  b{-255..255} Set brightness.  Current=%d\r\n"), config.displayBright);
}

Software error:

Can't locate object method "endform" via package "CGI" at /data/scott.dd.com.au/wiki/modules/search.pl line 15.

For help, please send mail to the webmaster (webmaster@dd.com.au), giving this error message and the time and date of the error.