mirror of
https://github.com/cclassic/hcs12ss59t
synced 2024-11-25 03:25:05 +01:00
Add peak indicators to the bar graph
This commit is contained in:
parent
7828be22aa
commit
ed32a6d2fd
38
hcs12ss59t.c
38
hcs12ss59t.c
@ -168,7 +168,24 @@ const char hcs12ss59t_bar_styles[2][5][2] = {
|
|||||||
{0x40, 0x20}, // 2
|
{0x40, 0x20}, // 2
|
||||||
{0x40, 0x30}, // 3
|
{0x40, 0x30}, // 3
|
||||||
{0x40, 0x38} // 4
|
{0x40, 0x38} // 4
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const char hcs12ss59t_tick_styles[2][5][2] = {
|
||||||
|
{
|
||||||
|
{0x80, 0x00}, // 1
|
||||||
|
{0x00, 0x80}, // 2
|
||||||
|
{0x00, 0x01}, // 3
|
||||||
|
{0x00, 0x02}, // 4
|
||||||
|
{0x04, 0x00} // 5
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
{0x40, 0x00}, // 1
|
||||||
|
{0x00, 0x20}, // 2
|
||||||
|
{0x00, 0x10}, // 3
|
||||||
|
{0x00, 0x08}, // 4
|
||||||
|
{0x08, 0x00} // 5
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,7 +193,8 @@ const char hcs12ss59t_bar_styles[2][5][2] = {
|
|||||||
* @param top Top progress bar value. 0 - HCS12SS59T_NUMDIGITS * 5
|
* @param top Top progress bar value. 0 - HCS12SS59T_NUMDIGITS * 5
|
||||||
* @param bottom Bottom progress bar value. 0 - HCS12SS59T_NUMDIGITS * 5
|
* @param bottom Bottom progress bar value. 0 - HCS12SS59T_NUMDIGITS * 5
|
||||||
*/
|
*/
|
||||||
void hcs12ss59t_set_progress(int top, int bottom)
|
void hcs12ss59t_set_progress_peak(uint8_t top, uint8_t bottom,
|
||||||
|
uint8_t peak_top, uint8_t peak_bottom)
|
||||||
{
|
{
|
||||||
char charconf[HCS12SS59T_NUMDIGITS * 2];
|
char charconf[HCS12SS59T_NUMDIGITS * 2];
|
||||||
int full;
|
int full;
|
||||||
@ -189,12 +207,30 @@ void hcs12ss59t_set_progress(int top, int bottom)
|
|||||||
top = HCS12SS59T_NUMDIGITS * 5;
|
top = HCS12SS59T_NUMDIGITS * 5;
|
||||||
if (bottom > HCS12SS59T_NUMDIGITS * 5)
|
if (bottom > HCS12SS59T_NUMDIGITS * 5)
|
||||||
bottom = HCS12SS59T_NUMDIGITS * 5;
|
bottom = HCS12SS59T_NUMDIGITS * 5;
|
||||||
|
if (peak_top > HCS12SS59T_NUMDIGITS * 5)
|
||||||
|
peak_top = HCS12SS59T_NUMDIGITS * 5;
|
||||||
|
if (peak_bottom > HCS12SS59T_NUMDIGITS * 5)
|
||||||
|
peak_bottom = HCS12SS59T_NUMDIGITS * 5;
|
||||||
|
|
||||||
// Clear memory
|
// Clear memory
|
||||||
for (ptr = charconf; ptr < charconf + HCS12SS59T_NUMDIGITS * 2; ++ptr) {
|
for (ptr = charconf; ptr < charconf + HCS12SS59T_NUMDIGITS * 2; ++ptr) {
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate ticks
|
||||||
|
if (peak_top != 0) {
|
||||||
|
peak_top--;
|
||||||
|
ptr = charconf + ((peak_top / 5) * 2);
|
||||||
|
*(ptr++) |= hcs12ss59t_tick_styles[0][peak_top % 5][0];
|
||||||
|
*ptr |= hcs12ss59t_tick_styles[0][peak_top % 5][1];
|
||||||
|
}
|
||||||
|
if (peak_bottom != 0) {
|
||||||
|
peak_bottom--;
|
||||||
|
ptr = charconf + ((peak_bottom / 5) * 2);
|
||||||
|
*(ptr++) |= hcs12ss59t_tick_styles[1][peak_bottom % 5][0];
|
||||||
|
*ptr |= hcs12ss59t_tick_styles[1][peak_bottom % 5][1];
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate top memory
|
// Calculate top memory
|
||||||
for (row = 0; row < 2; ++row) {
|
for (row = 0; row < 2; ++row) {
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
|
@ -53,7 +53,8 @@ void hcs12ss59t_set_buffer(char *data);
|
|||||||
void hcs12ss59t_set_brightness(char brightness);
|
void hcs12ss59t_set_brightness(char brightness);
|
||||||
void hcs12ss59t_set_lights(char lights);
|
void hcs12ss59t_set_lights(char lights);
|
||||||
void hcs12ss59t_set_character(int addr, char *data, int nchar);
|
void hcs12ss59t_set_character(int addr, char *data, int nchar);
|
||||||
void hcs12ss59t_set_progress(int top, int bottom);
|
void hcs12ss59t_set_progress_peak(uint8_t top, uint8_t bottom, uint8_t peak_top, uint8_t peak_bottom);
|
||||||
|
#define hcs12ss59t_set_progress(top,bottom) hcs12ss59t_set_progress_peak(top, bottom, 0, 0)
|
||||||
void hcs12ss59t_en_progress();
|
void hcs12ss59t_en_progress();
|
||||||
|
|
||||||
/* Low level functions */
|
/* Low level functions */
|
||||||
|
Loading…
Reference in New Issue
Block a user