I got two files for a 7 segment display, connected in a trivial way (i.e PORTA 0 to segment a ... PORTA 6 to segment g):
a file to be included only once, simple.h
python litseg.py -s simple -w simple.txt -f b >t && cat simple.h #ifndef __SIMPLE_H #define __SIMPLE_H #define MASK_SIMPLE 0b01111111 #define NMASK_SIMPLE 0xFF ^ 0b01111111 void init_simple(); void ecrit_simple(uint8_t digit); uint8_t codes_PORTAsimple [10 ] = { 0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110, 0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01101111 }; #endif
and a file to be compiled and linked, simple.c
#include "simple.h" void init_simple() { DDRA = 0b01111111; } void ecrit_simple(uint8_t digit) { PORTA &= ~0b01111111; PORTA |= codes[digit]; }
Connections are such a segment is lit if the correponding pin is high...
When one writes a digit to a (or more, later) port(s), one takes care not to corrupt the other unused pins -maybe used elsewhere-
Are these two simple files correct ?