src/display.h

Thu, 12 Nov 2020 20:26:35 +0100

author
David Douard <david.douard@sdf3.org>
date
Thu, 12 Nov 2020 20:26:35 +0100
changeset 53
74e85b34d26b
parent 51
d8042bff0e00
child 54
f6774bd0d570
permissions
-rw-r--r--

Reorganize the display + improvements for dimmed flags

- the whole upper zone is now dediacated to the main character line
- make sure eash flag has a dedicated non-overlaping area
- improve support for dimmed flags (not yet properly functionning since this
dimm state is actually stateful, so some major refactorings are needed to
properly handle this).

#ifndef DISPLAY_H
#define DISPLAY_H

#include "Terminal6x8.h"
#include "Mono19x27.h"
#include "Mono15x22.h"
#include "Arial12x12.h"
#include "SSD1322.h"
#include "hp34comm.h"

//typedef enum {
#define FMT_ASCII  0x01
#define FMT_HEX    0x02
#define FMT_BITS   0x04
#define FMT_FLAGS  0x08
#define FMT_IGNORE 0x80
	//} dsp_format_t;


typedef struct _DSP
{
	uint8_t cmd;
	uint8_t color;
	uint8_t bgcolor;
	uint8_t x0;
	uint8_t y0;
	uint8_t fmt; // 0x01=>ascii, 0x02=>hex, 0x04=>bits, 0x08=>flags, 0x80=>ignore
	uint8_t maxsize;
	uint8_t width;
	const unsigned char* font;
	char buffer[MAX_BUFF+1];
} DSP;


static DSP table[] =
{       // cmd,  fg, bg,  x0, y0,       fmt,  maxsize, width, font
	{ 0x00, 0xF, 0x0,  0,  0, FMT_ASCII, MAX_BUFF, 255, Mono19x27}, // main display
	{ 0x0C, 0xF, 0x0,194, 38, FMT_ASCII, 3,        45,  Mono15x22}, // channels display
	{ 0x0A, 0xF, 0x0,  0, 57, FMT_FLAGS, 4,        0, Terminal6x8}, // flags + bits
};

// 9x10
const unsigned char icon_alarm[] __attribute__((aligned (2))) =
{
		0x1c, 0x0,
		0x3e, 0x0,
		0x7f, 0x0,
		0x7f, 0x0,
		0x7f, 0x0,
		0x7f, 0x0,
		0x7f, 0x0,
		0x7f, 0x0,
		0xff, 0x80,
		0x10, 0x0
};

const unsigned char icon_curve[] __attribute__((aligned (2))) =
{
		0x80, 0x0,
		0x80, 0x0,
		0x80, 0x80,
		0x81, 0x0,
		0x9e, 0x0,
		0xa0, 0x0,
		0xc0, 0x0,
		0x80, 0x0,
		0x80, 0x0,
		0xff, 0x80
};

typedef struct _FLAG
{
	uint8_t flag;
	uint8_t x;
	uint8_t y;
	bool reverse;
	bool dimm;
	const char* msg;
	const unsigned char* icon;
} FLAG;

typedef struct _FRAME
{
	uint8_t flag;
	uint8_t x0;
	uint8_t y0;
	uint8_t x1;
	uint8_t y1;
} FRAME;



static const FLAG flags[] =
{
    // flag, x0, y0, reverse, dimm, msg, icon
    // right-side icons area
	// flag is the bit index in the 4 bytes viewed as a 32bits value
    { 0x00, 246, 27,  false, false, NULL, icon_alarm}, // F1.0  01 00 00 00
    { 0x01, 246, 38, false, false, NULL, icon_curve}, // F1.1  02 00 00 00
                                               // F1.2  04 00 00 00 - Channel frame
    { 0x03, 195, 29, false, false, "CHANNEL"},        // F1.3  08 00 00 00
                                               // F1.7  80 00 00 00 - Alarm frame
    { 0x1c, 0,  38,  false, false, "MON"},          // F4.4  00 00 00 10
    { 0x1b, 0,  47,  false, false, "VIEW"},         // F4.3  00 00 00 08
    { 0x1d, 0,  29,  true, false,  "SCAN"},          // F4.5  00 00 00 20
    { 0x1e, 0,  56,  true, false,  "CONFIG"},        // F4.6  00 00 00 40

    { 0x1a, 40,  56,   false, false, "*"},            // F4.2  00 00 00 04
    { 0x19, 50,  56,   false, false, "ADRS"},         // F4.1  00 00 00 02
    { 0x18, 80,  56,   false, false, "RMT"},          // F4.0  00 00 00 01
    { 0x17, 104, 56,   true, false, "ERROR"},         // F3.7  00 00 80 00

    { 0x16, 86, 38,   false, false, "EXT"},          // F3.6  00 00 40 00
    { 0x15, 60, 38,   false, false, "ONCE"},         // F3.5  00 00 20 00

    { 0x13, 40, 38,   false, false, "MEM"},         // F3.3  00 00 08 00


    // col 5
    { 0x0c, 244, 47,  false, false, "4W"},            // F2.4  00 10 00 00
    { 0x0d, 244, 56,  false, false, "OC"},            // F2.5  00 20 00 00

    { 0x12, 40,  47, false, true, "LAST"},        // F3.2  00 00 04 00
    { 0x11, 66,  47, false, true, "MIN"},         // F3.1  00 00 02 00
    { 0x10, 86,  47, false, true, "MAX"},         // F3.0  00 00 01 00
    { 0x0f, 106, 47, false, true, "AVG"},         // F2.7  00 80 00 00

    { 0x05, 152+0,  29, false, false, "Alarm"},    // F1.5  20 00 00 00
    { 0x08, 152+0,  39, false, false, "H"},        // F1.6  40 00 00 00
    { 0x07, 152+6,  39, false, false, "1"},        // F2.3  00 08 00 00
    { 0x06, 152+12, 39, false, false, "2"},        // F2.0  00 01 00 00
    { 0x04, 152+18, 39, false, false, "3"},        // F2.2  00 04 00 00
    { 0x09, 152+24, 39, false, false, "4"},        // F2.1  00 02 00 00
    { 0x0a, 152+30, 39, false, false, "L"},        // F1.4  00 10 00 00

	{ 0x80, 152, 56, true, false, "SHIFT"},   // not an actual command, managed by the front panel
};


static const FRAME frames[] =
{
    { 0x02, 192, 32, 240, 60}, // F1.2 - channel frame
    { 0x0b, 149, 32, 190, 50}, // F1.7 - alarm frame
};


typedef enum {
	FLAG_OFF,
	FLAG_ON,
	FLAG_DIM
} flag_status_t;

typedef struct _FLAG_STATUS
{
	uint8_t flag;
	flag_status_t status;
} FLAG_STATUS;


class Display: public SSD1322
{
public:
	Display(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
					const char* name);

	virtual ~Display();

	void test_dsp();
	void show(uint8_t, const char*, uint8_t);
	void dimm_char(uint8_t);
	void show_splashscreen();
	void show_byescreen();
	void set_flag(uint8_t flag, bool show=true, bool dimm=false);
	void show_flag(uint8_t flag) {set_flag(flag, true);};
	void hide_flag(uint8_t flag) {set_flag(flag, false);};
	void shift_on() {set_flag(0x80, true);};
	void shift_off() {set_flag(0x80, false);};


private:
	uint8_t must_refresh;

};

#endif

mercurial