Revision 9:d3875959a370, committed 2021-01-10
- Comitter:
- JLarkin
- Date:
- Sun Jan 10 20:28:36 2021 +0000
- Parent:
- 8:308d188a2d3a
- Commit message:
- Updated for Mbed OS 6: short wait to wait_us and long wait to sleep_for
Changed in this revision
diff -r 308d188a2d3a -r d3875959a370 TextLCD.cpp
--- a/TextLCD.cpp Thu Jan 02 21:07:01 2014 +0000
+++ b/TextLCD.cpp Sun Jan 10 20:28:36 2021 +0000
@@ -1,4 +1,13 @@
/* mbed TextLCD Library, for a 4-bit LCD based on HD44780
+ * Copyright (c) 2021 jlarkin, <jlarkin@whitworth.edu>
+ *
+ * Modified for compatibility under Mbed OS 6
+ * - explicit import of Stream.h
+ * - wait statements longer than 1 ms converted to ThisThread::sleep_for
+ * and rounded up to nearest ms
+ * - wait statements shorter than 1 ms converted to wait_us
+ *
+ * A fork of Simon Ford's mbed TextLCD library
* Copyright (c) 2007-2010, sford, http://mbed.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -31,15 +40,15 @@
_e = 1;
_rs = 0; // command mode
- wait(0.015); // Wait 15ms to ensure powered up
+ ThisThread::sleep_for(15ms); // Wait 15ms to ensure powered up
// send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus)
for (int i=0; i<3; i++) {
writeByte(0x3);
- wait(0.00164); // this command takes 1.64ms, so wait for it
+ ThisThread::sleep_for(2ms); // this command takes 1.64ms, so wait for it
}
writeByte(0x2); // 4-bit mode
- wait(0.000040f); // most instructions take 40us
+ wait_us(40); // most instructions take 40us
writeCommand(0x28); // Function set 001 BW N F - -
writeCommand(0x0C);
@@ -55,7 +64,7 @@
void TextLCD::cls() {
writeCommand(0x01); // cls, and set cursor to 0
- wait(0.00164f); // This command takes 1.64 ms
+ ThisThread::sleep_for(2ms); // This command takes 1.64 ms
locate(0, 0);
}
@@ -91,14 +100,14 @@
void TextLCD::writeByte(int value) {
_d = value >> 4;
- wait(0.000040f); // most instructions take 40us
+ wait_us(40); // most instructions take 40us
_e = 0;
- wait(0.000040f);
+ wait_us(40);
_e = 1;
_d = value >> 0;
- wait(0.000040f);
+ wait_us(40);
_e = 0;
- wait(0.000040f); // most instructions take 40us
+ wait_us(40); // most instructions take 40us
_e = 1;
}
diff -r 308d188a2d3a -r d3875959a370 TextLCD.h
--- a/TextLCD.h Thu Jan 02 21:07:01 2014 +0000
+++ b/TextLCD.h Sun Jan 10 20:28:36 2021 +0000
@@ -1,4 +1,13 @@
/* mbed TextLCD Library, for a 4-bit LCD based on HD44780
+ * Copyright (c) 2021 jlarkin, <jlarkin@whitworth.edu>
+ *
+ * Modified for compatibility under Mbed OS 6
+ * - explicit import of Stream.h
+ * - wait statements longer than 1 ms converted to ThisThread::sleep_for
+ * and rounded up to nearest ms
+ * - wait statements shorter than 1 ms converted to wait_us
+ *
+ * A fork of Simon Ford's mbed TextLCD library
* Copyright (c) 2007-2010, sford, http://mbed.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,7 +32,8 @@
#ifndef MBED_TEXTLCD_H
#define MBED_TEXTLCD_H
-#include "mbed.h"
+#include <mbed.h>
+#include <platform/Stream.h>
/** A TextLCD interface for driving 4-bit HD44780-based LCDs
*