diff --git a/8By8/8By8.ino b/8By8/8By8.ino index 8f949ce..ae96887 100644 --- a/8By8/8By8.ino +++ b/8By8/8By8.ino @@ -31,7 +31,7 @@ const uint16_t numbers[10] = { // 8 width, 7 height -const uint64_t letters[26]{ +const uint64_t letters[]{ 0x3C66667E666666, // A 0x7C66667C66667C, // B 0x3C66606060663C, // C @@ -58,6 +58,16 @@ const uint64_t letters[26]{ 0x6363361C366363, // X 0x6666663C181818, // Y 0x7E060C1830607E, // Z + 0x3C666E7666663C, // 0 + 0x1818381818187E, // 1 + 0x3C66060C30607E, // 2 + 0x3C66061C06663C, // 3 + 0x0C1C2C4C7E0C0C, // 4 + 0x7E607C0606663C, // 5 + 0x3C66607C66663C, // 6 + 0x7E660C0C181818, // 7 + 0x3C66663C66663C, // 8 + 0x3C66663E06663C, // 9 }; struct Triple { @@ -421,14 +431,14 @@ public: // 1 = look reverse x // 2 = look along y // 3 = look reverse y - if (num > 25 || num < 0) { + if (num >= sizeof(letters) || num < 0) { return; } switch (direction) { case 0: { for (int i = 0; i < 8; i++) { for (int j = 0; j < 7; j++) { - if ((numbers[num] >> (55 - (i + j * 8))) & 1) { + if ((letters[num] >> (55 - (i + j * 8))) & 1) { Cube::set_status(x, y - i, z - j, brightness); } else { @@ -441,7 +451,7 @@ public: case 1: { for (int i = 0; i < 8; i++) { for (int j = 0; j < 7; j++) { - if ((numbers[num] >> (55 - (i + j * 8))) & 1) { + if ((letters[num] >> (55 - (i + j * 8))) & 1) { Cube::set_status(x, y + i, z - j, brightness); } else { @@ -454,7 +464,7 @@ public: case 2: { for (int i = 0; i < 8; i++) { for (int j = 0; j < 7; j++) { - if ((numbers[num] >> (55 - (i + j * 8))) & 1) { + if ((letters[num] >> (55 - (i + j * 8))) & 1) { Cube::set_status(x + i, y, z - j, brightness); } else { @@ -467,7 +477,7 @@ public: case 3: { for (int i = 0; i < 8; i++) { for (int j = 0; j < 7; j++) { - if ((numbers[num] >> (55 - (i + j * 8))) & 1) { + if ((letters[num] >> (55 - (i + j * 8))) & 1) { Cube::set_status(x - i, y, z - j, brightness); } else { @@ -874,7 +884,7 @@ byte cube_step = 1; bool rain_create_new = false; -String display_string = ""; +String display_string = "MUELSYSE"; int letter_create_layer_count = 0; // When count to 7, it's time to draw the new letter. int next_char_ptr = 0; @@ -1101,11 +1111,14 @@ void words() { if (Serial.available()) { byte input_char = Serial.read(); if (input_char >= 'A' && input_char <= 'Z') { - display_string.concat(input_char); + display_string.concat((char)input_char); } if (input_char >= 'a' && input_char <= 'z') { - display_string.concat(input_char - 'a' + 'A'); + display_string.concat((char)(input_char - 'a' + 'A')); + } + if (input_char >= '0' && input_char <= '9') { + display_string.concat((char)input_char); } if (input_char == '?') { @@ -1114,6 +1127,8 @@ void words() { } if (input_char == '/') { + display_string = ""; + next_char_ptr = 0; Serial.println("Cleared input."); } } @@ -1130,7 +1145,7 @@ void words() { letter_create_layer_count++; - if (letter_create_layer_count < 7 ) { + if (letter_create_layer_count < 7) { // The previous have not been moved out return; } @@ -1143,7 +1158,14 @@ void words() { return; } - Cube::draw_letter(1, 7, 7, display_string[next_char_ptr] - 'A', 2, 3); + if (display_string[next_char_ptr] >= 'A') { + Cube::draw_letter(0, 7, 7, display_string[next_char_ptr] - 'A', 2, 3); + } + else { + Serial.print(display_string[next_char_ptr]); + Cube::draw_letter(0, 7, 7, display_string[next_char_ptr] - '0' + 26, 2, 3); + } + next_char_ptr++; }