DGUS LCD Library
1
|
DGUS II LCD Driver Utility functions. More...
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <time.h>
#include "dgus.h"
Functions | |
struct | __attribute__ ((packed)) |
A packet header that every packet needs len incudes data + 1 (for cmd byte) More... | |
void | dgus_init (ser_available_handler_cb avail, ser_recv_handler_cb recv, ser_send_handler_cb send, packet_handler_cb packet_handler) |
Initialise the DGUS LCD interface. More... | |
DGUS_RETURN | _polling_wait () |
Wait for the OK to return or data to arrive. More... | |
DGUS_RETURN | send_data (enum command cmd, dgus_packet *p) |
actually send the packet p with write cmd More... | |
int | dgus_recv_data () |
Receive and process data from the serial port. Call this in your main loop. More... | |
void | buffer_u8 (dgus_packet *p, uint8_t *data, size_t len) |
Append 1 byte len bytes to the send buffer in 8 bit format. More... | |
void | buffer_u16 (dgus_packet *p, uint16_t *data, size_t len) |
Append 2 bytes len bytes to the send buffer in 16 bit format. More... | |
void | buffer_u32 (dgus_packet *p, uint32_t *data, size_t len) |
Append 4 bytes len bytes to the send buffer in 2x word format. More... | |
void | buffer_u32_1 (dgus_packet *p, uint32_t data) |
Append 4 bytes 1 long of data to the send buffer in 8 bit format. More... | |
dgus_packet * | dgus_packet_init () |
Manually initialise the packet sending buffer. More... | |
void | dgus_packet_set_data (dgus_packet *p, uint8_t offset, uint8_t *data, uint8_t len) |
Write 8 bites of data at position n in the buffer. More... | |
DGUS_RETURN | dgus_request_var (uint16_t addr, uint8_t len) |
Async request a variable It is up to you to read the response. More... | |
DGUS_RETURN | dgus_get_var8 (uint16_t addr, uint8_t *buf, uint8_t len) |
Get len 8 bit bytes from the device. no encoding is applied. More... | |
DGUS_RETURN | dgus_get_var (uint16_t addr, uint16_t *buf, uint8_t len) |
Read len bytes into buf at address addr . More... | |
DGUS_RETURN | dgus_set_var (uint16_t addr, uint32_t data) |
Set data variable into addr on the DGUS. More... | |
DGUS_RETURN | dgus_set_var8 (uint16_t addr, uint8_t *data, uint8_t len) |
Set len 8 bit bytes to the device. no encoding is applied. More... | |
DGUS_RETURN | dgus_set_cmd (uint16_t addr, uint8_t *data, uint8_t len) |
Set data in the cmd area of the configuration. More... | |
DGUS_RETURN | dgus_get_cmd (uint16_t addr, uint8_t *data, uint8_t len) |
Get data from the cmd registers. More... | |
void | dgus_packet_set_len (dgus_packet *p, uint16_t len) |
Override a packets current length. More... | |
uint8_t * | dgus_packet_get_recv_buffer () |
Get a pointer the current data recv buffer. More... | |
DGUS_RETURN | _polling_read_16 (uint8_t *buf, uint8_t len) |
Poll and read a 16 bit return value. More... | |
Variables | |
dgus_packet_header | |
dgus_var_data | |
DGUS II LCD Driver Utility functions.
struct __attribute__ | ( | (packed) | ) |
A packet header that every packet needs len incudes data + 1 (for cmd byte)
DGUS_RETURN _polling_read_16 | ( | uint8_t * | buf, |
uint8_t | len | ||
) |
DGUS_RETURN _polling_wait | ( | ) |
Wait for the OK to return or data to arrive.
void buffer_u16 | ( | dgus_packet * | p, |
uint16_t * | data, | ||
size_t | len | ||
) |
Append 2 bytes len bytes to the send buffer in 16 bit format.
p | dgus_packet packet |
data | data to write |
len | length of data bytes to write |
void buffer_u32 | ( | dgus_packet * | p, |
uint32_t * | data, | ||
size_t | len | ||
) |
Append 4 bytes len bytes to the send buffer in 2x word format.
p | dgus_packet packet |
data | data to write |
len | length of data bytes to write |
void buffer_u32_1 | ( | dgus_packet * | p, |
uint32_t | data | ||
) |
Append 4 bytes 1 long of data to the send buffer in 8 bit format.
p | dgus_packet packet |
data | data to write |
void buffer_u8 | ( | dgus_packet * | p, |
uint8_t * | data, | ||
size_t | len | ||
) |
Append 1 byte len bytes to the send buffer in 8 bit format.
p | dgus_packet packet |
data | data to write |
len | length of data bytes to write |
DGUS_RETURN dgus_get_cmd | ( | uint16_t | addr, |
uint8_t * | data, | ||
uint8_t | len | ||
) |
DGUS_RETURN dgus_get_var | ( | uint16_t | addr, |
uint16_t * | buf, | ||
uint8_t | len | ||
) |
Read len
bytes into buf
at address addr
.
addr | |
buf | |
len |
DGUS_RETURN dgus_get_var8 | ( | uint16_t | addr, |
uint8_t * | buf, | ||
uint8_t | len | ||
) |
Get len
8 bit bytes from the device. no encoding is applied.
addr | |
buf | |
len |
void dgus_init | ( | ser_available_handler_cb | avail, |
ser_recv_handler_cb | recv, | ||
ser_send_handler_cb | send, | ||
packet_handler_cb | packet_handler | ||
) |
Initialise the DGUS LCD interface.
Callbacks allow platform independance. On Arduino like platforms, avail would be "SerialPort.available()"
avail | ser_available_handler_cb callback for the amount of bytes available |
recv | function that receives bytes from the serial port |
send | function that sends bytes over the serial port |
packet_handler | function that should be called when the lcd has sent a packet to be processed |
uint8_t* dgus_packet_get_recv_buffer | ( | ) |
Get a pointer the current data recv buffer.
dgus_packet* dgus_packet_init | ( | ) |
Manually initialise the packet sending buffer.
void dgus_packet_set_data | ( | dgus_packet * | p, |
uint8_t | offset, | ||
uint8_t * | data, | ||
uint8_t | len | ||
) |
Write 8 bites of data at position n in the buffer.
p | dgus_packet packet |
offset | where in the buffer to write |
data | data to write |
len | length of data bytes to write |
void dgus_packet_set_len | ( | dgus_packet * | p, |
uint16_t | len | ||
) |
Override a packets current length.
p | |
len |
int dgus_recv_data | ( | ) |
Receive and process data from the serial port. Call this in your main loop.
DGUS_RETURN dgus_request_var | ( | uint16_t | addr, |
uint8_t | len | ||
) |
Async request a variable It is up to you to read the response.
addr | VAR Addres to read from |
len | number of bytes to read |
DGUS_RETURN dgus_set_cmd | ( | uint16_t | addr, |
uint8_t * | data, | ||
uint8_t | len | ||
) |
Set data in the cmd area of the configuration.
addr | |
data | |
len |
DGUS_RETURN dgus_set_var | ( | uint16_t | addr, |
uint32_t | data | ||
) |
Set data
variable into addr
on the DGUS.
addr | address of the VAR data in word (u16) format |
data | data to send |
DGUS_RETURN dgus_set_var8 | ( | uint16_t | addr, |
uint8_t * | data, | ||
uint8_t | len | ||
) |
Set len
8 bit bytes to the device. no encoding is applied.
addr | |
data | |
len |
DGUS_RETURN send_data | ( | enum command | cmd, |
dgus_packet * | p | ||
) |
actually send the packet p with write cmd
cmd | command type such as DGUS_CMD_VAR_W |
p | packet handle |
dgus_packet_header |
packet header structure
dgus_var_data |
Header for a VAR command