Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:cmoarcas:adrian.ariton [2025/05/21 00:47]
adrian.ariton int pass_env_temperatures_read_interv_millis = 1000; const int pass_env_temperatures_read_limit = 10; const float pass_temp_threshold_celsius = 0.5;
pm:prj2025:cmoarcas:adrian.ariton [2025/05/25 22:21] (current)
adrian.ariton
Line 2: Line 2:
 ===== Introducere ===== ===== Introducere =====
  
 +<​html><​iframe width="​560"​ height="​315"​ src="​https://​www.youtube.com/​embed/​TrdBkxlq2JE?​si=ej5ocPEVzuya_28Z"​ title="​YouTube video player"​ frameborder="​0"​ allow="​accelerometer;​ autoplay; clipboard-write;​ encrypted-media;​ gyroscope; picture-in-picture;​ web-share"​ referrerpolicy="​strict-origin-when-cross-origin"​ allowfullscreen></​iframe></​html>​
 +
 +https://​github.com/​adrianariton/​PMProj
 +
 +Updated project:
 +https://​youtube.com/​shorts/​TrdBkxlq2JE?​feature=share
 +
 +Old version: ​
 +https://​youtube.com/​shorts/​uZILq4yrm3E?​feature=share
  
 Proiectul **"​Bomb Defusal Challenge"​** este un joc fizic interactiv inspirat de "Keep Talking and Nobody Explodes"​. ​ Proiectul **"​Bomb Defusal Challenge"​** este un joc fizic interactiv inspirat de "Keep Talking and Nobody Explodes"​. ​
Line 118: Line 127:
   * (etapa 3) surse şi funcţii implementate   * (etapa 3) surse şi funcţii implementate
 </​note>​ </​note>​
 +
 +=== Descriere ===
  
 Deignuit pe Platformio: VSCode. Deignuit pe Platformio: VSCode.
Line 129: Line 140:
 * Arduino.h - pt ft putine lucruri (setup) * Arduino.h - pt ft putine lucruri (setup)
  
 +=== Code Snippets ===
  
 Timer loop: Timer loop:
Line 137: Line 149:
     portENTER_CRITICAL_ISR(&​timerMux);​     portENTER_CRITICAL_ISR(&​timerMux);​
     myMillis++;     myMillis++;
- 
     if (myMillis % 200 == 0) {     if (myMillis % 200 == 0) {
- 
       if (is_active(GAME_SIMON_SAYS)) {       if (is_active(GAME_SIMON_SAYS)) {
         if (simon_can_do_next_round){         if (simon_can_do_next_round){
Line 175: Line 185:
           wire_cut_game_start_time = myMillis;           wire_cut_game_start_time = myMillis;
         }         }
- 
         if (wire_cut_game_started) {         if (wire_cut_game_started) {
           int deltaMilisSinceWireCutStart = (myMillis - wire_cut_game_start_time);​           int deltaMilisSinceWireCutStart = (myMillis - wire_cut_game_start_time);​
Line 188: Line 197:
           }           }
         }         }
-         +      ​else if (is_active(GAME_PASS_UNLOCK)) {
-      } +
-       +
-       else if (is_active(GAME_PASS_UNLOCK)) {+
         if (!pass_game_started) {         if (!pass_game_started) {
           pass_game_started = true;           pass_game_started = true;
Line 197: Line 203:
           passUnlockOnStart();​           passUnlockOnStart();​
         }         }
- 
- 
         if (pass_game_started) {         if (pass_game_started) {
           int dm = (myMillis - pass_game_start_time);​           int dm = (myMillis - pass_game_start_time);​
Line 213: Line 217:
         }         }
     }     }
-    ​ 
-  ​ 
     portEXIT_CRITICAL_ISR(&​timerMux);​     portEXIT_CRITICAL_ISR(&​timerMux);​
   }   }
Line 253: Line 255:
 ! Singura folosire a delay-ului implementat nu de mine (custom) e in functia de playNote care ajuta la audio. ! Singura folosire a delay-ului implementat nu de mine (custom) e in functia de playNote care ajuta la audio.
  
-const int dacPin = 25;    // DAC1 - GPIO25 +  ​const int dacPin = 25;    // DAC1 - GPIO25 
-const int frequency = 1000;  // tone frequency Hz +  const int frequency = 1000;  // tone frequency Hz 
-const int duration = 100;   // duration in ms+  const int duration = 100;   // duration in ms
  
   void playTone(int freq, int dur_ticks=1) {   void playTone(int freq, int dur_ticks=1) {
Line 279: Line 281:
 I2C ul se face pe pinii 26 si 27, pt ca pinul 25 e folosit pt DAC. I2C ul se face pe pinii 26 si 27, pt ca pinul 25 e folosit pt DAC.
 Acesta e conectat atat la senzorl giroscopic cat si la cel de temperatura. Acesta e conectat atat la senzorl giroscopic cat si la cel de temperatura.
 +
 +Senzorii de giroscop si temperatura sunt implementati cu drivere programate de mine dupa datasheets.
 +
 +E.g. (girocop):
 +
 +
 +  // Calculate B5 value from the datasheet
 +  int32_t computeB5(int32_t UT) {
 +    int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15;
 +    int32_t X2 = ((int32_t)mc << 11) / (X1 + (int32_t)md);​
 +    return X1 + X2;
 +  }
 +  ​
 +  float readTemperature() {
 +    int32_t UT = readRawTemperature();​
 +    int32_t B5 = computeB5(UT);​
 +    ​
 +    // Temperature in units of 0.1 deg C
 +    float temp = ((B5 + 8) >> 4);
 +    ​
 +    // Convert to degrees C
 +    return temp / 10.0;
 +  }
 +  ​
 +  uint32_t readRawPressure() {
 +    write8(BMP180_CONTROL,​ BMP180_READPRESSURECMD + (oversampling << 6));
 +    ​
 +    // Wait for conversion based on oversampling setting
 +    if (oversampling == BMP180_ULTRALOWPOWER)
 +      delay(5);
 +    else if (oversampling == BMP180_STANDARD)
 +      delay(8);
 +    else if (oversampling == BMP180_HIGHRES)
 +      delay(14);
 +    else
 +      delay(26);
 +    ​
 +    uint32_t MSB = read8(BMP180_PRESSUREDATA);​
 +    uint32_t LSB = read8(BMP180_PRESSUREDATA + 1);
 +    uint32_t XLSB = read8(BMP180_PRESSUREDATA + 2);
 +    ​
 +    // Combine readings with proper shifting based on oversampling
 +    uint32_t raw = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - oversampling);​
 +    return raw;
 +  }
 +  ​
 +  int32_t readPressure() {
 +    // Read raw temperature value first
 +    int32_t UT = readRawTemperature();​
 +    // Then read raw pressure value
 +    int32_t UP = readRawPressure();​
 +    ​
 +    // Temperature compensation
 +    int32_t B5 = computeB5(UT);​
 +    ​
 +    // Do pressure calculations (straight from Adafruit code)
 +    int32_t B6 = B5 - 4000;
 +    int32_t X1 = ((int32_t)b2 * ((B6 * B6) >> 12)) >> 11;
 +    int32_t X2 = ((int32_t)ac2 * B6) >> 11;
 +    int32_t X3 = X1 + X2;
 +    int32_t B3 = ((((int32_t)ac1 * 4 + X3) << oversampling) + 2) / 4;
 +    ​
 +    X1 = ((int32_t)ac3 * B6) >> 13;
 +    X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16;
 +    X3 = ((X1 + X2) + 2) >> 2;
 +    uint32_t B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15;
 +    uint32_t B7 = ((uint32_t)UP - B3) * (uint32_t)(50000UL >> oversampling);​
 +    ​
 +    int32_t p;
 +    if (B7 < 0x80000000) {
 +      p = (B7 * 2) / B4;
 +    } else {
 +      p = (B7 / B4) * 2;
 +    }
 +    ​
 +    X1 = (p >> 8) * (p >> 8);
 +    X1 = (X1 * 3038) >> 16;
 +    X2 = (-7357 * p) >> 16;
 +    p = p + ((X1 + X2 + (int32_t)3791) >> 4);
 +    ​
 +    return p; // Pressure in Pa
 +  }
 +  ​
 +  // Calculate altitude based on atmospheric pressure
 +  float readAltitude(float seaLevelPressure) {
 +    float pressure = readPressure();​
 +    float altitude = 44330 * (1.0 - pow(pressure / seaLevelPressure,​ 0.1903));
 +    return altitude;
 +  }
 +
 +
 +== Dificultati:​ ==
 +
 +* am setat frecventa la ceasul de transmisie i2c mai jos pt a compensa rezistentele de pullup puse in paralel
 +
 +
  
 ===== Rezultate Obţinute ===== ===== Rezultate Obţinute =====
Line 285: Line 383:
 Care au fost rezultatele obţinute în urma realizării proiectului vostru. Care au fost rezultatele obţinute în urma realizării proiectului vostru.
 </​note>​ </​note>​
 +
 +* Jocuri calibrabile si modificabile
 +
 +* Un workflow nedependent de main loop
  
 ===== Concluzii ===== ===== Concluzii =====
Line 296: Line 398:
 </​note>​ </​note>​
  
 +
 +https://​github.com/​adrianariton/​PMProj
 ===== Jurnal ===== ===== Jurnal =====
  
pm/prj2025/cmoarcas/adrian.ariton.1747777647.txt.gz · Last modified: 2025/05/21 00:47 by adrian.ariton
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0