Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:031024851a8d, committed 2020-08-05
- Comitter:
- kenjiArai
- Date:
- Wed Aug 05 05:11:23 2020 +0000
- Parent:
- 2:9bb0b4c70b43
- Child:
- 4:9d99684c6373
- Commit message:
- changed printf() and lib. for running on mbed-os6.2.0
Changed in this revision
--- a/ST7565_SPI_LCD.lib Mon Dec 01 23:20:16 2014 +0000 +++ b/ST7565_SPI_LCD.lib Wed Aug 05 05:11:23 2020 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/kenjiArai/code/ST7565_SPI_LCD/#a1fc999cd8f3 +http://mbed.org/users/kenjiArai/code/ST7565_SPI_LCD/#233a0d635d9d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/check_revision.cpp Wed Aug 05 05:11:23 2020 +0000
@@ -0,0 +1,27 @@
+/*
+ * Check Mbed revision
+ *
+ * Copyright (c) 2019,'20 Kenji Arai / JH1PJL
+ * http://www7b.biglobe.ne.jp/~kenjia/
+ * https://os.mbed.com/users/kenjiArai/
+ * Created: July 17th, 2019
+ * Revised: August 1st, 2020
+ */
+
+#include "mbed.h"
+
+// RUN ONLY ON mbed-os-6.2.0
+// https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.2.0
+#if (MBED_MAJOR_VERSION == 6) &&\
+ (MBED_MINOR_VERSION == 2) &&\
+ (MBED_PATCH_VERSION == 0)
+#else
+# error "Please use mbed-os-6.2.0"
+#endif
+
+void print_revision(void)
+{
+ printf("MBED_MAJOR_VERSION = %d, ", MBED_MAJOR_VERSION);
+ printf("MINOR = %d, ", MBED_MINOR_VERSION);
+ printf("PATCH = %d\r\n", MBED_PATCH_VERSION);
+}
--- a/main.cpp Mon Dec 01 23:20:16 2014 +0000
+++ b/main.cpp Wed Aug 05 05:11:23 2020 +0000
@@ -1,95 +1,114 @@
/*
* mbed Application program for the mbed LPC1114FN28
*
- * AD-12864-SPI / 128 x 64 dots / Interface: SPI
- * http://www.aitendo.com/product/1622
- *
- * Copyright (c) 2014 Kenji Arai / JH1PJL
- * http://www.page.sannet.ne.jp/kenjia/index.html
- * http://mbed.org/users/kenjiArai/
+ * Copyright (c) 2014,'20 Kenji Arai / JH1PJL
+ * http://www7b.biglobe.ne.jp/~kenjia/
+ * https://os.mbed.com/users/kenjiArai/
* Created: September 14th, 2014
* Revised: September 21st, 2014
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * Revised: August 5th, 2020
+ */
+/*
+ Tested LCD
+ 1) AD-12864-SPI / 128 x 64 dots / Interface: SPI
+ http://www.aitendo.com/product/1622
+
+ 1)CSI 2)RES 3)A0 4)SCK 5)SDI 6)3.3V 7)GND 8)LED_A
+ dp9 dp10 dp4 dp6 dp2 +3.3V GND +3.3V(51 ohm)
+
+ 2) AE-AQM1248(AQM1248A-RN-FBW-P) / 128 x 48 dots / Interface: SPI
+ http://akizukidenshi.com/catalog/g/gK-07007/
+ http://akizukidenshi.com/catalog/g/gP-07005/
+
+ 1)VDD 2)/CS 3)/RES 4)RS 5)SCLK 6)SDI 7)GND
+ +3.3V dp9 dp10 dp4 dp6 dp2 GND
*/
-// Include ---------------------------------------------------------------------------------------
+// Include --------------------------------------------------------------------
#include "mbed.h"
#include "ST7565_SPI_LCD.h"
-// Definition ------------------------------------------------------------------------------------
-#define USE_COM // use Communication with PC(UART)
+// Definition -----------------------------------------------------------------
+//#define AITENDO
+#define AKIZUKI
-// Com
-#ifdef USE_COM
-#define BAUD(x) pcm.baud(x)
-#define GETC(x) pcm.getc(x)
-#define PUTC(x) pcm.putc(x)
-#define PRINTF(...) pcm.printf(__VA_ARGS__)
-#define READABLE(x) pcm.readable(x)
-#else
-#define BAUD(x) {;}
-#define GETC(x) {;}
-#define PUTC(x) {;}
-#define PRINTF(...) {;}
-#define READABLE(x) {;}
+#if defined(AITENDO) && defined(AKIZUKI)
+# error "Please choose one!!"
+#elif defined(AITENDO)
+# define MAX_Y 64
+# define CONTRAST 0x32
+#elif defined(AKIZUKI)
+# define MAX_Y 48
+# define CONTRAST 0x23
#endif
-// Object ----------------------------------------------------------------------------------------
+#define Y0 (MAX_Y - 2)
+#define Y1 (MAX_Y - 9)
+#define Y2 (MAX_Y - 1)
+
+// Object ---------------------------------------------------------------------
// LED
DigitalOut myled(dp28);
-#ifdef USE_COM
// com
-Serial pcm(dp16,dp15); // Communication with Host
-#endif
+BufferedSerial pc(dp16,dp15);
// SPI LCD
-#if 1
-ST7565 lcd(dp2, dp6, dp10, dp4, dp9, ST7565::AD12864SPI); // mosi, sck, reset, a0, ncs
-#else
-SPI spi_lcd(dp2, dp1, dp6); // mosi, miso, sck
-ST7565 lcd(spi_lcd, dp10, dp4, dp9, ST7565::AD12864SPI); // spi, reset, a0, ncs
-#endif
-#if 0
-ST7565 lcd(dp2, dp6, dp10, dp4, dp9, ST7565::AQM1248A); // mosi, sck, reset, a0, ncs
+#if defined(AITENDO)
+# if 1
+// mosi, sck, reset, a0, ncs
+ST7565 lcd(dp2, dp6, dp10, dp4, dp9, ST7565::AD12864SPI);
+# else
+// mosi, miso, sck
+SPI spi_lcd(dp2, dp1, dp6);
+// spi, reset, a0, ncs
+ST7565 lcd(spi_lcd, dp10, dp4, dp9, ST7565::AD12864SPI);
+# endif
+#elif defined(AKIZUKI)
+// mosi, sck, reset, a0, ncs
+ST7565 lcd(dp2, dp6, dp10, dp4, dp9, ST7565::AQM1248A);
#endif
-// RAM -------------------------------------------------------------------------------------------
-
-// ROM / Constant data ---------------------------------------------------------------------------
+// RAM ------------------------------------------------------------------------
-// Function prototypes ---------------------------------------------------------------------------
+// ROM / Constant data --------------------------------------------------------
-// Function prototypes ---------------------------------------------------------------------------
+// Function prototypes --------------------------------------------------------
-//-------------------------------------------------------------------------------------------------
+// Function prototypes --------------------------------------------------------
+uint8_t getc(void);
+void putc(uint8_t c);
+FileHandle *mbed::mbed_override_console(int fd);
+extern void print_revision(void);
+
+//------------------------------------------------------------------------------
// Control Program
-//-------------------------------------------------------------------------------------------------
-int main() {
-uint8_t c;
-uint8_t i,k = 0;
+//------------------------------------------------------------------------------
+int main()
+{
+ uint8_t c;
+ print_revision();
myled = 0;
lcd.cls();
- lcd.set_contrast(0x06);
+ lcd.set_contrast(CONTRAST);
lcd.printf("test\r\n" );
- lcd.printf("Kenji Arai / JH1PJL\r\n" );
+ lcd.printf("Run on mbed-os6.2.0\r\n" );
lcd.printf("ABCDEFG 1234567890\r\n" );
- lcd.rect(5,30,120,62,1);
+ //lcd.rect(5,30,120,62,1);
+ lcd.rect(5,30,120,Y0,1);
lcd.circle(5,35,5,1);
- lcd.fillcircle(60,55,5,1);
- lcd.line(0,30,127,63,1);
- PRINTF("\r\nJH1PJL\r\n");
- PRINTF("H:%d W:%d\r\n", lcd.height(), lcd.width());
- while(1){
+ //lcd.fillcircle(60,55,5,1);
+ lcd.fillcircle(60,Y1,5,1);
+ //lcd.line(0,30,127,63,1);
+ lcd.line(0,30,127,Y2,1);
+ printf("Graphic Display example, bin file created on " __DATE__ ".\r\n");
+ printf("You can see something on the LCD screen.\r\n");
+ printf("H:%d W:%d\r\n", lcd.height(), lcd.width());
+ while(true) {
#if 1
myled = !myled;
- c = GETC();
- PUTC(c);
- if (c == '\b'){
+ c = getc();
+ putc(c);
+ if (c == '\b') {
myled = 0;
break;
}
@@ -97,33 +116,52 @@
#else
// check best contrast
uint8_t px = 0;
- for (px = 0; px < 0x40; px++){
- c = GETC();
- lcd.set_contrast(px);
- PRINTF("0x%x\r\n",px);
- }
+ for (px = 0; px < 0x40; px++) {
+ c = getc();
+ lcd.set_contrast(px);
+ printf("0x%x\r\n",px);
+ }
#endif
}
- while(1){
+ while(true) {
+ uint8_t i,k = 0;
i = 10 - k;
k++;
- c = GETC();
- lcd.rect(10, i, 100, 50, 1);
- c = GETC();
+ c = getc();
+ lcd.rect(10, i, 100, Y1, 1);
+ c = getc();
lcd.circle(10,10,i,1);
- c = GETC();
+ c = getc();
lcd.fillcircle(50,40,i,1);
- c = GETC();
- lcd.line(0, 0, 110-i, 60, 1);
- c = GETC();
- if (c == '\b'){
+ c = getc();
+ lcd.line(0, 0, 110-i, Y1, 1);
+ c = getc();
+ if (c == '\b') {
myled = 0;
break;
}
}
- while(1){
+ while(true) {
lcd.cls();
lcd.locate(4, 32);
- lcd.printf("JH1PJL" );
+ lcd.printf("JH1PJL" );
}
}
+
+uint8_t getc(void)
+{
+ uint8_t bf;
+ pc.read(&bf,1);
+ return bf;
+}
+
+void putc(uint8_t c)
+{
+ uint8_t bf = c;
+ pc.write(&bf,1);
+}
+
+FileHandle *mbed::mbed_override_console(int fd)
+{
+ return &pc;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Aug 05 05:11:23 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#a2ada74770f043aff3e61e29d164a8e78274fcd4
--- a/mbed.bld Mon Dec 01 23:20:16 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Wed Aug 05 05:11:23 2020 +0000
@@ -0,0 +1,8 @@
+{
+ "requires": ["bare-metal"],
+ "target_overrides": {
+ "*": {
+ "target.printf_lib": "std"
+ }
+ }
+}