move display code to new file
This commit is contained in:
6
code/inc/display.h
Normal file
6
code/inc/display.h
Normal file
@@ -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) ;
|
||||||
84
code/src/display.c
Normal file
84
code/src/display.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include <avr/interrupt.h> //interrupts
|
#include <avr/interrupt.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "pinout.h"
|
#include "pinout.h"
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "i2cmaster.h"
|
#include "i2cmaster.h"
|
||||||
#include "DS3231.h"
|
#include "DS3231.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
#define RX_INPUT_BUFFER_SIZE 92
|
#define RX_INPUT_BUFFER_SIZE 92
|
||||||
|
|
||||||
@@ -15,78 +16,6 @@ void check_dip_switches(void);
|
|||||||
void setup(void);
|
void setup(void);
|
||||||
void set_PWM_duty(int dutycycle);
|
void set_PWM_duty(int dutycycle);
|
||||||
|
|
||||||
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 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t parse_nmea_gps(char input_string[RX_INPUT_BUFFER_SIZE], uint8_t output_buffer[3]){
|
int8_t parse_nmea_gps(char input_string[RX_INPUT_BUFFER_SIZE], uint8_t output_buffer[3]){
|
||||||
char* token = strsep(&input_string, ",");
|
char* token = strsep(&input_string, ",");
|
||||||
if(!strcmp("$GPRMC", token)){
|
if(!strcmp("$GPRMC", token)){
|
||||||
@@ -119,7 +48,7 @@ int main(void){
|
|||||||
check_dip_switches();
|
check_dip_switches();
|
||||||
|
|
||||||
if(get_menu_active()){
|
if(get_menu_active()){
|
||||||
PORTC &= ~DOT; // blink dots
|
PORTC &= ~DOT;
|
||||||
string_to_buffer(get_menu_text());
|
string_to_buffer(get_menu_text());
|
||||||
_delay_ms(10);
|
_delay_ms(10);
|
||||||
}
|
}
|
||||||
@@ -128,10 +57,8 @@ int main(void){
|
|||||||
cli();
|
cli();
|
||||||
DS3231_read(clock);
|
DS3231_read(clock);
|
||||||
sei();
|
sei();
|
||||||
for(uint8_t i=0; i < 3; i++){
|
clock_to_buffer(clock);
|
||||||
SR_Buffer[5-(2*i)] = number_Font[clock[i] & 0x0F];
|
|
||||||
SR_Buffer[5-(2*i)-1] = number_Font[(clock[i] & 0xF0)>>4];
|
|
||||||
}
|
|
||||||
PORTC = (PORTC & (~DOT)) | (clock[0]%2) << 4; // blink dots
|
PORTC = (PORTC & (~DOT)) | (clock[0]%2) << 4; // blink dots
|
||||||
_delay_ms(100);
|
_delay_ms(100);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user