├── README.md
├── bom
├── farnell.csv
├── other.txt
└── reichelt.csv
├── images
├── 22780314_1206666822799181_4845087505472371951_n.jpg
├── 22780624_1207215072744356_6448307703032848811_n.jpg
├── 22851997_1206666786132518_3949441219433421302_n.jpg
├── 22885966_1207940582671805_9052044658180000451_n.jpg
├── 23131607_1213188442147019_5008004252267984808_n.jpg
├── 23131890_1213188468813683_2381276653004583966_n.jpg
├── 23244059_1218023491663514_6128260922593770176_n.jpg
├── 23380218_1219804668152063_8622113328646516671_n.jpg
├── 23380257_1223416981124165_4793755427854490814_n.jpg
├── 23559460_1223772024421994_2585757183464992038_n.jpg
├── 23559568_1223771867755343_5931761190105667111_n.jpg
├── DSC00244.JPG
├── Spectacle.Tw9321.png
└── lcd.png
├── kicad
├── beamer1-cache.lib
├── beamer1.kicad_pcb
├── beamer1.net
├── beamer1.pdf
├── beamer1.pro
├── beamer1.sch
└── gerber
│ ├── README.txt
│ ├── beamer1-B.Cu.gbl
│ ├── beamer1-B.Mask.gbs
│ ├── beamer1-B.SilkS.gbo
│ ├── beamer1-Edge.Cuts.gm1
│ ├── beamer1-F.Cu.gtl
│ ├── beamer1-F.Mask.gts
│ ├── beamer1-F.SilkS.gto
│ └── beamer1.drl
├── src
├── .cproject
├── .project
├── .settings
│ └── language.settings.xml
├── ArduinoJson
│ ├── Configuration.hpp
│ ├── Data
│ │ ├── Encoding.hpp
│ │ ├── JsonBufferAllocated.hpp
│ │ ├── JsonFloat.hpp
│ │ ├── JsonInteger.hpp
│ │ ├── JsonVariantAs.hpp
│ │ ├── JsonVariantComparer.hpp
│ │ ├── JsonVariantContent.hpp
│ │ ├── JsonVariantDefault.hpp
│ │ ├── JsonVariantType.hpp
│ │ ├── List.hpp
│ │ ├── ListConstIterator.hpp
│ │ ├── ListIterator.hpp
│ │ ├── ListNode.hpp
│ │ ├── ReferenceType.hpp
│ │ └── ValueSetter.hpp
│ ├── Deserialization
│ │ ├── Comments.hpp
│ │ ├── JsonParser.hpp
│ │ ├── JsonParserImpl.hpp
│ │ └── StringWriter.hpp
│ ├── DynamicJsonBuffer.hpp
│ ├── JsonArray.hpp
│ ├── JsonArrayImpl.hpp
│ ├── JsonArraySubscript.hpp
│ ├── JsonBuffer.hpp
│ ├── JsonBufferBase.hpp
│ ├── JsonBufferImpl.hpp
│ ├── JsonObject.hpp
│ ├── JsonObjectImpl.hpp
│ ├── JsonObjectSubscript.hpp
│ ├── JsonPair.hpp
│ ├── JsonVariant.hpp
│ ├── JsonVariantBase.hpp
│ ├── JsonVariantComparisons.hpp
│ ├── JsonVariantImpl.hpp
│ ├── Polyfills
│ │ ├── attributes.hpp
│ │ ├── ctype.hpp
│ │ ├── isFloat.hpp
│ │ ├── isInteger.hpp
│ │ ├── math.hpp
│ │ ├── normalize.hpp
│ │ ├── parseFloat.hpp
│ │ └── parseInteger.hpp
│ ├── RawJson.hpp
│ ├── Serialization
│ │ ├── DummyPrint.hpp
│ │ ├── DynamicStringBuilder.hpp
│ │ ├── IndentedPrint.hpp
│ │ ├── JsonPrintable.hpp
│ │ ├── JsonSerializer.hpp
│ │ ├── JsonSerializerImpl.hpp
│ │ ├── JsonWriter.hpp
│ │ ├── Prettyfier.hpp
│ │ ├── StaticStringBuilder.hpp
│ │ └── StreamPrintAdapter.hpp
│ ├── StaticJsonBuffer.hpp
│ ├── StringTraits
│ │ ├── ArduinoStream.hpp
│ │ ├── CharPointer.hpp
│ │ ├── FlashString.hpp
│ │ ├── StdStream.hpp
│ │ ├── StdString.hpp
│ │ └── StringTraits.hpp
│ └── TypeTraits
│ │ ├── EnableIf.hpp
│ │ ├── FloatTraits.hpp
│ │ ├── IsArray.hpp
│ │ ├── IsBaseOf.hpp
│ │ ├── IsChar.hpp
│ │ ├── IsConst.hpp
│ │ ├── IsFloatingPoint.hpp
│ │ ├── IsIntegral.hpp
│ │ ├── IsSame.hpp
│ │ ├── IsSignedIntegral.hpp
│ │ ├── IsUnsignedIntegral.hpp
│ │ ├── RemoveConst.hpp
│ │ └── RemoveReference.hpp
├── Release
│ ├── STM32_USB-FS-Device_Driver
│ │ └── src
│ │ │ ├── subdir.mk
│ │ │ ├── usb_core.d
│ │ │ ├── usb_core.o
│ │ │ ├── usb_init.d
│ │ │ ├── usb_init.o
│ │ │ ├── usb_int.d
│ │ │ ├── usb_int.o
│ │ │ ├── usb_mem.d
│ │ │ ├── usb_mem.o
│ │ │ ├── usb_regs.d
│ │ │ ├── usb_regs.o
│ │ │ ├── usb_sil.d
│ │ │ └── usb_sil.o
│ ├── beamer1.bin
│ ├── beamer1.hex
│ ├── beamer1.map
│ ├── makefile
│ ├── objects.mk
│ ├── sources.mk
│ ├── src
│ │ ├── Timer.d
│ │ ├── Timer.o
│ │ ├── _write.d
│ │ ├── _write.o
│ │ ├── font12x16_reduced.d
│ │ ├── font12x16_reduced.o
│ │ ├── font5x7.d
│ │ ├── font5x7.o
│ │ ├── gpio.d
│ │ ├── gpio.o
│ │ ├── i2c.d
│ │ ├── i2c.o
│ │ ├── icons.d
│ │ ├── icons.o
│ │ ├── ir.d
│ │ ├── ir.o
│ │ ├── irmp.d
│ │ ├── irmp.o
│ │ ├── json.d
│ │ ├── json.o
│ │ ├── lcd64x32.d
│ │ ├── lcd64x32.o
│ │ ├── main.d
│ │ ├── main.o
│ │ ├── rotenc.d
│ │ ├── rotenc.o
│ │ ├── rtc.d
│ │ ├── subdir.mk
│ │ ├── tim.d
│ │ ├── tim.o
│ │ ├── ugui.d
│ │ ├── ugui.o
│ │ ├── usb.d
│ │ └── usb.o
│ ├── system
│ │ └── src
│ │ │ ├── cmsis
│ │ │ ├── subdir.mk
│ │ │ ├── system_stm32f10x.d
│ │ │ ├── system_stm32f10x.o
│ │ │ ├── vectors_stm32f10x.d
│ │ │ └── vectors_stm32f10x.o
│ │ │ ├── cortexm
│ │ │ ├── _initialize_hardware.d
│ │ │ ├── _initialize_hardware.o
│ │ │ ├── _reset_hardware.d
│ │ │ ├── _reset_hardware.o
│ │ │ ├── exception_handlers.d
│ │ │ ├── exception_handlers.o
│ │ │ └── subdir.mk
│ │ │ ├── diag
│ │ │ ├── Trace.d
│ │ │ ├── Trace.o
│ │ │ ├── subdir.mk
│ │ │ ├── trace_impl.d
│ │ │ └── trace_impl.o
│ │ │ ├── newlib
│ │ │ ├── _cxx.d
│ │ │ ├── _cxx.o
│ │ │ ├── _exit.d
│ │ │ ├── _exit.o
│ │ │ ├── _sbrk.d
│ │ │ ├── _sbrk.o
│ │ │ ├── _startup.d
│ │ │ ├── _startup.o
│ │ │ ├── _syscalls.d
│ │ │ ├── _syscalls.o
│ │ │ ├── assert.d
│ │ │ ├── assert.o
│ │ │ └── subdir.mk
│ │ │ └── stm32f1-stdperiph
│ │ │ ├── misc.d
│ │ │ ├── misc.o
│ │ │ ├── stm32f10x_bkp.d
│ │ │ ├── stm32f10x_bkp.o
│ │ │ ├── stm32f10x_gpio.d
│ │ │ ├── stm32f10x_gpio.o
│ │ │ ├── stm32f10x_i2c.d
│ │ │ ├── stm32f10x_i2c.o
│ │ │ ├── stm32f10x_pwr.d
│ │ │ ├── stm32f10x_pwr.o
│ │ │ ├── stm32f10x_rcc.d
│ │ │ ├── stm32f10x_rcc.o
│ │ │ ├── stm32f10x_rtc.d
│ │ │ ├── stm32f10x_rtc.o
│ │ │ ├── stm32f10x_tim.d
│ │ │ ├── stm32f10x_tim.o
│ │ │ └── subdir.mk
│ └── vcp
│ │ └── src
│ │ ├── hw_config.d
│ │ ├── hw_config.o
│ │ ├── stm32_it.d
│ │ ├── stm32_it.o
│ │ ├── subdir.mk
│ │ ├── usb_desc.d
│ │ ├── usb_desc.o
│ │ ├── usb_endp.d
│ │ ├── usb_endp.o
│ │ ├── usb_istr.d
│ │ ├── usb_istr.o
│ │ ├── usb_prop.d
│ │ ├── usb_prop.o
│ │ ├── usb_pwr.d
│ │ └── usb_pwr.o
├── STM32_USB-FS-Device_Driver
│ ├── Release_Notes.html
│ ├── inc
│ │ ├── usb_core.h
│ │ ├── usb_def.h
│ │ ├── usb_init.h
│ │ ├── usb_int.h
│ │ ├── usb_lib.h
│ │ ├── usb_mem.h
│ │ ├── usb_regs.h
│ │ ├── usb_sil.h
│ │ └── usb_type.h
│ └── src
│ │ ├── usb_core.c
│ │ ├── usb_init.c
│ │ ├── usb_int.c
│ │ ├── usb_mem.c
│ │ ├── usb_regs.c
│ │ └── usb_sil.c
├── include
│ ├── ArduinoJson.h
│ ├── ArduinoJson.hpp
│ ├── Timer.h
│ ├── font5x7.h
│ ├── gpio.h
│ ├── i2c.h
│ ├── icons.h
│ ├── ir.h
│ ├── irmp.h
│ ├── irmpconfig.h
│ ├── irmpprotocols.h
│ ├── irmpsystem.h
│ ├── json.h
│ ├── lcd64x32.h
│ ├── main.h
│ ├── rotenc.h
│ ├── rtc.h
│ ├── stm32f10x_conf.h
│ ├── tim.h
│ ├── ugui.h
│ ├── ugui_config.h
│ └── usb.h
├── ldscripts
│ ├── libs.ld
│ ├── mem.ld
│ └── sections.ld
├── myboard.cfg
├── src
│ ├── Timer.cpp
│ ├── _write.c
│ ├── font12x16_reduced.c
│ ├── font5x7.c
│ ├── gpio.cpp
│ ├── i2c.cpp
│ ├── icons.cpp
│ ├── ir.cpp
│ ├── irmp.c
│ ├── json.cpp
│ ├── lcd64x32.cpp
│ ├── main.cpp
│ ├── rotenc.cpp
│ ├── rtc.cpp
│ ├── tim.cpp
│ ├── ugui.c
│ └── usb.cpp
├── system
│ ├── include
│ │ ├── arm
│ │ │ └── semihosting.h
│ │ ├── cmsis
│ │ │ ├── README_DEVICE.txt
│ │ │ ├── arm_common_tables.h
│ │ │ ├── arm_const_structs.h
│ │ │ ├── arm_math.h
│ │ │ ├── cmsis_armcc.h
│ │ │ ├── cmsis_armcc_V6.h
│ │ │ ├── cmsis_device.h
│ │ │ ├── cmsis_gcc.h
│ │ │ ├── core_cm0.h
│ │ │ ├── core_cm0plus.h
│ │ │ ├── core_cm3.h
│ │ │ ├── core_cm4.h
│ │ │ ├── core_cm7.h
│ │ │ ├── core_cmFunc.h
│ │ │ ├── core_cmInstr.h
│ │ │ ├── core_cmSimd.h
│ │ │ ├── core_sc000.h
│ │ │ ├── core_sc300.h
│ │ │ ├── stm32f10x.h
│ │ │ └── system_stm32f10x.h
│ │ ├── cortexm
│ │ │ └── ExceptionHandlers.h
│ │ ├── diag
│ │ │ └── Trace.h
│ │ └── stm32f1-stdperiph
│ │ │ ├── README_STDPERIPH.txt
│ │ │ ├── misc.h
│ │ │ ├── stm32f10x_adc.h
│ │ │ ├── stm32f10x_bkp.h
│ │ │ ├── stm32f10x_can.h
│ │ │ ├── stm32f10x_cec.h
│ │ │ ├── stm32f10x_crc.h
│ │ │ ├── stm32f10x_dac.h
│ │ │ ├── stm32f10x_dbgmcu.h
│ │ │ ├── stm32f10x_dma.h
│ │ │ ├── stm32f10x_exti.h
│ │ │ ├── stm32f10x_flash.h
│ │ │ ├── stm32f10x_fsmc.h
│ │ │ ├── stm32f10x_gpio.h
│ │ │ ├── stm32f10x_i2c.h
│ │ │ ├── stm32f10x_iwdg.h
│ │ │ ├── stm32f10x_pwr.h
│ │ │ ├── stm32f10x_rcc.h
│ │ │ ├── stm32f10x_rtc.h
│ │ │ ├── stm32f10x_sdio.h
│ │ │ ├── stm32f10x_spi.h
│ │ │ ├── stm32f10x_tim.h
│ │ │ ├── stm32f10x_usart.h
│ │ │ └── stm32f10x_wwdg.h
│ └── src
│ │ ├── cmsis
│ │ ├── README_DEVICE.txt
│ │ ├── system_stm32f10x.c
│ │ └── vectors_stm32f10x.c
│ │ ├── cortexm
│ │ ├── _initialize_hardware.c
│ │ ├── _reset_hardware.c
│ │ └── exception_handlers.c
│ │ ├── diag
│ │ ├── Trace.c
│ │ └── trace_impl.c
│ │ ├── newlib
│ │ ├── README.txt
│ │ ├── _cxx.cpp
│ │ ├── _exit.c
│ │ ├── _sbrk.c
│ │ ├── _startup.c
│ │ ├── _syscalls.c
│ │ └── assert.c
│ │ └── stm32f1-stdperiph
│ │ ├── README_STDPERIPH.txt
│ │ ├── misc.c
│ │ ├── stm32f10x_adc.c
│ │ ├── stm32f10x_bkp.c
│ │ ├── stm32f10x_can.c
│ │ ├── stm32f10x_cec.c
│ │ ├── stm32f10x_crc.c
│ │ ├── stm32f10x_dac.c
│ │ ├── stm32f10x_dbgmcu.c
│ │ ├── stm32f10x_dma.c
│ │ ├── stm32f10x_exti.c
│ │ ├── stm32f10x_flash.c
│ │ ├── stm32f10x_fsmc.c
│ │ ├── stm32f10x_gpio.c
│ │ ├── stm32f10x_i2c.c
│ │ ├── stm32f10x_iwdg.c
│ │ ├── stm32f10x_pwr.c
│ │ ├── stm32f10x_rcc.c
│ │ ├── stm32f10x_rtc.c
│ │ ├── stm32f10x_sdio.c
│ │ ├── stm32f10x_spi.c
│ │ ├── stm32f10x_tim.c
│ │ ├── stm32f10x_usart.c
│ │ └── stm32f10x_wwdg.c
└── vcp
│ ├── inc
│ ├── hw_config.h
│ ├── platform_config.h
│ ├── stm32_it.h
│ ├── stm32l1xx_conf.h
│ ├── usb_conf.h
│ ├── usb_desc.h
│ ├── usb_istr.h
│ ├── usb_prop.h
│ └── usb_pwr.h
│ └── src
│ ├── hw_config.c
│ ├── stm32_it.c
│ ├── usb_desc.c
│ ├── usb_endp.c
│ ├── usb_istr.c
│ ├── usb_prop.c
│ └── usb_pwr.c
└── stl
├── assembly.png
├── case_bottom.stl
├── case_foot.stl
├── case_top_cmount.stl
├── case_top_emount.stl
├── knob_smooth.stl
├── know.stl
├── lcd_holder.stl
└── spacer.stl
/README.md:
--------------------------------------------------------------------------------
1 | # DIY Night Projector Clock
2 |
3 | GitHub-Repository to this project web-site:
4 |
5 | https://microengineer.eu/2018/05/01/diy-night-clock-projector/
6 |
--------------------------------------------------------------------------------
/bom/farnell.csv:
--------------------------------------------------------------------------------
1 | 1635847;1
2 | 1759043;2
3 | 1812489;1
4 | 2057774;1
5 | 2064978;1
6 | 2251407;1
7 | 2293753;2
8 | 2307892;1
9 | 2362048;1
10 | 2430082;1
11 | 2463458;1
12 | 2466266;1
13 | 2467864;1
14 | 2769261;1
15 | 9227865;2
16 |
--------------------------------------------------------------------------------
/bom/other.txt:
--------------------------------------------------------------------------------
1 | 12.5mm objective:
2 | search on ebay for 25mm c-mount CCTV lens ... Should cost about < $15
3 |
4 | condensor:
5 | https://www.aliexpress.com/item/Cree-XPG-lens-Diameter-23-5mm-Belt-holder-5-degrees-LED-Lens-glass-Condenser-lens/1322969782.html?spm=a2g0s.9042311.0.0.MU73Ll
6 |
7 | LCD:
8 | (search on ebay for LCD 64x32) e.g.
9 | GLS Neu LCD-VATN 64x32 3V ST7567A I2C 15x12x2mm [LCD-AG-064032V-VIW W/KKK-E6]
10 |
11 |
12 |
--------------------------------------------------------------------------------
/bom/reichelt.csv:
--------------------------------------------------------------------------------
1 | BC 807-40W SMD;1
2 | BC 817-40 SMD;1
3 | KEM X7R1206 10U;2
4 | KEM X7R1206 2,2U;1
5 | KEM Y5V1206 1,0U;2
6 | LM 1117 IMP-3.3;1
7 | RND 0805 1 1,5K;1
8 | RND 0805 1 10;2
9 | RND 0805 1 100;3
10 | RND 0805 1 22;1
11 | RND 0805 1 36K;1
12 | RND 1206 1 10K;3
13 | RND 1206 1 2,2K;2
14 | SL 1X10G 1,27;1
15 | SL 2X10G SMD2,54;2
16 | SMD 1/4W 4,7;1
17 | SMD 1/4W 4,7K;3
18 | SMD-0805 10,0K;2
19 | STM32 F103C8T6;1
20 | TASTER 9313;1
21 | X7R-G0805 100N;8
22 | X7R-G1206 100N;1
23 | XO32 8,00000;1
24 |
--------------------------------------------------------------------------------
/images/22780314_1206666822799181_4845087505472371951_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/22780314_1206666822799181_4845087505472371951_n.jpg
--------------------------------------------------------------------------------
/images/22780624_1207215072744356_6448307703032848811_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/22780624_1207215072744356_6448307703032848811_n.jpg
--------------------------------------------------------------------------------
/images/22851997_1206666786132518_3949441219433421302_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/22851997_1206666786132518_3949441219433421302_n.jpg
--------------------------------------------------------------------------------
/images/22885966_1207940582671805_9052044658180000451_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/22885966_1207940582671805_9052044658180000451_n.jpg
--------------------------------------------------------------------------------
/images/23131607_1213188442147019_5008004252267984808_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23131607_1213188442147019_5008004252267984808_n.jpg
--------------------------------------------------------------------------------
/images/23131890_1213188468813683_2381276653004583966_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23131890_1213188468813683_2381276653004583966_n.jpg
--------------------------------------------------------------------------------
/images/23244059_1218023491663514_6128260922593770176_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23244059_1218023491663514_6128260922593770176_n.jpg
--------------------------------------------------------------------------------
/images/23380218_1219804668152063_8622113328646516671_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23380218_1219804668152063_8622113328646516671_n.jpg
--------------------------------------------------------------------------------
/images/23380257_1223416981124165_4793755427854490814_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23380257_1223416981124165_4793755427854490814_n.jpg
--------------------------------------------------------------------------------
/images/23559460_1223772024421994_2585757183464992038_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23559460_1223772024421994_2585757183464992038_n.jpg
--------------------------------------------------------------------------------
/images/23559568_1223771867755343_5931761190105667111_n.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/23559568_1223771867755343_5931761190105667111_n.jpg
--------------------------------------------------------------------------------
/images/DSC00244.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/DSC00244.JPG
--------------------------------------------------------------------------------
/images/Spectacle.Tw9321.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/Spectacle.Tw9321.png
--------------------------------------------------------------------------------
/images/lcd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/images/lcd.png
--------------------------------------------------------------------------------
/kicad/beamer1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shufps/diy-projector-clock/67b28d7980a767fedc22786be03422edd878822c/kicad/beamer1.pdf
--------------------------------------------------------------------------------
/kicad/beamer1.pro:
--------------------------------------------------------------------------------
1 | update=Di 01 Mai 2018 14:18:16 CEST
2 | version=1
3 | last_client=kicad
4 | [pcbnew]
5 | version=1
6 | LastNetListRead=
7 | UseCmpFile=1
8 | PadDrill=0.600000000000
9 | PadDrillOvalY=0.600000000000
10 | PadSizeH=1.500000000000
11 | PadSizeV=1.500000000000
12 | PcbTextSizeV=1.500000000000
13 | PcbTextSizeH=1.500000000000
14 | PcbTextThickness=0.300000000000
15 | ModuleTextSizeV=1.000000000000
16 | ModuleTextSizeH=1.000000000000
17 | ModuleTextSizeThickness=0.150000000000
18 | SolderMaskClearance=0.000000000000
19 | SolderMaskMinWidth=0.000000000000
20 | DrawSegmentWidth=0.200000000000
21 | BoardOutlineThickness=0.100000000000
22 | ModuleOutlineThickness=0.150000000000
23 | [cvpcb]
24 | version=1
25 | NetIExt=net
26 | [general]
27 | version=1
28 | [eeschema]
29 | version=1
30 | LibDir=
31 | [eeschema/libraries]
32 | LibName1=power
33 | LibName2=device
34 | LibName3=transistors
35 | LibName4=conn
36 | LibName5=linear
37 | LibName6=regul
38 | LibName7=74xx
39 | LibName8=cmos4000
40 | LibName9=adc-dac
41 | LibName10=memory
42 | LibName11=xilinx
43 | LibName12=microcontrollers
44 | LibName13=dsp
45 | LibName14=microchip
46 | LibName15=analog_switches
47 | LibName16=motorola
48 | LibName17=texas
49 | LibName18=intel
50 | LibName19=audio
51 | LibName20=interface
52 | LibName21=digital-audio
53 | LibName22=philips
54 | LibName23=display
55 | LibName24=cypress
56 | LibName25=siliconi
57 | LibName26=opto
58 | LibName27=atmel
59 | LibName28=contrib
60 | LibName29=valves
61 | LibName30=/home/thomas/btsync/work/kicad/libs/maxim
62 | LibName31=/home/thomas/btsync/work/kicad/libs/mylib
63 | LibName32=/home/thomas/btsync/work/kicad/libs/net-tie
64 | LibName33=/home/thomas/btsync/work/kicad/libs/ph2-cache
65 | LibName34=/home/thomas/btsync/work/kicad/libs/stm32
66 | LibName35=/home/thomas/btsync/work/kicad/libs/Symbols_DCDC-ACDC-Converter_RevC_29Aug2014
67 | LibName36=/home/thomas/btsync/work/kicad/clock_mini_v3/clock-cache
68 | [schematic_editor]
69 | version=1
70 | PageLayoutDescrFile=
71 | PlotDirectoryName=
72 | SubpartIdSeparator=0
73 | SubpartFirstId=65
74 | NetFmtName=
75 | SpiceForceRefPrefix=0
76 | SpiceUseNetNumbers=0
77 | LabSize=60
78 |
--------------------------------------------------------------------------------
/kicad/gerber/README.txt:
--------------------------------------------------------------------------------
1 | For best fitting, please make PCB with 0.5mm height.
2 |
--------------------------------------------------------------------------------
/kicad/gerber/beamer1-B.Mask.gbs:
--------------------------------------------------------------------------------
1 | G04 #@! TF.FileFunction,Soldermask,Bot*
2 | %FSLAX46Y46*%
3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
4 | G04 Created by KiCad (PCBNEW 4.0.7-e2-6376~58~ubuntu17.04.1) date Sat May 5 16:48:04 2018*
5 | %MOMM*%
6 | %LPD*%
7 | G01*
8 | G04 APERTURE LIST*
9 | %ADD10C,0.100000*%
10 | %ADD11C,2.400000*%
11 | %ADD12R,3.400000X3.400000*%
12 | %ADD13C,1.400000*%
13 | %ADD14R,1.400000X1.400000*%
14 | %ADD15O,1.400000X1.400000*%
15 | %ADD16R,1.800000X2.500000*%
16 | %ADD17O,0.800000X3.400000*%
17 | G04 APERTURE END LIST*
18 | D10*
19 | D11*
20 | X106500000Y-123000000D03*
21 | X106500000Y-125500000D03*
22 | X106500000Y-120500000D03*
23 | D12*
24 | X107750000Y-128850000D03*
25 | X107750000Y-117150000D03*
26 | D11*
27 | X109000000Y-125500000D03*
28 | X109000000Y-120500000D03*
29 | D13*
30 | X124305025Y-123719238D03*
31 | X125719239Y-122305025D03*
32 | X125012132Y-123012131D03*
33 | D14*
34 | X102750000Y-115540000D03*
35 | D15*
36 | X102750000Y-114270000D03*
37 | X102750000Y-113000000D03*
38 | X102750000Y-111730000D03*
39 | X102750000Y-110460000D03*
40 | D16*
41 | X103043000Y-142449000D03*
42 | X107493000Y-142449000D03*
43 | X107493000Y-133349000D03*
44 | X103043000Y-133349000D03*
45 | D17*
46 | X129554000Y-94080000D03*
47 | X128854000Y-94080000D03*
48 | X128154000Y-94080000D03*
49 | X127454000Y-94080000D03*
50 | X126754000Y-94080000D03*
51 | X126054000Y-94080000D03*
52 | X125354000Y-94080000D03*
53 | X124654000Y-94080000D03*
54 | X123954000Y-94080000D03*
55 | X123254000Y-94080000D03*
56 | X122554000Y-94080000D03*
57 | X121854000Y-94080000D03*
58 | X121154000Y-94080000D03*
59 | X120454000Y-94080000D03*
60 | D13*
61 | X130004000Y-90805000D03*
62 | X120004000Y-90805000D03*
63 | M02*
64 |
--------------------------------------------------------------------------------
/kicad/gerber/beamer1-B.SilkS.gbo:
--------------------------------------------------------------------------------
1 | G04 #@! TF.FileFunction,Legend,Bot*
2 | %FSLAX46Y46*%
3 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
4 | G04 Created by KiCad (PCBNEW 4.0.7-e2-6376~58~ubuntu17.04.1) date Sat May 5 16:48:04 2018*
5 | %MOMM*%
6 | %LPD*%
7 | G01*
8 | G04 APERTURE LIST*
9 | %ADD10C,0.100000*%
10 | %ADD11C,0.150000*%
11 | G04 APERTURE END LIST*
12 | D10*
13 | D11*
14 | X106993000Y-137899000D02*
15 | G75*
16 | G03X106993000Y-137899000I-1750000J0D01*
17 | G01*
18 | X108243000Y-140899000D02*
19 | X108243000Y-134899000D01*
20 | X108243000Y-134899000D02*
21 | X102243000Y-134899000D01*
22 | X102243000Y-134899000D02*
23 | X102243000Y-140899000D01*
24 | X102243000Y-140899000D02*
25 | X108243000Y-140899000D01*
26 | X124604000Y-72005000D02*
27 | X125404000Y-72005000D01*
28 | X125004000Y-71605000D02*
29 | X125004000Y-72405000D01*
30 | X130604000Y-74795000D02*
31 | X119404000Y-74795000D01*
32 | X131294000Y-68515000D02*
33 | X118714000Y-68515000D01*
34 | X132254000Y-76305000D02*
35 | X117754000Y-76305000D01*
36 | X130604000Y-69215000D02*
37 | X130604000Y-74795000D01*
38 | X132704000Y-78305000D02*
39 | X132304000Y-78305000D01*
40 | X132754000Y-80105000D02*
41 | X132754000Y-78305000D01*
42 | X131104000Y-80105000D02*
43 | X132704000Y-80105000D01*
44 | X121104000Y-89305000D02*
45 | X119504000Y-89305000D01*
46 | X121604000Y-79305000D02*
47 | X121604000Y-88805000D01*
48 | X130604000Y-88605000D02*
49 | X130604000Y-89005000D01*
50 | X130604000Y-80605000D02*
51 | X130604000Y-88605000D01*
52 | X132254000Y-79305000D02*
53 | X130604000Y-79305000D01*
54 | X132254000Y-67705000D02*
55 | X132254000Y-79305000D01*
56 | X117754000Y-67705000D02*
57 | X132254000Y-67705000D01*
58 | X117754000Y-79305000D02*
59 | X117754000Y-67705000D01*
60 | X130604000Y-79305000D02*
61 | X117754000Y-79305000D01*
62 | X119004000Y-89805000D02*
63 | G75*
64 | G02X119504000Y-89305000I500000J0D01*
65 | G01*
66 | X131004000Y-94805000D02*
67 | X131004000Y-89805000D01*
68 | X119004000Y-94805000D02*
69 | X119004000Y-89805000D01*
70 | X131004000Y-94805000D02*
71 | X119004000Y-94805000D01*
72 | X130803999Y-89405000D02*
73 | G75*
74 | G02X131004000Y-89805000I-299999J-400000D01*
75 | G01*
76 | X121604000Y-88805000D02*
77 | G75*
78 | G02X121104000Y-89305000I-500000J0D01*
79 | G01*
80 | X130803999Y-89405000D02*
81 | G75*
82 | G02X130603998Y-89005000I299999J400000D01*
83 | G01*
84 | X130604000Y-80605000D02*
85 | G75*
86 | G02X131104000Y-80105000I500000J0D01*
87 | G01*
88 | X119404000Y-69215000D02*
89 | X119404000Y-74795000D01*
90 | X131294000Y-68515000D02*
91 | X131294000Y-75495000D01*
92 | X118714000Y-68515000D02*
93 | X118714000Y-75495000D01*
94 | X130604000Y-69215000D02*
95 | X119404000Y-69215000D01*
96 | X131294000Y-75495000D02*
97 | X118714000Y-75495000D01*
98 | M02*
99 |
--------------------------------------------------------------------------------
/src/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | beamer1
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
25 | org.eclipse.cdt.core.ccnature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/.settings/language.settings.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/Encoding.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | class Encoding {
14 | public:
15 | // Optimized for code size on a 8-bit AVR
16 | static char escapeChar(char c) {
17 | const char *p = escapeTable(false);
18 | while (p[0] && p[1] != c) {
19 | p += 2;
20 | }
21 | return p[0];
22 | }
23 |
24 | // Optimized for code size on a 8-bit AVR
25 | static char unescapeChar(char c) {
26 | const char *p = escapeTable(true);
27 | for (;;) {
28 | if (p[0] == '\0') return c;
29 | if (p[0] == c) return p[1];
30 | p += 2;
31 | }
32 | }
33 |
34 | private:
35 | static const char *escapeTable(bool excludeIdenticals) {
36 | return &"\"\"\\\\b\bf\fn\nr\rt\t"[excludeIdenticals ? 4 : 0];
37 | }
38 | };
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonBufferAllocated.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../JsonBuffer.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | class JsonBufferAllocated {
16 | public:
17 | void *operator new(size_t n, JsonBuffer *jsonBuffer) throw() {
18 | if (!jsonBuffer) return NULL;
19 | return jsonBuffer->alloc(n);
20 | }
21 |
22 | void operator delete(void *, JsonBuffer *)throw() {}
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonFloat.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | #if ARDUINOJSON_USE_DOUBLE
16 | typedef double JsonFloat;
17 | #else
18 | typedef float JsonFloat;
19 | #endif
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonInteger.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | #if ARDUINOJSON_USE_LONG_LONG
16 | typedef long long JsonInteger;
17 | typedef unsigned long long JsonUInt;
18 | #elif ARDUINOJSON_USE_INT64
19 | typedef __int64 JsonInteger;
20 | typedef unsigned _int64 JsonUInt;
21 | #else
22 | typedef long JsonInteger;
23 | typedef unsigned long JsonUInt;
24 | #endif
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonVariantAs.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | // A metafunction that returns the type of the value returned by
14 | // JsonVariant::as()
15 | template
16 | struct JsonVariantAs {
17 | typedef T type;
18 | };
19 |
20 | template <>
21 | struct JsonVariantAs {
22 | typedef const char* type;
23 | };
24 |
25 | template <>
26 | struct JsonVariantAs {
27 | typedef JsonArray& type;
28 | };
29 |
30 | template <>
31 | struct JsonVariantAs {
32 | typedef const JsonArray& type;
33 | };
34 |
35 | template <>
36 | struct JsonVariantAs {
37 | typedef JsonObject& type;
38 | };
39 |
40 | template <>
41 | struct JsonVariantAs {
42 | typedef const JsonObject& type;
43 | };
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonVariantComparer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../JsonVariantBase.hpp"
11 | #include "../StringTraits/StringTraits.hpp"
12 | #include "../TypeTraits/EnableIf.hpp"
13 |
14 | namespace ArduinoJson {
15 | namespace Internals {
16 | template
17 | struct JsonVariantComparer {};
18 |
19 | template
20 | struct JsonVariantComparer<
21 | TString,
22 | typename TypeTraits::EnableIf::value>::type> {
23 | template
24 | static bool equals(const JsonVariantBase &variant,
25 | const TString &comparand) {
26 | const char *value = variant.template as();
27 | return Internals::StringTraits::equals(comparand, value);
28 | }
29 | };
30 |
31 | template
32 | struct JsonVariantComparer<
33 | TComparand, typename TypeTraits::EnableIf<
34 | !TypeTraits::IsVariant::value &&
35 | !TypeTraits::IsString::value>::type> {
36 | template
37 | static bool equals(const JsonVariantBase &variant,
38 | const TComparand &comparand) {
39 | return variant.template as() == comparand;
40 | }
41 | };
42 |
43 | template
44 | struct JsonVariantComparer::value>::type> {
47 | template
48 | static bool equals(const JsonVariantBase &left,
49 | const TVariant2 &right) {
50 | if (left.template is() && right.template is())
51 | return left.template as() == right.template as();
52 | if (left.template is() && right.template is())
53 | return left.template as() ==
54 | right.template as();
55 | if (left.template is() && right.template is())
56 | return left.template as() == right.template as();
57 | if (left.template is() && right.template is())
58 | return left.template as() == right.template as();
59 | if (left.template is() && right.template is())
60 | return left.template as() == right.template as();
61 | if (left.template is() && right.template is())
62 | return strcmp(left.template as(), right.template as()) ==
63 | 0;
64 |
65 | return false;
66 | }
67 | };
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonVariantContent.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonFloat.hpp"
11 | #include "JsonInteger.hpp"
12 |
13 | namespace ArduinoJson {
14 |
15 | // Forward declarations
16 | class JsonArray;
17 | class JsonObject;
18 |
19 | namespace Internals {
20 | // A union that defines the actual content of a JsonVariant.
21 | // The enum JsonVariantType determines which member is in use.
22 | union JsonVariantContent {
23 | JsonFloat asFloat; // used for double and float
24 | JsonUInt asInteger; // used for bool, char, short, int and longs
25 | const char* asString; // asString can be null
26 | JsonArray* asArray; // asArray cannot be null
27 | JsonObject* asObject; // asObject cannot be null
28 | };
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonVariantDefault.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | template
14 | struct JsonVariantDefault {
15 | static T get() {
16 | return T();
17 | }
18 | };
19 |
20 | template
21 | struct JsonVariantDefault : JsonVariantDefault {};
22 |
23 | template
24 | struct JsonVariantDefault : JsonVariantDefault {};
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/JsonVariantType.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | class JsonArray;
12 | class JsonObject;
13 |
14 | namespace Internals {
15 |
16 | // Enumerated type to know the current type of a JsonVariant.
17 | // The value determines which member of JsonVariantContent is used.
18 | enum JsonVariantType {
19 | JSON_UNDEFINED, // JsonVariant has not been initialized
20 | JSON_UNPARSED, // JsonVariant contains an unparsed string
21 | JSON_STRING, // JsonVariant stores a const char*
22 | JSON_BOOLEAN, // JsonVariant stores a bool
23 | JSON_POSITIVE_INTEGER, // JsonVariant stores an JsonUInt
24 | JSON_NEGATIVE_INTEGER, // JsonVariant stores an JsonUInt that must be negated
25 | JSON_ARRAY, // JsonVariant stores a pointer to a JsonArray
26 | JSON_OBJECT, // JsonVariant stores a pointer to a JsonObject
27 | JSON_FLOAT // JsonVariant stores a JsonFloat
28 | };
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/List.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../JsonBuffer.hpp"
11 | #include "ListConstIterator.hpp"
12 | #include "ListIterator.hpp"
13 |
14 | namespace ArduinoJson {
15 | namespace Internals {
16 |
17 | // A singly linked list of T.
18 | // The linked list is composed of ListNode.
19 | // It is derived by JsonArray and JsonObject
20 | template
21 | class List {
22 | public:
23 | typedef T value_type;
24 | typedef ListNode node_type;
25 | typedef ListIterator iterator;
26 | typedef ListConstIterator const_iterator;
27 |
28 | // Creates an empty List attached to a JsonBuffer.
29 | // The JsonBuffer allows to allocate new nodes.
30 | // When buffer is NULL, the List is not able to grow and success() returns
31 | // false. This is used to identify bad memory allocations and parsing
32 | // failures.
33 | explicit List(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {}
34 |
35 | // Returns true if the object is valid
36 | // Would return false in the following situation:
37 | // - the memory allocation failed (StaticJsonBuffer was too small)
38 | // - the JSON parsing failed
39 | bool success() const {
40 | return _buffer != NULL;
41 | }
42 |
43 | // Returns the numbers of elements in the list.
44 | // For a JsonObject, it would return the number of key-value pairs
45 | size_t size() const {
46 | size_t nodeCount = 0;
47 | for (node_type *node = _firstNode; node; node = node->next) nodeCount++;
48 | return nodeCount;
49 | }
50 |
51 | iterator add() {
52 | node_type *newNode = new (_buffer) node_type();
53 |
54 | if (_firstNode) {
55 | node_type *lastNode = _firstNode;
56 | while (lastNode->next) lastNode = lastNode->next;
57 | lastNode->next = newNode;
58 | } else {
59 | _firstNode = newNode;
60 | }
61 |
62 | return iterator(newNode);
63 | }
64 |
65 | iterator begin() {
66 | return iterator(_firstNode);
67 | }
68 | iterator end() {
69 | return iterator(NULL);
70 | }
71 |
72 | const_iterator begin() const {
73 | return const_iterator(_firstNode);
74 | }
75 | const_iterator end() const {
76 | return const_iterator(NULL);
77 | }
78 |
79 | void remove(iterator it) {
80 | node_type *nodeToRemove = it._node;
81 | if (!nodeToRemove) return;
82 | if (nodeToRemove == _firstNode) {
83 | _firstNode = nodeToRemove->next;
84 | } else {
85 | for (node_type *node = _firstNode; node; node = node->next)
86 | if (node->next == nodeToRemove) node->next = nodeToRemove->next;
87 | }
88 | }
89 |
90 | protected:
91 | JsonBuffer *_buffer;
92 |
93 | private:
94 | node_type *_firstNode;
95 | };
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/ListConstIterator.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "ListNode.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | // A read-only forward itertor for List
16 | template
17 | class ListConstIterator {
18 | public:
19 | explicit ListConstIterator(const ListNode *node = NULL) : _node(node) {}
20 |
21 | const T &operator*() const {
22 | return _node->content;
23 | }
24 | const T *operator->() {
25 | return &_node->content;
26 | }
27 |
28 | bool operator==(const ListConstIterator &other) const {
29 | return _node == other._node;
30 | }
31 |
32 | bool operator!=(const ListConstIterator &other) const {
33 | return _node != other._node;
34 | }
35 |
36 | ListConstIterator &operator++() {
37 | if (_node) _node = _node->next;
38 | return *this;
39 | }
40 |
41 | ListConstIterator &operator+=(size_t distance) {
42 | while (_node && distance) {
43 | _node = _node->next;
44 | --distance;
45 | }
46 | return *this;
47 | }
48 |
49 | private:
50 | const ListNode *_node;
51 | };
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/ListIterator.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "ListConstIterator.hpp"
11 | #include "ListNode.hpp"
12 |
13 | namespace ArduinoJson {
14 | namespace Internals {
15 |
16 | template
17 | class List;
18 |
19 | // A read-write forward iterator for List
20 | template
21 | class ListIterator {
22 | friend class List;
23 |
24 | public:
25 | explicit ListIterator(ListNode *node = NULL) : _node(node) {}
26 |
27 | T &operator*() const {
28 | return _node->content;
29 | }
30 | T *operator->() {
31 | return &_node->content;
32 | }
33 |
34 | bool operator==(const ListIterator &other) const {
35 | return _node == other._node;
36 | }
37 |
38 | bool operator!=(const ListIterator &other) const {
39 | return _node != other._node;
40 | }
41 |
42 | ListIterator &operator++() {
43 | if (_node) _node = _node->next;
44 | return *this;
45 | }
46 |
47 | ListIterator &operator+=(size_t distance) {
48 | while (_node && distance) {
49 | _node = _node->next;
50 | --distance;
51 | }
52 | return *this;
53 | }
54 |
55 | operator ListConstIterator() const {
56 | return ListConstIterator(_node);
57 | }
58 |
59 | private:
60 | ListNode *_node;
61 | };
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/ListNode.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include // for NULL
11 |
12 | #include "JsonBufferAllocated.hpp"
13 |
14 | namespace ArduinoJson {
15 | namespace Internals {
16 |
17 | // A node for a singly-linked list.
18 | // Used by List and its iterators.
19 | template
20 | struct ListNode : public Internals::JsonBufferAllocated {
21 | ListNode() : next(NULL) {}
22 |
23 | ListNode *next;
24 | T content;
25 | };
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/ReferenceType.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | // A type that is meant to be used by reference only (JsonArray and JsonObject)
14 | class ReferenceType {
15 | public:
16 | bool operator==(const ReferenceType& other) const {
17 | // two JsonArray are equal if they are the same instance
18 | // (we don't compare the content)
19 | return this == &other;
20 | }
21 |
22 | bool operator!=(const ReferenceType& other) const {
23 | return this != &other;
24 | }
25 |
26 | protected:
27 | ReferenceType() {}
28 |
29 | private:
30 | // copy constructor is private
31 | ReferenceType(const ReferenceType&);
32 |
33 | // copy operator is private
34 | ReferenceType& operator=(const ReferenceType&);
35 | };
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Data/ValueSetter.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../JsonBuffer.hpp"
11 | #include "../JsonVariant.hpp"
12 | #include "../StringTraits/StringTraits.hpp"
13 | #include "../TypeTraits/EnableIf.hpp"
14 |
15 | namespace ArduinoJson {
16 | namespace Internals {
17 |
18 | template
19 | struct ValueSetter {
20 | template
21 | static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
22 | destination = source;
23 | return true;
24 | }
25 | };
26 |
27 | template
28 | struct ValueSetter::should_duplicate>::type> {
30 | template
31 | static bool set(JsonBuffer* buffer, TDestination& destination,
32 | TSourceRef source) {
33 | const char* copy = buffer->strdup(source);
34 | if (!copy) return false;
35 | destination = copy;
36 | return true;
37 | }
38 | };
39 |
40 | template
41 | struct ValueSetter::should_duplicate>::type> {
43 | template
44 | static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
45 | // unsigned char* -> char*
46 | destination = reinterpret_cast(source);
47 | return true;
48 | }
49 | };
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Deserialization/Comments.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 | template
13 | void skipSpacesAndComments(TInput& input) {
14 | for (;;) {
15 | switch (input.current()) {
16 | // spaces
17 | case ' ':
18 | case '\t':
19 | case '\r':
20 | case '\n':
21 | input.move();
22 | continue;
23 |
24 | // comments
25 | case '/':
26 | switch (input.next()) {
27 | // C-style block comment
28 | case '*':
29 | input.move(); // skip '/'
30 | // no need to skip '*'
31 | for (;;) {
32 | input.move();
33 | if (input.current() == '\0') return;
34 | if (input.current() == '*' && input.next() == '/') {
35 | input.move(); // skip '*'
36 | input.move(); // skip '/'
37 | break;
38 | }
39 | }
40 | break;
41 |
42 | // C++-style line comment
43 | case '/':
44 | // not need to skip "//"
45 | for (;;) {
46 | input.move();
47 | if (input.current() == '\0') return;
48 | if (input.current() == '\n') break;
49 | }
50 | break;
51 |
52 | // not a comment, just a '/'
53 | default:
54 | return;
55 | }
56 | break;
57 |
58 | default:
59 | return;
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Deserialization/StringWriter.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | template
14 | class StringWriter {
15 | public:
16 | class String {
17 | public:
18 | String(TChar** ptr) : _writePtr(ptr), _startPtr(*ptr) {}
19 |
20 | void append(char c) {
21 | *(*_writePtr)++ = TChar(c);
22 | }
23 |
24 | const char* c_str() const {
25 | *(*_writePtr)++ = 0;
26 | return reinterpret_cast(_startPtr);
27 | }
28 |
29 | private:
30 | TChar** _writePtr;
31 | TChar* _startPtr;
32 | };
33 |
34 | StringWriter(TChar* buffer) : _ptr(buffer) {}
35 |
36 | String startString() {
37 | return String(&_ptr);
38 | }
39 |
40 | private:
41 | TChar* _ptr;
42 | };
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/ArduinoJson/JsonArrayImpl.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonArray.hpp"
11 | #include "JsonArraySubscript.hpp"
12 | #include "JsonObject.hpp"
13 |
14 | namespace ArduinoJson {
15 |
16 | inline JsonArray &JsonArray::createNestedArray() {
17 | if (!_buffer) return JsonArray::invalid();
18 | JsonArray &array = _buffer->createArray();
19 | add(array);
20 | return array;
21 | }
22 |
23 | inline JsonObject &JsonArray::createNestedObject() {
24 | if (!_buffer) return JsonObject::invalid();
25 | JsonObject &object = _buffer->createObject();
26 | add(object);
27 | return object;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/ArduinoJson/JsonBuffer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include // for size_t
11 | #include // for uint8_t
12 | #include
13 |
14 | #include "JsonVariant.hpp"
15 | #include "TypeTraits/EnableIf.hpp"
16 | #include "TypeTraits/IsArray.hpp"
17 |
18 | #if defined(__clang__)
19 | #pragma clang diagnostic push
20 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
21 | #elif defined(__GNUC__)
22 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
23 | #pragma GCC diagnostic push
24 | #endif
25 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
26 | #endif
27 |
28 | namespace ArduinoJson {
29 | class JsonArray;
30 | class JsonObject;
31 |
32 | // Entry point for using the library.
33 | //
34 | // Handle the memory management (done in derived classes) and calls the parser.
35 | // This abstract class is implemented by StaticJsonBuffer which implements a
36 | // fixed memory allocation.
37 | class JsonBuffer {
38 | public:
39 | // CAUTION: NO VIRTUAL DESTRUCTOR!
40 | // If we add a virtual constructor the Arduino compiler will add malloc() and
41 | // free() to the binary, adding 706 useless bytes.
42 | // virtual ~JsonBuffer() {}
43 |
44 | // Allocates an empty JsonArray.
45 | //
46 | // Returns a reference to the new JsonArray or JsonArray::invalid() if the
47 | // allocation fails.
48 | JsonArray &createArray();
49 |
50 | // Allocates an empty JsonObject.
51 | //
52 | // Returns a reference to the new JsonObject or JsonObject::invalid() if the
53 | // allocation fails.
54 | JsonObject &createObject();
55 |
56 | // Duplicates a string
57 | //
58 | // char* strdup(TValue);
59 | // TValue = const std::string&, const String&,
60 | template
61 | typename TypeTraits::EnableIf::value,
62 | char *>::type
63 | strdup(const TString &src) {
64 | return Internals::StringTraits::duplicate(src, this);
65 | }
66 | //
67 | // char* strdup(TValue);
68 | // TValue = const char*, const char[N], const FlashStringHelper*
69 | template
70 | char *strdup(const TString *src) {
71 | return Internals::StringTraits::duplicate(src, this);
72 | }
73 |
74 | // Allocates n bytes in the JsonBuffer.
75 | // Return a pointer to the allocated memory or NULL if allocation fails.
76 | virtual void *alloc(size_t size) = 0;
77 |
78 | protected:
79 | // Preserve aligment if necessary
80 | static FORCE_INLINE size_t round_size_up(size_t bytes) {
81 | #if ARDUINOJSON_ENABLE_ALIGNMENT
82 | const size_t x = sizeof(void *) - 1;
83 | return (bytes + x) & ~x;
84 | #else
85 | return bytes;
86 | #endif
87 | }
88 | };
89 | }
90 |
91 | #if defined(__clang__)
92 | #pragma clang diagnostic pop
93 | #elif defined(__GNUC__)
94 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
95 | #pragma GCC diagnostic pop
96 | #endif
97 | #endif
98 |
--------------------------------------------------------------------------------
/src/ArduinoJson/JsonBufferImpl.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "Deserialization/JsonParser.hpp"
11 |
12 | inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::createArray() {
13 | JsonArray *ptr = new (this) JsonArray(this);
14 | return ptr ? *ptr : JsonArray::invalid();
15 | }
16 |
17 | inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::createObject() {
18 | JsonObject *ptr = new (this) JsonObject(this);
19 | return ptr ? *ptr : JsonObject::invalid();
20 | }
21 |
--------------------------------------------------------------------------------
/src/ArduinoJson/JsonObjectImpl.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonArray.hpp"
11 | #include "JsonObject.hpp"
12 | #include "JsonObjectSubscript.hpp"
13 |
14 | namespace ArduinoJson {
15 |
16 | template
17 | inline JsonArray &JsonObject::createNestedArray_impl(TStringRef key) {
18 | if (!_buffer) return JsonArray::invalid();
19 | JsonArray &array = _buffer->createArray();
20 | set(key, array);
21 | return array;
22 | }
23 |
24 | template
25 | inline JsonObject &JsonObject::createNestedObject_impl(TStringRef key) {
26 | if (!_buffer) return JsonObject::invalid();
27 | JsonObject &object = _buffer->createObject();
28 | set(key, object);
29 | return object;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ArduinoJson/JsonPair.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonVariant.hpp"
11 |
12 | namespace ArduinoJson {
13 |
14 | // A key value pair for JsonObject.
15 | struct JsonPair {
16 | const char* key;
17 | JsonVariant value;
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/attributes.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #ifdef _MSC_VER // Visual Studio
11 |
12 | #define FORCE_INLINE __forceinline
13 | #define NO_INLINE __declspec(noinline)
14 | #define DEPRECATED(msg) __declspec(deprecated(msg))
15 |
16 | #elif defined(__GNUC__) // GCC or Clang
17 |
18 | #define FORCE_INLINE __attribute__((always_inline))
19 | #define NO_INLINE __attribute__((noinline))
20 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
21 | #define DEPRECATED(msg) __attribute__((deprecated(msg)))
22 | #else
23 | #define DEPRECATED(msg) __attribute__((deprecated))
24 | #endif
25 |
26 | #else // Other compilers
27 |
28 | #define FORCE_INLINE
29 | #define NO_INLINE
30 | #define DEPRECATED(msg)
31 |
32 | #endif
33 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/ctype.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Polyfills {
12 |
13 | inline bool isdigit(char c) {
14 | return '0' <= c && c <= '9';
15 | }
16 |
17 | inline bool issign(char c) {
18 | return '-' == c || c == '+';
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/isFloat.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include // for strcmp
11 | #include "./ctype.hpp"
12 |
13 | namespace ArduinoJson {
14 | namespace Polyfills {
15 |
16 | inline bool isFloat(const char* s) {
17 | if (!s) return false;
18 |
19 | if (!strcmp(s, "NaN")) return true;
20 | if (issign(*s)) s++;
21 | if (!strcmp(s, "Infinity")) return true;
22 | if (*s == '\0') return false;
23 |
24 | while (isdigit(*s)) s++;
25 |
26 | if (*s == '.') {
27 | s++;
28 | while (isdigit(*s)) s++;
29 | }
30 |
31 | if (*s == 'e' || *s == 'E') {
32 | s++;
33 | if (issign(*s)) s++;
34 | if (!isdigit(*s)) return false;
35 | while (isdigit(*s)) s++;
36 | }
37 |
38 | return *s == '\0';
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/isInteger.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "./ctype.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Polyfills {
14 |
15 | inline bool isInteger(const char* s) {
16 | if (!s) return false;
17 | if (issign(*s)) s++;
18 | while (isdigit(*s)) s++;
19 | return *s == '\0';
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/math.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Polyfills {
12 | template
13 | bool isNaN(T x) {
14 | return x != x;
15 | }
16 |
17 | template
18 | bool isInfinity(T x) {
19 | return x != 0.0 && x * 2 == x;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/normalize.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Polyfills {
14 | template
15 | int16_t normalize(T& value) {
16 | int16_t powersOf10 = 0;
17 |
18 | if (value >= ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD) {
19 | #if ARDUINOJSON_DOUBLE_IS_64BITS
20 | if (value >= 1e256) {
21 | value /= 1e256;
22 | powersOf10 = int16_t(powersOf10 + 256);
23 | }
24 | if (value >= 1e128) {
25 | value /= 1e128;
26 | powersOf10 = int16_t(powersOf10 + 128);
27 | }
28 | if (value >= 1e64) {
29 | value /= 1e64;
30 | powersOf10 = int16_t(powersOf10 + 64);
31 | }
32 | #endif
33 | if (value >= 1e32) {
34 | value /= 1e32;
35 | powersOf10 = int16_t(powersOf10 + 32);
36 | }
37 | if (value >= 1e16) {
38 | value /= 1e16;
39 | powersOf10 = int16_t(powersOf10 + 16);
40 | }
41 | if (value >= 1e8) {
42 | value /= 1e8;
43 | powersOf10 = int16_t(powersOf10 + 8);
44 | }
45 | if (value >= 1e4) {
46 | value /= 1e4;
47 | powersOf10 = int16_t(powersOf10 + 4);
48 | }
49 | if (value >= 1e2) {
50 | value /= 1e2;
51 | powersOf10 = int16_t(powersOf10 + 2);
52 | }
53 | if (value >= 1e1) {
54 | value /= 1e1;
55 | powersOf10 = int16_t(powersOf10 + 1);
56 | }
57 | }
58 |
59 | if (value > 0 && value <= ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD) {
60 | #if ARDUINOJSON_DOUBLE_IS_64BITS
61 | if (value < 1e-255) {
62 | value *= 1e256;
63 | powersOf10 = int16_t(powersOf10 - 256);
64 | }
65 | if (value < 1e-127) {
66 | value *= 1e128;
67 | powersOf10 = int16_t(powersOf10 - 128);
68 | }
69 | if (value < 1e-63) {
70 | value *= 1e64;
71 | powersOf10 = int16_t(powersOf10 - 64);
72 | }
73 | #endif
74 | if (value < 1e-31) {
75 | value *= 1e32;
76 | powersOf10 = int16_t(powersOf10 - 32);
77 | }
78 | if (value < 1e-15) {
79 | value *= 1e16;
80 | powersOf10 = int16_t(powersOf10 - 16);
81 | }
82 | if (value < 1e-7) {
83 | value *= 1e8;
84 | powersOf10 = int16_t(powersOf10 - 8);
85 | }
86 | if (value < 1e-3) {
87 | value *= 1e4;
88 | powersOf10 = int16_t(powersOf10 - 4);
89 | }
90 | if (value < 1e-1) {
91 | value *= 1e2;
92 | powersOf10 = int16_t(powersOf10 - 2);
93 | }
94 | if (value < 1e0) {
95 | value *= 1e1;
96 | powersOf10 = int16_t(powersOf10 - 1);
97 | }
98 | }
99 |
100 | return powersOf10;
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/parseFloat.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../TypeTraits/FloatTraits.hpp"
11 | #include "./ctype.hpp"
12 | #include "./math.hpp"
13 |
14 | namespace ArduinoJson {
15 | namespace Polyfills {
16 |
17 | template
18 | inline T parseFloat(const char* s) {
19 | typedef TypeTraits::FloatTraits traits;
20 | typedef typename traits::mantissa_type mantissa_t;
21 | typedef typename traits::exponent_type exponent_t;
22 |
23 | if (!s) return 0; // NULL
24 |
25 | bool negative_result = false;
26 | switch (*s) {
27 | case '-':
28 | negative_result = true;
29 | case '+':
30 | s++;
31 | }
32 |
33 | if (*s == 't') return 1; // true
34 | if (*s == 'n' || *s == 'N') return traits::nan();
35 | if (*s == 'i' || *s == 'I')
36 | return negative_result ? -traits::inf() : traits::inf();
37 |
38 | mantissa_t mantissa = 0;
39 | exponent_t exponent_offset = 0;
40 |
41 | while (isdigit(*s)) {
42 | if (mantissa < traits::mantissa_max / 10)
43 | mantissa = mantissa * 10 + (*s - '0');
44 | else
45 | exponent_offset++;
46 | s++;
47 | }
48 |
49 | if (*s == '.') {
50 | s++;
51 | while (isdigit(*s)) {
52 | if (mantissa < traits::mantissa_max / 10) {
53 | mantissa = mantissa * 10 + (*s - '0');
54 | exponent_offset--;
55 | }
56 | s++;
57 | }
58 | }
59 |
60 | int exponent = 0;
61 | if (*s == 'e' || *s == 'E') {
62 | s++;
63 | bool negative_exponent = false;
64 | if (*s == '-') {
65 | negative_exponent = true;
66 | s++;
67 | } else if (*s == '+') {
68 | s++;
69 | }
70 |
71 | while (isdigit(*s)) {
72 | exponent = exponent * 10 + (*s - '0');
73 | if (exponent + exponent_offset > traits::exponent_max) {
74 | if (negative_exponent)
75 | return negative_result ? -0.0f : 0.0f;
76 | else
77 | return negative_result ? -traits::inf() : traits::inf();
78 | }
79 | s++;
80 | }
81 | if (negative_exponent) exponent = -exponent;
82 | }
83 | exponent += exponent_offset;
84 |
85 | T result = traits::make_float(static_cast(mantissa), exponent);
86 |
87 | return negative_result ? -result : result;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Polyfills/parseInteger.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include
11 |
12 | #include "../Configuration.hpp"
13 | #include "./ctype.hpp"
14 |
15 | namespace ArduinoJson {
16 | namespace Polyfills {
17 | template
18 | T parseInteger(const char *s) {
19 | if (!s) return 0; // NULL
20 |
21 | if (*s == 't') return 1; // "true"
22 |
23 | T result = 0;
24 | bool negative_result = false;
25 |
26 | switch (*s) {
27 | case '-':
28 | negative_result = true;
29 | case '+':
30 | s++;
31 | break;
32 | }
33 |
34 | while (isdigit(*s)) {
35 | result = T(result * 10 + T(*s - '0'));
36 | s++;
37 | }
38 |
39 | return negative_result ? T(~result + 1) : result;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/ArduinoJson/RawJson.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 |
12 | // A special type of data that can be used to insert pregenerated JSON portions.
13 | class RawJson {
14 | public:
15 | explicit RawJson(const char* str) : _str(str) {}
16 | operator const char*() const {
17 | return _str;
18 | }
19 |
20 | private:
21 | const char* _str;
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/DummyPrint.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | // A dummy Print implementation used in JsonPrintable::measureLength()
14 | class DummyPrint {
15 | public:
16 | size_t print(char) {
17 | return 1;
18 | }
19 |
20 | size_t print(const char* s) {
21 | return strlen(s);
22 | }
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../StringTraits/StringTraits.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | // A Print implementation that allows to write in a String
16 | template
17 | class DynamicStringBuilder {
18 | public:
19 | DynamicStringBuilder(TString &str) : _str(str) {}
20 |
21 | size_t print(char c) {
22 | StringTraits::append(_str, c);
23 | return 1;
24 | }
25 |
26 | size_t print(const char *s) {
27 | size_t initialLen = _str.length();
28 | StringTraits::append(_str, s);
29 | return _str.length() - initialLen;
30 | }
31 |
32 | private:
33 | DynamicStringBuilder &operator=(const DynamicStringBuilder &);
34 |
35 | TString &_str;
36 | };
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/IndentedPrint.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | // Decorator on top of Print to allow indented output.
14 | // This class is used by JsonPrintable::prettyPrintTo() but can also be used
15 | // for your own purpose, like logging.
16 | template
17 | class IndentedPrint {
18 | public:
19 | explicit IndentedPrint(Print &p) : sink(&p) {
20 | level = 0;
21 | tabSize = 2;
22 | isNewLine = true;
23 | }
24 |
25 | size_t print(char c) {
26 | size_t n = 0;
27 | if (isNewLine) n += writeTabs();
28 | n += sink->print(c);
29 | isNewLine = c == '\n';
30 | return n;
31 | }
32 |
33 | size_t print(const char *s) {
34 | // TODO: optimize
35 | size_t n = 0;
36 | while (*s) n += print(*s++);
37 | return n;
38 | }
39 |
40 | // Adds one level of indentation
41 | void indent() {
42 | if (level < MAX_LEVEL) level++;
43 | }
44 |
45 | // Removes one level of indentation
46 | void unindent() {
47 | if (level > 0) level--;
48 | }
49 |
50 | // Set the number of space printed for each level of indentation
51 | void setTabSize(uint8_t n) {
52 | if (n < MAX_TAB_SIZE) tabSize = n & MAX_TAB_SIZE;
53 | }
54 |
55 | private:
56 | Print *sink;
57 | uint8_t level : 4;
58 | uint8_t tabSize : 3;
59 | bool isNewLine : 1;
60 |
61 | size_t writeTabs() {
62 | size_t n = 0;
63 | for (int i = 0; i < level * tabSize; i++) n += sink->print(' ');
64 | return n;
65 | }
66 |
67 | static const int MAX_LEVEL = 15; // because it's only 4 bits
68 | static const int MAX_TAB_SIZE = 7; // because it's only 3 bits
69 | };
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/JsonSerializer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonWriter.hpp"
11 |
12 | namespace ArduinoJson {
13 |
14 | class JsonArray;
15 | class JsonArraySubscript;
16 | class JsonObject;
17 | template
18 | class JsonObjectSubscript;
19 | class JsonVariant;
20 |
21 | namespace Internals {
22 |
23 | template
24 | class JsonSerializer {
25 | public:
26 | static void serialize(const JsonArray &, Writer &);
27 | static void serialize(const JsonArraySubscript &, Writer &);
28 | static void serialize(const JsonObject &, Writer &);
29 | template
30 | static void serialize(const JsonObjectSubscript &, Writer &);
31 | static void serialize(const JsonVariant &, Writer &);
32 | };
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../JsonArray.hpp"
11 | #include "../JsonArraySubscript.hpp"
12 | #include "../JsonObject.hpp"
13 | #include "../JsonObjectSubscript.hpp"
14 | #include "../JsonVariant.hpp"
15 | #include "JsonSerializer.hpp"
16 |
17 | template
18 | inline void ArduinoJson::Internals::JsonSerializer::serialize(
19 | const JsonArray& array, Writer& writer) {
20 | writer.beginArray();
21 |
22 | JsonArray::const_iterator it = array.begin();
23 | while (it != array.end()) {
24 | serialize(*it, writer);
25 |
26 | ++it;
27 | if (it == array.end()) break;
28 |
29 | writer.writeComma();
30 | }
31 |
32 | writer.endArray();
33 | }
34 |
35 | template
36 | inline void ArduinoJson::Internals::JsonSerializer::serialize(
37 | const JsonArraySubscript& arraySubscript, Writer& writer) {
38 | serialize(arraySubscript.as(), writer);
39 | }
40 |
41 | template
42 | inline void ArduinoJson::Internals::JsonSerializer::serialize(
43 | const JsonObject& object, Writer& writer) {
44 | writer.beginObject();
45 |
46 | JsonObject::const_iterator it = object.begin();
47 | while (it != object.end()) {
48 | writer.writeString(it->key);
49 | writer.writeColon();
50 | serialize(it->value, writer);
51 |
52 | ++it;
53 | if (it == object.end()) break;
54 |
55 | writer.writeComma();
56 | }
57 |
58 | writer.endObject();
59 | }
60 |
61 | template
62 | template
63 | inline void ArduinoJson::Internals::JsonSerializer::serialize(
64 | const JsonObjectSubscript& objectSubscript, Writer& writer) {
65 | serialize(objectSubscript.template as(), writer);
66 | }
67 |
68 | template
69 | inline void ArduinoJson::Internals::JsonSerializer::serialize(
70 | const JsonVariant& variant, Writer& writer) {
71 | switch (variant._type) {
72 | case JSON_FLOAT:
73 | writer.writeFloat(variant._content.asFloat);
74 | return;
75 |
76 | case JSON_ARRAY:
77 | serialize(*variant._content.asArray, writer);
78 | return;
79 |
80 | case JSON_OBJECT:
81 | serialize(*variant._content.asObject, writer);
82 | return;
83 |
84 | case JSON_STRING:
85 | writer.writeString(variant._content.asString);
86 | return;
87 |
88 | case JSON_UNPARSED:
89 | writer.writeRaw(variant._content.asString);
90 | return;
91 |
92 | case JSON_NEGATIVE_INTEGER:
93 | writer.writeRaw('-');
94 | case JSON_POSITIVE_INTEGER:
95 | writer.writeInteger(variant._content.asInteger);
96 | return;
97 |
98 | case JSON_BOOLEAN:
99 | writer.writeBoolean(variant._content.asInteger != 0);
100 | return;
101 |
102 | default: // JSON_UNDEFINED
103 | return;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/Prettyfier.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "IndentedPrint.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 |
15 | // Converts a compact JSON string into an indented one.
16 | template
17 | class Prettyfier {
18 | public:
19 | explicit Prettyfier(IndentedPrint& p) : _sink(p) {
20 | _previousChar = 0;
21 | _inString = false;
22 | }
23 |
24 | size_t print(char c) {
25 | size_t n = _inString ? handleStringChar(c) : handleMarkupChar(c);
26 | _previousChar = c;
27 | return n;
28 | }
29 |
30 | size_t print(const char* s) {
31 | // TODO: optimize
32 | size_t n = 0;
33 | while (*s) n += print(*s++);
34 | return n;
35 | }
36 |
37 | private:
38 | Prettyfier& operator=(const Prettyfier&); // cannot be assigned
39 |
40 | bool inEmptyBlock() {
41 | return _previousChar == '{' || _previousChar == '[';
42 | }
43 |
44 | size_t handleStringChar(char c) {
45 | bool isQuote = c == '"' && _previousChar != '\\';
46 |
47 | if (isQuote) _inString = false;
48 |
49 | return _sink.print(c);
50 | }
51 |
52 | size_t handleMarkupChar(char c) {
53 | switch (c) {
54 | case '{':
55 | case '[':
56 | return writeBlockOpen(c);
57 |
58 | case '}':
59 | case ']':
60 | return writeBlockClose(c);
61 |
62 | case ':':
63 | return writeColon();
64 |
65 | case ',':
66 | return writeComma();
67 |
68 | case '"':
69 | return writeQuoteOpen();
70 |
71 | default:
72 | return writeNormalChar(c);
73 | }
74 | }
75 |
76 | size_t writeBlockClose(char c) {
77 | size_t n = 0;
78 | n += unindentIfNeeded();
79 | n += _sink.print(c);
80 | return n;
81 | }
82 |
83 | size_t writeBlockOpen(char c) {
84 | size_t n = 0;
85 | n += indentIfNeeded();
86 | n += _sink.print(c);
87 | return n;
88 | }
89 |
90 | size_t writeColon() {
91 | size_t n = 0;
92 | n += _sink.print(": ");
93 | return n;
94 | }
95 |
96 | size_t writeComma() {
97 | size_t n = 0;
98 | n += _sink.print(",\r\n");
99 | return n;
100 | }
101 |
102 | size_t writeQuoteOpen() {
103 | _inString = true;
104 | size_t n = 0;
105 | n += indentIfNeeded();
106 | n += _sink.print('"');
107 | return n;
108 | }
109 |
110 | size_t writeNormalChar(char c) {
111 | size_t n = 0;
112 | n += indentIfNeeded();
113 | n += _sink.print(c);
114 | return n;
115 | }
116 |
117 | size_t indentIfNeeded() {
118 | if (!inEmptyBlock()) return 0;
119 |
120 | _sink.indent();
121 | return _sink.print("\r\n");
122 | }
123 |
124 | size_t unindentIfNeeded() {
125 | if (inEmptyBlock()) return 0;
126 |
127 | _sink.unindent();
128 | return _sink.print("\r\n");
129 | }
130 |
131 | char _previousChar;
132 | IndentedPrint& _sink;
133 | bool _inString;
134 | };
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/StaticStringBuilder.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | // A Print implementation that allows to write in a char[]
14 | class StaticStringBuilder {
15 | public:
16 | StaticStringBuilder(char *buf, size_t size) : end(buf + size - 1), p(buf) {
17 | *p = '\0';
18 | }
19 |
20 | size_t print(char c) {
21 | if (p >= end) return 0;
22 | *p++ = c;
23 | *p = '\0';
24 | return 1;
25 | }
26 |
27 | size_t print(const char *s) {
28 | char *begin = p;
29 | while (p < end && *s) *p++ = *s++;
30 | *p = '\0';
31 | return size_t(p - begin);
32 | }
33 |
34 | private:
35 | char *end;
36 | char *p;
37 | };
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 |
12 | #if ARDUINOJSON_ENABLE_STD_STREAM
13 |
14 | #include
15 |
16 | namespace ArduinoJson {
17 | namespace Internals {
18 |
19 | class StreamPrintAdapter {
20 | public:
21 | explicit StreamPrintAdapter(std::ostream& os) : _os(os) {}
22 |
23 | size_t print(char c) {
24 | _os << c;
25 | return 1;
26 | }
27 |
28 | size_t print(const char* s) {
29 | _os << s;
30 | return strlen(s);
31 | }
32 |
33 | private:
34 | // cannot be assigned
35 | StreamPrintAdapter& operator=(const StreamPrintAdapter&);
36 |
37 | std::ostream& _os;
38 | };
39 | }
40 | }
41 |
42 | #endif // ARDUINOJSON_ENABLE_STD_STREAM
43 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StaticJsonBuffer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "JsonBufferBase.hpp"
11 |
12 | #if defined(__clang__)
13 | #pragma clang diagnostic push
14 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
15 | #elif defined(__GNUC__)
16 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
17 | #pragma GCC diagnostic push
18 | #endif
19 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
20 | #endif
21 |
22 | namespace ArduinoJson {
23 |
24 | class StaticJsonBufferBase : public JsonBufferBase {
25 | public:
26 | class String {
27 | public:
28 | String(StaticJsonBufferBase* parent) : _parent(parent) {
29 | _start = parent->_buffer + parent->_size;
30 | }
31 |
32 | void append(char c) {
33 | if (_parent->canAlloc(1)) {
34 | char* last = static_cast(_parent->doAlloc(1));
35 | *last = c;
36 | }
37 | }
38 |
39 | const char* c_str() const {
40 | if (_parent->canAlloc(1)) {
41 | char* last = static_cast(_parent->doAlloc(1));
42 | *last = '\0';
43 | return _start;
44 | } else {
45 | return NULL;
46 | }
47 | }
48 |
49 | private:
50 | StaticJsonBufferBase* _parent;
51 | char* _start;
52 | };
53 |
54 | StaticJsonBufferBase(char* buffer, size_t capa)
55 | : _buffer(buffer), _capacity(capa), _size(0) {}
56 |
57 | size_t capacity() const {
58 | return _capacity;
59 | }
60 | size_t size() const {
61 | return _size;
62 | }
63 |
64 | virtual void* alloc(size_t bytes) {
65 | alignNextAlloc();
66 | if (!canAlloc(bytes)) return NULL;
67 | return doAlloc(bytes);
68 | }
69 |
70 | String startString() {
71 | return String(this);
72 | }
73 |
74 | private:
75 | void alignNextAlloc() {
76 | _size = round_size_up(_size);
77 | }
78 |
79 | bool canAlloc(size_t bytes) const {
80 | return _size + bytes <= _capacity;
81 | }
82 |
83 | void* doAlloc(size_t bytes) {
84 | void* p = &_buffer[_size];
85 | _size += bytes;
86 | return p;
87 | }
88 |
89 | char* _buffer;
90 | size_t _capacity;
91 | size_t _size;
92 | };
93 |
94 | // Implements a JsonBuffer with fixed memory allocation.
95 | // The template paramenter CAPACITY specifies the capacity of the buffer in
96 | // bytes.
97 | template
98 | class StaticJsonBuffer : public StaticJsonBufferBase {
99 | public:
100 | explicit StaticJsonBuffer() : StaticJsonBufferBase(_buffer, CAPACITY) {}
101 |
102 | private:
103 | char _buffer[CAPACITY];
104 | };
105 | }
106 |
107 | #if defined(__clang__)
108 | #pragma clang diagnostic pop
109 | #elif defined(__GNUC__)
110 | #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
111 | #pragma GCC diagnostic pop
112 | #endif
113 | #endif
114 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/ArduinoStream.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #if ARDUINOJSON_ENABLE_ARDUINO_STREAM
11 |
12 | #include
13 |
14 | namespace ArduinoJson {
15 | namespace Internals {
16 |
17 | struct ArduinoStreamTraits {
18 | class Reader {
19 | Stream& _stream;
20 | char _current, _next;
21 |
22 | public:
23 | Reader(Stream& stream) : _stream(stream), _current(0), _next(0) {}
24 |
25 | void move() {
26 | _current = _next;
27 | _next = 0;
28 | }
29 |
30 | char current() {
31 | if (!_current) _current = read();
32 | return _current;
33 | }
34 |
35 | char next() {
36 | // assumes that current() has been called
37 | if (!_next) _next = read();
38 | return _next;
39 | }
40 |
41 | private:
42 | char read() {
43 | // don't use _stream.read() as it ignores the timeout
44 | char c = 0;
45 | _stream.readBytes(&c, 1);
46 | return c;
47 | }
48 | };
49 | };
50 |
51 | template
52 | struct StringTraits::type>::value>::type>
57 | : ArduinoStreamTraits {};
58 | }
59 | }
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/CharPointer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace Internals {
12 |
13 | template
14 | struct CharPointerTraits {
15 | class Reader {
16 | const TChar* _ptr;
17 |
18 | public:
19 | Reader(const TChar* ptr)
20 | : _ptr(ptr ? ptr : reinterpret_cast("")) {}
21 |
22 | void move() {
23 | ++_ptr;
24 | }
25 |
26 | char current() const {
27 | return char(_ptr[0]);
28 | }
29 |
30 | char next() const {
31 | return char(_ptr[1]);
32 | }
33 | };
34 |
35 | static bool equals(const TChar* str, const char* expected) {
36 | return strcmp(reinterpret_cast(str), expected) == 0;
37 | }
38 |
39 | template
40 | static char* duplicate(const TChar* str, Buffer* buffer) {
41 | if (!str) return NULL;
42 | size_t size = strlen(reinterpret_cast(str)) + 1;
43 | void* dup = buffer->alloc(size);
44 | if (dup != NULL) memcpy(dup, str, size);
45 | return static_cast(dup);
46 | }
47 |
48 | static const bool has_append = false;
49 | static const bool has_equals = true;
50 | static const bool should_duplicate = false;
51 | };
52 |
53 | template
54 | struct StringTraits::value>::type>
56 | : CharPointerTraits {};
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/FlashString.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #if ARDUINOJSON_ENABLE_PROGMEM
11 |
12 | namespace ArduinoJson {
13 | namespace Internals {
14 | template <>
15 | struct StringTraits {
16 | class Reader {
17 | const char* _ptr;
18 |
19 | public:
20 | Reader(const __FlashStringHelper* ptr)
21 | : _ptr(reinterpret_cast(ptr)) {}
22 |
23 | void move() {
24 | _ptr++;
25 | }
26 |
27 | char current() const {
28 | return pgm_read_byte_near(_ptr);
29 | }
30 |
31 | char next() const {
32 | return pgm_read_byte_near(_ptr + 1);
33 | }
34 | };
35 |
36 | static bool equals(const __FlashStringHelper* str, const char* expected) {
37 | return strcmp_P(expected, (PGM_P)str) == 0;
38 | }
39 |
40 | template
41 | static char* duplicate(const __FlashStringHelper* str, Buffer* buffer) {
42 | if (!str) return NULL;
43 | size_t size = strlen_P((PGM_P)str) + 1;
44 | void* dup = buffer->alloc(size);
45 | if (dup != NULL) memcpy_P(dup, (PGM_P)str, size);
46 | return static_cast(dup);
47 | }
48 |
49 | static const bool has_append = false;
50 | static const bool has_equals = true;
51 | static const bool should_duplicate = true;
52 | };
53 | }
54 | }
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/StdStream.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #if ARDUINOJSON_ENABLE_STD_STREAM
11 |
12 | #include
13 |
14 | namespace ArduinoJson {
15 | namespace Internals {
16 |
17 | struct StdStreamTraits {
18 | class Reader {
19 | std::istream& _stream;
20 | char _current, _next;
21 |
22 | public:
23 | Reader(std::istream& stream) : _stream(stream), _current(0), _next(0) {}
24 |
25 | void move() {
26 | _current = _next;
27 | _next = 0;
28 | }
29 |
30 | char current() {
31 | if (!_current) _current = read();
32 | return _current;
33 | }
34 |
35 | char next() {
36 | // assumes that current() has been called
37 | if (!_next) _next = read();
38 | return _next;
39 | }
40 |
41 | private:
42 | Reader& operator=(const Reader&); // Visual Studio C4512
43 |
44 | char read() {
45 | return _stream.eof() ? '\0' : static_cast(_stream.get());
46 | }
47 | };
48 | };
49 |
50 | template
51 | struct StringTraits::type>::value>::type>
56 | : StdStreamTraits {};
57 | }
58 | }
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/StdString.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #if ARDUINOJSON_ENABLE_STD_STRING || ARDUINOJSON_ENABLE_ARDUINO_STRING
11 |
12 | #if ARDUINOJSON_ENABLE_ARDUINO_STRING
13 | #include
14 | #endif
15 |
16 | #if ARDUINOJSON_ENABLE_STD_STRING
17 | #include
18 | #endif
19 |
20 | namespace ArduinoJson {
21 | namespace Internals {
22 |
23 | template
24 | struct StdStringTraits {
25 | template
26 | static char* duplicate(const TString& str, Buffer* buffer) {
27 | if (!str.c_str()) return NULL; // <- Arduino string can return NULL
28 | size_t size = str.length() + 1;
29 | void* dup = buffer->alloc(size);
30 | if (dup != NULL) memcpy(dup, str.c_str(), size);
31 | return static_cast(dup);
32 | }
33 |
34 | struct Reader : CharPointerTraits::Reader {
35 | Reader(const TString& str) : CharPointerTraits::Reader(str.c_str()) {}
36 | };
37 |
38 | static bool equals(const TString& str, const char* expected) {
39 | return 0 == strcmp(str.c_str(), expected);
40 | }
41 |
42 | static void append(TString& str, char c) {
43 | str += c;
44 | }
45 |
46 | static void append(TString& str, const char* s) {
47 | str += s;
48 | }
49 |
50 | static const bool has_append = true;
51 | static const bool has_equals = true;
52 | static const bool should_duplicate = true;
53 | };
54 |
55 | #if ARDUINOJSON_ENABLE_ARDUINO_STRING
56 | template <>
57 | struct StringTraits : StdStringTraits {};
58 | template <>
59 | struct StringTraits : StdStringTraits {
60 | };
61 | #endif
62 |
63 | #if ARDUINOJSON_ENABLE_STD_STRING
64 | template <>
65 | struct StringTraits : StdStringTraits {};
66 | #endif
67 | }
68 | }
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/src/ArduinoJson/StringTraits/StringTraits.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include
11 | #include "../Configuration.hpp"
12 | #include "../TypeTraits/EnableIf.hpp"
13 | #include "../TypeTraits/IsBaseOf.hpp"
14 | #include "../TypeTraits/IsChar.hpp"
15 | #include "../TypeTraits/RemoveReference.hpp"
16 |
17 | namespace ArduinoJson {
18 | namespace Internals {
19 |
20 | template
21 | struct StringTraits {};
22 |
23 | template
24 | struct StringTraits : StringTraits {};
25 |
26 | template
27 | struct StringTraits : StringTraits {};
28 | }
29 | }
30 |
31 | #include "ArduinoStream.hpp"
32 | #include "CharPointer.hpp"
33 | #include "FlashString.hpp"
34 | #include "StdStream.hpp"
35 | #include "StdString.hpp"
36 |
37 | namespace ArduinoJson {
38 | namespace TypeTraits {
39 | template
40 | struct IsString {
41 | static const bool value = false;
42 | };
43 |
44 | template
45 | struct IsString::has_equals>::type> {
47 | static const bool value = Internals::StringTraits::has_equals;
48 | };
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/EnableIf.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that return the type T if Condition is true.
14 | template
15 | struct EnableIf {};
16 |
17 | template
18 | struct EnableIf {
19 | typedef T type;
20 | };
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/FloatTraits.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include
11 | #include // for size_t
12 | #include "../Configuration.hpp"
13 | #include "../Polyfills/math.hpp"
14 |
15 | namespace ArduinoJson {
16 | namespace TypeTraits {
17 |
18 | template
19 | struct FloatTraits {};
20 |
21 | #if ARDUINOJSON_DOUBLE_IS_64BITS
22 | template
23 | struct FloatTraits {
24 | typedef int64_t mantissa_type;
25 | static const short mantissa_bits = 52;
26 | static const mantissa_type mantissa_max =
27 | (static_cast(1) << mantissa_bits) - 1;
28 |
29 | typedef int16_t exponent_type;
30 | static const exponent_type exponent_max = 308;
31 |
32 | template
33 | static T make_float(T m, TExponent e) {
34 | if (e >= 0)
35 | return m * (e & 1 ? 1e1 : 1) * (e & 2 ? 1e2 : 1) * (e & 4 ? 1e4 : 1) *
36 | (e & 8 ? 1e8 : 1) * (e & 16 ? 1e16 : 1) * (e & 32 ? 1e32 : 1) *
37 | (e & 64 ? 1e64 : 1) * (e & 128 ? 1e128 : 1) *
38 | (e & 256 ? 1e256 : 1);
39 | e = TExponent(-e);
40 | return m * (e & 1 ? 1e-1 : 1) * (e & 2 ? 1e-2 : 1) * (e & 4 ? 1e-4 : 1) *
41 | (e & 8 ? 1e-8 : 1) * (e & 16 ? 1e-16 : 1) * (e & 32 ? 1e-32 : 1) *
42 | (e & 64 ? 1e-64 : 1) * (e & 128 ? 1e-128 : 1) *
43 | (e & 256 ? 1e-256 : 1);
44 | }
45 |
46 | static T nan() {
47 | uint64_t x = uint64_t(0x7ff8) << 48;
48 | return *reinterpret_cast(&x);
49 | }
50 |
51 | static T inf() {
52 | uint64_t x = uint64_t(0x7ff0) << 48;
53 | return *reinterpret_cast(&x);
54 | }
55 | };
56 | #endif
57 |
58 | template
59 | struct FloatTraits {
60 | typedef int32_t mantissa_type;
61 | static const short mantissa_bits = 23;
62 | static const mantissa_type mantissa_max =
63 | (static_cast(1) << mantissa_bits) - 1;
64 |
65 | typedef int8_t exponent_type;
66 | static const exponent_type exponent_max = 38;
67 |
68 | template
69 | static T make_float(T m, TExponent e) {
70 | if (e > 0)
71 | return m * (e & 1 ? 1e1f : 1) * (e & 2 ? 1e2f : 1) * (e & 4 ? 1e4f : 1) *
72 | (e & 8 ? 1e8f : 1) * (e & 16 ? 1e16f : 1) * (e & 32 ? 1e32f : 1);
73 | e = -e;
74 | return m * (e & 1 ? 1e-1f : 1) * (e & 2 ? 1e-2f : 1) * (e & 4 ? 1e-4f : 1) *
75 | (e & 8 ? 1e-8f : 1) * (e & 16 ? 1e-16f : 1) * (e & 32 ? 1e-32f : 1);
76 | }
77 |
78 | static T nan() {
79 | uint32_t x = 0x7fc00000;
80 | return *reinterpret_cast(&x);
81 | }
82 |
83 | static T inf() {
84 | uint32_t x = 0x7f800000;
85 | return *reinterpret_cast(&x);
86 | }
87 | };
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsArray.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that return the type T without the const modifier
14 | template
15 | struct IsArray {
16 | static const bool value = false;
17 | };
18 | template
19 | struct IsArray {
20 | static const bool value = true;
21 | };
22 | template
23 | struct IsArray {
24 | static const bool value = true;
25 | };
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsBaseOf.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that returns true if Derived inherits from TBase is an
14 | // integral type.
15 | template
16 | class IsBaseOf {
17 | protected: // <- to avoid GCC's "all member functions in class are private"
18 | typedef char Yes[1];
19 | typedef char No[2];
20 |
21 | static Yes &probe(const TBase *);
22 | static No &probe(...);
23 |
24 | public:
25 | enum {
26 | value = sizeof(probe(reinterpret_cast(0))) == sizeof(Yes)
27 | };
28 | };
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsChar.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "IsSame.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace TypeTraits {
14 |
15 | // A meta-function that returns true if T is a charater
16 | template
17 | struct IsChar {
18 | static const bool value = IsSame::value ||
19 | IsSame::value ||
20 | IsSame::value;
21 | };
22 |
23 | template
24 | struct IsChar : IsChar {};
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsConst.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that return the type T without the const modifier
14 | template
15 | struct IsConst {
16 | static const bool value = false;
17 | };
18 |
19 | template
20 | struct IsConst {
21 | static const bool value = true;
22 | };
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "IsSame.hpp"
11 |
12 | namespace ArduinoJson {
13 | namespace TypeTraits {
14 |
15 | // A meta-function that returns true if T is a floating point type
16 | template
17 | struct IsFloatingPoint {
18 | static const bool value = IsSame::value || IsSame::value;
19 | };
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsIntegral.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "IsSame.hpp"
11 | #include "IsSignedIntegral.hpp"
12 | #include "IsUnsignedIntegral.hpp"
13 |
14 | namespace ArduinoJson {
15 | namespace TypeTraits {
16 |
17 | // A meta-function that returns true if T is an integral type.
18 | template
19 | struct IsIntegral {
20 | static const bool value = TypeTraits::IsSignedIntegral::value ||
21 | TypeTraits::IsUnsignedIntegral::value ||
22 | TypeTraits::IsSame::value;
23 | // CAUTION: differs from std::is_integral as it doesn't include bool
24 | };
25 |
26 | template
27 | struct IsIntegral : IsIntegral {};
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsSame.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that returns true if types T and U are the same.
14 | template
15 | struct IsSame {
16 | static const bool value = false;
17 | };
18 |
19 | template
20 | struct IsSame {
21 | static const bool value = true;
22 | };
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 | #include "IsSame.hpp"
12 |
13 | namespace ArduinoJson {
14 | namespace TypeTraits {
15 |
16 | // A meta-function that returns true if T is an integral type.
17 | template
18 | struct IsSignedIntegral {
19 | static const bool value = TypeTraits::IsSame::value ||
20 | TypeTraits::IsSame::value ||
21 | TypeTraits::IsSame::value ||
22 | TypeTraits::IsSame::value ||
23 | #if ARDUINOJSON_USE_LONG_LONG
24 | TypeTraits::IsSame::value ||
25 | #endif
26 |
27 | #if ARDUINOJSON_USE_INT64
28 | TypeTraits::IsSame::value ||
29 | #endif
30 | false;
31 | };
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | #include "../Configuration.hpp"
11 | #include "IsSame.hpp"
12 |
13 | namespace ArduinoJson {
14 | namespace TypeTraits {
15 |
16 | // A meta-function that returns true if T is an integral type.
17 | template
18 | struct IsUnsignedIntegral {
19 | static const bool value = TypeTraits::IsSame::value ||
20 | TypeTraits::IsSame::value ||
21 | TypeTraits::IsSame::value ||
22 | TypeTraits::IsSame::value ||
23 | #if ARDUINOJSON_USE_LONG_LONG
24 | TypeTraits::IsSame::value ||
25 | #endif
26 |
27 | #if ARDUINOJSON_USE_INT64
28 | TypeTraits::IsSame::value ||
29 | #endif
30 | false;
31 | };
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/RemoveConst.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that return the type T without the const modifier
14 | template
15 | struct RemoveConst {
16 | typedef T type;
17 | };
18 | template
19 | struct RemoveConst {
20 | typedef T type;
21 | };
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/ArduinoJson/TypeTraits/RemoveReference.hpp:
--------------------------------------------------------------------------------
1 | // Copyright Benoit Blanchon 2014-2017
2 | // MIT License
3 | //
4 | // Arduino JSON library
5 | // https://bblanchon.github.io/ArduinoJson/
6 | // If you like this project, please add a star!
7 |
8 | #pragma once
9 |
10 | namespace ArduinoJson {
11 | namespace TypeTraits {
12 |
13 | // A meta-function that return the type T without the reference modifier.
14 | template
15 | struct RemoveReference {
16 | typedef T type;
17 | };
18 | template