cboswel / stopwatch

Embedded Systems Design Group Project
0 stars 0 forks source link

Add numbers to LCD #1

Closed cboswel closed 2 months ago

cboswel commented 3 months ago

Complete the binary values in the char_to_digit functions so the correct numbers and characters appear in the test in the LCD branch

awillia123 commented 3 months ago

include "stopwatch.h"

void LCD_init() { /**

void char_to_digit(char character, char shape[2]) {

if (character == '9' || character == '\9') {  // For convenience: int 9 == char '\9' so we can send ints as input
    shape[0] = 0b11110111;
    shape[1] = 0b00000000;
}
else if (character == '8' || character == '\8') {
    shape[0] = 0b11111111;
    shape[1] = 0b00000000;
}
else if (character == '7' || character == '\7') {
    shape[0] = 0b11100000;
    shape[1] = 0b00000000;
}
else if (character == '6' || character == '\6') {
    shape[0] = 0b10111111;
    shape[1] = 0b00000000;
}
else if (character == '5' || character == '\5') {
    shape[0] = 0b10110111;
    shape[1] = 0b00000000;
}
else if (character == '4' || character == '\4') {
    shape[0] = 0b01100111;
    shape[1] = 0b00000000;
}
else if (character == '3' || character == '\3') {
    shape[0] = 0b11110011;
    shape[1] = 0b00000000;
}
else if (character == '2' || character == '\2') {
    shape[0] = 0b11011011;
    shape[1] = 0b00000000;
}
else if (character == '1' || character == '\1') {
    shape[0] = 0b01100000;
    shape[1] = 0b00100000;
}
else if (character == '0' || character == '\0') {
    shape[0] = 0b11111100;
    shape[1] = 0b00101000;
}
// and letters for days of week
else if (character == 'M') {
    shape[0] = 0b01101100;
    shape[1] = 0b10100000;
}
else if (character == 'T') {
    shape[0] = 0b10000000;
    shape[1] = 0b01010000;
}
else if (character == 'W') {
    shape[0] = 0b01101100;
    shape[1] = 0b00001010;
}
else if (character == 'F') {
    shape[0] = 0b10001111;
    shape[1] = 0b00000000;
}
else if (character == 'S') {
    shape[0] = 0b10110111;
    shape[1] = 0b00000000;
}
else if (character == 'o') {
    shape[0] = 0b00111011;
    shape[1] = 0b00000000;
}
else if (character == 'u') {
    shape[0] = 0b00111000;
    shape[1] = 0b00000000;
}
else if (character == 'e') {
    shape[0] = 0b10011111;
    shape[1] = 0b00000000;
}
else if (character == 'h') {
    shape[0] = 0b00101111;
    shape[1] = 0b00000000;
}
else if (character == 'r') {
    shape[0] = 0b00001010;
    shape[1] = 0b00000000;
}
else if (character == 'a') {
    shape[0] = 0b00011010;
    shape[1] = 0b00010000;
}

}

void colons(char shape[2], int pos) { if (pos == 1) { if (STATE != MONTH) { shape[1] |= 0b00000100; // add a colon } else { shape[1] |= 0b00000001; // add a decimal point } } if (pos == 3) { if (STATE == MONTH) { shape[1] |= 0b00000001; // add a decimal point } else if (STATE == CHRONO || STATE == LAP) { shape[1] |= 0b00000100; // add a colon } } }

void set_digit(char shape[2], int pos) { if (pos == 0) { LCDM4 = shape[0]; LCDM5 = shape[1]; } else if (pos == 1) { LCDM6 = shape[0]; LCDM7 = shape[1]; } else if (pos == 2) { LCDM8 = shape[0]; LCDM9 = shape[1]; } else if (pos == 3) { LCDM10 = shape[0]; LCDM11 = shape[1]; } else if (pos == 4) { LCDM2 = shape[0]; LCDM3 = shape[1]; } else if (pos == 5) { LCDM18 = shape[0]; LCDM19 = shape[1]; } }

void show_digit(char character, int pos) { /**

awillia123 commented 3 months ago

LCDfuncts.c updated with correct LCD encoding