Demo of low res colour vga video for stm32f3 discovery board

Dependencies:   STM32F3-Discovery-minimal

Fork of Space_Invaders_Demo by Martin Johnson

Committer:
MartinJohnson
Date:
Wed Apr 03 22:05:56 2019 +0000
Revision:
17:833f1b69e11d
Parent:
14:3035b3271395
update library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MartinJohnson 14:3035b3271395 1 #include <gdi.h>
MartinJohnson 14:3035b3271395 2 #include <menu.h>
MartinJohnson 14:3035b3271395 3 #include <video.h>
MartinJohnson 14:3035b3271395 4 #include "stm32f30x.h"
MartinJohnson 14:3035b3271395 5
MartinJohnson 14:3035b3271395 6 void menu(menu_t *menu) {
MartinJohnson 14:3035b3271395 7 int n=menu->no;
MartinJohnson 14:3035b3271395 8 int selected=0;
MartinJohnson 14:3035b3271395 9 int16_t accel[3];
MartinJohnson 14:3035b3271395 10 MemsConfig();
MartinJohnson 14:3035b3271395 11 while(1) {
MartinJohnson 14:3035b3271395 12 gdiSetColour(3);
MartinJohnson 14:3035b3271395 13 gdiRectangle(0,0,(VID_HSIZE - 1),VID_VSIZE - 1,0);
MartinJohnson 14:3035b3271395 14
MartinJohnson 14:3035b3271395 15 gdiSetColour(7);
MartinJohnson 14:3035b3271395 16 gdiDrawTextEx(VID_HSIZE/2-strlen(menu->title)*3, 16, menu->title, 0);
MartinJohnson 14:3035b3271395 17 for(int i=0;i<n;i++) {
MartinJohnson 14:3035b3271395 18 if(selected==i) {
MartinJohnson 14:3035b3271395 19 gdiSetColour(1);
MartinJohnson 14:3035b3271395 20 gdiFilledRectangle(12,i*12+15+16,16+strlen(menu->entries[i].name)*6+2,i*12+26+16,0);
MartinJohnson 14:3035b3271395 21 gdiSetColour(7);
MartinJohnson 14:3035b3271395 22 }
MartinJohnson 14:3035b3271395 23 else
MartinJohnson 14:3035b3271395 24 gdiSetColour(1);
MartinJohnson 14:3035b3271395 25 gdiDrawTextEx(16, i*12+32, menu->entries[i].name, 0);
MartinJohnson 14:3035b3271395 26 }
MartinJohnson 14:3035b3271395 27 if(buttonPress())
MartinJohnson 14:3035b3271395 28 menu->entries[selected].prog();
MartinJohnson 14:3035b3271395 29 ReadAccelerometer(accel );
MartinJohnson 14:3035b3271395 30 selected= accel[0]/2000+n/2;
MartinJohnson 14:3035b3271395 31 if(selected<0) selected=0;
MartinJohnson 14:3035b3271395 32 if(selected>n-1) selected=n-1;
MartinJohnson 14:3035b3271395 33 waitForRefresh();
MartinJohnson 14:3035b3271395 34 vidNextBuffer();
MartinJohnson 14:3035b3271395 35
MartinJohnson 14:3035b3271395 36 }
MartinJohnson 14:3035b3271395 37 }