Monday, December 31, 2018

Chinese Character Hex Bitmapper For Sino:bit

In an effort to help realize the goal of making the Sino:bit accessible to novice coders in non-Latin based languages here is an app that allows you to paste a Chinese character and get a char array representing a bitmap version of the character. The array can be uploaded and displayed on the Sino:bit with the Arduino IDE.
While the Sino:bit features a 12 X 12 matrix of LEDs the character representation is limited to an 11 X 11 grid, due to the dimension of the font I used, SolidZORO's zpix font. So, many characters in Chinese, even simplified as found here, will be too complex to represent effectively, but it is a start!
The app is made in Processing using export as application feature. For Mac this means it is self-signed and I find must be moved to Desktop, Documents, or Application folder for the text file output to work. If left in Downloads the app freezes when trying to run output. I must give a shout out to this resource (last post in the thread) for pasting clipboard content into a Processing app. I struggled with this and finally got it to work thanks to this! Without a paste from clipboard feature I couldn't see being able to make this into an app. As far as I can tell Chinese characters can't be typed in to a text field in a Processing sketch, as much as I tried (though I am not very good at it).
To use the char array in an Arduino sketch, pass it to a drawBitmap function call like this:
 #include <sinobit.h>  
 Sinobit matrix = Sinobit();  
 const unsigned char myBitmap [] PROGMEM = {  
 // char bitmap of 见  
  0x7f,0xc0,  
  0x40,0x40,  
  0x40,0x40,  
  0x44,0x40,  
  0x44,0x40,  
  0x44,0x40,  
  0x44,0x40,  
  0x04,0x00,  
  0x0a,0x20,  
  0x32,0x20,  
  0xc3,0xe0,  
  0x00,0x00,  
 };  
 void setup() {  
  matrix.begin();  
 }  
 void loop() {  
  matrix.drawBitmap(0, 0, myBitmap, 12, 12, 1);  
  matrix.writeScreen();  
 }  

Here is the app for Mac.
Here is the app for PC (not tested yet).
For more things to do with the Sino:bit LED matrix, see this post.

No comments :