display optimization; sprites
parent
c4e8f26cbb
commit
fdf1a42bba
@ -1,67 +1,95 @@
|
|||||||
/**
|
/**
|
||||||
* main.c - Firmware entry point and main loop for game or testing.
|
* main.c - Firmware entry point and main loop for game or testing.
|
||||||
* Copyright (C) 2020 Clyne Sullivan
|
* Copyright (C) 2020 Clyne Sullivan
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "dogs.h"
|
#include "dogs.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Progress:
|
* Progress:
|
||||||
* - Serial through LPUART1 works (38400 baud, takes over swdio pins)
|
* - Serial through LPUART1 works (38400 baud, takes over swdio pins)
|
||||||
* - Display comm. over SPI, can clear screen
|
* - Display comm. over SPI, can clear screen
|
||||||
* - Can read buttons through PAL (through interrupts now)
|
* - Can read buttons through PAL (through interrupts now)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
THD_WORKING_AREA(waThread2, 96);
|
THD_WORKING_AREA(waThread2, 96);
|
||||||
THD_FUNCTION(Thread2, arg)
|
THD_FUNCTION(Thread2, arg)
|
||||||
{
|
{
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
dogs_init();
|
dogs_init();
|
||||||
|
|
||||||
while (1) {
|
const unsigned char testbitmap[] = {
|
||||||
chThdSleepMilliseconds(100);
|
8, 8,
|
||||||
dogs_buffer[0] = button_state;
|
0b00111100,
|
||||||
dogs_buffer[1] = button_state;
|
0b01100110,
|
||||||
dogs_buffer[2] = button_state;
|
0b01000010,
|
||||||
dogs_buffer[3] = button_state;
|
0b01111110,
|
||||||
dogs_flush();
|
0b01100110,
|
||||||
}
|
0b01000010,
|
||||||
}
|
0b11000000,
|
||||||
|
0b11000000,
|
||||||
THD_TABLE_BEGIN
|
};
|
||||||
THD_TABLE_THREAD(0, "game", waThread2, Thread2, NULL)
|
|
||||||
THD_TABLE_END
|
|
||||||
|
int x = 0, y = 0;
|
||||||
int main(void)
|
while (1) {
|
||||||
{
|
chThdSleepMilliseconds(100);
|
||||||
halInit();
|
|
||||||
chSysInit();
|
unsigned char b = button_state;
|
||||||
|
if ((b & (BUTTON_JOYUR | BUTTON_JOYUL)) == (BUTTON_JOYUR | BUTTON_JOYUL))
|
||||||
buttons_init();
|
y--;
|
||||||
|
else if ((b & (BUTTON_JOYUR | BUTTON_JOYDR)) == (BUTTON_JOYUR | BUTTON_JOYDR))
|
||||||
// Below code for serial -- note that it cuts off debugging, and MUST be used in a thread
|
x++;
|
||||||
//chThdSleepMilliseconds(2000);
|
else if ((b & (BUTTON_JOYDR | BUTTON_JOYDL)) == (BUTTON_JOYDR | BUTTON_JOYDL))
|
||||||
//palSetPadMode(GPIOA, 13, PAL_MODE_ALTERNATE(6));
|
y++;
|
||||||
//palSetPadMode(GPIOA, 14, PAL_MODE_ALTERNATE(6));
|
else if ((b & (BUTTON_JOYDL | BUTTON_JOYUL)) == (BUTTON_JOYDL | BUTTON_JOYUL))
|
||||||
//sdStart(&LPSD1, NULL);
|
x--;
|
||||||
//chnWrite(&LPSD1, (const uint8_t *)"Hello World!\r\n", 14);
|
|
||||||
|
dogs_clear();
|
||||||
|
draw_bitmap(x, y, testbitmap);
|
||||||
|
dogs_flush();
|
||||||
/* This is now the idle thread loop, you may perform here a low priority
|
}
|
||||||
task but YOU MUST NEVER TRY TO SLEEP OR WAIT in this loop. Note that
|
}
|
||||||
this tasks runs at the lowest priority level so any instruction added
|
|
||||||
here will be executed after all other tasks have been started. */
|
THD_TABLE_BEGIN
|
||||||
while (1);
|
THD_TABLE_THREAD(0, "game", waThread2, Thread2, NULL)
|
||||||
}
|
THD_TABLE_END
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
halInit();
|
||||||
|
chSysInit();
|
||||||
|
|
||||||
|
buttons_init();
|
||||||
|
|
||||||
|
// Below code for serial -- note that it cuts off debugging, and MUST be used in a thread
|
||||||
|
//chThdSleepMilliseconds(2000);
|
||||||
|
//palSetPadMode(GPIOA, 13, PAL_MODE_ALTERNATE(6));
|
||||||
|
//palSetPadMode(GPIOA, 14, PAL_MODE_ALTERNATE(6));
|
||||||
|
//sdStart(&LPSD1, NULL);
|
||||||
|
//chnWrite(&LPSD1, (const uint8_t *)"Hello World!\r\n", 14);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* This is now the idle thread loop, you may perform here a low priority
|
||||||
|
task but YOU MUST NEVER TRY TO SLEEP OR WAIT in this loop. Note that
|
||||||
|
this tasks runs at the lowest priority level so any instruction added
|
||||||
|
here will be executed after all other tasks have been started. */
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardFault_Handler()
|
||||||
|
{
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue