move display code to new file
parent
b738f89cb8
commit
091a8c24e8
@ -0,0 +1,6 @@
|
|||||||
|
extern unsigned char SR_Buffer[6];
|
||||||
|
|
||||||
|
void string_to_buffer(const char input_string[6]);
|
||||||
|
void clock_to_buffer(uint8_t clock[3]);
|
||||||
|
void clear_SR_Buffer(void) ;
|
||||||
|
void print_SR_Buffer(void) ;
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include "pinout.h"
|
||||||
|
|
||||||
|
unsigned char SR_Buffer[6];
|
||||||
|
|
||||||
|
const unsigned char number_Font[10] = {
|
||||||
|
0b11011110, //0
|
||||||
|
0b00000110, //1
|
||||||
|
0b11101010, //2
|
||||||
|
0b01101110, //3
|
||||||
|
0b00110110, //4
|
||||||
|
0b01111100, //5
|
||||||
|
0b11111100, //6
|
||||||
|
0b00001110, //7
|
||||||
|
0b11111110, //8
|
||||||
|
0b01111110 //9
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char character_Font[26] = {
|
||||||
|
0b10111110, //A
|
||||||
|
0b11110100, //b
|
||||||
|
0b11100000, //c
|
||||||
|
0b11100110, //d
|
||||||
|
0b11111000, //e
|
||||||
|
0b10111000, //F
|
||||||
|
0b11011100, //G
|
||||||
|
0b10110100, //h
|
||||||
|
0b00000100, //i
|
||||||
|
0b01000110, //J
|
||||||
|
0b10111100, //K
|
||||||
|
0b11010000, //L
|
||||||
|
0b10011110, //M
|
||||||
|
0b10100100, //n
|
||||||
|
0b11100100, //o
|
||||||
|
0b10111010, //P
|
||||||
|
0b00111110, //q
|
||||||
|
0b10100000, //r
|
||||||
|
0b01111100, //S
|
||||||
|
0b11110000, //t
|
||||||
|
0b11000100, //u
|
||||||
|
0b11000100, //v
|
||||||
|
0b11010110, //W
|
||||||
|
0b10110110, //X
|
||||||
|
0b01110110, //Y
|
||||||
|
0b11101010 //Z
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char character_minus = 0b00100000; //zeigt '-' an
|
||||||
|
|
||||||
|
void string_to_buffer(const char input_string[6]){
|
||||||
|
for(uint8_t i=0; i < 6; i++){
|
||||||
|
if(input_string[i] >= 0x41 && input_string[i] <= 0x5A)
|
||||||
|
SR_Buffer[i] = character_Font[input_string[i] - 0x41];
|
||||||
|
else if(input_string[i] >= 0x30 && input_string[i] <= 0x39)
|
||||||
|
SR_Buffer[i] = number_Font[input_string[i] - 0x30];
|
||||||
|
else if(input_string[i] == 0x2D)
|
||||||
|
SR_Buffer[i] = character_minus;
|
||||||
|
else
|
||||||
|
SR_Buffer[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clock_to_buffer(uint8_t clock[3]){
|
||||||
|
for(uint8_t i=0; i < 3; i++){
|
||||||
|
SR_Buffer[5-(2*i)] = number_Font[clock[i] & 0x0F];
|
||||||
|
SR_Buffer[5-(2*i)-1] = number_Font[(clock[i] & 0xF0)>>4];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_SR_Buffer(void) {
|
||||||
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
|
SR_Buffer[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_SR_Buffer(void) {
|
||||||
|
PORTC &= ~(LATCH_SR);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
|
SPDR = SR_Buffer[i];
|
||||||
|
while (!(SPSR & (1 << SPIF))); //warten auf transferabschluss
|
||||||
|
}
|
||||||
|
PORTC |= LATCH_SR;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue