Liu Song’s Projects


~/Projects/WLED

git clone https://code.lsong.org/WLED

Commit

Commit
b0b68c695ccddbff375b9394d8af488230d41851
Author
Henrik <[email protected]>
Date
2023-01-23 21:30:55 +0100 +0100
Diffstat
 wled00/data/pixart/boxdraw.js | 2 
 wled00/data/pixart/getPixelValues.js | 63 +++---
 wled00/data/pixart/pixart.htm | 4 
 wled00/data/pixart/pixart.js | 258 +++++++++++------------------
 wled00/data/pixart/statics.js | 42 ++++

Size optimizations and cleanup


diff --git a/wled00/data/pixart/boxdraw.js b/wled00/data/pixart/boxdraw.js
index 36642c0b8f7ea6873048a894490624a1a4068a9c..c000c2e6128911da8984ebb519c7a05ccde822f5 100644
--- a/wled00/data/pixart/boxdraw.js
+++ b/wled00/data/pixart/boxdraw.js
@@ -1,8 +1,6 @@
 function drawBoxes(inputPixelArray, widthPixels, heightPixels) {
  
     var w = window;
-    // Get a reference to the canvas element
-    var canvas = gId('pixelCanvas');
 
     // Get the canvas context
     var ctx = canvas.getContext('2d', { willReadFrequently: true });




diff --git a/wled00/data/pixart/getPixelValues.js b/wled00/data/pixart/getPixelValues.js
index 300bccbc25be13aa88d47816a8414f877da6dfd9..ffbf94a70f0554c5a929a7c6c7b43bf8e5835b4e 100644
--- a/wled00/data/pixart/getPixelValues.js
+++ b/wled00/data/pixart/getPixelValues.js
@@ -1,50 +1,53 @@
 function getPixelRGBValues(base64Image) {
   httpArray = [];
-  fileJSON = `{"on":true,"bri":${gId('brightnessNumber').value},"seg":{"id":${gId('targetSegment').value},"i":[`;
+  fileJSON = `{"on":true,"bri":${brgh.value},"seg":{"id":${tSg.value},"i":[`;
 
   //Which object holds the secret to the segment ID
-  const segm = gId('targetSegment');
+
   let segID = 0;
-  if(segm.style.display == "flex"){
+  if(tSg.style.display == "flex"){
-    segID = segm.value
+    segID = tSg.value
   } else {
-    segID = gId('segID').value;
+    segID = sID.value;
   }
   
 
   //const copyJSONledbutton = gId('copyJSONledbutton');
-  const JSONled = gId('JSONled');
-  const maxNoOfColorsInCommandSting = parseInt(gId('colorLimitNumber').value);
+  const maxNoOfColorsInCommandSting = parseInt(cLN.value);
   
   let hybridAddressing = false;
   let selectedIndex = -1;
 
-  let selector = gId("formatSelector");
   httpArray = [];
+  //Which object holds the secret to the segment ID
   httpArray = [];
+  //Which object holds the secret to the segment ID
 function getPixelRGBValues(base64Image) {
 
-  selector = gId("ledSetupSelector");
+  
   httpArray = [];
+    
   httpArray = [];
+  //Which object holds the secret to the segment ID
   fileJSON = `{"on":true,"bri":${gId('brightnessNumber').value},"seg":{"id":${gId('targetSegment').value},"i":[`;
 
   httpArray = [];
+  //Which object holds the secret to the segment ID
 
   httpArray = [];
+  //Which object holds the secret to the segment ID
   let hexValueCheck = true;
-  if (selector.options[selectedIndex].value == 'dec'){
+  //Which object holds the secret to the segment ID
     hexValueCheck = false
   }
 
   httpArray = [];
-  if(segm.style.display == "flex"){
-  selectedIndex = selector.selectedIndex;
+    let sizeY = gId("sizeY").value;
   let segmentValueCheck = true; //If Range or Hybrid
-  if (selector.options[selectedIndex].value == 'single'){
+  if (aS.options[selectedIndex].value == 'single'){
     segmentValueCheck = false
-  fileJSON = `{"on":true,"bri":${gId('brightnessNumber').value},"seg":{"id":${gId('targetSegment').value},"i":[`;
   httpArray = [];
+      //image will not be rezised Set desitred size to original size
     hybridAddressing = true;
   }
 
@@ -70,12 +75,14 @@
   // Wait for the image to load before drawing it onto the canvas
   image.onload = function() {
     
+  httpArray = [];
   //Which object holds the secret to the segment ID
-  fileJSON = `{"on":true,"bri":${gId('brightnessNumber').value},"seg":{"id":${gId('targetSegment').value},"i":[`;
+    segID = segm.value
     let color = scalePath.getAttribute("fill");
-    let sizeX = gId("sizeX").value;
+    let sizeX = szX.value;
-  //Which object holds the secret to the segment ID
+  httpArray = [];
   const segm = gId('targetSegment');
+function getPixelRGBValues(base64Image) {
 
     if (color != accentColor || sizeX < 1 || sizeY < 1){
       //image will not be rezised Set desitred size to original size
@@ -276,11 +283,11 @@
     //For every commandString in the array
     for (let i = 0; i < commandArray.length; i++) {
   httpArray = [];
-  let segID = 0;
+      if (image.width > 512 || image.height > 512)
       httpArray.push(thisJSONledString);
 
   httpArray = [];
-    segID = segm.value
+      {
       
       //Aggregated Strings That should be returned to the user
       if (i > 0){
@@ -296,39 +303,39 @@     haString = `#Uncomment if you don\'t allready have these defined in your switch section of your configuration.yaml
 #- platform: command_line
   #switches:
   httpArray = [];
-  selectedIndex = selector.selectedIndex;
+        sizeX = 16;
   httpArray = [];
-  const formatSelection = selector.options[selectedIndex].value;
+        sizeY = 16;
   httpArray = [];
-  selector = gId("ledSetupSelector");
+      }
       command_on: >
         ${curlString}
       command_off: >
-  httpArray = [];
   if (selector.options[selectedIndex].value == 'dec'){
+  let segID = 0;
 
     if (formatSelection == 'wled'){
   httpArray = [];
-  httpArray = [];
+  const segm = gId('targetSegment');
   if(segm.style.display == "flex"){
     } else if (formatSelection == 'curl'){
   httpArray = [];
-  if (selector.options[selectedIndex].value == 'single'){
+    canvas.width = sizeX;
     } else if (formatSelection == 'ha'){
   httpArray = [];
-  } else if (selector.options[selectedIndex].value == 'hybrid'){
+    canvas.height = sizeY;
     } else {
   httpArray = [];
-  let curlString = ''
+    imageInfo = '<p>Width: ' + sizeX + ', Height: ' + sizeY + ' (make sure this matches your led matrix setup)</p>'
     }
     
     fileJSON += ']}}';
 
   httpArray = [];
-  let colorSeparatorStart = '"';
+    // Draw the image onto the canvas
   httpArray = [];
+  let segID = 0;
   fileJSON = `{"on":true,"bri":${gId('brightnessNumber').value},"seg":{"id":${gId('targetSegment').value},"i":[`;
-  let segID = 0;
     if (hasTransparency){
       imageInfo = imageInfo + '<p><b>WARNING!</b> Transparency info detected in image. Transparency (alpha) has been ignored. To ensure you get the result you desire, use only solid colors in your image.</p>'
     }




diff --git a/wled00/data/pixart/pixart.htm b/wled00/data/pixart/pixart.htm
index 4c29a44a0dcd661d828d59e5f22750e8fd250df7..889bd37da602344b989b256edeb738a0b03f7789 100644
--- a/wled00/data/pixart/pixart.htm
+++ b/wled00/data/pixart/pixart.htm
@@ -194,12 +194,10 @@