尝试words。
This commit is contained in:
@@ -874,6 +874,11 @@ byte cube_step = 1;
|
||||
|
||||
bool rain_create_new = false;
|
||||
|
||||
String display_string = "";
|
||||
int letter_create_layer_count = 0;
|
||||
// When count to 7, it's time to draw the new letter.
|
||||
int next_char_ptr = 0;
|
||||
|
||||
void setup() {
|
||||
for (int i = 22; i < 46; i++) {
|
||||
pinMode(i, OUTPUT);
|
||||
@@ -1093,7 +1098,53 @@ void clock() {
|
||||
}
|
||||
|
||||
void words() {
|
||||
return;
|
||||
if (Serial.available()) {
|
||||
byte input_char = Serial.read();
|
||||
if (input_char >= 'A' && input_char <= 'Z') {
|
||||
display_string.concat(input_char);
|
||||
}
|
||||
|
||||
if (input_char >= 'a' && input_char <= 'z') {
|
||||
display_string.concat(input_char - 'a' + 'A');
|
||||
}
|
||||
|
||||
if (input_char == '?') {
|
||||
Serial.print("Current string: ");
|
||||
Serial.println(display_string);
|
||||
}
|
||||
|
||||
if (input_char == '/') {
|
||||
Serial.println("Cleared input.");
|
||||
}
|
||||
}
|
||||
|
||||
delay(50);
|
||||
|
||||
// Move everything one light forward.
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
Cube::LED_brightness[i][j] = Cube::LED_brightness[i][j] >> 2;
|
||||
Cube::LED_status[i][j] = Cube::LED_status[i][j] >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
letter_create_layer_count++;
|
||||
|
||||
if (letter_create_layer_count < 7 ) {
|
||||
// The previous have not been moved out
|
||||
return;
|
||||
}
|
||||
|
||||
letter_create_layer_count = 0;
|
||||
|
||||
if (next_char_ptr == display_string.length()) {
|
||||
// Displayed all chars. 'Display' a space and reverse to the first char.
|
||||
next_char_ptr = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Cube::draw_letter(1, 7, 7, display_string[next_char_ptr] - 'A', 2, 3);
|
||||
next_char_ptr++;
|
||||
}
|
||||
|
||||
void calculate_and_draw() {
|
||||
|
||||
Reference in New Issue
Block a user