summaryrefslogtreecommitdiffstats
path: root/crypto/ssd1306.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/ssd1306.c')
-rw-r--r--crypto/ssd1306.c138
1 files changed, 111 insertions, 27 deletions
diff --git a/crypto/ssd1306.c b/crypto/ssd1306.c
index 7421669..4b009b2 100644
--- a/crypto/ssd1306.c
+++ b/crypto/ssd1306.c
@@ -182,12 +182,61 @@ sd_cmd (uint8_t c)
}
+
+static uint8_t cur_x;
+static uint8_t cur_y;
+
static int
sd_dat (uint8_t c)
{
+ cur_x++;
return sd_write (1, c);
}
+static int
+sd_dat0s (size_t len)
+{
+ int ret = 0;
+
+ i2c_start ();
+
+ i2c_send_byte (SAD | WRITE);
+ ret |= i2c_recv_ack ();
+ i2c_send_byte (0x40);
+ ret |= i2c_recv_ack ();
+
+ while (len--) {
+ i2c_send_byte (0);
+ ret |= i2c_recv_ack ();
+ cur_x++;
+ }
+ i2c_stop ();
+
+ return ret;
+}
+
+static int
+sd_dats (uint8_t *v,size_t len)
+{
+ int ret = 0;
+
+ i2c_start ();
+
+ i2c_send_byte (SAD | WRITE);
+ ret |= i2c_recv_ack ();
+ i2c_send_byte (0x40);
+ ret |= i2c_recv_ack ();
+
+ while (len--) {
+ i2c_send_byte (*(v++));
+ ret |= i2c_recv_ack ();
+ cur_x++;
+ }
+ i2c_stop ();
+
+ return ret;
+}
+
static int
@@ -209,6 +258,8 @@ sd_cols (uint8_t s, uint8_t e)
ret |= sd_cmd (s);
ret |= sd_cmd (e);
+ cur_x=s;
+
return ret;
}
@@ -222,10 +273,68 @@ sd_rows (uint8_t s, uint8_t e)
ret |= sd_cmd (s);
ret |= sd_cmd (e);
+ cur_y=s;
+
return ret;
}
+void sd_putstr(char *s,int x,int y)
+{
+static uint8_t d[8];
+
+while (*s) {
+
+if (x!=cur_x)
+ sd_cols (x, 127);
+if (y!=cur_y)
+ sd_rows (y, 3);
+
+gt_read_8x8(*s,d,sizeof(d));
+sd_dats(d,sizeof(d));
+
+x+=8;
+
+if (x==128) {
+ x=0;
+ y++;
+}
+
+if (y==4)
+ y=0;
+
+
+s++;
+}
+
+}
+
+
+void sd_cls(void)
+{
+
+ sd_cols (0, 127);
+ sd_rows (0, 3);
+
+ sd_dat0s(128*4);
+
+}
+
+void
+sd_doodle (void)
+{
+//static uint8_t d[8];
+
+sd_putstr("Fishsoup",0,0);
+
+
+//gt_read_8x8('f',d,sizeof(d));
+//sd_dats(d,sizeof(d));
+
+
+}
+
+
void
sd_on (void)
{
@@ -300,33 +409,8 @@ sd_on (void)
sd_address_mode (0);
sd_cols (0, 127);
- sd_rows (0, 63);
-}
-
-void
-sd_doodle (void)
-{
- static uint8_t d[8];
- random_vector_generate(d,1);
- uint32_t a;
-
-
- a=d[0];
- a%=63;
- a*=8;
- a+=768;
-
- gt_read(a,d,sizeof(d));
-
-
- sd_dat (d[0]);
- sd_dat (d[1]);
- sd_dat (d[2]);
- sd_dat (d[3]);
- sd_dat (d[4]);
- sd_dat (d[5]);
- sd_dat (d[6]);
- sd_dat (d[7]);
+ sd_rows (0, 3);
+ sd_cls();
}