IOT-emoji 显示装置-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1913|回复: 3

IOT-emoji 显示装置

[复制链接]
发表于 2019-9-9 10:55 | 显示全部楼层 |阅读模式
本帖最后由 vany5921 于 2019-9-9 10:57 编辑

本项目将利用ESP32(M5StickC)制作一个局域网的Emoji显示屏

FABFSE7JU8N4W32.LARGE.jpg

1. 准备工作
images.jpeg FALTCNRJU8N4W3C.LARGE.jpg FYNL8RGJU8N4W4M.LARGE.jpg

ESP32 开发板
我们需要一个ESP32开发板,这里我选用了M5Stack,当然NodeMCU或者其他相同类型的开发板也是可以的。
NeoPixels项目中用到了Adafruit_NeoPixel 的库,因此各种可编程的LED都支持比如WS2812, WS2812B, SK6812, SK6812mini...,项目中使用了SK6812mini来制作8x8的点阵面板,当然你也可以买现成的LED点阵屏
底座
项目中使用了一个柔性可弯曲的USB连接线

2. 3D打印和装配(可选)
如果用的是8X8点阵屏可以直接跳过此步
FLXCWMIJU8N2R1V.LARGE.jpg FTNCHQNJU8N2R2W.LARGE.jpg F5267M1JU8N2R5J.LARGE.jpg

1.3D打印外壳 files.zip (54.03 KB, 下载次数: 2)
2.将SK6812旋转一定方向放入外壳中
3.焊接电路
4.将开发板用热熔胶粘到外壳内部(使用M5Stack可以省略)
5.固定USB供电接口,(使用M5Stack可以省略)
6.安装螺丝
由于项目需要显示8X8的emoji,从这里找到相关素材,修改图片的像素尺寸并且进行base64编码,以便嵌入到HTML网页中。

3.HTML界面制作
FUUQWXPJU8N50H6.LARGE.jpg
写一个HTML脚本来选择emoji并且传送到ESP32进行显示,在这里用了Web Socket协议传送二进制数据
[mw_shl_code=html,true]<!DOCTYPE html>
<html>

<head>
  <meta name='viewport' content='user-scalable=no,initial-scale=2.0' />
  <style>
    body {
      background: #000;
      color: #fff;
      text-align: center;
    }

    div {
      margin: 10px;
    }
  </style>
</head>

<body>
  <div>
      <h3>Pick An Emoji</h3>
      <img id='emojis'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H61OodapY6tQu4n++FArHnyrYa30KWHI6n+u4AQDL6uxTcYWEAAGj/995RXx/iSf5j+jSlhpEpqKBMzgVNBOO4vUHg/X44opnD5vMn8ebKkfP7AVKrd0YHnoZxnS+WMGCUnWQhHLU/GF7f7kHOg1xqNWh97CP6l61evRzE2U2uAPNWUeGgcgYGKZhXje0VaT63zATQST0dwdAesoNnDuHcXlVinkkzmmyOiASeMG0SCLXpLdaYfXFXOTCSXf9xt9hi40pHLUlsp1uOAgSHZJvYgpYtXjQu6thao46xVCYwBFHYZe8pxYvkItS/qBbf3EDHRevwIH3NwwCV7O0k1bQpFEgDw1G8iNm1P7ZrdGxOlekII5La5zfi3ks/PI6Xk4VoOGZ5sS2+XhN9Sm90mcRi9PJtr7WnonMieMcRBu0yasedaLTJ5Os1bJ/PLe9r3xtucwoppJBCCqk2ouVcXE+WFnslNvUysdHqtCW1wSl/cMrERgvsYprqBNidTS2/lc0xU8fUTGzlRuGfoLfHh1i51UpftanRIiAVVI8EJiIkWyP8VjYVsF8gU7xwk4PK5klzImukQnmigC+YP/eRdp7iFwsPP3FcXAql3WzyROzsl5RIkOzJJ1U23H/1/VcXAIDuTaeUiczAHmbGjHrvRWrJ1uPoUEhG61NXL4hsdZL7jxxhIwMTlpcfis2nDv/H5qQV6bXl7OjYAZlPgsGcLDWEdG9l1pIW16pTc6fU1Qs4u0IY9KTdoqM+FP26jI/X1TiRXhIvRdeR9RL1ifYFh45sqjKxpsawqeakikw37LJR91WoD0sH1ctT+eqmjo7aySSa6ovq/nfZIrw/Uu+kRFeS6aswohA9u9qBBwDAyScDk1OC4dc5do2IPlt1j6LxFaHU+joY0L/2/VcX/GIBfTJ+sfD9VxfEPaYaMMwwaL1D6sP/A7aQQgoppPuN/gPGU98FNpiT5gAAAABJRU5ErkJggg=='>
  </div>
  <div>
      <p id='out'></p>
      <canvas id='emoji' width='8' height='8'></canvas>
  </div>
  <script>
    function nw() { return new WebSocket('ws://' + location.hostname + ':81/', ['arduino']); }
    var ws = nw();

    function cc(c) {
      return String.fromCharCode(c / 64);
    }

    function clickEmoji(e) {
      var xo = 3;
      var yo = 3;
      var xs = 13;
      var ys = 12;
      var x = e.offsetX;
      var y = e.offsetY;
      var c = Math.round((x - xo - 4) / xs);
      var r = Math.round((y - yo - 4) / ys);

      document.getElementById('out').innerText = 'Selected [' + c + ', ' + r + ']';

      var img = document.getElementById('emojis');
      var ce = document.getElementById('emoji');
      var ctx = ce.getContext('2d');
      // ctx.drawImage(img, -(xo + (xs * c)), -(yo + (ys * r)), 131, 122);
      ctx.drawImage(img, -(xo + (xs * c)), -(yo + (ys * r)), 131, 122);

      var d = ctx.getImageData(0, 0, 8, 8).data;
      var t = '';
      for (var i = 0; i < 64; i++) {
        t += cc(d[(i * 4)]);
        t += cc(d[(i * 4) + 1]);
        t += cc(d[(i * 4) + 2]);
      }
      ws.send(t, { binary: true });
    }
  </script>
</body>

</html>[/mw_shl_code]


使用html-minifier将上述文件转换为单行代码,嵌入到arduino程序中。以下代码仅在M5StickC中进行测试验证,ESP32可参考

[mw_shl_code=arduino,true]#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <WebSocketsServer.h>
#include <ESPmDNS.h>
#include <Adafruit_NeoPixel.h>
#include <M5StickC.h>
#define NEOPIXEL_PIN 32
#define WIDTH 8
#define HEIGHT 8
#define ZIGZAG_MATRIX


const char *ssid = "M5STACK";
const char *password = "M5STACK";

WebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(WIDTH * HEIGHT, NEOPIXEL_PIN, NEO_RGB + NEO_KHZ400);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
  switch (type) {
    case WStype_DISCONNECTED:
      Serial.printf("[%u] Disconnected!\n", num);
      break;
    case WStype_CONNECTED: {
        IPAddress ip = webSocket.remoteIP(num);
        Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);

        // send message to client
        webSocket.sendTXT(num, "Connected");
      }
      break;
    case WStype_TEXT:
      Serial.printf("[%u] get Text[%u].\n", num, length);
      Serial.println(*payload);

      uint8_t i = 0;
      for (uint8_t y = 0; y < HEIGHT; y++) {
      for (uint8_t x = 0; x < WIDTH; x++) {
        uint8_t r = payload[i++];
        uint8_t g = payload[i++];
        uint8_t b = payload[i++];
#ifdef ZIGZAG_MATRIX
        uint16_t p = (y % 2) ? (((y + 1) * 8) - x - 1) : ((y * 8) + x);
#else
        uint16_t p = (y * 8) + x;
#endif
        pixels.setPixelColor(p, pixels.Color(r, g, b));
        Serial.printf("(%u, %u) [%u] color: %u, %u, %u\n", x, y, p, r, g, b);
      }
      }
      pixels.show(); // This sends the updated pixel color to the hardware.

      break;
  }
}

void handleNotFound() {
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";

  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }

  server.send(404, "text/plain", message);
}

void setup(void) {
  M5.begin();
  pixels.begin();
  pixels.fill(pixels.Color(0, 0, 0));
  pixels.show();
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.on("/", []() {
    server.send(200, "text/html", "<!DOCTYPE html><html><head><meta name='viewport' content='user-scalable=no,initial-scale=2.0' /><style>body{background:#000;color:#fff;text-align:center}div{margin:10px}</style></head><body><div><h3>Pick An Emoji</h3> <img id='emojis' onclick='clickEmoji(event);' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIMAAAB6CAIAAAATYnfgAAASWElEQVR42u1dTW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X44opnD5vMn8ebKkfP7AVKrd0YHnoZxnS+WMGCUnWQhHLU/GF7f7kHOg1xqNWh97CP6l61evRzE2U2uAPNWUeGgcgYGKZhXje0VaT63zATQST0dwdAesoNnDuHcXlVinkkzmmyOiASeMG0SCLXpLdaYfXFXOTCSXf9xt9hi40pHLUlsp1uOAgSHZJvYgpYtXjQu6thao46xVCYwBFHYZe8pxYvkItS/qBbf3EDHRevwIH3NwwCV7O0k1bQpFEgDw1G8iNm1P7ZrdGxOlekII5La5zfi3ks/PI6Xk4VoOGZ5sS2+XhN9Sm90mcRi9PJtr7WnonMieMcRBu0yasedaLTJ5Os1bJ/PLe9r3xtucwoppJBCCqk2ouVcXE+WFnslNvUysdHqtCW1wSl/cMrERgvsYprqBNidTS2/lc0xU8fUTGzlRuGfoLfHh1i51UpftanRIiAVVI8EJiIkWyP8VjYVsF8gU7xwk4PK5klzImukQnmigC+YP/eRdp7iFwsPP3FcXAql3WzyROzsl5RIkOzJJ1U23H/1/VcXAIDuTaeUiczAHmbGjHrvRWrJ1uPoUEhG61NXL4hsdZL7jxxhIwMTlpcfis2nDv/H5qQV6bXl7OjYAZlPgsGcLDWEdG9l1pIW16pTc6fU1Qs4u0IY9KTdoqM+FP26jI/X1TiRXhIvRdeR9RL1ifYFh45sqjKxpsawqeakikw37LJR91WoD0sH1ctT+eqmjo7aySSa6ovq/nfZIrw/Uu+kRFeS6aswohA9u9qBBwDAyScDk1OC4dc5do2IPlt1j6LxFaHU+joY0L/2/VcX/GIBfTJ+sfD9VxfEPaYaMMwwaL1D6sP/A7aQQgoppPuN/gPGU98FNpiT5gAAAABJRU5ErkJggg=='></div><div><p id='out'></p> <canvas id='emoji' width='8' height='8'></canvas></div> <script>function nw(){return new WebSocket('ws://'+location.hostname+':81/',['arduino']);} var ws=nw();function cc(c){return String.fromCharCode(c/64);} function clickEmoji(e){var xo=3;var yo=3;var xs=13;var ys=12;var x=e.offsetX;var y=e.offsetY;var c=Math.round((x-xo-4)/xs);var r=Math.round((y-yo-4)/ys);document.getElementById('out').innerText='Selected ['+c+', '+r+']';var img=document.getElementById('emojis');var ce=document.getElementById('emoji');var ctx=ce.getContext('2d');ctx.drawImage(img,-(xo+(xs*c)),-(yo+(ys*r)),131,122);var d=ctx.getImageData(0,0,8,8).data;var t='';for(var i=0;i<64;i++){t+=cc(d[(i*4)]);t+=cc(d[(i*4)+1]);t+=cc(d[(i*4)+2]);} ws.send(t,{binary:true});}</script> </body></html>");
  });
  server.onNotFound(handleNotFound);
  server.begin();
  Serial.println("HTTP server started");

  webSocket.begin();
  webSocket.onEvent(webSocketEvent);

  MDNS.addService("http", "tcp", 80);
  MDNS.addService("ws", "tcp", 81);
}

unsigned long last_10sec = 0;
unsigned int counter = 0;


void loop(void) {
  unsigned long t = millis();
  webSocket.loop();
  server.handleClient();
  if((t - last_10sec) > 10 *1000) {
    counter++;
    bool ping = (counter %2);
    int i = webSocket.connectedClients(ping);
    Serial.printf("d% Connected websocket clients ping: %d\n", i, ping);
    last_10sec = millis();
  }
}[/mw_shl_code]


发表于 2020-4-10 00:32 | 显示全部楼层
你好,请问led矩阵的电路是用什么方式连接的?
我也想做一个密集的led矩阵,但是不知道用PCB还是用3d打印来固定灯珠。
 楼主| 发表于 2020-4-10 09:49 | 显示全部楼层
aspendove 发表于 2020-4-10 00:32
你好,请问led矩阵的电路是用什么方式连接的?
我也想做一个密集的led矩阵,但是不知道用PCB还是用3d打印来 ...

PCB工作量小一些
发表于 2020-4-10 11:23 | 显示全部楼层

请问您的这块led板是怎么连接电路的?
感觉您的这种设计方式对我来说就比较理想了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-28 10:04 , Processed in 0.089603 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表