Romenovaskez / u8glib

Automatically exported from code.google.com/p/u8glib
Other
0 stars 0 forks source link

add support for flip disc devices #118

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
support something like 14 x XY device (2x7 x XY)
1) implement 14h architecture
2) based on this, implement the device

Original issue reported on code.google.com by olikr...@gmail.com on 28 Nov 2012 at 10:00

GoogleCodeExporter commented 8 years ago
should be 14v

Original comment by olikr...@gmail.com on 28 Nov 2012 at 10:01

GoogleCodeExporter commented 8 years ago
do some testing with the u8g_flipdisc_2x7 device (console???)

Original comment by olikr...@gmail.com on 28 Nov 2012 at 10:46

GoogleCodeExporter commented 8 years ago
C++:
U8GLIB_FLIPDISC_2X7 u8g();

/*
  Write data to the flip disc matrix.
  This procedure must be implemented by the user.
  Arguments:
    id: Id for the matrix. Currently always 0.
    page:   A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
    width:  The width of the flip disc matrix. Always equal to WIDTH
    row1:   first data line (7 pixel per byte)
    row2:   first data line (7 pixel per byte)
*/

Original comment by olikr...@gmail.com on 29 Nov 2012 at 8:09

GoogleCodeExporter commented 8 years ago
void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t 
*row1, uint8_t *row2);

Original comment by olikr...@gmail.com on 29 Nov 2012 at 8:13

GoogleCodeExporter commented 8 years ago
device implemented

Original comment by olikr...@gmail.com on 2 Dec 2012 at 6:55

GoogleCodeExporter commented 8 years ago
there is now a procedure to register the callback procedure:
void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, 
uint8_t width, uint8_t *row1, uint8_t *row2))

todo
test and documentation

Original comment by olikr...@gmail.com on 9 Dec 2012 at 6:55

GoogleCodeExporter commented 8 years ago
// current code for the flip disk device

#include "u8g.h"
#include <stdlib.h>
#include <stdio.h>

void writeFlipDiscMatrixRow(uint8_t width, uint8_t *row)
{
  uint8_t i, b;
  for( b = 0; b < 7; b++ )
  {
    for( i = 0; i < width; i++ )
    {
      if ( row[i] & (1<<b) )
      {
    printf("*");
      }
      else
      {
    printf(".");
      }
    }
    printf("\n");
  }
}

/*
  Write data to the flip disc matrix.
  This procedure must be implemented by the user.
  Arguments:
    id: Id for the matrix. Currently always 0.
    page:   A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
    width:  The width of the flip disc matrix. Always equal to WIDTH
    row1:   first data line (7 pixel per byte)
    row2:   first data line (7 pixel per byte)
*/
void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t 
*row1, uint8_t *row2)
{
  writeFlipDiscMatrixRow(width, row1);
  writeFlipDiscMatrixRow(width, row2);
}

u8g_t u8g1;
u8g_t u8g2;
u8g_t u8g;

int main(void)
{
  u8g_uint_t h;

  u8g_Init(&u8g1, &u8g_dev_flipdisc_2x7);
  u8g_SetFlipDiscCallback(&u8g1, writeFlipDiscMatrix);
  u8g_Init(&u8g2, &u8g_dev_flipdisc_2x7);
  u8g_SetFlipDiscCallback(&u8g2, writeFlipDiscMatrix);

  u8g_Init(&u8g, &u8g_dev_vs);

  u8g_SetVirtualScreenDimension(&u8g, 28, 28);
  u8g_AddToVirtualScreen(&u8g, 0, 0, &u8g1);
  u8g_AddToVirtualScreen(&u8g, 0, 14, &u8g2);

  u8g_FirstPage(&u8g);
  do
  {
    u8g_DrawLine(&u8g, 0,0,27,27);
    u8g_SetFont(&u8g, u8g_font_7x13);
    h = u8g_GetFontAscent(&u8g);
    u8g_DrawStr(&u8g, 10, h, "ABCgdef");
    u8g_DrawStr(&u8g, 0, 10+h, "AB");
  }while( u8g_NextPage(&u8g) );
  return 0;
}

Original comment by olikr...@gmail.com on 15 Dec 2012 at 7:11

GoogleCodeExporter commented 8 years ago
documentation finished

Original comment by olikr...@gmail.com on 15 Dec 2012 at 8:32