diff --git a/Inc/dht22.h b/Inc/dht22.h new file mode 100644 index 0000000..0725330 --- /dev/null +++ b/Inc/dht22.h @@ -0,0 +1,42 @@ +/* +DHT 22 humidity and temperature sensor library + + Copyright (C) 2013 Fabio Angeletti - fabio.angeletti89@gmail.com + + See attached license.txt file + +*/ + +/* Define to prevent recursive inclusion -----------------------------------*/ +#ifndef __DHT22_H +#define __DHT22_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Includes ----------------------------------------------------------------*/ +#include "stm32f4xx_hal.h" + +/* defines -----------------------------------------------------------------*/ +#define DHT22_DATA_PIN GPIO_PIN_3 +#define DHT22_GPIO GPIOE +#define DHT22_TIM TIM6 + +/* variables ---------------------------------------------------------------*/ +uint8_t DHT22data[6]; + +/* functions prototypes ----------------------------------------------------*/ +void DHT22pinIn(void); +void DHT22pinOut(void); +void DHT22_Init(void); +void DHT22_Read(TIM_HandleTypeDef timer); +float DHT22getTemperature(void); +float DHT22getHumidity(void); +float convertCtoF(float cTemperature); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Inc/fastlz.h b/Inc/fastlz.h new file mode 100644 index 0000000..f87bc7b --- /dev/null +++ b/Inc/fastlz.h @@ -0,0 +1,100 @@ +/* + FastLZ - lightning-fast lossless compression library + + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2005 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef FASTLZ_H +#define FASTLZ_H + +#define FASTLZ_VERSION 0x000100 + +#define FASTLZ_VERSION_MAJOR 0 +#define FASTLZ_VERSION_MINOR 0 +#define FASTLZ_VERSION_REVISION 0 + +#define FASTLZ_VERSION_STRING "0.1.0" + +#if defined (__cplusplus) +extern "C" { +#endif + +/** + Compress a block of data in the input buffer and returns the size of + compressed block. The size of input buffer is specified by length. The + minimum input buffer size is 16. + + The output buffer must be at least 5% larger than the input buffer + and can not be smaller than 66 bytes. + + If the input is not compressible, the return value might be larger than + length (input buffer size). + + The input buffer and the output buffer can not overlap. +*/ + +int fastlz_compress(const void* input, int length, void* output); + +/** + Decompress a block of compressed data and returns the size of the + decompressed block. If error occurs, e.g. the compressed data is + corrupted or the output buffer is not large enough, then 0 (zero) + will be returned instead. + + The input buffer and the output buffer can not overlap. + + Decompression is memory safe and guaranteed not to write the output buffer + more than what is specified in maxout. + */ + +int fastlz_decompress(const void* input, int length, void* output, int maxout); + +/** + Compress a block of data in the input buffer and returns the size of + compressed block. The size of input buffer is specified by length. The + minimum input buffer size is 16. + + The output buffer must be at least 5% larger than the input buffer + and can not be smaller than 66 bytes. + + If the input is not compressible, the return value might be larger than + length (input buffer size). + + The input buffer and the output buffer can not overlap. + + Compression level can be specified in parameter level. At the moment, + only level 1 and level 2 are supported. + Level 1 is the fastest compression and generally useful for short data. + Level 2 is slightly slower but it gives better compression ratio. + + Note that the compressed data, regardless of the level, can always be + decompressed using the function fastlz_decompress above. +*/ + +int fastlz_compress_level(int level, const void* input, int length, void* output); + +#if defined (__cplusplus) +} +#endif + +#endif /* FASTLZ_H */ diff --git a/Inc/image.h b/Inc/image.h index c759e61..1b9ce67 100644 --- a/Inc/image.h +++ b/Inc/image.h @@ -1,3 +1,3 @@ #include "stm32f4xx_hal.h" -extern uint8_t image[1024]; \ No newline at end of file +extern uint8_t image[]; \ No newline at end of file diff --git a/Inc/sprites.h b/Inc/sprites.h new file mode 100644 index 0000000..0d2bd4c --- /dev/null +++ b/Inc/sprites.h @@ -0,0 +1,13 @@ +#include "stm32f4xx_hal.h" + +typedef struct { + const uint8_t width; + const uint8_t height; + const uint8_t *buffer; +} SpriteDef; + +extern SpriteDef sprite_0; +extern SpriteDef sprite_1; +extern SpriteDef sprite_2; +extern SpriteDef sprite_3; +extern SpriteDef sprite_4; diff --git a/Inc/ssd1306.h b/Inc/ssd1306.h index e0d3717..6921f90 100644 --- a/Inc/ssd1306.h +++ b/Inc/ssd1306.h @@ -3,6 +3,9 @@ #include "stm32f4xx_hal.h" #include "fonts.h" #include "image.h" +#include "sprites.h" +#include "fastlz.h" + #ifndef ssd1306 #define ssd1306 @@ -93,5 +96,6 @@ void ssd1306_ScrollUp(unsigned int pixels, unsigned int delay, UART_HandleTypeDe void startscrollright(uint8_t start, uint8_t stop); void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1); void ssd1306_LoadImage(void); +void ssd1306_Anim(void); #endif diff --git a/Inc/starfield.h b/Inc/starfield.h index 6a1afbf..17c3465 100644 --- a/Inc/starfield.h +++ b/Inc/starfield.h @@ -1,6 +1,6 @@ #include //#include "stm32f4xx_hal.h" -#include "ssd1306.h" +//#include "ssd1306.h" struct Star { diff --git a/Makefile b/Makefile index d3ddc67..c6590da 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,9 @@ BUILD_DIR = build ###################################### C_SOURCES = \ Src/main.c \ + Src/fastlz.c \ + Src/sprites.c \ Src/image.c \ - Src/cube.c \ - Src/starfield.c \ Src/ssd1306.c \ Src/fonts.c \ Src/system_stm32f4xx.c \ @@ -58,12 +58,11 @@ ASM_SOURCES = \ # binaries ####################################### -TOOLCHAIN=/mnt/wd/toolchain/gcc-arm-none-eabi-6-2017-q1-update/install-native/bin -CC = ${TOOLCHAIN}/arm-none-eabi-gcc -AS = ${TOOLCHAIN}/arm-none-eabi-gcc -x assembler-with-cpp -CP = ${TOOLCHAIN}/arm-none-eabi-objcopy -AR = ${TOOLCHAIN}/arm-none-eabi-ar -SZ = ${TOOLCHAIN}/arm-none-eabi-size +CC = arm-none-eabi-gcc +AS = arm-none-eabi-gcc -x assembler-with-cpp +CP = arm-none-eabi-objcopy +AR = arm-none-eabi-ar +SZ = arm-none-eabi-size HEX = $(CP) -O ihex BIN = $(CP) -O binary -S diff --git a/Src/dht22.c b/Src/dht22.c new file mode 100644 index 0000000..dcbf7e8 --- /dev/null +++ b/Src/dht22.c @@ -0,0 +1,128 @@ +/* +DHT 22 humidity and temperature sensor library + + Copyright (C) 2013 Fabio Angeletti - fabio.angeletti89@gmail.com + + See attached license.txt file + +*/ + +/* includes --------------------------------------------------------- */ +#include "dht22.h" + +/* functions -------------------------------------------------------- */ +/* + configure DHT22_DATA as input + */ +void DHT22pinIn(void){ + GPIO_InitTypeDef GPIO_InitStructure; + + GPIO_InitStructure.Pin = DHT22_DATA_PIN; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + GPIO_InitStructure.Pull = GPIO_PULLUP; + HAL_GPIO_Init(DHT22_GPIO, &GPIO_InitStructure); +} + + +/* + configure DHT22_DATA as output + */ +void DHT22pinOut(void){ + GPIO_InitTypeDef GPIO_InitStructure; + + GPIO_InitStructure.Pin = DHT22_DATA_PIN; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStructure.Pull = GPIO_PULLUP; + HAL_GPIO_Init(DHT22_GPIO, &GPIO_InitStructure); +} + + +void DHT22_Init(void){ + //__HAL_RCC_GPIOE_CLK_ENABLE(); + DHT22pinOut(); + + /* hold DHT22 in standby state */ + HAL_GPIO_WritePin(DHT22_GPIO, DHT22_DATA_PIN, GPIO_PIN_SET); +} + + +void DHT22_Read(TIM_HandleTypeDef timer){ + uint8_t dataIndex = 0; + uint8_t counter = 7; + uint8_t currByte = 0; + uint8_t index = 0; + uint32_t startTime = 0; + + /* reset data holder */ + for(index=0; index < 6; index++){ + DHT22data[index] = 0x00; + } + + /* mcu sends start signal to sensor */ + DHT22pinOut(); + HAL_GPIO_WritePin(DHT22_GPIO, DHT22_DATA_PIN, GPIO_PIN_RESET); + __HAL_TIM_SET_COUNTER(&timer, 0); + + /* wait for at least 20 mSecs */ + while(__HAL_TIM_GET_COUNTER(&timer) < 20000); + + /* switch to input and wait for sensor response */ + DHT22pinIn(); + while(HAL_GPIO_ReadPin(DHT22_GPIO, DHT22_DATA_PIN)); + + /* DHT22 sends response signal */ + while(!HAL_GPIO_ReadPin(DHT22_GPIO, DHT22_DATA_PIN)); + while(HAL_GPIO_ReadPin(DHT22_GPIO, DHT22_DATA_PIN)); + + /* DHT22 sends, finally, data */ + for (dataIndex=0; dataIndex<40; dataIndex++) { + __HAL_TIM_SET_COUNTER(&timer, 0); + while(!HAL_GPIO_ReadPin(DHT22_GPIO, DHT22_DATA_PIN)); + startTime = __HAL_TIM_GET_COUNTER(&timer); + while(HAL_GPIO_ReadPin(DHT22_GPIO, DHT22_DATA_PIN)); + + if ((__HAL_TIM_GET_COUNTER(&timer) - startTime) > 40){ + DHT22data[currByte] |= (1 << counter); + } + + if (counter == 0) { // next byte? + counter = 7; // restart at MSB + currByte++; // next byte! + } else { + counter--; + } + + } +} + + +float DHT22getTemperature(void){ + float retVal; + + retVal = DHT22data[2] & 0x7F; + retVal *= 256; + retVal += DHT22data[3]; + retVal /= 10; + + if (DHT22data[2] & 0x80) + retVal *= -1; + + return retVal; +} + + +float DHT22getHumidity(void){ + float retVal; + + retVal = DHT22data[0]; + retVal *= 256; + retVal += DHT22data[1]; + retVal /= 10; + + return retVal; +} + + +float convertCtoF(float cTemperature){ + return cTemperature * 9 / 5 + 32; +} diff --git a/Src/fastlz.c b/Src/fastlz.c new file mode 100644 index 0000000..3c9d6f6 --- /dev/null +++ b/Src/fastlz.c @@ -0,0 +1,551 @@ +/* + FastLZ - lightning-fast lossless compression library + + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2005 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#if !defined(FASTLZ__COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR) + +/* + * Always check for bound when decompressing. + * Generally it is best to leave it defined. + */ +#define FASTLZ_SAFE + +/* + * Give hints to the compiler for branch prediction optimization. + */ +#if defined(__GNUC__) && (__GNUC__ > 2) +#define FASTLZ_EXPECT_CONDITIONAL(c) (__builtin_expect((c), 1)) +#define FASTLZ_UNEXPECT_CONDITIONAL(c) (__builtin_expect((c), 0)) +#else +#define FASTLZ_EXPECT_CONDITIONAL(c) (c) +#define FASTLZ_UNEXPECT_CONDITIONAL(c) (c) +#endif + +/* + * Use inlined functions for supported systems. + */ +#if defined(__GNUC__) || defined(__DMC__) || defined(__POCC__) || defined(__WATCOMC__) || defined(__SUNPRO_C) +#define FASTLZ_INLINE inline +#elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__LCC__) +#define FASTLZ_INLINE __inline +#else +#define FASTLZ_INLINE +#endif + +/* + * Prevent accessing more than 8-bit at once, except on x86 architectures. + */ +#if !defined(FASTLZ_STRICT_ALIGN) +#define FASTLZ_STRICT_ALIGN +#if defined(__i386__) || defined(__386) /* GNU C, Sun Studio */ +#undef FASTLZ_STRICT_ALIGN +#elif defined(__i486__) || defined(__i586__) || defined(__i686__) /* GNU C */ +#undef FASTLZ_STRICT_ALIGN +#elif defined(_M_IX86) /* Intel, MSVC */ +#undef FASTLZ_STRICT_ALIGN +#elif defined(__386) +#undef FASTLZ_STRICT_ALIGN +#elif defined(_X86_) /* MinGW */ +#undef FASTLZ_STRICT_ALIGN +#elif defined(__I86__) /* Digital Mars */ +#undef FASTLZ_STRICT_ALIGN +#endif +#endif + +/* + * FIXME: use preprocessor magic to set this on different platforms! + */ +typedef unsigned char flzuint8; +typedef unsigned short flzuint16; +typedef unsigned int flzuint32; + +/* prototypes */ +int fastlz_compress(const void* input, int length, void* output); +int fastlz_compress_level(int level, const void* input, int length, void* output); +int fastlz_decompress(const void* input, int length, void* output, int maxout); + +#define MAX_COPY 32 +#define MAX_LEN 264 /* 256 + 8 */ +#define MAX_DISTANCE 8192 + +#if !defined(FASTLZ_STRICT_ALIGN) +#define FASTLZ_READU16(p) *((const flzuint16*)(p)) +#else +#define FASTLZ_READU16(p) ((p)[0] | (p)[1]<<8) +#endif + +#define HASH_LOG 13 +#define HASH_SIZE (1<< HASH_LOG) +#define HASH_MASK (HASH_SIZE-1) +#define HASH_FUNCTION(v,p) { v = FASTLZ_READU16(p); v ^= FASTLZ_READU16(p+1)^(v>>(16-HASH_LOG));v &= HASH_MASK; } + +#undef FASTLZ_LEVEL +#define FASTLZ_LEVEL 1 + +#undef FASTLZ_COMPRESSOR +#undef FASTLZ_DECOMPRESSOR +#define FASTLZ_COMPRESSOR fastlz1_compress +#define FASTLZ_DECOMPRESSOR fastlz1_decompress +static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output); +static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout); +#include "fastlz.c" + +#undef FASTLZ_LEVEL +#define FASTLZ_LEVEL 2 + +#undef MAX_DISTANCE +#define MAX_DISTANCE 8191 +#define MAX_FARDISTANCE (65535+MAX_DISTANCE-1) + +#undef FASTLZ_COMPRESSOR +#undef FASTLZ_DECOMPRESSOR +#define FASTLZ_COMPRESSOR fastlz2_compress +#define FASTLZ_DECOMPRESSOR fastlz2_decompress +static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output); +static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout); +#include "fastlz.c" + +int fastlz_compress(const void* input, int length, void* output) +{ + /* for short block, choose fastlz1 */ + if(length < 65536) + return fastlz1_compress(input, length, output); + + /* else... */ + return fastlz2_compress(input, length, output); +} + +int fastlz_decompress(const void* input, int length, void* output, int maxout) +{ + /* magic identifier for compression level */ + int level = ((*(const flzuint8*)input) >> 5) + 1; + + if(level == 1) + return fastlz1_decompress(input, length, output, maxout); + if(level == 2) + return fastlz2_decompress(input, length, output, maxout); + + /* unknown level, trigger error */ + return 0; +} + +int fastlz_compress_level(int level, const void* input, int length, void* output) +{ + if(level == 1) + return fastlz1_compress(input, length, output); + if(level == 2) + return fastlz2_compress(input, length, output); + + return 0; +} + +#else /* !defined(FASTLZ_COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR) */ + +static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void* output) +{ + const flzuint8* ip = (const flzuint8*) input; + const flzuint8* ip_bound = ip + length - 2; + const flzuint8* ip_limit = ip + length - 12; + flzuint8* op = (flzuint8*) output; + + const flzuint8* htab[HASH_SIZE]; + const flzuint8** hslot; + flzuint32 hval; + + flzuint32 copy; + + /* sanity check */ + if(FASTLZ_UNEXPECT_CONDITIONAL(length < 4)) + { + if(length) + { + /* create literal copy only */ + *op++ = length-1; + ip_bound++; + while(ip <= ip_bound) + *op++ = *ip++; + return length+1; + } + else + return 0; + } + + /* initializes hash table */ + for (hslot = htab; hslot < htab + HASH_SIZE; hslot++) + *hslot = ip; + + /* we start with literal copy */ + copy = 2; + *op++ = MAX_COPY-1; + *op++ = *ip++; + *op++ = *ip++; + + /* main loop */ + while(FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit)) + { + const flzuint8* ref; + flzuint32 distance; + + /* minimum match length */ + flzuint32 len = 3; + + /* comparison starting-point */ + const flzuint8* anchor = ip; + + /* check for a run */ +#if FASTLZ_LEVEL==2 + if(ip[0] == ip[-1] && FASTLZ_READU16(ip-1)==FASTLZ_READU16(ip+1)) + { + distance = 1; + ip += 3; + ref = anchor - 1 + 3; + goto match; + } +#endif + + /* find potential match */ + HASH_FUNCTION(hval,ip); + hslot = htab + hval; + ref = htab[hval]; + + /* calculate distance to the match */ + distance = anchor - ref; + + /* update hash table */ + *hslot = anchor; + + /* is this a match? check the first 3 bytes */ + if(distance==0 || +#if FASTLZ_LEVEL==1 + (distance >= MAX_DISTANCE) || +#else + (distance >= MAX_FARDISTANCE) || +#endif + *ref++ != *ip++ || *ref++!=*ip++ || *ref++!=*ip++) + goto literal; + +#if FASTLZ_LEVEL==2 + /* far, needs at least 5-byte match */ + if(distance >= MAX_DISTANCE) + { + if(*ip++ != *ref++ || *ip++!= *ref++) + goto literal; + len += 2; + } + + match: +#endif + + /* last matched byte */ + ip = anchor + len; + + /* distance is biased */ + distance--; + + if(!distance) + { + /* zero distance means a run */ + flzuint8 x = ip[-1]; + while(ip < ip_bound) + if(*ref++ != x) break; else ip++; + } + else + for(;;) + { + /* safe because the outer check against ip limit */ + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + if(*ref++ != *ip++) break; + while(ip < ip_bound) + if(*ref++ != *ip++) break; + break; + } + + /* if we have copied something, adjust the copy count */ + if(copy) + /* copy is biased, '0' means 1 byte copy */ + *(op-copy-1) = copy-1; + else + /* back, to overwrite the copy count */ + op--; + + /* reset literal counter */ + copy = 0; + + /* length is biased, '1' means a match of 3 bytes */ + ip -= 3; + len = ip - anchor; + + /* encode the match */ +#if FASTLZ_LEVEL==2 + if(distance < MAX_DISTANCE) + { + if(len < 7) + { + *op++ = (len << 5) + (distance >> 8); + *op++ = (distance & 255); + } + else + { + *op++ = (7 << 5) + (distance >> 8); + for(len-=7; len >= 255; len-= 255) + *op++ = 255; + *op++ = len; + *op++ = (distance & 255); + } + } + else + { + /* far away, but not yet in the another galaxy... */ + if(len < 7) + { + distance -= MAX_DISTANCE; + *op++ = (len << 5) + 31; + *op++ = 255; + *op++ = distance >> 8; + *op++ = distance & 255; + } + else + { + distance -= MAX_DISTANCE; + *op++ = (7 << 5) + 31; + for(len-=7; len >= 255; len-= 255) + *op++ = 255; + *op++ = len; + *op++ = 255; + *op++ = distance >> 8; + *op++ = distance & 255; + } + } +#else + + if(FASTLZ_UNEXPECT_CONDITIONAL(len > MAX_LEN-2)) + while(len > MAX_LEN-2) + { + *op++ = (7 << 5) + (distance >> 8); + *op++ = MAX_LEN - 2 - 7 -2; + *op++ = (distance & 255); + len -= MAX_LEN-2; + } + + if(len < 7) + { + *op++ = (len << 5) + (distance >> 8); + *op++ = (distance & 255); + } + else + { + *op++ = (7 << 5) + (distance >> 8); + *op++ = len - 7; + *op++ = (distance & 255); + } +#endif + + /* update the hash at match boundary */ + HASH_FUNCTION(hval,ip); + htab[hval] = ip++; + HASH_FUNCTION(hval,ip); + htab[hval] = ip++; + + /* assuming literal copy */ + *op++ = MAX_COPY-1; + + continue; + + literal: + *op++ = *anchor++; + ip = anchor; + copy++; + if(FASTLZ_UNEXPECT_CONDITIONAL(copy == MAX_COPY)) + { + copy = 0; + *op++ = MAX_COPY-1; + } + } + + /* left-over as literal copy */ + ip_bound++; + while(ip <= ip_bound) + { + *op++ = *ip++; + copy++; + if(copy == MAX_COPY) + { + copy = 0; + *op++ = MAX_COPY-1; + } + } + + /* if we have copied something, adjust the copy length */ + if(copy) + *(op-copy-1) = copy-1; + else + op--; + +#if FASTLZ_LEVEL==2 + /* marker for fastlz2 */ + *(flzuint8*)output |= (1 << 5); +#endif + + return op - (flzuint8*)output; +} + +static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void* output, int maxout) +{ + const flzuint8* ip = (const flzuint8*) input; + const flzuint8* ip_limit = ip + length; + flzuint8* op = (flzuint8*) output; + flzuint8* op_limit = op + maxout; + flzuint32 ctrl = (*ip++) & 31; + int loop = 1; + + do + { + const flzuint8* ref = op; + flzuint32 len = ctrl >> 5; + flzuint32 ofs = (ctrl & 31) << 8; + + if(ctrl >= 32) + { +#if FASTLZ_LEVEL==2 + flzuint8 code; +#endif + len--; + ref -= ofs; + if (len == 7-1) +#if FASTLZ_LEVEL==1 + len += *ip++; + ref -= *ip++; +#else + do + { + code = *ip++; + len += code; + } while (code==255); + code = *ip++; + ref -= code; + + /* match from 16-bit distance */ + if(FASTLZ_UNEXPECT_CONDITIONAL(code==255)) + if(FASTLZ_EXPECT_CONDITIONAL(ofs==(31 << 8))) + { + ofs = (*ip++) << 8; + ofs += *ip++; + ref = op - ofs - MAX_DISTANCE; + } +#endif + +#ifdef FASTLZ_SAFE + if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit)) + return 0; + + if (FASTLZ_UNEXPECT_CONDITIONAL(ref-1 < (flzuint8 *)output)) + return 0; +#endif + + if(FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit)) + ctrl = *ip++; + else + loop = 0; + + if(ref == op) + { + /* optimize copy for a run */ + flzuint8 b = ref[-1]; + *op++ = b; + *op++ = b; + *op++ = b; + for(; len; --len) + *op++ = b; + } + else + { +#if !defined(FASTLZ_STRICT_ALIGN) + const flzuint16* p; + flzuint16* q; +#endif + /* copy from reference */ + ref--; + *op++ = *ref++; + *op++ = *ref++; + *op++ = *ref++; + +#if !defined(FASTLZ_STRICT_ALIGN) + /* copy a byte, so that now it's word aligned */ + if(len & 1) + { + *op++ = *ref++; + len--; + } + + /* copy 16-bit at once */ + q = (flzuint16*) op; + op += len; + p = (const flzuint16*) ref; + for(len>>=1; len > 4; len-=4) + { + *q++ = *p++; + *q++ = *p++; + *q++ = *p++; + *q++ = *p++; + } + for(; len; --len) + *q++ = *p++; +#else + for(; len; --len) + *op++ = *ref++; +#endif + } + } + else + { + ctrl++; +#ifdef FASTLZ_SAFE + if (FASTLZ_UNEXPECT_CONDITIONAL(op + ctrl > op_limit)) + return 0; + if (FASTLZ_UNEXPECT_CONDITIONAL(ip + ctrl > ip_limit)) + return 0; +#endif + + *op++ = *ip++; + for(--ctrl; ctrl; ctrl--) + *op++ = *ip++; + + loop = FASTLZ_EXPECT_CONDITIONAL(ip < ip_limit); + if(loop) + ctrl = *ip++; + } + } + while(FASTLZ_EXPECT_CONDITIONAL(loop)); + + return op - (flzuint8*)output; +} + +#endif /* !defined(FASTLZ_COMPRESSOR) && !defined(FASTLZ_DECOMPRESSOR) */ diff --git a/Src/image.c b/Src/image.c index 0fa06ad..4f5d29e 100644 --- a/Src/image.c +++ b/Src/image.c @@ -1,5 +1,6 @@ #include "image.h" +/* uint8_t image[1024] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -105,4 +106,51 @@ uint8_t image[1024] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; +*/ + +uint8_t image[340] = { + 0x01, 0x00, 0x00, 0xe0, 0xe9, 0x01, 0x0c, 0x20, + 0x20, 0xe0, 0x20, 0x20, 0x00, 0xe0, 0xe0, 0x40, + 0x40, 0x40, 0xe0, 0xf8, 0x40, 0x00, 0x01, 0x78, + 0x38, 0xe0, 0x04, 0x00, 0x01, 0x78, 0xf8, 0x40, + 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x06, 0x01, + 0x38, 0x38, 0xa0, 0x0f, 0x80, 0x00, 0x03, 0x38, + 0x38, 0x38, 0xf8, 0x20, 0x00, 0xa0, 0x1c, 0xa0, + 0x00, 0x40, 0x3f, 0x00, 0xf8, 0xe0, 0x01, 0x00, + 0xe0, 0x17, 0x1c, 0x02, 0x00, 0x00, 0x07, 0x40, + 0x03, 0x00, 0x03, 0x40, 0x04, 0x00, 0xff, 0x20, + 0x00, 0x00, 0x01, 0x20, 0x08, 0x01, 0xfc, 0xfe, + 0xa0, 0x00, 0x04, 0xfc, 0xe0, 0xc0, 0xc0, 0xc1, + 0x20, 0x14, 0x00, 0xff, 0x20, 0x14, 0x20, 0x05, + 0x40, 0x06, 0x07, 0x00, 0xe1, 0xc3, 0x87, 0x0f, + 0x1f, 0x3f, 0x7f, 0x20, 0x0d, 0x40, 0x0e, 0x20, + 0x05, 0xc0, 0x06, 0x40, 0x00, 0x09, 0x3f, 0x0f, + 0x03, 0x00, 0xc0, 0xe0, 0x80, 0x01, 0x07, 0x1f, + 0x60, 0x20, 0x20, 0x00, 0x20, 0x31, 0x20, 0x05, + 0x60, 0x00, 0xe0, 0x0c, 0x1c, 0xe0, 0x03, 0x00, + 0x00, 0xff, 0x20, 0x00, 0x40, 0x0f, 0x04, 0x7f, + 0x7f, 0x7f, 0x77, 0x73, 0x60, 0x00, 0x00, 0x03, + 0x20, 0x00, 0x20, 0x14, 0x40, 0x15, 0x20, 0x05, + 0x40, 0x06, 0x40, 0x07, 0x03, 0xfe, 0xfc, 0xf8, + 0xf0, 0x20, 0x86, 0x40, 0xb8, 0x20, 0x14, 0x40, + 0x15, 0x20, 0x05, 0x10, 0xff, 0x7f, 0x1f, 0x07, + 0x01, 0x80, 0x80, 0x98, 0x9e, 0x9f, 0x9f, 0x9f, + 0x9c, 0x80, 0x80, 0x00, 0x03, 0x80, 0x82, 0x80, + 0x31, 0x01, 0xff, 0xff, 0x60, 0x1c, 0x00, 0x88, + 0xe0, 0x00, 0x1c, 0x02, 0x0f, 0x3f, 0xff, 0x20, + 0x00, 0x20, 0x1c, 0xe0, 0x03, 0x00, 0x20, 0x11, + 0x00, 0xff, 0x20, 0xf4, 0xe0, 0x04, 0x00, 0x01, + 0xfe, 0xfe, 0x20, 0x14, 0x40, 0x28, 0x20, 0x05, + 0x03, 0xff, 0xfc, 0xf8, 0xfc, 0x60, 0x0e, 0x80, + 0x00, 0x40, 0x29, 0x40, 0x09, 0x20, 0x42, 0x40, + 0x06, 0x40, 0x36, 0x40, 0x07, 0x80, 0x00, 0xe0, + 0x06, 0x1c, 0x00, 0xfd, 0x20, 0x1d, 0x80, 0x18, + 0x40, 0x00, 0xe0, 0x02, 0x1c, 0xe0, 0x03, 0x00, + 0x40, 0x1a, 0xe0, 0x0d, 0x00, 0x20, 0x25, 0xe0, + 0x0d, 0x18, 0x40, 0x00, 0xe0, 0x34, 0x1c, 0xe0, + 0x03, 0x00, 0x00, 0x07, 0xe0, 0x10, 0x00, 0x20, + 0x25, 0xe0, 0x10, 0x1b, 0xe0, 0x35, 0x1c, 0x0b, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, +}; diff --git a/Src/main.c b/Src/main.c index 0e7bdd1..6c9a511 100644 --- a/Src/main.c +++ b/Src/main.c @@ -39,8 +39,8 @@ /* USER CODE BEGIN Includes */ #include "ssd1306.h" #include "fonts.h" -#include "starfield.h" -#include "cube.h" +//#include "starfield.h" +//#include "cube.h" //#include "dht22.h" /* USER CODE END Includes */ @@ -90,13 +90,14 @@ int main(void) /* USER CODE BEGIN 2 */ ssd1306_Init(); - starfield_Init(); - cube_Init(); + //starfield_Init(); + //cube_Init(); + //DHT22_Init(); HAL_UART_Receive_IT(&huart1, (uint8_t*) &UART1_Data, 1); //drawLine(0,2, 150, 2); //drawLine(0,4, 150, 4); - ssd1306_LoadImage(); + //ssd1306_LoadImage(); /* USER CODE END 2 */ /* Infinite loop */ @@ -106,7 +107,7 @@ int main(void) /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ - //ssd1306_Fill(Black); + ssd1306_Fill(Black); /* int x, msg; @@ -121,8 +122,9 @@ int main(void) //starfield_Update(); //cube_Update(60); */ + ssd1306_Anim(); ssd1306_UpdateScreen(); - //HAL_Delay(25); + HAL_Delay(100); } /* USER CODE END 3 */ } diff --git a/Src/sprites.c b/Src/sprites.c new file mode 100644 index 0000000..2db46f2 --- /dev/null +++ b/Src/sprites.c @@ -0,0 +1,282 @@ +#include "sprites.h" + +static const uint8_t sprite_0_Buf[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x80, 0x80, 0x80, 0x98, 0x98, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, + 0xe0, 0xe0, 0xe0, 0xe0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0xc1, 0xc1, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, + 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xff, 0xff, + 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xcf, + 0xff, 0xff, 0xff, 0xff, 0xcf, 0xcf, 0xcf, 0x03, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x00, 0x00, + 0x30, 0x30, 0xc0, 0xc0, 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xfe, 0xf8, 0xf8, 0xf8, 0xf8, 0xe0, 0xe0, 0x60, + 0x60, 0x60, 0x98, 0x98, 0x06, 0x06, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x01, 0x01, 0x01, + 0x01, 0xf1, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0x0f, 0x0f, 0x30, 0x30, + 0x30, 0x30, 0x0e, 0x0e, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x70, + 0x70, 0x0c, 0x0c, 0x03, 0x03, 0x0f, 0x0f, 0x7f, 0x7f, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0xf0, 0xff, 0xff, 0x80, 0x80, 0x00, 0x00, 0x00, + 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x78, 0x86, 0x86, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x98, + 0x98, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0x7f, 0x7f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x03, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x03, 0x03, 0x03, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +static const uint8_t sprite_1_Buf[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0x7f, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x01, + 0x01, 0x61, 0x61, 0x61, 0x01, 0x01, 0x81, 0x81, 0x07, 0x07, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0x3e, 0x3e, + 0x0f, 0x0f, 0x0f, 0x0f, 0x3e, 0x3e, 0x3e, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, + 0x31, 0x31, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x7f, + 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xfc, 0xfc, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x0f, + 0x0f, 0x0f, 0x70, 0x70, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, + 0xfe, 0x1f, 0x1f, 0x60, 0x60, 0x60, 0xe0, 0xe0, 0xf8, 0xf8, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, + 0x1f, 0xf8, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x07, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x30, 0x30, 0xf0, 0xf0, 0xf0, + 0xf3, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0c, 0x0c, 0x0c, 0x0c, 0x03, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +static const uint8_t sprite_2_Buf[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, + 0xfc, 0xfc, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xf0, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, + 0x07, 0x01, 0x01, 0x01, 0x61, 0x61, 0x01, 0x01, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, + 0x30, 0x30, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x70, 0x70, 0x73, 0x73, 0x7f, + 0x7f, 0x7f, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xe0, 0xe0, 0xf8, + 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0x78, 0x78, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x9e, 0x9e, 0x9e, 0x7f, 0x7f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xf0, 0xfc, 0xfc, 0xfc, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3f, + 0x3f, 0x3f, 0x0f, 0x0f, 0x3f, 0x3f, 0xc3, 0xc3, 0xc3, 0xc0, + 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, 0x0c, 0x0c, 0x03, 0x03, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x03, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +static const uint8_t sprite_3_Buf[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xf0, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, + 0x07, 0x01, 0x01, 0x01, 0x61, 0x61, 0x01, 0x01, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x30, 0x30, 0x0e, 0x0e, 0xce, 0xce, 0xce, 0xfe, 0xfe, + 0xff, 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x0f, 0x30, 0x30, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, + 0x30, 0x30, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, + 0x7c, 0x83, 0x83, 0x70, 0x70, 0x0c, 0x0c, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x80, 0x80, 0x03, 0x03, 0x0f, + 0x0f, 0x0f, 0x0c, 0x0c, 0x83, 0x83, 0x73, 0x73, 0x0c, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, + 0x80, 0x9f, 0x9f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe6, 0xe6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xfc, + 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0xff, + 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x03, 0x03, 0x0c, 0x0c, 0x0c, + 0x30, 0x30, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x1c, 0x1c, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x63, 0x63, + 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +static const uint8_t sprite_4_Buf[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, + 0xfc, 0xfc, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0x7f, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x01, + 0x01, 0x61, 0x61, 0x61, 0x01, 0x01, 0x81, 0x81, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0x3e, 0x3e, + 0x0f, 0x0f, 0x0f, 0x0f, 0x3e, 0x3e, 0x3e, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, + 0x31, 0x31, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0xfc, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x9e, + 0x9e, 0x07, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, + 0x3c, 0x3c, 0x3c, 0x3c, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3c, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x7f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x63, 0x63, 0x63, 0x7f, 0x7f, 0x03, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +SpriteDef sprite_0 = {64, 64, sprite_0_Buf}; +SpriteDef sprite_1 = {64, 64, sprite_1_Buf}; +SpriteDef sprite_2 = {64, 64, sprite_2_Buf}; +SpriteDef sprite_3 = {64, 64, sprite_3_Buf}; +SpriteDef sprite_4 = {64, 64, sprite_4_Buf}; diff --git a/Src/ssd1306.c b/Src/ssd1306.c index 81be1c6..ef60dea 100644 --- a/Src/ssd1306.c +++ b/Src/ssd1306.c @@ -57,8 +57,69 @@ void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1) } } +static int anim = 1; +static x = 0; + void ssd1306_LoadImage(void) { - memcpy(SSD1306_Buffer, image, 1024); + //memcpy(SSD1306_Buffer, image, 1024); + fastlz_decompress(image, 1024, SSD1306_Buffer, 1024); + //size = fastlz_compress(a, 1024, b); +} + +void ssd1306_DrawSprite(SpriteDef *sprite, int8_t x, int8_t y) { + int spriteAddr = 0; + int currX, currY = 0; + + for(int bank = y / 8; bank < sprite->height / 8; bank++) { + int start = (bank * sprite->width) + (bank * sprite->height) + (x); + currX = x; + int end = start + sprite->width; + for(int addr = start; addr < end; addr++) { + + if (currX > 0 && currY > 0 && currX < SSD1306_WIDTH && currY < SSD1306_HEIGHT) { + SSD1306_Buffer[addr] = sprite->buffer[spriteAddr]; + } + + spriteAddr++; + currX++; + } + currY += 8; + } +} + +void ssd1306_Anim(void) { + SpriteDef *sprite; + + switch(anim) { + case 0: + sprite = &sprite_0; + break; + case 1: + sprite = &sprite_1; + break; + case 2: + sprite = &sprite_2; + break; + case 3: + sprite = &sprite_3; + break; + case 4: + sprite = &sprite_4; + break; + } + + ssd1306_DrawSprite(sprite, x, 0); + + anim++; + x += 15; + + if (anim == 5) { + anim = 1; + } + + if (x > SSD1306_WIDTH) { + x = -64; + } } /** diff --git a/anim/anim.c b/anim/anim.c new file mode 100644 index 0000000..3155800 --- /dev/null +++ b/anim/anim.c @@ -0,0 +1,282 @@ +#include "sprites.h" + +uint8_t sprite_0_Buf[512] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + 0x80, 0x80, 0x80, 0x98, 0x98, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, + 0xe0, 0xe0, 0xe0, 0xe0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0xc1, 0xc1, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, + 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, + 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xff, 0xff, + 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcf, 0xcf, + 0xff, 0xff, 0xff, 0xff, 0xcf, 0xcf, 0xcf, 0x03, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x00, 0x00, + 0x30, 0x30, 0xc0, 0xc0, 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x81, 0x81, 0x81, 0x81, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xfe, 0xf8, 0xf8, 0xf8, 0xf8, 0xe0, 0xe0, 0x60, + 0x60, 0x60, 0x98, 0x98, 0x06, 0x06, 0x01, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x01, 0x01, 0x01, + 0x01, 0xf1, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xc1, 0xc1, 0xc0, 0xc0, 0xc0, 0x0f, 0x0f, 0x30, 0x30, + 0x30, 0x30, 0x0e, 0x0e, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x70, + 0x70, 0x0c, 0x0c, 0x03, 0x03, 0x0f, 0x0f, 0x7f, 0x7f, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xf0, 0xf0, 0xff, 0xff, 0x80, 0x80, 0x00, 0x00, 0x00, + 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x78, 0x86, 0x86, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x98, + 0x98, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0x7f, 0x7f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x03, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x03, 0x03, 0x03, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +uint8_t sprite_1_Buf[512] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0x7f, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x01, + 0x01, 0x61, 0x61, 0x61, 0x01, 0x01, 0x81, 0x81, 0x07, 0x07, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0x3e, 0x3e, + 0x0f, 0x0f, 0x0f, 0x0f, 0x3e, 0x3e, 0x3e, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, + 0x31, 0x31, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x7f, + 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xfc, 0xfc, + 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x0f, + 0x0f, 0x0f, 0x70, 0x70, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, + 0xfe, 0x1f, 0x1f, 0x60, 0x60, 0x60, 0xe0, 0xe0, 0xf8, 0xf8, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, + 0x1f, 0xf8, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x07, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x30, 0x30, 0xf0, 0xf0, 0xf0, + 0xf3, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0c, 0x0c, 0x0c, 0x0c, 0x03, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7c, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +uint8_t sprite_2_Buf[512] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, + 0xfc, 0xfc, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xf0, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, + 0x07, 0x01, 0x01, 0x01, 0x61, 0x61, 0x01, 0x01, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, + 0x30, 0x30, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x70, 0x70, 0x73, 0x73, 0x7f, + 0x7f, 0x7f, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xe0, 0xe0, 0xf8, + 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0x78, 0x78, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x9e, 0x9e, 0x9e, 0x7f, 0x7f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0xc0, 0xf0, 0xf0, 0xfc, 0xfc, 0xfc, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3f, + 0x3f, 0x3f, 0x0f, 0x0f, 0x3f, 0x3f, 0xc3, 0xc3, 0xc3, 0xc0, + 0xc0, 0xc0, 0xc0, 0xf0, 0xf0, 0x0c, 0x0c, 0x03, 0x03, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x03, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +uint8_t sprite_3_Buf[512] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xf0, 0xf0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, + 0x07, 0x01, 0x01, 0x01, 0x61, 0x61, 0x01, 0x01, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x30, 0x30, 0x0e, 0x0e, 0xce, 0xce, 0xce, 0xfe, 0xfe, + 0xff, 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x0f, 0x30, 0x30, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, + 0x30, 0x30, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7c, + 0x7c, 0x83, 0x83, 0x70, 0x70, 0x0c, 0x0c, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x80, 0x80, 0x03, 0x03, 0x0f, + 0x0f, 0x0f, 0x0c, 0x0c, 0x83, 0x83, 0x73, 0x73, 0x0c, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x80, + 0x80, 0x9f, 0x9f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xe6, 0xe6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xfc, + 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0xff, + 0xff, 0x3f, 0x3f, 0x0f, 0x0f, 0x03, 0x03, 0x0c, 0x0c, 0x0c, + 0x30, 0x30, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x1c, 0x1c, 0x60, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x63, 0x63, + 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +uint8_t sprite_4_Buf[512] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, + 0xfc, 0xfc, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xfc, + 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfc, 0xc0, 0xc0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x06, 0x06, 0x7f, 0x7f, 0xff, 0xff, 0xff, 0xff, + 0x7f, 0x7f, 0x7f, 0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x01, + 0x01, 0x61, 0x61, 0x61, 0x01, 0x01, 0x81, 0x81, 0x01, 0x01, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0x3e, 0x3e, + 0x0f, 0x0f, 0x0f, 0x0f, 0x3e, 0x3e, 0x3e, 0xf0, 0xf0, 0xc0, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, + 0x31, 0x31, 0x0e, 0x0e, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0xfc, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + 0x00, 0x03, 0x03, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x1f, 0x1f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, + 0x7f, 0x7f, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x9e, + 0x9e, 0x07, 0x07, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, + 0x3c, 0x3c, 0x3c, 0x3c, 0xfc, 0xfc, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x3f, 0x3f, 0x3c, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x7f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, + 0x63, 0x63, 0x63, 0x7f, 0x7f, 0x03, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, +}; + +SpriteDef sprite_0 = {64, 64, sprite_0_Buf}; +SpriteDef sprite_1 = {64, 64, sprite_1_Buf}; +SpriteDef sprite_2 = {64, 64, sprite_2_Buf}; +SpriteDef sprite_3 = {64, 64, sprite_3_Buf}; +SpriteDef sprite_4 = {64, 64, sprite_4_Buf}; diff --git a/anim/frame_0_delay-0.1s.bmp b/anim/frame_0_delay-0.1s.bmp new file mode 100644 index 0000000..802651f Binary files /dev/null and b/anim/frame_0_delay-0.1s.bmp differ diff --git a/anim/frame_1_delay-0.1s.bmp b/anim/frame_1_delay-0.1s.bmp new file mode 100644 index 0000000..92be79d Binary files /dev/null and b/anim/frame_1_delay-0.1s.bmp differ diff --git a/anim/frame_2_delay-0.1s.bmp b/anim/frame_2_delay-0.1s.bmp new file mode 100644 index 0000000..95b8184 Binary files /dev/null and b/anim/frame_2_delay-0.1s.bmp differ diff --git a/anim/frame_3_delay-0.1s.bmp b/anim/frame_3_delay-0.1s.bmp new file mode 100644 index 0000000..e223d7c Binary files /dev/null and b/anim/frame_3_delay-0.1s.bmp differ diff --git a/anim/frame_4_delay-0.1s.bmp b/anim/frame_4_delay-0.1s.bmp new file mode 100644 index 0000000..1fe9ecd Binary files /dev/null and b/anim/frame_4_delay-0.1s.bmp differ diff --git a/anim/sprite.py b/anim/sprite.py new file mode 100755 index 0000000..e5b4d51 --- /dev/null +++ b/anim/sprite.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 + +# 128x64 +# convert gnaa.png +dither -monochrome -colors 2 image.bmp + +from PIL import Image +import sys +import math + +#import zlib + +invert = 0 + +def set_bit(value, bit): + return value | (1< 64 or width > 128): + sys.exit() + + banks = math.ceil(height / 8); + + #print(banks) + + buf = [] + + for bank in range(0, banks): + for x in range(0, width): + value = 0 + if (invert == 1): + value = 255 + c = 7 + #print("OI") + for y in range( (bank * 8 ) + 7, (bank * 8) - 1, -1): + #print(bank, x, y) + b = im.getpixel((x,y)) + + if (b == 1 or b == 255): + value = set_bit(value, c) + if (invert == 1): + value = clear_bit(value, c) + c = c - 1 + buf.append(value) + + #buffer = zlib.compress(bytes(buffer)) + frames.append({'name': 'sprite_' + str(counter), 'buf': buf}) + counter = counter + 1 + + + print('#include "sprites.h"') + print() + for item in frames: + print_array(item['name'] + "_Buf", item['buf']) + for item in frames: + print_sprites(item['name'], height, width) diff --git a/anim/sprite_0.bmp b/anim/sprite_0.bmp new file mode 100644 index 0000000..32fea0f Binary files /dev/null and b/anim/sprite_0.bmp differ diff --git a/anim/sprite_1.bmp b/anim/sprite_1.bmp new file mode 100644 index 0000000..ef9d0b7 Binary files /dev/null and b/anim/sprite_1.bmp differ diff --git a/anim/sprite_2.bmp b/anim/sprite_2.bmp new file mode 100644 index 0000000..01d5d6c Binary files /dev/null and b/anim/sprite_2.bmp differ diff --git a/anim/sprite_3.bmp b/anim/sprite_3.bmp new file mode 100644 index 0000000..78a2527 Binary files /dev/null and b/anim/sprite_3.bmp differ diff --git a/anim/sprite_4.bmp b/anim/sprite_4.bmp new file mode 100644 index 0000000..da99aac Binary files /dev/null and b/anim/sprite_4.bmp differ diff --git a/image.py b/image.py index 1a6ef09..6e5057d 100755 --- a/image.py +++ b/image.py @@ -7,7 +7,8 @@ from PIL import Image -import zlib +import sys +#import zlib invert = 0 @@ -17,7 +18,7 @@ def set_bit(value, bit): def clear_bit(value, bit): return value & ~(1<