Permalink
Browse files

Font updates: added new fonts, changed a way to select a font size / …

…print characters. Global updates: moved to Arduino 1.0, fixed examples
  • Loading branch information...
1 parent 0a46cc6 commit f7f7d4c8088fe0d1402367bf852a064b8eec272c @andykarpov committed Jan 9, 2012
@@ -22,13 +22,14 @@ void loop() {
void demoFlashingCursor() {
panel.clear();
+ panel.set_font(5,7);
panel.flashing_cursor(0,1,5,6,3);
byte x = 0;
char* text = "DEMO";
for (byte i=0; i<strlen(text); i++) {
panel.flashing_cursor(i*6,1,5,6,1);
delay(50);
- panel.putmediumchar(i*6,1,text[i]);
+ panel.put_char(i*6,1,text[i]);
delay(400);
}
delay(2000);
@@ -106,8 +106,11 @@ void playerScored(byte player) {
//draw score
panel.clear();
- panel.putbigdigit(LEFT_SCORE_X,SCORE_Y, leftPlayerScore);
- panel.putbigdigit(RIGHT_SCORE_X,SCORE_Y, rightPlayerScore);
+ panel.set_font(5,12);
+ char sc[2];
+ sprintf(sc, "%d%d", leftPlayerScore, rightPlayerScore);
+ panel.put_char(LEFT_SCORE_X,SCORE_Y, sc[0]);
+ panel.put_char(RIGHT_SCORE_X,SCORE_Y, sc[1]);
panel.rect(11,3,12,4,1);
panel.rect(11,11,12,12,1);
@@ -140,8 +143,8 @@ void drawMenu() {
char prevVolX = 1;
char prevVolY = 1;
panel.clear();
- panel.putstring(0,0,5,"PONG");
- //panel.putstring(0,8,5,"PONG");
+ panel.set_font(5,7);
+ panel.putstring(0,0,"PONG");
delay(1000);
while(!buttonStatus) {
processInputs();
@@ -251,8 +254,9 @@ void loop() {
}
if(state == GAME_OVER) {
panel.clear();
- panel.putstring(0,0,5,"GAME");
- panel.putstring(0,8,5,"OVER");
+ panel.set_font(5,7);
+ panel.putstring(0,0,"GAME");
+ panel.putstring(0,8,"OVER");
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; thisNote++) {
File renamed without changes.
@@ -1,13 +1,22 @@
+/**
+ * A simple clock with big digits example
+ *
+ * Based on DS1307 RTC and 24x16 dot matrix display from Sure Electronics
+ * Author Andy Karpov <andy.karpov@gmail.com>
+ * Copyright (c) 2012
+ */
+
#include <Wire.h>
-#include "ht1632c.h"
+#include <digitalWriteFast.h>
+#include <ht1632c.h>
#include <RealTimeClockDS1307.h>
-#include "Button.h"
+#include <Button.h>
// sure electronics 24x16 panel connected to pins
// DATA - pin 10
// WRCLK - pin 11
// CS1 - pin 4
-ht1632c panel(24,16,10,11,4);
+ht1632c panel;
Button btnMode(2, PULLUP);
Button btnSet(3, PULLUP);
@@ -55,25 +64,18 @@ void loop() {
*/
void printTime(int h, int m) {
- panel.putbigdigit(-1, 2, (h>9) ? (h/10) : 0);
- panel.putbigdigit( 5, 2, h % 10);
-
- panel.putbigdigit(12, 2, (m>9) ? (m/10) : 0);
- panel.putbigdigit(18, 2, m % 10);
+ char time[4];
+ panel.set_font(5,12);
+ sprintf(time, "%d%d%d%d", (h>9) ? (h/10) : 0, h % 10, (m>9) ? (m/10) : 0, m % 10);
+
+ panel.put_char(0, 2, time[0]);
+ panel.put_char( 6, 2, time[1]);
+ panel.put_char(13, 2, time[2]);
+ panel.put_char(19, 2, time[3]);
}
void printDots(boolean on)
-{
-/* panel.plot(11, 4, on);
- panel.plot(11, 5, on);
- panel.plot(12, 4, on);
- panel.plot(12, 5, on);
-
- panel.plot(11, 11, on);
- panel.plot(11, 10, on);
- panel.plot(12, 11, on);
- panel.plot(12, 10, on); */
-
+{
for (byte i=0; i<24; i++) {
panel.plot(i,0, on);
panel.plot(i,15, !on);
View
@@ -9,19 +9,6 @@
#undef abs
#include <stdlib.h>
-/*extern "C" {
- #include "WConstants.h";
-}*/
-
-// it is a russian alphabet translation
-// except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
-PROGMEM prog_uchar utf_recode[] =
- { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,
- 0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
- 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,
- 0xbe,0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7
-};
-
/******************************************************************************
* Constructors
******************************************************************************/
@@ -100,51 +87,34 @@ void ht1632c::set_font(byte width, byte height) {
void ht1632c::put_char(byte x, byte y, char c) {
byte dots;
- if (c >= 'A' && c <= 'Z' || (c >= 'a' && c <= 'z') ) {
- c &= 0x1F; // A-Z maps to 1-26
- }
- else if (c >= '0' && c <= '9') {
- c = (c - '0') + 31;
- }
- else if (c == ' ') {
- c = 0; // space
- }
- else if (c == '.') {
- c = 27; // full stop
- }
- else if (c == '\'') {
- c = 28; // single quote mark
- } else if (c == '!') {
- c = 29; // single quote mark
- } else if (c == '?') {
- c = 30; // single quote mark
- }
-
+ c = c - 32; // offset
if (_font_height <= 8) {
- for (char col=0; col< _font_width; col++) {
+ for (char col=0; col< _font_width; col++) {
switch (_font_width) {
- case 3:
- dots = pgm_read_byte_near(&ht1632c_font_3x5[c][col]);
- break;
- case 5:
- dots = pgm_read_byte_near(&ht1632c_font_5x7[c][col]);
- break;
+ case 3:
+ dots = pgm_read_byte_near(&ht1632c_font_3x5[c][col]);
+ break;
+ case 4:
+ dots = pgm_read_byte_near(&ht1632c_font_4x7[c][col]);
+ break;
+ case 5:
+ dots = pgm_read_byte_near(&ht1632c_font_5x7[c][col]);
+ break;
}
for (char row=0; row < _font_height; row++) {
- if (bitRead(dots, _font_height-row-1))
+ if (bitRead(dots, 7-row))
plot(x+col, y+row, 1);
else
plot(x+col, y+row, 0);
}
}
} else {
- c = c-31; // only digits
for (byte row=0; row < _font_height; row++)
{
- dots = pgm_read_byte_near(&ht1632c_font_6x12[c][row]);
- for (byte col=1; col<_font_width; col++)
+ dots = pgm_read_byte_near(&ht1632c_font_5x12[c][row]);
+ for (byte col=0; col<_font_width; col++)
{
- if (bitRead(dots, _font_width-1-col))
+ if (bitRead(dots, 7-col))
plot(x+col, y+row, 1);
else
plot(x+col, y+row, 0);
Oops, something went wrong.

0 comments on commit f7f7d4c

Please sign in to comment.