Skip to content

Commit

Permalink
Moved parts for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBattilana committed Dec 22, 2021
1 parent 50c15a7 commit 101cf42
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
26 changes: 25 additions & 1 deletion include/i2c_lcd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#include "stm32f4xx_hal.h"

/*LCD Commands*/
#define LCD_FUNCTION_SET1 0x31
#define LCD_FUNCTION_SET2 0x22
#define LCD_4BIT_2LINE_MODE 0x28
#define LCD_DISP_CURS_ON 0x0E
#define LCD_DISP_ON_CURS_OFF 0x0C //Display on, cursor off
#define LCD_DISPLAY_OFF 0x08
#define LCD_DISPLAY_ON 0x04
#define LCD_CLEAR_DISPLAY 0x01
#define LCD_ENTRY_MODE_SET 0x04
#define LCD_INCREMENT_CURSER 0x06
#define LCD_SET_ROW1_COL1 0x80 //Force cursor to beginning ( 1st line)
#define LCD_SET_ROW2_COL1 0xC0 //Force cursor to beginning ( 2nd line)
#define LCD_MOVE_DISPLAY_LEFT 0x18
#define LCD_MOVE_DISPLAY_RIGHT 0x1C
#define LCD_CREATE_CHAR 0x40

#define SLAVE_ADDRESS_LCD 0x34<<1 // change this according to ur setup
#define LCD_BACKLIGHT 0x08
#define LCD_NOBACKLIGHT 0x00
#define EN 0x04
#define RS 0x01


void lcd_init (I2C_HandleTypeDef * i2c_ref); // initialize lcd

void lcd_create_char(char customChar[], int location);
Expand All @@ -22,4 +46,4 @@ void lcd_send_two_string (char *str1, char * str2);

void lcd_set_text_downloading();

void lcd_set_number_people(int n_people, int max_people);
void lcd_set_number_people(int n_people, int max_people);
25 changes: 1 addition & 24 deletions src/i2c_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,6 @@
#include "stm32f4xx_hal.h"
#include "stdio.h"

/*LCD Commands*/
#define LCD_FUNCTION_SET1 0x31
#define LCD_FUNCTION_SET2 0x22
#define LCD_4BIT_2LINE_MODE 0x28
#define LCD_DISP_CURS_ON 0x0E
#define LCD_DISP_ON_CURS_OFF 0x0C //Display on, cursor off
#define LCD_DISPLAY_OFF 0x08
#define LCD_DISPLAY_ON 0x04
#define LCD_CLEAR_DISPLAY 0x01
#define LCD_ENTRY_MODE_SET 0x04
#define LCD_INCREMENT_CURSER 0x06
#define LCD_SET_ROW1_COL1 0x80 //Force cursor to beginning ( 1st line)
#define LCD_SET_ROW2_COL1 0xC0 //Force cursor to beginning ( 2nd line)
#define LCD_MOVE_DISPLAY_LEFT 0x18
#define LCD_MOVE_DISPLAY_RIGHT 0x1C
#define LCD_CREATE_CHAR 0x40

#define SLAVE_ADDRESS_LCD 0x34<<1 // change this according to ur setup
#define LCD_BACKLIGHT 0x08
#define LCD_NOBACKLIGHT 0x00
#define EN 0x04
#define RS 0x01

static I2C_HandleTypeDef *hi2c1;

// https://maxpromer.github.io/LCD-Character-Creator/
Expand Down Expand Up @@ -146,4 +123,4 @@ void lcd_set_number_people(int n_people, int max_people){
lcd_send_string(" ");
lcd_send_string(num_char);
lcd_send_string(" ");
}
}
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ static void MX_GPIO_Init(void) {
GPIO_InitTypeDef GPIO_InitStruct;

/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();

GPIO_InitStruct.Pin = RED_LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // pin 6 as pull up
Expand Down

0 comments on commit 101cf42

Please sign in to comment.