Compare commits
	
		
			8 commits
		
	
	
		
			main
			...
			lcd_upload
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 88c2003116 | |||
| 1206427e82 | |||
| 7351c8d46a | |||
| 4c54da6e34 | |||
| e2bf2610b3 | |||
| 0c31060035 | |||
| 6ba2a1a0f7 | |||
| d056e6fa7b | 
					 6 changed files with 51 additions and 94 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -7,4 +7,5 @@
 | 
				
			||||||
.vscode/
 | 
					.vscode/
 | 
				
			||||||
.vscode/settings.json
 | 
					.vscode/settings.json
 | 
				
			||||||
firmware/
 | 
					firmware/
 | 
				
			||||||
release/
 | 
					release/
 | 
				
			||||||
 | 
					.vscode/extensions.json
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										78
									
								
								.vscode/settings.json
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										78
									
								
								.vscode/settings.json
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,78 +0,0 @@
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  "C_Cpp.errorSquiggles": "enabled",
 | 
					 | 
				
			||||||
  "files.associations": {
 | 
					 | 
				
			||||||
    "*.cps": "javascript",
 | 
					 | 
				
			||||||
    "string": "cpp",
 | 
					 | 
				
			||||||
    "optional": "cpp",
 | 
					 | 
				
			||||||
    "istream": "cpp",
 | 
					 | 
				
			||||||
    "ostream": "cpp",
 | 
					 | 
				
			||||||
    "system_error": "cpp",
 | 
					 | 
				
			||||||
    "array": "cpp",
 | 
					 | 
				
			||||||
    "functional": "cpp",
 | 
					 | 
				
			||||||
    "tuple": "cpp",
 | 
					 | 
				
			||||||
    "type_traits": "cpp",
 | 
					 | 
				
			||||||
    "utility": "cpp",
 | 
					 | 
				
			||||||
    "*.d": "cpp",
 | 
					 | 
				
			||||||
    "*.html": "cpp",
 | 
					 | 
				
			||||||
    "*.tcc": "cpp",
 | 
					 | 
				
			||||||
    "regex": "cpp"
 | 
					 | 
				
			||||||
  },
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.msvcBatchPath": "",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.cCompilerPath": "gcc",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.cppCompilerPath": "g++",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.debuggerPath": "gdb",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.cStandard": "",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.cppStandard": "",
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.useMsvc": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.warnings": [
 | 
					 | 
				
			||||||
    "-Wall",
 | 
					 | 
				
			||||||
    "-Wextra",
 | 
					 | 
				
			||||||
    "-Wpedantic",
 | 
					 | 
				
			||||||
    "-Wshadow",
 | 
					 | 
				
			||||||
    "-Wformat=2",
 | 
					 | 
				
			||||||
    "-Wcast-align",
 | 
					 | 
				
			||||||
    "-Wconversion",
 | 
					 | 
				
			||||||
    "-Wsign-conversion",
 | 
					 | 
				
			||||||
    "-Wnull-dereference"
 | 
					 | 
				
			||||||
  ],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.msvcWarnings": [
 | 
					 | 
				
			||||||
    "/W4",
 | 
					 | 
				
			||||||
    "/permissive-",
 | 
					 | 
				
			||||||
    "/w14242",
 | 
					 | 
				
			||||||
    "/w14287",
 | 
					 | 
				
			||||||
    "/w14296",
 | 
					 | 
				
			||||||
    "/w14311",
 | 
					 | 
				
			||||||
    "/w14826",
 | 
					 | 
				
			||||||
    "/w44062",
 | 
					 | 
				
			||||||
    "/w44242",
 | 
					 | 
				
			||||||
    "/w14905",
 | 
					 | 
				
			||||||
    "/w14906",
 | 
					 | 
				
			||||||
    "/w14263",
 | 
					 | 
				
			||||||
    "/w44265",
 | 
					 | 
				
			||||||
    "/w14928"
 | 
					 | 
				
			||||||
  ],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.enableWarnings": true,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.warningsAsError": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.compilerArgs": [],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.linkerArgs": [],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.includePaths": [],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.includeSearch": [
 | 
					 | 
				
			||||||
    "*",
 | 
					 | 
				
			||||||
    "**/*"
 | 
					 | 
				
			||||||
  ],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.excludeSearch": [
 | 
					 | 
				
			||||||
    "**/build",
 | 
					 | 
				
			||||||
    "**/build/**",
 | 
					 | 
				
			||||||
    "**/.*",
 | 
					 | 
				
			||||||
    "**/.*/**",
 | 
					 | 
				
			||||||
    "**/.vscode",
 | 
					 | 
				
			||||||
    "**/.vscode/**"
 | 
					 | 
				
			||||||
  ],
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.useAddressSanitizer": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.useUndefinedSanitizer": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.useLeakSanitizer": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.showCompilationTime": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.useLinkTimeOptimization": false,
 | 
					 | 
				
			||||||
  "C_Cpp_Runner.msvcSecureNoWarnings": false,
 | 
					 | 
				
			||||||
  "cmake.sourceDirectory": "D:/Git/iot-firmware/.pio/libdeps/full/Adafruit BusIO"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										2
									
								
								Jenkinsfile
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								Jenkinsfile
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -4,7 +4,7 @@ pipeline {
 | 
				
			||||||
    stages {
 | 
					    stages {
 | 
				
			||||||
        stage('Build') {
 | 
					        stage('Build') {
 | 
				
			||||||
            steps {
 | 
					            steps {
 | 
				
			||||||
                git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git'
 | 
					                git branch: 'lcd_upload', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git'
 | 
				
			||||||
                sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio'
 | 
					                sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio'
 | 
				
			||||||
                sh '/usr/bin/python3 gen_release.py'
 | 
					                sh '/usr/bin/python3 gen_release.py'
 | 
				
			||||||
                stash includes: 'release/**/*', name: 'release_binaries'
 | 
					                stash includes: 'release/**/*', name: 'release_binaries'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -547,6 +547,24 @@ void ota_begin()
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
					  otaserver.on("/lcd_update",HTTP_POST,[]() {
 | 
				
			||||||
 | 
					    otaserver.sendHeader("Connection","close");
 | 
				
			||||||
 | 
					  },[](){
 | 
				
			||||||
 | 
					    for(int i=0;i<otaserver.headers();i++) {
 | 
				
			||||||
 | 
					        // Print all headers
 | 
				
			||||||
 | 
					        Serial.printf("HEADER[%s]:[%s]\n", otaserver.headerName(i).c_str(), otaserver.header(i).c_str());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    HTTPUpload &upload = otaserver.upload();
 | 
				
			||||||
 | 
					    size_t file_size = 0;
 | 
				
			||||||
 | 
					    if(upload.status == UPLOAD_FILE_START) {
 | 
				
			||||||
 | 
					      Serial.println(file_size);
 | 
				
			||||||
 | 
					      lcd_upload_start(file_size);
 | 
				
			||||||
 | 
					    } else if (upload.status == UPLOAD_FILE_WRITE) {
 | 
				
			||||||
 | 
					      lcd_upload_write(upload.buf, upload.currentSize);
 | 
				
			||||||
 | 
					    } else if (upload.status == UPLOAD_FILE_END) {
 | 
				
			||||||
 | 
					      Serial.println("Upload END.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
  otaserver.begin();
 | 
					  otaserver.begin();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,11 @@
 | 
				
			||||||
#include <user_code.hpp>
 | 
					#include <user_code.hpp>
 | 
				
			||||||
#include <espmega_iot_lcd.hpp>
 | 
					#include <espmega_iot_lcd.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int lcd_byte_counter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Sends stop bit to LCD.
 | 
					 * @brief Sends stop bit to LCD.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 * This function sends a stop bit to the LCD. It is only enabled if the ENABLE_INTERNAL_LCD macro is defined.
 | 
					 * This function sends a stop bit to the LCD. It is only enabled if the ENABLE_INTERNAL_LCD macro is defined.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void lcd_send_stop_bit()
 | 
					void lcd_send_stop_bit()
 | 
				
			||||||
| 
						 | 
					@ -17,7 +19,7 @@ void lcd_send_stop_bit()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Sends a command to the LCD display.
 | 
					 * Sends a command to the LCD display.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 * @param command The command to send to the LCD display.
 | 
					 * @param command The command to send to the LCD display.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void lcd_send_command(String command)
 | 
					void lcd_send_command(String command)
 | 
				
			||||||
| 
						 | 
					@ -31,9 +33,9 @@ void lcd_send_command(String command)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Resets the LCD display.
 | 
					 * @brief Resets the LCD display.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 * If ENABLE_INTERNAL_LCD is defined, sends a reset command to the LCD display.
 | 
					 * If ENABLE_INTERNAL_LCD is defined, sends a reset command to the LCD display.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void lcd_reset()
 | 
					void lcd_reset()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -57,7 +59,7 @@ void lcd_init()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Starts the upload process to the LCD.
 | 
					 * @brief Starts the upload process to the LCD.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 * @param size The size of the data to be uploaded.
 | 
					 * @param size The size of the data to be uploaded.
 | 
				
			||||||
 * @return true if the upload process started successfully, false otherwise.
 | 
					 * @return true if the upload process started successfully, false otherwise.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
| 
						 | 
					@ -70,14 +72,16 @@ bool lcd_upload_start(size_t size)
 | 
				
			||||||
    Serial.print("connect");
 | 
					    Serial.print("connect");
 | 
				
			||||||
    lcd_send_stop_bit();
 | 
					    lcd_send_stop_bit();
 | 
				
			||||||
    delay(1000);
 | 
					    delay(1000);
 | 
				
			||||||
    Serial.print("whmi-wri 1024,115200,res0");
 | 
					    Serial.print("whmi-wri ");
 | 
				
			||||||
 | 
					    Serial.print(size);
 | 
				
			||||||
 | 
					    Serial.print(",115200,res0");
 | 
				
			||||||
    lcd_send_stop_bit();
 | 
					    lcd_send_stop_bit();
 | 
				
			||||||
    lcd_wait_ack();
 | 
					    return lcd_wait_ack();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Writes data to the LCD upload buffer.
 | 
					 * Writes data to the LCD upload buffer.
 | 
				
			||||||
 * 
 | 
					 *
 | 
				
			||||||
 * @param data Pointer to the data to be written.
 | 
					 * @param data Pointer to the data to be written.
 | 
				
			||||||
 * @param size Size of the data to be written.
 | 
					 * @param size Size of the data to be written.
 | 
				
			||||||
 * @return True if the write was successful, false otherwise.
 | 
					 * @return True if the write was successful, false otherwise.
 | 
				
			||||||
| 
						 | 
					@ -87,9 +91,15 @@ bool lcd_upload_write(uint8_t *data, size_t size)
 | 
				
			||||||
    for (int i = 0; i < size; i++)
 | 
					    for (int i = 0; i < size; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Serial.write(data[i]);
 | 
					        Serial.write(data[i]);
 | 
				
			||||||
 | 
					        lcd_byte_counter++;
 | 
				
			||||||
 | 
					        if (lcd_byte_counter == 4096)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            lcd_wait_ack();
 | 
				
			||||||
 | 
					            lcd_byte_counter = 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Waits for an acknowledgement signal from the LCD.
 | 
					 * Waits for an acknowledgement signal from the LCD.
 | 
				
			||||||
 * @return true if acknowledgement signal is received, false otherwise.
 | 
					 * @return true if acknowledgement signal is received, false otherwise.
 | 
				
			||||||
| 
						 | 
					@ -97,12 +107,15 @@ bool lcd_upload_write(uint8_t *data, size_t size)
 | 
				
			||||||
bool lcd_wait_ack()
 | 
					bool lcd_wait_ack()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    bool data_ok = false;
 | 
					    bool data_ok = false;
 | 
				
			||||||
    for (int i; i < 50; i++)
 | 
					    for (int i = 0; i < 50; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (Serial.read() == 0x05)
 | 
					        if (Serial.available())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            data_ok = true;
 | 
					            if (Serial.read() == 0x05)
 | 
				
			||||||
            break;
 | 
					            {
 | 
				
			||||||
 | 
					                data_ok = true;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        delay(100);
 | 
					        delay(100);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,11 +23,14 @@ R"=====(<button type="button" class="conf" onclick="window.location.href='config
 | 
				
			||||||
    var form = $("#upload_form")[0];
 | 
					    var form = $("#upload_form")[0];
 | 
				
			||||||
    var data = new FormData(form);
 | 
					    var data = new FormData(form);
 | 
				
			||||||
    $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
      url: "/update",
 | 
					      url: "/lcd_update",
 | 
				
			||||||
      type: "POST",
 | 
					      type: "POST",
 | 
				
			||||||
      data: data,
 | 
					      data: data,
 | 
				
			||||||
      contentType: false,
 | 
					      contentType: false,
 | 
				
			||||||
      processData: false,
 | 
					      processData: false,
 | 
				
			||||||
 | 
					      headers: {
 | 
				
			||||||
 | 
					        "Content-Length": data.length
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
      xhr: function () {
 | 
					      xhr: function () {
 | 
				
			||||||
        var xhr = new window.XMLHttpRequest();
 | 
					        var xhr = new window.XMLHttpRequest();
 | 
				
			||||||
        xhr.upload.addEventListener(
 | 
					        xhr.upload.addEventListener(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue