
Projet Interfacage capteur de recul
Dependencies: TS_DISCO_F746NG LCD_DISCO_F746NG SRF02 BSP_DISCO_F746NG BUTTON_GROUP
Revision 0:735dae6ecacf, committed 2020-06-18
- Comitter:
- darkseb
- Date:
- Thu Jun 18 14:45:26 2020 +0000
- Child:
- 1:7e34491bfd01
- Commit message:
- test
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,2 @@ +BUILD +mbed-os/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F746NG.lib Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#85dbcff443aa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BUTTON_GROUP.lib Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/MikamiUitOpen/code/BUTTON_GROUP/#af578b53ff0e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Clock.cpp Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,64 @@ +#include <mbed.h> + +// The us ticker is a wrapping uint32_t. We insert interrupts at +// 0, 0x40000000, 0x8000000, and 0xC0000000, rather than just 0 or just 0xFFFFFFFF because there is +// code that calls interrupts that are "very soon" immediately and we don't +// want that. Also because if we only use 0 and 0x80000000 then there is a chance it would +// be considered to be in the past and executed immediately. + +class ExtendedClock : public TimerEvent +{ +public: + ExtendedClock() + { + // This also starts the us ticker. + insert(0x40000000); + } + + float read() + { + return read_us() / 1000000.0f; + } + + uint64_t read_ms() + { + return read_us() / 1000; + } + + uint64_t read_us() + { + return mTriggers * 0x40000000ull + (ticker_read(_ticker_data) & 0x3FFFFFFF); + } + +private: + void handler() override + { + ++mTriggers; + // If this is the first time we've been called (at 0x4...) + // then mTriggers now equals 1 and we want to insert at 0x80000000. + insert((mTriggers+1) * 0x40000000); + } + + // The number of times the us_ticker has rolled over. + uint32_t mTriggers = 0; +}; + +static ExtendedClock _GlobalClock; + +// Return the number of seconds since boot. +float clock_s() +{ + return _GlobalClock.read(); +} + +// Return the number of milliseconds since boot. +uint64_t clock_ms() +{ + return _GlobalClock.read_ms(); +} + +// Return the number of microseconds since boot. +uint64_t clock_us() +{ + return _GlobalClock.read_us(); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Clock.h Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,12 @@ +#pragma once + +#include <stdint.h> + +// Return the number of seconds since boot. +float clock_s(); + +// Return the number of milliseconds since boot. +uint64_t clock_ms(); + +// Return the number of microseconds since boot. +uint64_t clock_us(); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F746NG.lib Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F746NG.lib Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,169 @@ +#include "mbed.h" +#include "stm32746g_discovery_lcd.h" +#include "stm32746g_discovery_ts.h" +#include "button_group.hpp" + +Serial pc(USBTX, USBRX); // tx, rx + +using namespace Mikami; +TS_DISCO_F746NG ts_; +LCD_DISCO_F746NG lcd_; + +int main() +{ + unsigned int boutton_commande = 0; + unsigned int boutton_retour = 0; + unsigned int boutton_scanner = 0; + unsigned int boutton_panier = 0; + unsigned int boutton_acceuil = 0; + unsigned int boutton_valider = 0; + + BSP_LCD_Init(); + BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); + BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); + + while(1) + { + //Ecran d'acceuil + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&LCD_DEFAULT_FONT); + BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + HAL_Delay(1000); + + BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"BIENVENUE SUR CEL", CENTER_MODE); + HAL_Delay(1000); + + //Bouton faire une commande + Button commande(lcd_, ts_, 88, 160, 300, 50, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Faire une commande", Font20); + commande.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + while(boutton_commande == 0) + { + if(commande.Touched()) + { + boutton_commande = 1; + } + } + boutton_commande = 0; + + + //Ecran produits + BSP_LCD_Clear(LCD_COLOR_WHITE); + HAL_Delay(1000); + + //Bouton retour + Button retour(lcd_, ts_, 10, 5, 60, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour", Font12); + retour.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + //Bouton scanner + Button scanner(lcd_, ts_, 200, 5, 60, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Scanner", Font12); + scanner.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + //Bouton panier + Button panier(lcd_, ts_, 410, 5, 60, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Panier", Font12); + panier.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + while(boutton_retour == 0 && boutton_scanner == 0 && boutton_panier == 0) + { + if(retour.Touched()) + { + boutton_retour = 1; + } + + else if(scanner.Touched()) + { + boutton_scanner = 1; + + //Ecran scanner + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&Font20); + BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + HAL_Delay(1000); + + BSP_LCD_DisplayStringAt(0, 40, (uint8_t *)"Scanner le code barre", CENTER_MODE); + BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"du produit", CENTER_MODE); + HAL_Delay(1000); + + BSP_LCD_SetBackColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Le produit est :", CENTER_MODE); + HAL_Delay(1000); + + //Bouton retour vers la page d'acceuil + Button acceuil(lcd_, ts_, 68, 215, 350, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); + acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + while(boutton_acceuil == 0) + { + if(acceuil.Touched()) + { + boutton_acceuil = 1; + } + } + boutton_acceuil = 0; + } + + else if(panier.Touched()) + { + boutton_panier = 1; + + //Ecran panier + BSP_LCD_Clear(LCD_COLOR_WHITE); + HAL_Delay(1000); + + //Bouton valider la commande + Button valider(lcd_, ts_, 88, 215, 300, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Valider la commande", Font16); + valider.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + while(boutton_valider == 0) + { + if(valider.Touched()) + { + boutton_valider = 1; + } + } + boutton_valider = 0; + + + //Ecran prix total + BSP_LCD_Clear(LCD_COLOR_WHITE); + BSP_LCD_SetFont(&LCD_DEFAULT_FONT); + BSP_LCD_SetBackColor(LCD_COLOR_ORANGE); + BSP_LCD_SetTextColor(LCD_COLOR_BLACK); + HAL_Delay(1000); + + BSP_LCD_DisplayStringAt(0, 70, (uint8_t *)"Prix total", CENTER_MODE); + HAL_Delay(1000); + + BSP_LCD_SetFont(&Font20); + BSP_LCD_SetBackColor(LCD_COLOR_RED); + BSP_LCD_DisplayStringAt(0, 120, (uint8_t *)"100,00 Euros", CENTER_MODE); + HAL_Delay(1000); + + //Bouton retour vers la page d'acceuil + Button acceuil(lcd_, ts_, 68, 215, 350, 40, + LCD_COLOR_BLUE, LCD_COLOR_BLACK, "Retour vers la page d'acceuil", Font16); + acceuil.Draw(LCD_COLOR_GRAY, LCD_COLOR_BLACK); + + while(boutton_acceuil == 0) + { + if(acceuil.Touched()) + { + boutton_acceuil = 1; + } + } + boutton_acceuil = 0; + } + } + boutton_retour = 0; + boutton_scanner = 0; + boutton_panier = 0; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Jun 18 14:45:26 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#699372421a3b388fe568e9be85b1a985749a438f