Skip to content

Commit

Permalink
issue #822
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Feb 20, 2019
1 parent 35790bc commit ebefbc5
Show file tree
Hide file tree
Showing 6 changed files with 516 additions and 5 deletions.
6 changes: 6 additions & 0 deletions cppsrc/U8g2lib.h
Expand Up @@ -62,6 +62,10 @@ class U8G2 : public Print
U8G2(void) { cpp_next_cb = u8x8_ascii_next; home(); }
u8x8_t *getU8x8(void) { return u8g2_GetU8x8(&u8g2); }
u8g2_t *getU8g2(void) { return &u8g2; }

void sendF(const char *fmt, ...)
{ va_list va; va_start(va, fmt); u8x8_cad_vsendf(u8g2_GetU8x8(&u8g2), fmt, va); va_end(va); }


uint32_t getBusClock(void) { return u8g2_GetU8x8(&u8g2)->bus_clock; }
void setBusClock(uint32_t clock_speed) { u8g2_GetU8x8(&u8g2)->bus_clock = clock_speed; }
Expand Down Expand Up @@ -122,6 +126,8 @@ class U8G2 : public Print

void setDisplayRotation(const u8g2_cb_t *u8g2_cb) {
u8g2_SetDisplayRotation(&u8g2, u8g2_cb); }




bool begin(void) {
Expand Down
3 changes: 3 additions & 0 deletions csrc/u8x8.h
Expand Up @@ -109,6 +109,7 @@


#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <limits.h>

Expand Down Expand Up @@ -599,6 +600,8 @@ uint8_t u8x8_cad_SendMultipleArg(u8x8_t *u8x8, uint8_t cnt, uint8_t arg) U8X8_NO
uint8_t u8x8_cad_SendData(u8x8_t *u8x8, uint8_t cnt, uint8_t *data) U8X8_NOINLINE;
uint8_t u8x8_cad_StartTransfer(u8x8_t *u8x8) U8X8_NOINLINE;
uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8) U8X8_NOINLINE;
void u8x8_cad_vsendf(u8x8_t * u8x8, const char *fmt, va_list va);
void u8x8_SendF(u8x8_t * u8x8, const char *fmt, ...);

/*
#define U8X8_C(c0) (0x04), (c0)
Expand Down
26 changes: 26 additions & 0 deletions csrc/u8x8_cad.c
Expand Up @@ -120,6 +120,32 @@ uint8_t u8x8_cad_EndTransfer(u8x8_t *u8x8)
return u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
}

void u8x8_cad_vsendf(u8x8_t * u8x8, const char *fmt, va_list va)
{
uint8_t d;
u8x8_cad_StartTransfer(u8x8);
while( *fmt != '\0' )
{
d = (uint8_t)va_arg(va, int);
switch(*fmt)
{
case 'a': u8x8_cad_SendArg(u8x8, d); break;
case 'c': u8x8_cad_SendCmd(u8x8, d); break;
case 'd': u8x8_cad_SendData(u8x8, 1, &d); break;
}
fmt++;
}
u8x8_cad_EndTransfer(u8x8);
}

void u8x8_SendF(u8x8_t * u8x8, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
u8x8_cad_vsendf(u8x8, fmt, va);
va_end(va);
}

/*
21 c send command c
22 a send arg a
Expand Down

0 comments on commit ebefbc5

Please sign in to comment.