Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions wordclockfunctions.ino_javanese
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@

const String clockStringJava = "JAMASETENGAHTELOROLASIJIPAPATELUENEMPITUWOLULIMOSEPULOHSONGOOSEWELASPASIKURANGPUNJULLIMOSEPRAPATKATESEPULOHIJURONGPULOHATSELAWEMENIT";

/**
* @brief control the four minute indicator LEDs
*
* @param minutes minutes to be displayed [0 ... 59]
* @param color 24bit color value
*/
void drawMinuteIndicator(uint8_t minutes, uint32_t color) {
//separate LEDs for minutes in an additional row
{
switch (minutes % 5) {
case 0:
break;

case 1:
ledmatrix.setMinIndicator(0b1000, color);
break;

case 2:
ledmatrix.setMinIndicator(0b1100, color);
break;

case 3:
ledmatrix.setMinIndicator(0b1110, color);
break;

case 4:
ledmatrix.setMinIndicator(0b1111, color);
break;
}
}
}

/**
* @brief Draw the given sentence to the word clock
*
* @param message sentence to be displayed
* @param color 24bit color value
* @return int: 0 if successful, -1 if sentence not possible to display
*/
int showStringOnClock(String message, uint32_t color) {
String word = "";
int lastLetterClock = 0;
int positionOfWord = 0;
int index = 0;

// add space on the end of message for splitting
message = message + " ";

// empty the targetgrid
ledmatrix.gridFlush();

while (true) {
// extract next word from message
word = split(message, ' ', index);
index++;

if (word.length() > 0) {
// find word in clock string
positionOfWord = clockStringJava.indexOf(word, lastLetterClock);

if (positionOfWord >= 0) {
// word found on clock -> enable leds in targetgrid
for (unsigned int i = 0; i < word.length(); i++) {
int x = (positionOfWord + i) % WIDTH;
int y = (positionOfWord + i) / WIDTH;
ledmatrix.gridAddPixel(x, y, color);
}
// remember end of the word on clock
lastLetterClock = positionOfWord + word.length();
} else {
// word is not possible to show on clock
logger.logString("word is not possible to show on clock: " + String(word));
return -1;
}
} else {
// end - no more word in message
break;
}
}
// return success
return 0;
}

/**
* @brief Converts the given time as sentence (String)
*
* @param hours hours of the time value
* @param minutes minutes of the time value
* @return String time as sentence
*/
String timeToString(uint8_t hours, uint8_t minutes) {

String message = "JAM ";

hours = hours % 12;

if (minutes >= 30)
hours = (hours + 1) % 12;

if (hours == 0)
hours = 12;

if (minutes >= 30 && minutes < 35)
message += "SETENGAH ";

// show hours
switch (hours) {
case 1:
message += "SIJI ";
break;
case 2:
message += "LORO ";
break;
case 3:
message += "TELU ";
break;
case 4:
message += "PAPAT ";
break;
case 5:
message += "LIMO ";
break;
case 6:
message += "ENEM ";
break;
case 7:
message += "PITU ";
break;
case 8:
message += "WOLU ";
break;
case 9:
message += "SONGO ";
break;
case 10:
message += "SEPULOH ";
break;
case 11:
message += "SEWELAS ";
break;
case 12:
message += "ROLAS ";
break;
}

if (minutes >= 35) {
message += "KURANG ";
} else if (minutes >= 5 && minutes < 30) {
message += "PUNJUL ";
}

//show minutes
if (minutes >= 5 && minutes < 10) {
message += "LIMO MENIT ";
} else if (minutes >= 10 && minutes < 15) {
message += "SEPULOH MENIT ";
} else if (minutes >= 15 && minutes < 20) {
message += "SEPRAPAT MENIT";
} else if (minutes >= 20 && minutes < 25) {
message += "RONGPULOH MENIT ";
} else if (minutes >= 25 && minutes < 30) {
message += "SELAWE MENIT ";
} else if (minutes >= 30 && minutes < 35) {
// message += "SETENGAH ";
} else if (minutes >= 35 && minutes < 40) {
message += "SELAWE MENIT ";
} else if (minutes >= 40 && minutes < 45) {
message += "RONGPULOH MENIT ";
} else if (minutes >= 45 && minutes < 50) {
message += "SEPRAPAT MENIT ";
} else if (minutes >= 50 && minutes < 55) {
message += "SEPULOH MENIT ";
} else if (minutes >= 55 && minutes < 60) {
message += "LIMO MENIT ";
}


if (minutes < 5 || (minutes >= 30 && minutes < 35)) {
message += "PAS ";
}

logger.logString("time as String: " + String(message));

return message;
}