Replace tabs with spaces

This commit is contained in:
2015-09-01 13:20:22 +01:00
parent ea15951f36
commit 841cbde3da

View File

@@ -15,7 +15,6 @@ TM1640 *tm1640;
TM1638 *tm1638[6]; TM1638 *tm1638[6];
TM16XX *module; TM16XX *module;
tm1638_Construct construct;
int pong = 0; int pong = 0;
String text; String text;
byte pressed = 0; byte pressed = 0;
@@ -104,14 +103,17 @@ bool callbackFont(pb_istream_t *stream, const pb_field_t *field, void **arg) {
void setup() { void setup() {
tm1638[0] = new TM1638(8, 9, 7); tm1638[0] = new TM1638(8, 9, 7);
tm1638[0]->setupDisplay(true, 1); tm1638[0]->setupDisplay(true, 1);
tm1638[0]->setDisplayToError(); tm1638[0]->setDisplayToString("Ready", 0, 0);
// tm1638[0]->setDisplayToError();
Serial.begin(19200); Serial.begin(4800);
sendText("setup()"); Serial.println("");
//sendText("setup()");
Serial.println("setup()");
} }
void loop() { void loop() {
if (pong > 0) { /*if (pong > 0) {
sendPong(pong); sendPong(pong);
pong = 0; pong = 0;
} }
@@ -123,7 +125,7 @@ void loop() {
if (buttons != pressed) { if (buttons != pressed) {
sendButtons(buttons); sendButtons(buttons);
pressed = buttons; pressed = buttons;
} }*/
} }
void serialEvent() { void serialEvent() {
@@ -132,17 +134,20 @@ void serialEvent() {
uint8_t in_buffer[256]; uint8_t in_buffer[256];
int bytes_read = Serial.readBytes((char*) in_buffer, packet_size); int bytes_read = Serial.readBytes((char*) in_buffer, packet_size);
if (bytes_read != packet_size) { if (bytes_read != packet_size) {
Serial.println("length problem");
return; return;
} }
pb_istream_t istream = pb_istream_from_buffer(in_buffer, bytes_read); pb_istream_t istream = pb_istream_from_buffer(in_buffer, bytes_read);
_tm1638_Command command; _tm1638_Command command;
if (!pb_decode(&istream, tm1638_Command_fields, &command)) { if (!pb_decode(&istream, tm1638_Command_fields, &command)) {
Serial.println("decode problem");
return; return;
} }
// tm1638[0]->setDisplayDigit(command.type / 10, 0, false); // tm1638[0]->setDisplayDigit(command.type / 10, 0, false);
// tm1638[0]->setDisplayDigit(command.type, 1, false); // tm1638[0]->setDisplayDigit(command.type, 1, false);
Serial.println("command");
Serial.println(command.type);
switch (command.type) { switch (command.type) {
case tm1638_Command_Type_PING: case tm1638_Command_Type_PING:
if (command.has_ping) { if (command.has_ping) {
@@ -153,7 +158,7 @@ void serialEvent() {
break; break;
case tm1638_Command_Type_CONSTRUCT: case tm1638_Command_Type_CONSTRUCT:
if (command.has_construct) { if (command.has_construct) {
construct = command.construct; tm1638_Construct construct = command.construct;
switch (construct.module) { switch (construct.module) {
case tm1638_Module_TM1638: case tm1638_Module_TM1638:
tm1638[0] = new TM1638((byte) construct.dataPin, (byte) construct.clockPin, (byte) construct.strobePin); tm1638[0] = new TM1638((byte) construct.dataPin, (byte) construct.clockPin, (byte) construct.strobePin);
@@ -256,7 +261,8 @@ void serialEvent() {
tm1638[0]->setDisplayToError(); tm1638[0]->setDisplayToError();
break; break;
case tm1638_Command_Type_SET_DISPLAY_TO_STRING: case tm1638_Command_Type_SET_DISPLAY_TO_STRING:
if(command.has_setDisplayToString) { if (command.has_setDisplayToString) {
text = "SET_DISPLAY_TO_STRING";
tm1638_SetDisplayToString setDisplayToString = command.setDisplayToString; tm1638_SetDisplayToString setDisplayToString = command.setDisplayToString;
pb_decode(&istream, tm1638_SetDisplayToString_fields, &setDisplayToString); pb_decode(&istream, tm1638_SetDisplayToString_fields, &setDisplayToString);
byte dots = setDisplayToString.dots; byte dots = setDisplayToString.dots;
@@ -268,8 +274,8 @@ void serialEvent() {
if (pb_decode(&istream, tm1638_SetDisplayToString_fields, &setDisplayToString)) { if (pb_decode(&istream, tm1638_SetDisplayToString_fields, &setDisplayToString)) {
tm1638[0]->setDisplayToString(setDisplayToString.string, dots, pos, font); tm1638[0]->setDisplayToString(setDisplayToString.string, dots, pos, font);
} }
} else { } else { // setDisplayToString.string
tm1638[0]->setDisplayToString(setDisplayToString.string, dots, pos); tm1638[0]->setDisplayToString("test...", dots, pos);
} }
} }
break; break;