driver, hd44780: add tests application
This commit is contained in:
parent
51d89fabbb
commit
8acb068dec
|
@ -0,0 +1,14 @@
|
|||
APPLICATION = driver_hd44780
|
||||
include ../Makefile.tests_common
|
||||
|
||||
# the stm32f4discovery does not have the arduino pinout
|
||||
BOARD_BLACKLIST := stm32f4discovery
|
||||
# currently the test provides config params for arduinos only
|
||||
FEATURES_REQUIRED += arduino
|
||||
|
||||
USEMODULE += hd44780
|
||||
|
||||
test:
|
||||
tests/01-run.py
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
|
@ -0,0 +1,27 @@
|
|||
# About
|
||||
|
||||
This is a test application for the HD44780 LCD driver. This display comes with
|
||||
many Arduino starter kits under the name of LCM1602C, and typically has 16x2
|
||||
columns and rows.
|
||||
|
||||
# Details
|
||||
|
||||
This test application will initialize the HD44780 driver with the configuration
|
||||
as specified in the default `hd44780_params.h` file. To connect the display with
|
||||
your board use the following minimal pinout for the LCD (i.e., Arduino here):
|
||||
|
||||
- Pin 1 is connected directly to GND.
|
||||
- Pin 2 is connected directly to VCC +5V.
|
||||
- Pin 3 is used to set LCD contrast, for max use +5V or a 10k potentiometer.
|
||||
- Pin 4 (RS or “register select”) is connected to pin 2 on the Arduino
|
||||
- Pin 5 (RW or “read/write”) is connected directly to GND, i.e., unused.
|
||||
Also note: if you connect RW to your board that the LCD is driven by 5V, while
|
||||
many boards internally run at 3.3V - so this could fry the board :/
|
||||
- Pin 6 (EN or “enable”) is connected to pin 3 on the Arduino.
|
||||
- Pins 7 – 10: Not connected.
|
||||
- Pin 11 on the LCD is connected to pin 4 on the Arduino.
|
||||
- Pin 12 on the LCD is connected to pin 5 on the Arduino.
|
||||
- Pin 13 on the LCD is connected to pin 6 on the Arduino.
|
||||
- Pin 14 on the LCD is connected to pin 7 on the Arduino.
|
||||
- Pin 15 is connected to one end of a 1k resistor, and its other end to VCC +5V.
|
||||
- Pin 16 is connected directly to GND.
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2017 HAW Hamburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup drivers_hd44780
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief Pinout config for the HD44780 display
|
||||
*
|
||||
* @author Sebastian Meiling <s@mlng.net>
|
||||
*/
|
||||
#ifndef HD44780_PARAMS_H
|
||||
#define HD44780_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "hd44780.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define HD44780_PARAMS_ARDUINO { \
|
||||
.cols = 16, \
|
||||
.rows = 2, \
|
||||
.rs = ARDUINO_PIN_2, \
|
||||
.rw = HD44780_RW_OFF, \
|
||||
.enable = ARDUINO_PIN_3, \
|
||||
.data = {ARDUINO_PIN_4, ARDUINO_PIN_5, ARDUINO_PIN_6, ARDUINO_PIN_7, \
|
||||
HD44780_RW_OFF, HD44780_RW_OFF, HD44780_RW_OFF, HD44780_RW_OFF} \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LCM1602C configuration
|
||||
*/
|
||||
static const hd44780_params_t hd44780_params[] =
|
||||
{
|
||||
HD44780_PARAMS_ARDUINO,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HD44780_PARAMS_H */
|
||||
/** @} */
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (C) 2017 HAW Hamburg
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test application for Arduino LCM1602C LCD
|
||||
*
|
||||
* @author Sebastian Meiling <s@mlng.net>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "hd44780.h"
|
||||
#include "hd44780_params.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
hd44780_t dev;
|
||||
/* init display */
|
||||
puts("[START]");
|
||||
if (hd44780_init(&dev, &hd44780_params[0]) != 0) {
|
||||
puts("[FAILED]");
|
||||
return 1;
|
||||
}
|
||||
/* clear screen, reset cursor */
|
||||
hd44780_clear(&dev);
|
||||
hd44780_home(&dev);
|
||||
/* write first line */
|
||||
hd44780_print(&dev, "Hello World ...");
|
||||
xtimer_sleep(1);
|
||||
/* set cursor to second line and write */
|
||||
hd44780_set_cursor(&dev, 0, 1);
|
||||
hd44780_print(&dev, " RIOT is here!");
|
||||
xtimer_sleep(3);
|
||||
/* clear screen, reset cursor */
|
||||
hd44780_clear(&dev);
|
||||
hd44780_home(&dev);
|
||||
/* write first line */
|
||||
hd44780_print(&dev, "The friendly IoT");
|
||||
/* set cursor to second line and write */
|
||||
hd44780_set_cursor(&dev, 0, 1);
|
||||
hd44780_print(&dev, "Operating System");
|
||||
|
||||
puts("[SUCCESS]");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
# 2017 Sebastian Meiling <s@mlng.net>
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
|
||||
import testrunner
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact("[START]")
|
||||
child.expect_exact("[SUCCESS]")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(testrunner.run(testfunc))
|
Loading…
Reference in New Issue