「裁線條碼亮燈」:修訂間差異

出自TSK WIKI
跳至導覽 跳至搜尋
Root​(留言 | 貢獻)
 
(未顯示同一使用者於中間所作的 45 次修訂)
第1行: 第1行:
==20190114==
 
==20200604看板==
<c>
<c>
//接收及LED看板
//20200604以pi send to Arduino uno
//20190221增加經過10分鐘看板未輸入條碼,LED看板全黑
#include <SPI.h>
#include <RF24.h>
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A  A0
#define B  A1
#define C  A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
RF24 rf24(A4, A5); // CE腳, CSN腳
const uint64_t addr = 0xF0F0F0F0E2LL;
const uint64_t pipe = 0xE8E8F0F0E2LL;
void setup() {
  Serial.begin(9600);
  rf24.begin();
  matrix.begin();
  rf24.setChannel(0x72);  // 設定頻道編號
  rf24.setPALevel(RF24_PA_MAX);
  rf24.setDataRate(RF24_1MBPS);
  rf24.openReadingPipe(1, pipe);  // 開啟通道和位址
  rf24.enableDynamicPayloads();
  rf24.powerUp();
  rf24.startListening();  // 開始監聽無線廣播
  matrix.fillScreen(matrix.Color333(0, 0, 0));
  matrix.setTextColor(matrix.Color333(7,0,0));
  matrix.setCursor(8, 4);
  matrix.print("TSK");
}
unsigned long starttime;
unsigned long runtime;
void loop() {
  starttime = millis()/60000;
  if (rf24.available()) {
    char msg[32] = "";
    //char s[10];
    runtime = millis()/60000;
    rf24.read(&msg, sizeof(msg));
    String myString = String(msg);   
    int sX=(myString.length() >=5)? 1:5 ;
    matrix.setCursor(sX, 1);
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
    if(atof(msg)<3){
        matrix.setTextColor(matrix.Color333(0,7,3));
      }else if(atof(msg)>=3 && atof(msg)<10){
              matrix.setTextColor(matrix.Color333(7,3,0));
            }else{
              matrix.setTextColor(matrix.Color333(7,0,0));
      }
    delay(30);
    matrix.setTextSize(1);
    matrix.print(myString);
    matrix.setCursor(25, 8);
    matrix.setTextColor(matrix.Color333(0,7,0));
    matrix.print("m"); 
    Serial.println(myString); 
  }
  //超過10分鐘沒有輸入條碼,則關閉LED看板
  if((starttime-runtime)>=10){
    matrix.fillScreen(matrix.Color333(0, 0, 0));   
    }
    //Serial.println(starttime-runtime);
delay(300);
}
</c>
==20190320看板*2==
<c>
//接收及LED看板
//20190221增加經過10分鐘看板未輸入條碼,LED看板全黑
#include <SPI.h>
#include "RF24.h"
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A  A0
#define B  A1
#define C  A2f
#define n  2  // inline panels number
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false,32*n);
RF24 rf24(A4, A5); // CE腳, CSN腳
const byte addr[] = "1Node";
const byte pipe = 1;  // 指定通道編號
void setup() {
  Serial.begin(9600);
  rf24.begin();
  matrix.begin();
  rf24.setChannel(76);  // 設定頻道編號
  rf24.setPALevel(RF24_PA_MAX);
  rf24.setDataRate(RF24_250KBPS);
  rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
  rf24.startListening();  // 開始監聽無線廣播
  matrix.fillScreen(matrix.Color333(0, 0, 0));
  matrix.setTextColor(matrix.Color333(7,0,0));
  matrix.setCursor(8, 4);
  matrix.print("TSK");
}
unsigned long starttime;
unsigned long runtime;
void loop() {
  starttime = millis()/60000;
  if (rf24.available(&pipe)) {
    char msg[32] = "";
    //char s[10];
    runtime = millis()/60000;
    rf24.read(&msg, sizeof(msg));
    String myString = String(msg);   
    int sX=(myString.length() >=5)? 1:5 ;
    matrix.setCursor(sX, 1);
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
    if(atof(msg)<3){
        matrix.setTextColor(matrix.Color333(0,7,3));
      }else if(atof(msg)>=3 && atof(msg)<10){
              matrix.setTextColor(matrix.Color333(7,3,0));
            }else{
              matrix.setTextColor(matrix.Color333(7,0,0));
      }
    delay(30);
    matrix.setTextSize(2);
    matrix.print(myString);
    matrix.setCursor(25, 8);
    matrix.setTextColor(matrix.Color333(0,7,0));
    matrix.print("m"); 
    Serial.println(myString); 
  }
  //超過10分鐘沒有輸入條碼,則關閉LED看板
  if((starttime-runtime)>=10){
    matrix.fillScreen(matrix.Color333(0, 0, 0));   
    }
    //Serial.println(starttime-runtime);
delay(300);
}
</c>
==20190222看板==
<c>
//接收及LED看板
//20190221增加經過10分鐘看板未輸入條碼,LED看板全黑
#include <SPI.h>
#include "RF24.h"
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A  A0
#define B  A1
#define C  A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
RF24 rf24(A4, A5); // CE腳, CSN腳
const byte addr[] = "1Node";
const byte pipe = 1;  // 指定通道編號
void setup() {
  Serial.begin(9600);
  rf24.begin();
  matrix.begin();
  rf24.setChannel(76);  // 設定頻道編號
  rf24.setPALevel(RF24_PA_MAX);
  rf24.setDataRate(RF24_250KBPS);
  rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
  rf24.startListening();  // 開始監聽無線廣播
  matrix.fillScreen(matrix.Color333(0, 0, 0));
  matrix.setTextColor(matrix.Color333(7,0,0));
  matrix.setCursor(8, 4);
  matrix.print("TSK");
}
unsigned long starttime;
unsigned long runtime;
void loop() {
  starttime = millis()/60000;
  if (rf24.available(&pipe)) {
    char msg[32] = "";
    //char s[10];
    runtime = millis()/60000;
    rf24.read(&msg, sizeof(msg));
    String myString = String(msg);   
    int sX=(myString.length() >=5)? 1:5 ;
    matrix.setCursor(sX, 1);
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
    if(atof(msg)<3){
        matrix.setTextColor(matrix.Color333(0,7,3));
      }else if(atof(msg)>=3 && atof(msg)<10){
              matrix.setTextColor(matrix.Color333(7,3,0));
            }else{
              matrix.setTextColor(matrix.Color333(7,0,0));
      }
    delay(30);
    matrix.setTextSize(1);
    matrix.print(myString);
    matrix.setCursor(25, 8);
    matrix.setTextColor(matrix.Color333(0,7,0));
    matrix.print("m"); 
    Serial.println(myString); 
  }
  //超過10分鐘沒有輸入條碼,則關閉LED看板
  if((starttime-runtime)>=10){
    matrix.fillScreen(matrix.Color333(0, 0, 0));   
    }
    //Serial.println(starttime-runtime);
delay(300);
}
</c>


//20190114增加LED看板顯示
==20190223==
<c>
//發送,LED燈條及條碼掃瞄
//20190220增加LED燈條後移長度
//20190222修改燈條後移長度0.3m
//修改loop判斷條件的延時時間
#include <SPI.h>
#include "RF24.h"
#include <printf.h>
#include <usbhid.h>
#include <usbhid.h>
#include <usbhub.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <hidboot.h>
#include <FastLED.h>
#define NUM_LEDS 1200 // led灯数量20m*60顆
#define DATA_PIN A5  // 数据传输引脚(Digital 6)
#define BRIGHTNESS 20 //設定led亮度
#define FRONT_LENGTH 0.295 //LED燈條後移長度
unsigned long starttime;
unsigned long runtime;
int ck_delay;
RF24 rf24(A0, A1); // CE腳, CSN腳
const byte addr[] = "1Node";
String s;
CRGB leds[NUM_LEDS];
class MyParser : public HIDReportParser {
  public:
    MyParser();
    void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  protected:
    uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
    virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
    virtual void OnScanFinished();
};
MyParser::MyParser() {}
void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
  // If error or empty, return
  if (buf[2] == 1 || buf[2] == 0) return;
  for (uint8_t i = 7; i >= 2; i--) {
    // If empty, skip
    if (buf[i] == 0) continue;
    // If enter signal emitted, scan finished
    if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
      OnScanFinished();
    }
    // If not, continue normally
    else {
      // If bit position not in 2, it's uppercase words
      OnKeyScanned(i > 2, buf, buf[i]);
    }
    return;
  }
}
uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {
  // Letters
  if (VALUE_WITHIN(key, 0x04, 0x1d)) {
    if (upper) return (key - 4 + 'A');
    else return (key - 4 + 'a');
  }
  // Numbers
  else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
    return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
  }
  if(key== 55 ) {
    return 46;
    }else return 0;
}
void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {
  uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii); 
delay(50);
s=(ascii==0)? s : s+ (char)ascii ;
ck_delay=0;
}
void MyParser::OnScanFinished() {
//int i,k,j=2;
float a=s.toFloat();
char msg[32];
ck_delay=1;
s.toCharArray(msg,32);
  a=(a-FRONT_LENGTH)*60; 
  int uplimit=ceil(a);
  int downlimit=floor(a);
  delay(150);
  rf24.write(&msg, sizeof(msg));  // 傳送資料 
  runtime = millis()/60000;
   
  FastLED.clear();
  delay(30);
 
  if(uplimit==downlimit){ 
    leds[uplimit] = CRGB::White;
  }else{
    leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
    leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
  }
  FastLED.show(); 
  s="";
}
USB          Usb;
USBHub      Hub(&Usb);
HIDUniversal Hid(&Usb);
MyParser    Parser;
void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
  FastLED.setBrightness(  BRIGHTNESS ); 
  Serial.begin( 9600 );
// Serial.println("Start");
  printf_begin(); 
  rf24.begin();
  rf24.setChannel(76);      // 設定頻道編號
  rf24.openWritingPipe(addr); // 設定通道位址
  rf24.setPALevel(RF24_PA_MAX);  // 設定廣播功率
  rf24.setDataRate(RF24_250KBPS); // 設定傳輸速率
  rf24.stopListening();      // 停止偵聽;設定成發射模式
  //rf24.printDetails();
  if (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
  }
  delay( 50 );
  Hid.SetReportParser(0, &Parser);
  FastLED.clear();
  FastLED.show();
}
void loop() {
  starttime = millis()/60000;
  Usb.Task();
  //十五分鐘入輸入條碼,關閉led燈條
  if((starttime-runtime)>=15){
    FastLED.clear();
    FastLED.show();       
    }
  if(ck_delay==1)delay(200);
}
</c>
==20190221==
<c>
//接收及LED看板
//20190221增加經過10分鐘看板未輸入條碼,LED看板全黑
#include <SPI.h>
#include <SPI.h>
#include <FastLED.h>
#include "RF24.h"
#include <Adafruit_GFX.h>  // Core graphics library
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <RGBmatrixPanel.h> // Hardware-specific library
   
   
#define NUM_LEDS 60 // led灯数量
#define DATA_PIN 6  // 数据传输引脚(Digital 6)
#define BRIGHTNESS 25 //設定led亮度
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define LAT A3
第22行: 第409行:
#define B  A1
#define B  A1
#define C  A2
#define C  A2
 
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
int LIGHTDELAY= 60/NUM_LEDS/60;
RF24 rf24(A4, A5); // CE腳, CSN腳
const byte addr[] = "1Node";
const byte pipe = 1;  // 指定通道編號
void setup() {
  Serial.begin(9600);
  rf24.begin();
  matrix.begin();
  rf24.setChannel(76);  // 設定頻道編號
  rf24.setPALevel(RF24_PA_MAX);
  rf24.setDataRate(RF24_250KBPS);
  rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
  rf24.startListening();  // 開始監聽無線廣播
  matrix.fillScreen(matrix.Color333(0, 0, 0));
  matrix.setTextColor(matrix.Color333(7,4,0));
  matrix.setCursor(8, 4);
  matrix.print("TSK");
}
unsigned long starttime;
unsigned long runtime;
void loop() {
  starttime = millis()/60000;
  if (rf24.available(&pipe)) {
    char msg[32] = "";
    //char s[10];
    runtime = millis()/60000;
    rf24.read(&msg, sizeof(msg));
    String myString = String(msg);   
    int sX=(myString.length() >=5)? 1:5 ;
    matrix.setCursor(sX, 1);
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
    if(atof(msg)<3){
        matrix.setTextColor(matrix.Color333(0,7,7));
      }else if(atof(msg)>=3 && atof(msg)<10){
              matrix.setTextColor(matrix.Color333(7,3,0));
            }else{
              matrix.setTextColor(matrix.Color333(7,0,0));
      }
    delay(30);
    matrix.setTextSize(1);
    matrix.print(myString);
    matrix.setCursor(25, 8);
    matrix.setTextColor(matrix.Color333(0,7,0));
    matrix.print("m"); 
    Serial.println(myString); 
  }
  //超過10分鐘沒有輸入條碼,則關閉LED看板
  if((starttime-runtime)>=10){
    matrix.fillScreen(matrix.Color333(0, 0, 0));   
    }
    //Serial.println(starttime-runtime);
delay(300);
}
</c>
<c>
//發送,LED燈條及條碼掃瞄
//20190220增加LED燈條後移長度
#include <SPI.h>
#include "RF24.h"
#include <printf.h>
#include <usbhid.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <FastLED.h>
#define NUM_LEDS 1200 // led灯数量20m*60顆
#define DATA_PIN A5  // 数据传输引脚(Digital 6)
#define BRIGHTNESS 18 //設定led亮度
#define FRONT_LENGTH 0.3 //LED燈條後移長度
unsigned long starttime;
unsigned long runtime;
RF24 rf24(A0, A1); // CE腳, CSN腳
const byte addr[] = "1Node";
String s;
String s;
CRGB leds[NUM_LEDS];
CRGB leds[NUM_LEDS];
第57行: 第528行:
       // If bit position not in 2, it's uppercase words
       // If bit position not in 2, it's uppercase words
       OnKeyScanned(i > 2, buf, buf[i]);
       OnKeyScanned(i > 2, buf, buf[i]);
    }
    return;
  }
}
uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {
  // Letters
  if (VALUE_WITHIN(key, 0x04, 0x1d)) {
    if (upper) return (key - 4 + 'A');
    else return (key - 4 + 'a');
  }
  // Numbers
  else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
    return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
  }
  if(key== 55 ) {
    return 46;
    }else return 0;
}
void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {
  uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii); 
delay(50);
s=(ascii==0)? s : s+ (char)ascii ;
}
void MyParser::OnScanFinished() {
  int i,k,j=2;
  float a=s.toFloat();
char msg[32];
s.toCharArray(msg,32);
  a=(a-FRONT_LENGTH)*60; 
  int uplimit=ceil(a)-1;
  int downlimit=floor(a)-1;
  delay(150);
  rf24.write(&msg, sizeof(msg));  // 傳送資料
  runtime = millis()/60000;
  Serial.println(s);
  FastLED.clear();
  delay(30);
  if(uplimit==downlimit){ 
    leds[uplimit] = CRGB::White;
  }else{
    leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
    leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
  }
  FastLED.show(); 
  s="";
}
USB          Usb;
USBHub      Hub(&Usb);
HIDUniversal Hid(&Usb);
MyParser    Parser;
void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
  FastLED.setBrightness(  BRIGHTNESS ); 
  Serial.begin( 9600 );
// Serial.println("Start");
  printf_begin(); 
  rf24.begin();
  rf24.setChannel(76);      // 設定頻道編號
  rf24.openWritingPipe(addr); // 設定通道位址
  rf24.setPALevel(RF24_PA_MAX);  // 設定廣播功率
  rf24.setDataRate(RF24_250KBPS); // 設定傳輸速率
  rf24.stopListening();      // 停止偵聽;設定成發射模式
  rf24.printDetails();
 
  if (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
  }
  delay( 50 );
  Hid.SetReportParser(0, &Parser);
}
void loop() {
  starttime = millis()/60000;
  Usb.Task();
  //十五分鐘入輸入條碼,關閉led燈條
  if((starttime-runtime)>=15){
    FastLED.clear();
    FastLED.show();       
    }
  delay(2);
}
</c>
==20190117==
<c>
//20190124 修正桌上型掃瞄器C39 barcod前後置0的轉碼誤判
//s=(ascii==0)? s : s+ (char)ascii ;
//20190117 改用Arduino Mega2560
#include <usbhid.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <SPI.h>
#include <FastLED.h>
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define NUM_LEDS 1200 // led灯数量20m*60顆
#define DATA_PIN A5  // 数据传输引脚(Digital 6)
#define BRIGHTNESS 20 //設定led亮度
#define CLK 11  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A4
#define OE  9
#define A  A0
#define B  A1
#define C  A2
//int LIGHTDELAY= 1/NUM_LEDS;
String s;
CRGB leds[NUM_LEDS];
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
class MyParser : public HIDReportParser {
  public:
    MyParser();
    void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  protected:
    uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
    virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
    virtual void OnScanFinished();
};
MyParser::MyParser() {}
void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
  // If error or empty, return
  if (buf[2] == 1 || buf[2] == 0) return;
  for (uint8_t i = 7; i >= 2; i--) {
    // If empty, skip
    if (buf[i] == 0) continue;
    // If enter signal emitted, scan finished
    if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
      OnScanFinished();
     }
     }
   
   
    // If not, continue normally
    else {
      // If bit position not in 2, it's uppercase words
      OnKeyScanned(i > 2, buf, buf[i]);
    }
     return;
     return;
   }
   }
第68行: 第690行:
     if (upper) return (key - 4 + 'A');
     if (upper) return (key - 4 + 'A');
     else return (key - 4 + 'a');
     else return (key - 4 + 'a');
  }
  // Numbers
  else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
    return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
  }
  if(key== 55 ) {
    return 46;
    }else return 0;
}
void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {
  uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii); 
delay(50);
s=(ascii==0)? s : s+ (char)ascii ;
}
void MyParser::OnScanFinished() {
  int i,k,j=2;
  float a=s.toFloat();
  a=a*60; 
  int uplimit=ceil(a)-1;
  int downlimit=floor(a)-1; 
  int sX=(s.length()>=5)? 1:5 ; 
  matrix.setCursor(sX, 1);
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
    matrix.setTextColor(matrix.Color333(7,0,0));
    delay(30);
    matrix.setTextSize(1);
    Serial.println(s);
    matrix.print(s);
    FastLED.clear();
/*
    int delaynum= ceil(downlimit/60.0)*3;
    //Serial.println(delaynum);
  for(i=0;i< downlimit;i+=delaynum){
    leds[i] = CRGB::Yellow;
    FastLED.show();
  // delay(1);
    leds[i] = CRGB::Black;
    FastLED.show();   
  }
*/
  delay(30);
  if(uplimit==downlimit){ 
    leds[uplimit] = CRGB::White;
  }else{
    leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
    leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
   }
   }
   
   
  FastLED.show();
  matrix.setCursor(25, 8);
  matrix.setTextColor(matrix.Color333(0,7,0));
  matrix.print("m"); 
  s="";
}
USB          Usb;
USBHub      Hub(&Usb);
HIDUniversal Hid(&Usb);
MyParser    Parser;
void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
  FastLED.setBrightness(  BRIGHTNESS );
  matrix.begin();
  Serial.begin( 115200 );
  Serial.println("Start");
  if (Usb.Init() == -1) {
    Serial.println("OSC did not start.");
  }
  delay( 100 );
  Hid.SetReportParser(0, &Parser);
  matrix.fillScreen(matrix.Color333(0, 0, 0));
}
void loop() {
  Usb.Task();
}
</c>
==20190115==
<c>
//20190115 增加LED看板顯示
#include <usbhid.h>
#include <usbhub.h>
#include <hiduniversal.h>
#include <hidboot.h>
#include <SPI.h>
#include <FastLED.h>
#include <Adafruit_GFX.h>  // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#define NUM_LEDS 60 // led灯数量20m*60顆
#define DATA_PIN A5  // 数据传输引脚(Digital 6)
#define BRIGHTNESS 25 //設定led亮度
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A  A0
#define B  A1
#define C  A2
//int LIGHTDELAY= 1/NUM_LEDS;
String s;
CRGB leds[NUM_LEDS];
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
class MyParser : public HIDReportParser {
  public:
    MyParser();
    void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
  protected:
    uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
    virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
    virtual void OnScanFinished();
};
MyParser::MyParser() {}
void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
  // If error or empty, return
  if (buf[2] == 1 || buf[2] == 0) return;
  for (uint8_t i = 7; i >= 2; i--) {
    // If empty, skip
    if (buf[i] == 0) continue;
    // If enter signal emitted, scan finished
    if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
      OnScanFinished();
    }
    // If not, continue normally
    else {
      // If bit position not in 2, it's uppercase words
      OnKeyScanned(i > 2, buf, buf[i]);
    }
    return;
  }
}
uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {
  // Letters
  if (VALUE_WITHIN(key, 0x04, 0x1d)) {
    if (upper) return (key - 4 + 'A');
    else return (key - 4 + 'a');
  }
   // Numbers
   // Numbers
   else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
第77行: 第852行:
   if(key== 55 ) {  
   if(key== 55 ) {  
     return 46;  
     return 46;  
     }else return 0;
     }else return 0;  
}
}
   
   
第85行: 第859行:
  // Serial.print((char)ascii);   
  // Serial.print((char)ascii);   
  delay(100);
  delay(100);
   s= s + ((char)ascii) + "";
   s= s + ((char)ascii) + "";  
}
}
   
   
void MyParser::OnScanFinished() {
void MyParser::OnScanFinished() {
   int i,k,j=2;
   int i,k,j=2;  
   float a=s.toFloat();
   float a=s.toFloat();
   a=a*60;
   a=a*60;
   int uplimit=ceil(a)-1;
   int uplimit=ceil(a)-1;
   int downlimit=floor(a)-1;
   int downlimit=floor(a)-1;
  //Serial.println(uplimit);
  matrix.setCursor(5, 0);
  FastLED.clear();
    matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  // fill the screen with 'black'
    matrix.setTextColor(matrix.Color333(7,0,0));
//  matrix.setCursor(1, 0);
    delay(30);
// matrix.fillScreen(matrix.Color333(0, 0, 0));
    matrix.setTextSize(1);
// matrix.setTextSize(a);  
    matrix.print(s);
   for(i=1;i< downlimit;i++){
    FastLED.clear();  
/*
    int delaynum= ceil(downlimit/60.0);
   for(i=1;i< downlimit;i+=delaynum){
     leds[i] = CRGB::Yellow;
     leds[i] = CRGB::Yellow;
     FastLED.show();
     FastLED.show();
     delay(LIGHTDELAY);
     delay(10);
     FastLED.clear();
     FastLED.clear();
   }
   }  
   
  */
  delay(30);
   if(uplimit==downlimit){
   if(uplimit==downlimit){  
     leds[uplimit] = CRGB::White;
     leds[uplimit] = CRGB::White;
   }else{
   }else{
第116行: 第892行:
     leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
     leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
   }
   }
   FastLED.show();
   FastLED.show();
   Serial.println(s);
   matrix.setCursor(25, 7);
   s="";
  matrix.setTextColor(matrix.Color333(0,7,0));
  matrix.print("m");  
   s="";  
}
}
   
   
第132行: 第910行:
   matrix.begin();
   matrix.begin();
   Serial.begin( 115200 );
   Serial.begin( 115200 );
   Serial.println("Start");
   Serial.println("Start");  
 
   
   
   if (Usb.Init() == -1) {
   if (Usb.Init() == -1) {
第139行: 第916行:
   }
   }
   
   
   delay( 200 );
   delay( 100 );
  Hid.SetReportParser(0, &Parser);
  matrix.fillScreen(matrix.Color333(0, 0, 0));  
   
   
  Hid.SetReportParser(0, &Parser);
}
}
   
   
第147行: 第925行:
   Usb.Task();
   Usb.Task();
}
}
   
   
</c>
</c>
==20190104-2==
==20190104-2==
<c>
<c>
//20190104增加LCE顯示
//20190104增加LCD顯示
#include <Wire.h>  
#include <Wire.h>  
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
第546行: 第1,324行:
}
}
</c>
</c>
==APR標籤==
<vb>
Combine('*', if(Position(加工設計書標籤.長度, 'M', 0)>0,Replace(加工設計書標籤.長度,Position(加工設計書標籤.長度, 'M', 0),1),加工設計書標籤.長度), '*')
</vb>
*條碼字型 C39P48DITt(無顯示文字)
==零件清單==
*[https://goods.ruten.com.tw/item/show?21310080868502 Arduino Mega 2560]:280元
*[https://goods.ruten.com.tw/item/show?21733964944057 Arduino USB Host Shield]:260元
*[https://goods.ruten.com.tw/item/show?21646433501353 32x16 RGB LED Matrix]:1050元
*[https://shopee.tw/5M-300LED-WS2812B-5050SMD%E8%B7%91%E9%A6%AC%E7%87%88%E4%B8%B2%E5%B9%BB%E5%BD%A9%E7%87%88%E5%B8%B65V%E4%B8%8D%E9%98%B2%E6%B0%B4-i.28087237.1723413462 5M 300LED WS2812B 5050SMDx4=20M]:2540
*[https://goods.ruten.com.tw/item/show?21207103775117 LED 電源變壓器5V 50W]:500元
*[https://goods.ruten.com.tw/item/show?21823144632017 DENSO QK30-U Series 桌上型條碼掃描器]:3500元
*總計 8,130元
*[https://goods.ruten.com.tw/item/show?21646421762742 24L01無線模組轉接板 3.3V]:20元x2
*[https://shopee.tw/product/4877344/64923635 NORDIC原裝NRF24L01+ PA LNA的無線模塊]:130x2
*[https://goods.ruten.com.tw/item/show?21747360083001 MW明緯原裝LRS-50-5電源供應器/變壓器(5V 10A 50W)]:375元
*[https://goods.ruten.com.tw/item/show?21404244774414 Arduino UNO R3、Mega328+ ATMega16U2]:185元
*[https://goods.ruten.com.tw/item/show?21733964944057 Arduino USB Host Shield]:260元
*保護盒 90+130=220元
*杜邦連接糸線 60元
*總計1400元
==工程需求==
*桌面部分
**條碼掃瞄器安裝 : 桌面挖洞與桌面齊平
**固定桌腳 : 避免桌子移動,扯壞LED燈條
**綠墊割開 10mm寬 : 避免燈條被壓壞
**燈條電源孔 : 燈條安裝於距桌端面3cm,需挖孔穿電源線
**桌面控制器安裝
**電源供應器安裝 : 要注意燈條電源線長
*LED看板
**LED看板固定
**看板控制器固定
**看板電源供應器固定
**[https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/connecting-with-jumper-wires 看板接線方法]
*電源插座及開關(或插拔插頭)
**桌面電源 : 一桌至少三孔插座
**看板電源 : 一桌至少三孔插座

於 2020年6月4日 (四) 15:38 的最新修訂

20200604看板

<c> //接收及LED看板 //20200604以pi send to Arduino uno //20190221增加經過10分鐘看板未輸入條碼,LED看板全黑

  1. include <SPI.h>
  2. include <RF24.h>
  3. include <Adafruit_GFX.h> // Core graphics library
  4. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A3
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); RF24 rf24(A4, A5); // CE腳, CSN腳 const uint64_t addr = 0xF0F0F0F0E2LL; const uint64_t pipe = 0xE8E8F0F0E2LL;

void setup() {

 Serial.begin(9600);
 rf24.begin();
 matrix.begin();
 rf24.setChannel(0x72);  // 設定頻道編號
 rf24.setPALevel(RF24_PA_MAX);
 rf24.setDataRate(RF24_1MBPS);
 rf24.openReadingPipe(1, pipe);  // 開啟通道和位址
 rf24.enableDynamicPayloads();
 rf24.powerUp();
 rf24.startListening();  // 開始監聽無線廣播
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 
 matrix.setTextColor(matrix.Color333(7,0,0));
 matrix.setCursor(8, 4);
 matrix.print("TSK"); 

}

unsigned long starttime; unsigned long runtime;

void loop() {

 starttime = millis()/60000;
 if (rf24.available()) {
   char msg[32] = "";
   //char s[10];
   runtime = millis()/60000;
   rf24.read(&msg, sizeof(msg)); 
   String myString = String(msg);    
   int sX=(myString.length() >=5)? 1:5 ; 
   matrix.setCursor(sX, 1);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
   if(atof(msg)<3){
       matrix.setTextColor(matrix.Color333(0,7,3));
     }else if(atof(msg)>=3 && atof(msg)<10){
             matrix.setTextColor(matrix.Color333(7,3,0));
           }else{
             matrix.setTextColor(matrix.Color333(7,0,0));
     }

   delay(30);
   matrix.setTextSize(1);
   matrix.print(myString); 
   matrix.setCursor(25, 8);
   matrix.setTextColor(matrix.Color333(0,7,0));
   matrix.print("m");  
   Serial.println(myString);  
 }
 //超過10分鐘沒有輸入條碼,則關閉LED看板
 if((starttime-runtime)>=10){
   matrix.fillScreen(matrix.Color333(0, 0, 0));     
   }
   //Serial.println(starttime-runtime);
delay(300);

} </c>

20190320看板*2

<c> //接收及LED看板 //20190221增加經過10分鐘看板未輸入條碼,LED看板全黑

  1. include <SPI.h>
  2. include "RF24.h"
  3. include <Adafruit_GFX.h> // Core graphics library
  4. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A3
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2f
  7. define n 2 // inline panels number

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false,32*n); RF24 rf24(A4, A5); // CE腳, CSN腳 const byte addr[] = "1Node"; const byte pipe = 1; // 指定通道編號

void setup() {

 Serial.begin(9600);
 rf24.begin();
 matrix.begin();
 rf24.setChannel(76);  // 設定頻道編號
 rf24.setPALevel(RF24_PA_MAX);
 rf24.setDataRate(RF24_250KBPS);
 rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
 rf24.startListening();  // 開始監聽無線廣播
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 
 matrix.setTextColor(matrix.Color333(7,0,0));
 matrix.setCursor(8, 4);
 matrix.print("TSK"); 

}

unsigned long starttime; unsigned long runtime;

void loop() {

 starttime = millis()/60000;
 if (rf24.available(&pipe)) {
   char msg[32] = "";
   //char s[10];
   runtime = millis()/60000;
   rf24.read(&msg, sizeof(msg)); 
   String myString = String(msg);    
   int sX=(myString.length() >=5)? 1:5 ; 
   matrix.setCursor(sX, 1);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
   if(atof(msg)<3){
       matrix.setTextColor(matrix.Color333(0,7,3));
     }else if(atof(msg)>=3 && atof(msg)<10){
             matrix.setTextColor(matrix.Color333(7,3,0));
           }else{
             matrix.setTextColor(matrix.Color333(7,0,0));
     }

   delay(30);
   matrix.setTextSize(2);
   matrix.print(myString); 
   matrix.setCursor(25, 8);
   matrix.setTextColor(matrix.Color333(0,7,0));
   matrix.print("m");  
   Serial.println(myString);  
 }
 //超過10分鐘沒有輸入條碼,則關閉LED看板
 if((starttime-runtime)>=10){
   matrix.fillScreen(matrix.Color333(0, 0, 0));     
   }
   //Serial.println(starttime-runtime);
delay(300);

}

</c>

20190222看板

<c> //接收及LED看板 //20190221增加經過10分鐘看板未輸入條碼,LED看板全黑

  1. include <SPI.h>
  2. include "RF24.h"
  3. include <Adafruit_GFX.h> // Core graphics library
  4. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A3
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); RF24 rf24(A4, A5); // CE腳, CSN腳 const byte addr[] = "1Node"; const byte pipe = 1; // 指定通道編號

void setup() {

 Serial.begin(9600);
 rf24.begin();
 matrix.begin();
 rf24.setChannel(76);  // 設定頻道編號
 rf24.setPALevel(RF24_PA_MAX);
 rf24.setDataRate(RF24_250KBPS);
 rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
 rf24.startListening();  // 開始監聽無線廣播
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 
 matrix.setTextColor(matrix.Color333(7,0,0));
 matrix.setCursor(8, 4);
 matrix.print("TSK"); 

}

unsigned long starttime; unsigned long runtime;

void loop() {

 starttime = millis()/60000;
 if (rf24.available(&pipe)) {
   char msg[32] = "";
   //char s[10];
   runtime = millis()/60000;
   rf24.read(&msg, sizeof(msg)); 
   String myString = String(msg);    
   int sX=(myString.length() >=5)? 1:5 ; 
   matrix.setCursor(sX, 1);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
   if(atof(msg)<3){
       matrix.setTextColor(matrix.Color333(0,7,3));
     }else if(atof(msg)>=3 && atof(msg)<10){
             matrix.setTextColor(matrix.Color333(7,3,0));
           }else{
             matrix.setTextColor(matrix.Color333(7,0,0));
     }

   delay(30);
   matrix.setTextSize(1);
   matrix.print(myString); 
   matrix.setCursor(25, 8);
   matrix.setTextColor(matrix.Color333(0,7,0));
   matrix.print("m");  
   Serial.println(myString);  
 }
 //超過10分鐘沒有輸入條碼,則關閉LED看板
 if((starttime-runtime)>=10){
   matrix.fillScreen(matrix.Color333(0, 0, 0));     
   }
   //Serial.println(starttime-runtime);
delay(300);

} </c>

20190223

<c> //發送,LED燈條及條碼掃瞄 //20190220增加LED燈條後移長度 //20190222修改燈條後移長度0.3m //修改loop判斷條件的延時時間

  1. include <SPI.h>
  2. include "RF24.h"
  3. include <printf.h>
  4. include <usbhid.h>
  5. include <usbhub.h>
  6. include <hiduniversal.h>
  7. include <hidboot.h>
  8. include <FastLED.h>
  1. define NUM_LEDS 1200 // led灯数量20m*60顆
  2. define DATA_PIN A5 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 20 //設定led亮度
  4. define FRONT_LENGTH 0.295 //LED燈條後移長度

unsigned long starttime; unsigned long runtime; int ck_delay; RF24 rf24(A0, A1); // CE腳, CSN腳 const byte addr[] = "1Node";


String s; CRGB leds[NUM_LEDS];

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   } 
   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 } 
 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0; 

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(50);
s=(ascii==0)? s : s+ (char)ascii ;
ck_delay=0;

}

void MyParser::OnScanFinished() {

//int i,k,j=2; 
float a=s.toFloat();
char msg[32];
ck_delay=1;
s.toCharArray(msg,32);
 a=(a-FRONT_LENGTH)*60;  
 int uplimit=ceil(a);
 int downlimit=floor(a); 
 delay(150);
 rf24.write(&msg, sizeof(msg));  // 傳送資料  
 runtime = millis()/60000;
   
 FastLED.clear();
 delay(30); 
 
 if(uplimit==downlimit){   
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }

 FastLED.show();  
 s=""; 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );  
 Serial.begin( 9600 );
// Serial.println("Start");
 printf_begin();  
 rf24.begin();
 rf24.setChannel(76);       // 設定頻道編號
 rf24.openWritingPipe(addr); // 設定通道位址
 rf24.setPALevel(RF24_PA_MAX);   // 設定廣播功率
 rf24.setDataRate(RF24_250KBPS); // 設定傳輸速率
 rf24.stopListening();       // 停止偵聽;設定成發射模式
 //rf24.printDetails();

 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 } 
 delay( 50 ); 
 Hid.SetReportParser(0, &Parser); 
 FastLED.clear();
 FastLED.show(); 

}

void loop() {

 starttime = millis()/60000;
 Usb.Task();
 //十五分鐘入輸入條碼,關閉led燈條
 if((starttime-runtime)>=15){
   FastLED.clear();
   FastLED.show();        
   }
 if(ck_delay==1)delay(200);

}


</c>

20190221

<c> //接收及LED看板 //20190221增加經過10分鐘看板未輸入條碼,LED看板全黑

  1. include <SPI.h>
  2. include "RF24.h"
  3. include <Adafruit_GFX.h> // Core graphics library
  4. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A3
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2

RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); RF24 rf24(A4, A5); // CE腳, CSN腳 const byte addr[] = "1Node"; const byte pipe = 1; // 指定通道編號

void setup() {

 Serial.begin(9600);
 rf24.begin();
 matrix.begin();
 rf24.setChannel(76);  // 設定頻道編號
 rf24.setPALevel(RF24_PA_MAX);
 rf24.setDataRate(RF24_250KBPS);
 rf24.openReadingPipe(pipe, addr);  // 開啟通道和位址
 rf24.startListening();  // 開始監聽無線廣播
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 
 matrix.setTextColor(matrix.Color333(7,4,0));
 matrix.setCursor(8, 4);
 matrix.print("TSK"); 

}

unsigned long starttime; unsigned long runtime;

void loop() {

 starttime = millis()/60000;
 if (rf24.available(&pipe)) {
   char msg[32] = "";
   //char s[10];
   runtime = millis()/60000;
   rf24.read(&msg, sizeof(msg)); 
   String myString = String(msg);    
   int sX=(myString.length() >=5)? 1:5 ; 
   matrix.setCursor(sX, 1);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
  //線長大於等於10紅色,小於10橙色
   if(atof(msg)<3){
       matrix.setTextColor(matrix.Color333(0,7,7));
     }else if(atof(msg)>=3 && atof(msg)<10){
             matrix.setTextColor(matrix.Color333(7,3,0));
           }else{
             matrix.setTextColor(matrix.Color333(7,0,0));
     }

   delay(30);
   matrix.setTextSize(1);
   matrix.print(myString); 
   matrix.setCursor(25, 8);
   matrix.setTextColor(matrix.Color333(0,7,0));
   matrix.print("m");  
   Serial.println(myString);  
 }
 //超過10分鐘沒有輸入條碼,則關閉LED看板
 if((starttime-runtime)>=10){
   matrix.fillScreen(matrix.Color333(0, 0, 0));     
   }
   //Serial.println(starttime-runtime);
delay(300);

}

</c> <c> //發送,LED燈條及條碼掃瞄 //20190220增加LED燈條後移長度

  1. include <SPI.h>
  2. include "RF24.h"
  3. include <printf.h>
  4. include <usbhid.h>
  5. include <usbhub.h>
  6. include <hiduniversal.h>
  7. include <hidboot.h>
  8. include <FastLED.h>
  1. define NUM_LEDS 1200 // led灯数量20m*60顆
  2. define DATA_PIN A5 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 18 //設定led亮度
  4. define FRONT_LENGTH 0.3 //LED燈條後移長度

unsigned long starttime; unsigned long runtime;

RF24 rf24(A0, A1); // CE腳, CSN腳 const byte addr[] = "1Node";


String s; CRGB leds[NUM_LEDS];

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   } 
   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 } 
 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0; 

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(50);
s=(ascii==0)? s : s+ (char)ascii ;

}

void MyParser::OnScanFinished() {

 int i,k,j=2; 
 float a=s.toFloat();
char msg[32];
s.toCharArray(msg,32);
 a=(a-FRONT_LENGTH)*60;  
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1; 
 delay(150);
 rf24.write(&msg, sizeof(msg));  // 傳送資料
 runtime = millis()/60000;
 Serial.println(s);
 FastLED.clear(); 

 delay(30); 
 if(uplimit==downlimit){   
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }

 FastLED.show();  
 s=""; 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );  
 Serial.begin( 9600 );
// Serial.println("Start");
 printf_begin();  
 rf24.begin();
 rf24.setChannel(76);       // 設定頻道編號
 rf24.openWritingPipe(addr); // 設定通道位址
 rf24.setPALevel(RF24_PA_MAX);   // 設定廣播功率
 rf24.setDataRate(RF24_250KBPS); // 設定傳輸速率
 rf24.stopListening();       // 停止偵聽;設定成發射模式
 rf24.printDetails();
 
 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 } 
 delay( 50 ); 
 Hid.SetReportParser(0, &Parser); 

}

void loop() {

 starttime = millis()/60000;
 Usb.Task();
 //十五分鐘入輸入條碼,關閉led燈條
 if((starttime-runtime)>=15){
   FastLED.clear();
   FastLED.show();        
   }
 delay(2);

} </c>

20190117

<c> //20190124 修正桌上型掃瞄器C39 barcod前後置0的轉碼誤判 //s=(ascii==0)? s : s+ (char)ascii ; //20190117 改用Arduino Mega2560

  1. include <usbhid.h>
  2. include <usbhub.h>
  3. include <hiduniversal.h>
  4. include <hidboot.h>
  5. include <SPI.h>
  6. include <FastLED.h>
  7. include <Adafruit_GFX.h> // Core graphics library
  8. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define NUM_LEDS 1200 // led灯数量20m*60顆
  2. define DATA_PIN A5 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 20 //設定led亮度
  1. define CLK 11 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A4
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2

//int LIGHTDELAY= 1/NUM_LEDS; String s; CRGB leds[NUM_LEDS]; RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   } 
   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 } 
 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0; 

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(50);
s=(ascii==0)? s : s+ (char)ascii ; 

}

void MyParser::OnScanFinished() {

 int i,k,j=2; 
 float a=s.toFloat();
 a=a*60;  
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1;  
 int sX=(s.length()>=5)? 1:5 ;  
  matrix.setCursor(sX, 1);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
   matrix.setTextColor(matrix.Color333(7,0,0));
   delay(30);
   matrix.setTextSize(1);
   Serial.println(s);
   matrix.print(s); 
   FastLED.clear(); 

/*

   int delaynum= ceil(downlimit/60.0)*3; 
   //Serial.println(delaynum); 
 for(i=0;i< downlimit;i+=delaynum){
   leds[i] = CRGB::Yellow;
   FastLED.show();
  // delay(1);
   leds[i] = CRGB::Black;
   FastLED.show();    
 } 
  • /
 delay(30); 
 if(uplimit==downlimit){   
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }

 FastLED.show();
 matrix.setCursor(25, 8);
 matrix.setTextColor(matrix.Color333(0,7,0));
 matrix.print("m");   
 s=""; 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );
 matrix.begin();
 Serial.begin( 115200 );
 Serial.println("Start"); 

 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 }

 delay( 100 ); 
 Hid.SetReportParser(0, &Parser);
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 

}

void loop() {

 Usb.Task();

}

</c>

20190115

<c> //20190115 增加LED看板顯示

  1. include <usbhid.h>
  2. include <usbhub.h>
  3. include <hiduniversal.h>
  4. include <hidboot.h>
  5. include <SPI.h>
  6. include <FastLED.h>
  7. include <Adafruit_GFX.h> // Core graphics library
  8. include <RGBmatrixPanel.h> // Hardware-specific library
  1. define NUM_LEDS 60 // led灯数量20m*60顆
  2. define DATA_PIN A5 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 25 //設定led亮度
  1. define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
  2. define LAT A3
  3. define OE 9
  4. define A A0
  5. define B A1
  6. define C A2

//int LIGHTDELAY= 1/NUM_LEDS; String s; CRGB leds[NUM_LEDS]; RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   } 
   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 } 
 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0; 

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(100);
 s= s + ((char)ascii) + ""; 

}

void MyParser::OnScanFinished() {

 int i,k,j=2; 
 float a=s.toFloat();
 a=a*60;  
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1;  
  matrix.setCursor(5, 0);
   matrix.fillScreen(matrix.Color333(0, 0, 0)); // fill the screen with 'black'
   matrix.setTextColor(matrix.Color333(7,0,0));
   delay(30);
   matrix.setTextSize(1);
   matrix.print(s);

   FastLED.clear(); 

/*

   int delaynum= ceil(downlimit/60.0);  
 for(i=1;i< downlimit;i+=delaynum){
   leds[i] = CRGB::Yellow;
   FastLED.show();
   delay(10);
   FastLED.clear();
 } 
*/
 delay(30); 
 if(uplimit==downlimit){   
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }

 FastLED.show();
 matrix.setCursor(25, 7);
 matrix.setTextColor(matrix.Color333(0,7,0));
 matrix.print("m");   
 s=""; 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );
 matrix.begin();
 Serial.begin( 115200 );
 Serial.println("Start"); 

 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 }

 delay( 100 ); 
 Hid.SetReportParser(0, &Parser);
 matrix.fillScreen(matrix.Color333(0, 0, 0)); 

}

void loop() {

 Usb.Task();

}

</c>

20190104-2

<c> //20190104增加LCD顯示

  1. include <Wire.h>
  2. include <LiquidCrystal_I2C.h>
  3. include <usbhid.h>
  4. include <usbhub.h>
  5. include <hiduniversal.h>
  6. include <hidboot.h>
  7. include <SPI.h>
  8. include <FastLED.h>
  1. define NUM_LEDS 60 // led灯数量
  2. define DATA_PIN 6 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 25 //設定led亮度

int LIGHTDELAY= 60/NUM_LEDS/60; String s; CRGB leds[NUM_LEDS]; LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   }

   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 }

 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0;

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(100);
 s= s + ((char)ascii) + "";

}

void MyParser::OnScanFinished() {

 int i,k,j=2;
 
 float a=s.toFloat();
 String lcdtext2=s +" m";
 lcd.clear();
 lcd.setCursor(1,0);
 lcd.print("Cable Length:");
 lcd.setCursor(6,1);
 lcd.print(lcdtext2);  
 a=a*60;
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1;
 FastLED.clear(); 
 for(i=1;i< downlimit;i++){
   leds[i] = CRGB::Yellow;
   FastLED.show();
   delay(LIGHTDELAY);
   FastLED.clear();
 }


 if(uplimit==downlimit){
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }
 FastLED.show();
 s="";
 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );
 Serial.begin( 115200 );
 lcd.init();
 lcd.backlight();
 lcd.setCursor(1,0);
 lcd.print("Cable Length:");


 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 }

 delay( 200 );

 Hid.SetReportParser(0, &Parser);

}

void loop() {

 Usb.Task();

}

</c>

20190104-1

<c> //20190104增加流水燈

  1. include <usbhid.h>
  2. include <usbhub.h>
  3. include <hiduniversal.h>
  4. include <hidboot.h>
  5. include <SPI.h>
  6. include <FastLED.h>
  1. define NUM_LEDS 60 // led灯数量
  2. define DATA_PIN 6 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 25 //設定led亮度

int LIGHTDELAY= 60/NUM_LEDS/60; String s; CRGB leds[NUM_LEDS];

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;

 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;

   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }

   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   }

   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 }

 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }

 if(key== 55 ) { 
   return 46; 
   }else return 0;

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(100);
 s= s + ((char)ascii) + "";

}

void MyParser::OnScanFinished() {

 int i,k,j=2;
 
 float a=s.toFloat();
 a=a*60;
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1;
 //Serial.println(uplimit);  
 FastLED.clear();

 for(i=1;i< downlimit;i++){
   leds[i] = CRGB::Yellow;
   FastLED.show();
   delay(LIGHTDELAY);
   FastLED.clear();
 }


 if(uplimit==downlimit){
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }
 FastLED.show();
 s="";
 

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );
 Serial.begin( 115200 );
 Serial.println("Start");

 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 }

 delay( 200 );

 Hid.SetReportParser(0, &Parser);

}

void loop() {

 Usb.Task();

}

</c>

20190103

<c>

  1. include <usbhid.h>
  2. include <usbhub.h>
  3. include <hiduniversal.h>
  4. include <hidboot.h>
  5. include <SPI.h>
  6. include <FastLED.h>
  1. define NUM_LEDS 60 // led灯数量
  2. define DATA_PIN 6 // 数据传输引脚(Digital 6)
  3. define BRIGHTNESS 25 ////設定led亮度

String s; CRGB leds[NUM_LEDS];

class MyParser : public HIDReportParser {

 public:
   MyParser();
   void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
 protected:
   uint8_t KeyToAscii(bool upper, uint8_t mod, uint8_t key);
   virtual void OnKeyScanned(bool upper, uint8_t mod, uint8_t key);
   virtual void OnScanFinished();

};

MyParser::MyParser() {}

void MyParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {

 // If error or empty, return
 if (buf[2] == 1 || buf[2] == 0) return;
 for (uint8_t i = 7; i >= 2; i--) {
   // If empty, skip
   if (buf[i] == 0) continue;
   // If enter signal emitted, scan finished
   if (buf[i] == UHS_HID_BOOT_KEY_ENTER) {
     OnScanFinished();
   }
   // If not, continue normally
   else {
     // If bit position not in 2, it's uppercase words
     OnKeyScanned(i > 2, buf, buf[i]);
   }
   return;
 }

}

uint8_t MyParser::KeyToAscii(bool upper, uint8_t mod, uint8_t key) {

 // Letters
 if (VALUE_WITHIN(key, 0x04, 0x1d)) {
   if (upper) return (key - 4 + 'A');
   else return (key - 4 + 'a');
 }
 // Numbers
 else if (VALUE_WITHIN(key, 0x1e, 0x27)) {
   return ((key == UHS_HID_BOOT_KEY_ZERO) ? '0' : key - 0x1e + '1');
 }
 if(key== 55 ) { 
   return 46; 
   }else return 0;
 

}

void MyParser::OnKeyScanned(bool upper, uint8_t mod, uint8_t key) {

 uint8_t ascii = KeyToAscii(upper, mod, key);
// Serial.print((char)ascii);  
delay(100);
 s= s + ((char)ascii) + "";

//s=s + ascii; }

void MyParser::OnScanFinished() {

 float a=s.toFloat();
 a=a*60;
 int uplimit=ceil(a)-1;
 int downlimit=floor(a)-1;
 Serial.println(uplimit);  
 FastLED.clear();
 if(uplimit==downlimit){
   leds[uplimit] = CRGB::White;
 }else{
   leds[uplimit] = CRGB::Red;  // 设置第1个led灯的颜色Red
   leds[downlimit] = CRGB::Green;  // 设置第2个led灯的颜色Red
 }
 FastLED.show();
 s="";

}

USB Usb; USBHub Hub(&Usb); HIDUniversal Hid(&Usb); MyParser Parser;

void setup() {

 FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // 初始化所有LED灯
 FastLED.setBrightness(  BRIGHTNESS );
 Serial.begin( 115200 );
 Serial.println("Start");
 if (Usb.Init() == -1) {
   Serial.println("OSC did not start.");
 }
 delay( 200 );
 Hid.SetReportParser(0, &Parser);

}

void loop() {

 Usb.Task();

} </c>

APR標籤

<vb> Combine('*', if(Position(加工設計書標籤.長度, 'M', 0)>0,Replace(加工設計書標籤.長度,Position(加工設計書標籤.長度, 'M', 0),1),加工設計書標籤.長度), '*') </vb>

  • 條碼字型 C39P48DITt(無顯示文字)

零件清單

工程需求

  • 桌面部分
    • 條碼掃瞄器安裝 : 桌面挖洞與桌面齊平
    • 固定桌腳 : 避免桌子移動,扯壞LED燈條
    • 綠墊割開 10mm寬 : 避免燈條被壓壞
    • 燈條電源孔 : 燈條安裝於距桌端面3cm,需挖孔穿電源線
    • 桌面控制器安裝
    • 電源供應器安裝 : 要注意燈條電源線長
  • LED看板
  • 電源插座及開關(或插拔插頭)
    • 桌面電源 : 一桌至少三孔插座
    • 看板電源 : 一桌至少三孔插座