wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
72 stars 17 forks source link

Combine Library Manager and libraries.txt into a single tab #362

Open leftCoast opened 2 years ago

leftCoast commented 2 years ago

Is your feature request related to a problem? Please describe. The library stuff has two tabs to do its functions. That's one tab too many.

Describe the solution you'd like Lets work on combining this functionality into a single libraries tab.

urish commented 2 years ago

Thanks! Opened for voting

leftCoast commented 2 years ago

Maybe even a "hide tab" would work? Default some tabs, .json & library.txt for example, to hidden? Just typing out loud here.

urish commented 2 years ago

Some more thoughts: We're slowly adding more and more of the diagram.json functionality into the diagram editor.

So perhaps at some point it'll make sense to have "Simple mode", where the diagram.json/libraries.txt files are hidden, and an Advanced (or Power) Mode, that allows you to edit these files.

leftCoast commented 2 years ago

That sounds like a good roadmap. The thing is, as long as you have the json thing, I fear this will cause the UI to Lag. And UI is far more important than engineers can possibly understand. (I know, I grew up with engineers.)

urish commented 2 years ago

I agreed there's a trade-off (as everything in engineering). On the other hand, it allows us to test new features more rapidly: it takes far less time to add a new property in diagram.json in comparison to creating UI.

For instance, the ESP32 has some very specific properties that most users wouldn't really care about (and don't even know about) - these properties are only useful for more advanced users: firmwareOffset, flashSize, psramSize, fullBoot, __timingOptimizations, fastTLS. They are not even documented yet :)

8689-SAMMY commented 1 year ago

Salve !e buona Domenica ;sono un neo appasionato di programmazione , overo rializzare i progetti con arduino .Ho provato a creare unico conde con piu librerie pero non mi funziona chiedo se qualcuno se mi puo aiutare a fare funzinare ,grazie !allego il code: //Here is a sample code to get started with the NodeMCU ESP8266, TFT_eSPI.h, TFT ILI9341 touchscreen, DS1302 RTC, and XPT2046_touchscreen.h libraries. This code implements a basic clock and touch interface.

//```c++

include

include

//#include

include

include

include

include

include

include

include

// Pin definitions

define TFT_CS D8 // Pin for TFT chip select

define TFT_DC D3 // Pin for TFT data/command

define TFT_RST D4 // Pin for TFT reset

define SI4703_RST D1 // Pin for Si4703 reset

define SI4703_SCL D5 // Pin for Si4703 clock

define SI4703_SDA D6 // Pin for Si4703 data

define SI4703_SEN D7 // Pin for Si4703 interrupt

// Touchscreen pins

define TS_CS_PIN 2

define TS_IRQ_PIN 7

define TFT_CS_PIN 10

define TFT_DC_PIN 17

// The TIRQ interrupt signal must be used for this example.

define TIRQ_PIN 2

define CS_PIN 8

// MOSI=11, MISO=12, SCK=13

// Initialize the TFT and Si4703 objects //si4703_Breakout(const uint8_t&, const uint8_t&);

int channel; int volume; char rdsBuffer[10];

// Initialize the TFT display using the TFT_eSPI library.

// Initialize the RTC using the DS1302 library.

// CONNECTIONS: // DS1302 CLK/SCLK --> 5 // DS1302 DAT/IO --> 4 // DS1302 RST/CE --> 2 // DS1302 VCC --> 3.3v - 5v // DS1302 GND --> GND

ThreeWire myWire(4,5,2); // IO, SCLK, CE RtcDS1302 Rtc(myWire);

define countof(a) (sizeof(a) / sizeof(a[0]))

const char data[] = "what time is it";

const int buttonPin = 2; const int maxChannels = 2; // how many channels do you want? (4 is the physical maximum for PT2314). //uint8_t channel = 1; bool loud = false; // this will be toggled later, don't touch.

PT2314 audioswitch;

int freq = 1000; //default frequency int mode = 0;

void drawMenu() { ts.fillScreen(TFT_BLACK); ts.setCursor(0, 0, 2); ts.setTextFont(2); ts.setTextColor(TFT_WHITE); ts.println("MENU"); ts.setCursor(0, 35, 2); ts.println("1. Increase Volume"); ts.setCursor(0, 70, 2); ts.println("2. Decrease Volume"); ts.setCursor(0, 105, 2); ts.println("3. Change to Mode 1"); ts.setCursor(0, 140, 2); ts.println("4. Change to Mode 2"); ts.setCursor(0, 175, 2); ts.println("5. Set Frequency"); ts.setCursor(0, 210, 2); ts.println("6. Exit Menu"); }

void increaseVolume() { pt2314.setVolume(1); }

void decreaseVolume() { pt2314.setVolume(-1); }

void changeMode1() { mode = 1; }

void changeMode2() { mode = 2; } //file copy void setFrequency() { ts.fillScreen(TFT_BLACK); ts.setCursor(0, 0, 2); ts.setTextFont(2); ts.setTextColor(TFT_WHITE); ts.println("ENTER FREQUENCY"); ts.setCursor(0, 35, 2);

String input = ""; bool done = false; while (!done) { if (ts.touched()) { TS_Point point = ts.getPoint(); MAP x = map(point.x, 0, 4095, 0, tft.width()); MAP y = map(point.y, 0, 4095, 0, tft.height()); if (y < 35) { //cancel done = true; } else if (y > 70) { //done int newFreq = input.toInt(); if (newFreq > 0 && newFreq <= 20000) { freq = newFreq; } done = true; } else { //number input int num = -1; if (x >= 20 && x < 100) { num = 1; } else if (x >= 110 && x < 190) { num = 2; } else if (x >= 200 && x < 280) { num = 3; } else if (x >= 290 && x < 370) { num = 4; } else if (x >= 380 && x < 460) { num = 5; } else if (x >= 470 && x < 550) { num = 6; } else if (x >= 560 && x < 640) { num = 7; } else if (x >= 650 && x < 730) { num = 8; } else if (x >= 740 && x < 820) { num = 9; } else if (x >= 860 && x < 940) { num = 0; } if (num >= 0) { input += String(num); ts.setTextColor(TFT_GREEN); ts.print(num); ts.setTextColor(TFT_WHITE); } } delay(50); } } }

void handleTouch() { if (touched()) {

// TS_Point point = ts.getPoint();

//updateScreenEdges(p);

// determine which screen point is closest to this touch event
PointID n = nearestScreenPoint(p);

// update the corresponding line mapping
drawMapping(n, p);

delay(30);

} }

// -- UTILITY ROUTINES (DEFINITION) -- inline bool touched() {

ifdef TIRQ_PIN

// if (tft.tirqTouched()) { // return ts.touched(); } return false;

else

return ts.touched();

endif

} MAP x = map(point.x, 0, 4095, 0, tft.width()); MAP y = map(point.y, 0, 4095, 0, tft.height()); if (y < 35) { //menu drawMenu(); while (true) { if (ts.touched()) { TS_Point point = ts.getPoint(); MAP x = map(point.x, 0, 4095, 0, tft.width()); MAP y = map(point.y, 0, 4095, 0, tft.height()); if (y < 35) { //cancel break; } else if (y > 210) { //exit return; } else if (y > 175) { //set frequency setFrequency(); return; } else if (y > 140) { //change mode if (x > 150) { changeMode2(); } else { changeMode1(); } return; } else if (y > 105) { //decrease volume decreaseVolume(); return; } else if (y > 70) { //increase volume increaseVolume(); return; } delay(200); } } } else if (mode == 1) { //input selector //do something } else if (mode == 2) { //audio spectrum analyzer //do something } } } //start copy code file; void setup() { // Initialize TFT // ts.init(); tft.setRotation(1); tft.fillScreen(TFT_BLACK); pt2314.begin(); pt2314.setBass(0); //disable bass

// Initialize Touchscreen tft.begin();

// Initialize PT2314 spectrumAnalyzer.begin();

// Add menu start MainMenu(); } //c

void setup() { // Connect to Wi-Fi. WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { delay(1000); }

// Initialize the TFT display. SPI.begin(22, 23, 19); tft.init();

// Initialize the touch screen. // tft.begin();

// Initialize the RTC. rtc.halt(false); rtc.writeProtect(false); rtc.setTime(0, 0, 0); rtc.setDate(1, 1, 2022); }

void setup() { Serial.begin(115200); while (!Serial && (millis() <= 1000U)) { continue; } tft.begin(); tft.setRotation(SCREEN_ROTATION); tft.fillScreen(ILI9341_BLACK); tft.setTextSize(1); tft.setTextColor(ILI9341_WHITE);

tft.begin(); tft.setRotation(SCREEN_ROTATION);

ifdef VERIFY_CALIBRATION

ts.calibrate(cal);

endif

// draw the crosshairs on screen only once for (int i = (int)PointID::NONE + 1; i < (int)PointID::COUNT; ++i) { crosshair(_screenPoint[i]); } }

// Initialize Touchscreen tft.begin();

// Initialize Si4703 radio if (!radio.begin()) { Serial.println("Could not find Si4703"); while (1); }

radio.setVolume(15);

// Display startup screen tft.fillScreen(TFT_BLACK); tft.setTextSize(2); tft.setTextColor(TFT_WHITE); tft.setCursor(10, 10); tft.println("Welcome to"); tft.setTextColor(TFT_CYAN); tft.setCursor(10, 30); tft.println("My Project"); delay(2000); tft.fillScreen(TFT_BLACK); }

void loop() {

if (touched()) {

// TS_Point p = ts.getPoint();

//updateScreenEdges(p);

// determine which screen point is closest to this touch event
PointID n = nearestScreenPoint(p);

// update the corresponding line mapping
drawMapping(n, p);

delay(30);

} }

}

void loop(){
if (touched()) {
TFT_Point p = ts.getPoint(); if (p.z > 50) {

//updateScreenEdges(p);

// determine which screen point is closest to this touch event
PointID n = nearestScreenPoint(p);

// update the corresponding line mapping
drawMapping(n, p);

delay(30);

}

// Update spectrum analyzer spectrumAnalyzer.update(); }

void MainMenu() { // Display main menu tft.fillScreen(TFT_BLACK); tft.setCursor(0, 0); tft.setTextSize(2); tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.println("Main Menu");

// Add menu items tft.setCursor(0, 30); tft.setTextSize(1); tft.print("1. Item 1"); tft.setCursor(0, 40); tft.print("2. Item 2"); tft.setCursor(0, 50); tft.print("3. Item 3"); }

void loop() { // Read the current time from the RTC. Time t = rtc.getTime(); int hours = t.hour; int minutes = t.min; int seconds = t.sec;

// Clear the screen. tft.fillScreen(ILI9341_BLACK);

// Draw the clock face. tft.fillCircle(120, 120, 110, TFT_BLUE); tft.fillCircle(120, 120, 105, TFT_WHITE); tft.fillCircle(120, 120, 100, TFT_BLUE); tft.drawCircle(120, 120, 110, TFT_WHITE); tft.drawCircle(120, 120, 105, TFT_BLUE); tft.drawCircle(120, 120, 100, TFT_WHITE);

// Draw the clock hands. drawHand(hours, 120, 25, TFT_RED, 5); drawHand(minutes, 120, 40, TFT_GREEN, 4); drawHand(seconds, 120, 53, TFT_YELLOW, 2);

define MAP_2D_LANDSCAPE(x, y)

TS_Point( int x = p.x; int y = p.y;

// If the touch coordinates are within the bounds of the clock face, set the time. if (x >= 10 && x <= 230 && y >= 10 && y <= 230) { int angle = getAngle(x, y); if (angle != -1) { int selectedHour = angle / 30; int selectedMinute = ((angle % 30) * 2) / 5; int selectedSecond = 0; rtc.setTime(selectedHour, selectedMinute, selectedSecond); } }

delay(1000);

} // draw the crosshairs on screen only once for (int i = (int)PointID::NONE + 1; i < (int)PointID::COUNT; ++i) { crosshair(_screenPoint[i]); } }

void loop() {

  if (touched()) {

  Serial.print("Pressure = ");
//updateScreenEdges(p);

// determine which screen point is closest to this touch event
PointID n = nearestScreenPoint(p);

// update the corresponding line mapping
drawMapping(n, p);

delay(30);

}

//updateScreenEdges(p);

define MAP_2D_LANDSCAPE(x, y) \

TS_Point(
(int16_t) x = map(p.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0); (int16_t) y = map(p.y, TS_MINY, TS_MAXY, TFT_HEIGHT, 0); void updateScreenEdges(TS_Point p) { Serial.print("Pressure = "); Serial.print(p.z); Serial.print(", x = "); Serial.print(p.x); Serial.print(", y = "); Serial.print(p.y); delay(30); Serial.println(); } } }

if (p.z > 0) { // There was a touch event

// Check if touch was in the "Play" button area
if (x > 20 && x < 220 && y > 60 && y < 160) {
  // Play button was pressed
  ts.fillScreen(TFT_BLACK);
  ts.setTextSize(2);
  ts.setTextColor(TFT_WHITE);
  ts.setCursor(10, 10);
  ts.println("Playing...");

  // Turn on radio and start playing
  radio.setVolume(15);
  radio.setChannel(97.3);
  radio.unmute();

  // Wait for stop button or touch
  while (true) {
    p = ts.getPoint();
    x = map(p.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0);
    y = map(p.y, TS_MINY, TS_MAXY, TFT_HEIGHT, 0);
    if (p.z > 0) {
      // There was a touch event

      // Check if touch was in the "Stop" button area
      if (x > 20 && x < 220 && y > 180 && y < 280) {
        // Stop button was pressed
        radio.mute();
        ts.fillScreen(TFT_BLACK);
        break;
      }
    }
  }
}

}

// Display menu ts.fillRect(20, 60, 200, 100, TFT_WHITE); ts.setTextColor(TFT_BLACK); ts.setCursor(60, 90); ts.println("Play"); ts.setCursor(60, 210); ts.println("Stop"); delay(1000); }

// Draw a clock hand at the given angle and length. void drawHand(int value, int length, int width, uint16_t color, int weight) { // Convert the value (hours, minutes, or seconds) to an angle. float angle = map(value, 0, 60, 0, 360);

// Convert the angle to radians. float radians = angle * 0.0174532925;

// Calculate the x and y coordinates of the hand. int x = length cos(radians) + 120; int y = length sin(radians) + 120;

// draw the current line

// ts.drawLine(120, 120, x, y, color, weight); }

// Get the angle (in degrees) of the touch point relative to the center of the clock face. int getAngle(int x, int y) { int centerX = 120; int centerY = 120; int adjX = abs(x - centerX); int adjY = abs(y - centerY); if (adjX >= 105 || adjY >= 105) { // Touch point is outside the clock face. return -1; } float hypotenuse = sqrt(adjX adjX + adjY adjY); float angle; if (x >= centerX && y < centerY) { // Quadrant 1. angle = asin(adjY / hypotenuse); } else if (x >= centerX && y >= centerY) { // Quadrant 2. angle = acos(adjX / hypotenuse) + 0.5 PI; } else if (x < centerX && y >= centerY) { // Quadrant 3. angle = PI - asin(adjY / hypotenuse); } else { // Quadrant 4. angle = PI + acos(adjX / hypotenuse) + 0.5 PI; } return angle * 180 / PI; }

//***Note: There are some variables and values used in this code that are declared outside of the included code block. Please make sure you provide the necessary values for WIFI_SSID, WIFI_PASSWORD, TP_CS, RTC_DAT, RTC_CLK, and RTC_RST. void setup() { // put your setup code here, to run once:

}

void loop() { // put your main code here, to run repeatedly:

}