SPKDisplay - A mbed display class and processing imaging tools for 128x64 OLEDs using the SSD1305 driver, connected via SPI.
Dependents: SPK-DVIMXR SPK-DMXer
spk_oled_fontByteMaker--processing.h
00001 // OLED display using SSD1305 driver 00002 // A library by *spark audio-visual 00003 00004 /* Copyright (c) 2011 Toby Harris, MIT License 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00007 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00008 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00009 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in all copies or 00013 * substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00016 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00017 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00018 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00020 */ 00021 00022 int w = 132; 00023 int h = 64; 00024 int scaleFactor = 5; 00025 00026 PImage imgPixel; 00027 color white = color(255, 255, 255, 255); 00028 color black = color(0, 0, 0, 255); 00029 00030 void setup() 00031 { 00032 imgPixel = loadImage("spk_dvimxr_font.png"); 00033 w = imgPixel.width; 00034 h = imgPixel.height; 00035 00036 size(w*scaleFactor, h*scaleFactor); 00037 00038 noSmooth(); 00039 } 00040 00041 void draw() 00042 { 00043 background(0); 00044 image(imgPixel, 0, 0, w*scaleFactor, h*scaleFactor); 00045 } 00046 00047 void mouseDragged() 00048 { 00049 int x = mouseX/scaleFactor; 00050 int y = mouseY/scaleFactor; 00051 00052 imgPixel.set(x, y, white); 00053 } 00054 00055 void mousePressed() 00056 { 00057 int x = mouseX/scaleFactor; 00058 int y = mouseY/scaleFactor; 00059 00060 if (imgPixel.get(x, y) == white) 00061 { 00062 imgPixel.set(x, y, black); 00063 } 00064 else 00065 { 00066 imgPixel.set(x, y, white); 00067 } 00068 } 00069 00070 void keyPressed() 00071 { 00072 int startID = 33; 00073 int stopID = 126; 00074 00075 for (int charID = startID; charID <= stopID; charID++) 00076 { 00077 boolean blank = false; 00078 String output = ""; 00079 int counter = 0; 00080 while (blank == false) 00081 { 00082 int x = (charID-startID)*8 + counter; 00083 00084 char theByte = 0; // byte and other types are signed in java! char is the exception 00085 for (int b = 0; b < 8; b++) 00086 { 00087 if (imgPixel.get(x, b) == white) 00088 { 00089 theByte += pow(2, b); 00090 } 00091 } 00092 00093 if (theByte > 0) 00094 { 00095 if (output.length() > 0) output = output + ", "; 00096 output = output + "0x" + hex(theByte, 2); 00097 } 00098 else 00099 { 00100 blank = true; 00101 println("const uint8_t char" + charID + "[] = {" + counter + ", " + output + "};"); 00102 } 00103 00104 counter++; 00105 } 00106 } 00107 println(); 00108 println("const int characterBytesStartChar = " + startID + ";"); 00109 println("const int characterBytesEndChar = " + stopID + ";"); 00110 print("const uint8_t* characterBytes[] = {"); 00111 for (int charID = startID; charID <= stopID; charID++) 00112 { 00113 print("char" + charID + ", "); 00114 } 00115 println("};"); 00116 }
Generated on Fri Jul 15 2022 01:46:06 by 1.7.2