Skip to content
/ hast Public

FH Technikum Wien Project in Microcontroller design: Coin counter stm32 nucleo l432kc

Notifications You must be signed in to change notification settings

fasteiner/hast

Repository files navigation

Project HAST

Initialization

Requirements:
  • D7 connected to A1 with a wire (Reset of Display)
  • Display (MikroElektronika oled_c v101, SSD1351) in Slot 1 of Click Board
  • LDC1000 in Slot 2 of Click Board
  • USART Initalized
  • USART DMA Channels configured and Inizalized
  • TIM6, TIM7 Initalized
  • LDC_CS_GPIO_Port --> LOW
  • OLED_CS_GPIO_Port --> LOW

Initialization of Modules

LDC1000

  applicationInit (&hspi1, LDC_CS_GPIO_Port, LDC_CS_Pin);
  enableInterrupt (&hspi1, LDC_CS_GPIO_Port, LDC_CS_Pin, 5500, 8500);

OLED_C v101

  oled_c = (OLED_C *)malloc(sizeof(OLED_C));
  OLED_C_Init_Struct(oled_c, &hspi1);
  oled_c_init(oled_c);
  oled_c_set_font(guiFont_Tahoma_10_Regular, WHITE, 0 );

Gamer

  prioOnly = false;
  isSoftwareInt = false;
  DISPLAY_TIME = 30000;
  messageToDisplay = (uint8_t *)malloc((10 + MAX_PAYLOAD_LENGTH) * sizeof(uint8_t));
  currTime = (RTC_TimeTypeDef*)malloc(sizeof(RTC_TimeTypeDef));
  currDate = (RTC_DateTypeDef*)malloc(sizeof(RTC_DateTypeDef));
  initGAMER(&huart2, messageToDisplay);
  HAL_TIM_Base_Start_IT(&htim6);

  // Print Coins after startup
  printCoins(messageToDisplay);

  // Send menu on startup via UART
  printMenu(&huart2);

Usage of Modules

Gamer Protokoll

-----------------------------------------
-------Welcome to our MCSD Project-------
-----------------------------------------
 /$$   /$$  /$$$$$$   /$$$$$$  /$$$$$$$$
| $$  | $$ /$$__  $$ /$$__  $$|__  $$__/
| $$  | $$| $$  \ $$| $$  \__/   | $$
| $$$$$$$$| $$$$$$$$|  $$$$$$    | $$
| $$__  $$| $$__  $$ \____  $$   | $$
| $$  | $$| $$  | $$ /$$  \ $$   | $$
| $$  | $$| $$  | $$|  $$$$$$/   | $$
|__/  |__/|__/  |__/ \______/    |__/
-----------------------------------------
Your options are:
#g   Receive the current amount of coins
#a   Send an Answer
#m   Send a message
#e   Send an error
#r   Reset amount of coins
#d   Display number of coins on Display
#s...
#sc  Set amount of coins
#st  Set time and date YYYY-MM-DD-hh:mm:ss
#sd  Set delay time that messages
     are displayed between 25 and 60
#?   Show this menu again."
-----------------------------------------

If a command with invalid content is send, then the gamer protocol sends an error and the needed format.

Application

prioOnly: flag that indicates that only messages with prio can be displayed
isSoftwareInt: flag that needs to be set to ensure the Software Interrupt is only triggered on purpose

Feature Description

A coin counter with a display of inserted coins. The display shows the ontime.

After Power-on:

The Display is initialized to the following values:
Coin Counter: 0
On Time: 00-00-00:00:00

Usecase 1:

A coin is inserted or the display Coin command #d\0 is sent via UART so the coin count is displayed for 30 seconds (default) or for a specified time between 25 and 60 seconds.

Usecase 1 example

The displayed format is MM-DD-hh:mm:ss. As the RTC uses a calendar internally, the Month starts with 1 and ends with 12.

Usecase 2:

A message is recieved over UART and displayed on the display for the configured timeinterval. If the message is longer then the display, it scrolls in 1px steps every delayT ms.

uint16_t delayT = (uint16_t)((DISPLAY_TIME - (SCROLL_DELAY + 2000)) / 128);

Fits display:

Usecase 2 example

Does not fit display:

Usecase 2 example

Linebreaks are added automatically if a word is to long.

Diplaytime: configurable over UART using #sdxx\0, where xx is in seconds and has to be between 25 and 60.

Usecase 3:

When nothing happens for the configured timeinterval (default 30s), then only the ontime is displayed.

Usecase 3 example

Usecase 4:

A coin is inserted while a message is being displayed. The coin is counted, but not displayed, because the display is blocked by a priority message.

Usecase 5:

Description char
Beginn of Message #
Get Number of coins g
Answer to message a
Post message m
Error message e
Reset coin counter r
Set coins sc
Set display delay sd
Set time st
Display coins d
Display help message ?
End of message \0

Example messages:

Descriptionmessage
Answer message#aPAYLOAD\0
Post message#mLorem Ipsum dolor sit amet\0
Get message#g\0
Error message#eERRORMESSAGE\0
Reset message#r\0
Display coins message#d\0
Set coins message#sc1000\0
Set display delay message#sd59\0
Set time message#st2022-02-04-10:30:50\0
Help message#?\0
Maximal Payload length: 110
Exceeding payload length: error
Violation of the protocol: error

Usecase 6:

A answer message is recieved by the microcontroller. This displays the message answer: 'message' for the configured time interval.

Usecase 6 example

About

FH Technikum Wien Project in Microcontroller design: Coin counter stm32 nucleo l432kc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published