├── LICENSE.md ├── README.md ├── examples ├── CompleteTest │ ├── CompleteTest.ino │ └── bitmaps.h ├── Sample1-Basic │ ├── Sample1-Basic.ino │ └── bitmaps.h ├── Sample2-Mirror │ ├── Sample2-Mirror.ino │ └── bitmaps.h ├── Sample3-Resize │ ├── Sample3-Resize.ino │ └── bitmaps.h ├── Sample4-Animation │ ├── Sample4-Animation.ino │ └── bitmaps.h ├── Sample5-Basic-Arduboy2 │ ├── Sample5-Basic-Arduboy2.ino │ └── bitmaps.h └── Sample6-Complex │ ├── Sample6-Complex.ino │ └── bitmaps.h ├── extras ├── compressor │ └── compressor2.0.jar └── images │ ├── boy.gif │ ├── dog.gif │ └── test.png ├── keywords.txt ├── library.properties └── src └── ArdBitmap.h /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArdBitmap: Compress and draw bitmaps on the Arduboy 2 | By @igvina 3 | ## Features: 4 | ### Bitmap library: 5 | * Works with compressed & uncompressed bitmaps. 6 | * Real-time image resize (downscale). 7 | * Horizontal/Vertical mirroring (fast). 8 | * Bitmap alignment. 9 | 10 | ### Bitmap compressor: 11 | * Compatible with PC/MAC/Linux (made with Java). 12 | * Good compression (better than Cabi). 13 | * Supports PNG, GIF (also animated gifs) & JPG. 14 | * Autogenerate sketches from images or animated gifs (great for no-developers). 15 | 16 | ## Video: 17 | 18 | DEMO 21 | 22 | ## Usage: 23 | ### Compressor (v2.0): 24 | * Syntax: java -jar compressor2.0.jar image [-options] 25 | * options: 26 | * -gs SKETCH_FOLDER Generate sketch code 27 | * -fr VALUE Change frame rate (only animated gifs) 28 | * -v View compressed image 29 | * -anp PREFIX Array name prefix 30 | * -ver Show encoder version 31 | 32 | * examples: 33 | 34 | "java -jar compressor2.0.jar dog.gif -gs DOG -fr 15" 35 | "java -jar compressor2.0.jar dance.png -v" 36 | 37 | * Notes: 38 | * Supports PNG, GIF (also animated gifs) & JPG 39 | * Max image size = 128 x 64 pixels (resized if bigger) 40 | * Encoding ratio could be bigger than 1 (worse than original image) 41 | 42 | ### Bitmap library (v2.0.x): 43 | * Install the ArdBitmap library in the Arduino IDE. The library can be installed using the Arduino IDE library manager: 44 | 45 | - In the Arduino IDE select from the menus: `Sketch > Include Library > Manage Libraries...` 46 | - In the Library Manager *Filter your search...* field enter *ardbitmap* 47 | - Click somewhere within the ArdBitmap entry. 48 | - Click on the *Install* button. 49 | 50 | For more library installation information see: 51 | 52 | [Installing Additional Arduino Libraries - Using the Library Manager](https://www.arduino.cc/en/Guide/Libraries#toc3) 53 | 54 | * In .ino file, add ArdBitmap library instance after main library instance: 55 | 56 | ```cpp 57 | // make an instance of the Arduboy2 class used for many functions 58 | Arduboy2 arduboy; 59 | 60 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 61 | #define ARDBITMAP_SBUF arduboy.getBuffer() 62 | #include 63 | ArdBitmap ardbitmap; 64 | ``` 65 | 66 | * See the _Library instance details_ section below for more information on creating an ArdBitmap class instance. 67 | 68 | * To draw, call function: ardbitmap.drawCompressed(...) , ardbitmap.drawCompressedResized(...) , ardbitmap.drawBitmap(...) , ardbitmap.drawBitmapResized(...) 69 | 70 | #### Methods: 71 | 72 | ##### Compressed images: 73 | * `void drawCompressed(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color, uint8_t align, uint8_t mirror);` 74 | * `void drawCompressedResized(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color,uint8_t align, uint8_t mirror, float resize);` 75 | 76 | ##### Uncompressed images: 77 | * `void drawBitmap(int16_t sx, int16_t sy, const uint8_t *bitmap,uint8_t w, uint8_t h, uint8_t color, uint8_t align, uint8_t mirror);` 78 | * `void drawBitmapResized(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t w,uint8_t h, uint8_t color,uint8_t align, uint8_t mirror, float resize);` 79 | 80 | #### Defines: 81 | * `#define ALIGN_H_LEFT` 82 | * `#define ALIGN_H_RIGHT` 83 | * `#define ALIGN_H_CENTER` 84 | * `#define ALIGN_V_TOP` 85 | * `#define ALIGN_V_BOTTOM` 86 | * `#define ALIGN_V_CENTER` 87 | * `#define ALIGN_CENTER` 88 | * `#define ALIGN_NONE` 89 | * `#define MIRROR_NONE` 90 | * `#define MIRROR_HORIZONTAL` 91 | * `#define MIRROR_VERTICAL` 92 | * `#define MIRROR_HOR_VER` 93 | 94 | #### Library instance details: 95 | * The library is implemented as a class template named ArdBitmap. It requires 3 pieces of information in order to create an instance of the ArdBitmap class: 96 | 97 | - An _expression_ that will evaluate to a pointer to the first location in the screen buffer array, such that it can be used to index a screen buffer location like `expression[i] = 5`. The expression is provided by defining the macro `ARDBITMAP_SBUF`. It must be defined **before** including _ArdBitmap.h_ 98 | - The width of the screen, in pixels. This is provided as the first of the two template arguments. 99 | - the height of the screen in pixels. This is provided as the second of the two template arguments. 100 | 101 | * It's probably best to group the `#define ARDBITMAP_SBUF`, the `#include ArdBitmap.h` and the instantiation of an ArdBitmap class object as one block of code. For an Arduboy sketch this might be: 102 | 103 | ```cpp 104 | // make an instance of the Arduboy2 class used for many functions 105 | // (this has to be done before creating an ArdBitmap object so we can define 106 | // the ARDBITMAP_SBUF macro and use the defined WIDTH and HEIGHT) 107 | Arduboy2 arduboy; 108 | // use the following instead, for the older Arduboy library: 109 | //Arduboy arduboy; 110 | 111 | // define the screen buffer pointer expression 112 | #define ARDBITMAP_SBUF arduboy.getBuffer() 113 | // Arduboy2 library verson 3.1.0 and higher exposes the screen buffer as public, 114 | // so the following could be used instead and may reduce code size: 115 | //#define ARDBITMAP_SBUF arduboy.sBuffer 116 | 117 | // we can now include the ArdBitmap header file, which will use the 118 | // ARDBITMAP_SBUF macro when creating the template 119 | #include 120 | 121 | // make an ArdBitmap instance, providing screen width and height arguments that 122 | // were defined by the Arduboy2 (or Arduboy) library 123 | ArdBitmap ardbitmap; 124 | ``` 125 | 126 | -------------------------------------------------------------------------------- /examples/CompleteTest/CompleteTest.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) 6 | 7 | #define SHOW_FPS 8 | 9 | #ifdef SHOW_FPS 10 | 11 | unsigned long previousTime = 0; 12 | uint8_t fps = 0, fpsCounter = 0; 13 | 14 | #endif 15 | 16 | unsigned char* bitmap = BITMAP_TEST; 17 | unsigned char* bitmap_c = BITMAP_COMP_TEST; 18 | float resize = 0.6; 19 | 20 | uint16_t counter = 0; 21 | uint8_t test_number = 0; 22 | int16_t offset = -WIDTH/2; 23 | 24 | // make an instance of arduboy used for many functions 25 | Arduboy arduboy; 26 | 27 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 28 | #define ARDBITMAP_SBUF arduboy.getBuffer() 29 | #include 30 | ArdBitmap ardbitmap; 31 | 32 | // This function runs once in your game. 33 | // use it for anything that needs to be set only once in your game. 34 | void setup() { 35 | // initiate arduboy instance 36 | arduboy.beginNoLogo(); 37 | //arduboy.boot(); 38 | arduboy.setFrameRate(60); 39 | } 40 | 41 | 42 | // our main game loop, this runs once every cycle/frame. 43 | // this is where our game logic goes. 44 | void loop() { 45 | // pause render until it's time for the next frame 46 | if (!(arduboy.nextFrame())) 47 | return; 48 | counter++; 49 | // first we clear our screen to black 50 | arduboy.clear(); 51 | 52 | long time1 = millis(); 53 | 54 | switch (test_number){ 55 | case 0: 56 | arduboy.setCursor(6, 28); 57 | arduboy.print(F("UNCOMPRESSED BITMAP")); 58 | break; 59 | case 1: 60 | ardbitmap.drawBitmap(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_NONE); 61 | break; 62 | case 2: 63 | ardbitmap.drawBitmap(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_NONE); 64 | break; 65 | case 3: 66 | ardbitmap.drawBitmap(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL); 67 | break; 68 | case 4: 69 | ardbitmap.drawBitmap(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL); 70 | break; 71 | case 5: 72 | ardbitmap.drawBitmap(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_VERTICAL); 73 | break; 74 | case 6: 75 | ardbitmap.drawBitmap(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_VERTICAL); 76 | break; 77 | case 7: 78 | ardbitmap.drawBitmap(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HOR_VER); 79 | break; 80 | case 8: 81 | ardbitmap.drawBitmap(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HOR_VER); 82 | break; 83 | 84 | case 9: 85 | arduboy.setCursor(12, 28); 86 | arduboy.print(F("COMPRESSED BITMAP")); 87 | break; 88 | case 10: 89 | ardbitmap.drawCompressed(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_NONE); 90 | break; 91 | case 11: 92 | ardbitmap.drawCompressed(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_NONE); 93 | break; 94 | case 12: 95 | ardbitmap.drawCompressed(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL); 96 | break; 97 | case 13: 98 | ardbitmap.drawCompressed(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL); 99 | break; 100 | case 14: 101 | ardbitmap.drawCompressed(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_VERTICAL); 102 | break; 103 | case 15: 104 | ardbitmap.drawCompressed(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_VERTICAL); 105 | break; 106 | case 16: 107 | ardbitmap.drawCompressed(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HOR_VER); 108 | break; 109 | case 17: 110 | ardbitmap.drawCompressed(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HOR_VER); 111 | break; 112 | 113 | case 18: 114 | arduboy.setCursor(6, 24); 115 | arduboy.print(F("UNCOMPRESSED BITMAP")); 116 | arduboy.setCursor(50, 38); 117 | arduboy.print(F("RESIZE")); 118 | break; 119 | case 19: 120 | ardbitmap.drawBitmapResized(WIDTH/2, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_NONE, abs(cos(counter/80.0))); 121 | break; 122 | case 20: 123 | ardbitmap.drawBitmapResized(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_NONE, resize); 124 | break; 125 | case 21: 126 | ardbitmap.drawBitmapResized(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_NONE, resize); 127 | break; 128 | case 22: 129 | ardbitmap.drawBitmapResized(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL, resize); 130 | break; 131 | case 23: 132 | ardbitmap.drawBitmapResized(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL, resize); 133 | break; 134 | case 24: 135 | ardbitmap.drawBitmapResized(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_VERTICAL, resize); 136 | break; 137 | case 25: 138 | ardbitmap.drawBitmapResized(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_VERTICAL, resize); 139 | break; 140 | case 26: 141 | ardbitmap.drawBitmapResized(offset, HEIGHT/2, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HOR_VER, resize); 142 | break; 143 | case 27: 144 | ardbitmap.drawBitmapResized(WIDTH/2, offset, bitmap, 128, 64, WHITE, ALIGN_CENTER, MIRROR_HOR_VER, resize); 145 | break; 146 | 147 | case 28: 148 | arduboy.setCursor(12, 24); 149 | arduboy.print(F("COMPRESSED BITMAP")); 150 | arduboy.setCursor(50, 38); 151 | arduboy.print(F("RESIZE")); 152 | break; 153 | case 29: 154 | ardbitmap.drawCompressedResized(WIDTH/2, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_NONE, abs(cos(counter/50.0))); 155 | break; 156 | case 30: 157 | ardbitmap.drawCompressedResized(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_NONE, resize); 158 | break; 159 | case 31: 160 | ardbitmap.drawCompressedResized(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_NONE, resize); 161 | break; 162 | case 32: 163 | ardbitmap.drawCompressedResized(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL, resize); 164 | break; 165 | case 33: 166 | ardbitmap.drawCompressedResized(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL, resize); 167 | break; 168 | case 34: 169 | ardbitmap.drawCompressedResized(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_VERTICAL, resize); 170 | break; 171 | case 35: 172 | ardbitmap.drawCompressedResized(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_VERTICAL, resize); 173 | break; 174 | case 36: 175 | ardbitmap.drawCompressedResized(offset, HEIGHT/2, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HOR_VER, resize); 176 | break; 177 | case 37: 178 | ardbitmap.drawCompressedResized(WIDTH/2, offset, bitmap_c, WHITE, ALIGN_CENTER, MIRROR_HOR_VER, resize); 179 | break; 180 | 181 | case 38: 182 | arduboy.setCursor(12, 24); 183 | arduboy.print(F("COMPRESSED BITMAP")); 184 | arduboy.setCursor(36, 38); 185 | arduboy.print(F("ANIMATION")); 186 | break; 187 | case 39: 188 | ardbitmap.drawCompressed(WIDTH/2, HEIGHT, DOG[(time1/80)%ARRAY_LEN(DOG)], WHITE, ALIGN_H_CENTER | ALIGN_V_BOTTOM, MIRROR_NONE); 189 | break; 190 | 191 | case 40: 192 | arduboy.setCursor(12, 24); 193 | arduboy.print(F("COMPRESSED BITMAP")); 194 | arduboy.setCursor(15, 38); 195 | arduboy.print(F("RESIZE ANIMATION")); 196 | break; 197 | case 41: 198 | ardbitmap.drawCompressedResized(WIDTH/2, HEIGHT, DOG[(time1/80)%ARRAY_LEN(DOG)], WHITE, ALIGN_H_CENTER | ALIGN_V_BOTTOM, MIRROR_HORIZONTAL, abs(cos(counter/50.0))); 199 | break; 200 | 201 | default: 202 | arduboy.setCursor(44, 28); 203 | arduboy.print(F("TEST OK")); 204 | 205 | break; 206 | } 207 | 208 | offset++; 209 | if (offset > (WIDTH * 3) /2){ 210 | offset = -WIDTH/2; 211 | test_number++; 212 | } 213 | 214 | time1 = millis() - time1; 215 | #ifdef SHOW_FPS 216 | fpsCounter++; 217 | unsigned long actualTime = millis(); 218 | if ((fpsCounter % 30) == 0) { 219 | if (previousTime != 0) { 220 | fps = (30 * 1000 / (actualTime - previousTime)); 221 | } 222 | previousTime = actualTime; 223 | fpsCounter = 0; 224 | } 225 | 226 | arduboy.setCursor(96, 4); 227 | arduboy.print(fps); 228 | arduboy.print(F("fps")); 229 | 230 | arduboy.setCursor(96, 56); 231 | arduboy.print(time1); 232 | arduboy.print(F(" ms")); 233 | 234 | #endif 235 | 236 | // then we finaly we tell the arduboy to display what we just wrote to the display 237 | arduboy.display(); 238 | } 239 | -------------------------------------------------------------------------------- /examples/CompleteTest/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BITMAP_TEST[] ={ 3 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 38 | 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 40 | 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 41 | 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0x00, 44 | 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 45 | 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 47 | 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0xc0, 49 | 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x80, 0xc0, 0xc0, 0xc0, 0x40, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfc, 52 | 0xff, 0xff, 0x1f, 0x7f, 0xff, 0xfe, 0xf0, 0x80, 53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 54 | 0xff, 0x81, 0x81, 0x81, 0x81, 0xc3, 0xe7, 0xff, 55 | 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 56 | 0xff, 0xff, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 57 | 0x1f, 0xff, 0xfe, 0xfc, 0xe0, 0x00, 0x00, 0x00, 58 | 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 59 | 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 60 | 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xc1, 61 | 0xc1, 0xc1, 0xc1, 0xc3, 0xff, 0xff, 0x7f, 0x3e, 62 | 0x00, 0x00, 0x00, 0xf0, 0xfc, 0xff, 0xff, 0x0f, 63 | 0x03, 0x01, 0x01, 0x01, 0x01, 0x03, 0x07, 0xff, 64 | 0xff, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x07, 65 | 0x1f, 0x7f, 0xfe, 0xf8, 0xe0, 0x80, 0xe0, 0xf8, 66 | 0xfe, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 67 | 0x00, 0x00, 0x00, 0xc0, 0xf8, 0xff, 0xff, 0x3f, 68 | 0x3f, 0x38, 0x38, 0x38, 0x3b, 0x3f, 0xff, 0xff, 69 | 0xfc, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 70 | 0xff, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, 0xff, 71 | 0xfe, 0xfc, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 72 | 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 73 | 0xf8, 0xff, 0x7f, 0x3f, 0x07, 0x00, 0x00, 0x00, 74 | 0x7f, 0xff, 0xff, 0xf0, 0xc0, 0x80, 0x80, 0x80, 75 | 0x80, 0xc0, 0xe0, 0xff, 0xff, 0x7f, 0x3f, 0x00, 76 | 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x81, 77 | 0x81, 0x81, 0x81, 0x83, 0xc3, 0xff, 0xff, 0xff, 78 | 0x7c, 0x00, 0x00, 0x0f, 0x3f, 0xff, 0xff, 0xf0, 79 | 0xc0, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0xff, 80 | 0xff, 0x7f, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 81 | 0x00, 0x00, 0x01, 0x07, 0xff, 0xff, 0xff, 0x07, 82 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 | 0x00, 0x00, 0x02, 0x03, 0x03, 0x03, 0x01, 0x00, 84 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 85 | 0x03, 0x03, 0x03, 0x00, 0x00, 0x03, 0x03, 0x03, 86 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 87 | 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 88 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 89 | 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 90 | 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 91 | 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 92 | 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 93 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 95 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 97 | 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 98 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 100 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 102 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 103 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 104 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 106 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 107 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 110 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 111 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 112 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 113 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 114 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 115 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 116 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 118 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 119 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 125 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 126 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 127 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 128 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 129 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 130 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 131 | }; 132 | 133 | const unsigned char PROGMEM BITMAP_COMP_TEST[] ={ 134 | 0x7f, 0xbf, 0xff, 0x67, 0x84, 0xdc, 0x7a, 0xf3, 0xfb, 0xde, 0x7a, 0xeb, 0xad, 0xb7, 0xde, 0xf2, 135 | 0xf1, 0xde, 0x7a, 0xeb, 0xad, 0xb7, 0x5c, 0xf9, 0x7a, 0x6f, 0x7e, 0xdf, 0x5b, 0x6f, 0xbe, 0xf7, 136 | 0xd6, 0x5b, 0x6f, 0xbd, 0xf5, 0x96, 0x2b, 0x9f, 0xf7, 0xd8, 0x5b, 0x6f, 0x3d, 0xfa, 0x3d, 0x6e, 137 | 0xbd, 0xf5, 0xeb, 0x1c, 0x7b, 0x13, 0x7e, 0xca, 0xc1, 0x47, 0x7d, 0x35, 0xc6, 0xe7, 0x3e, 0xb0, 138 | 0x5c, 0x2e, 0x57, 0x3a, 0x7c, 0xc2, 0xfa, 0xc0, 0x07, 0xae, 0x5e, 0x73, 0x9b, 0xd9, 0x1c, 0x67, 139 | 0xde, 0xbd, 0xfb, 0xfe, 0xfb, 0xf7, 0x5f, 0x18, 0x8e, 0x0e, 0x47, 0xfb, 0x30, 0xe3, 0x61, 0xd7, 140 | 0xab, 0xae, 0xa3, 0x57, 0x8f, 0x63, 0x3c, 0xcb, 0x7a, 0xc7, 0x6d, 0x77, 0x72, 0xdb, 0xbd, 0xed, 141 | 0x4e, 0x6e, 0xbb, 0x9f, 0xf5, 0xf0, 0xc8, 0x5b, 0xb3, 0xd2, 0x44, 0xd2, 0x57, 0x1e, 0x1e, 0xbf, 142 | 0x5f, 0xbd, 0xf5, 0x34, 0xbb, 0x39, 0xce, 0xbc, 0x7b, 0x3f, 0xbd, 0x7a, 0xec, 0xe1, 0x4d, 0x0e, 143 | 0x8f, 0x27, 0x6f, 0x2e, 0xb9, 0x7a, 0xcd, 0xe9, 0x09, 0xc7, 0x2f, 0x7c, 0x60, 0xb9, 0x5c, 0x2e, 144 | 0x47, 0xfb, 0xd2, 0xf1, 0xe8, 0xe2, 0x9b, 0x4b, 0xae, 0x5e, 0x73, 0x7a, 0xc2, 0xf1, 0xcb, 0xdc, 145 | 0x9e, 0x8e, 0xfe, 0x1e, 0x6e, 0xbd, 0xe5, 0xc7, 0xf4, 0xd6, 0xb7, 0xbd, 0xf5, 0xdb, 0xbd, 0xf5, 146 | 0xb5, 0xb7, 0xde, 0x7a, 0xeb, 0xad, 0x47, 0x7f, 0x0e, 0xd7, 0xdc, 0x7a, 0xeb, 0x2d, 0x57, 0xbe, 147 | 0xde, 0x5b, 0x6f, 0xbd, 0xf5, 0xd6, 0x5b, 0x3e, 0xcf, 0x35, 0xb7, 0xde, 0x7a, 0xcb, 0x95, 0xdf, 148 | 0xe7, 0xad, 0xff, 0xd7, 0x04, 149 | }; 150 | 151 | // File: test.png 152 | // Size: 128x64px (1024 bytes) 153 | // Compressed: 229 bytes 154 | // Ratio: 0.22363281 155 | 156 | const unsigned char PROGMEM DOG_0[] ={ 157 | 0x7f, 0xbf, 0xff, 0xec, 0xbc, 0x7a, 0xf5, 0xea, 0xd5, 0xab, 0xff, 0x1d, 0xe1, 0xb4, 0x0e, 0x7b, 158 | 0xd6, 0x91, 0x95, 0xdb, 0x38, 0x1c, 0xd6, 0x29, 0x7f, 0x8d, 0x9c, 0xe6, 0x3c, 0xf5, 0xe8, 0x5f, 159 | 0xc7, 0x6b, 0x6e, 0xe3, 0x32, 0xf7, 0x61, 0x9d, 0x7a, 0xcb, 0xd5, 0xab, 0x9f, 0xde, 0xf3, 0x32, 160 | 0xf7, 0xde, 0x7b, 0x1f, 0xd6, 0x65, 0xee, 0xbd, 0xf7, 0xde, 0x7b, 0x1f, 0xc6, 0x91, 0xbf, 0xf2, 161 | 0x38, 0xec, 0x79, 0xca, 0x95, 0xe9, 0xb1, 0xa7, 0x75, 0xd8, 0xfb, 0x30, 0xe7, 0x29, 0xff, 0x1c, 162 | 0xb9, 0x7a, 0x14, 0xfe, 0xb8, 0xb9, 0x8d, 0xcb, 0xba, 0xfc, 0x89, 0xb9, 0xe6, 0xd6, 0xd3, 0xba, 163 | 0xac, 0xcb, 0x3a, 0xf5, 0xe8, 0x71, 0x1c, 0x2e, 0xf9, 0xe7, 0xcb, 0x35, 0xa7, 0x75, 0xd8, 0x7b, 164 | 0xef, 0x7d, 0x58, 0x97, 0x75, 0x59, 0x87, 0xbd, 0xf7, 0x3c, 0xe5, 0x9f, 0xd6, 0x89, 0xcf, 0x38, 165 | 0x7a, 0xeb, 0x2d, 0xdf, 0xe7, 0xd6, 0x5b, 0x4f, 0x7b, 0xdc, 0xc6, 0x65, 0xf6, 0xf7, 0x73, 0xcd, 166 | 0x6d, 0x5c, 0xe6, 0x3e, 0x8c, 0x5b, 0xfe, 0xe3, 0xf1, 0x05, 0x4e, 0x27, 0x3e, 0xd3, 0xc3, 0xc5, 167 | 0xcf, 0xe4, 0x74, 0xf0, 0x3d, 0xf3, 0x77, 0x70, 0x1c, 0x87, 0xc3, 0x38, 0xf2, 0xdf, 0xa7, 0xd5, 168 | 0x5b, 0x4f, 0x6b, 0xff, 0x98, 0xee, 0x0f, 0x60, 0x2e, 0xeb, 0x32, 0x3e, 0xd2, 0xc3, 0x61, 0x1c, 169 | 0xf9, 0xef, 0x2d, 0xc7, 0xde, 0xb6, 0x1f, 0x9d, 0xfb, 0xdf, 0x38, 170 | }; 171 | 172 | const unsigned char PROGMEM DOG_1[] ={ 173 | 0x7f, 0xff, 0xff, 0xfb, 0x88, 0xe3, 0x38, 0xec, 0x79, 0x59, 0x97, 0x75, 0x59, 0x97, 0x75, 0x59, 174 | 0x97, 0x75, 0x99, 0x7b, 0xcf, 0x53, 0x8f, 0xfe, 0xb9, 0xb9, 0x7a, 0xcd, 0x69, 0x1d, 0xf6, 0xde, 175 | 0x7b, 0x9e, 0x7a, 0xf4, 0x9f, 0x23, 0xb7, 0x3d, 0x8e, 0xfc, 0xb9, 0x3d, 0xf6, 0x36, 0x2e, 0xeb, 176 | 0xb2, 0x2e, 0xeb, 0xb2, 0x2e, 0xeb, 0xb0, 0x4f, 0x5e, 0x3d, 0xe6, 0xea, 0x5f, 0x79, 0xe4, 0xef, 177 | 0xea, 0x35, 0xb7, 0x71, 0x99, 0xfb, 0x30, 0x6e, 0x79, 0xc6, 0x95, 0x7f, 0xee, 0x39, 0xcd, 0xc3, 178 | 0xba, 0xac, 0xcb, 0x3a, 0xec, 0xbd, 0xf7, 0xde, 0x7b, 0x9e, 0xfa, 0xb7, 0x40, 0x4e, 0x92, 0xcb, 179 | 0xdc, 0x7b, 0xef, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 0xbd, 0x0f, 0xeb, 0x32, 0x6e, 0xf9, 0x0c, 0x93, 180 | 0x4e, 0x07, 0x3f, 0x29, 0x47, 0x3e, 0x3e, 0x6e, 0xf9, 0x73, 0x72, 0x1c, 0x87, 0xc3, 0x38, 0xfa, 181 | 0x9f, 0x0b, 0x8e, 0xe3, 0x32, 0xf7, 0x9e, 0x97, 0x71, 0xeb, 0xd1, 0xc9, 0xe7, 0xc7, 0x38, 0xcd, 182 | 0xf5, 0x15, 0x8e, 0xe3, 0x30, 0x4f, 0xf9, 0x0d, 0xb4, 0xae, 0x5c, 0xf9, 0x6f, 0x56, 0x18, 0xeb, 183 | 0xb2, 0x2e, 0xeb, 0xb2, 0x2e, 0xea, 0x85, 0xf2, 0x88, 0x6b, 0x6e, 0xb9, 0x3a, 0xb9, 0x7a, 0xec, 184 | 0x69, 0xae, 0xc5, 0x68, 0x87, 0x9f, 0xfe, 0xef, 0x19, 0x57, 0xaf, 0x5e, 0xbd, 0x7a, 0xf5, 0xb7, 185 | 0xce, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 0x3d, 0x2f, 0xe3, 0x5f, 0x1d, 186 | }; 187 | 188 | const unsigned char PROGMEM DOG_2[] ={ 189 | 0x7f, 0xff, 0xff, 0xb9, 0xf4, 0xea, 0xd5, 0x2b, 0xff, 0xfe, 0xb9, 0x7a, 0xcd, 0xad, 0xb7, 0xde, 190 | 0x7a, 0xeb, 0xad, 0xb7, 0x1e, 0xbd, 0xfa, 0x35, 0xaf, 0x5e, 0xbd, 0x7a, 0xf5, 0xea, 0xd5, 0xab, 191 | 0x57, 0xbf, 0x74, 0xea, 0x2d, 0x57, 0xaf, 0xfc, 0x1e, 0x8e, 0xe3, 0xb2, 0x2e, 0xeb, 0xb2, 0x2e, 192 | 0xeb, 0xf0, 0x4f, 0xab, 0x87, 0xc3, 0xb8, 0xe5, 0x9f, 0x39, 0x57, 0xaf, 0x39, 0x7a, 0xf5, 0xea, 193 | 0x35, 0xb7, 0x71, 0x38, 0xf4, 0x5f, 0x4d, 0x4e, 0x73, 0xfd, 0xab, 0xe6, 0x9a, 0xdb, 0x38, 0x1c, 194 | 0xc6, 0x91, 0x3f, 0x2e, 0xe5, 0x60, 0xb3, 0x32, 0x92, 0xae, 0xd2, 0xbd, 0xf7, 0xde, 0x7b, 0xef, 195 | 0xbd, 0xf7, 0xde, 0x87, 0x75, 0xea, 0xd1, 0xe5, 0xb1, 0xa7, 0x79, 0x18, 0xb7, 0xfc, 0xa9, 0x74, 196 | 0x8d, 0xcb, 0xdc, 0x87, 0x71, 0xcb, 0xd5, 0xab, 0xbf, 0xce, 0xab, 0xbf, 0xc2, 0x63, 0x4f, 0x73, 197 | 0x1f, 0xd6, 0xa9, 0x47, 0xfe, 0x5d, 0x70, 0xf5, 0x9a, 0x5b, 0x6f, 0xbd, 0xf5, 0xe8, 0x95, 0xdf, 198 | 0xcb, 0xfc, 0xbe, 0x97, 0xfd, 0xf9, 0x53, 0xae, 0xbc, 0xf7, 0xd6, 0x5b, 0x17, 0x23, 0x9d, 0x09, 199 | 0x1f, 0xfd, 0xbc, 0xd7, 0x8c, 0xb4, 0x1d, 0x2e, 0x17, 0x9f, 0xee, 0xf8, 0xa7, 0xed, 0xba, 0xf1, 200 | 0xa5, 0x8c, 0x23, 0x9f, 0xf3, 0x38, 0x0e, 0x7b, 0x9e, 0xf2, 0x8c, 0x6b, 0xbe, 0xc8, 0x70, 0xcf, 201 | 0xc3, 0xde, 0x7b, 0x9e, 0xfc, 0x31, 0x73, 0xef, 0x79, 0x99, 0xfb, 0xb0, 0x4e, 0x3d, 0xf2, 0xcf, 202 | 0x3f, 0xa7, 0x39, 0x2f, 0xe3, 0xc8, 0xf4, 0xd8, 0x5b, 0x6f, 0xe3, 0xf2, 0x13, 0xb8, 0xe6, 0xd6, 203 | 0x5b, 0x6f, 0x3d, 0xf2, 0xef, 0x16, 204 | }; 205 | 206 | const unsigned char PROGMEM DOG_3[] ={ 207 | 0x7f, 0xff, 0xff, 0x39, 0xf3, 0xd8, 0x5b, 0x6f, 0xbd, 0xf5, 0x36, 0x2e, 0xeb, 0xb0, 0xf7, 0x3e, 208 | 0xac, 0x53, 0x8f, 0xfc, 0xe7, 0xcb, 0x63, 0x6f, 0xbd, 0xf5, 0xd6, 0x5b, 0x6f, 0x3d, 0x48, 0x49, 209 | 0xfe, 0x9c, 0x1c, 0x7b, 0xeb, 0xad, 0xb7, 0x8e, 0x7f, 0x0f, 0x5e, 0xbd, 0x7a, 0xf5, 0x38, 0x0e, 210 | 0x7b, 0x5e, 0xc6, 0x2d, 0x57, 0xaf, 0x5e, 0xbd, 0x7a, 0xf5, 0xea, 0xd5, 0xab, 0xd7, 0xdc, 0x72, 211 | 0xf5, 0xea, 0x3f, 0x03, 0x8e, 0x3d, 0xad, 0xcb, 0xba, 0xac, 0xcb, 0xba, 0xac, 0xcb, 0x3a, 0xec, 212 | 0xbd, 0xe7, 0x8d, 0xbf, 0x13, 0xc7, 0x71, 0x99, 0xf3, 0xd4, 0xa3, 0xcb, 0xe3, 0xb8, 0xac, 0xc3, 213 | 0xde, 0xe3, 0x9f, 0x3a, 0xc3, 0x59, 0x3b, 0x86, 0x8b, 0xe9, 0xb1, 0xb7, 0xde, 0x7a, 0xeb, 0x2d, 214 | 0x57, 0xfe, 0x06, 0x2c, 0x36, 0xcb, 0x95, 0x66, 0xa5, 0x59, 0x69, 0x56, 0xed, 0xba, 0xac, 0xcb, 215 | 0xdc, 0x87, 0x71, 0xf4, 0xb3, 0x1c, 0xc7, 0xe1, 0x10, 0xf8, 0x0b, 0xce, 0xcb, 0xb8, 0xf5, 0xe8, 216 | 0xd5, 0x9f, 0xc3, 0xd5, 0x63, 0x8f, 0xfc, 0xb1, 0x28, 0x17, 0xc9, 0x65, 0x9d, 0x72, 0xe5, 0x99, 217 | 0xc7, 0x9e, 0xe6, 0x3e, 0x8c, 0xbf, 0xed, 0x5a, 0x47, 0xaf, 0xbc, 0xe3, 0x9a, 0xdb, 0xb8, 0xcc, 218 | 0x7d, 0x58, 0x97, 0x71, 0xeb, 0x69, 0xfb, 0x03, 0xb8, 0x1d, 0xfc, 0xe7, 0xe0, 0xd5, 0xab, 0xa3, 219 | 0x6d, 0x56, 0xda, 0xe6, 0x93, 0xac, 0x0f, 0x71, 0xec, 0x69, 0x5d, 0xd6, 0x65, 0x1c, 0xf9, 0x3b, 220 | 0x79, 0xb9, 0xe4, 0x23, 0xe3, 0x70, 0xc9, 0x95, 0x1f, 0xbe, 0xf8, 0x01, 0x23, 0xff, 0x8c, 0x3c, 221 | 0xad, 0xcb, 0xba, 0xac, 0xcb, 0xb8, 0xe5, 0xdf, 0xce, 0xa1, 0x47, 0xaf, 0xae, 0x0c, 0x47, 0x47, 222 | 0xf2, 0x27, 0xe1, 0x9a, 0xd3, 0x3a, 0x1c, 0xc6, 0xd1, 0x57, 0xb9, 0xf5, 0xd6, 0x45, 0x67, 0xfe, 223 | 0x03, 0x00, 224 | }; 225 | 226 | const unsigned char PROGMEM DOG_4[] ={ 227 | 0x7f, 0xff, 0xff, 0xf9, 0xf3, 0xbf, 0x8e, 0x5e, 0x3d, 0xf6, 0x36, 0x2e, 0x73, 0xef, 0xbd, 0xf7, 228 | 0xbc, 0xac, 0xcb, 0xb8, 0x55, 0x13, 0x4b, 0x19, 0x94, 0xbf, 0x89, 0xc7, 0x71, 0x99, 0xf3, 0xb2, 229 | 0x4e, 0xbd, 0xf5, 0xe6, 0xef, 0xe1, 0x38, 0x2e, 0x73, 0x5e, 0xc6, 0x62, 0x74, 0xb8, 0x1c, 0x1d, 230 | 0xac, 0x71, 0x59, 0x97, 0x75, 0x59, 0x97, 0x71, 0xeb, 0xd1, 0xe5, 0xd5, 0x63, 0x6f, 0xb9, 0xfa, 231 | 0x73, 0xb9, 0xfa, 0xaf, 0xd0, 0xab, 0x3f, 0x87, 0x6b, 0x4e, 0x73, 0x7e, 0xc4, 0x4b, 0xec, 0xe8, 232 | 0x28, 0xdd, 0xf3, 0x32, 0x8e, 0xfe, 0x19, 0xb8, 0xcd, 0xf5, 0x1f, 0x02, 0xb6, 0xcd, 0x68, 0x9b, 233 | 0xd1, 0xc1, 0xea, 0xad, 0xb7, 0xde, 0x7a, 0xeb, 0x2d, 0x57, 0xff, 0x9a, 0x39, 0xad, 0xcb, 0xdc, 234 | 0x7b, 0x1f, 0xd6, 0xa9, 0x47, 0xfe, 0x4a, 0x63, 0xdf, 0xbc, 0x7a, 0xf5, 0xea, 0xb1, 0xa7, 0x75, 235 | 0xd8, 0xf3, 0xb2, 0x4e, 0xbd, 0xf5, 0xd6, 0x5b, 0x6f, 0xbd, 0xf5, 0xd6, 0xd3, 0xba, 0xac, 0xc3, 236 | 0xde, 0xf3, 0xd4, 0xa3, 0x57, 0xaf, 0x7c, 0x9a, 0x99, 0x66, 0xb4, 0x6d, 0x56, 0xed, 0x8c, 0x39, 237 | 0xac, 0x4b, 0xf0, 0x84, 0xdc, 0xd0, 0x26, 0x7a, 0xe5, 0x63, 0x73, 0xef, 0xc3, 0x3a, 0xec, 0x79, 238 | 0xca, 0x67, 0x38, 0x8e, 0x43, 0x06, 0xbf, 0xcc, 0xab, 0xc7, 0xde, 0xc6, 0x65, 0xee, 0xc3, 0xb8, 239 | 0xe5, 0x9f, 0x2b, 0xd7, 0xdc, 0xc6, 0x65, 0xce, 0xcb, 0xba, 0xac, 0xcb, 0xba, 0xac, 0xcb, 0xba, 240 | 0xac, 0xcb, 0x3a, 0xec, 0x79, 0xf2, 0x73, 0x39, 0xad, 0xc3, 0xde, 0xf3, 0xb2, 0x4e, 0xb9, 0xb2, 241 | 0x3d, 0xdc, 0xf8, 0x4c, 0x0f, 0x17, 0xff, 0x6b, 0x3d, 0xc7, 0x2d, 0x57, 0xaf, 0x2e, 0x97, 0x63, 242 | 0xe4, 0xbf, 0x90, 243 | }; 244 | 245 | const unsigned char PROGMEM DOG_5[] ={ 246 | 0x7f, 0xbf, 0x3f, 0xd3, 0xab, 0xc7, 0xde, 0x7a, 0xeb, 0x69, 0x5d, 0xd6, 0x65, 0x5d, 0xd6, 0x65, 247 | 0x9d, 0x7a, 0xeb, 0xd1, 0x7f, 0xdd, 0x5e, 0xbd, 0x7a, 0xf5, 0xea, 0x1f, 0x9a, 0x8b, 0x7a, 0x02, 248 | 0x6f, 0xbd, 0xf5, 0xe8, 0xd5, 0xab, 0x57, 0x8f, 0xbd, 0xf5, 0xd6, 0xd3, 0x3a, 0xec, 0x79, 0x19, 249 | 0xb7, 0x3c, 0xe3, 0xd8, 0xd3, 0xba, 0xac, 0x53, 0x6f, 0xbd, 0xf5, 0xd6, 0x5b, 0x6f, 0xbd, 0x8d, 250 | 0xcb, 0xba, 0xac, 0xc3, 0xde, 0x7b, 0x5e, 0xd6, 0x65, 0x5d, 0xd6, 0x65, 0x5d, 0xd6, 0x65, 0xee, 251 | 0xbd, 0xf7, 0xde, 0x7b, 0x1f, 0xd6, 0xa9, 0xb7, 0x74, 0xd5, 0xce, 0x98, 0x03, 0x1f, 0xce, 0x69, 252 | 0x5d, 0xd6, 0x65, 0x1d, 0xf6, 0xbc, 0x8c, 0x23, 0xff, 0xbc, 0xc6, 0xfa, 0x8f, 0x95, 0xc7, 0x8e, 253 | 0xf4, 0x97, 0x72, 0xf5, 0x9a, 0xd3, 0x9c, 0xa7, 0x5c, 0xb9, 0x73, 0xf5, 0xd8, 0xd3, 0xba, 0x8c, 254 | 0x23, 0x7f, 0x16, 0x8f, 0xe3, 0x32, 0xf7, 0x3c, 0xe5, 0x5f, 0x47, 0x6e, 0xe3, 0x32, 0xf7, 0x61, 255 | 0x5d, 0xd6, 0xa9, 0xb7, 0xde, 0x7a, 0xeb, 0x69, 0x5d, 0xd6, 0x65, 0xdc, 0xf2, 0x73, 0xbd, 0x5c, 256 | 0xf8, 0x7d, 0x5e, 0x3d, 0xe6, 0xea, 0xd5, 0xab, 0x57, 0x8f, 0x3d, 0xcd, 0x7d, 0x58, 0x97, 0x75, 257 | 0x19, 0xb7, 0x1e, 0xfd, 0xb5, 0xb9, 0x8d, 0xc3, 0xde, 0x87, 0x75, 0x59, 0x97, 0x75, 0xea, 0x6d, 258 | 0x5c, 0xd6, 0x25, 0xbf, 0x93, 0xe3, 0xb8, 0xac, 0xc3, 0x9e, 0x97, 0x71, 0xcb, 0x95, 0x3f, 0xcd, 259 | 0x65, 0x5d, 0xc6, 0xad, 0x47, 0x27, 0xd7, 0xdc, 0xc6, 0xe1, 0xb0, 0x4e, 0xb9, 0xf2, 0x8f, 0x7f, 260 | 0x8f, 0xdf, 0x91, 0x8e, 0x71, 0x99, 0x7b, 0xcf, 0xcb, 0x3a, 0xf5, 0x96, 0xab, 0x57, 0x97, 0xd7, 261 | 0xdc, 0x7a, 0xeb, 0x2d, 0xd7, 0xdc, 0x3a, 0xd2, 0xff, 0xa0, 0xe5, 0xb4, 0xc7, 0x91, 0xcf, 0xe4, 262 | 0x72, 0x18, 0x47, 0xfe, 0xbb, 0xcd, 0x71, 0x1c, 0x0e, 0xe3, 0xe8, 0xd5, 0xc9, 0x72, 0x74, 0x38, 263 | 0x3a, 0x1c, 0x1d, 0x8e, 0xe1, 0x4f, 0x05, 264 | }; 265 | 266 | const unsigned char PROGMEM DOG_6[] ={ 267 | 0x7f, 0xff, 0xbf, 0x8d, 0xc5, 0x74, 0x39, 0x32, 0x4d, 0x76, 0xe8, 0x9e, 0x87, 0x3d, 0x2f, 0xe3, 268 | 0xe8, 0xf2, 0xd8, 0xd3, 0x3a, 0x1c, 0xd6, 0x29, 0xff, 0x15, 0xcf, 0x6d, 0x1c, 0xf6, 0x3c, 0xf5, 269 | 0xc8, 0xe6, 0x9a, 0x5b, 0x6f, 0xbd, 0xf5, 0xd6, 0x5b, 0x6f, 0xbd, 0xf5, 0xd6, 0xd3, 0x3a, 0xec, 270 | 0x7d, 0x58, 0xa7, 0x1e, 0xfd, 0x7b, 0x76, 0xdc, 0x7a, 0x1b, 0x97, 0x39, 0x4f, 0xfe, 0x7b, 0xe2, 271 | 0xd8, 0xcb, 0x61, 0x9d, 0x7a, 0x1b, 0x87, 0xc3, 0x38, 0x7a, 0xed, 0xe1, 0xd0, 0x7f, 0x1d, 0x5e, 272 | 0xbd, 0x7a, 0xf5, 0xea, 0xb1, 0xb7, 0xde, 0x7a, 0x5a, 0x87, 0xc3, 0xba, 0xac, 0xcb, 0x6a, 0xfd, 273 | 0x34, 0x57, 0xaf, 0x5e, 0x3d, 0x8e, 0xc3, 0x61, 0x1c, 0xf9, 0xc1, 0x1e, 0xf6, 0xde, 0xfb, 0xb0, 274 | 0x4e, 0x3d, 0xfa, 0x8c, 0x63, 0x4f, 0x73, 0xef, 0x1d, 0xb3, 0x2d, 0x7f, 0x6c, 0xfe, 0xd5, 0x3b, 275 | 0x59, 0x8e, 0x5f, 0xc2, 0x35, 0xb7, 0x71, 0x59, 0x97, 0x75, 0xea, 0x11, 0x33, 0x86, 0xa3, 0xc3, 276 | 0xd1, 0x5b, 0x6f, 0xbd, 0x8d, 0xcb, 0x3a, 0xec, 0x79, 0x59, 0x97, 0x75, 0x59, 0x97, 0x75, 0xea, 277 | 0xad, 0xb7, 0xde, 0x7a, 0xeb, 0x2d, 0x57, 0x9f, 0x73, 0x1c, 0x87, 0xc3, 0xba, 0x04, 0xfe, 0x96, 278 | 0xe8, 0x65, 0xee, 0xc3, 0xba, 0x8c, 0x5b, 0x8f, 0x5e, 0xbd, 0x7a, 0xcd, 0xad, 0xa7, 0x75, 0x59, 279 | 0x97, 0x71, 0xcb, 0x95, 0xff, 0x4e, 0x78, 0xb9, 0xe4, 0xb3, 0x1c, 0xc7, 0xe1, 0x30, 0x8e, 0x5e, 280 | 0xc7, 0xbc, 0x8c, 0x5b, 0xae, 0x7c, 0x36, 0xa7, 0x39, 0x4f, 0xf9, 0xaf, 0xd7, 0xca, 0x67, 0x72, 281 | 0x39, 0x8c, 0x23, 0x7f, 0x1e, 0x8f, 0x3d, 0xcd, 0x79, 0x19, 0x47, 0x5f, 0xe5, 0xb4, 0x0e, 0x7b, 282 | 0x5e, 0xd6, 0x65, 0x5d, 0xc6, 0x7f, 0x45, 0x32, 0x8f, 0x5e, 0xbd, 0x3a, 0x59, 0x8e, 0x7f, 0x10, 283 | 0x1e, 0x7b, 0xeb, 0x69, 0x5d, 0xd6, 0x65, 0xdc, 0xfa, 0xab, 0x00, 284 | }; 285 | 286 | const unsigned char *DOG[] = { 287 | DOG_0, 288 | DOG_1, 289 | DOG_2, 290 | DOG_3, 291 | DOG_4, 292 | DOG_5, 293 | DOG_6, 294 | }; 295 | -------------------------------------------------------------------------------- /examples/Sample1-Basic/Sample1-Basic.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | // make an instance of arduboy used for many functions 6 | Arduboy arduboy; 7 | 8 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 9 | #define ARDBITMAP_SBUF arduboy.getBuffer() 10 | #include 11 | ArdBitmap ardbitmap; 12 | 13 | // This function runs once in your game. 14 | // use it for anything that needs to be set only once in your game. 15 | void setup() { 16 | // initiate arduboy instance 17 | arduboy.begin(); 18 | arduboy.setFrameRate(60); 19 | } 20 | 21 | 22 | // our main game loop, this runs once every cycle/frame. 23 | // this is where our game logic goes. 24 | void loop() { 25 | // pause render until it's time for the next frame 26 | if (!(arduboy.nextFrame())) 27 | return; 28 | 29 | // first we clear our screen to black 30 | arduboy.clear(); 31 | 32 | ardbitmap.drawCompressed(WIDTH / 2 ,HEIGHT / 2, BOY, WHITE, ALIGN_CENTER, MIRROR_NONE); 33 | 34 | // then we finaly we tell the arduboy to display what we just wrote to the display 35 | arduboy.display(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/Sample1-Basic/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BOY[] ={ 3 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 4 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 5 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 6 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 7 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 8 | }; 9 | 10 | // File: d:\arduboy\boy.gif 11 | // Size: 64x64px (512 bytes) 12 | // Encoded: 80 bytes 13 | // Ratio: 0.15625 14 | -------------------------------------------------------------------------------- /examples/Sample2-Mirror/Sample2-Mirror.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | // make an instance of arduboy used for many functions 6 | Arduboy arduboy; 7 | 8 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 9 | #define ARDBITMAP_SBUF arduboy.getBuffer() 10 | #include 11 | ArdBitmap ardbitmap; 12 | 13 | // This function runs once in your game. 14 | // use it for anything that needs to be set only once in your game. 15 | void setup() { 16 | // initiate arduboy instance 17 | arduboy.begin(); 18 | arduboy.setFrameRate(60); 19 | } 20 | 21 | 22 | // our main game loop, this runs once every cycle/frame. 23 | // this is where our game logic goes. 24 | void loop() { 25 | // pause render until it's time for the next frame 26 | if (!(arduboy.nextFrame())) 27 | return; 28 | 29 | // first we clear our screen to black 30 | arduboy.clear(); 31 | 32 | ardbitmap.drawCompressed(WIDTH / 2 ,HEIGHT / 2, BOY, WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL | MIRROR_VERTICAL); 33 | 34 | // then we finaly we tell the arduboy to display what we just wrote to the display 35 | arduboy.display(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/Sample2-Mirror/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BOY[] ={ 3 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 4 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 5 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 6 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 7 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 8 | }; 9 | 10 | // File: d:\arduboy\boy.gif 11 | // Size: 64x64px (512 bytes) 12 | // Encoded: 80 bytes 13 | // Ratio: 0.15625 14 | -------------------------------------------------------------------------------- /examples/Sample3-Resize/Sample3-Resize.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | // make an instance of arduboy used for many functions 6 | Arduboy arduboy; 7 | 8 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 9 | #define ARDBITMAP_SBUF arduboy.getBuffer() 10 | #include 11 | ArdBitmap ardbitmap; 12 | 13 | // This function runs once in your game. 14 | // use it for anything that needs to be set only once in your game. 15 | void setup() { 16 | // initiate arduboy instance 17 | arduboy.begin(); 18 | arduboy.setFrameRate(60); 19 | } 20 | 21 | 22 | // our main game loop, this runs once every cycle/frame. 23 | // this is where our game logic goes. 24 | void loop() { 25 | // pause render until it's time for the next frame 26 | if (!(arduboy.nextFrame())) 27 | return; 28 | 29 | // first we clear our screen to black 30 | arduboy.clear(); 31 | 32 | ardbitmap.drawCompressedResized(WIDTH / 2 ,HEIGHT, BOY, WHITE, ALIGN_H_CENTER | ALIGN_V_BOTTOM, MIRROR_NONE, 0.5); 33 | 34 | // then we finaly we tell the arduboy to display what we just wrote to the display 35 | arduboy.display(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/Sample3-Resize/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BOY[] ={ 3 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 4 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 5 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 6 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 7 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 8 | }; 9 | 10 | // File: d:\arduboy\boy.gif 11 | // Size: 64x64px (512 bytes) 12 | // Encoded: 80 bytes 13 | // Ratio: 0.15625 14 | -------------------------------------------------------------------------------- /examples/Sample4-Animation/Sample4-Animation.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) 6 | 7 | #define FRAME_RATE 60 8 | #define SHOW_FPS 9 | // make an instance of arduboy used for many functions 10 | Arduboy arduboy; 11 | 12 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 13 | #define ARDBITMAP_SBUF arduboy.getBuffer() 14 | #include 15 | ArdBitmap ardbitmap; 16 | 17 | #ifdef SHOW_FPS 18 | 19 | long previousTime = 0; 20 | uint8_t fps = 0, fpsCounter = 0; 21 | 22 | #endif 23 | 24 | 25 | // This function runs once in your game. 26 | // use it for anything that needs to be set only once in your game. 27 | void setup() { 28 | // initiate arduboy instance 29 | //arduboy.begin(); 30 | arduboy.beginNoLogo(); 31 | arduboy.setFrameRate(FRAME_RATE); 32 | } 33 | 34 | 35 | // our main game loop, this runs once every cycle/frame. 36 | // this is where our game logic goes. 37 | void loop() { 38 | // pause render until it's time for the next frame 39 | if (!(arduboy.nextFrame())) 40 | return; 41 | 42 | // first we clear our screen to black 43 | arduboy.clear(); 44 | 45 | //ardbitmap.drawCompressedResized(WIDTH / 2, HEIGHT / 2, BOY[arduboy.frameCount % ARRAY_LEN(BOY)], WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL| MIRROR_VERTICAL, (arduboy.frameCount % 100)/50.0); 46 | ardbitmap.drawCompressed(WIDTH / 2, HEIGHT / 2, BOY[arduboy.frameCount % ARRAY_LEN(BOY)], WHITE, ALIGN_CENTER, MIRROR_HORIZONTAL| MIRROR_VERTICAL); 47 | 48 | #ifdef SHOW_FPS 49 | fpsCounter++; 50 | long actualTime = millis(); 51 | if ((fpsCounter % 30) == 0) { 52 | if (previousTime != 0) { 53 | fps = (30 * 1000 / (actualTime - previousTime)); 54 | } 55 | previousTime = actualTime; 56 | fpsCounter = 0; 57 | } 58 | 59 | arduboy.setCursor(116, 4); 60 | arduboy.print(fps); 61 | 62 | #endif 63 | 64 | // then we finaly we tell the arduboy to display what we just wrote to the display 65 | arduboy.display(); 66 | } 67 | -------------------------------------------------------------------------------- /examples/Sample4-Animation/bitmaps.h: -------------------------------------------------------------------------------- 1 | // java -jar compressor.jar boy.gif -anp BOY 2 | 3 | const unsigned char PROGMEM BOY_0[] ={ 4 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 5 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 6 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 7 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 8 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 9 | }; 10 | 11 | const unsigned char PROGMEM BOY_1[] ={ 12 | 0x3f, 0xbf, 0xff, 0xd1, 0x99, 0x7b, 0xcf, 0xc3, 0x9e, 0x27, 0xff, 0xb5, 0xae, 0xfe, 0x9a, 0xde, 13 | 0xc6, 0x65, 0x1d, 0x0e, 0xe3, 0x96, 0xab, 0x57, 0xaf, 0x5e, 0x73, 0x9a, 0x17, 0xfe, 0xf0, 0x7f, 14 | 0x13, 0xed, 0x3e, 0x8c, 0x5b, 0x6f, 0xbd, 0xe5, 0xea, 0x95, 0xbf, 0x3f, 0xc7, 0xb5, 0x0f, 0xfe, 15 | 0xee, 0x8c, 0xf8, 0x6f, 0xce, 0xf9, 0xf1, 0x1e, 0xf9, 0xce, 0xca, 0x3f, 0x39, 0x3a, 0xf2, 0xd9, 16 | 0x47, 0x9f, 0x5c, 0xfe, 0xa3, 0xd3, 0x06, 0x86, 0xd7, 0xdc, 0xba, 0x5e, 0x8f, 0xcb, 0x21, 0x57, 17 | 0x57, 0xf3, 0x97, 0x06, 18 | }; 19 | 20 | const unsigned char PROGMEM BOY_2[] ={ 21 | 0x3f, 0xff, 0xff, 0x39, 0xca, 0xe5, 0x30, 0x6e, 0xbd, 0xf5, 0x34, 0xf3, 0xcf, 0x6f, 0xcd, 0x9b, 22 | 0x3f, 0x8f, 0x63, 0x4f, 0x73, 0xde, 0xf8, 0x97, 0xe3, 0xbc, 0xac, 0xcb, 0xf8, 0xf9, 0xd9, 0xf3, 23 | 0xd4, 0xe1, 0x68, 0xa6, 0xff, 0x92, 0x34, 0xfc, 0x15, 0x0e, 0xfc, 0x93, 0xfb, 0x76, 0x0f, 0xfb, 24 | 0xb0, 0x4e, 0x7e, 0x65, 0x8e, 0x7f, 0x57, 0x19, 0x83, 0xc9, 0x77, 0xbe, 0xfb, 0xbd, 0xe5, 0x3f, 25 | 0x2c, 0x0f, 0xf1, 0xea, 0xb1, 0xab, 0x7c, 0x39, 0xa7, 0x3d, 0x8e, 0xae, 0x36, 0xfe, 0x2d, 0x01, 26 | }; 27 | 28 | const unsigned char PROGMEM BOY_3[] ={ 29 | 0x3f, 0xbf, 0x7f, 0x46, 0xaf, 0x5e, 0xf9, 0xf7, 0xc8, 0x71, 0x5c, 0xe6, 0x3e, 0xf4, 0xf3, 0x54, 30 | 0xfe, 0x45, 0x65, 0xd4, 0x95, 0xbf, 0x8e, 0xc7, 0x35, 0xfe, 0x19, 0x39, 0xff, 0x10, 0x2c, 0x6e, 31 | 0x3d, 0xad, 0x41, 0xff, 0x55, 0xfd, 0x11, 0x38, 0x9d, 0xf8, 0x77, 0xf6, 0x5d, 0x2f, 0x87, 0x75, 32 | 0xd8, 0xf3, 0xe4, 0x57, 0xe6, 0xf8, 0x27, 0x25, 0x23, 0xdf, 0xfb, 0x19, 0x59, 0x9f, 0xfa, 0x17, 33 | 0xa5, 0xcd, 0xf4, 0x9a, 0x5b, 0xfd, 0x41, 0x73, 0x1d, 0x9d, 0x2c, 0xf3, 0x37, 0x04, 34 | }; 35 | 36 | const unsigned char PROGMEM BOY_4[] ={ 37 | 0x3f, 0xff, 0x7f, 0xdc, 0xb9, 0xf7, 0xde, 0x7b, 0xde, 0xf8, 0xf7, 0xe3, 0x6d, 0x5c, 0xe6, 0xbc, 38 | 0xac, 0x53, 0x8f, 0xfe, 0x34, 0xb3, 0xf8, 0xf7, 0xc2, 0x71, 0x66, 0xf6, 0x90, 0xe1, 0x1f, 0xe8, 39 | 0x5f, 0x07, 0x76, 0xef, 0x8b, 0x6b, 0xe6, 0x6f, 0x40, 0x73, 0x58, 0x97, 0x75, 0xf8, 0xb7, 0xf4, 40 | 0xf7, 0xc8, 0xfc, 0x57, 0xc6, 0xfc, 0xf6, 0xa5, 0xa7, 0x39, 0x2f, 0xe3, 0x2b, 0x1e, 0x4e, 0xf9, 41 | 0x47, 0xb5, 0xfd, 0xce, 0xaf, 0x99, 0xf9, 0x0e, 0xb7, 0x7f, 0x3b, 0x59, 0xc3, 0x6b, 0x6e, 0x63, 42 | 0xfc, 0xb8, 0xdd, 0xab, 0x57, 0x2d, 0x7f, 0x37, 43 | }; 44 | 45 | const unsigned char PROGMEM BOY_5[] ={ 46 | 0x3f, 0xbf, 0x7f, 0xe6, 0x1e, 0x0e, 0xeb, 0xb2, 0x2e, 0x73, 0xfe, 0x5b, 0x1a, 0x7b, 0xcf, 0x53, 47 | 0x6f, 0xb9, 0xfa, 0x13, 0xc3, 0xe4, 0xdf, 0x81, 0xb7, 0x71, 0x09, 0x1d, 0x99, 0x21, 0x97, 0x31, 48 | 0x46, 0xe4, 0xaf, 0xc3, 0xf8, 0x87, 0xe0, 0x95, 0x97, 0xec, 0xe4, 0x4f, 0x41, 0x7a, 0x58, 0x97, 49 | 0xd9, 0x7f, 0x4f, 0x7f, 0x8e, 0xcd, 0xbf, 0xb3, 0xef, 0x2e, 0xef, 0x5e, 0x0e, 0xe3, 0xc8, 0x57, 50 | 0xe6, 0xf8, 0x57, 0xe5, 0xfe, 0xd4, 0xf6, 0xfb, 0x3d, 0x7c, 0xb2, 0xe3, 0x5f, 0xce, 0xf0, 0xea, 51 | 0x71, 0x8c, 0xdf, 0x97, 0x79, 0xf4, 0xea, 0x1c, 0xfe, 0xe1, 0x00, 52 | }; 53 | 54 | const unsigned char PROGMEM BOY_6[] ={ 55 | 0x3f, 0xbf, 0xff, 0x0a, 0xc6, 0x61, 0xef, 0xbd, 0xe7, 0xc9, 0x7f, 0x3e, 0xbd, 0xcc, 0x7d, 0x58, 56 | 0x97, 0x71, 0xcb, 0xd5, 0xab, 0x57, 0xbe, 0x6d, 0xfe, 0xf0, 0xce, 0x34, 0xcb, 0x95, 0x7a, 0x50, 57 | 0x4f, 0xbd, 0x65, 0xb5, 0xe6, 0x20, 0x1e, 0xf9, 0xfd, 0x8c, 0x7f, 0x33, 0x19, 0xc3, 0xbf, 0xc5, 58 | 0xba, 0xac, 0xcb, 0x85, 0x7f, 0x46, 0x9b, 0xdf, 0xcf, 0xfc, 0x77, 0xf6, 0xdd, 0x95, 0xb3, 0x97, 59 | 0xc3, 0xf8, 0xe6, 0xcc, 0xbf, 0xa7, 0xc9, 0x77, 0xb2, 0x7f, 0xca, 0x98, 0x5f, 0xe1, 0xf6, 0xaf, 60 | 0xe7, 0x94, 0x6b, 0x36, 0xf9, 0xa5, 0x5d, 0x47, 0xaf, 0xce, 0xe1, 0x1f, 0x0e, 61 | }; 62 | 63 | const unsigned char PROGMEM BOY_7[] ={ 64 | 0x3f, 0xbf, 0xff, 0x2c, 0x72, 0x5a, 0x97, 0x75, 0x19, 0x47, 0xfe, 0xf9, 0xe4, 0xd6, 0xd3, 0x3a, 65 | 0xec, 0x79, 0x19, 0xb7, 0xde, 0x7a, 0xf3, 0xcb, 0x19, 0x7f, 0x68, 0x97, 0x2b, 0xcd, 0x4a, 0x33, 66 | 0xad, 0x07, 0xf5, 0x32, 0x6e, 0x1d, 0x4d, 0x33, 0xfd, 0x8b, 0xd8, 0x7f, 0x2e, 0xa4, 0xe3, 0xc8, 67 | 0xef, 0xf6, 0xd6, 0x5b, 0xf7, 0xbf, 0xa2, 0x91, 0x3f, 0xc7, 0x3f, 0x2c, 0xe7, 0x67, 0xc7, 0x38, 68 | 0xe6, 0x72, 0x18, 0x5f, 0xed, 0xfa, 0xd7, 0xf4, 0xb9, 0xee, 0x8f, 0x73, 0x5c, 0xeb, 0x2b, 0x9e, 69 | 0xfe, 0xcd, 0xb8, 0x4f, 0xb9, 0x66, 0xd5, 0x5f, 0x3a, 0xc6, 0xd1, 0xab, 0x73, 0xf8, 0x87, 0x03, 70 | }; 71 | 72 | const unsigned char PROGMEM BOY_8[] ={ 73 | 0x3f, 0xff, 0xff, 0x5e, 0x38, 0xf6, 0xd6, 0x5b, 0xfe, 0x75, 0x79, 0xf5, 0x38, 0x2e, 0x73, 0xef, 74 | 0xbd, 0xf7, 0x1e, 0x9f, 0xcd, 0xe1, 0xcf, 0xca, 0xb6, 0x59, 0x69, 0x56, 0x9a, 0xe5, 0x4a, 0x33, 75 | 0x4d, 0x76, 0xe8, 0xde, 0xc5, 0x0b, 0x7f, 0x96, 0x7f, 0x3a, 0xd9, 0xa7, 0xfc, 0x4c, 0xae, 0x5e, 76 | 0x3d, 0xae, 0x75, 0xe4, 0xdf, 0x49, 0xfb, 0xc7, 0xf8, 0x97, 0x95, 0xcb, 0xf7, 0x0e, 0xeb, 0xd4, 77 | 0xcb, 0xc5, 0xef, 0x66, 0xfc, 0x3b, 0xfa, 0xe8, 0xc1, 0xaf, 0x8f, 0xc3, 0xc5, 0xaf, 0x6c, 0xff, 78 | 0xdd, 0x8c, 0x71, 0xf4, 0x58, 0xc3, 0x0f, 0xcc, 0x3c, 0xe5, 0xea, 0x4e, 0xf4, 0x8f, 0x07, 79 | }; 80 | 81 | const unsigned char PROGMEM BOY_9[] ={ 82 | 0x3f, 0xff, 0xff, 0xb9, 0xcb, 0xad, 0xb7, 0xde, 0xc6, 0x65, 0xae, 0xa3, 0x57, 0x8f, 0x5d, 0xf4, 83 | 0x8f, 0xeb, 0xb6, 0x6e, 0xeb, 0xb6, 0x4e, 0x97, 0xcb, 0x95, 0x74, 0xd5, 0x8e, 0xe1, 0xe8, 0x5f, 84 | 0x05, 0xcd, 0xbf, 0x9e, 0x71, 0x38, 0xf4, 0x67, 0xf1, 0xf5, 0x1e, 0xfe, 0xcd, 0x2c, 0x7f, 0xfe, 85 | 0xca, 0xe6, 0xea, 0x95, 0x7f, 0x37, 0x9e, 0x3e, 0xc1, 0x71, 0xcd, 0xc3, 0xc5, 0x5f, 0xf1, 0x6f, 86 | 0xea, 0x2b, 0x1c, 0xbe, 0x3d, 0x0e, 0x17, 0xbf, 0xb3, 0xfc, 0x37, 0x14, 0x3a, 0x2f, 0xb3, 0x3f, 87 | 0xb0, 0xe3, 0x96, 0xab, 0xdb, 0xea, 0x1f, 0x0f, 88 | }; 89 | 90 | const unsigned char PROGMEM BOY_10[] ={ 91 | 0x3f, 0xbf, 0xff, 0xd9, 0xec, 0x61, 0xef, 0xbd, 0xf7, 0x21, 0x7f, 0xed, 0xde, 0x7a, 0x1b, 0x17, 92 | 0xcd, 0xb6, 0x19, 0x6d, 0xb3, 0x5c, 0x2e, 0xa6, 0x7f, 0x10, 0xf9, 0x53, 0x73, 0xf5, 0xca, 0x67, 93 | 0x73, 0xda, 0xe3, 0x6f, 0xf4, 0x8f, 0x26, 0xfe, 0x78, 0xbd, 0xe6, 0x36, 0x2e, 0xeb, 0x1f, 0xd3, 94 | 0x67, 0xfd, 0x19, 0xae, 0x7f, 0x5f, 0x5c, 0x6e, 0xbc, 0x1a, 0xf3, 0xc8, 0x9d, 0xdb, 0xee, 0xe7, 95 | 0xfe, 0x91, 0xad, 0xcb, 0xba, 0xf1, 0x53, 0xca, 0xea, 0xd1, 0xab, 0x39, 0xf8, 0x87, 0x03, 96 | }; 97 | 98 | const unsigned char PROGMEM BOY_11[] ={ 99 | 0x3f, 0xbf, 0xff, 0xd9, 0xec, 0x61, 0xef, 0xbd, 0xe7, 0xc9, 0x7f, 0x3d, 0xe3, 0x32, 0xf7, 0x9e, 100 | 0x97, 0x71, 0xcb, 0xd5, 0xab, 0x57, 0xbe, 0x3b, 0xc6, 0x3f, 0x04, 0x47, 0x56, 0x9a, 0x95, 0xe4, 101 | 0x30, 0x6e, 0x1d, 0x4d, 0xfd, 0xd3, 0xac, 0xfc, 0x03, 0x5a, 0xfc, 0xe4, 0x38, 0xe6, 0xbc, 0xac, 102 | 0xcb, 0x21, 0xff, 0x9c, 0x32, 0x7f, 0xed, 0x3f, 0xc6, 0x9d, 0x6f, 0x1c, 0xe6, 0xfa, 0xda, 0xc8, 103 | 0x3f, 0xbd, 0xb2, 0x7a, 0xeb, 0xfa, 0x54, 0x5c, 0x3d, 0x7a, 0x35, 0x07, 0xff, 0x70, 104 | }; 105 | 106 | const unsigned char PROGMEM BOY_12[] ={ 107 | 0x3f, 0xbf, 0xff, 0xd5, 0x1c, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xe7, 0x94, 0xdb, 0xb8, 0xcc, 108 | 0x79, 0x19, 0xb7, 0xde, 0xfa, 0x1b, 0x76, 0xfe, 0x59, 0xe4, 0xb2, 0x0e, 0x49, 0xda, 0x39, 0x2f, 109 | 0x2b, 0x7f, 0x98, 0xcd, 0xbf, 0x9f, 0xd1, 0x9f, 0x3d, 0xe6, 0x3e, 0xac, 0xc3, 0x25, 0xff, 0x9c, 110 | 0xb2, 0x7f, 0xec, 0xbf, 0xcf, 0xcf, 0xf1, 0xbd, 0x8c, 0x7f, 0x81, 0x6d, 0x5d, 0xbd, 0xf5, 0x70, 111 | 0xe3, 0x52, 0x66, 0x8f, 0x5e, 0xcd, 0xc1, 0x3f, 0x1c, 112 | }; 113 | 114 | const unsigned char PROGMEM BOY_13[] ={ 115 | 0x3f, 0xff, 0xff, 0xb1, 0x5c, 0x87, 0xbd, 0xf7, 0x9e, 0xff, 0xb8, 0xbc, 0x8d, 0xcb, 0xdc, 0x87, 116 | 0x75, 0xea, 0xad, 0x3f, 0x24, 0xfe, 0x33, 0xda, 0x3c, 0x0a, 0xf9, 0xf3, 0xfc, 0xa3, 0xf1, 0xd6, 117 | 0xfe, 0xfe, 0xb9, 0x0e, 0x7b, 0xaf, 0x23, 0xff, 0x7e, 0x38, 0x1e, 0xf8, 0x9d, 0xcc, 0x7f, 0x94, 118 | 0xbf, 0xf3, 0x1f, 0x61, 0x46, 0x3b, 0x58, 0xbd, 0x15, 0xe6, 0x69, 0xf7, 0x96, 0xab, 0xb3, 0xd1, 119 | 0x3f, 0x1e, 120 | }; 121 | 122 | const unsigned char PROGMEM BOY_14[] ={ 123 | 0x3f, 0xbf, 0xff, 0x91, 0x9c, 0xf3, 0xb2, 0x2e, 0x73, 0xff, 0x53, 0xcb, 0x6d, 0x1c, 0x0e, 0xe3, 124 | 0xd6, 0x5b, 0xae, 0x7c, 0x1c, 0x47, 0xff, 0x1d, 0xa5, 0x93, 0xbf, 0x97, 0xeb, 0x9f, 0xd0, 0xdf, 125 | 0xe1, 0x34, 0xd7, 0x65, 0x8e, 0x7f, 0x4e, 0x4c, 0xf3, 0x93, 0xff, 0x1d, 0xc6, 0xef, 0xe6, 0x7b, 126 | 0x2e, 0xf2, 0xcf, 0x8e, 0xae, 0xde, 0x7a, 0x2b, 0x8e, 0x87, 0x71, 0xf5, 0xe8, 0xd5, 0x1c, 0xfc, 127 | 0xc3, 0x01, 128 | }; 129 | 130 | const unsigned char PROGMEM BOY_15[] ={ 131 | 0x3f, 0xbf, 0xff, 0xd9, 0xcb, 0x6d, 0xe7, 0xea, 0xd5, 0x6b, 0x4e, 0xff, 0xf4, 0x3c, 0xdc, 0xf8, 132 | 0xf9, 0xb9, 0x1c, 0xfa, 0x0f, 0x29, 0xf9, 0x73, 0xac, 0xb5, 0x4f, 0x79, 0x72, 0xc9, 0x3f, 0x93, 133 | 0x3f, 0xc3, 0xe6, 0xf3, 0x39, 0xad, 0xc3, 0xfc, 0xa3, 0x7b, 0x9a, 0xfd, 0x0e, 0xa7, 0xc3, 0xec, 134 | 0x77, 0xff, 0xb9, 0x7d, 0xf7, 0x0b, 0x9f, 0xfd, 0xa7, 0x66, 0x56, 0x6f, 0xbd, 0x1d, 0xf8, 0x52, 135 | 0x5d, 0x3d, 0x7a, 0x35, 0x61, 0xf8, 0x87, 0x03, 136 | }; 137 | 138 | const unsigned char PROGMEM BOY_16[] ={ 139 | 0x3f, 0xbf, 0x7f, 0xf6, 0xdc, 0xc6, 0x65, 0x5d, 0xc6, 0x91, 0x7f, 0x9d, 0xe3, 0x32, 0xfb, 0x63, 140 | 0xe6, 0x3e, 0x8c, 0x23, 0xff, 0xbe, 0x46, 0xfe, 0x0e, 0xde, 0x32, 0xbd, 0x8d, 0x79, 0xe4, 0x9f, 141 | 0x4b, 0xfd, 0x2b, 0x7c, 0xcb, 0xe3, 0xb8, 0x84, 0xec, 0xd8, 0x95, 0xe6, 0x0f, 0xbe, 0xfd, 0x2b, 142 | 0xfc, 0xfb, 0x5a, 0xfd, 0x8e, 0xa7, 0xdd, 0xe3, 0xea, 0x77, 0xff, 0x7d, 0x39, 0x3e, 0xf4, 0xe9, 143 | 0xcf, 0xd9, 0x7f, 0x52, 0x8e, 0xba, 0x7a, 0x5a, 0xf3, 0xc8, 0xa7, 0xe3, 0xea, 0xd1, 0xab, 0x09, 144 | 0xc3, 0x3f, 0x1c, 145 | }; 146 | 147 | const unsigned char PROGMEM BOY_17[] ={ 148 | 0x3f, 0xbf, 0x7f, 0xd3, 0xc3, 0xb8, 0xf5, 0xd6, 0xd3, 0x1c, 0xff, 0x3c, 0xb9, 0xed, 0xf1, 0xeb, 149 | 0xb8, 0xe6, 0x36, 0x0e, 0x7b, 0x9e, 0xfa, 0x8f, 0x68, 0xe5, 0x4f, 0x50, 0xaf, 0xb9, 0xf5, 0xb4, 150 | 0x2e, 0x9a, 0x6d, 0xdd, 0xd6, 0x6d, 0xf9, 0x27, 0xb0, 0xfc, 0x0b, 0xb8, 0xfe, 0x69, 0x9d, 0xfc, 151 | 0x3b, 0xac, 0xfe, 0x2b, 0xca, 0x3e, 0xf9, 0x8e, 0xdb, 0x5c, 0x47, 0xae, 0xab, 0x5f, 0x1e, 0xfc, 152 | 0x3b, 0xfa, 0x4e, 0xc7, 0xaf, 0xf9, 0xe6, 0x3f, 0xa3, 0xc1, 0xf4, 0x38, 0x0e, 0xbf, 0x6d, 0x8c, 153 | 0xa3, 0x57, 0xe7, 0xf0, 0x0f, 0x07, 154 | }; 155 | 156 | const unsigned char PROGMEM BOY_18[] ={ 157 | 0x3f, 0xbf, 0x7f, 0xb8, 0xac, 0x5b, 0xae, 0x5e, 0x73, 0xda, 0xbd, 0xf2, 0xaf, 0x73, 0x8c, 0xdf, 158 | 0xcb, 0x35, 0xb7, 0x9e, 0xd6, 0x61, 0xcf, 0x53, 0xae, 0x5e, 0xbd, 0xf2, 0x77, 0xef, 0xfa, 0x7b, 159 | 0x7c, 0x85, 0xab, 0x57, 0xaf, 0x5e, 0xfd, 0xe7, 0xa0, 0x7f, 0x0b, 0x0e, 0xff, 0xb0, 0x4e, 0xfe, 160 | 0x1d, 0xa6, 0xff, 0x8c, 0xbc, 0x9c, 0x78, 0xe7, 0x69, 0xce, 0x93, 0xe7, 0x8e, 0xef, 0xff, 0xfb, 161 | 0x61, 0x7e, 0x67, 0xf4, 0xd7, 0x7c, 0xf8, 0x9f, 0x8e, 0xe3, 0xe8, 0x71, 0x8d, 0x9f, 0x97, 0x79, 162 | 0xf4, 0xea, 0xae, 0x7f, 0x38, 163 | }; 164 | 165 | const unsigned char PROGMEM BOY_19[] ={ 166 | 0x3f, 0xbf, 0x7f, 0xa2, 0x32, 0xc6, 0xad, 0xb7, 0xde, 0xd6, 0xfa, 0xc7, 0xfb, 0x43, 0xb9, 0x7a, 167 | 0xec, 0xad, 0xb7, 0x9e, 0xd6, 0x65, 0xaf, 0xcb, 0xba, 0x04, 0x2f, 0x86, 0x3f, 0xfa, 0xc8, 0x1f, 168 | 0x65, 0xe7, 0x5f, 0xd9, 0xda, 0x7f, 0x93, 0xcc, 0x7f, 0x5a, 0x3b, 0x7f, 0x87, 0xe9, 0x3f, 0x23, 169 | 0x6e, 0x07, 0x3f, 0x93, 0xcb, 0x61, 0x1c, 0x73, 0xf8, 0x01, 0xff, 0x7a, 0x32, 0xbe, 0x92, 0x79, 170 | 0xe4, 0xfb, 0x93, 0xef, 0xfe, 0xcb, 0xa9, 0xd3, 0x63, 0x2f, 0xbf, 0x8e, 0x7d, 0xf3, 0xea, 0x21, 171 | 0xfe, 0xe1, 0x00, 172 | }; 173 | 174 | const unsigned char PROGMEM BOY_20[] ={ 175 | 0x3f, 0xbf, 0x7f, 0x15, 0xc8, 0xe1, 0xb0, 0x2e, 0xeb, 0x32, 0xc7, 0x3f, 0xdf, 0xdf, 0xe1, 0xad, 176 | 0xb7, 0x9e, 0xd6, 0x65, 0x5d, 0xd6, 0x61, 0xef, 0xbd, 0x2f, 0xbd, 0xf5, 0x36, 0x2e, 0xc1, 0x83, 177 | 0x7f, 0xe9, 0xe5, 0x5f, 0x05, 0xdd, 0xf5, 0xea, 0xd5, 0x7f, 0x3e, 0x5e, 0xf6, 0xfe, 0x8b, 0xcc, 178 | 0xfc, 0xeb, 0x5a, 0xfd, 0x03, 0xb0, 0x26, 0xff, 0xaa, 0x66, 0xbe, 0xc3, 0x6d, 0xae, 0x63, 0x4e, 179 | 0x9f, 0xff, 0x67, 0xf4, 0xc1, 0x43, 0x3f, 0x3f, 0xf9, 0xee, 0xbf, 0x1c, 0x3b, 0x3d, 0xf6, 0x74, 180 | 0xf0, 0x07, 0xb9, 0x6f, 0x5e, 0x3d, 0xc4, 0x3f, 0x1c, 181 | }; 182 | 183 | const unsigned char PROGMEM BOY_21[] ={ 184 | 0x3f, 0xff, 0x7f, 0x1e, 0x8f, 0x3d, 0xfa, 0xcf, 0x97, 0xdb, 0xef, 0x98, 0x7b, 0xcf, 0xcb, 0x3a, 185 | 0xf5, 0xd6, 0x5b, 0xae, 0xbe, 0xf6, 0xea, 0xb1, 0xa7, 0xfc, 0xa5, 0xeb, 0x9f, 0x84, 0x1d, 0xba, 186 | 0xf7, 0x3e, 0x8c, 0x5b, 0x6f, 0xb9, 0x7a, 0xe5, 0xcf, 0x9f, 0xc3, 0xa9, 0x37, 0x7f, 0xf5, 0x38, 187 | 0x5c, 0xf2, 0xcf, 0xed, 0x4f, 0x61, 0x96, 0xf0, 0x6f, 0xec, 0xfb, 0x63, 0x9e, 0x66, 0x3f, 0x55, 188 | 0xfe, 0x79, 0x75, 0x7c, 0x26, 0x87, 0x1b, 0xdf, 0x69, 0xbe, 0xf5, 0x2f, 0x89, 0x34, 0x33, 0xb7, 189 | 0xde, 0x56, 0x7f, 0xcd, 0xce, 0xd5, 0xab, 0xfe, 0xf1, 0x00, 190 | }; 191 | 192 | const unsigned char PROGMEM BOY_22[] ={ 193 | 0x3f, 0xbf, 0xff, 0xdd, 0xc9, 0x3e, 0xf5, 0xd6, 0xdb, 0x38, 0x9c, 0xbc, 0x7a, 0xf5, 0xc7, 0xf7, 194 | 0x34, 0xfe, 0xf6, 0xdb, 0xdf, 0xcf, 0x64, 0xb9, 0x5c, 0x8e, 0x15, 0x73, 0x50, 0x2f, 0xe3, 0xd6, 195 | 0xa3, 0x7f, 0xfe, 0xae, 0x23, 0x7f, 0x84, 0x3d, 0xfe, 0xcd, 0xf5, 0xd6, 0xf5, 0xe3, 0x67, 0xe2, 196 | 0xbf, 0xb9, 0xdf, 0xcd, 0x34, 0xff, 0xf4, 0xbe, 0xe7, 0xe1, 0x94, 0xe3, 0x97, 0x18, 0xff, 0xb6, 197 | 0xd8, 0x75, 0xb1, 0x7a, 0xeb, 0xe1, 0xe4, 0xf7, 0x56, 0x8f, 0xde, 0xfe, 0xb4, 198 | }; 199 | 200 | const unsigned char PROGMEM BOY_23[] ={ 201 | 0x3f, 0xbf, 0xff, 0xdd, 0xc9, 0x3e, 0xf5, 0xd6, 0xdb, 0x38, 0x9c, 0xbc, 0x7a, 0xf5, 0xc7, 0xf7, 202 | 0x34, 0xfe, 0xf6, 0xdb, 0xdf, 0xcf, 0x64, 0xb9, 0x5c, 0x8e, 0x15, 0x73, 0x50, 0x2f, 0xe3, 0xd6, 203 | 0xa3, 0x7f, 0xfe, 0xae, 0x23, 0x7f, 0x84, 0x3d, 0xfe, 0xcd, 0xf5, 0xd6, 0x55, 0x7f, 0xf6, 0x6a, 204 | 0xfc, 0x37, 0xf7, 0xbb, 0x99, 0xe6, 0x9f, 0xde, 0xf7, 0x3c, 0x9c, 0x72, 0xfc, 0x12, 0xe3, 0xdf, 205 | 0x16, 0xbb, 0x2e, 0x56, 0x6f, 0x3d, 0x1d, 0xfc, 0xde, 0xea, 0xd1, 0xdb, 0x9f, 0x16, 206 | }; 207 | 208 | 209 | const unsigned char *BOY[] = { 210 | BOY_0, 211 | BOY_1, 212 | BOY_2, 213 | BOY_3, 214 | BOY_4, 215 | BOY_5, 216 | BOY_6, 217 | BOY_7, 218 | BOY_8, 219 | BOY_9, 220 | BOY_10, 221 | BOY_11, 222 | BOY_12, 223 | BOY_13, 224 | BOY_14, 225 | BOY_15, 226 | BOY_16, 227 | BOY_17, 228 | BOY_18, 229 | BOY_19, 230 | BOY_20, 231 | BOY_21, 232 | BOY_22, 233 | BOY_23, 234 | }; 235 | 236 | // File: d:\arduboy\boy.gif (24 frames) 237 | // Size: 24x64x64px (12288 bytes) 238 | // Encoded: 1978 bytes 239 | // Ratio: 0.16097005 240 | 241 | -------------------------------------------------------------------------------- /examples/Sample5-Basic-Arduboy2/Sample5-Basic-Arduboy2.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | // make an instance of arduboy used for many functions 6 | Arduboy2 arduboy; 7 | 8 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 9 | #define ARDBITMAP_SBUF arduboy.getBuffer() 10 | #include 11 | ArdBitmap ardbitmap; 12 | 13 | // This function runs once in your game. 14 | // use it for anything that needs to be set only once in your game. 15 | void setup() { 16 | // initiate arduboy instance 17 | arduboy.begin(); 18 | arduboy.setFrameRate(60); 19 | } 20 | 21 | 22 | // our main game loop, this runs once every cycle/frame. 23 | // this is where our game logic goes. 24 | void loop() { 25 | // pause render until it's time for the next frame 26 | if (!(arduboy.nextFrame())) 27 | return; 28 | 29 | // first we clear our screen to black 30 | arduboy.clear(); 31 | 32 | ardbitmap.drawCompressed(WIDTH / 2 ,HEIGHT / 2, BOY, WHITE, ALIGN_CENTER, MIRROR_NONE); 33 | 34 | // then we finaly we tell the arduboy to display what we just wrote to the display 35 | arduboy.display(); 36 | } 37 | -------------------------------------------------------------------------------- /examples/Sample5-Basic-Arduboy2/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BOY[] ={ 3 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 4 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 5 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 6 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 7 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 8 | }; 9 | 10 | // File: d:\arduboy\boy.gif 11 | // Size: 64x64px (512 bytes) 12 | // Encoded: 80 bytes 13 | // Ratio: 0.15625 14 | -------------------------------------------------------------------------------- /examples/Sample6-Complex/Sample6-Complex.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "bitmaps.h" 4 | 5 | #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) 6 | 7 | #define FRAME_RATE 24 8 | // make an instance of arduboy used for many functions 9 | Arduboy arduboy; 10 | 11 | // make an ArdBitmap instance that will use the given the screen buffer and dimensions 12 | #define ARDBITMAP_SBUF arduboy.getBuffer() 13 | #include 14 | ArdBitmap ardbitmap; 15 | 16 | // This function runs once in your game. 17 | // use it for anything that needs to be set only once in your game. 18 | void setup() { 19 | // initiate arduboy instance 20 | arduboy.begin(); 21 | arduboy.setFrameRate(FRAME_RATE); 22 | } 23 | 24 | 25 | // our main game loop, this runs once every cycle/frame. 26 | // this is where our game logic goes. 27 | void loop() { 28 | // pause render until it's time for the next frame 29 | if (!(arduboy.nextFrame())) 30 | return; 31 | 32 | // first we clear our screen to black 33 | arduboy.clear(); 34 | 35 | float resize1 = abs(cos(millis()/ 1000.0)); 36 | float resize2 = abs(sin(millis()/ 1000.0)); 37 | 38 | ardbitmap.drawCompressedResized(WIDTH/ 4, HEIGHT, BOY[arduboy.frameCount % ARRAY_LEN(BOY)], WHITE, ALIGN_H_CENTER | ALIGN_V_BOTTOM, MIRROR_NONE, resize1); 39 | 40 | ardbitmap.drawCompressedResized((WIDTH * 3) / 4, HEIGHT, BOY[(arduboy.frameCount + 10) % ARRAY_LEN(BOY)], WHITE, ALIGN_H_CENTER | ALIGN_V_BOTTOM, MIRROR_NONE, resize2); 41 | 42 | // then we finaly we tell the arduboy to display what we just wrote to the display 43 | arduboy.display(); 44 | } 45 | -------------------------------------------------------------------------------- /examples/Sample6-Complex/bitmaps.h: -------------------------------------------------------------------------------- 1 | 2 | const unsigned char PROGMEM BOY_0[] ={ 3 | 0x3f, 0xbf, 0xff, 0x91, 0x59, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xfb, 0x70, 0xf4, 0xdf, 0x81, 4 | 0xf9, 0x36, 0xb7, 0xde, 0x7a, 0xeb, 0x6d, 0x5c, 0xe6, 0xde, 0x7b, 0xc7, 0xcc, 0x34, 0x23, 0x2b, 5 | 0xc9, 0x9e, 0x27, 0xff, 0xfe, 0x7f, 0x0b, 0x5b, 0x57, 0xfe, 0xb1, 0xad, 0xf5, 0x47, 0xc8, 0x22, 6 | 0xff, 0xfc, 0x7e, 0x6c, 0xc7, 0x3f, 0xc0, 0x8c, 0xc1, 0xf7, 0xba, 0xf9, 0x54, 0xc6, 0x3f, 0x42, 7 | 0x6d, 0x60, 0x78, 0xcd, 0xad, 0xfb, 0xb4, 0x0e, 0x7b, 0xdd, 0xb2, 0x32, 0xec, 0xe6, 0x2f, 0x0d, 8 | }; 9 | 10 | const unsigned char PROGMEM BOY_1[] ={ 11 | 0x3f, 0xbf, 0xff, 0xd1, 0x99, 0x7b, 0xcf, 0xc3, 0x9e, 0x27, 0xff, 0xb5, 0xae, 0xfe, 0x9a, 0xde, 12 | 0xc6, 0x65, 0x1d, 0x0e, 0xe3, 0x96, 0xab, 0x57, 0xaf, 0x5e, 0x73, 0x9a, 0x17, 0xfe, 0xf0, 0x7f, 13 | 0x13, 0xed, 0x3e, 0x8c, 0x5b, 0x6f, 0xbd, 0xe5, 0xea, 0x95, 0xbf, 0x3f, 0xc7, 0xb5, 0x0f, 0xfe, 14 | 0xee, 0x8c, 0xf8, 0x6f, 0xce, 0xf9, 0xf1, 0x1e, 0xf9, 0xce, 0xca, 0x3f, 0x39, 0x3a, 0xf2, 0xd9, 15 | 0x47, 0x9f, 0x5c, 0xfe, 0xa3, 0xd3, 0x06, 0x86, 0xd7, 0xdc, 0xba, 0x5e, 0x8f, 0xcb, 0x21, 0x57, 16 | 0x57, 0xf3, 0x97, 0x06, 17 | }; 18 | 19 | const unsigned char PROGMEM BOY_2[] ={ 20 | 0x3f, 0xff, 0xff, 0x39, 0xca, 0xe5, 0x30, 0x6e, 0xbd, 0xf5, 0x34, 0xf3, 0xcf, 0x6f, 0xcd, 0x9b, 21 | 0x3f, 0x8f, 0x63, 0x4f, 0x73, 0xde, 0xf8, 0x97, 0xe3, 0xbc, 0xac, 0xcb, 0xf8, 0xf9, 0xd9, 0xf3, 22 | 0xd4, 0xe1, 0x68, 0xa6, 0xff, 0x92, 0x34, 0xfc, 0x15, 0x0e, 0xfc, 0x93, 0xfb, 0x76, 0x0f, 0xfb, 23 | 0xb0, 0x4e, 0x7e, 0x65, 0x8e, 0x7f, 0x57, 0x19, 0x83, 0xc9, 0x77, 0xbe, 0xfb, 0xbd, 0xe5, 0x3f, 24 | 0x2c, 0x0f, 0xf1, 0xea, 0xb1, 0xab, 0x7c, 0x39, 0xa7, 0x3d, 0x8e, 0xae, 0x36, 0xfe, 0x2d, 0x01, 25 | }; 26 | 27 | const unsigned char PROGMEM BOY_3[] ={ 28 | 0x3f, 0xbf, 0x7f, 0x46, 0xaf, 0x5e, 0xf9, 0xf7, 0xc8, 0x71, 0x5c, 0xe6, 0x3e, 0xf4, 0xf3, 0x54, 29 | 0xfe, 0x45, 0x65, 0xd4, 0x95, 0xbf, 0x8e, 0xc7, 0x35, 0xfe, 0x19, 0x39, 0xff, 0x10, 0x2c, 0x6e, 30 | 0x3d, 0xad, 0x41, 0xff, 0x55, 0xfd, 0x11, 0x38, 0x9d, 0xf8, 0x77, 0xf6, 0x5d, 0x2f, 0x87, 0x75, 31 | 0xd8, 0xf3, 0xe4, 0x57, 0xe6, 0xf8, 0x27, 0x25, 0x23, 0xdf, 0xfb, 0x19, 0x59, 0x9f, 0xfa, 0x17, 32 | 0xa5, 0xcd, 0xf4, 0x9a, 0x5b, 0xfd, 0x41, 0x73, 0x1d, 0x9d, 0x2c, 0xf3, 0x37, 0x04, 33 | }; 34 | 35 | const unsigned char PROGMEM BOY_4[] ={ 36 | 0x3f, 0xff, 0x7f, 0xdc, 0xb9, 0xf7, 0xde, 0x7b, 0xde, 0xf8, 0xf7, 0xe3, 0x6d, 0x5c, 0xe6, 0xbc, 37 | 0xac, 0x53, 0x8f, 0xfe, 0x34, 0xb3, 0xf8, 0xf7, 0xc2, 0x71, 0x66, 0xf6, 0x90, 0xe1, 0x1f, 0xe8, 38 | 0x5f, 0x07, 0x76, 0xef, 0x8b, 0x6b, 0xe6, 0x6f, 0x40, 0x73, 0x58, 0x97, 0x75, 0xf8, 0xb7, 0xf4, 39 | 0xf7, 0xc8, 0xfc, 0x57, 0xc6, 0xfc, 0xf6, 0xa5, 0xa7, 0x39, 0x2f, 0xe3, 0x2b, 0x1e, 0x4e, 0xf9, 40 | 0x47, 0xb5, 0xfd, 0xce, 0xaf, 0x99, 0xf9, 0x0e, 0xb7, 0x7f, 0x3b, 0x59, 0xc3, 0x6b, 0x6e, 0x63, 41 | 0xfc, 0xb8, 0xdd, 0xab, 0x57, 0x2d, 0x7f, 0x37, 42 | }; 43 | 44 | const unsigned char PROGMEM BOY_5[] ={ 45 | 0x3f, 0xbf, 0x7f, 0xe6, 0x1e, 0x0e, 0xeb, 0xb2, 0x2e, 0x73, 0xfe, 0x5b, 0x1a, 0x7b, 0xcf, 0x53, 46 | 0x6f, 0xb9, 0xfa, 0x13, 0xc3, 0xe4, 0xdf, 0x81, 0xb7, 0x71, 0x09, 0x1d, 0x99, 0x21, 0x97, 0x31, 47 | 0x46, 0xe4, 0xaf, 0xc3, 0xf8, 0x87, 0xe0, 0x95, 0x97, 0xec, 0xe4, 0x4f, 0x41, 0x7a, 0x58, 0x97, 48 | 0xd9, 0x7f, 0x4f, 0x7f, 0x8e, 0xcd, 0xbf, 0xb3, 0xef, 0x2e, 0xef, 0x5e, 0x0e, 0xe3, 0xc8, 0x57, 49 | 0xe6, 0xf8, 0x57, 0xe5, 0xfe, 0xd4, 0xf6, 0xfb, 0x3d, 0x7c, 0xb2, 0xe3, 0x5f, 0xce, 0xf0, 0xea, 50 | 0x71, 0x8c, 0xdf, 0x97, 0x79, 0xf4, 0xea, 0x1c, 0xfe, 0xe1, 0x00, 51 | }; 52 | 53 | const unsigned char PROGMEM BOY_6[] ={ 54 | 0x3f, 0xbf, 0xff, 0x0a, 0xc6, 0x61, 0xef, 0xbd, 0xe7, 0xc9, 0x7f, 0x3e, 0xbd, 0xcc, 0x7d, 0x58, 55 | 0x97, 0x71, 0xcb, 0xd5, 0xab, 0x57, 0xbe, 0x6d, 0xfe, 0xf0, 0xce, 0x34, 0xcb, 0x95, 0x7a, 0x50, 56 | 0x4f, 0xbd, 0x65, 0xb5, 0xe6, 0x20, 0x1e, 0xf9, 0xfd, 0x8c, 0x7f, 0x33, 0x19, 0xc3, 0xbf, 0xc5, 57 | 0xba, 0xac, 0xcb, 0x85, 0x7f, 0x46, 0x9b, 0xdf, 0xcf, 0xfc, 0x77, 0xf6, 0xdd, 0x95, 0xb3, 0x97, 58 | 0xc3, 0xf8, 0xe6, 0xcc, 0xbf, 0xa7, 0xc9, 0x77, 0xb2, 0x7f, 0xca, 0x98, 0x5f, 0xe1, 0xf6, 0xaf, 59 | 0xe7, 0x94, 0x6b, 0x36, 0xf9, 0xa5, 0x5d, 0x47, 0xaf, 0xce, 0xe1, 0x1f, 0x0e, 60 | }; 61 | 62 | const unsigned char PROGMEM BOY_7[] ={ 63 | 0x3f, 0xbf, 0xff, 0x2c, 0x72, 0x5a, 0x97, 0x75, 0x19, 0x47, 0xfe, 0xf9, 0xe4, 0xd6, 0xd3, 0x3a, 64 | 0xec, 0x79, 0x19, 0xb7, 0xde, 0x7a, 0xf3, 0xcb, 0x19, 0x7f, 0x68, 0x97, 0x2b, 0xcd, 0x4a, 0x33, 65 | 0xad, 0x07, 0xf5, 0x32, 0x6e, 0x1d, 0x4d, 0x33, 0xfd, 0x8b, 0xd8, 0x7f, 0x2e, 0xa4, 0xe3, 0xc8, 66 | 0xef, 0xf6, 0xd6, 0x5b, 0xf7, 0xbf, 0xa2, 0x91, 0x3f, 0xc7, 0x3f, 0x2c, 0xe7, 0x67, 0xc7, 0x38, 67 | 0xe6, 0x72, 0x18, 0x5f, 0xed, 0xfa, 0xd7, 0xf4, 0xb9, 0xee, 0x8f, 0x73, 0x5c, 0xeb, 0x2b, 0x9e, 68 | 0xfe, 0xcd, 0xb8, 0x4f, 0xb9, 0x66, 0xd5, 0x5f, 0x3a, 0xc6, 0xd1, 0xab, 0x73, 0xf8, 0x87, 0x03, 69 | }; 70 | 71 | const unsigned char PROGMEM BOY_8[] ={ 72 | 0x3f, 0xff, 0xff, 0x5e, 0x38, 0xf6, 0xd6, 0x5b, 0xfe, 0x75, 0x79, 0xf5, 0x38, 0x2e, 0x73, 0xef, 73 | 0xbd, 0xf7, 0x1e, 0x9f, 0xcd, 0xe1, 0xcf, 0xca, 0xb6, 0x59, 0x69, 0x56, 0x9a, 0xe5, 0x4a, 0x33, 74 | 0x4d, 0x76, 0xe8, 0xde, 0xc5, 0x0b, 0x7f, 0x96, 0x7f, 0x3a, 0xd9, 0xa7, 0xfc, 0x4c, 0xae, 0x5e, 75 | 0x3d, 0xae, 0x75, 0xe4, 0xdf, 0x49, 0xfb, 0xc7, 0xf8, 0x97, 0x95, 0xcb, 0xf7, 0x0e, 0xeb, 0xd4, 76 | 0xcb, 0xc5, 0xef, 0x66, 0xfc, 0x3b, 0xfa, 0xe8, 0xc1, 0xaf, 0x8f, 0xc3, 0xc5, 0xaf, 0x6c, 0xff, 77 | 0xdd, 0x8c, 0x71, 0xf4, 0x58, 0xc3, 0x0f, 0xcc, 0x3c, 0xe5, 0xea, 0x4e, 0xf4, 0x8f, 0x07, 78 | }; 79 | 80 | const unsigned char PROGMEM BOY_9[] ={ 81 | 0x3f, 0xff, 0xff, 0xb9, 0xcb, 0xad, 0xb7, 0xde, 0xc6, 0x65, 0xae, 0xa3, 0x57, 0x8f, 0x5d, 0xf4, 82 | 0x8f, 0xeb, 0xb6, 0x6e, 0xeb, 0xb6, 0x4e, 0x97, 0xcb, 0x95, 0x74, 0xd5, 0x8e, 0xe1, 0xe8, 0x5f, 83 | 0x05, 0xcd, 0xbf, 0x9e, 0x71, 0x38, 0xf4, 0x67, 0xf1, 0xf5, 0x1e, 0xfe, 0xcd, 0x2c, 0x7f, 0xfe, 84 | 0xca, 0xe6, 0xea, 0x95, 0x7f, 0x37, 0x9e, 0x3e, 0xc1, 0x71, 0xcd, 0xc3, 0xc5, 0x5f, 0xf1, 0x6f, 85 | 0xea, 0x2b, 0x1c, 0xbe, 0x3d, 0x0e, 0x17, 0xbf, 0xb3, 0xfc, 0x37, 0x14, 0x3a, 0x2f, 0xb3, 0x3f, 86 | 0xb0, 0xe3, 0x96, 0xab, 0xdb, 0xea, 0x1f, 0x0f, 87 | }; 88 | 89 | const unsigned char PROGMEM BOY_10[] ={ 90 | 0x3f, 0xbf, 0xff, 0xd9, 0xec, 0x61, 0xef, 0xbd, 0xf7, 0x21, 0x7f, 0xed, 0xde, 0x7a, 0x1b, 0x17, 91 | 0xcd, 0xb6, 0x19, 0x6d, 0xb3, 0x5c, 0x2e, 0xa6, 0x7f, 0x10, 0xf9, 0x53, 0x73, 0xf5, 0xca, 0x67, 92 | 0x73, 0xda, 0xe3, 0x6f, 0xf4, 0x8f, 0x26, 0xfe, 0x78, 0xbd, 0xe6, 0x36, 0x2e, 0xeb, 0x1f, 0xd3, 93 | 0x67, 0xfd, 0x19, 0xae, 0x7f, 0x5f, 0x5c, 0x6e, 0xbc, 0x1a, 0xf3, 0xc8, 0x9d, 0xdb, 0xee, 0xe7, 94 | 0xfe, 0x91, 0xad, 0xcb, 0xba, 0xf1, 0x53, 0xca, 0xea, 0xd1, 0xab, 0x39, 0xf8, 0x87, 0x03, 95 | }; 96 | 97 | const unsigned char PROGMEM BOY_11[] ={ 98 | 0x3f, 0xbf, 0xff, 0xd9, 0xec, 0x61, 0xef, 0xbd, 0xe7, 0xc9, 0x7f, 0x3d, 0xe3, 0x32, 0xf7, 0x9e, 99 | 0x97, 0x71, 0xcb, 0xd5, 0xab, 0x57, 0xbe, 0x3b, 0xc6, 0x3f, 0x04, 0x47, 0x56, 0x9a, 0x95, 0xe4, 100 | 0x30, 0x6e, 0x1d, 0x4d, 0xfd, 0xd3, 0xac, 0xfc, 0x03, 0x5a, 0xfc, 0xe4, 0x38, 0xe6, 0xbc, 0xac, 101 | 0xcb, 0x21, 0xff, 0x9c, 0x32, 0x7f, 0xed, 0x3f, 0xc6, 0x9d, 0x6f, 0x1c, 0xe6, 0xfa, 0xda, 0xc8, 102 | 0x3f, 0xbd, 0xb2, 0x7a, 0xeb, 0xfa, 0x54, 0x5c, 0x3d, 0x7a, 0x35, 0x07, 0xff, 0x70, 103 | }; 104 | 105 | const unsigned char PROGMEM BOY_12[] ={ 106 | 0x3f, 0xbf, 0xff, 0xd5, 0x1c, 0x87, 0xbd, 0xf7, 0x61, 0xdd, 0xf8, 0xe7, 0x94, 0xdb, 0xb8, 0xcc, 107 | 0x79, 0x19, 0xb7, 0xde, 0xfa, 0x1b, 0x76, 0xfe, 0x59, 0xe4, 0xb2, 0x0e, 0x49, 0xda, 0x39, 0x2f, 108 | 0x2b, 0x7f, 0x98, 0xcd, 0xbf, 0x9f, 0xd1, 0x9f, 0x3d, 0xe6, 0x3e, 0xac, 0xc3, 0x25, 0xff, 0x9c, 109 | 0xb2, 0x7f, 0xec, 0xbf, 0xcf, 0xcf, 0xf1, 0xbd, 0x8c, 0x7f, 0x81, 0x6d, 0x5d, 0xbd, 0xf5, 0x70, 110 | 0xe3, 0x52, 0x66, 0x8f, 0x5e, 0xcd, 0xc1, 0x3f, 0x1c, 111 | }; 112 | 113 | const unsigned char PROGMEM BOY_13[] ={ 114 | 0x3f, 0xff, 0xff, 0xb1, 0x5c, 0x87, 0xbd, 0xf7, 0x9e, 0xff, 0xb8, 0xbc, 0x8d, 0xcb, 0xdc, 0x87, 115 | 0x75, 0xea, 0xad, 0x3f, 0x24, 0xfe, 0x33, 0xda, 0x3c, 0x0a, 0xf9, 0xf3, 0xfc, 0xa3, 0xf1, 0xd6, 116 | 0xfe, 0xfe, 0xb9, 0x0e, 0x7b, 0xaf, 0x23, 0xff, 0x7e, 0x38, 0x1e, 0xf8, 0x9d, 0xcc, 0x7f, 0x94, 117 | 0xbf, 0xf3, 0x1f, 0x61, 0x46, 0x3b, 0x58, 0xbd, 0x15, 0xe6, 0x69, 0xf7, 0x96, 0xab, 0xb3, 0xd1, 118 | 0x3f, 0x1e, 119 | }; 120 | 121 | const unsigned char PROGMEM BOY_14[] ={ 122 | 0x3f, 0xbf, 0xff, 0x91, 0x9c, 0xf3, 0xb2, 0x2e, 0x73, 0xff, 0x53, 0xcb, 0x6d, 0x1c, 0x0e, 0xe3, 123 | 0xd6, 0x5b, 0xae, 0x7c, 0x1c, 0x47, 0xff, 0x1d, 0xa5, 0x93, 0xbf, 0x97, 0xeb, 0x9f, 0xd0, 0xdf, 124 | 0xe1, 0x34, 0xd7, 0x65, 0x8e, 0x7f, 0x4e, 0x4c, 0xf3, 0x93, 0xff, 0x1d, 0xc6, 0xef, 0xe6, 0x7b, 125 | 0x2e, 0xf2, 0xcf, 0x8e, 0xae, 0xde, 0x7a, 0x2b, 0x8e, 0x87, 0x71, 0xf5, 0xe8, 0xd5, 0x1c, 0xfc, 126 | 0xc3, 0x01, 127 | }; 128 | 129 | const unsigned char PROGMEM BOY_15[] ={ 130 | 0x3f, 0xbf, 0xff, 0xd9, 0xcb, 0x6d, 0xe7, 0xea, 0xd5, 0x6b, 0x4e, 0xff, 0xf4, 0x3c, 0xdc, 0xf8, 131 | 0xf9, 0xb9, 0x1c, 0xfa, 0x0f, 0x29, 0xf9, 0x73, 0xac, 0xb5, 0x4f, 0x79, 0x72, 0xc9, 0x3f, 0x93, 132 | 0x3f, 0xc3, 0xe6, 0xf3, 0x39, 0xad, 0xc3, 0xfc, 0xa3, 0x7b, 0x9a, 0xfd, 0x0e, 0xa7, 0xc3, 0xec, 133 | 0x77, 0xff, 0xb9, 0x7d, 0xf7, 0x0b, 0x9f, 0xfd, 0xa7, 0x66, 0x56, 0x6f, 0xbd, 0x1d, 0xf8, 0x52, 134 | 0x5d, 0x3d, 0x7a, 0x35, 0x61, 0xf8, 0x87, 0x03, 135 | }; 136 | 137 | const unsigned char PROGMEM BOY_16[] ={ 138 | 0x3f, 0xbf, 0x7f, 0xf6, 0xdc, 0xc6, 0x65, 0x5d, 0xc6, 0x91, 0x7f, 0x9d, 0xe3, 0x32, 0xfb, 0x63, 139 | 0xe6, 0x3e, 0x8c, 0x23, 0xff, 0xbe, 0x46, 0xfe, 0x0e, 0xde, 0x32, 0xbd, 0x8d, 0x79, 0xe4, 0x9f, 140 | 0x4b, 0xfd, 0x2b, 0x7c, 0xcb, 0xe3, 0xb8, 0x84, 0xec, 0xd8, 0x95, 0xe6, 0x0f, 0xbe, 0xfd, 0x2b, 141 | 0xfc, 0xfb, 0x5a, 0xfd, 0x8e, 0xa7, 0xdd, 0xe3, 0xea, 0x77, 0xff, 0x7d, 0x39, 0x3e, 0xf4, 0xe9, 142 | 0xcf, 0xd9, 0x7f, 0x52, 0x8e, 0xba, 0x7a, 0x5a, 0xf3, 0xc8, 0xa7, 0xe3, 0xea, 0xd1, 0xab, 0x09, 143 | 0xc3, 0x3f, 0x1c, 144 | }; 145 | 146 | const unsigned char PROGMEM BOY_17[] ={ 147 | 0x3f, 0xbf, 0x7f, 0xd3, 0xc3, 0xb8, 0xf5, 0xd6, 0xd3, 0x1c, 0xff, 0x3c, 0xb9, 0xed, 0xf1, 0xeb, 148 | 0xb8, 0xe6, 0x36, 0x0e, 0x7b, 0x9e, 0xfa, 0x8f, 0x68, 0xe5, 0x4f, 0x50, 0xaf, 0xb9, 0xf5, 0xb4, 149 | 0x2e, 0x9a, 0x6d, 0xdd, 0xd6, 0x6d, 0xf9, 0x27, 0xb0, 0xfc, 0x0b, 0xb8, 0xfe, 0x69, 0x9d, 0xfc, 150 | 0x3b, 0xac, 0xfe, 0x2b, 0xca, 0x3e, 0xf9, 0x8e, 0xdb, 0x5c, 0x47, 0xae, 0xab, 0x5f, 0x1e, 0xfc, 151 | 0x3b, 0xfa, 0x4e, 0xc7, 0xaf, 0xf9, 0xe6, 0x3f, 0xa3, 0xc1, 0xf4, 0x38, 0x0e, 0xbf, 0x6d, 0x8c, 152 | 0xa3, 0x57, 0xe7, 0xf0, 0x0f, 0x07, 153 | }; 154 | 155 | const unsigned char PROGMEM BOY_18[] ={ 156 | 0x3f, 0xbf, 0x7f, 0xb8, 0xac, 0x5b, 0xae, 0x5e, 0x73, 0xda, 0xbd, 0xf2, 0xaf, 0x73, 0x8c, 0xdf, 157 | 0xcb, 0x35, 0xb7, 0x9e, 0xd6, 0x61, 0xcf, 0x53, 0xae, 0x5e, 0xbd, 0xf2, 0x77, 0xef, 0xfa, 0x7b, 158 | 0x7c, 0x85, 0xab, 0x57, 0xaf, 0x5e, 0xfd, 0xe7, 0xa0, 0x7f, 0x0b, 0x0e, 0xff, 0xb0, 0x4e, 0xfe, 159 | 0x1d, 0xa6, 0xff, 0x8c, 0xbc, 0x9c, 0x78, 0xe7, 0x69, 0xce, 0x93, 0xe7, 0x8e, 0xef, 0xff, 0xfb, 160 | 0x61, 0x7e, 0x67, 0xf4, 0xd7, 0x7c, 0xf8, 0x9f, 0x8e, 0xe3, 0xe8, 0x71, 0x8d, 0x9f, 0x97, 0x79, 161 | 0xf4, 0xea, 0xae, 0x7f, 0x38, 162 | }; 163 | 164 | const unsigned char PROGMEM BOY_19[] ={ 165 | 0x3f, 0xbf, 0x7f, 0xa2, 0x32, 0xc6, 0xad, 0xb7, 0xde, 0xd6, 0xfa, 0xc7, 0xfb, 0x43, 0xb9, 0x7a, 166 | 0xec, 0xad, 0xb7, 0x9e, 0xd6, 0x65, 0xaf, 0xcb, 0xba, 0x04, 0x2f, 0x86, 0x3f, 0xfa, 0xc8, 0x1f, 167 | 0x65, 0xe7, 0x5f, 0xd9, 0xda, 0x7f, 0x93, 0xcc, 0x7f, 0x5a, 0x3b, 0x7f, 0x87, 0xe9, 0x3f, 0x23, 168 | 0x6e, 0x07, 0x3f, 0x93, 0xcb, 0x61, 0x1c, 0x73, 0xf8, 0x01, 0xff, 0x7a, 0x32, 0xbe, 0x92, 0x79, 169 | 0xe4, 0xfb, 0x93, 0xef, 0xfe, 0xcb, 0xa9, 0xd3, 0x63, 0x2f, 0xbf, 0x8e, 0x7d, 0xf3, 0xea, 0x21, 170 | 0xfe, 0xe1, 0x00, 171 | }; 172 | 173 | const unsigned char PROGMEM BOY_20[] ={ 174 | 0x3f, 0xbf, 0x7f, 0x15, 0xc8, 0xe1, 0xb0, 0x2e, 0xeb, 0x32, 0xc7, 0x3f, 0xdf, 0xdf, 0xe1, 0xad, 175 | 0xb7, 0x9e, 0xd6, 0x65, 0x5d, 0xd6, 0x61, 0xef, 0xbd, 0x2f, 0xbd, 0xf5, 0x36, 0x2e, 0xc1, 0x83, 176 | 0x7f, 0xe9, 0xe5, 0x5f, 0x05, 0xdd, 0xf5, 0xea, 0xd5, 0x7f, 0x3e, 0x5e, 0xf6, 0xfe, 0x8b, 0xcc, 177 | 0xfc, 0xeb, 0x5a, 0xfd, 0x03, 0xb0, 0x26, 0xff, 0xaa, 0x66, 0xbe, 0xc3, 0x6d, 0xae, 0x63, 0x4e, 178 | 0x9f, 0xff, 0x67, 0xf4, 0xc1, 0x43, 0x3f, 0x3f, 0xf9, 0xee, 0xbf, 0x1c, 0x3b, 0x3d, 0xf6, 0x74, 179 | 0xf0, 0x07, 0xb9, 0x6f, 0x5e, 0x3d, 0xc4, 0x3f, 0x1c, 180 | }; 181 | 182 | const unsigned char PROGMEM BOY_21[] ={ 183 | 0x3f, 0xff, 0x7f, 0x1e, 0x8f, 0x3d, 0xfa, 0xcf, 0x97, 0xdb, 0xef, 0x98, 0x7b, 0xcf, 0xcb, 0x3a, 184 | 0xf5, 0xd6, 0x5b, 0xae, 0xbe, 0xf6, 0xea, 0xb1, 0xa7, 0xfc, 0xa5, 0xeb, 0x9f, 0x84, 0x1d, 0xba, 185 | 0xf7, 0x3e, 0x8c, 0x5b, 0x6f, 0xb9, 0x7a, 0xe5, 0xcf, 0x9f, 0xc3, 0xa9, 0x37, 0x7f, 0xf5, 0x38, 186 | 0x5c, 0xf2, 0xcf, 0xed, 0x4f, 0x61, 0x96, 0xf0, 0x6f, 0xec, 0xfb, 0x63, 0x9e, 0x66, 0x3f, 0x55, 187 | 0xfe, 0x79, 0x75, 0x7c, 0x26, 0x87, 0x1b, 0xdf, 0x69, 0xbe, 0xf5, 0x2f, 0x89, 0x34, 0x33, 0xb7, 188 | 0xde, 0x56, 0x7f, 0xcd, 0xce, 0xd5, 0xab, 0xfe, 0xf1, 0x00, 189 | }; 190 | 191 | const unsigned char PROGMEM BOY_22[] ={ 192 | 0x3f, 0xbf, 0xff, 0xdd, 0xc9, 0x3e, 0xf5, 0xd6, 0xdb, 0x38, 0x9c, 0xbc, 0x7a, 0xf5, 0xc7, 0xf7, 193 | 0x34, 0xfe, 0xf6, 0xdb, 0xdf, 0xcf, 0x64, 0xb9, 0x5c, 0x8e, 0x15, 0x73, 0x50, 0x2f, 0xe3, 0xd6, 194 | 0xa3, 0x7f, 0xfe, 0xae, 0x23, 0x7f, 0x84, 0x3d, 0xfe, 0xcd, 0xf5, 0xd6, 0xf5, 0xe3, 0x67, 0xe2, 195 | 0xbf, 0xb9, 0xdf, 0xcd, 0x34, 0xff, 0xf4, 0xbe, 0xe7, 0xe1, 0x94, 0xe3, 0x97, 0x18, 0xff, 0xb6, 196 | 0xd8, 0x75, 0xb1, 0x7a, 0xeb, 0xe1, 0xe4, 0xf7, 0x56, 0x8f, 0xde, 0xfe, 0xb4, 197 | }; 198 | 199 | const unsigned char PROGMEM BOY_23[] ={ 200 | 0x3f, 0xbf, 0xff, 0xdd, 0xc9, 0x3e, 0xf5, 0xd6, 0xdb, 0x38, 0x9c, 0xbc, 0x7a, 0xf5, 0xc7, 0xf7, 201 | 0x34, 0xfe, 0xf6, 0xdb, 0xdf, 0xcf, 0x64, 0xb9, 0x5c, 0x8e, 0x15, 0x73, 0x50, 0x2f, 0xe3, 0xd6, 202 | 0xa3, 0x7f, 0xfe, 0xae, 0x23, 0x7f, 0x84, 0x3d, 0xfe, 0xcd, 0xf5, 0xd6, 0x55, 0x7f, 0xf6, 0x6a, 203 | 0xfc, 0x37, 0xf7, 0xbb, 0x99, 0xe6, 0x9f, 0xde, 0xf7, 0x3c, 0x9c, 0x72, 0xfc, 0x12, 0xe3, 0xdf, 204 | 0x16, 0xbb, 0x2e, 0x56, 0x6f, 0x3d, 0x1d, 0xfc, 0xde, 0xea, 0xd1, 0xdb, 0x9f, 0x16, 205 | }; 206 | 207 | 208 | const unsigned char *BOY[] = { 209 | BOY_0, 210 | BOY_1, 211 | BOY_2, 212 | BOY_3, 213 | BOY_4, 214 | BOY_5, 215 | BOY_6, 216 | BOY_7, 217 | BOY_8, 218 | BOY_9, 219 | BOY_10, 220 | BOY_11, 221 | BOY_12, 222 | BOY_13, 223 | BOY_14, 224 | BOY_15, 225 | BOY_16, 226 | BOY_17, 227 | BOY_18, 228 | BOY_19, 229 | BOY_20, 230 | BOY_21, 231 | BOY_22, 232 | BOY_23, 233 | }; 234 | 235 | // File: d:\arduboy\boy.gif (24 frames) 236 | // Size: 24x64x64px (12288 bytes) 237 | // Encoded: 1978 bytes 238 | // Ratio: 0.16097005 239 | 240 | -------------------------------------------------------------------------------- /extras/compressor/compressor2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igvina/ArdBitmap/719035a3c424dd02655f9fa794e73b3a2ac79dbe/extras/compressor/compressor2.0.jar -------------------------------------------------------------------------------- /extras/images/boy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igvina/ArdBitmap/719035a3c424dd02655f9fa794e73b3a2ac79dbe/extras/images/boy.gif -------------------------------------------------------------------------------- /extras/images/dog.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igvina/ArdBitmap/719035a3c424dd02655f9fa794e73b3a2ac79dbe/extras/images/dog.gif -------------------------------------------------------------------------------- /extras/images/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/igvina/ArdBitmap/719035a3c424dd02655f9fa794e73b3a2ac79dbe/extras/images/test.png -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ###################################### 2 | # Syntax Coloring Map For ArdBitmap 3 | ###################################### 4 | 5 | ###################################### 6 | # Datatypes (KEYWORD1) 7 | ###################################### 8 | 9 | ArdBitmap KEYWORD1 10 | 11 | ###################################### 12 | # Methods and Functions (KEYWORD2) 13 | ###################################### 14 | 15 | drawBitmap KEYWORD2 16 | drawBitmapResized KEYWORD2 17 | drawCompressed KEYWORD2 18 | drawCompressedResized KEYWORD2 19 | 20 | ###################################### 21 | # Constants (LITERAL1) 22 | ###################################### 23 | 24 | ALIGN_H_LEFT LITERAL1 25 | ALIGN_H_RIGHT LITERAL1 26 | ALIGN_H_CENTER LITERAL1 27 | ALIGN_V_TOP LITERAL1 28 | ALIGN_V_BOTTOM LITERAL1 29 | ALIGN_V_CENTER LITERAL1 30 | ALIGN_CENTER LITERAL1 31 | ALIGN_NONE LITERAL1 32 | 33 | MIRROR_NONE LITERAL1 34 | MIRROR_HORIZONTAL LITERAL1 35 | MIRROR_VERTICAL LITERAL1 36 | MIRROR_HOR_VER LITERAL1 37 | 38 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ArdBitmap 2 | version=2.0.3 3 | author=Ignacio Vina 4 | maintainer=Ignacio Vina 5 | sentence=A library to compress and draw bitmaps on the Arduboy game system. 6 | paragraph=It supports real-time resizing and mirroring. This library is implemented as a class template. 7 | category=Other 8 | url=https://github.com/igvina/ArdBitmap 9 | architectures=* 10 | -------------------------------------------------------------------------------- /src/ArdBitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Ignacio Vina (@igvina) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // ArdBitmap: version 2.0.3 18 | 19 | #ifndef ARDBITMAP_H 20 | #define ARDBITMAP_H 21 | 22 | //Uncomment NO_SPEED_HACK if speed is not important (reduce ~100 bytes) 23 | //#define NO_SPEED_HACK 24 | 25 | //Uncomment RESIZE_HACK for fast drawResized with resize >= 1.0 26 | //#define RESIZE_HACK 27 | 28 | #include 29 | 30 | #define ALIGN_H_LEFT 0b00000000 31 | #define ALIGN_H_RIGHT 0b00000001 32 | #define ALIGN_H_CENTER 0b00000010 33 | #define ALIGN_V_TOP 0b00000000 34 | #define ALIGN_V_BOTTOM 0b00000100 35 | #define ALIGN_V_CENTER 0b00001000 36 | #define ALIGN_CENTER 0b00001010 37 | #define ALIGN_NONE 0b00000000 38 | 39 | #define MIRROR_NONE 0b00000000 40 | #define MIRROR_HORIZONTAL 0b00000001 41 | #define MIRROR_VERTICAL 0b00000010 42 | #define MIRROR_HOR_VER 0b00000011 43 | 44 | static const uint8_t BIT_SHIFT[8] = { 45 | 0b00000001, 46 | 0b00000010, 47 | 0b00000100, 48 | 0b00001000, 49 | 0b00010000, 50 | 0b00100000, 51 | 0b01000000, 52 | 0b10000000, 53 | }; 54 | 55 | /* 56 | static const uint8_t REVERSE_16[16] = { 0, 8, 4, 12, 57 | 2, 10, 6, 14 , 58 | 1, 9, 5, 13, 59 | 3, 11, 7, 15 }; 60 | 61 | static const uint8_t REVERSE_256[256] = { 62 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 63 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 64 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 65 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 66 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 67 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 68 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 69 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 70 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 71 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 72 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 73 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 74 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 75 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 76 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 77 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 78 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 79 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 80 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 81 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 82 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 83 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 84 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 85 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 86 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 87 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 88 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 89 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 90 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 91 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 92 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 93 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, 94 | }; 95 | */ 96 | 97 | template class ArdBitmap 98 | { 99 | public: 100 | 101 | void drawCompressed(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color, uint8_t align, uint8_t mirror); 102 | void drawCompressedResized(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color,uint8_t align, uint8_t mirror, float resize); 103 | 104 | void drawBitmap(int16_t sx, int16_t sy, const uint8_t *bitmap,uint8_t w, uint8_t h, uint8_t color, uint8_t align, uint8_t mirror); 105 | void drawBitmapResized(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t w,uint8_t h, uint8_t color,uint8_t align, uint8_t mirror, float resize); 106 | }; 107 | 108 | //////////////////////// 109 | // COMPRESSED BITMAPS // 110 | //////////////////////// 111 | 112 | template 113 | void ArdBitmap::drawCompressed(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color, uint8_t align, uint8_t mirror) 114 | { 115 | //TODO: check why int16_t sizeCounter is a bit faster than uint16_t sizeCounter 116 | int16_t sizeCounter; 117 | uint16_t len; 118 | int a, iCol; 119 | uint8_t decByte; 120 | uint8_t w, h; 121 | uint8_t col; 122 | boolean scanMode, scanZigZag; 123 | uint16_t encoderPos; 124 | uint8_t characterPos; 125 | 126 | 127 | // Read size from header (Max image size = 128 x 64) 128 | 129 | uint8_t byte0 = pgm_read_byte(&compBitmap[0]); 130 | uint8_t byte1 = pgm_read_byte(&compBitmap[1]); 131 | 132 | w = (byte0 & 0b01111111) + 1; 133 | h = (byte1 & 0b00111111) + 1; 134 | 135 | // Move positions to match alignment 136 | 137 | if (align & ALIGN_H_CENTER) { 138 | sx -= (w / 2); 139 | } else if (align & ALIGN_H_RIGHT) { 140 | sx -= w; 141 | } 142 | 143 | if (align & ALIGN_V_CENTER) { 144 | sy -= (h / 2); 145 | } else if (align & ALIGN_V_BOTTOM) { 146 | sy -= h; 147 | } 148 | 149 | // No need to draw at all if we're offscreen 150 | if (sx + w < 0 || sx > SB_WIDTH - 1 || sy + h < 0 || sy > SB_HEIGHT - 1) 151 | return; 152 | 153 | col = (byte0 >> 7) & 0x01; 154 | scanMode = ((byte1 >> 6) & 0x01) > 0; 155 | scanZigZag = ((byte1 >> 7) & 0x01) > 0; 156 | 157 | int yOffset = abs(sy) % 8; 158 | int sRow = sy / 8; 159 | if (sy < 0 && yOffset > 0) { 160 | sRow--; 161 | yOffset = 8 - yOffset; 162 | } 163 | 164 | uint8_t data; 165 | uint16_t bitmap_data; 166 | uint8_t mul_amt = 1 << yOffset; 167 | 168 | //uint16_t boffs; 169 | 170 | int8_t rows = h / 8; 171 | if (h % 8 != 0) rows++; 172 | 173 | // Init values 174 | iCol = 0; 175 | decByte = 0; 176 | encoderPos = 16; 177 | characterPos = 7; 178 | a = 0; 179 | 180 | if (mirror & MIRROR_VERTICAL) { 181 | a = rows - 1; 182 | scanMode = !scanMode; 183 | } 184 | 185 | int iColMod = (mirror & MIRROR_HORIZONTAL) ? w - 1 : 0; 186 | while (a < rows && a > -1) { 187 | 188 | sizeCounter = 1; 189 | while (((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01) == 1) { 190 | sizeCounter ++; 191 | encoderPos++; 192 | } 193 | encoderPos ++; 194 | 195 | if (sizeCounter == 1) { 196 | len = 1 + ((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01); 197 | encoderPos++; 198 | } else { 199 | len = (1 << (sizeCounter - 1)) + 1 ; 200 | 201 | //TODO: check why int j is faster than uint16_t j 202 | for (int j = 0; j < sizeCounter - 1; j++) { 203 | if (((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01) == 1) { 204 | len += (1 << j); 205 | } 206 | encoderPos++; 207 | } 208 | } 209 | 210 | for (uint16_t i = 0; i < len; i++) 211 | { 212 | 213 | #ifndef NO_SPEED_HACK 214 | if (col == 0) { 215 | if (len - i > characterPos) { 216 | i += characterPos; 217 | characterPos = 0; 218 | } else { 219 | characterPos -= (len - i - 1); 220 | i = len; 221 | } 222 | } else if (len - i > characterPos) { 223 | if (characterPos == 7) { 224 | decByte = 0xFF; 225 | } else { 226 | decByte |= scanMode ? 0xFF >> (7 - characterPos) : (0xFF80 >> characterPos); 227 | } 228 | i += characterPos; 229 | characterPos = 0; 230 | } else { 231 | decByte |= scanMode ? BIT_SHIFT[characterPos] : BIT_SHIFT[7 - characterPos]; 232 | } 233 | #else 234 | if (col) { 235 | decByte |= scanMode ? BIT_SHIFT[characterPos] : BIT_SHIFT[7 - characterPos]; 236 | } 237 | #endif 238 | 239 | characterPos--; 240 | 241 | if (characterPos == 0xFF){ 242 | 243 | //Paint decoded byte 244 | int8_t bRow = sRow + a; 245 | 246 | if (decByte && bRow < (SB_HEIGHT / 8) && iColMod + sx < SB_WIDTH && iColMod + sx >= 0){ 247 | 248 | bitmap_data = decByte * mul_amt; 249 | 250 | if (bRow >= 0) { 251 | 252 | data = ARDBITMAP_SBUF[(bRow * SB_WIDTH) + sx + iColMod]; 253 | if (color) { 254 | data |= bitmap_data & 0xFF; 255 | }else { 256 | data &= ~(bitmap_data & 0xFF); 257 | } 258 | ARDBITMAP_SBUF[(bRow * SB_WIDTH) + sx + iColMod] = data; 259 | } 260 | 261 | if (yOffset && bRow < (SB_HEIGHT / 8) - 1 && bRow > -2) { 262 | 263 | data = ARDBITMAP_SBUF[((bRow + 1) * SB_WIDTH) + sx + iColMod]; 264 | if (color) { 265 | data |= ((bitmap_data >> 8) & 0xFF); 266 | } else { 267 | data &= ~(((bitmap_data >> 8) & 0xFF)); 268 | } 269 | ARDBITMAP_SBUF[((bRow + 1)*SB_WIDTH) + sx + iColMod] = data; 270 | } 271 | } 272 | 273 | // Iterate next column-byte 274 | 275 | if (scanZigZag) { 276 | scanMode = !scanMode; 277 | } 278 | 279 | iCol++; 280 | 281 | if(mirror & MIRROR_HORIZONTAL){ 282 | iColMod--; 283 | }else{ 284 | iColMod++; 285 | } 286 | if (iCol >= w){ 287 | 288 | iCol = 0; 289 | if (mirror & MIRROR_VERTICAL) { 290 | a--; 291 | } else { 292 | a++; 293 | } 294 | 295 | iColMod = (mirror & MIRROR_HORIZONTAL) ? w - 1 : 0; 296 | } 297 | 298 | // Reset decoded byte 299 | decByte = 0; 300 | characterPos = 7; 301 | } 302 | } 303 | 304 | // Toggle color for next span 305 | col = 1 - col; 306 | } 307 | } 308 | 309 | 310 | 311 | template 312 | void ArdBitmap::drawCompressedResized(int16_t sx, int16_t sy, const uint8_t *compBitmap, uint8_t color,uint8_t align, uint8_t mirror, float resize) 313 | { 314 | 315 | //TODO: check if this can be done in a better way 316 | #ifdef RESIZE_HACK 317 | if (resize >= 1.0){ 318 | return drawCompressed(sx, sy, compBitmap, color, align, mirror); 319 | } 320 | #else 321 | if (resize > 1.0){ 322 | resize = 1.0; 323 | } 324 | #endif 325 | 326 | //TODO: check why int16_t sizeCounter is a bit faster than uint16_t sizeCounter 327 | int16_t sizeCounter; 328 | uint16_t len; 329 | uint8_t a, iCol; 330 | uint8_t decByte; 331 | uint8_t w, wRes, h, hRes; 332 | uint8_t col; 333 | boolean scanMode, scanZigZag; 334 | uint16_t encoderPos; 335 | uint8_t characterPos; 336 | 337 | // Read size from header (Max image size = 128 x 64) 338 | 339 | uint8_t byte0 = pgm_read_byte(&compBitmap[0]); 340 | uint8_t byte1 = pgm_read_byte(&compBitmap[1]); 341 | 342 | w = (byte0 & 0b01111111) + 1; 343 | h = (byte1 & 0b00111111) + 1; 344 | 345 | wRes = (uint8_t)(w * resize); 346 | hRes = (uint8_t)(h * resize); 347 | 348 | if (align & ALIGN_H_CENTER) { 349 | sx -= (wRes / 2); 350 | } else if (align & ALIGN_H_RIGHT) { 351 | sx -= wRes; 352 | } 353 | 354 | if (align & ALIGN_V_CENTER) { 355 | sy -= (hRes / 2); 356 | } else if (align & ALIGN_V_BOTTOM) { 357 | sy -= hRes; 358 | } 359 | 360 | // No need to draw at all if we're offscreen 361 | if (sx + wRes < 0 || sx > SB_WIDTH - 1 || sy + hRes < 0 || sy > SB_HEIGHT - 1) 362 | return; 363 | 364 | col = (byte0 >> 7) & 0x01; 365 | scanMode = ((byte1 >> 6) & 0x01) > 0; 366 | scanZigZag = ((byte1 >> 7) & 0x01) > 0; 367 | 368 | int yOffset = abs(sy) % 8; 369 | int sRow = sy / 8; 370 | if (sy < 0) { 371 | sRow--; 372 | yOffset = 8 - yOffset; 373 | } 374 | 375 | uint8_t data; 376 | uint16_t bitmap_data; 377 | uint8_t mul_amt = 1 << yOffset; 378 | 379 | int rows = h / 8; 380 | if (h % 8 != 0) rows++; 381 | 382 | uint8_t rowsRes = hRes / 8; 383 | if (hRes % 8 != 0) rowsRes++; 384 | 385 | // Init values 386 | iCol = 0; 387 | decByte = 0; 388 | encoderPos = 16; 389 | characterPos = 7; 390 | a = 0; 391 | 392 | // Create Lookup tables to speed up drawing 393 | 394 | uint8_t x_LUT[w]; 395 | 396 | for (uint8_t i=0 ; i < w; i++){ 397 | x_LUT[i] = 0xFF; 398 | } 399 | // Precalculate column translation (0xFF if skipped) 400 | for (uint8_t i=0 ; i < wRes; i++){ 401 | x_LUT[((uint16_t)i * w) / wRes] = (mirror & MIRROR_HORIZONTAL) ? wRes - 1 - i : i; 402 | } 403 | 404 | uint8_t y_LUT[h]; 405 | 406 | for (uint8_t i=0 ; i < h; i++){ 407 | y_LUT[i] = 0xFF; 408 | } 409 | 410 | for (uint8_t i=0 ; i < hRes; i++){ 411 | y_LUT[((uint16_t)i * h) / hRes] = (mirror & MIRROR_VERTICAL) ? hRes - 1 - i : i; 412 | } 413 | 414 | while (a < rows && /*a > -1*/ a != 0xFF) { 415 | 416 | sizeCounter = 1; 417 | while (((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01) == 1) { 418 | sizeCounter ++; 419 | encoderPos++; 420 | } 421 | encoderPos ++; 422 | 423 | if (sizeCounter == 1) { 424 | len = 1 + ((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01); 425 | encoderPos++; 426 | } else { 427 | len = (1 << (sizeCounter - 1)) + 1 ; 428 | 429 | //TODO: check why int j is faster than uint16_t j 430 | for (int j = 0; j < sizeCounter - 1; j++) { 431 | if (((pgm_read_byte(&compBitmap[encoderPos / 8]) >> (encoderPos % 8)) & 0x01) == 1) { 432 | len += (1 << j); 433 | } 434 | encoderPos++; 435 | } 436 | } 437 | 438 | for (uint16_t i = 0; i < len; i++) 439 | { 440 | 441 | #ifndef NO_SPEED_HACK 442 | if (col == 0) { 443 | if (len - i > characterPos) { 444 | i += characterPos; 445 | characterPos = 0; 446 | } else { 447 | characterPos -= (len - i - 1); 448 | i = len; 449 | } 450 | } else if (len - i > characterPos) { 451 | if (characterPos == 7) { 452 | decByte = 0xFF; 453 | } else { 454 | decByte |= scanMode ? 0xFF >> (7 - characterPos) : (0xFF80 >> characterPos); 455 | } 456 | i += characterPos; 457 | characterPos = 0; 458 | } else { 459 | decByte |= scanMode ? BIT_SHIFT[characterPos] : BIT_SHIFT[7 - characterPos]; 460 | } 461 | #else 462 | if (col) { 463 | decByte |= scanMode ? BIT_SHIFT[characterPos] : BIT_SHIFT[7 - characterPos]; 464 | } 465 | #endif 466 | 467 | characterPos--; 468 | 469 | if (characterPos == 0xFF){ 470 | 471 | //Paint decoded byte 472 | int aRow8 = a * 8; 473 | int16_t iColMod = x_LUT[iCol] + sx; 474 | 475 | // Skip if column not needed 476 | if (x_LUT[iCol] != 0xFF && iColMod < SB_WIDTH && iColMod >= 0){ 477 | 478 | for (uint8_t s = 0; s < 8 ;s++){ 479 | 480 | if (y_LUT[aRow8+s] != 0xFF && decByte & BIT_SHIFT[s]){ 481 | 482 | //TODO: CHECK LIMITS ON LUT? 483 | uint8_t row = (uint8_t)(y_LUT[aRow8+s]+sy) / 8; 484 | 485 | if (row < (SB_HEIGHT / 8)) { 486 | 487 | if (color) { 488 | ARDBITMAP_SBUF[(row*SB_WIDTH) + (uint8_t)iColMod] |= BIT_SHIFT[((uint8_t)(y_LUT[aRow8+s]+sy) % 8)]; 489 | } else { 490 | ARDBITMAP_SBUF[(row*SB_WIDTH) + (uint8_t)iColMod] &= ~ BIT_SHIFT[((uint8_t)(y_LUT[aRow8+s]+sy) % 8)]; 491 | } 492 | } 493 | 494 | } 495 | } 496 | } 497 | 498 | // Iterate next column-byte 499 | 500 | if (scanZigZag) { 501 | scanMode = !scanMode; 502 | } 503 | 504 | iCol++; 505 | if (iCol >= w){ 506 | 507 | iCol = 0; 508 | a++; 509 | } 510 | 511 | // Reset decoded byte 512 | decByte = 0; 513 | characterPos = 7; 514 | } 515 | } 516 | 517 | col = 1 - col; // toggle colour for next span 518 | } 519 | } 520 | 521 | 522 | 523 | ////////////////////////// 524 | // UNCOMPRESSED BITMAPS // 525 | ////////////////////////// 526 | 527 | 528 | template 529 | void ArdBitmap::drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color, uint8_t align, uint8_t mirror) 530 | { 531 | 532 | // Move positions to match alignment 533 | 534 | if (align & ALIGN_H_CENTER) { 535 | x -= (w / 2); 536 | } else if (align & ALIGN_H_RIGHT) { 537 | x -= w; 538 | } 539 | 540 | if (align & ALIGN_V_CENTER) { 541 | y -= (h / 2); 542 | } else if (align & ALIGN_V_BOTTOM) { 543 | y -= h; 544 | } 545 | 546 | // no need to draw at all of we're offscreen 547 | if (x + w <= 0 || x > SB_WIDTH - 1 || y + h <= 0 || y > SB_HEIGHT - 1) 548 | return; 549 | 550 | if (bitmap == NULL) 551 | return; 552 | 553 | // xOffset technically doesn't need to be 16 bit but the math operations 554 | // are measurably faster if it is 555 | uint16_t xOffset, ofs; 556 | int8_t yOffset = abs(y) % 8; 557 | int8_t sRow = y / 8; 558 | uint8_t loop_h, start_h, rendered_width; 559 | 560 | if (y < 0 && yOffset > 0) { 561 | sRow--; 562 | yOffset = 8 - yOffset; 563 | } 564 | 565 | // if the left side of the render is offscreen skip those loops 566 | if (x < 0) { 567 | xOffset = abs(x); 568 | } else { 569 | xOffset = 0; 570 | } 571 | 572 | // if the right side of the render is offscreen skip those loops 573 | if (x + w > SB_WIDTH - 1) { 574 | rendered_width = ((SB_WIDTH - x) - xOffset); 575 | } else { 576 | rendered_width = (w - xOffset); 577 | } 578 | 579 | // if the top side of the render is offscreen skip those loops 580 | if (sRow < -1) { 581 | start_h = abs(sRow) - 1; 582 | } else { 583 | start_h = 0; 584 | } 585 | 586 | loop_h = h / 8 + (h % 8 > 0 ? 1 : 0); // divide, then round up 587 | 588 | // if (sRow + loop_h - 1 > (SB_HEIGHT/8)-1) 589 | if (sRow + loop_h > (SB_HEIGHT / 8)) { 590 | loop_h = (SB_HEIGHT / 8) - sRow; 591 | } 592 | 593 | // prepare variables for loops later so we can compare with 0 594 | // instead of comparing two variables 595 | loop_h -= start_h; 596 | 597 | sRow += start_h; 598 | ofs = (sRow * SB_WIDTH) + x + xOffset; 599 | 600 | uint8_t *bofs = (uint8_t *)bitmap + (start_h * w) + xOffset; 601 | 602 | if (mirror & MIRROR_HORIZONTAL) { 603 | bofs += rendered_width - 1; 604 | if (x < 0){ 605 | bofs -= w - rendered_width; 606 | } else{ 607 | bofs += w - rendered_width; 608 | } 609 | } 610 | 611 | if (mirror & MIRROR_VERTICAL) { 612 | bofs += (loop_h - 1) * w; 613 | if (y < 0){ 614 | bofs -= (start_h * w); 615 | } else { 616 | bofs += (sRow * w); 617 | } 618 | } 619 | 620 | uint8_t data; 621 | uint8_t mul_amt = 1 << yOffset; 622 | uint16_t bitmap_data; 623 | 624 | // really if yOffset = 0 you have a faster case here that could be 625 | // optimized 626 | for (uint8_t a = 0; a < loop_h; a++) { 627 | for (uint8_t iCol = 0; iCol < rendered_width; iCol++) { 628 | data = pgm_read_byte(bofs); 629 | if(data) { 630 | if (mirror & MIRROR_VERTICAL){ 631 | //reverse bits 632 | data = (data & 0xF0) >> 4 | (data & 0x0F) << 4; 633 | data = (data & 0xCC) >> 2 | (data & 0x33) << 2; 634 | data = (data & 0xAA) >> 1 | (data & 0x55) << 1; 635 | 636 | //LUT - No speed improvement and more mem 637 | //data = (((REVERSE_16[(data & 0x0F)]) << 4) + REVERSE_16[((data & 0xF0) >> 4)]); 638 | 639 | //Fast but too much mem 640 | //data = REVERSE_256[data]; 641 | } 642 | 643 | bitmap_data = data * mul_amt; 644 | if (sRow >= 0) { 645 | data = ARDBITMAP_SBUF[ofs]; 646 | if (color){ 647 | data |= bitmap_data & 0xFF; 648 | } else { 649 | data &= ~(bitmap_data & 0xFF); 650 | } 651 | ARDBITMAP_SBUF[ofs] = data; 652 | } 653 | 654 | if (yOffset != 0 && sRow < 7) { 655 | data = ARDBITMAP_SBUF[ofs + SB_WIDTH]; 656 | if (color){ 657 | data |= (bitmap_data >> 8) & 0xFF; 658 | } else{ 659 | data &= ~((bitmap_data >> 8) & 0xFF); 660 | } 661 | ARDBITMAP_SBUF[ofs + SB_WIDTH] = data; 662 | } 663 | } 664 | ofs++; 665 | 666 | if (mirror & MIRROR_HORIZONTAL){ 667 | bofs--; 668 | } else{ 669 | bofs++; 670 | } 671 | } 672 | sRow++; 673 | 674 | if (mirror & MIRROR_HORIZONTAL){ 675 | bofs += w + rendered_width; 676 | } else{ 677 | bofs += w - rendered_width; 678 | } 679 | 680 | if (mirror & MIRROR_VERTICAL){ 681 | bofs -= 2 * w; 682 | } 683 | ofs += SB_WIDTH - rendered_width; 684 | } 685 | } 686 | 687 | 688 | template 689 | void ArdBitmap::drawBitmapResized(int16_t sx, int16_t sy, const uint8_t *bitmap, uint8_t w,uint8_t h, uint8_t color,uint8_t align, uint8_t mirror, float resize) 690 | { 691 | 692 | //TODO: check if this can be done in a better way 693 | #ifdef RESIZE_HACK 694 | if (resize >= 1.0){ 695 | return drawBitmap(sx, sy, bitmap,w, h, color, align, mirror); 696 | } 697 | #else 698 | if (resize > 1.0){ 699 | resize = 1.0; 700 | } 701 | #endif 702 | 703 | //TODO: check why int16_t sizeCounter is a bit faster than uint16_t sizeCounter 704 | int16_t sizeCounter; 705 | uint16_t len; 706 | uint8_t a, iCol; 707 | uint8_t data; 708 | uint8_t wRes, hRes; 709 | uint8_t col; 710 | 711 | wRes = (uint8_t)(w * resize); 712 | hRes = (uint8_t)(h * resize); 713 | 714 | 715 | // Move positions to match alignment 716 | if (align & ALIGN_H_CENTER) { 717 | sx -= (wRes / 2); 718 | } else if (align & ALIGN_H_RIGHT) { 719 | sx -= wRes; 720 | } 721 | 722 | if (align & ALIGN_V_CENTER) { 723 | sy -= (hRes / 2); 724 | } else if (align & ALIGN_V_BOTTOM) { 725 | sy -= hRes; 726 | } 727 | 728 | // No need to draw at all if we're offscreen 729 | if (sx + wRes < 0 || sx > SB_WIDTH - 1 || sy + hRes < 0 || sy > SB_HEIGHT - 1) 730 | return; 731 | 732 | int yOffset = abs(sy) % 8; 733 | int sRow = sy / 8; 734 | if (sy < 0) { 735 | sRow--; 736 | yOffset = 8 - yOffset; 737 | } 738 | 739 | int rows = h / 8; 740 | if (h % 8 != 0) rows++; 741 | 742 | uint8_t rowsRes = hRes / 8; 743 | if (hRes % 8 != 0) rowsRes++; 744 | 745 | // Init values 746 | iCol = 0; 747 | a = 0; 748 | 749 | // Create Lookup tables to speed up drawing 750 | 751 | uint8_t x_LUT[w]; 752 | 753 | for (uint8_t i=0 ; i < w; i++){ 754 | x_LUT[i] = 0xFF; 755 | } 756 | // Precalculate column translation (0xFF if skipped) 757 | for (uint8_t i=0 ; i < wRes; i++){ 758 | x_LUT[((uint16_t)i * w) / wRes] = (mirror & MIRROR_HORIZONTAL) ? wRes - 1 - i : i; 759 | } 760 | 761 | uint8_t y_LUT[h]; 762 | 763 | for (uint8_t i=0 ; i < h; i++){ 764 | y_LUT[i] = 0xFF; 765 | } 766 | 767 | for (uint8_t i=0 ; i < hRes; i++){ 768 | y_LUT[((uint16_t)i * h) / hRes] = (mirror & MIRROR_VERTICAL) ? hRes - 1 - i : i; 769 | } 770 | 771 | len = w * rows; 772 | 773 | for (uint16_t i = 0; i < len ; i++){ 774 | 775 | data = pgm_read_byte(&bitmap[i]); 776 | int aRow8 = a * 8; 777 | int16_t iColMod = x_LUT[iCol] + sx; 778 | 779 | // Skip if column not needed 780 | if (x_LUT[iCol] != 0xFF && iColMod < SB_WIDTH && iColMod >= 0){ 781 | for (uint8_t s = 0; s < 8 ;s++){ 782 | if (y_LUT[aRow8+s] != 0xFF && data & BIT_SHIFT[s]){ 783 | //TODO: CHECK LIMITS ON LUT? 784 | uint8_t row = (uint8_t)(y_LUT[aRow8+s]+sy) / 8; 785 | 786 | if (row < (SB_HEIGHT / 8)) { 787 | if (color) { 788 | ARDBITMAP_SBUF[(row*SB_WIDTH) + (uint8_t)iColMod] |= BIT_SHIFT[((uint8_t)(y_LUT[aRow8+s]+sy) % 8)]; 789 | } else { 790 | ARDBITMAP_SBUF[(row*SB_WIDTH) + (uint8_t)iColMod] &= ~ BIT_SHIFT[((uint8_t)(y_LUT[aRow8+s]+sy) % 8)]; 791 | } 792 | } 793 | } 794 | } 795 | } 796 | 797 | iCol++; 798 | if (iCol >= w){ 799 | iCol = 0; 800 | a++; 801 | } 802 | } 803 | } 804 | 805 | #endif 806 | 807 | --------------------------------------------------------------------------------