Commit 6ee7fb53 authored by Mikaël BRIDAY's avatar Mikaël BRIDAY

add lab5

parent f373b9fc
File added
No preview for this file type
No preview for this file type
#to compile the project:
# mkdir _build
# cd _build
# cmake -D CMAKE_TOOLCHAIN_FILE=../../sys/cmake/arm-none-eabi.cmake ..
# make
# make flash
cmake_minimum_required(VERSION 3.5)
#project name
project(lab5)
#application sources
set(SRCS
${CMAKE_SOURCE_DIR}/main.cpp
)
option(WITH_TFT "add compilation rules for the TFT support" ON)
include("../sys/cmake/coroLabs.cmake")
File added
#include "stm32f3xx.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ST7735.h"
#include "adc.h"
#include "tft.h"
void setup()
{
Tft.setup();
Tft.setTextCursor(4, 1); //col,line
Tft.print("Hello World! ");
ADCInit();
}
//this is a simple application that uses the TFT display.
// => it first write a string in the top of the screen (in setup)
// => it writes the ADC value of the potentiometer in green, and
// refreshes it each time the value differs more than 5.
int main()
{
static int prevPot = -1;
setup();
while(1)
{
//potentiometer
int pot = ADCRead(); //12 bits -> 4096 -> 4 digits
//update only we value changes significantly
if(abs(prevPot - pot) > 5)
{
//set cursor centered on line 4.
Tft.setTextCursor(Tft.getTextWidth()/2-2,4);
Tft.eraseText(4); //remove previous value (4 digits)
Tft.print(pot);
prevPot = pot;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment