Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:iot-open:practical:hardware:sut:stm32:emb5_1 [2024/04/10 19:44] – [Prerequisites] ktokarzen:iot-open:practical:hardware:sut:stm32:emb5_1 [2024/04/10 20:20] (current) – [Steps] ktokarz
Line 5: Line 5:
  
 ===== Prerequisites ===== ===== Prerequisites =====
-Familiarise yourself with a hardware reference. LCD of this type can be connected to the microcontroller with 8 or 4 lines of data, RS - register select, R/#W - read/write, and EN - synchronisation line. In our lab equipment, the LCD is controlled with 6 GPIOs. We use 4 lines for data and because We don't read anything from the LCD the R/#W is connected to the ground.+Familiarise yourself with a hardware reference. LCD of this type can be connected to the microcontroller with 8 or 4 lines of data, RS - register select, R/#W - read/write, and EN - synchronisation line. In our lab equipment, the LCD is controlled with 6 GPIOs. We use 4 lines for data and because We don't read anything from the LCD the R/#W is connected to the ground. Details can be found in //Table 1: STM32WB55 Node Hardware Details// on the STM32 laboratory hardware reference page.
 You are going to use a library to handle the LCD. It means you need to add it to your ''platformio.ini'' file. Use the template provided in the hardware reference section and extend it with the library definition: You are going to use a library to handle the LCD. It means you need to add it to your ''platformio.ini'' file. Use the template provided in the hardware reference section and extend it with the library definition:
 <code bash> <code bash>
-lib_deps = adafruit/Adafruit LiquidCrystal@^2.0.2+lib_deps = arduino-libraries/LiquidCrystal@^1.0.7
 </code> </code>
  
 ===== Suggested Readings and Knowledge Resources ===== ===== Suggested Readings and Knowledge Resources =====
   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]   * [[en:iot-open:introductiontoembeddedprogramming2:cppfundamentals]]
-  * [[en:iot-open:hardware2:esp32|]]+  * [[en:iot-open:hardware2:stm32]]
   * [[en:iot-open:hardware2:actuators_light|]]   * [[en:iot-open:hardware2:actuators_light|]]
-  * [[en:iot-open:practical:hardware:sut:esp32|]]+  * [[en:iot-open:practical:hardware:sut:stm32|]]
 ===== Hands-on Lab Scenario ===== ===== Hands-on Lab Scenario =====
  
Line 30: Line 30:
 Include the library in your source code: Include the library in your source code:
 <code c> <code c>
-#include <Adafruit_LiquidCrystal.h>+#include <LiquidCrystal.h>
 </code> </code>
  
Line 36: Line 36:
 Declare GPIOs controlling the LCD, according to the hardware reference: Declare GPIOs controlling the LCD, according to the hardware reference:
 <code c> <code c>
-#define LCD_RS 2 +const int rs = PC5, en = PB11, d4 = PB12, d5 = PB13, d6 = PB14, d7 = PB15;
-#define LCD_ENABLE 1 +
-#define LCD_D4 39 +
-#define LCD_D5 40 +
-#define LCD_D6 41 +
-#define LCD_D7 42+
 </code> </code>
  
 === Step 3 === === Step 3 ===
-Declare a static instance of the LCD controller class and preconfigure it with appropriate control GPIOs:+Declare an instance of the LCD controller class and preconfigure it with appropriate control GPIOs:
 <code c> <code c>
-static Adafruit_LiquidCrystal lcd(LCD_RSLCD_ENABLELCD_D4LCD_D5LCD_D6LCD_D7);+LiquidCrystal lcd(rsend4d5d6d7);
 </code> </code>
  
Line 53: Line 48:
 Initialise class with display area configuration (number of columns, here 16 and rows, here 2): Initialise class with display area configuration (number of columns, here 16 and rows, here 2):
 <code c> <code c>
-lcd.begin(16,2); +lcd.begin(16, 2);
 </code> </code>
  
Line 61: Line 56:
   * ''.setCursor(x,y)'' - set cursor, writing will start there;   * ''.setCursor(x,y)'' - set cursor, writing will start there;
   * ''.print(contents)'' - prints text in the cursor location; note there are many overloaded functions, accepting various arguments, including numerical.   * ''.print(contents)'' - prints text in the cursor location; note there are many overloaded functions, accepting various arguments, including numerical.
 +
 +A simple example can be the Hello World:
 +<code c>
 +lcd.print("hello, world!");
 +</code>
  
 ==== Result validation ==== ==== Result validation ====
en/iot-open/practical/hardware/sut/stm32/emb5_1.1712778268.txt.gz · Last modified: 2024/04/10 19:44 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0