mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
Merge pull request #278 from ficeto/esp8266
Make the web server not waste heap
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -72,3 +72,4 @@ nbproject
|
||||
build/macosx/esptool-*-osx.zip
|
||||
|
||||
build/macosx/dist/osx-xtensa-lx106-elf.tgz
|
||||
/hardware/esp8266com/esp8266/tools
|
||||
|
@ -3,7 +3,9 @@
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="_("Additional Boards Manager URLs: ")"/>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Additional Boards Manager URLs")" type="code"/>
|
||||
</Property>
|
||||
<Property name="modal" type="boolean" value="true"/>
|
||||
<Property name="modalExclusionType" type="java.awt.Dialog$ModalExclusionType" editor="org.netbeans.modules.form.editors.EnumEditor">
|
||||
<Value id="APPLICATION_EXCLUDE"/>
|
||||
@ -32,12 +34,16 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="0" pref="439" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="332" max="32767" attributes="0"/>
|
||||
<Component id="ok" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -47,7 +53,9 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="141" max="32767" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="118" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -82,7 +90,9 @@
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="cancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Cancel")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelActionPerformed"/>
|
||||
@ -94,7 +104,9 @@
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="ok">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="OK"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("OK")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okActionPerformed"/>
|
||||
@ -104,5 +116,16 @@
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enter additional URLs, one for each row")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -74,6 +74,7 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
|
||||
javax.swing.JButton cancel = new javax.swing.JButton();
|
||||
javax.swing.JButton ok = new javax.swing.JButton();
|
||||
javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(_("Additional Boards Manager URLs"));
|
||||
@ -99,6 +100,8 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText(_("Enter additional URLs, one for each row"));
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@ -107,18 +110,23 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 439, Short.MAX_VALUE)
|
||||
.addGap(0, 332, Short.MAX_VALUE)
|
||||
.addComponent(ok)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancel))
|
||||
.addComponent(jScrollPane1))
|
||||
.addComponent(jScrollPane1)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cancel)
|
||||
@ -139,48 +147,6 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
|
||||
cancelActionPerformed(evt);
|
||||
}//GEN-LAST:event_okActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(AdditionalBoardsManagerURLTextArea.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the dialog */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
AdditionalBoardsManagerURLTextArea dialog = new AdditionalBoardsManagerURLTextArea(new javax.swing.JFrame());
|
||||
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(java.awt.event.WindowEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
Collection<String> urls = splitAndTrim(text, ",");
|
||||
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
|
||||
|
@ -74,22 +74,17 @@
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" min="-2" pref="494" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" pref="36" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="additionalBoardsManagerLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="additionalBoardsManagerField" min="-2" pref="500" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="extendedAdditionalUrlFieldWindow" min="-2" pref="36" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@ -472,6 +467,9 @@
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Additional Boards Manager URLs: ")" type="code"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
@ -479,6 +477,11 @@
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="additionalBoardsManagerField">
|
||||
<Properties>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="_("Enter a comma separated list of urls")" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="extendedAdditionalUrlFieldWindow">
|
||||
<Properties>
|
||||
|
@ -379,6 +379,9 @@ public class Preferences extends javax.swing.JDialog {
|
||||
);
|
||||
|
||||
additionalBoardsManagerLabel.setText(_("Additional Boards Manager URLs: "));
|
||||
additionalBoardsManagerLabel.setToolTipText(_("Enter a comma separated list of urls"));
|
||||
|
||||
additionalBoardsManagerField.setToolTipText(_("Enter a comma separated list of urls"));
|
||||
|
||||
extendedAdditionalUrlFieldWindow.setIcon(new ImageIcon(Base.getThemeImage("newwindow.gif", this)));
|
||||
extendedAdditionalUrlFieldWindow.addActionListener(new java.awt.event.ActionListener() {
|
||||
@ -490,18 +493,15 @@ public class Preferences extends javax.swing.JDialog {
|
||||
.addComponent(preferencesFileLabel))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(additionalBoardsManagerLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(additionalBoardsManagerField, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(extendedAdditionalUrlFieldWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(okButton)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cancelButton)))))
|
||||
.addComponent(extendedAdditionalUrlFieldWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
|
@ -1422,7 +1422,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
if (find == null) {
|
||||
find = new FindReplace(Editor.this);
|
||||
}
|
||||
if (!OSUtils.isMacOS() && getSelectedText() != null) {
|
||||
if (!OSUtils.isMacOS()) {
|
||||
find.setFindText(getSelectedText());
|
||||
}
|
||||
find.setLocationRelativeTo(Editor.this);
|
||||
@ -1458,11 +1458,8 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
if (find == null) {
|
||||
find = new FindReplace(Editor.this);
|
||||
}
|
||||
if (getSelectedText() != null) {
|
||||
find.setFindText(getSelectedText());
|
||||
}
|
||||
find.setLocationRelativeTo(Editor.this);
|
||||
find.setVisible(true);
|
||||
find.findNext();
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
@ -439,9 +439,12 @@ public class FindReplace extends JFrame implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void setFindText(String t) {
|
||||
findField.setText(t);
|
||||
findString = t;
|
||||
public void setFindText(String text) {
|
||||
if (text == null) {
|
||||
return;
|
||||
}
|
||||
findField.setText(text);
|
||||
findString = text;
|
||||
}
|
||||
|
||||
public void findNext() {
|
||||
|
@ -21,34 +21,13 @@
|
||||
#include "wiring_private.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
extern uint16_t readvdd33(void);
|
||||
|
||||
void analogReference(uint8_t mode) {}
|
||||
|
||||
extern int __analogRead(uint8_t pin) {
|
||||
if(pin == 17){
|
||||
//return system_adc_read();
|
||||
uint8_t i;
|
||||
uint16_t data[8];
|
||||
|
||||
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1);
|
||||
|
||||
ESP8266_REG(0xD5C) |= (1 << 21);
|
||||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
|
||||
ESP8266_REG(0xD50) &= ~(1 << 1);
|
||||
ESP8266_REG(0xD50) |= (1 << 1);
|
||||
delayMicroseconds(2);
|
||||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
|
||||
|
||||
read_sar_dout(data);
|
||||
rom_i2c_writeReg_Mask(0x6C,2,0,5,5,1);
|
||||
|
||||
while ((ESP8266_REG(0xD50) & (7 << 24)) > 0);
|
||||
ESP8266_REG(0xD5C) &= ~(1 << 21);
|
||||
ESP8266_REG(0xD60) |= (1 << 0);
|
||||
ESP8266_REG(0xD60) &= ~(1 << 0);
|
||||
|
||||
uint16_t tout = 0;
|
||||
for (i = 0; i < 8; i++) tout += data[i];
|
||||
return tout >> 4;//tout is 10 bits fraction
|
||||
return readvdd33() >> 2; // readvdd33 is 12 bit
|
||||
}
|
||||
return digitalRead(pin) * 1023;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ void ICACHE_RAM_ATTR hexdump(uint8_t *mem, uint32_t len, uint8_t cols) {
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
if(i % cols == 0) {
|
||||
os_printf("\n[0x%08X] 0x%08X: ", mem, i);
|
||||
yield();
|
||||
}
|
||||
os_printf("%02X ", *mem);
|
||||
mem++;
|
||||
|
@ -101,7 +101,8 @@ void ESP8266WebServer::handleClient()
|
||||
#endif
|
||||
|
||||
// Wait for data from client to become available
|
||||
while(client.connected() && !client.available()){
|
||||
uint16_t maxWait = HTTP_MAX_DATA_WAIT;
|
||||
while(client.connected() && !client.available() && maxWait--){
|
||||
delay(1);
|
||||
}
|
||||
|
||||
@ -136,7 +137,12 @@ void ESP8266WebServer::send(int code, const char* content_type, String content)
|
||||
|
||||
if (!content_type)
|
||||
content_type = "text/html";
|
||||
|
||||
String len(content.length());
|
||||
sendHeader("Content-Type", content_type, true);
|
||||
sendHeader("Content-Length", len.c_str());
|
||||
sendHeader("Connection", "close");
|
||||
sendHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
response += _responseHeaders;
|
||||
response += "\r\n";
|
||||
@ -145,6 +151,14 @@ void ESP8266WebServer::send(int code, const char* content_type, String content)
|
||||
sendContent(response);
|
||||
}
|
||||
|
||||
void ESP8266WebServer::send(int code, char* content_type, String content) {
|
||||
send(code, (const char*)content_type, content);
|
||||
}
|
||||
|
||||
void ESP8266WebServer::send(int code, String content_type, String content) {
|
||||
send(code, (const char*)content_type.c_str(), content);
|
||||
}
|
||||
|
||||
void ESP8266WebServer::sendContent(String content) {
|
||||
size_t size_to_send = content.length();
|
||||
size_t size_sent = 0;
|
||||
@ -158,6 +172,10 @@ void ESP8266WebServer::sendContent(String content) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint16_t maxWait = HTTP_MAX_CLOSE_WAIT;
|
||||
while(_currentClient.connected() && maxWait--) {
|
||||
delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
String ESP8266WebServer::arg(const char* name) {
|
||||
|
@ -31,6 +31,8 @@ enum HTTPUploadStatus { UPLOAD_FILE_START, UPLOAD_FILE_WRITE, UPLOAD_FILE_END };
|
||||
|
||||
#define HTTP_DOWNLOAD_UNIT_SIZE 1460
|
||||
#define HTTP_UPLOAD_BUFLEN 2048
|
||||
#define HTTP_MAX_DATA_WAIT 1000 //ms to wait for the client to send the request
|
||||
#define HTTP_MAX_CLOSE_WAIT 2000 //ms to wait for the client to close the connection
|
||||
|
||||
typedef struct {
|
||||
HTTPUploadStatus status;
|
||||
@ -73,6 +75,8 @@ public:
|
||||
// content_type - HTTP content type, like "text/plain" or "image/png"
|
||||
// content - actual content body
|
||||
void send(int code, const char* content_type = NULL, String content = String(""));
|
||||
void send(int code, char* content_type, String content);
|
||||
void send(int code, String content_type, String content);
|
||||
|
||||
void sendHeader(String name, String value, bool first = false);
|
||||
void sendContent(String content);
|
||||
@ -87,7 +91,12 @@ template<typename T> size_t streamFile(T &file, String contentType){
|
||||
head += "\r\n\r\n";
|
||||
_currentClient.print(head);
|
||||
head = String();
|
||||
return _currentClient.write(file, HTTP_DOWNLOAD_UNIT_SIZE);
|
||||
size_t res = _currentClient.write(file, HTTP_DOWNLOAD_UNIT_SIZE);
|
||||
uint16_t maxWait = HTTP_MAX_CLOSE_WAIT;
|
||||
while(_currentClient.connected() && maxWait--) {
|
||||
delay(1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -127,7 +127,7 @@ void Adafruit_ILI9341::spiwrite(uint8_t c) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void Adafruit_ILI9341::spiwriteBytes(uint8_t * data, uint8_t size) {
|
||||
void Adafruit_ILI9341::spiwriteBytes(uint8_t * data, uint32_t size) {
|
||||
#ifdef ESP8266
|
||||
SPI.writeBytes(data, size);
|
||||
#else
|
||||
@ -250,13 +250,21 @@ void Adafruit_ILI9341::writeCmdData(uint8_t cmd, uint8_t * data, uint8_t size) {
|
||||
spiCsHigh();
|
||||
}
|
||||
|
||||
uint16_t Adafruit_ILI9341::getHeight(void) {
|
||||
return _height;
|
||||
}
|
||||
|
||||
uint16_t Adafruit_ILI9341::getWidth(void){
|
||||
return _width;
|
||||
}
|
||||
|
||||
// If the SPI library has transaction support, these functions
|
||||
// establish settings and protect from interference from other
|
||||
// libraries. Otherwise, they simply do nothing.
|
||||
#ifdef SPI_HAS_TRANSACTION
|
||||
|
||||
#ifdef ESP8266
|
||||
SPISettings spiSettings = SPISettings(F_CPU, MSBFIRST, SPI_MODE0);
|
||||
SPISettings spiSettings = SPISettings(SPI_MAX_SPEED, MSBFIRST, SPI_MODE0);
|
||||
#else
|
||||
SPISettings spiSettings = SPISettings(8000000, MSBFIRST, SPI_MODE0);
|
||||
#endif
|
||||
@ -438,6 +446,20 @@ void Adafruit_ILI9341::begin(void) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Adafruit_ILI9341::area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
spiCsLow();
|
||||
setAddrWindow_(x, y, x + w - 1, y + h - 1);
|
||||
}
|
||||
|
||||
void Adafruit_ILI9341::area_update_data(uint8_t *data, uint32_t pixel){
|
||||
spiwriteBytes(&data[0], (pixel*2));
|
||||
}
|
||||
|
||||
void Adafruit_ILI9341::area_update_end(void){
|
||||
spiCsHigh();
|
||||
}
|
||||
|
||||
void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||
spiCsLow();
|
||||
setAddrWindow_(x0, y0, x1, y1);
|
||||
@ -583,7 +605,7 @@ void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint
|
||||
|
||||
spiCsLow();
|
||||
|
||||
setAddrWindow_(x, y, x + w - 1, y + h - 1);
|
||||
setAddrWindow_(x, y, (x + w - 1), (y + h - 1));
|
||||
|
||||
uint8_t colorBin[] = { (uint8_t) (color >> 8), (uint8_t) color };
|
||||
spiwritePattern(&colorBin[0], 2, (w * h));
|
||||
|
@ -158,6 +158,13 @@ class Adafruit_ILI9341 : public Adafruit_GFX {
|
||||
void writedata(uint8_t * data, uint8_t size);
|
||||
void writeCmdData(uint8_t cmd, uint8_t * data, uint8_t size);
|
||||
|
||||
|
||||
uint16_t getHeight(void);
|
||||
uint16_t getWidth(void);
|
||||
|
||||
void area_update_start(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
||||
void area_update_data(uint8_t *data, uint32_t pixel);
|
||||
void area_update_end(void);
|
||||
private:
|
||||
|
||||
uint8_t spiread(void);
|
||||
@ -166,7 +173,7 @@ class Adafruit_ILI9341 : public Adafruit_GFX {
|
||||
#ifdef ESP8266
|
||||
inline void spiwrite(uint8_t data);
|
||||
inline void spiwrite16(uint16_t data);
|
||||
inline void spiwriteBytes(uint8_t * data, uint8_t size);
|
||||
inline void spiwriteBytes(uint8_t * data, uint32_t size);
|
||||
inline void spiwritePattern(uint8_t * data, uint8_t size, uint32_t repeat);
|
||||
|
||||
inline void setAddrWindow_(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
||||
|
Reference in New Issue
Block a user