这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 活动中心 » 板卡试用 » 【TOPWAY7寸智能屏】04 TOPWAY智能屏网络应用之作业提示器

共1条 1/1 1 跳转至

【TOPWAY7寸智能屏】04 TOPWAY智能屏网络应用之作业提示器

高工
2021-09-05 22:23:50     打赏

  TOPWAY智能屏HMT070ETD-1D具有丰富电容通讯接口,USART,RS232,USB,以太网接口。本项目借助 TOPWAY智能屏网络功能开发一个学生作业提示器,家里小朋友一放学就玩手机,玩游戏,作业被抛到九霄云外。有必要做一个显示器,学校家长群学生作业,提示小朋友做完作业在玩。

   KK.png

W6.png

       TOPWAY智能屏已经把以太网转串口封装好了,相当于完成以太网转串口透传功能,用户不用考虑TCP/IP 网络拓扑。直接接入接入本地路由器就可以用了。

 

  方案框图:

   方案一:用额外WIFI模块可以省去网线,但是成本增加。

    方案二.png    方案二:

          TOPWAY智能屏模块通过网线直接连接到路由器,构建本地局域网。

方案一.png


作业提示器 GUI界面设定:


  TOPWAY智能屏具有强大的文本设计能力,简单明了。


image.png

    工程配置.png       TOPWAY智能屏本地局域网网络配置。SSCOM测试,IP地址要设定在本地局域网中。

   

#include <WiFi.h>

char ssid[] = "SSID";      //  your network SSID (name)
char pass[] = "password";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
WiFiServer server(5000);

void setup() {
  Serial1.begin(115200);
  Serial.begin(115200);      // initialize serial communication
  pinMode(9, OUTPUT);      // set the LED pin mode

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true);       // don't continue
  }

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);                   // print the network name (SSID);

    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();                           // start the tcp server on port 5000
  printWifiStatus();                        // you're connected now, so print out the status
}

char buffer[1000];
char Head_buff[] = {0xAA, 0x42, 0x00, 0x00, 0x00, 0x80};//显示器接收包头
char End_buff[] = {0x00, 0xCC, 0x33, 0xC3, 0x3C};//显示器接收包尾
//char bbf[] = {0xB4, 0xAB, 0xCA, 0xE4, 0xCD, 0xEA, 0xB1, 0xCF, 0xA3, 0xA1, 0x0D, 0x0A};
char bbf[] = "succ";
void loop() {
  int hz_start = 0;
  int i = 0;
  WiFiClient client = server.available();

  while (client.connected()) {
    memset(buffer, 0, 1000);
    int n = client.read((uint8_t*)(&buffer[0]), sizeof(buffer));
    if (n > 0) {

      for (i = 0; i < n; i++) {
        Serial.print(buffer[i]);
      }

      hz_start = 0;
      for (i = 0; i < n; i++) {
        if (buffer[i] == 0x0A) {
          if (buffer[i + 1] == 0x0D) {
            if (buffer[i + 2] == 0x0A) {
              hz_start = i + 3;
              break;
            }
          }
        }
      }
      //      Serial.print(hz_start);

      if (hz_start > 0) {
        for (i = 0; i < 6; i++) {
          Serial1.print(Head_buff[i]);
        }
        for (i = hz_start; i < hz_start + 125; i++) {
          Serial1.print(buffer[i]);
        }
        for (i = 0; i < 5; i++) {
          Serial1.print(End_buff[i]);
        }
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println("Connection: close");
        client.println();
        break;
      }

      //      n = client.write(buffer, n);
      n = client.write(bbf, sizeof(bbf));
      if (n <= 0) {
        break;
      }
    }
  }

  client.stop();
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

驱动程序,注意通讯协议帧头AA 42 00 00 00 帧尾 00 CC 33 C3 3C汉子
注意点:
显示中文,字体属性必须要设置中文字库. 显示其他字体类同.
- 最后一个字符必须为'\0'结尾符(即 0x00)
- 中文字符要根据选择的字库是 GB2312 还是 GBK 等,发送汉字
对应的编码.

显示效果:做个APP向路由器指定IP发送。

      项目运行视频:

   作业提示器

      附件为项目GUI界面打包,相关程序,和APP

UI文件.rar

APP.zip


帖子汇总:

01 绚丽智慧屏初探

02 TOPWAY SGTools显示图片"河南加油" 操作流程

03 组态工业看板显示

04 TOPWAY智能屏网络应用之作业提示器




关键词: TOPWAY7     TOPWAY     智能     网络    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]