You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug:
I wrote a script for the interpreter, but when i try to use wifiConnect(keyboard("SSID"), 60, keyboard("Password")); it only displays > Main Menu
Steps To Reproduce:
`Screen dimensions
var SCREEN_WIDTH = 240;
var SCREEN_HEIGHT = 135;
function waitForKey(key) {
print("Entering waitForKey function");
while (true) {
var pressedKeys = getKeysPressed();
print("Pressed keys: ");
if (pressedKeys === key) {
print("Key pressed: ");
return; // Exit the loop when the key is pressed
}
delay(50); // Prevent excessive CPU usage
}
}
print("Fetching site contents");
siteContents = httpGet(url);
print("Got site contents: ");
if (!siteContents) {
drawString("Failed to fetch site contents.", 0, 0);
}
var scrollOffset = 0;
var SCROLL_STEP = 20;
function drawContent(html) {
print("Entering drawContent function");
var y = -scrollOffset;
var i = 0;
fillScreen(color(190, 190, 190));
drawLine(0, 25, SCREEN_WIDTH, 25, color(25, 25, 25));
setTextSize(1);
setTextColor(color(0, 0, 0));
drawString("U - Enter URL | Left/Right arrow - Back/Forward | W/S or Up/Down - Scroll", 0, SCREEN_HEIGHT - 10);
while (i < html.length) {
if (html[i] === "<") {
var tagStart = i + 1;
var tagEnd = html.indexOf(">", tagStart);
if (tagEnd === -1) {
print("Invalid HTML: Missing closing tag");
break; // Invalid HTML, exit loop
}
var tag = html.substring(tagStart, tagEnd);
var contentStart = tagEnd + 1;
var contentEnd = html.indexOf("</" + tag + ">", contentStart);
if (contentEnd === -1) {
print("Invalid HTML: Missing closing tag for content");
break; // Invalid HTML, exit loop
}
var content = html.substring(contentStart, contentEnd);
switch (tag) {
case "h1":
setTextSize(4);
break;
case "h2":
setTextSize(3);
break;
case "h3":
setTextSize(2);
break;
case "p":
setTextSize(1);
break;
default:
i = contentEnd + tag.length + 3;
continue;
}
if (y + 20 > 25 && y < SCREEN_HEIGHT - 10) {
drawString(content, 0, y);
}
y += 20;
i = contentEnd + tag.length + 3;
} else {
i++;
}
}
print("Exiting drawContent function");
}
function handleScroll(html) {
print("Entering handleScroll function");
while (true) {
var pressedKeys = getKeysPressed();
var scrollDown = false;
var scrollUp = false;
for (var i = 0; i < pressedKeys.length; i++) {
if (pressedKeys[i] === "Down" || pressedKeys[i] === "S") {
scrollDown = true;
break;
}
}
for (var i = 0; i < pressedKeys.length; i++) {
if (pressedKeys[i] === "Up" || pressedKeys[i] === "W") {
scrollUp = true;
break;
}
}
if (scrollDown) {
scrollOffset += SCROLL_STEP;
drawContent(html);
} else if (scrollUp) {
scrollOffset -= SCROLL_STEP;
if (scrollOffset < 0) {
scrollOffset = 0;
print("Scroll offset reset to 0");
}
drawContent(html);
}
if (pressedKeys.includes("Escape")) {
exit();
}
delay(100);
}
}
print("Initial draw of content");
drawContent(siteContents);
print("Enabling scrolling");
handleScroll(siteContents);`
Use this script
Device used: Cardputer
Expected behavior:
Connect to the WiFi and fetch the HTML code
Actual behavior:
Nothing, as the Main Menu option kicks me out from the Interpreter
The text was updated successfully, but these errors were encountered:
Describe the bug:
I wrote a script for the interpreter, but when i try to use
wifiConnect(keyboard("SSID"), 60, keyboard("Password"));
it only displays > Main MenuSteps To Reproduce:
`Screen dimensions
var SCREEN_WIDTH = 240;
var SCREEN_HEIGHT = 135;
function waitForKey(key) {
print("Entering waitForKey function");
while (true) {
var pressedKeys = getKeysPressed();
print("Pressed keys: ");
if (pressedKeys === key) {
print("Key pressed: ");
return; // Exit the loop when the key is pressed
}
delay(50); // Prevent excessive CPU usage
}
}
fillScreen(color(190, 190, 190));
drawLine(0, 25, SCREEN_WIDTH, 25, color(25, 25, 25));
setTextSize(1);
setTextColor(color(0, 0, 0));
drawString("U - Enter URL | Left/Right arrow - Back/Forward | W/S or Up/Down - Scroll", 0, SCREEN_HEIGHT - 10);
wifiConnect(keyboard("SSID"), 60, keyboard("Password"));
print("Prompting for URL");
url = keyboard("http://www.example.com");
print("URL entered: ");
if (!url) {
print("Invalid URL input");
drawString("Invalid URL input.", 0, 0);
}
print("Fetching site contents");
siteContents = httpGet(url);
print("Got site contents: ");
if (!siteContents) {
drawString("Failed to fetch site contents.", 0, 0);
}
var scrollOffset = 0;
var SCROLL_STEP = 20;
function drawContent(html) {
print("Entering drawContent function");
var y = -scrollOffset;
var i = 0;
}
function handleScroll(html) {
print("Entering handleScroll function");
while (true) {
}
print("Initial draw of content");
drawContent(siteContents);
print("Enabling scrolling");
handleScroll(siteContents);`
Use this script
Expected behavior:
Connect to the WiFi and fetch the HTML code
Actual behavior:
Nothing, as the Main Menu option kicks me out from the Interpreter
The text was updated successfully, but these errors were encountered: