randomskk / followingrobot

C/ASM code for an ARM-based robot with a vision system to follow the user

This URL has Read+Write access

followingrobot / oled.h
100644 54 lines (40 sloc) 1.505 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/************************************************
* FollowingRobot - oled.h
* Functions to interact with an OLED
* screen connected to USART1.
* Header file.
* See README for more details.
***********************************************/
 
#include "stm32f10x_lib.h"
#pragma once
 
//Colour codes in RGB565
#define BLACK 0x0000
#define RED 0xF800
#define YELLOW 0xFFE0
#define GREEN 0x07E0
#define CYAN 0x07FF
#define BLUE 0x001F
#define PURPLE 0xF81F
#define WHITE 0xFFFF
 
//Which USART to use
#define USART USART1
 
//Send an array of data over the USART
void _usart_send_data( char* data, int len );
 
//Busy wait for an ACK from the OLED
void oled_wait_for_ack();
 
//Send a 'U' (01010101) character to get the OLED determine baud rate
void oled_autobaudrate();
 
//Set background colour of the OLED. Used when erasing the screen.
void oled_set_background_colour( u16 colour );
 
//Erase the OLED screen, filling with the background colour.
void oled_erase_screen();
 
//Set the font size to be used by the formatted_string command.
void oled_font_size( u8 font_size );
 
//Draw a filled rectangle
void oled_rectangle( u8 x1, u8 y1, u8 x2, u8 y2, u16 colour );
 
//Write a string to the OLED screen
void oled_formatted_string( u8 column, u8 row, u8 font_size, u16 colour, char* str );
 
//Draw image data. Not currently used.
//void oled_image( u8 x, u8 y, u8 width, u8 height, u8 colourmode, u16** data );
 
//Power-toggle the OLED. This is the 'correct' way to shut it down.
void oled_power( int state );