mirror of
https://github.com/Derisis13/AT-VFD.git
synced 2025-12-06 19:32:49 +01:00
Fix: changed display digits to 15 according to my vfd
Refactor: one function to set display mode Enhancement: made demo program display something Enhancement: changed compiler optimisation for smaller size
This commit is contained in:
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@ MCU=atmega88
|
||||
F_CPU=8000000UL
|
||||
CC=avr-gcc
|
||||
OBJCOPY=avr-objcopy
|
||||
CFLAGS=-std=c99 -Wall -g -O3 -mmcu=${MCU} -DF_CPU=${F_CPU} -I/usr/lib/avr/include/
|
||||
CFLAGS=-std=c99 -Wall -g -Os -mcall-prologues -mmcu=${MCU} -DF_CPU=${F_CPU} -I/usr/lib/avr/include/
|
||||
TARGET=main
|
||||
SRCS=main.c PT6302.c PT6302.h
|
||||
|
||||
|
||||
15
PT6302.c
15
PT6302.c
@@ -93,8 +93,7 @@ void set_duty (uint8_t brightness)
|
||||
{
|
||||
brightness = 7;
|
||||
}
|
||||
const uint8_t command = 0x50 | brightness;
|
||||
transmit_byte (command);
|
||||
transmit_byte (0x50 | brightness);
|
||||
}
|
||||
|
||||
void set_digits (uint8_t digit_count)
|
||||
@@ -138,6 +137,7 @@ void set_CGRAM (const uint8_t address, const uint8_t *data, uint8_t size)
|
||||
}
|
||||
transmit_bytes (payload, size);
|
||||
}
|
||||
|
||||
void set_DCRAM (const uint8_t address, const uint8_t *cg_address, uint8_t size)
|
||||
{
|
||||
if (address > DISPLAY_DIGITS)
|
||||
@@ -152,17 +152,12 @@ void set_DCRAM (const uint8_t address, const uint8_t *cg_address, uint8_t size)
|
||||
}
|
||||
transmit_bytes (payload, size);
|
||||
}
|
||||
void all_on (void)
|
||||
|
||||
void set_display_mode (enum display_modes mode)
|
||||
{
|
||||
const uint8_t command = 0x72;
|
||||
transmit_byte (command);
|
||||
transmit_byte (mode | 0x70);
|
||||
}
|
||||
|
||||
void all_off (void)
|
||||
{
|
||||
const uint8_t command = 0x71;
|
||||
transmit_byte (command);
|
||||
}
|
||||
void PT6302_reset (void)
|
||||
{
|
||||
PORTC &= ~RSTpin;
|
||||
|
||||
18
PT6302.h
18
PT6302.h
@@ -43,6 +43,12 @@ enum RAM_types {
|
||||
ADRAM = 0x30,
|
||||
};
|
||||
|
||||
enum display_modes {
|
||||
NORMAL_MODE = 0x0,
|
||||
ALL_ON = 0x1,
|
||||
ALL_OFF = 0x2,
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
* Initial setup for the VFD controller interface
|
||||
* Sets up the connected pins and leaves them in inactive state.
|
||||
@@ -122,14 +128,8 @@ void set_CGRAM (uint8_t address, const uint8_t *data, uint8_t size);
|
||||
void set_ADRAM (uint8_t address, const uint8_t *data, uint8_t size);
|
||||
|
||||
/* -----------------------------------------
|
||||
* Turn all outputs of the VFD controller on
|
||||
* This is primarily used for testing
|
||||
* Sets the VFD operation mode
|
||||
* See operation modes in enum display_modes
|
||||
* Handles the entire communication
|
||||
* ----------------------------------------- */
|
||||
void all_on (void);
|
||||
|
||||
/* ------------------------------------------
|
||||
* Turn all outputs of the VFD controller off
|
||||
* Handles the entire communication
|
||||
* ------------------------------------------ */
|
||||
void all_off (void);
|
||||
void set_display_mode (enum display_modes mode);
|
||||
12
main.c
12
main.c
@@ -18,8 +18,7 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
#define F_CPU 8000000UL
|
||||
#define DISPLAY_DIGITS 12
|
||||
#define DISPLAY_DIGITS 15
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
@@ -28,10 +27,10 @@
|
||||
int main ()
|
||||
{
|
||||
static const uint8_t digitstates[] =
|
||||
{0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11, 0b11};
|
||||
{0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00, 0b00};
|
||||
static const uint8_t custom_chars[8 * 5] = {0};
|
||||
static const uint8_t characters[] =
|
||||
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
{0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x48, 0x41, 0x35, 0x4B, 0x46, 0x55, 0x20, 0x20, 0x20};
|
||||
PT6302_startup ();
|
||||
set_ports (1, 1);
|
||||
set_digits (DISPLAY_DIGITS);
|
||||
@@ -39,11 +38,8 @@ int main ()
|
||||
set_ADRAM (0, digitstates, DISPLAY_DIGITS);
|
||||
set_CGRAM (0, custom_chars, 8);
|
||||
set_DCRAM (0, characters, DISPLAY_DIGITS);
|
||||
set_display_mode (NORMAL_MODE);
|
||||
while (1)
|
||||
{
|
||||
all_on ();
|
||||
_delay_us (1000);
|
||||
all_off ();
|
||||
_delay_us (1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user