Merge branch 'main' into display
This commit is contained in:
		
						commit
						6acf99d894
					
				| @ -34,12 +34,13 @@ buzzer_t::buzzer_t(gpio_num_t gpio_pin_f, uint16_t msGap_f){ | |||||||
| //=========== beep ===========
 | //=========== beep ===========
 | ||||||
| //============================
 | //============================
 | ||||||
| //function to add a beep command to the queue
 | //function to add a beep command to the queue
 | ||||||
| void buzzer_t::beep(uint8_t count, uint16_t msOn, uint16_t msOff){ | void buzzer_t::beep(uint8_t count, uint16_t msOn, uint16_t msOff, bool noGap){ | ||||||
|     //create entry struct with provided data
 |     //create entry struct with provided data
 | ||||||
|     struct beepEntry entryInsert = { |     struct beepEntry entryInsert = { | ||||||
|         count = count, |         count = count, | ||||||
|         msOn = msOn, |         msOn = msOn, | ||||||
|         msOff = msOff |         msOff = msOff, | ||||||
|  |         noGap = noGap | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     // Send a pointer to a struct AMessage object.  Don't block if the
 |     // Send a pointer to a struct AMessage object.  Don't block if the
 | ||||||
| @ -83,8 +84,10 @@ void buzzer_t::processQueue(){ | |||||||
|                     gpio_set_level(gpio_pin, 0);                 |                     gpio_set_level(gpio_pin, 0);                 | ||||||
|                     vTaskDelay(entryRead.msOff / portTICK_PERIOD_MS); |                     vTaskDelay(entryRead.msOff / portTICK_PERIOD_MS); | ||||||
|                 } |                 } | ||||||
|                 //wait for minimum gap between beep events
 |                 if( entryRead.noGap == false ){ | ||||||
|                 vTaskDelay(msGap / portTICK_PERIOD_MS); |                     //wait for minimum gap between beep events
 | ||||||
|  |                     vTaskDelay(msGap / portTICK_PERIOD_MS); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         }else{ //wait for queue to become available
 |         }else{ //wait for queue to become available
 | ||||||
|             vTaskDelay(50 / portTICK_PERIOD_MS); |             vTaskDelay(50 / portTICK_PERIOD_MS); | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ class buzzer_t { | |||||||
| 
 | 
 | ||||||
|         //--- functions ---
 |         //--- functions ---
 | ||||||
|         void processQueue(); //has to be run once in a separate task, waits for and processes queued events
 |         void processQueue(); //has to be run once in a separate task, waits for and processes queued events
 | ||||||
|         void beep(uint8_t count, uint16_t msOn, uint16_t msOff); |         void beep(uint8_t count, uint16_t msOn, uint16_t msOff, bool noGap = false); | ||||||
|         //void clear(); (TODO - not implemented yet)
 |         //void clear(); (TODO - not implemented yet)
 | ||||||
|         //void createTask(); (TODO - not implemented yet)
 |         //void createTask(); (TODO - not implemented yet)
 | ||||||
| 
 | 
 | ||||||
| @ -45,6 +45,7 @@ class buzzer_t { | |||||||
|             uint8_t count; |             uint8_t count; | ||||||
|             uint16_t msOn; |             uint16_t msOn; | ||||||
|             uint16_t msOff; |             uint16_t msOff; | ||||||
|  |             bool noGap; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         //queue for queueing up multiple events while one is still processing
 |         //queue for queueing up multiple events while one is still processing
 | ||||||
|  | |||||||
| @ -11,5 +11,5 @@ gpio_evaluatedSwitch SW_PRESET2(GPIO_SW_PRESET2, false, true); //pullup false, I | |||||||
| gpio_evaluatedSwitch SW_PRESET3(GPIO_SW_PRESET3, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered)
 | gpio_evaluatedSwitch SW_PRESET3(GPIO_SW_PRESET3, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered)
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //create buzzer object with gap between queued events of 100ms 
 | //create buzzer object with no gap between beep events
 | ||||||
| buzzer_t buzzer(GPIO_BUZZER, 100); | buzzer_t buzzer(GPIO_BUZZER, 0); | ||||||
|  | |||||||
| @ -209,14 +209,24 @@ void task_control(void *pvParameter) | |||||||
|             //read adc
 |             //read adc
 | ||||||
|             potiRead = readAdc(ADC_CHANNEL_POTI); //0-4095
 |             potiRead = readAdc(ADC_CHANNEL_POTI); //0-4095
 | ||||||
|             //scale to target length range
 |             //scale to target length range
 | ||||||
|             int lengthTargetNew = (float)potiRead / 4095 * 50000; |             int lengthTargetNew = (float)potiRead / 4095 * 30000; | ||||||
|             //round to whole meters
 |             //apply hysteresis and round to whole meters //TODO optimize this
 | ||||||
|             lengthTarget = round(lengthTarget / 1000) * 1000; |             if (lengthTargetNew % 1000 < 200) { //round down if less than .2 meter
 | ||||||
|             //update target length and beep if changed
 |                 ESP_LOGD(TAG, "Poti input = %d -> rounding down", lengthTargetNew); | ||||||
|  |                 lengthTargetNew = (lengthTargetNew/1000 ) * 1000; //round down
 | ||||||
|  |             } else if (lengthTargetNew % 1000 > 800 ) { //round up if more than .8 meter
 | ||||||
|  |                 ESP_LOGD(TAG, "Poti input = %d -> rounding up", lengthTargetNew); | ||||||
|  |                 lengthTargetNew = (lengthTargetNew/1000 + 1) * 1000; //round up
 | ||||||
|  |             } else { | ||||||
|  |                 ESP_LOGD(TAG, "Poti input = %d -> hysteresis", lengthTargetNew); | ||||||
|  |                 lengthTargetNew = lengthTarget; | ||||||
|  |             } | ||||||
|  |             //update target length and beep when effectively changed
 | ||||||
|             if (lengthTargetNew != lengthTarget) { |             if (lengthTargetNew != lengthTarget) { | ||||||
|                 //TODO update lengthTarget only at button release?
 |                 //TODO update lengthTarget only at button release?
 | ||||||
|                 lengthTarget = lengthTargetNew; |                 lengthTarget = lengthTargetNew; | ||||||
|                 buzzer.beep(1, 60, 0); |                 ESP_LOGI(TAG, "Changed target length to %d mm", lengthTarget); | ||||||
|  |                 buzzer.beep(1, 25, 10); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         //beep start and end of editing
 |         //beep start and end of editing
 | ||||||
| @ -232,15 +242,15 @@ void task_control(void *pvParameter) | |||||||
|         if (controlState != MANUAL) { //dont apply preset length while controlling motor with preset buttons
 |         if (controlState != MANUAL) { //dont apply preset length while controlling motor with preset buttons
 | ||||||
|             if (SW_PRESET1.risingEdge){ |             if (SW_PRESET1.risingEdge){ | ||||||
|                 lengthTarget = 1000; |                 lengthTarget = 1000; | ||||||
|                 buzzer.beep(lengthTarget/1000, 50, 30); |                 buzzer.beep(lengthTarget/1000, 25, 30); | ||||||
|             } |             } | ||||||
|             else if (SW_PRESET2.risingEdge) { |             else if (SW_PRESET2.risingEdge) { | ||||||
|                 lengthTarget = 5000; |                 lengthTarget = 5000; | ||||||
|                 buzzer.beep(lengthTarget/1000, 50, 30); |                 buzzer.beep(lengthTarget/1000, 25, 30); | ||||||
|             } |             } | ||||||
|             else if (SW_PRESET3.risingEdge) { |             else if (SW_PRESET3.risingEdge) { | ||||||
|                 lengthTarget = 10000; |                 lengthTarget = 10000; | ||||||
|                 buzzer.beep(lengthTarget/1000, 50, 30); |                 buzzer.beep(lengthTarget/1000, 25, 30); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -721,10 +721,10 @@ CONFIG_LOG_DEFAULT_LEVEL_INFO=y | |||||||
| # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set | ||||||
| # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set | ||||||
| CONFIG_LOG_DEFAULT_LEVEL=3 | CONFIG_LOG_DEFAULT_LEVEL=3 | ||||||
| CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y | # CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT is not set | ||||||
| # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set | # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set | ||||||
| # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set | CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE=y | ||||||
| CONFIG_LOG_MAXIMUM_LEVEL=3 | CONFIG_LOG_MAXIMUM_LEVEL=5 | ||||||
| CONFIG_LOG_COLORS=y | CONFIG_LOG_COLORS=y | ||||||
| CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y | CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y | ||||||
| # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set | # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user