Added Makefile. Now builds. DOS->UNIX

This commit is contained in:
DWW 2021-06-27 16:35:34 +03:00
parent de681b31bc
commit 24ba7eab98
4 changed files with 901 additions and 891 deletions

8
code/Makefile Normal file
View File

@ -0,0 +1,8 @@
all:
make build
make program
build:
avr-gcc main.c i2c_master.c -o counter -mmcu=attiny85
program:
avrdude

View File

@ -74,6 +74,26 @@ const uint8_t PROGMEM rot_table[16] =
EVENT_NONE, EVENT_ROT_CCW, EVENT_ROT_CW, EVENT_NONE
};
const uint8_t PROGMEM unfold_table[16] =
{
0x00,
0x02,
0x08,
0x0A,
0x20,
0x22,
0x28,
0x2A,
0x80,
0x82,
0x88,
0x8A,
0xA0,
0xA2,
0xA8,
0xAA
};
const uint8_t PROGMEM symbols[80] =
{
0x3D, 0x51, 0x49, 0x45, 0x3D, // 0
@ -102,7 +122,7 @@ void display_enable(uint8_t en);
void get_symbol16(uint8_t index, uint8_t *out);
void print_symbol(uint8_t symbol_idx, uint8_t x, uint8_t y, uint8_t invert);
void print_mm(uint32_t value, uint32_t highlight);
void print_direction(uint8_t is_up);
void print_direction(uint8_t is_up, uint8_t invert);
void print_voltage(uint16_t value);
uint16_t adc_measure();
uint16_t get_voltage();
@ -379,7 +399,7 @@ int main()
++eeprom_idx;
eeprom_idx %= EEPROM_SIZE;
write_eeprom_val(idx, count_value, move_dir);
write_eeprom_val(eeprom_idx, count_value, move_dir);
}
update_display(count_value, highlight, move_dir, dir_highlight);
@ -532,25 +552,6 @@ void get_symbol16(uint8_t index, uint8_t *out)
{
uint8_t i;
uint8_t data_byte;
const uint8_t PROGMEM unfold_table[16] =
{
0x00,
0x02,
0x08,
0x0A,
0x20,
0x22,
0x28,
0x2A,
0x80,
0x82
0x88,
0x8A,
0xA0,
0xA2,
0xA8,
0xAA
};
for (i = 0; i < CHAR_SIZE * 4; ++i)
{
@ -568,7 +569,7 @@ void get_symbol16(uint8_t index, uint8_t *out)
void print_symbol(uint8_t symbol_idx, uint8_t x, uint8_t y, uint8_t invert)
{
uint8_t unfolded_symbol[CHAR_SIZE * 4];
uint8_t cmd_list[6]
uint8_t cmd_list[6] =
{
0x21, // Set Column Address
0x00, // Start Address
@ -591,7 +592,7 @@ void print_symbol(uint8_t symbol_idx, uint8_t x, uint8_t y, uint8_t invert)
x = x % (OLED_X_SIZE);
y = y % (OLED_Y_SIZE / (8 * 2));
if (x > (OLED_X_SIZE - CHAR_SIZE * 2)
if (x > (OLED_X_SIZE - CHAR_SIZE * 2))
{
x = OLED_X_SIZE - CHAR_SIZE * 2;
}
@ -735,7 +736,8 @@ uint16_t measure_voltage()
uint32_t val;
uint16_t result;
val = 110 * 1023;
val = 110;
val *= 1023;
val /= adc_measure();
result = val;
@ -844,5 +846,5 @@ void update_display(uint32_t value, uint32_t highlight, uint8_t dir, uint8_t dir
{
print_mm(value, highlight);
print_direction(dir, dir_highlight);
print_voltage(get_voltage());
print_voltage(measure_voltage());
}