summaryrefslogtreecommitdiff
path: root/deps/fff/examples/weak_linking/src/display.c
blob: 1b9a7d6e6efba68b03420df931c00586e817489f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <string.h>

#include "display.h"
#include "bus.h"

#define DISPLAY_ADDRESS     0xAF
#define DISPLAY_REG_INIT    0x10
#define DISPLAY_REG_UPDATE  0x20

bool display_init()
{
    char init_config[] = { 0xDE, 0xFE, 0x00 };
    bus_read_write( DISPLAY_ADDRESS, DISPLAY_REG_INIT, (uint8_t*)init_config, 3, false );

    if (init_config[2] != 0x10)
        return false;

    return true;
}

void display_update( const char* info )
{
    int len = strlen( info );

    if ( bus_write( DISPLAY_ADDRESS, DISPLAY_REG_UPDATE, (const uint8_t*)info, len, true ) != true )
    {
        runtime_error("display update failed!");
    }
}