mirror of
https://github.com/Derisis13/AT-VFD.git
synced 2025-12-06 19:32:49 +01:00
* made the code leaner
This commit is contained in:
@@ -11,7 +11,7 @@ include_directories(/usr/lib/avr/include)
|
|||||||
|
|
||||||
add_link_options(-Wl,--print-memory-usage)
|
add_link_options(-Wl,--print-memory-usage)
|
||||||
add_executable(${PROJECT_NAME} main.c
|
add_executable(${PROJECT_NAME} main.c
|
||||||
#PT6302.c PT6302.h
|
PT6302.c PT6302.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
|
|||||||
21
PT6302.c
21
PT6302.c
@@ -45,29 +45,24 @@ void transmit_bytes (const uint8_t *payload, const uint8_t size)
|
|||||||
PORTB |= CSBpin;
|
PORTB |= CSBpin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_command (const uint8_t command)
|
|
||||||
{
|
|
||||||
transmit_bytes (&command, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void set_display_brightness (uint8_t level)
|
void set_display_brightness (uint8_t level)
|
||||||
{
|
{
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case 0:send_command (0x0A);
|
case 0:transmit_bytes (0x0A, 1);
|
||||||
break;
|
break;
|
||||||
case 1:send_command (0x2A);
|
case 1:transmit_bytes (0x2A, 1);
|
||||||
break;
|
break;
|
||||||
case 2:send_command (0x4A);
|
case 2:transmit_bytes (0x4A, 1);
|
||||||
break;
|
break;
|
||||||
case 3:send_command (0x6A);
|
case 3:transmit_bytes (0x6A, 1);
|
||||||
break;
|
break;
|
||||||
case 4:send_command (0x8A);
|
case 4:transmit_bytes (0x8A, 1);
|
||||||
break;
|
break;
|
||||||
case 5:send_command (0xAA);
|
case 5:transmit_bytes (0xAA, 1);
|
||||||
break;
|
break;
|
||||||
case 6:send_command (0xCA);
|
case 6:transmit_bytes (0xCA, 1);
|
||||||
default:send_command (0xEA);
|
default:transmit_bytes (0xEA, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
main.c
9
main.c
@@ -1,18 +1,15 @@
|
|||||||
#define F_CPU 8000000UL
|
#define F_CPU 8000000UL
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
#include "PT6302.h"
|
||||||
|
|
||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
uint8_t ledpin = (1 << PC4);
|
PT6302_startup ();
|
||||||
DDRC |= ledpin;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
PORTC |= ledpin;
|
|
||||||
_delay_ms (1000);
|
|
||||||
PORTC &= ~ledpin;
|
|
||||||
_delay_ms (1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user