Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
graphics.cpp
- Committer:
- lballard9
- Date:
- 2021-09-28
- Revision:
- 4:37d3935365f8
- Parent:
- 0:35660d7952f7
- Child:
- 6:c9695079521d
File content as of revision 4:37d3935365f8:
#include "graphics.h"
#include "globals.h"
/*
In this file put all your graphical functions (don't forget to declare them first
in graphics.h). So when you want to draw something use this file. One cool function
to look at would be uLCD.blit() there are more like filled_rectangle etc...
https://os.mbed.com/users/4180_1/notebook/ulcd-144-g2-128-by-128-color-lcd/
This website is a good resource.
*/
void draw_player(int u, int v, int key)
{
uLCD.filled_rectangle(u, v, u+11, v+11, RED);
}
#define YELLOW 0xFFFF00
#define BROWN 0xD2691E
#define DIRT BROWN
void draw_img(int u, int v, const char* img)
{
int colors[11*11];
for (int i = 0; i < 11*11; i++)
{
if (img[i] == 'R') colors[i] = RED;
else if (img[i] == 'Y') colors[i] = YELLOW;
else if (img[i] == 'G') colors[i] = GREEN;
else if (img[i] == 'D') colors[i] = DIRT;
else if (img[i] == '5') colors[i] = LGREY;
else if (img[i] == '3') colors[i] = DGREY;
else colors[i] = BLACK;
}
uLCD.BLIT(u, v, 11, 11, colors);
wait_us(250); // Recovery time!
}
void draw_nothing(int u, int v)
{
// Fill a tile with blackness
uLCD.filled_rectangle(u, v, u+10, v+10, BLACK);
}
void draw_wall(int u, int v)
{
uLCD.filled_rectangle(u, v, u+10, v+10, BROWN);
}
void draw_plant(int u, int v)
{
uLCD.filled_rectangle(u, v, u+10, v+10, GREEN);
}
void draw_upper_status()
{
// Draw bottom border of status bar
uLCD.line(0, 9, 127, 9, GREEN);
// Add other status info drawing code here
}
void draw_lower_status()
{
// Draw top border of status bar
uLCD.line(0, 118, 127, 118, GREEN);
// Add other status info drawing code here
}
void draw_border()
{
uLCD.filled_rectangle(0, 9, 127, 14, WHITE); // Top
uLCD.filled_rectangle(0, 13, 2, 114, WHITE); // Left
uLCD.filled_rectangle(0, 114, 127, 117, WHITE); // Bottom
uLCD.filled_rectangle(124, 14, 127, 117, WHITE); // Right
}