1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
-
- #include <avr/io.h>
- #include <stdint.h>
- #include <stdlib.h>
- #include <serial.h>
- #include <strings.h>
-
- void buffClearAllPixels(uint8_t *buffer) {
- uint8_t i;
- for(i = 0; i < 64; i++) {
- buffer[i] = 0;
- }
- }
-
- uint8_t *buffNew(void) {
- uint8_t *tmp = (uint8_t *)malloc(65);
- if (tmp == NULL) {
- serialWriteString(getString(24));
- while(1);
- }
- buffClearAllPixels(tmp);
- tmp[64] = 1;
- return tmp;
- }
-
- void buffSetPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z) {
- buffer[(8 * (7 - z)) + (7 - y)] |= (1 << x);
- }
-
- void buffClearPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z) {
- buffer[(8 * (7 - z)) + (7 - y)] &= ~(1 << x);
- }
-
- void buffFree(uint8_t *buffer) {
- free(buffer);
- }
|