配置esp-idf开发环境

最近入手ESP-32CAM,自带程序是网络摄像头,图片获取速度平均1.3s一帧,图片流获取速度一秒5帧左右,而且这1帧是所有请求共享的。。。
好吧,看在RMB50还自带摄像头的份子上也还不错了。
接下来,如果想要对它改写程序必须配置esp32-idf的环境。
当时什么都看,直接clone了master分支,master分支是v4.1的开发版本,为后来的的配环境的困难埋下隐患。
先根据官方的入门文档 https://docs.espressif.com/projects/esp-idf/zh_CN/latest/get-started/index.html
笔者电脑里有三个python环境
1是anaconda的python2
2是Python3.6
3是miniconda的python3.7
在windows工具链安装过程中,使用python2和miniconda的python3.7均未能完成安装,采用python3.6成功安装。
当时它自动添加%IDF_PATH%的环境变量失败,手动添加解决
当windows下运行install.ps1脚本时候,因为powershell的权限原因未能运行成功。于是采用了cmd的install.bat
运行export.bat时候记得使用管理员模式,否则无法成功添加环境变量
“重要
ESP-IDF 编译系统不支持带有空格的路径。”
9102年了。。。。。
接下来尝试build example中的hello world项目
直接编译

build```
1
出错

Executing action: all (aliases: build)
Running ninja in directory c:\users\8192\desktop\feibiao\esp-idf\hello_world\build
Executing “ninja all”…
[263/859] Performing configure step for ‘bootloader’
FAILED: bootloader-prefix/src/bootloader-stamp/bootloader-configure
cmd.exe /C “cd /D C:\Users\8192\Desktop\feibiao\esp-idf\hello_world\build\bootloader && C:\Users\8192.espressif\tools\cmake\3.13.4\bin\cmake.exe -DSDKCONFIG=C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/sdkconfig -DIDF_PATH=C:/Users/8192/Desktop/feibiao/esp-idf -DIDF_TARGET=esp32 -DPYTHON_DEPS_CHECKED=1 -DPYTHON=C:\Users\8192.espressif\python_env\idf4.1_py3.6_env\Scripts\python.exe -DEXTRA_COMPONENT_DIRS=C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader -DLEGACY_INCLUDE_COMMON_HEADERS= -GNinja C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject && C:\Users\8192.espressif\tools\cmake\3.13.4\bin\cmake.exe -E touch C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader-prefix/src/bootloader-stamp/bootloader-configure”
– Found Git: C:/Program Files/Git/cmd/git.exe (found version “2.22.0.windows.1”)
– The C compiler identification is GNU 8.2.0
– The CXX compiler identification is GNU 8.2.0
– The ASM compiler identification is GNU
– Found assembler: C:/Users/8192/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
– Check for working C compiler: C:/Users/8192/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
– Check for working C compiler: C:/Users/8192/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: C:/Users/8192/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
– Check for working CXX compiler: C:/Users/8192/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Project version: v4.1-dev-1086-g93a8603c5
– Building ESP-IDF components for target esp32
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp32/ld/esp32.peripherals.ld
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.ld
– Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.rom.ld
– Components: bootloader bootloader_support efuse esp32 esp_common esp_rom esptool_py freertos log main micro-ecc partition_table soc spi_flash xtensa
– Component paths: C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader_support C:/Users/8192/Desktop/feibiao/esp-idf/components/efuse C:/Users/8192/Desktop/feibiao/esp-idf/components/esp32 C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_common C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom C:/Users/8192/Desktop/feibiao/esp-idf/components/esptool_py C:/Users/8192/Desktop/feibiao/esp-idf/components/freertos C:/Users/8192/Desktop/feibiao/esp-idf/components/log C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/components/micro-ecc C:/Users/8192/Desktop/feibiao/esp-idf/components/partition_table C:/Users/8192/Desktop/feibiao/esp-idf/components/soc C:/Users/8192/Desktop/feibiao/esp-idf/components/spi_flash C:/Users/8192/Desktop/feibiao/esp-idf/components/xtensa
– Configuring done
CMake Error at …/…/…/tools/cmake/component.cmake:445 (add_library):
Cannot find source file:

C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/components/micro-ecc/micro-ecc/uECC.c

Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
Call Stack (most recent call first):
components/micro-ecc/CMakeLists.txt:2 (idf_component_register)

CMake Error at …/…/…/tools/cmake/component.cmake:445 (add_library):
No SOURCES given to target: __idf_micro-ecc
Call Stack (most recent call first):
components/micro-ecc/CMakeLists.txt:2 (idf_component_register)

– Build files have been written to: C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader
[268/859] Building C object esp-idf/wpa_supplicant/CMakeFiles/__idf_wpa_supplicant.dir/src/crypto/des-internal.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

C:\Users\8192\Desktop\feibiao\esp-idf\hello_world>idf.py menuconfig
Executing action: menuconfig
Running ninja in directory c:\users\8192\desktop\feibiao\esp-idf\hello_world\build
Executing “ninja menuconfig”…
[0/1] cmd.exe /C “cd /D C:\Users\8192\Desktop\feibiao\esp-idf\hello_world\build && C:\Users\8192.espressif…fig.env --env IDF_TARGET=esp32 --output config C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/sdkconfig”
Loaded configuration ‘C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/sdkconfig’
Configuration saved to ‘C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/sdkconfig’

1
2
3
4
5
6
7
8
9
10
11
12
查看发现是缺少了micro-ecc下的文件
于是先```idf.py build menuconfig``` 把设置中的Compatibility options中
把Include headers accross components as before IDF V4.0选项打开
重新build
报一样的错误

经过查看microecc目录发现存在makefile.mk但是源文件内容为空

返回github上查看对应项目发现micro-ecc是一个git的submodule

查询本地仓库的.gitsubmodule发现配置正确无误
根据找到的资料执行

git submodule update

1
报错

fatal: could not get a repository handle for submodule ‘components/bootloader/subproject/components/micro-ecc/micro-ecc’

1
于是在本地删除了micro-ecc文件夹,尝试根据资料执行

git submodule sync
git submodule update

1
报错

Synchronizing submodule url for ‘components/asio/asio’
fatal: not a git repository: components/bootloader/subproject/components/micro-ecc/micro-ecc/…/…/…/…/…/…/.git/modules/components/bootloader/subproject/components/micro-ecc/micro-ecc
Synchronizing submodule url for ‘components/bootloader/subproject/components/micro-ecc/micro-ecc’

1
鉴于自动添加submodule的方式一直失败,选择手动添加micro-ecc仓库

cd components/bootloader/subproject/components/micro-ecc
git clone https://github.com/kmackay/micro-ecc.git

1
接下来执行

git submodule update

1
输出

Submodule path ‘components/bootloader/subproject/components/micro-ecc/micro-ecc’: checked out ‘d037ec89546fad14b5c4d5456c2e23a71e554966’

1
再```idf.py build

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Executing action: all (aliases: build)
Running ninja in directory c:\users\8192\desktop\feibiao\esp-idf\hello_world\build
Executing "ninja all"...
[65/514] Performing configure step for 'bootloader'
FAILED: bootloader-prefix/src/bootloader-stamp/bootloader-configure
cmd.exe /C "cd /D C:\Users\8192\Desktop\feibiao\esp-idf\hello_world\build\bootloader && C:\Users\8192\.espressif\tools\cmake\3.13.4\bin\cmake.exe -DSDKCONFIG=C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/sdkconfig -DIDF_PATH=C:/Users/8192/Desktop/feibiao/esp-idf -DIDF_TARGET=esp32 -DPYTHON_DEPS_CHECKED=1 -DPYTHON=C:\Users\8192\.espressif\python_env\idf4.1_py3.6_env\Scripts\python.exe -DEXTRA_COMPONENT_DIRS=C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader -DLEGACY_INCLUDE_COMMON_HEADERS=y -GNinja C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject && C:\Users\8192\.espressif\tools\cmake\3.13.4\bin\cmake.exe -E touch C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader-prefix/src/bootloader-stamp/bootloader-configure"
-- Project version: v4.1-dev-1086-g93a8603c5-dirty
-- Building ESP-IDF components for target esp32
CMake Error at C:/Users/8192/Desktop/feibiao/esp-idf/tools/cmake/build.cmake:185 (message):
Failed to resolve component 'micro-ecc'.
Call Stack (most recent call first):
C:/Users/8192/Desktop/feibiao/esp-idf/tools/cmake/build.cmake:216 (__build_resolve_and_add_req)
C:/Users/8192/Desktop/feibiao/esp-idf/tools/cmake/build.cmake:425 (__build_expand_requirements)
C:/Users/8192/Desktop/feibiao/esp-idf/tools/cmake/project.cmake:357 (idf_build_process)
CMakeLists.txt:27 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader/CMakeFiles/CMakeOutput.log".
[70/514] Building C object esp-idf/wpa_supplicant...a_supplicant.dir/src/tls/tlsv1_server_write.c.objninja: build stopped: subcommand failed.
ninja failed with exit code 1

发现是当初删除micro-ecc文件夹时候,将CmakeList也一起删除了,从回收站里找回之后再

build```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
成功build hello_world项目
成功信息如下
```Executing action: all (aliases: build)
Running ninja in directory c:\users\8192\desktop\feibiao\esp-idf\hello_world\build
Executing "ninja all"...
[116/445] Performing configure step for 'bootloader'
-- Project version: v4.1-dev-1086-g93a8603c5
-- Building ESP-IDF components for target esp32
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.ld
-- Adding linker script C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp32 esp_common esp_rom esptool_py freertos log main micro-ecc partition_table soc spi_flash xtensa
-- Component paths: C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader_support C:/Users/8192/Desktop/feibiao/esp-idf/components/efuse C:/Users/8192/Desktop/feibiao/esp-idf/components/esp32 C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_common C:/Users/8192/Desktop/feibiao/esp-idf/components/esp_rom C:/Users/8192/Desktop/feibiao/esp-idf/components/esptool_py C:/Users/8192/Desktop/feibiao/esp-idf/components/freertos C:/Users/8192/Desktop/feibiao/esp-idf/components/log C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/main C:/Users/8192/Desktop/feibiao/esp-idf/components/bootloader/subproject/components/micro-ecc C:/Users/8192/Desktop/feibiao/esp-idf/components/partition_table C:/Users/8192/Desktop/feibiao/esp-idf/components/soc C:/Users/8192/Desktop/feibiao/esp-idf/components/spi_flash C:/Users/8192/Desktop/feibiao/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader
[157/445] Performing build step for 'bootloader'
[1/65] Generating project_elf_src.c
[2/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/cpu_util.c.obj
[3/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/gpio_periph.c.obj
[4/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_clk_init.c.obj
[5/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_init.c.obj
[6/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_clk.c.obj
[7/65] Building C object CMakeFiles/bootloader.elf.dir/project_elf_src.c.obj
[8/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_periph.c.obj
[9/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_time.c.obj
[10/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_sleep.c.obj
[11/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/sdmmc_periph.c.obj
[12/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_pm.c.obj
[13/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/soc_memory_layout.c.obj
[14/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/i2s_periph.c.obj
[15/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_wdt.c.obj
[16/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/memory_layout_utils.c.obj
[17/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/sdio_slave_periph.c.obj
[18/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/ledc_periph.c.obj
[19/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/interrupts.c.obj
[20/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/lldesc.c.obj
[21/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_flash_hal_iram.c.obj
[22/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_hal.c.obj
[23/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/spi_periph.c.obj
[24/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_flash_hal.c.obj
[25/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/soc_include_legacy_warn.c.obj
C:/Users/8192/Desktop/feibiao/esp-idf/components/soc/src/soc_include_legacy_warn.c:4:2: warning: #warning Legacy including is enabled. This will be deprecated in the future. You can disable this option in the menuconfig. If there are some including errors, please try to include: "soc/soc.h", "soc/soc_memory_layout.h", "driver/gpio.h", or "esp_sleep.h". [-Wcpp]
#warning Legacy including is enabled. This will be deprecated in the future. You can disable this option in the menuconfig. If there are some including errors, please try to include: "soc/soc.h", "soc/soc_memory_layout.h", "driver/gpio.h", or "esp_sleep.h".
^~~~~~~
[26/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_hal_iram.c.obj
[27/65] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log.c.obj
[28/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_slave_hal_iram.c.obj
[29/65] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/src/hal/spi_slave_hal.c.obj
[30/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32/esp_efuse_table.c.obj
[31/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_fields.c.obj
[32/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp32/esp_efuse_api.c.obj
[33/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp32/esp_efuse_fields.c.obj
[34/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_api.c.obj
[35/65] Linking C static library esp-idf\log\liblog.a
[36/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp32/esp_efuse_utility.c.obj
[37/65] Building C object esp-idf/micro-ecc/CMakeFiles/__idf_micro-ecc.dir/micro-ecc/uECC.c.obj
[38/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_clock.c.obj
[39/65] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_utility.c.obj
[40/65] Building C object esp-idf/spi_flash/CMakeFiles/__idf_spi_flash.dir/esp32/spi_flash_rom_patch.c.obj
[41/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_common.c.obj
[42/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_utility.c.obj
[43/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_flash.c.obj
[44/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp_image_format.c.obj
[45/65] Linking C static library esp-idf\soc\libsoc.a
[46/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_random.c.obj
[47/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_partitions.c.obj
[48/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_qio_mode.c.obj
[49/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/bootloader_esp32.c.obj
[50/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/secure_boot.c.obj
[51/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_efuse_esp32.c.obj
[52/65] Linking C static library esp-idf\micro-ecc\libmicro-ecc.a
[53/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_flash_config_esp32.c.obj
[54/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/bootloader_sha.c.obj
[55/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/flash_encrypt.c.obj
[56/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_init.c.obj
[57/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_encrypt.c.obj
[58/65] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/bootloader_start.c.obj
[59/65] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/secure_boot_signatures.c.obj
[60/65] Linking C static library esp-idf\bootloader_support\libbootloader_support.a
[61/65] Linking C static library esp-idf\efuse\libefuse.a
[62/65] Linking C static library esp-idf\spi_flash\libspi_flash.a
[63/65] Linking C static library esp-idf\main\libmain.a
[64/65] Linking C executable bootloader.elf
[65/65] Generating binary image from built executable
esptool.py v2.9-dev
Generated C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/bootloader/bootloader.bin
[445/445] Generating binary image from built executable
esptool.py v2.9-dev
Generated C:/Users/8192/Desktop/feibiao/esp-idf/hello_world/build/hello-world.bin

Project build complete. To flash, run this command:
C:\Users\8192\.espressif\python_env\idf4.1_py3.6_env\Scripts\python.exe ..\components\esptool_py\esptool\esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x1000 build\bootloader\bootloader.bin 0x8000 build\partition_table\partition-table.bin 0x10000 build\hello-world.bin
or run 'idf.py -p (PORT) flash'

由于暂时还不想把板子里面的摄像头程序给覆盖掉,所以没有烧录程序。环境配置应该差不多了,主要是被git的submodule坑了一把

条件控制的④种写法

众所周知,茴字有四种写法,C语言中的条件控制比茴字的写法更多一种。
这里分为三类:普通类,?:运算符,短路类。
##普通类
if和switch
易用性:★★★★
抽象性:★

1
2
3
4
5
6
7
int i=5;
if(i==5){
printf("if condition\n");
}
switch(i){
case 5:printf("switch condition\n");
}

OUTPUT

1
2
if condition
switch condition

##?:运算符
易用性:★★★★★
抽象性:★★★

1
2
int i=5;
i==5?printf(":? condition\n"):1;

OUTPUT

1
:? condition

##短路类
易用性:★★★
抽象性:★★★★★

1
2
3
int i=5;
i==5 && (printf("&& condition\n"),1);
i==4 || (printf("|| condition\n"),0);

OUTPUT

1
2
&& condition
|| condition

抽象程度实属有两个孙笑川

web_hw5

作业要求

->最终效果<-
三个小时打完作业,然而出现谜之bug:
如果在使用键盘enter键得出答案之前采用鼠标点击过按钮,则按enter键后会在运算式中重复输入最后一个字符
后发现是焦点问题使用enter相当于触发一次焦点上的按钮。
在键盘点击后加入

1
document.getElementById('equal').focus();

在enter时候将焦点设置为equal键上解决

程设写迷惑代码第二周

第二周又来写迷惑代码啦

一行迷惑的不能再迷惑的代码

1
2
3
4
5
6
7
#include<stdio.h>
int main()
{
int y,m,md=0,temp,flag=0;
scanf("%d%d",&y,&m);
(y>=0&&y<=9999&&m>=1&&m<=12)?printf("%04d/%02d has %d days.\n",y,m,m==2?((y%100==0?(y%400==0?1:0):(y%4==0?1:0))==1?29:28):((m*2-15)>0?(m*2-15):(15-m*2))%4==1?31:30):printf("Invalid Input Detected.\n");
}
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
char c;
scanf("%c", &c);
printf("%c\n", c - 'A' + 'a');
}
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
int num1, num2;
scanf("%d%d", &num1, &num2);
printf("%d\n",num1%num2==0?num1+num2:num1);
}
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
int n, flag = 0;
scanf("%d", &n);
printf("%d is%s a leap year.\n", n, (n % 100==0 ? (n % 400==0 ? 1 : 0 ): (n % 4==0 ? 1 : 0)) ? "" : " not");
}

啊,你说社么if?不存在的:不存在的;

程设写迷惑代码第一天

突然找到了写毒瘤代码的快感XDDDD:

Descrption

输出 hello, world

别忘了换行哦 _

毒瘤代码一

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include<stdio.h>
int main(){
char s[13];
for(int i=0;i<13;i++){
if(i==0){
int j=0;
while(j<104){
j++;
}
s[i]=j;
}
if(i==1){
int j=0;
while(j<101){
j++;
}
s[i]=j;
}
if(i==2){
int j=0;
while(j<108){
j++;
}
s[i]=j;
}
if(i==3){
int j=0;
while(j<108){
j++;
}
s[i]=j;
}
if(i==4){
int j=0;
while(j<111){
j++;
}
s[i]=j;
}
if(i==5){
int j=0;
while(j<44){
j++;
}
s[i]=j;
}
if(i==6){
int j=0;
while(j<32){
j++;
}
s[i]=j;
}
if(i==7){
int j=0;
while(j<119){
j++;
}
s[i]=j;
}
if(i==8){
int j=0;
while(j<111){
j++;
}
s[i]=j;
}
if(i==9){
int j=0;
while(j<114){
j++;
}
s[i]=j;
}
if(i==10){
int j=0;
while(j<108){
j++;
}
s[i]=j;
}
if(i==11){
int j=0;
while(j<100){
j++;
}
s[i]=j;
}
if(i==12){
int j=0;
while(j<'\n'){
j++;
}
s[i]=j;
}
if(i==13){
int j=0;
while(j<0){
j++;
}
s[i]=j;
}
}
printf("%s",s);
return 0;
}

然而并没有逃过matrix的法眼

Description

计算两个整数a,b的和,整数范围为-1000<a,b<1000。

毒瘤代码二

1
2
3
4
5
6
7
8
9
#include<stdio.h>

int main(){
int a,b;
scanf("%d",&a);
scanf("%d",&b);
printf("%d\n",a^a^a^a^a^a^a^a^a-a-a-a-a+a+a+a+a+b^b^b^b^b-b-b-b-b+b+b+b+b);
return 0;
}

Description

In one week an employee works h hours (h is an integer and 0<h<168) at the hourly pay rate of 24.75 dollar. Assume a 40.0 hour normal work week and an overtime pay rate factor of 1.5.

What are the employee’s wages?

毒瘤代码三

1
2
3
4
5
6
#include <stdio.h>
int main(){
int hours=0;
scanf("%d",&hours);
printf("%.2f\n", 24.75 * hours + (hours > 40 ? 0.5f*24.75*(hours-40):0.0));
}

Description

Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas: area = radius * radius * PI volume = area * length PI = 3.14159

毒瘤代码四

1
2
3
4
5
6
7
8
#include <stdio.h>
int main(){
double pi = 2,now=2.0/3,r,l;
scanf("%lf%lf",&r,&l);
for (int i = 1; i < 30;pi = pi + now,now = now * (i + 1) / ((2 * (i + 1)) + 1),i++);
printf("%.4lf",pi*r*r*l);
return 0;
}

照这样写代码被打死可不要怪我。