From 707de9c1bcd43bcade123204c5edd95db028b76b Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Mon, 7 Nov 2022 14:46:34 +0900 Subject: [PATCH] add ino program for display 1.28 round screen --- jsk_spot_robot/README.md | 19 ++ .../ino/lcd_128/FreeSansBold10pt7b.h | 251 ++++++++++++++++ .../jsk_spot_startup/ino/lcd_128/example.py | 38 +++ .../jsk_spot_startup/ino/lcd_128/lcd_128.ino | 267 ++++++++++++++++++ 4 files changed, 575 insertions(+) create mode 100644 jsk_spot_robot/jsk_spot_startup/ino/lcd_128/FreeSansBold10pt7b.h create mode 100755 jsk_spot_robot/jsk_spot_startup/ino/lcd_128/example.py create mode 100644 jsk_spot_robot/jsk_spot_startup/ino/lcd_128/lcd_128.ino diff --git a/jsk_spot_robot/README.md b/jsk_spot_robot/README.md index 9f642f4988..43826a96af 100644 --- a/jsk_spot_robot/README.md +++ b/jsk_spot_robot/README.md @@ -120,3 +120,22 @@ roscd jsk_spot_startup/apps/head_lead_demo #### Install apps If you would like to call your apps from rwt_app_chooser, you can + +## Setup Developmenet Environment for 1.28 round LCD monitor + +- Setup Arduino IDE + - Add followingn Board Manager URLs (File -> Preference -> Additional Boards Manager URLs -> Click icon) + - `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json` + - Install `esp32` by Espressif Systems 2.0.5 (Tools -> Board -> Boards Manager) + - Install following libraries (Tools -> Manage Libraries) + - `ArduinoSTL` by Mike Matera 1.3.3 + - `GFX Library for Arduino` by Moon On Our Nation 1.3.0 + +- Layout + - Use https://dronebotworkshop.com/gc9a01/#ESP32_Hookup information, but you need to check actual pinout from https://learn.adafruit.com/adafruit-huzzah32-esp32-feather/pinouts + +- Upload image file + - Put your image data under `data/` directory. + - Download `arduino-esp32fs-plugin` from `https://github.com/lorol/arduino-esp32fs-plugin/releases` + - Put `esp32fs.jar` into tool direcotry (Arduino/tools/ESP32FS/tool/esp32fs.jar). + - Noete that upload plugin does not work ArduinoIDE >2.0, You need to use ArduinoIDE 1.x diff --git a/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/FreeSansBold10pt7b.h b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/FreeSansBold10pt7b.h new file mode 100644 index 0000000000..5a16222c37 --- /dev/null +++ b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/FreeSansBold10pt7b.h @@ -0,0 +1,251 @@ +#ifndef FreeSansBold10pt7b_H +#define FreeSansBold10pt7b_H + +#ifdef __AVR__ +#include +#include +#elif defined(ESP8266) +#include +#undef PROGMEM +#define PROGMEM STORE_ATTR +#elif defined(__IMXRT1052__) || defined(__IMXRT1062__) +// PROGMEM is defefind for T4 to place data in specific memory section +#undef PROGMEM +#define PROGMEM +#else +#define PROGMEM +#endif + +const uint8_t FreeSansBold10pt7bBitmaps[] PROGMEM = { + 0x00, 0xFF, 0xFF, 0xFE, 0x48, 0x7F, 0xC0, 0xE7, 0xE7, 0xE7, 0xE7, 0x42, + 0x0C, 0xC3, 0x39, 0xFF, 0xBF, 0xF7, 0xFE, 0x73, 0x0C, 0xE7, 0xFE, 0xFF, + 0xDF, 0xF9, 0x8C, 0x33, 0x06, 0x60, 0x08, 0x0F, 0x87, 0xFB, 0xFE, 0xEB, + 0xFA, 0x7F, 0x81, 0xF8, 0x1F, 0x82, 0xFE, 0x9F, 0xAF, 0xFF, 0xDF, 0xE3, + 0xE0, 0x20, 0x3C, 0x08, 0x3F, 0x0C, 0x3F, 0xC4, 0x18, 0x66, 0x0F, 0xF2, + 0x03, 0xF3, 0x00, 0xF3, 0x00, 0x01, 0x1C, 0x01, 0x9F, 0x00, 0x9F, 0xC0, + 0xCC, 0x60, 0x47, 0xF0, 0x61, 0xF0, 0x60, 0x70, 0x0F, 0x00, 0xFC, 0x0F, + 0xF0, 0x73, 0x83, 0x9C, 0x0F, 0xC0, 0x78, 0x0F, 0xF6, 0xE3, 0xF7, 0x0F, + 0x3C, 0x79, 0xFF, 0xE7, 0xFB, 0x0F, 0x9C, 0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, 1, 6, 0, 0 }, // 0x20 ' ' + { 1, 3, 14, 7, 2, -13 }, // 0x21 '!' + { 7, 8, 5, 9, 1, -14 }, // 0x22 '"' + { 12, 11, 13, 11, 0, -12 }, // 0x23 '#' + { 30, 10, 16, 11, 1, -14 }, // 0x24 '$' + { 50, 17, 14, 18, 0, -13 }, // 0x25 '%' + { 80, 13, 14, 14, 1, -13 }, // 0x26 '&' + { 103, 3, 5, 5, 1, -14 }, // 0x27 ''' + { 105, 6, 19, 7, 1, -14 }, // 0x28 '(' + { 120, 6, 19, 7, 0, -14 }, // 0x29 ')' + { 135, 7, 6, 8, 0, -14 }, // 0x2A '*' + { 141, 9, 9, 12, 2, -8 }, // 0x2B '+' + { 152, 3, 6, 5, 1, -2 }, // 0x2C ',' + { 155, 5, 3, 7, 1, -6 }, // 0x2D '-' + { 157, 3, 3, 5, 1, -2 }, // 0x2E '.' + { 159, 5, 14, 6, 0, -13 }, // 0x2F '/' + { 168, 10, 14, 11, 1, -13 }, // 0x30 '0' + { 186, 6, 14, 11, 2, -13 }, // 0x31 '1' + { 197, 9, 14, 11, 1, -13 }, // 0x32 '2' + { 213, 9, 14, 11, 1, -13 }, // 0x33 '3' + { 229, 9, 14, 11, 1, -13 }, // 0x34 '4' + { 245, 10, 14, 11, 1, -13 }, // 0x35 '5' + { 263, 10, 14, 11, 1, -13 }, // 0x36 '6' + { 281, 9, 14, 11, 1, -13 }, // 0x37 '7' + { 297, 11, 14, 11, 0, -13 }, // 0x38 '8' + { 317, 9, 14, 11, 1, -13 }, // 0x39 '9' + { 333, 3, 10, 5, 1, -9 }, // 0x3A ':' + { 337, 3, 13, 5, 1, -9 }, // 0x3B ';' + { 342, 10, 10, 12, 1, -9 }, // 0x3C '<' + { 355, 10, 8, 12, 1, -8 }, // 0x3D '=' + { 365, 10, 10, 12, 1, -9 }, // 0x3E '>' + { 378, 10, 15, 12, 1, -14 }, // 0x3F '?' + { 397, 18, 18, 20, 1, -14 }, // 0x40 '@' + { 438, 14, 15, 14, 0, -14 }, // 0x41 'A' + { 465, 11, 15, 14, 2, -14 }, // 0x42 'B' + { 486, 13, 15, 14, 1, -14 }, // 0x43 'C' + { 511, 12, 15, 14, 2, -14 }, // 0x44 'D' + { 534, 10, 15, 13, 2, -14 }, // 0x45 'E' + { 553, 10, 15, 13, 2, -14 }, // 0x46 'F' + { 572, 13, 15, 15, 1, -14 }, // 0x47 'G' + { 597, 11, 15, 15, 2, -14 }, // 0x48 'H' + { 618, 3, 15, 6, 2, -14 }, // 0x49 'I' + { 624, 9, 15, 11, 1, -14 }, // 0x4A 'J' + { 641, 13, 15, 15, 2, -14 }, // 0x4B 'K' + { 666, 9, 15, 12, 2, -14 }, // 0x4C 'L' + { 683, 14, 15, 17, 2, -14 }, // 0x4D 'M' + { 710, 11, 15, 15, 2, -14 }, // 0x4E 'N' + { 731, 14, 15, 16, 1, -14 }, // 0x4F 'O' + { 758, 11, 15, 14, 2, -14 }, // 0x50 'P' + { 779, 14, 15, 16, 1, -14 }, // 0x51 'Q' + { 806, 12, 15, 14, 2, -14 }, // 0x52 'R' + { 829, 12, 15, 14, 1, -14 }, // 0x53 'S' + { 852, 11, 15, 13, 1, -14 }, // 0x54 'T' + { 873, 11, 15, 15, 2, -14 }, // 0x55 'U' + { 894, 13, 15, 13, 0, -14 }, // 0x56 'V' + { 919, 19, 15, 19, 0, -14 }, // 0x57 'W' + { 955, 13, 15, 13, 0, -14 }, // 0x58 'X' + { 980, 13, 15, 13, 0, -14 }, // 0x59 'Y' + { 1005, 11, 15, 12, 1, -14 }, // 0x5A 'Z' + { 1026, 5, 19, 7, 1, -14 }, // 0x5B '[' + { 1038, 6, 14, 6, 0, -13 }, // 0x5C '\' + { 1049, 5, 19, 7, 0, -14 }, // 0x5D ']' + { 1061, 9, 9, 12, 1, -13 }, // 0x5E '^' + { 1072, 12, 2, 11, 0, 3 }, // 0x5F '_' + { 1075, 4, 3, 5, 0, -14 }, // 0x60 '`' + { 1077, 10, 11, 11, 1, -10 }, // 0x61 'a' + { 1091, 11, 15, 12, 1, -14 }, // 0x62 'b' + { 1112, 10, 11, 11, 1, -10 }, // 0x63 'c' + { 1126, 10, 15, 12, 1, -14 }, // 0x64 'd' + { 1145, 10, 11, 12, 1, -10 }, // 0x65 'e' + { 1159, 6, 15, 7, 1, -14 }, // 0x66 'f' + { 1171, 10, 15, 12, 1, -10 }, // 0x67 'g' + { 1190, 10, 15, 12, 1, -14 }, // 0x68 'h' + { 1209, 3, 15, 6, 1, -14 }, // 0x69 'i' + { 1215, 4, 19, 6, 0, -14 }, // 0x6A 'j' + { 1225, 10, 15, 11, 1, -14 }, // 0x6B 'k' + { 1244, 3, 15, 5, 1, -14 }, // 0x6C 'l' + { 1250, 16, 11, 18, 1, -10 }, // 0x6D 'm' + { 1272, 10, 11, 12, 1, -10 }, // 0x6E 'n' + { 1286, 11, 11, 12, 1, -10 }, // 0x6F 'o' + { 1302, 11, 15, 12, 1, -10 }, // 0x70 'p' + { 1323, 10, 15, 12, 1, -10 }, // 0x71 'q' + { 1342, 6, 11, 8, 1, -10 }, // 0x72 'r' + { 1351, 10, 11, 11, 1, -10 }, // 0x73 's' + { 1365, 5, 13, 7, 1, -12 }, // 0x74 't' + { 1374, 10, 11, 12, 1, -10 }, // 0x75 'u' + { 1388, 11, 11, 11, 0, -10 }, // 0x76 'v' + { 1404, 15, 11, 16, 0, -10 }, // 0x77 'w' + { 1425, 11, 11, 11, 0, -10 }, // 0x78 'x' + { 1441, 11, 15, 11, 0, -10 }, // 0x79 'y' + { 1462, 9, 11, 10, 1, -10 }, // 0x7A 'z' + { 1475, 5, 19, 8, 0, -14 }, // 0x7B '{' + { 1487, 1, 19, 6, 2, -14 }, // 0x7C '|' + { 1490, 5, 19, 8, 2, -14 }, // 0x7D '}' + { 1502, 9, 4, 10, 0, -6 } }; // 0x7E '~' + +const GFXfont FreeSansBold10pt7b PROGMEM = { + (uint8_t *)FreeSansBold10pt7bBitmaps, + (GFXglyph *)FreeSansBold10pt7bGlyphs, + 0x20, 0x7E, 24 }; + +// Approx. 2179 bytes + +#endif // FreeSansBold10pt7b_H diff --git a/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/example.py b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/example.py new file mode 100755 index 0000000000..e5a77d3930 --- /dev/null +++ b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/example.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import rospy +import cv2 +import numpy as np +import sys +from sensor_msgs.msg import CompressedImage + + +rospy.init_node('pub_compressed_image_example') +image = cv2.imread(sys.argv[1] if len(sys.argv) > 1 else '/usr/share/pixmaps/faces/legacy/penguin.jpg') +image = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY) # Comment out if you want to send color data +pub = rospy.Publisher('image/compressed', CompressedImage) +msg = CompressedImage() +msg.header.stamp = rospy.Time.now() +msg.format = 'jpeg' +msg.data = np.array(cv2.imencode('.jpg', image)[1]).tostring() +rospy.loginfo("Sending {}-byte data".format(len(msg.data))) + +cv2.imshow('image', image) +rospy.loginfo('C-c or hit any key on images to stop publishing') + +# test because wd can no send imagecompress?? +from os import listdir +from os.path import isfile, join +images = [ join('/', f) for f in listdir('data') if isfile(join('data', f)) ] +images_i = 0; +msg.data = [] +rate = rospy.Rate(10) +while (not rospy.is_shutdown()) and cv2.waitKey(1) < 0: + msg.format = images[images_i%len(images)] + images_i+=1 + pub.publish(msg) + rate.sleep() + + + + diff --git a/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/lcd_128.ino b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/lcd_128.ino new file mode 100644 index 0000000000..823494ff24 --- /dev/null +++ b/jsk_spot_robot/jsk_spot_startup/ino/lcd_128/lcd_128.ino @@ -0,0 +1,267 @@ +#if 0 +#include + +int Power = 11; +int PIN = 12; +#define NUMPIXELS 1 + +Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800); +#endif + +// On ESP32, ros.h need to be fixed see https://github.com/espressif/arduino-esp32/issues/4807 +#include +#include + +// https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html +#include + +// https://github.com/Bodmer/TJpg_Decoder +#include + +// https://github.com/moononournation/Arduino_GFX/ +#include + +/* Adafruit HUZZAH32 ESP32 Feather +https://www.instructables.com/ArduinoGFX/ +DIN 23 +CLK 18 +CS 5 +DC 27 +RST 33 +BL 22 + */ + +// https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class#spi +Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, GFX_NOT_DEFINED /* MISO */, VSPI /* spi_num */); + +// https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class#spi +Arduino_GFX *gfx = new Arduino_GC9A01(bus, 33 /* RST */, 0 /* rotation */, true /* IPS */); + +// more fonts at: https://github.com/moononournation/ArduinoFreeFontFile.git +#include "FreeSansBold10pt7b.h" + +// +uint16_t hsi2rgb(int h, int i, float s); + +// +#include +class BitmapImage +{ + public: + BitmapImage() { + } + + String filename; + uint16_t width; + uint16_t height; + //uint16_t buffer[240*240]; + //uint16_t *buffer PROGMEM; +}; + +typedef std::vector ImageList; +ImageList images; + +// https://answers.ros.org/question/208079/rosserial-arduino-custom-message-message-larger-than-buffer/ +// +//ros::NodeHandle_ nh; // 32768 = 128 * 256 +ros::NodeHandle nh; + +void imageCb(const sensor_msgs::CompressedImage& msg) { + char log[255]; + sprintf(log, "cb %s %d", msg.format, msg.data_length); + nh.loginfo(log); + TJpgDec.drawFsJpg(0, 0, msg.format, LittleFS); +} + +ros::Subscriber sub("image/compressed", &imageCb); + +// +uint16_t* image_buf; +uint16_t image_width = 0; +bool output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap) +{ +#if 0 + //image_buf = new uint16_t[w*h]; + char txt[256]; + sprintf(txt, "%p : %d : %d %d %d %d", image_buf, image_width, x, y, w, h); + gfx->println(txt); + for(int i = 0; i < h; i++) { + for(int j = 0; j < w; j++) { + image_buf[(y+i)*image_width+(x+j)] = bitmap[i*w+j]; + } + } +#endif + gfx->draw16bitRGBBitmap(x, y, bitmap, w, h); + + // Return 1 to decode next block + return 1; +} + +void setup() +{ + // Initialize ROS + nh.initNode(); + nh.subscribe(sub); + nh.loginfo(".. initialized ROS"); + + // Setup LED + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, HIGH); + nh.loginfo(".. initialized LED"); + + // Setup GFX + gfx->begin(); + gfx->fillScreen(BLACK); + +#ifdef GFX_BL + pinMode(GFX_BL, OUTPUT); + digitalWrite(GFX_BL, HIGH); +#endif + + gfx->setFont(&FreeSansBold10pt7b); + gfx->setTextColor(WHITE); + gfx->setCursor(0,120+4); + nh.loginfo(".. initialized GFX"); + + // Setup LittleFS + if (!LittleFS.begin()) { + gfx->setTextColor(RED); + gfx->setCursor(10,120-5); + gfx->println("File System Mount Failed!"); + nh.logerror("File System Mount Failed!"); + return; + } + + // list up images + File root = LittleFS.open("/"); + File file = root.openNextFile(); + while ( file ) { + if ( file.isDirectory() ) { continue; } + BitmapImage image; + image.filename = String(file.name()); + images.push_back(image); + file = root.openNextFile(); + } + root.close(); + nh.loginfo(".. initialized LittleFS"); + // get image size, store bitmap data + nh.loginfo(".. loading..."); + TJpgDec.setJpgScale(1); + TJpgDec.setCallback(output); + gfx->setCursor(0,120); + for (ImageList::iterator it = images.begin(); it != images.end(); it++ ) { + char filename[256]; + sprintf(filename, "/%s", it->filename.c_str()); + gfx->println(filename); + TJpgDec.getFsJpgSize(&it->width, &it->height, filename, LittleFS); + //it->buffer = (uint16_t *)malloc(sizeof(uint16_t)*it->width*it->height); + //it->buffer = buffer; +#if 0 + if ( it->buffer == nullptr) { + gfx->setTextColor(RED); + gfx->setCursor(10,120-5); + gfx->println("malloc failed"); + nh.logerror("malloc failed"); + return; + } +#endif + //image_buf = it->buffer; + //image_width = it->width; + // use drawFsJpg to store bitmap buffer to images + //TJpgDec.drawFsJpg(0, 0, filename, LittleFS); + } + // display + for(int y = 240; y > (int)(images.size())*-20; y-=4) { + gfx->fillScreen(BLACK); + gfx->setCursor(0,y); + for (ImageList::iterator it = images.begin(); it != images.end(); it++ ) { + const char* message = String(it->filename + " " + String(it->width) + ", " + String(it->height)).c_str(); + gfx->println(message); + nh.loginfo(message); + } + } + + // Show initial demonstration + for(int r = 120; r >= 0; r-=1) { + uint16_t rgb = hsi2rgb(240*pow(r/120.0, 2), 255, 1); + gfx->drawCircle(120, 120, r, rgb); + } +#if 0 + int rgb = 0x0000; + char rgb_text[32]; + for(unsigned int r = 0; r < 256; r+=63) { + for(unsigned int g = 0; g < 256; g+=63) { + for(unsigned int b = 0; b < 256; b+=63) { + rgb = ((r>>3) << 11) + ((g>>2) << 5) + (b>>3); + gfx->fillScreen(rgb); + gfx->setCursor(120-10*2,120-5); + sprintf(rgb_text, "%04X", rgb); + gfx->println(rgb_text); + yield(); + } + } + } +#endif + gfx->fillScreen(BLACK); + + // send dummy compressed image + sensor_msgs::CompressedImage msg = sensor_msgs::CompressedImage(); + msg.format = "/ubuntu-logo-icon.jpg"; + imageCb((const sensor_msgs::CompressedImage &)msg); +} + +static int loop_count = 0; +void loop() +{ + loop_count += 1; + // Blink LED + if (loop_count % 10000 == 0) { + digitalWrite(13, HIGH-digitalRead(13)); + nh.loginfo("loop"); + } + +#if 0 + pixels.clear(); + pixels.setPixelColor(0, pixels.Color(15, 15, 205)); + delay(400); + pixels.show(); + + pixels.clear(); + pixels.setPixelColor(0, pixels.Color(15, 205, 15)); + delay(400); + pixels.show(); + + pixels.clear(); + pixels.setPixelColor(0, pixels.Color(205, 15, 15)); + delay(400); + pixels.show(); +#endif + + // ROS Spinning... + nh.spinOnce(); +} + +// hsi -> rgb +uint16_t hsi2rgb(int h, int i, float s) { + // 0 <= h < 360, 0 <= i < 256, 0 <= s <= 1 + int r, g, b; + float hh = h / 180.0 * M_PI; + if ( h < 120) { + r = i + i * s * cos(hh) / cos(M_PI/3 - hh); + g = i + i * s * (1 - (cos(hh) / cos(M_PI/3 - hh))); + b = i - i * s; + } else if ( h < 240 ) { + r = i - i * s; + g = i + i * s * cos(hh-M_PI*2/3) / cos(M_PI - hh); + b = i + i * s * (1 - (cos(hh-M_PI*2/3) / cos(M_PI - hh))); + } else { + r = i + i * s * (1 - (cos(hh-M_PI*4/3) / cos(M_PI*5/3 - hh))); + g = i - i * s; + b = i + i * s * cos(hh-M_PI*4/3) / cos(M_PI*5/3 - hh); + } + if ( r > 255 ) r = 255; if ( r < 0 ) r = 0; + if ( g > 255 ) g = 255; if ( g < 0 ) g = 0; + if ( b > 255 ) b = 255; if ( b < 0 ) b = 0; + // + return ((r>>3) << 11) + ((g>>2) << 5) + (b>>3); +}