text,length,is_long_context,metric_val,label_metric "############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 .globl _cpMontSqr1024_avx2 _cpMontSqr1024_avx2: push %rbx push %rbp push %r12 push %r13 push %r14 sub $(64), %rsp movslq %ecx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rcx,8) vmovdqu %ymm11, (%rdx,%rcx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) movq %rcx, (24)(%rsp) movq %r8, (32)(%rsp) mov $(40), %rcx mov %r9, %rdi movq %rdi, (48)(%rsp) lea (%rdi,%rcx,8), %rbx lea (%rbx,%rcx,8), %r9 movq %r9, (40)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_1 .p2align 5, 0x90 .Lsqr1024_loop4gas_1: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_1: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_1 movq (48)(%rsp), %rdi movq (16)(%rsp), %rcx movq (32)(%rsp), %r8 mov $(38), %r9 movq (%rdi), %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rdi), %ymm1 vmovdqu (64)(%rdi), %ymm2 vmovdqu (96)(%rdi), %ymm3 vmovdqu (128)(%rdi), %ymm4 vmovdqu (160)(%rdi), %ymm5 vmovdqu (192)(%rdi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rdi), %ymm7 vmovdqu (256)(%rdi), %ymm8 vmovdqu (288)(%rdi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 5, 0x90 .Lreduction_loopgas_1: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_1 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rdi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rdi), %ymm14, %ymm9 add $(32), %rdi sub $(2), %r9 jnz .Lreduction_loopgas_1 .Lexit_reduction_loopgas_1: movq (%rsp), %rdi movq %r12, (%rdi) movq %r13, (8)(%rdi) vmovdqu %ymm1, (16)(%rdi) vmovdqu %ymm2, (48)(%rdi) vmovdqu %ymm3, (80)(%rdi) vmovdqu %ymm4, (112)(%rdi) vmovdqu %ymm5, (144)(%rdi) vmovdqu %ymm6, (176)(%rdi) vmovdqu %ymm7, (208)(%rdi) vmovdqu %ymm8, (240)(%rdi) vmovdqu %ymm9, (272)(%rdi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_1: addq (%rdi), %rax add $(8), %rdi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (-8)(%rdi) sub $(1), %r9 jg .Lnorm_loopgas_1 movq %rax, (%rdi) add $(64), %rsp vzeroupper pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .p2align 5, 0x90 .globl _cpSqr1024_avx2 _cpSqr1024_avx2: push %rbx sub $(48), %rsp movslq %edx, %rdx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rdx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) mov $(40), %rdx mov %rcx, %rdi movq %rdi, (32)(%rsp) lea (%rdi,%rdx,8), %rbx lea (%rbx,%rdx,8), %r9 movq %r9, (24)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_2 .p2align 5, 0x90 .Lsqr1024_loop4gas_2: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_2: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_2 movq (32)(%rsp), %rsi movq (%rsp), %rdi mov $(76), %r9 xor %rax, %rax .Lnorm_loopgas_2: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_2 movq %rax, (%rdi) add $(48), %rsp vzeroupper pop %rbx ret .p2align 5, 0x90 .globl _cpMontRed1024_avx2 _cpMontRed1024_avx2: push %r12 push %r13 movslq %ecx, %r9 mov %rdx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rdx,%r9,8) movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 5, 0x90 .Lreduction_loopgas_3: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_3 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rsi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rsi), %ymm14, %ymm9 add $(32), %rsi sub $(2), %r9 jnz .Lreduction_loopgas_3 .Lexit_reduction_loopgas_3: movq (%rsp), %rsi movq %r12, (%rsi) movq %r13, (8)(%rsi) vmovdqu %ymm1, (16)(%rsi) vmovdqu %ymm2, (48)(%rsi) vmovdqu %ymm3, (80)(%rsi) vmovdqu %ymm4, (112)(%rsi) vmovdqu %ymm5, (144)(%rsi) vmovdqu %ymm6, (176)(%rsi) vmovdqu %ymm7, (208)(%rsi) vmovdqu %ymm8, (240)(%rsi) vmovdqu %ymm9, (272)(%rsi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_3: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_3 movq %rax, (%rdi) vzeroupper pop %r13 pop %r12 ret ",16355,True,4232.121874395184,median "CLASS zcl_abapgit_gui_page_sett_info DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_component FINAL CREATE PRIVATE . PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler . INTERFACES zif_abapgit_gui_renderable . CLASS-METHODS create IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS constructor IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RAISING zcx_abapgit_exception . PROTECTED SECTION. PRIVATE SECTION. TYPES: BEGIN OF ty_stats, measure TYPE string, local TYPE i, remote TYPE i, END OF ty_stats . TYPES: BEGIN OF ty_infos, size TYPE p LENGTH 16 DECIMALS 0, line TYPE p LENGTH 16 DECIMALS 0, sloc TYPE p LENGTH 16 DECIMALS 0, END OF ty_infos . CONSTANTS: BEGIN OF c_id, info TYPE string VALUE 'info', created_by TYPE string VALUE 'created_by', created_at TYPE string VALUE 'created_at', deserialized_by TYPE string VALUE 'deserialized_by', deserialized_at TYPE string VALUE 'deserialized_at', stats TYPE string VALUE 'stats', stats_table TYPE string VALUE 'stats_table', END OF c_id . CONSTANTS: BEGIN OF c_event, go_back TYPE string VALUE 'go-back', save TYPE string VALUE 'save', END OF c_event . DATA mo_form TYPE REF TO zcl_abapgit_html_form . DATA mo_form_data TYPE REF TO zcl_abapgit_string_map . DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA: mt_stats TYPE STANDARD TABLE OF ty_stats WITH KEY measure . METHODS get_form_schema RETURNING VALUE(ro_form) TYPE REF TO zcl_abapgit_html_form RAISING zcx_abapgit_exception . METHODS read_settings RAISING zcx_abapgit_exception . METHODS read_stats RAISING zcx_abapgit_exception . METHODS read_stats_files EXPORTING !et_local TYPE zif_abapgit_definitions=>ty_files_item_tt !et_remote TYPE zif_abapgit_definitions=>ty_files_tt RAISING zcx_abapgit_exception . METHODS read_stats_state RAISING zcx_abapgit_exception . METHODS read_stats_size_lines_sloc IMPORTING !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !it_remote TYPE zif_abapgit_definitions=>ty_files_tt EXPORTING !et_local_items TYPE zif_abapgit_definitions=>ty_items_tt !et_remote_items TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . METHODS read_stats_file IMPORTING !is_file TYPE zif_abapgit_definitions=>ty_file RETURNING VALUE(rs_info) TYPE ty_infos . METHODS read_stats_objects CHANGING !ct_local_items TYPE zif_abapgit_definitions=>ty_items_tt !ct_remote_items TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . METHODS format_user IMPORTING !iv_username TYPE xubname RETURNING VALUE(rv_user) TYPE string . METHODS format_timestamp IMPORTING !iv_timestamp TYPE timestampl RETURNING VALUE(rv_timestamp) TYPE string . METHODS format_size IMPORTING !iv_size TYPE i RETURNING VALUE(rv_size) TYPE string . ENDCLASS. CLASS zcl_abapgit_gui_page_sett_info IMPLEMENTATION. METHOD constructor. super->constructor( ). CREATE OBJECT mo_form_data. mo_repo = io_repo. mo_form = get_form_schema( ). ENDMETHOD. METHOD create. DATA lo_component TYPE REF TO zcl_abapgit_gui_page_sett_info. CREATE OBJECT lo_component EXPORTING io_repo = io_repo. ri_page = zcl_abapgit_gui_page_hoc=>create( iv_page_title = 'Repository Stats' io_page_menu = zcl_abapgit_gui_chunk_lib=>settings_repo_toolbar( iv_key = io_repo->get_key( ) iv_act = zif_abapgit_definitions=>c_action-repo_infos ) ii_child_component = lo_component ). ENDMETHOD. METHOD format_size. DATA: lv_size TYPE p LENGTH 16 DECIMALS 2. IF iv_size > 1024 * 1024 * 1024. lv_size = iv_size / 1024 / 1024 / 1024. rv_size = |{ lv_size } GB|. ELSEIF iv_size > 1024 * 1024. lv_size = iv_size / 1024 / 1024. rv_size = |{ lv_size } MB|. ELSEIF iv_size > 1024. lv_size = iv_size / 1024. rv_size = |{ lv_size } KB|. ELSE. rv_size = |{ iv_size } Bytes|. ENDIF. ENDMETHOD. METHOD format_timestamp. IF iv_timestamp IS INITIAL. rv_timestamp = 'n/a'. RETURN. ENDIF. CALL FUNCTION 'CONVERSION_EXIT_TIMES_OUTPUT' EXPORTING input = iv_timestamp IMPORTING output = rv_timestamp. ENDMETHOD. METHOD format_user. DATA: ls_user_address TYPE addr3_val, lv_title TYPE string. IF iv_username IS INITIAL. rv_user = 'n/a'. RETURN. ENDIF. IF iv_username <> zcl_abapgit_objects_super=>c_user_unknown. CALL FUNCTION 'SUSR_USER_ADDRESS_READ' EXPORTING user_name = iv_username IMPORTING user_address = ls_user_address EXCEPTIONS user_address_not_found = 1 OTHERS = 2. IF sy-subrc = 0. lv_title = ls_user_address-name_text. ENDIF. ENDIF. rv_user = iv_username. IF lv_title IS NOT INITIAL. rv_user = |{ rv_user } ({ lv_title })|. ENDIF. ENDMETHOD. METHOD get_form_schema. DATA lv_label TYPE string. ro_form = zcl_abapgit_html_form=>create( iv_form_id = 'repo-infos-form' iv_help_page = 'https://docs.abapgit.org/guide-repo-infos.html' ). IF mo_repo->is_offline( ) = abap_true. lv_label = 'ZIP File'. ELSE. lv_label = 'Remote'. ENDIF. ro_form->start_group( iv_name = c_id-info iv_label = 'Stats' )->text( iv_name = c_id-created_by iv_label = 'Created By' iv_readonly = abap_true )->text( iv_name = c_id-created_at iv_label = 'Created At' iv_readonly = abap_true )->text( iv_name = c_id-deserialized_by iv_label = 'Last Deserialized By' iv_readonly = abap_true )->text( iv_name = c_id-deserialized_at iv_label = 'Last Deserialized At' iv_readonly = abap_true )->table( iv_name = c_id-stats_table iv_label = 'Statistics' )->column( iv_label = 'Measure' iv_width = '50%' iv_readonly = abap_true )->column( iv_label = 'Local' iv_width = '25%' iv_readonly = abap_true )->column( iv_label = lv_label iv_width = '25%' iv_readonly = abap_true )->command( iv_label = 'Back' iv_action = c_event-go_back ). ENDMETHOD. METHOD read_settings. DATA: ls_repo TYPE zif_abapgit_persistence=>ty_repo, ls_stats TYPE ty_stats, lv_row TYPE i, lv_int TYPE i, lv_val TYPE string. "" Get infos from DB TRY. ls_repo = zcl_abapgit_persist_factory=>get_repo( )->read( mo_repo->get_key( ) ). CATCH zcx_abapgit_not_found. zcx_abapgit_exception=>raise( |Repo not found, key { mo_repo->get_key( ) }| ). ENDTRY. read_stats( ). "" Infos mo_form_data->set( iv_key = c_id-created_by iv_val = format_user( ls_repo-created_by ) ). mo_form_data->set( iv_key = c_id-created_at iv_val = format_timestamp( ls_repo-created_at ) ). mo_form_data->set( iv_key = c_id-deserialized_by iv_val = format_user( ls_repo-deserialized_by ) ). mo_form_data->set( iv_key = c_id-deserialized_at iv_val = format_timestamp( ls_repo-deserialized_at ) ). LOOP AT mt_stats INTO ls_stats. lv_row = sy-tabix. DO 3 TIMES. CASE sy-index. WHEN 1. lv_val = ls_stats-measure. WHEN 2. lv_val = ls_stats-local. WHEN 3. lv_val = ls_stats-remote. ENDCASE. IF ls_stats-measure CS 'Size' AND sy-index BETWEEN 2 AND 3. lv_int = lv_val. lv_val = format_size( lv_int ). ENDIF. mo_form_data->set( iv_key = |{ c_id-stats_table }-{ lv_row }-{ sy-index }| iv_val = lv_val ). ENDDO. ENDLOOP. mo_form_data->set( iv_key = |{ c_id-stats_table }-{ zif_abapgit_html_form=>c_rows }| iv_val = |{ lv_row }| ). ENDMETHOD. METHOD read_stats. DATA: lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_remote TYPE zif_abapgit_definitions=>ty_files_tt, lt_local_items TYPE zif_abapgit_definitions=>ty_items_tt, lt_remote_items TYPE zif_abapgit_definitions=>ty_items_tt. CLEAR mt_stats. read_stats_files( IMPORTING et_local = lt_local et_remote = lt_remote ). read_stats_state( ). read_stats_size_lines_sloc( EXPORTING it_local = lt_local it_remote = lt_remote IMPORTING et_local_items = lt_local_items et_remote_items = lt_remote_items ). read_stats_objects( CHANGING ct_local_items = lt_local_items ct_remote_items = lt_remote_items ). ENDMETHOD. METHOD read_stats_file. DATA: lv_code TYPE string, lt_code TYPE abaptxt255_tab. FIELD-SYMBOLS: LIKE LINE OF lt_code. rs_info-size = xstrlen( is_file-data ). IF is_file-filename CP '*.abap'. lv_code = zcl_abapgit_convert=>xstring_to_string_utf8( is_file-data ). SPLIT lv_code AT zif_abapgit_definitions=>c_newline INTO TABLE lt_code. rs_info-line = lines( lt_code ). LOOP AT lt_code ASSIGNING WHERE table_line IS NOT INITIAL AND table_line(1) <> '*'. SHIFT -line LEFT DELETING LEADING space. IF -line(1) <> '""'. rs_info-sloc = rs_info-sloc + 1. ENDIF. ENDLOOP. ENDIF. ENDMETHOD. METHOD read_stats_files. DATA ls_stats TYPE ty_stats. et_local = mo_repo->get_files_local( ). ls_stats-measure = 'Number of Files'. ls_stats-local = lines( et_local ). IF mo_repo->has_remote_source( ) = abap_true. et_remote = mo_repo->get_files_remote( ). ls_stats-remote = lines( et_remote ). ENDIF. APPEND ls_stats TO mt_stats. IF et_remote IS NOT INITIAL. ls_stats-measure = 'Number of Ignored Files'. ls_stats-local = ls_stats-remote - ls_stats-local. IF ls_stats-local < 0. ls_stats-local = 0. ENDIF. ls_stats-remote = 0. APPEND ls_stats TO mt_stats. ENDIF. ENDMETHOD. METHOD read_stats_objects. DATA: ls_stats TYPE ty_stats, ls_item TYPE zif_abapgit_definitions=>ty_item, lt_supported_types TYPE zcl_abapgit_objects=>ty_types_tt. ls_stats-measure = 'Number of Objects'. DELETE ct_local_items WHERE obj_type IS INITIAL OR obj_name IS INITIAL. ls_stats-local = lines( ct_local_items ). DELETE ct_remote_items WHERE obj_type IS INITIAL OR obj_name IS INITIAL. ls_stats-remote = lines( ct_remote_items ). APPEND ls_stats TO mt_stats. CLEAR ls_stats. ls_stats-measure = 'Number of Unsupported Objects'. ls_stats-local = lines( mo_repo->get_unsupported_objects_local( ) ). lt_supported_types = zcl_abapgit_objects=>supported_list( ). LOOP AT ct_remote_items INTO ls_item. READ TABLE lt_supported_types WITH KEY table_line = ls_item-obj_type TRANSPORTING NO FIELDS. IF sy-subrc <> 0. ls_stats-remote = ls_stats-remote + 1. ENDIF. ENDLOOP. APPEND ls_stats TO mt_stats. ENDMETHOD. METHOD read_stats_size_lines_sloc. DATA: ls_stats TYPE ty_stats, lv_ignored TYPE abap_bool, ls_info_file TYPE ty_infos, ls_info_local TYPE ty_infos, ls_info_remote TYPE ty_infos, ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS: LIKE LINE OF it_local, LIKE LINE OF it_remote. LOOP AT it_local ASSIGNING . ls_info_file = read_stats_file( -file ). ls_info_local-size = ls_info_local-size + ls_info_file-size. ls_info_local-line = ls_info_local-line + ls_info_file-line. ls_info_local-sloc = ls_info_local-sloc + ls_info_file-sloc. COLLECT -item INTO et_local_items. ENDLOOP. IF mo_repo->has_remote_source( ) = abap_true. LOOP AT it_remote ASSIGNING . ls_info_file = read_stats_file( ). ls_info_remote-size = ls_info_remote-size + ls_info_file-size. ls_info_remote-line = ls_info_remote-line + ls_info_file-line. ls_info_remote-sloc = ls_info_remote-sloc + ls_info_file-sloc. lv_ignored = mo_repo->get_dot_abapgit( )->is_ignored( iv_filename = -filename iv_path = -path ). IF -filename IS NOT INITIAL AND lv_ignored = abap_false. TRY. zcl_abapgit_filename_logic=>file_to_object( EXPORTING iv_filename = -filename iv_path = -path iv_devclass = mo_repo->get_package( ) io_dot = mo_repo->get_dot_abapgit( ) IMPORTING es_item = ls_item ). COLLECT ls_item INTO et_remote_items. CATCH zcx_abapgit_exception ##NO_HANDLER. ENDTRY. ENDIF. ENDLOOP. ENDIF. ls_stats-measure = 'Size of Files'. ls_stats-local = ls_info_local-size. ls_stats-remote = ls_info_remote-size. APPEND ls_stats TO mt_stats. ls_stats-measure = 'Lines in ABAP Files'. ls_stats-local = ls_info_local-line. ls_stats-remote = ls_info_remote-line. APPEND ls_stats TO mt_stats. ls_stats-measure = 'Lines of Code in ABAP Files'. ls_stats-local = ls_info_local-sloc. ls_stats-remote = ls_info_remote-sloc. APPEND ls_stats TO mt_stats. ENDMETHOD. METHOD read_stats_state. DATA: lt_results TYPE zif_abapgit_definitions=>ty_results_tt, lv_state TYPE c LENGTH 1, ls_stats TYPE ty_stats. FIELD-SYMBOLS: LIKE LINE OF lt_results. lt_results = zcl_abapgit_file_status=>status( mo_repo ). DO 3 TIMES. CLEAR ls_stats. CASE sy-index. WHEN 1. ls_stats-measure = 'Number of Modified Files'. lv_state = zif_abapgit_definitions=>c_state-modified. WHEN 2. ls_stats-measure = 'Number of Added Files'. lv_state = zif_abapgit_definitions=>c_state-added. WHEN 3. ls_stats-measure = 'Number of Deleted Files'. lv_state = zif_abapgit_definitions=>c_state-deleted. ENDCASE. LOOP AT lt_results ASSIGNING . IF -lstate = lv_state. ls_stats-local = ls_stats-local + 1. ENDIF. IF -rstate = lv_state AND mo_repo->has_remote_source( ) = abap_true. ls_stats-remote = ls_stats-remote + 1. ENDIF. ENDLOOP. APPEND ls_stats TO mt_stats. ENDDO. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. IF ii_event->mv_action = c_event-go_back. rs_handled-state = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_renderable~render. gui_services( )->register_event_handler( me ). read_settings( ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( `
` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo iv_show_commit = abap_false iv_interactive_branch = abap_true ) ). ri_html->add( `
` ). ri_html->add( mo_form->render( mo_form_data ) ). ENDMETHOD. ENDCLASS. ",4288,False,887.4106626138883,median "// -*-c++-*- /* A sketch that has the mission of sending people up for a couple of meters and then bringing them down again Uses the MS5611 altimeter/barometer Developed on an Arduino Pro Mini, deployed on a ATtiny84, meanwhile ATtiny167 PCB is the Open-V3a board that fits together with a 3.6V/2400mA lithium battery into a preform tube (15cm) ATtiny Fusebits: Divide clock by 8, Brown-out disabled Arduino board: ATtiny 167 / 1MHz */ /* Version 0.9 - first version out in the wild * Version 1.0 - switched to SoftI2CMaster (faster and less memory consumption) * Version 2.0 - improved power saving * Version 2.1 - simplified, less states, output only when key pressed, * no scpecial descend mode, sleep only after 5 minutes * after inactivity * Version 2.2 - removed bug introduced by using idleDelay - too inaccurate! * Version 2.3 - restricted pressure measuring & blinking - only every 3rd second * Version 2.4 - added ""Laufen"" to the message * Version 2.5 - parameter + message are now in EEPROM - and are initialized by defaults * Version 2.6 - height is now a global var in order to avoid unintialized values * in the loop; we also now have a MAXCHANGE constant that leads to * a longer measurement if the height change over a 3 second period * is too large * -> Version to go into the wild after 5.10.2013 * Version 2.7 - switched SCL and SDA to conform with wiring description * EEPROM parameters are now at the beginning of the EEPROM * after power-up, the summit message is displayed * Version 2.8 - changed internally from meters do decimeters for: * - meters_up -> decimeters_up * - epsilon * - height * - lastheight * The display is still in meters! * Added IMPERIAL as a compile time option which will * enable to display height in FEET instead of METERS * 21.01.2014 * Version 2.9 - changed errcode to char * new error: OUTLIER_ERROR * changed retry limit in measure to 4 * removed the MAXCHANGE clause (when 4 meter change, try again) * reject measurement if the max-min value is higher than 0.6 hPa = 5 meters * we check whether error code is set and then go into error state * introduced compile time SETTINGS * and included timeout there! * Version 3.0 - added __attribute__((used)) to wdt_init * Version 3.1 - added I2C_ERROR when i2c initialization failed * - added RESET: Press key five times when GO is displayed * Version 3.2 (19.4.2019) * - increased SCHOENBERG epsilon by 2 * - allow recovery when OUTLIER error * - ignoring bad measurements (but increasing errcnt!) * - RESET can be activated when key is pressed five times during GO or number. * - added ADDRESS constant to SETTING-specific settings * Version 4.0 * - added ATtiny167 as one of the possibilities, which now allows to power-cycle the MS5611 * - not yet fully integrated! * - resetAlti does no internal recovery, this is now handled externally. * - For ATtiny84, we added some recovery mechanism, when SDA is stuck. I am not sure, if * it helps all the time! * * Version 4.1 (24.5.2020) * - When volt < LOWBATT_ERR then we check again and reset the error bit EEPROM if volt is above limit. * This means, it does not get stuck when we have one wrong measurement, as it seemed to have happened here! */ #define Version ""4.1"" #include #include #include #include #define SCHOENBERG_SETTING 1 #define HOME_SETTING 2 #define DAGSTUHL_SETTING 3 #define SETTING DAGSTUHL_SETTING #if SETTING==HOME_SETTING #define MAXWAKEUP_NOBUMP 60 // if there is no bump, we go to sleep again #define MAXWAKEUP_TOTAL 120 // 2 minutes for wakeup & start climbing #define MINQUIET 180 // 3 minutes no bump means we are back in the box #define DEFAULT_METERS_UP 6 // meters you have to walk up #define DEFAULT_EPSILON 2 // potential error #define DEFAULT_SUMMIT_STR ""OBEN"" // message displayed on summit, max 30 chars #define INTREFVOLTAGE 1120 #define OLD_I2C_WIRING // define if first board (= dragon) is used, depends of course! #define ADDRESS 0xEC // depends, of course! #elif SETTING==DAGSTUHL_SETTING #define MAXWAKEUP_NOBUMP 120 // if there is no bump, we go to sleep again #define MAXWAKEUP_TOTAL 3600 // 60 minutes for wakeup & start climbing #define MINQUIET 540 // 10 minutes no bump means we are back in the box #define DEFAULT_METERS_UP 60 // meters you have to walk up #define DEFAULT_EPSILON 5 // potential error #define DEFAULT_SUMMIT_STR ""CODE 132"" // message displayed on summit, max 30 chars #define ENGLISH // all messages in English #define IMPERIAL // measures in feet #define INTREFVOLTAGE 1112 #define ADDRESS 0xEE // 8-bit I2C address of MS5611 (CSB not connected to Vcc) #elif SETTING==SCHOENBERG_SETTING #define MAXWAKEUP_NOBUMP 120 // if there is no bump, we go to sleep again #define MAXWAKEUP_TOTAL 1800 // 30 minutes for wakeup & start climbing #define MINQUIET 300 // 5 minutes no bump means we are back in the box #define DEFAULT_METERS_UP 32 // meters you have to walk up #define DEFAULT_EPSILON 7 // potential error #define DEFAULT_SUMMIT_STR ""CODE 4213"" // message displayed on summit, max 30 chars #define OLD_I2C_WIRING // define if first board (= dragon) is used! #define INTREFVOLTAGE 1120 #define ADDRESS 0xEC // 8-bit I2C address of MS5611 (CSB connected to Vcc) #else #error ""Undefined setting"" #endif #define MAXSUMSTR 200 // should be less than 512-6 #define MAXOUTLIER 0.6 // max diff between extreme measurements corresponds to 5 meters uint8_t emeters_up[1] EEMEM; uint8_t eepsilon[1] EEMEM; char esummit_str[MAXSUMSTR+1] EEMEM; uint16_t eemagickey2[1] EEMEM; uint8_t eelowvolterr[1] EEMEM; // #define DEB_LCD // #define DEB_TTY // #define DEB_LED // #define DEB_LEDRAM // #define DEB_LEDBATT // #define DEB_LEDHEIGHT // #define DEB_LEDSTABLE #ifdef IMPERIAL #define CONVFAC 3.048 // 3.048 decimeters are one foot #else #define CONVFAC 10.0 // 10 decimeters are one meter #endif #define DISPLAY_ON_MSECS 1000 // msecs on #define DISPLAY_OFF_MSECS 300 // msecs off #define MAXERRCNT 20 // after that many measurement errors we give up #define MAXRETRYCNT 5 // number of retries in reset and param command #define LOWVOLT_WARN 280 // warning that battery is low #define LOWVOLT_ERR 230 // with that we do not startup anymore! /* error codes */ #define NO_ERROR 0 #define RESET_ERROR '1' #define PARAM_ERROR '2' #define CONV_ERROR '3' #define TEMP_ERROR '4' #define PRESS_ERROR '5' #define NOBUMP_ERROR '6' #define HEIGHT_ERROR '7' #define WAKEUP_ERROR '8' #define STATE_ERROR '9' #define OUTLIER_ERROR 'A' #define I2C_ERROR 'C' /* On the PCB (or breadboard) put in the the following electronic components: IC1: Attiny84 with pin 1 away from prototyping area Display1: 7-segment with decimal point facing away from the Attiny C1: 100nF R1: 330 Ohm (if you use extra bright seven segment displays) R2: 3 MOhm R3: 0 Ohm, just a wire R4: 0 Ohm, just a wire R5: 0 Ohm, just a wire R9: 10 kOhm S1: Vibration switch The breakout board with the MS5611 on the prototype area row 2 to 8, pin 1 Now connect: Pin5 of the first row in the prototype area (PA1 = D1) with SDA MS5611 Pin4 of the first row (PA2 = D2) with SCL MS5611 Pin5 of the 8th row (Vcc) with Vcc MS5611 Pin2 of the 8throw (GND) with GND MS5611 Note: On the MS5611 breakout board, you have to connect - the I2C bridge (of SPI/I2C), - the pullup resistor bridge, - and the bottom I2C ADDR bridge - NO! We now use EE instead of EC! On breadboard connect: Attiny84-Pin Attiny84 ATtiny167-Pin ATtiny167 ProMini External PB0 D8(20) Button PA0 D0 PA3 D3(4) D2 Vibration switch PA1 D1 PA0 D0(1) D3 MS5611 SDA PA2 D2 PA1 D1(2) D4 MS5611 SCL PA6 D6(9) MS5611 Vcc MS5611 GND PA3 D3 PB3 D11(17) D5 Disp. Pin1(g) PA4 D4 PB4 D12(14) D6 Disp. Pin2(f) + ISP CLK PA5 D5 PB5 D13(13) D7 Disp. Pin4(e) + ISP MISO PA6 D6 PB6 D14(12) D8 Disp. Pin5(d) + ISP MOSI PA7 D7 PA7 D7(10) D9 Disp. Pin6(DP) PB2 D8 PA5 D5(8) D10 Disp. Pin7(c) PB1 D9 PA4 D4(7) D11 Disp. Pin9(b) PB0 D10 PA2 D2(3) D12 Disp. Pin10(a) PB2 D10(18) D1 Serial TX Disp. Pin8 or 3 to R1 D13 LCD SCLK D14 LCD DIN D15 LCD D/C D16 LCD RST D17 LCD CS LCD Vcc LCD GND */ #if defined(DEB_LCD) //#include //#include //Adafruit_PCD8544 lcd = Adafruit_PCD8544(13,14,15,17,16); #endif // differences between Atmega and Attiny #if defined(__AVR_ATmega328P__) #define SEGAPIN 12 #define SEGBPIN 11 #define SEGCPIN 10 #define SEGDPPIN 9 #define SEGDPIN 8 #define SEGEPIN 7 #define SEGFPIN 6 #define SEGGPIN 5 #define T1_vect TIMER1_OVF_vect #define PCINT_vect PCINT2_vect #define SDA_PORT PORTD #define SDA_PIN 3 #define SCL_PORT PORTD #define SCL_PIN 4 #elif defined(__AVR_ATtiny84__) #define SEGAPIN 10 #define SEGBPIN 9 #define SEGCPIN 8 #define SEGDPPIN 7 #define SEGDPIN 6 #define SEGEPIN 5 #define SEGFPIN 4 #define SEGGPIN 3 #define T1_vect TIM1_OVF_vect #define PCINT_vect PCINT0_vect // I2C pins - now conforms to description above! #define SDA_PORT PORTA #define SCL_PORT PORTA #ifdef OLD_I2C_WIRING // as on the dragon board! #define SDA_PIN 2 #define SCL_PIN 1 #else // as described above and on the new boards #define SDA_PIN 1 #define SCL_PIN 2 #endif #elif defined(__AVR_ATtiny167__) #define SEGAPIN 2 #define SEGBPIN 4 #define SEGCPIN 5 #define SEGDPPIN 7 #define SEGDPIN 14 #define SEGEPIN 13 #define SEGFPIN 12 #define SEGGPIN 11 #define T1_vect TIMER1_OVF_vect #define PCINT_vect PCINT0_vect #define PCINTBUTTON_vect PCINT1_vect #define WDTCSR WDTCR #define SDA_PORT PORTA #define SCL_PORT PORTA #define SDA_PIN 0 #define SCL_PIN 1 #define SDA_ARDUINO_PIN 0 #define SCL_ARDUINO_PIN 1 #define MS_POWER 6 #define BUTTON 8 #include #ifdef DEB_TTY Serial TXOnlySerial(10); #endif #else #error ""Unsupported MCU"" #endif #include #if defined(DEB_TTY) #define DEBTTY_PRINT(str) Serial.print(str) #define DEBTTY_PRINTLN(str) Serial.println(str) #define DEBTTY_INIT() Serial.begin(9600) #else #define DEBTTY_PRINT(str) #define DEBTTY_PRINTLN(str) #define DEBTTY_INIT() #endif #if defined(DEB_LCD) #define DEBLCD_PRINT(str) lcd.print(str) #define DEBLCD_PRINTLN(str) lcd.println(str) #define DEBLCD_HOME() lcd.setCursor(0,0) #define DEBLCD_DISPLAY() lcd.display() #define DEBLCD_CLEAR() lcd.clearDisplay() #define DBLCD_INIT() lcd.begin() #else #define DEBLCD_PRINT(str) #define DEBLCD_PRINTLN(str) #define DEBLCD_HOME() #define DEBLCD_DISPLAY() #define DEBLCD_CLEAR() #define DEBLCD_INIT() #endif // error value for measurements #define ERRORVAL -9999.0 // LCD segment definitions. // These will need to be changed depending on the // wiring of your output port to the segements. #define SEGa (1<"" SEGa+SEGb+SEGg+SEGe, // ""?"" 0, // ""@"" SEGa+SEGb+SEGc+SEGe+SEGf+SEGg, // ""A"" SEGc+SEGd+SEGe+SEGf+SEGg, // ""b"" SEGg+SEGe+SEGd, // ""c"" SEGb+SEGc+SEGd+SEGe+SEGg, // ""d"" SEGa+SEGd+SEGe+SEGf+SEGg, // ""E"" SEGa+SEGe+SEGf+SEGg, // ""F"" SEGa+SEGc+SEGd+SEGe+SEGf, // ""G"" SEGc+SEGe+SEGf+SEGg, // ""h"" SEGf+SEGe, // ""I"" SEGb+SEGc+SEGd+SEGe, // ""J"" SEGa+SEGc+SEGe+SEGf+SEGg, // ""k"" SEGd+SEGe+SEGf, // ""L"" SEGg+SEGc+SEGe, // ""M"" SEGc+SEGe+SEGf+SEGb+SEGa, // ""n"" SEGc+SEGd+SEGe+SEGg, // ""o"" SEGa+SEGb+SEGe+SEGf+SEGg, // ""P"" SEGa+SEGb+SEGd+SEGf+SEGg, // ""q"" SEGe+SEGg, // ""r"" SEGc+SEGf+SEGg, // ""S"" SEGd+SEGe+SEGf+SEGg, // ""t"" SEGb+SEGc+SEGd+SEGe+SEGf, // ""U"" SEGc+SEGd+SEGe, // ""v"" SEGb+SEGd+SEGf, // ""W"" SEGb+SEGc+SEGe+SEGf+SEGg, // ""X"" SEGb+SEGc+SEGd+SEGf+SEGg, // ""Y"" SEGa+SEGb+SEGd+SEGe+SEGg, // ""Z"" }; #define LASTCHAR 'Z' /* messages */ const char reset_str[] PROGMEM = ""RESET""; #ifdef ENGLISH const char lowbatt_str[] PROGMEM = "" BATT LO. ""; const char go_str[] PROGMEM = ""GO""; #ifdef IMPERIAL const char up_str[] PROGMEM =""UP""; const char meter_str[] PROGMEM =""FEET""; #else const char up_str[] PROGMEM =""UP""; const char meter_str[] PROGMEM =""METER""; #endif const char bye_str[] PROGMEM = ""BYE.""; const char error_str[] PROGMEM = "" ERROR""; const char sleep_str[] PROGMEM = ""SP""; #else const char lowbatt_str[] PROGMEM = "" BATT LO. ""; const char go_str[] PROGMEM = """"; const char up_str[] PROGMEM =""HOCH LAUFEN""; const char meter_str[] PROGMEM =""METER""; const char bye_str[] PROGMEM = ""BYE.""; const char error_str[] PROGMEM = "" FEHLER""; const char sleep_str[] PROGMEM = ""SP""; #endif /* states */ #define NO_STATE 0 #define SLEEP_STATE 1 #define WAKEUP_STATE 2 #define CLIMB_STATE 3 #define SUMMIT_STATE 4 #define BATT_LOW_STATE 5 #define ERROR_STATE 6 #define DEEPSLEEP_STATE 7 #define RESET_STATE 8 #define LAST_STATE 8 #if (defined(DEB_TTY) || defined(DEB_LCD)) char statestr[14][12] = { ""UNDEF"", ""SLEEP"", ""WAKEUP"", ""CLIMB"", ""SUMMIT"", ""BATT_LOW"", ""ERROR"", ""DEEP_SLEEP"" }; #endif /* magic keys - to find out whether reset is a startup */ #define MKEY1 0x7109 #define MKEY2 0xFD1E /***** super global variables (surviving resets) *****/ // The state var volatile uint8_t state __attribute__ ((section ("".noinit""))); // value of start variable last time volatile uint8_t laststate __attribute__ ((section ("".noinit""))); // This counter is advanced by the wdt interrupt - started after wakeup volatile uint16_t seconds __attribute__ ((section ("".noinit""))); // Keeping track when last bump happened (using seconds) uint16_t lastbump __attribute__ ((section ("".noinit""))); // last time the reset button was pressed uint16_t lastpress __attribute__ ((section ("".noinit""))); // last time, the state was changed uint16_t lastchange __attribute__ ((section ("".noinit""))); // last time, we measured the pressure volatile uint16_t lastmeasure __attribute__ ((section ("".noinit""))); // reference pressure for 0 level volatile float refPress __attribute__ ((section ("".noinit""))); // measurement converted to height above zero level volatile int height __attribute__ ((section ("".noinit""))); // last height when making measurement volatile int lastheight __attribute__ ((section ("".noinit""))); volatile uint8_t sleeplevel __attribute__ ((section ("".noinit""))); volatile uint8_t resetlevel __attribute__ ((section ("".noinit""))); uint16_t magickey1 __attribute__ ((section ("".noinit""))); /***** global vars ****/ char summit_str[31] = DEFAULT_SUMMIT_STR; // will be initialized in setup! int errcnt = 0; char errcode = '\\0'; int decimeters_up; // will be initialized from EEPROM int epsilon; // will be initialized from EEPROM int volt; uint8_t pressed = true; volatile uint8_t bumped = false; uint8_t lbumped = false; /* interrupt routine to drive display */ /* variables for display driver */ int csegix = 0; // current segment index long cmask = 0; volatile unsigned char dispchar = ' '; // correction coefficents of MS5611 uint16_t C[7]; // MS5611 variables // SoftI2cMaster baro(SDA_PIN,SCL_PIN); ISR(T1_vect) { TCNT1 = 0xFFFF-40; // 156 for 8MHz digitalWrite(lcd_seg[csegix],LOW); if (++csegix == 8) { csegix = 0; } if (1< 1 && (num/digval) == 0) digval = digval / 10; while (digval > 0) { displayChar((num/digval) + '0'); num = num%digval; digval = digval/10; } } float getAltiVal(byte code) { float ret = 0; if (!i2c_start(ADDRESS | I2C_WRITE)) return ERRORVAL; if (!i2c_write(code)) return ERRORVAL; i2c_stop(); idleDelay(15); // at least 10, 15 is on the safe side // start read sequence if (!i2c_start(ADDRESS | I2C_WRITE)) return ERRORVAL; if (!i2c_write(0x00)) return ERRORVAL; // request ADC vals i2c_stop(); if (!i2c_start(ADDRESS | I2C_READ)) return ERRORVAL; ret = i2c_read(false) * 65536.0 + i2c_read(false) * 256.0 + i2c_read(true); i2c_stop(); return ret; } bool resetAlti(void) { bool fail = true; if (i2c_start(ADDRESS | I2C_WRITE)) if (i2c_write(0x1E)) { idleDelay(6); fail = false; } i2c_stop(); if (fail) { errcnt++; errcode = RESET_ERROR; DEBTTY_PRINTLN(F(""Reset command unsuccessfull"")); } return (!(fail)); } void paramAlti(void) { bool fail = true; int retrycnt = 0; DEBTTY_PRINTLN(""""); DEBTTY_PRINTLN(F(""PROM COEFFICIENTS"")); while (fail && retrycnt++ < MAXRETRYCNT && errcnt < MAXERRCNT) { fail = false; for (int i=0; i<6 && !fail ; i++) { if (!i2c_start(ADDRESS | I2C_WRITE)) fail = true; if (!fail && !i2c_write(0xA2 + i*2)) fail = true; i2c_stop(); if (!fail && !i2c_start(ADDRESS | I2C_READ)) fail = true; C[i+1] = i2c_read(false) << 8 | i2c_read(true); i2c_stop(); DEBTTY_PRINTLN(C[i+1]); if (fail) { DEBTTY_PRINTLN(F(""Prom command unsuccessfull"")); errcnt++; recoverFromI2cProblem(); errcode = PARAM_ERROR; idleDelay(10); } } DEBTTY_PRINTLN(""""); } if (fail) { errcnt = MAXERRCNT; DEBTTY_PRINTLN(F(""*** Fatal error in prom command"")); } } float measurePress(int count) { float D1; float D2; float dT; float TEMP, P; float OFF; float SENS; float acc = 0; float minpress = 5000.0; float maxpress = 0; if (count <= 0) count = 1; while (errcnt < MAXERRCNT) { acc = 0; maxpress = 0; minpress = 5000.0; for (int i = 0; i < count && errcnt < MAXERRCNT; i++) { D1 = getAltiVal(0x48); // Pressure raw D2 = getAltiVal(0x58);// Temperature raw if (D1 != ERRORVAL && D2 != ERRORVAL) { dT = D2 - (C[5] * 256.0); OFF = C[2] * 65536.0 + ((dT * C[4])/128.0); SENS = (C[1] * 32768.0) + ((dT * C[3])/256.0); TEMP = dT * C[6] / 8388608.0 + 2000.0; if(TEMP < 2000.0) // if temperature lower than 20 Celsius { int32_t T1 = 0; int64_t OFF1 = 0; int64_t SENS1 = 0; T1 = pow(dT, 2) / 2147483648; OFF1 = 5 * pow((TEMP - 2000), 2) / 2; SENS1 = 5 * pow((TEMP - 2000), 2) / 4; if(TEMP < -1500) // if temperature lower than -15 Celsius { OFF1 = OFF1 + 7 * pow((TEMP + 1500), 2); SENS1 = SENS1 + 11 * pow((TEMP + 1500), 2) / 2; } TEMP -= T1; OFF -= OFF1; SENS -= SENS1; } if (TEMP < -7000.0 || TEMP > 12000.0) { // almost impossible temperatures errcnt++; errcode = TEMP_ERROR; if (errcnt < MAXERRCNT) { // reset the chip again resetAlti(); i--; // redo last measurement continue; } else { DEBTTY_PRINTLN(F(""*** Fatal abort because too many measurement errors"")); return(0); } } P = (D1 * SENS / 2097152 - OFF) / 32768 / 100.0; if (P < 600.0 || P > 1200.0) { // almost impossible pressures up to 4000 meters elevation errcnt++; errcode = PRESS_ERROR; if (errcnt < MAXERRCNT) { // reset the chip again resetAlti(); i--; // redo last measurement continue; } else { DEBTTY_PRINTLN(F(""*** Fatal abort because too many measurement errors"")); return(0); } } acc += P; if (minpress > P) minpress = P; if (maxpress < P) maxpress = P; } else { errcnt++; errcode = CONV_ERROR; DEBTTY_PRINTLN(F(""Measure command unsuccessful"")); if (errcnt < MAXERRCNT) { // reset the chip again recoverFromI2cProblem(); i--; // redo last measurement errcode = CONV_ERROR; } else { DEBTTY_PRINTLN(F(""*** Fatal abort because too many measurement errors"")); return(0); } } } if (maxpress-minpress > MAXOUTLIER) { // if more than 0.6 hPa resp. 5 meters diff errcnt++; errcode = OUTLIER_ERROR; } else break; } return (acc/count); } float measurePressWithRecovery(int count) { float result; bool cont = true; int retrycnt = 4; while (retrycnt-- && cont) { result = measurePress(count); if (errcnt >= MAXERRCNT && retrycnt) { errcnt = 0; errcode = NO_ERROR; resetAlti(); idleDelay(20); paramAlti(); idleDelay(20); } else cont = false; } return result; } int readVoltage(void) { int result, reading; ADCSRA |= (1< WAKEUP_STATE) state = BATT_LOW_STATE; if (errcnt >= MAXERRCNT) state = ERROR_STATE; if (state > LAST_STATE || state < NO_STATE) state = NO_STATE; if (sleeplevel == 5) state = DEEPSLEEP_STATE; if (resetlevel >= 5) state = RESET_STATE; nextmeasure = getSeconds(); if ((state == CLIMB_STATE || state == SUMMIT_STATE) && (nextmeasure != lastmeasure || pressed)) { lastmeasure = nextmeasure; if (nextmeasure%3 == 0 || pressed) { dispchar = '.'; currPress = measurePressWithRecovery(5); dispchar = ' '; idleDelay(300); lastheight = height; height = (int)((refPress-currPress)/0.012); #if 1 if ((height < -(5*epsilon) || height > decimeters_up+5*epsilon) && state == CLIMB_STATE) { #ifdef DEB_LEDHEIGHT displayNum((int)height); displayChar(' '); #endif errcnt = MAXERRCNT; errcode = HEIGHT_ERROR; } #endif } } if (errcode && errcnt >= MAXERRCNT) state = ERROR_STATE; //DEBUG // displayNum(state); // displayNum(sleeplevel); DEBLCD_CLEAR(); DEBLCD_HOME(); if (laststate != state) { DEBTTY_PRINT(F(""New state: "")); DEBTTY_PRINTLN(statestr[state]); laststate = state; setSeconds(lastchange); } DEBLCD_PRINTLN(statestr[state]); DEBLCD_PRINT(F(""Volt: "")); DEBLCD_PRINTLN(volt); DEBLCD_PRINT(F(""Height: "")); DEBLCD_PRINTLN(height); DEBLCD_PRINT(F(""Time: "")); DEBLCD_PRINTLN(getSeconds()); DEBLCD_PRINT(F(""P/B: "")); DEBLCD_PRINT(getSeconds()-lastpress); DEBLCD_PRINT(F(""/"")); DEBLCD_PRINTLN(getSeconds()-lastbump); DEBLCD_PRINT(F(""RefP: "")); DEBLCD_PRINTLN(refPress); DEBLCD_DISPLAY(); switch(state) { case RESET_STATE: resetlevel = 0; displayPString(reset_str); state = WAKEUP_STATE; pressed = true; break; case SLEEP_STATE: // sleeping and waiting for a bump or reset to wake up if (!pressed) { gosleep(); } if (bumped || pressed) { cli(); seconds = 0; lastbump = 0; lastpress = 0; lastchange = 0; sei(); setupIO(); dispchar = '.'; idleDelay(100); dispchar = ' '; idleDelay(100); state = WAKEUP_STATE; } break; case WAKEUP_STATE: // somebody was moving us if (bumped) { dispchar = '.'; idleDelay(60); dispchar = ' '; idleDelay(60); } if (pressed) { if (eeprom_read_byte(&eelowvolterr[0]) == 0) state = BATT_LOW_STATE; else { dispchar = '.'; refPress = measurePressWithRecovery(20); currPress = refPress; dispchar = ' '; idleDelay(200); state = CLIMB_STATE; if (volt < LOWVOLT_WARN) displayPString(lowbatt_str); if (!errcode || errcnt < MAXERRCNT) { resetlevel++; displayPString(go_str); displayChar(' '); if (sleeplevel == 0) sleeplevel = 1; displayNum(int(decimeters_up/CONVFAC)); if (sleeplevel == 1) sleeplevel = 0; displayChar(' '); resetlevel = 0; displayPString(meter_str); displayChar(' '); displayPString(up_str); } } } else { if (getSeconds() > MAXWAKEUP_TOTAL) state = SLEEP_STATE; else if (getSeconds() - lastbump > MAXWAKEUP_NOBUMP) state = SLEEP_STATE; } break; case CLIMB_STATE: // steadily climbing #ifndef DEB_LEDSTABLE if (decimeters_up-height <= epsilon) { if (pressed) displaySummitString(); state = SUMMIT_STATE; } else if (pressed) { if (decimeters_up-height >= 0) { resetlevel++; displayPString(go_str); displayChar(' '); resetlevel = 0; if (sleeplevel == 0) sleeplevel = 1; displayNum(int((decimeters_up-height)/CONVFAC)); displayChar(' '); if (sleeplevel == 1) sleeplevel = 0; if (sleeplevel == 2) sleeplevel = 3; displayPString(meter_str); displayChar(' '); if (sleeplevel == 3) sleeplevel = 0; if (sleeplevel == 4) sleeplevel = 5; displayPString(up_str); if (sleeplevel == 5) sleeplevel = 0; } else { state = SUMMIT_STATE; } } else if (getSeconds() - lastbump > MINQUIET) { displayPString(bye_str); state = SLEEP_STATE; } break; #else if (height < 0) { displayChar('-'); height = -height; } displayNum(height); break; #endif case SUMMIT_STATE: // reached the summit if (pressed) { displaySummitString(); if (volt < LOWVOLT_WARN) displayPString(lowbatt_str); } if (height < decimeters_up-epsilon*2) state = CLIMB_STATE; break; case BATT_LOW_STATE: // if battery is definitely too low if (!pressed || lastchange >= lastpress) for (int i=0; i<3; i++) displayPString(lowbatt_str); state = SLEEP_STATE; displayPString(bye_str); break; case ERROR_STATE: // display error code if (!pressed || lastchange >= lastpress) { for (int i=0; i<4; i++) { displayPString(error_str); displayChar(' '); displayChar(errcode); } } errcode = NO_ERROR; errcnt = 0; state = SLEEP_STATE; displayPString(bye_str); break; case DEEPSLEEP_STATE: // sleep for transport displayPString(sleep_str); disableVibIRQ(); state = SLEEP_STATE; sleeplevel = 0; gosleep(); errcode = WAKEUP_ERROR; errcnt = MAXERRCNT; break; default: // somehow, the state var got a wrong value errcode = STATE_ERROR; errcnt = MAXERRCNT; break; } lbumped = bumped; pressed = false; bumped = false; if (laststate == state) { IOoff(); set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_mode(); setupIO(); } } ",12063,False,1684.8350788235127,median """!

SAPgui Shortcut

class /GAL/SAPGUI_SHORTCUT definition public final create public . public section. type-pools ABAP . ""!

SAPgui shortcut type: Report

constants SHORTCUT_TYPE_REPORT type I value 2. ""#EC NOTEXT ""!

SAPgui shortcut type: System Command

constants SHORTCUT_TYPE_SYSTEM_COMMAND type I value 3. ""#EC NOTEXT ""!

SAPgui shortcut type: Transaction

constants SHORTCUT_TYPE_TRANSACTION type I value 1. ""#EC NOTEXT ""!

SAPgui shortcut type: Undefined

constants SHORTCUT_TYPE_UNDEFINED type I value 0. ""#EC NOTEXT ""!

Client

data CLIENT type MANDT read-only . ""!

Do not re-use existing session

data FORCE_LOGIN type ABAP_BOOL read-only . ""!

Language Key

data LANGUAGE type LANGU read-only . ""!

Parameters

data PARAMETERS type STRING read-only . ""!

Program Name (type Report only)

data PROGRAM_NAME type PROGNAME read-only . ""!

System description used in SAPlogon

data SAPLOGON_SYSTEM_DESCRIPTION type STRING read-only . ""!

System Command (type System Command)

data SYSTEM_COMMAND type STRING read-only . ""!

System ID

data SYSTEM_ID type SYSYSID read-only . ""!

Title

data TITLE type STRING read-only . ""!

Transaction Code (type Transaction only)

data TRANSACTION_CODE type TCODE read-only . ""!

SAPgui shortcut type

data TYPE type I read-only value SHORTCUT_TYPE_UNDEFINED. ""#EC NOTEXT ""!

User Name

data USER type SYUNAME read-only . ""!

Skip first screen for transaction

data SKIP_FIRST_SCREEN type ABAP_BOOL read-only . ""!

Include SNC information

data WITH_SNC_INFO type ABAP_BOOL read-only. ""!

SNC name of target system

data SYS_SNC_NAME type STRING read-only. ""!

SNC quality of protection

data SYS_SNC_QOP type CHAR1 read-only. ""!

Constructor

""! ""! @parameter transaction_code |

Transaction code

""! @parameter program_name |

Program name

""! @parameter system_command |

System Command

""! @parameter system_id |

System ID

""! @parameter saplogon_system_description |

System description used in SAPlogon

""! @parameter client |

Client

""! @parameter user |

User

""! @parameter language |

Language

""! @parameter title |

Title

""! @parameter force_login |

Do not re-use existing session

""! @parameter sys_snc_name |

SNC name of target system

""! @parameter sys_snc_qop |

SNC quality of protection

""! @raising /gal/cx_gui_shortcut_exception |

SAPgui Shortcut related exception

methods CONSTRUCTOR importing !TRANSACTION_CODE type CSEQUENCE optional !PROGRAM_NAME type CSEQUENCE optional !SYSTEM_COMMAND type CSEQUENCE optional !SYSTEM_ID type SYSYSID default SY-SYSID !SAPLOGON_SYSTEM_DESCRIPTION type CSEQUENCE optional !CLIENT type MANDT default SY-MANDT !USER type CSEQUENCE default SY-UNAME !LANGUAGE type LANGU default SY-LANGU !TITLE type CSEQUENCE optional !FORCE_LOGIN type ABAP_BOOL default ABAP_FALSE !SYS_SNC_NAME type CSEQUENCE optional !SYS_SNC_QOP TYPE CSEQUENCE optional raising /GAL/CX_GUI_SHORTCUT_EXCEPTION . ""!

Write to temporary frontend file and execute

""! ""! @raising /gal/cx_gui_shortcut_exception |

SAPgui Shortcut related exception

""! @raising /gal/cx_io_exception |

IO Exception

methods EXECUTE raising /GAL/CX_GUI_SHORTCUT_EXCEPTION /GAL/CX_IO_EXCEPTION . ""!

Set dynpro field value (type Transaction only)

""! ""! @parameter field_name |

Field name

""! @parameter field_value |

Field value

""! @raising /gal/cx_gui_shortcut_exception |

SAPgui Shortcut related exception

methods SET_DYNPRO_FIELD_VALUE importing !FIELD_NAME type CSEQUENCE !FIELD_VALUE type ANY raising /GAL/CX_GUI_SHORTCUT_EXCEPTION . ""!

Write to file

""! ""! @parameter file |

File

""! @raising /gal/cx_io_exception |

IO Exception

methods WRITE_TO_FILE importing !FILE type ref to /GAL/FILE raising /GAL/CX_IO_EXCEPTION . ""!

Write to frontend file

""! ""! @parameter name |

File name (full path)

""! @raising /gal/cx_io_exception |

IO Exception

methods WRITE_TO_FRONTEND_FILE importing !NAME type CSEQUENCE raising /GAL/CX_IO_EXCEPTION . ""!

Write to stream

""! ""! @parameter stream |

Stream

""! @raising /gal/cx_io_exception |

IO Exception

methods WRITE_TO_STREAM importing !STREAM type ref to /GAL/STREAM raising /GAL/CX_IO_EXCEPTION . ""!

Write to string

""! ""! @parameter result |

Result

methods WRITE_TO_STRING returning value(RESULT) type STRING . ""!

Set indicator to skip first screen (type Transaction only)

""! ""! @parameter skip_first_screen |

Skip first screen for transaction

""! @raising /gal/cx_gui_shortcut_exception |

SAPgui Shortcut related exception

methods SET_SKIP_FIRST_SCREEN importing !SKIP_FIRST_SCREEN type ABAP_BOOL default ABAP_FALSE raising /GAL/CX_GUI_SHORTCUT_EXCEPTION . protected section. private section. ENDCLASS. CLASS /GAL/SAPGUI_SHORTCUT IMPLEMENTATION. METHOD constructor. DATA l_language_iso(2) TYPE c. * Determine shortcut type IF transaction_code IS NOT INITIAL AND program_name IS INITIAL AND system_command IS INITIAL. me->title = transaction_code. me->transaction_code = transaction_code. me->type = shortcut_type_transaction. ELSEIF transaction_code IS INITIAL AND program_name IS NOT INITIAL AND system_command IS INITIAL. me->title = program_name. me->program_name = program_name. me->type = shortcut_type_report. ELSEIF transaction_code IS INITIAL AND program_name IS INITIAL AND system_command IS NOT INITIAL. me->title = system_command. me->system_command = system_command. me->type = shortcut_type_system_command. ELSE. RAISE EXCEPTION TYPE /gal/cx_gui_shortcut_exception EXPORTING textid = /gal/cx_gui_shortcut_exception=>invalid_param_combination. ENDIF. * Copy parameters to attributes me->system_id = system_id. me->saplogon_system_description = saplogon_system_description. me->client = client. me->user = user. me->language = language. me->force_login = force_login. me->sys_snc_name = sys_snc_name. me->sys_snc_qop = sys_snc_qop. IF me->sys_snc_name IS NOT INITIAL AND me->sys_snc_qop IS NOT INITIAL. me->with_snc_info = abap_true. ELSE. me->with_snc_info = abap_false. ENDIF. IF title IS NOT INITIAL. me->title = title. ELSE. CONCATENATE system_id `.` client ` - ` user ` - ` me->title INTO me->title. IF language IS NOT INITIAL. WRITE language TO l_language_iso. CONCATENATE me->title ` (` l_language_iso `)` INTO me->title. ENDIF. ENDIF. ENDMETHOD. METHOD execute. DATA l_temp_path TYPE string. DATA l_temp_name TYPE string. DATA l_full_name TYPE string. DATA l_file TYPE REF TO /gal/frontend_file. DATA l_message TYPE string. * Get folder for temporary files cl_gui_frontend_services=>get_temp_directory( CHANGING temp_dir = l_temp_path EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. l_message = TEXT-e01. RAISE EXCEPTION TYPE /gal/cx_gui_shortcut_exception EXPORTING textid = /gal/cx_gui_shortcut_exception=>sapgui_communication_error var1 = l_message. ELSE. cl_gui_cfw=>flush( ). ENDIF. * Create unique file name for temporary file l_temp_name = /gal/uuid=>create_char( ). CONCATENATE l_temp_name `.sap` INTO l_temp_name. ""#EC NOTEXT * Create full file name l_full_name = /gal/path=>combine( path1 = l_temp_path path2 = l_temp_name separator = /gal/path=>client_path_separator ). * Write shortcut to temporary file CREATE OBJECT l_file EXPORTING name = l_full_name. write_to_file( l_file ). * Execute shortcut cl_gui_frontend_services=>execute( EXPORTING document = l_full_name default_directory = l_temp_path synchronous = `X` EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. l_message = TEXT-e02. RAISE EXCEPTION TYPE /gal/cx_gui_shortcut_exception EXPORTING textid = /gal/cx_gui_shortcut_exception=>sapgui_communication_error var1 = l_message. ENDIF. * Delete temporary file TRY. l_file->delete( ). CATCH /gal/cx_io_exception. ""#EC NO_HANDLER ""File is delete by SAPgui after successful execution. ""Therefore file may have been deleted already. ENDTRY. ENDMETHOD. METHOD set_dynpro_field_value. DATA l_value TYPE string. * Pre-defined field values are only supported for transactions IF type <> shortcut_type_transaction. RAISE EXCEPTION TYPE /gal/cx_gui_shortcut_exception EXPORTING textid = /gal/cx_gui_shortcut_exception=>invalid_param_combination. ENDIF. * Add field value to parameters l_value = field_value. CONCATENATE parameters field_name `=` l_value `;` INTO parameters. ENDMETHOD. METHOD set_skip_first_screen. * Indicator for skipping first screen is only possible for transactions IF type <> shortcut_type_transaction. RAISE EXCEPTION TYPE /gal/cx_gui_shortcut_exception EXPORTING textid = /gal/cx_gui_shortcut_exception=>invalid_param_combination. ENDIF. me->skip_first_screen = skip_first_screen. ENDMETHOD. METHOD write_to_file. DATA l_stream TYPE REF TO /gal/stream. l_stream = file->open( access = /gal/file=>access_write mode = /gal/file=>mode_text options = /gal/file=>options_create line_break = /gal/file=>line_break_windows ). write_to_stream( l_stream ). l_stream->close( ). ENDMETHOD. METHOD write_to_frontend_file. DATA l_file TYPE REF TO /gal/frontend_file. CREATE OBJECT l_file EXPORTING name = name. write_to_file( l_file ). ENDMETHOD. METHOD write_to_stream. DATA l_data TYPE string. l_data = write_to_string( ). stream->write_chars( l_data ). ENDMETHOD. METHOD write_to_string. * Function module SWN_CREATE_SHORTCUT is not used here because of string length limitations! DATA l_language_iso(2) TYPE c. DATA l_command TYPE string. DATA l_type TYPE string. DATA l_reuse TYPE string. DATA l_window_size TYPE string. * Determine command and type CASE type. WHEN shortcut_type_transaction. IF skip_first_screen = abap_false. CONCATENATE transaction_code parameters INTO l_command SEPARATED BY space. ELSE. CONCATENATE '*' transaction_code INTO l_command. ""#EC NOTEXT CONCATENATE l_command parameters INTO l_command SEPARATED BY space. ENDIF. l_type = `Transaction`. ""#EC NOTEXT WHEN shortcut_type_report. l_command = program_name. l_type = `Report`. ""#EC NOTEXT WHEN shortcut_type_system_command. l_command = system_command. l_type = `SystemCommand`. ""#EC NOTEXT ENDCASE. * Convert language key to ISO code WRITE language TO l_language_iso. * Determine re-use option IF force_login = abap_true. l_reuse = `0`. ELSE. l_reuse = `1`. ENDIF. * Set window size l_window_size = `Normal window`. ""#EC NOTEXT * Create shortcut IF with_snc_info = abap_false. CONCATENATE `[System]` /gal/string=>line_break_windows ""#EC NOTEXT `Name=` system_id /gal/string=>line_break_windows ""#EC NOTEXT `Description=` saplogon_system_description /gal/string=>line_break_windows ""#EC NOTEXT `Client=` client /gal/string=>line_break_windows ""#EC NOTEXT `[User]` /gal/string=>line_break_windows ""#EC NOTEXT `Name=` user /gal/string=>line_break_windows ""#EC NOTEXT `Language=` l_language_iso /gal/string=>line_break_windows ""#EC NOTEXT `[Function]` /gal/string=>line_break_windows ""#EC NOTEXT `Title=` title /gal/string=>line_break_windows ""#EC NOTEXT `Command=` l_command /gal/string=>line_break_windows ""#EC NOTEXT `Type=` l_type /gal/string=>line_break_windows ""#EC NOTEXT `[Configuration]` /gal/string=>line_break_windows ""#EC NOTEXT `GuiSize=` l_window_size /gal/string=>line_break_windows ""#EC NOTEXT `[Options]` /gal/string=>line_break_windows ""#EC NOTEXT `Reuse=` l_reuse /gal/string=>line_break_windows ""#EC NOTEXT INTO result. ELSE. CONCATENATE `[System]` /gal/string=>line_break_windows ""#EC NOTEXT `Name=` system_id /gal/string=>line_break_windows ""#EC NOTEXT `Description=` saplogon_system_description /gal/string=>line_break_windows ""#EC NOTEXT `Client=` client /gal/string=>line_break_windows ""#EC NOTEXT `snc_name=` sys_snc_name /gal/string=>line_break_windows ""#EC NOTEXT `snc_qop=` sys_snc_qop /gal/string=>line_break_windows ""#EC NOTEXT `[User]` /gal/string=>line_break_windows ""#EC NOTEXT `Name=` user /gal/string=>line_break_windows ""#EC NOTEXT `Language=` l_language_iso /gal/string=>line_break_windows ""#EC NOTEXT `[Function]` /gal/string=>line_break_windows ""#EC NOTEXT `Title=` title /gal/string=>line_break_windows ""#EC NOTEXT `Command=` l_command /gal/string=>line_break_windows ""#EC NOTEXT `Type=` l_type /gal/string=>line_break_windows ""#EC NOTEXT `[Configuration]` /gal/string=>line_break_windows ""#EC NOTEXT `GuiSize=` l_window_size /gal/string=>line_break_windows ""#EC NOTEXT `[Options]` /gal/string=>line_break_windows ""#EC NOTEXT `Reuse=` l_reuse /gal/string=>line_break_windows ""#EC NOTEXT INTO result. ENDIF. ENDMETHOD. ENDCLASS. ",4326,False,680.693121619837,median "/* Shennong.ino Scroll through Chinese Short Story ""The Farmer God Shen Nong Tastes All the Plants"" 2KB Ram and > 200K Flash required Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. English translation: The Farmer God Shen Nong Tastes All the Plants Source: http://chinesereadingpractice.com/2012/08/22/the-farmer-god-shen-nong-tastes-all-the-plants/ All his life, Shen Nong had a crystal abdomen, and one could clearly see all of his internal organs. At that time, humans were often getting sick and even dying because they ate things indiscriminately [not knowing if they were good or bad]. Shen Nong determinedly tasted everything everywhere; the good-tasting things he put in a bag on his left side, those were for people to eat; the bad-tasting things he put in a bag on his right side, and those were used for medicine. The first time, Shen Nong tasted a small fresh leaf. As this leaf fell into his stomach, it cleaned every inch of his insides so that every organ top and bottom was fresh and cool, as if [the leaf] was somehow on patrol [making the rounds], so Shen Nong called it “chá” [to investigate / check], and later generations of men called it “chá” [tea]. Shen Nong put it in the bag on the right. The second time, Shen Nong tasted a little light red flower that looked like a butterfly, which was sweet and delicious, with an exotic smell that filled his nostrils, so he called it “licorice”. He put it in the bag on the left. In this way, Shen Nong diligently tasted all manner of flora, and every time he was poisoned, he used tea to rescue himself. Before long, the bag on his left contained 47,000 kinds of flowers, grasses, roots and leaves, and the right side had 398,000 kinds. But one day, Shen Nong tasted “heartbreak grass”, and this poison was too terrible, so there wasn’t enough time to eat the tea leaves to detoxify and he died. He sacrificed himself to save humanity, so people call him the “Bodhisattva of Medicine”, and people forever commemorate him through this story. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! // End of constructor list // To read the short story with all glyphs you need at least a font with _gb2312b postfix // However, a font with _gb2312b postfix is very large and will not always fit on // the target controller. For testing you can use _chinese1 extenstion, but then // many gylphs are skipped. // // wqy fonts are available in different sizes, here are only wqy12, wqy14 and wqy16 listed //#define FONT u8g2_font_wqy12_t_chinese1 //#define FONT u8g2_font_wqy12_t_gb2312b //#define FONT u8g2_font_wqy14_t_chinese1 #define FONT u8g2_font_wqy14_t_gb2312b //#define FONT u8g2_font_wqy16_t_chinese1 //#define FONT u8g2_font_wqy16_t_gb2312b // The next two macros define the scroll speed of the short story #define SCROLL_DELTA 2 #define SCROLL_DELAY 200 // Chinese Short Story // The Farmer God Shen Nong Tastes All the Plants // Please excause wrong line breaks const char c_str[] = ""Shen Nong\\n\\n"" ""神农一生下来就是\\n"" ""个水晶肚子,五脏\\n"" ""六腑全都能看得一\\n"" ""清二楚。那时侯,\\n"" ""人们经常因为乱吃\\n"" ""东西而生病,甚至\\n"" ""丧命。神农决心尝\\n"" ""遍所有的东西,好\\n"" ""吃的放在身边左边\\n"" ""的袋子里,给人吃\\n"" "";\\n"" ""不好吃的就放在身\\n"" ""子右边的袋子里,\\n"" ""作药用。\\n"" ""第一次,神农尝了\\n"" ""一片小嫩叶。这叶\\n"" ""片一落进肚里,就\\n"" ""上上下下地把里面\\n"" ""各器官擦洗得清清\\n"" ""爽爽,\\n"" ""象巡查似的,\\n"" ""神农把它叫做\\n"" ""“查”,\\n"" ""就是后人所称的\\n"" ""“茶”。\\n"" ""神农将它放进右边\\n"" ""袋子里。第二次,\\n"" ""神农尝了朵蝴蝶样\\n"" ""的淡红小花,甜津\\n"" ""津的,香味扑鼻,\\n"" ""这是“甘草”。他把\\n"" ""它放进了左边袋子\\n"" ""里。就这样,神农\\n"" ""辛苦地尝遍百草,\\n"" ""每次中毒,都靠茶\\n"" ""来解救。后来,\\n"" ""他左边的袋子里花\\n"" ""草根叶有四万七千\\n"" ""种,右边有三十九\\n"" ""万八千种。\\n"" ""但有一天,神农尝\\n"" ""到了“断肠草”,这\\n"" ""种毒草太厉害了,\\n"" ""他还来不及吃茶解\\n"" ""毒就死了。\\n"" ""他是为了拯救人们\\n"" ""而牺牲的,人们称\\n"" ""他为“药王菩萨”,\\n"" ""人间以这个神话故\\n"" ""事永远地纪念他。\\n""; char buf[48]; // there are at most 8 chinese glyphs per line, max buf size is 8*3 = 24 uint8_t total_lines; // the total number of lines in the story uint8_t i; // loop variable for the lines uint8_t line_cnt; // number of lines to draw, usually equal to lines_per_draw uint8_t start_line; // topmost visible line, derived from top_window_pos uint8_t lines_per_draw; // how many lines to draw on the screen, derived from font and display height uint16_t glyph_height; // height of the glyphs uint16_t top_window_pos; // defines the display position in pixel within the text uint16_t total_height; // total height in pixel, derived from font height and total_lines u8g2_uint_t top_offset; // offset between the first visible line and the display void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); /* select a font */ u8g2.setFont(u8g2_font_wqy12_t_chinese1); // two unknown glyphs //u8g2.setFont(u8g2_font_wqy12_t_chinese3); // two unknown glyphs //u8g2.setFont(u8g2_font_wqy12_t_gb2312a); // "";"" is missing //u8g2.setFont(u8g2_font_wqy12_t_gb2312b); // all glyphs available u8g2.setFont(FONT); /* calculate the length of the text in lines */ total_lines = u8x8_GetStringLineCnt(c_str); /* get the height of the glyphs */ glyph_height = u8g2.getMaxCharHeight(); /* calculate the height of the text in pixel */ total_height = (uint16_t)total_lines * (uint16_t)glyph_height; /* calculate how many lines must be drawn on the screen */ lines_per_draw = u8g2.getDisplayHeight() / glyph_height; lines_per_draw += 2; /* start at the top of the text */ top_window_pos = 0; } void loop(void) { start_line = top_window_pos / glyph_height; top_offset = top_window_pos % glyph_height; line_cnt = total_lines - start_line; if ( line_cnt > lines_per_draw ) line_cnt = lines_per_draw; u8g2.firstPage(); do { for( i = 0; i < line_cnt; i++ ) { /* copy a line of the text to the local buffer */ u8x8_CopyStringLine(buf, i+start_line, c_str); /* draw the content of the local buffer */ u8g2.drawUTF8(0, i*glyph_height-top_offset +glyph_height, buf); } } while ( u8g2.nextPage() ); delay(SCROLL_DELAY); top_window_pos += SCROLL_DELTA; } ",12179,True,3158.9572591221463,median "* Copyright 2019 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the ""License""); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an ""AS IS"" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ""!

Natural Language Classifier

""! IBM Watson™ Natural Language Classifier uses machine learning algorithms ""! to return the top matching predefined classes for short text input. You create ""! and train a classifier to connect predefined classes to example texts so that ""! the service can apply those classes to new inputs.
class ZCL_IBMC_NAT_LANG_CLASS_V1 DEFINITION public inheriting from ZCL_IBMC_SERVICE_EXT create public . public section. types: ""! Response payload for HTTP errors. begin of T_ERROR_RESPONSE, CODE type INTEGER, ERROR type STRING, DESCRIPTION type STRING, end of T_ERROR_RESPONSE. types: ""! Request payload to classify. begin of T_CLASSIFY_INPUT, TEXT type STRING, end of T_CLASSIFY_INPUT. types: ""! begin of T_INLINE_OBJECT, TRAINING_METADATA type FILE, TRAINING_DATA type FILE, end of T_INLINE_OBJECT. types: ""! Class and confidence. begin of T_CLASSIFIED_CLASS, CONFIDENCE type DOUBLE, CLASS_NAME type STRING, end of T_CLASSIFIED_CLASS. types: ""! Response from the classifier for a phrase in a collection. begin of T_COLLECTION_ITEM, TEXT type STRING, TOP_CLASS type STRING, CLASSES type STANDARD TABLE OF T_CLASSIFIED_CLASS WITH NON-UNIQUE DEFAULT KEY, end of T_COLLECTION_ITEM. types: ""! A classifier for natural language phrases. begin of T_CLASSIFIER, NAME type STRING, URL type STRING, STATUS type STRING, CLASSIFIER_ID type STRING, CREATED type DATETIME, STATUS_DESCRIPTION type STRING, LANGUAGE type STRING, end of T_CLASSIFIER. types: ""! List of available classifiers. begin of T_CLASSIFIER_LIST, CLASSIFIERS type STANDARD TABLE OF T_CLASSIFIER WITH NON-UNIQUE DEFAULT KEY, end of T_CLASSIFIER_LIST. types: ""! Response from the classifier for a phrase. begin of T_CLASSIFICATION, CLASSIFIER_ID type STRING, URL type STRING, TEXT type STRING, TOP_CLASS type STRING, CLASSES type STANDARD TABLE OF T_CLASSIFIED_CLASS WITH NON-UNIQUE DEFAULT KEY, end of T_CLASSIFICATION. types: ""! Request payload to classify. begin of T_CLASSIFY_COLLECTION_INPUT, COLLECTION type STANDARD TABLE OF T_CLASSIFY_INPUT WITH NON-UNIQUE DEFAULT KEY, end of T_CLASSIFY_COLLECTION_INPUT. types: ""! Response payload for Cloud errors. begin of T_ERROR_CLOUD, CODE type INTEGER, ERROR type STRING, end of T_ERROR_CLOUD. types: ""! T_EMPTY type JSONOBJECT. types: ""! Response from the classifier for multiple phrases. begin of T_CLASSIFICATION_COLLECTION, CLASSIFIER_ID type STRING, URL type STRING, COLLECTION type STANDARD TABLE OF T_COLLECTION_ITEM WITH NON-UNIQUE DEFAULT KEY, end of T_CLASSIFICATION_COLLECTION. constants: begin of C_REQUIRED_FIELDS, T_ERROR_RESPONSE type string value '|', T_CLASSIFY_INPUT type string value '|TEXT|', T_INLINE_OBJECT type string value '|TRAINING_METADATA|TRAINING_DATA|', T_CLASSIFIED_CLASS type string value '|', T_COLLECTION_ITEM type string value '|', T_CLASSIFIER type string value '|URL|CLASSIFIER_ID|', T_CLASSIFIER_LIST type string value '|CLASSIFIERS|', T_CLASSIFICATION type string value '|', T_CLASSIFY_COLLECTION_INPUT type string value '|COLLECTION|', T_ERROR_CLOUD type string value '|', T_CLASSIFICATION_COLLECTION type string value '|', __DUMMY type string value SPACE, end of C_REQUIRED_FIELDS . constants: begin of C_ABAPNAME_DICTIONARY, CODE type string value 'code', ERROR type string value 'error', DESCRIPTION type string value 'description', CLASSIFIERS type string value 'classifiers', NAME type string value 'name', URL type string value 'url', STATUS type string value 'status', CLASSIFIER_ID type string value 'classifier_id', CREATED type string value 'created', STATUS_DESCRIPTION type string value 'status_description', LANGUAGE type string value 'language', COLLECTION type string value 'collection', TEXT type string value 'text', TOP_CLASS type string value 'top_class', CLASSES type string value 'classes', CONFIDENCE type string value 'confidence', CLASS_NAME type string value 'class_name', CLASSIFYINPUT type string value 'classifyInput', TRAINING_METADATA type string value 'training_metadata', TRAINING_DATA type string value 'training_data', end of C_ABAPNAME_DICTIONARY . methods GET_APPNAME redefinition . methods GET_REQUEST_PROP redefinition . methods GET_SDK_VERSION_DATE redefinition . ""! Classify a phrase. ""! ""! @parameter I_classifier_id | ""! Classifier ID to use. ""! @parameter I_body | ""! Phrase to classify. ""! @parameter E_RESPONSE | ""! Service return value of type T_CLASSIFICATION ""! methods CLASSIFY importing !I_classifier_id type STRING !I_body type T_CLASSIFY_INPUT !I_contenttype type string default 'application/json' !I_accept type string default 'application/json' exporting !E_RESPONSE type T_CLASSIFICATION raising ZCX_IBMC_SERVICE_EXCEPTION . ""! Classify multiple phrases. ""! ""! @parameter I_classifier_id | ""! Classifier ID to use. ""! @parameter I_body | ""! Phrase to classify. You can submit up to 30 text phrases in a request. ""! @parameter E_RESPONSE | ""! Service return value of type T_CLASSIFICATION_COLLECTION ""! methods CLASSIFY_COLLECTION importing !I_classifier_id type STRING !I_body type T_CLASSIFY_COLLECTION_INPUT !I_contenttype type string default 'application/json' !I_accept type string default 'application/json' exporting !E_RESPONSE type T_CLASSIFICATION_COLLECTION raising ZCX_IBMC_SERVICE_EXCEPTION . ""! Create classifier. ""! ""! @parameter I_training_metadata | ""! Metadata in JSON format. The metadata identifies the language of the data, and ""! an optional name to identify the classifier. Specify the language with the ""! 2-letter primary language code as assigned in ISO standard 639. ""! ""! Supported languages are English (`en`), Arabic (`ar`), French (`fr`), German, ""! (`de`), Italian (`it`), Japanese (`ja`), Korean (`ko`), Brazilian Portuguese ""! (`pt`), and Spanish (`es`). ""! @parameter I_training_data | ""! Training data in CSV format. Each text value must have at least one class. The ""! data can include up to 3,000 classes and 20,000 records. For details, see [Data ""! preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?to ""! pic=natural-language-classifier-using-your-data). ""! @parameter E_RESPONSE | ""! Service return value of type T_CLASSIFIER ""! methods CREATE_CLASSIFIER importing !I_training_metadata type FILE !I_training_data type FILE !I_training_metadata_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL !I_training_data_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL !I_contenttype type string default 'multipart/form-data' !I_accept type string default 'application/json' exporting !E_RESPONSE type T_CLASSIFIER raising ZCX_IBMC_SERVICE_EXCEPTION . ""! List classifiers. ""! ""! @parameter E_RESPONSE | ""! Service return value of type T_CLASSIFIER_LIST ""! methods LIST_CLASSIFIERS importing !I_accept type string default 'application/json' exporting !E_RESPONSE type T_CLASSIFIER_LIST raising ZCX_IBMC_SERVICE_EXCEPTION . ""! Get information about a classifier. ""! ""! @parameter I_classifier_id | ""! Classifier ID to query. ""! @parameter E_RESPONSE | ""! Service return value of type T_CLASSIFIER ""! methods GET_CLASSIFIER importing !I_classifier_id type STRING !I_accept type string default 'application/json' exporting !E_RESPONSE type T_CLASSIFIER raising ZCX_IBMC_SERVICE_EXCEPTION . ""! Delete classifier. ""! ""! @parameter I_classifier_id | ""! Classifier ID to delete. ""! methods DELETE_CLASSIFIER importing !I_classifier_id type STRING !I_accept type string default 'application/json' raising ZCX_IBMC_SERVICE_EXCEPTION . protected section. private section. methods SET_DEFAULT_QUERY_PARAMETERS changing !C_URL type TS_URL . ENDCLASS. class ZCL_IBMC_NAT_LANG_CLASS_V1 IMPLEMENTATION. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_APPNAME * +-------------------------------------------------------------------------------------------------+ * | [<-()] E_APPNAME TYPE STRING * +-------------------------------------------------------------------------------------- method GET_APPNAME. e_appname = 'Natural Language Classifier'. endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Protected Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_REQUEST_PROP * +-------------------------------------------------------------------------------------------------+ * | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) * | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP * +-------------------------------------------------------------------------------------- method GET_REQUEST_PROP. data: lv_auth_method type string ##NEEDED. e_request_prop = super->get_request_prop( ). lv_auth_method = i_auth_method. if lv_auth_method eq c_default. lv_auth_method = 'IAM'. endif. if lv_auth_method is initial. e_request_prop-auth_basic = c_boolean_false. e_request_prop-auth_oauth = c_boolean_false. e_request_prop-auth_apikey = c_boolean_false. elseif lv_auth_method eq 'IAM'. e_request_prop-auth_name = 'IAM'. e_request_prop-auth_type = 'apiKey'. e_request_prop-auth_headername = 'Authorization'. e_request_prop-auth_header = c_boolean_true. elseif lv_auth_method eq 'basicAuth'. e_request_prop-auth_name = 'basicAuth'. e_request_prop-auth_type = 'http'. e_request_prop-auth_basic = c_boolean_true. else. endif. e_request_prop-url-protocol = 'http'. e_request_prop-url-host = 'localhost'. e_request_prop-url-path_base = '/natural-language-classifier/api'. endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_SDK_VERSION_DATE * +-------------------------------------------------------------------------------------------------+ * | [<-()] E_SDK_VERSION_DATE TYPE STRING * +-------------------------------------------------------------------------------------- method get_sdk_version_date. e_sdk_version_date = '20191002122844'. endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CLASSIFY * +-------------------------------------------------------------------------------------------------+ * | [--->] I_classifier_id TYPE STRING * | [--->] I_body TYPE T_CLASSIFY_INPUT * | [--->] I_contenttype TYPE string (default ='application/json') * | [--->] I_accept TYPE string (default ='application/json') * | [<---] E_RESPONSE TYPE T_CLASSIFICATION * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method CLASSIFY. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers/{classifier_id}/classify'. replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_classifier_id ignoring case. "" standard headers ls_request_prop-header_content_type = I_contenttype. ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" process body parameters data: lv_body type string, lv_bodyparam type string, lv_datatype type char. field-symbols: type any. lv_separator = ''. lv_datatype = get_datatype( i_body ). if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or ls_request_prop-header_content_type cp '*json*'. if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. lv_bodyparam = abap_to_json( i_value = i_body i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). else. lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_body ). endif. lv_body = lv_body && lv_separator && lv_bodyparam. else. assign i_body to . lv_bodyparam = . concatenate lv_body lv_bodyparam into lv_body. endif. if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. lv_body = `{` && lv_body && `}`. endif. if ls_request_prop-header_content_type cp '*charset=utf-8*'. ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). replace all occurrences of regex ';\\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. else. ls_request_prop-body = lv_body. endif. "" execute HTTP POST request lo_response = HTTP_POST( i_request_prop = ls_request_prop ). "" retrieve JSON data lv_json = get_response_string( lo_response ). parse_json( exporting i_json = lv_json i_dictionary = c_abapname_dictionary changing c_abap = e_response ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CLASSIFY_COLLECTION * +-------------------------------------------------------------------------------------------------+ * | [--->] I_classifier_id TYPE STRING * | [--->] I_body TYPE T_CLASSIFY_COLLECTION_INPUT * | [--->] I_contenttype TYPE string (default ='application/json') * | [--->] I_accept TYPE string (default ='application/json') * | [<---] E_RESPONSE TYPE T_CLASSIFICATION_COLLECTION * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method CLASSIFY_COLLECTION. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers/{classifier_id}/classify_collection'. replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_classifier_id ignoring case. "" standard headers ls_request_prop-header_content_type = I_contenttype. ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" process body parameters data: lv_body type string, lv_bodyparam type string, lv_datatype type char. field-symbols: type any. lv_separator = ''. lv_datatype = get_datatype( i_body ). if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or ls_request_prop-header_content_type cp '*json*'. if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. lv_bodyparam = abap_to_json( i_value = i_body i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). else. lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_body ). endif. lv_body = lv_body && lv_separator && lv_bodyparam. else. assign i_body to . lv_bodyparam = . concatenate lv_body lv_bodyparam into lv_body. endif. if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. lv_body = `{` && lv_body && `}`. endif. if ls_request_prop-header_content_type cp '*charset=utf-8*'. ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). replace all occurrences of regex ';\\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. else. ls_request_prop-body = lv_body. endif. "" execute HTTP POST request lo_response = HTTP_POST( i_request_prop = ls_request_prop ). "" retrieve JSON data lv_json = get_response_string( lo_response ). parse_json( exporting i_json = lv_json i_dictionary = c_abapname_dictionary changing c_abap = e_response ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CREATE_CLASSIFIER * +-------------------------------------------------------------------------------------------------+ * | [--->] I_training_metadata TYPE FILE * | [--->] I_training_data TYPE FILE * | [--->] I_training_metadata_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) * | [--->] I_training_data_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) * | [--->] I_contenttype TYPE string (default ='multipart/form-data') * | [--->] I_accept TYPE string (default ='application/json') * | [<---] E_RESPONSE TYPE T_CLASSIFIER * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method CREATE_CLASSIFIER. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers'. "" standard headers ls_request_prop-header_content_type = I_contenttype. ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" process form parameters data: ls_form_part type ts_form_part, lt_form_part type tt_form_part, lv_formdata type string value is initial ##NEEDED, lv_value type string ##NEEDED, lv_index(3) type n value '000' ##NEEDED, lv_keypattern type string ##NEEDED, lv_base_name type string ##NEEDED, lv_extension type string ##NEEDED. if not i_training_metadata is initial. lv_extension = get_file_extension( I_training_metadata_CT ). lv_value = `form-data; name=""training_metadata""; filename=""file` && lv_index && `.` && lv_extension && `""` ##NO_TEXT. lv_index = lv_index + 1. clear ls_form_part. ls_form_part-content_type = I_training_metadata_CT. ls_form_part-content_disposition = lv_value. ls_form_part-xdata = i_training_metadata. append ls_form_part to lt_form_part. endif. if not i_training_data is initial. lv_extension = get_file_extension( I_training_data_CT ). lv_value = `form-data; name=""training_data""; filename=""file` && lv_index && `.` && lv_extension && `""` ##NO_TEXT. lv_index = lv_index + 1. clear ls_form_part. ls_form_part-content_type = I_training_data_CT. ls_form_part-content_disposition = lv_value. ls_form_part-xdata = i_training_data. append ls_form_part to lt_form_part. endif. "" execute HTTP POST request lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). "" retrieve JSON data lv_json = get_response_string( lo_response ). parse_json( exporting i_json = lv_json i_dictionary = c_abapname_dictionary changing c_abap = e_response ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->LIST_CLASSIFIERS * +-------------------------------------------------------------------------------------------------+ * | [--->] I_accept TYPE string (default ='application/json') * | [<---] E_RESPONSE TYPE T_CLASSIFIER_LIST * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method LIST_CLASSIFIERS. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers'. "" standard headers ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" execute HTTP GET request lo_response = HTTP_GET( i_request_prop = ls_request_prop ). "" retrieve JSON data lv_json = get_response_string( lo_response ). parse_json( exporting i_json = lv_json i_dictionary = c_abapname_dictionary changing c_abap = e_response ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_CLASSIFIER * +-------------------------------------------------------------------------------------------------+ * | [--->] I_classifier_id TYPE STRING * | [--->] I_accept TYPE string (default ='application/json') * | [<---] E_RESPONSE TYPE T_CLASSIFIER * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method GET_CLASSIFIER. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers/{classifier_id}'. replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_classifier_id ignoring case. "" standard headers ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" execute HTTP GET request lo_response = HTTP_GET( i_request_prop = ls_request_prop ). "" retrieve JSON data lv_json = get_response_string( lo_response ). parse_json( exporting i_json = lv_json i_dictionary = c_abapname_dictionary changing c_abap = e_response ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->DELETE_CLASSIFIER * +-------------------------------------------------------------------------------------------------+ * | [--->] I_classifier_id TYPE STRING * | [--->] I_accept TYPE string (default ='application/json') * | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION * +-------------------------------------------------------------------------------------- method DELETE_CLASSIFIER. data: ls_request_prop type ts_request_prop, lv_separator(1) type c ##NEEDED, lv_sep(1) type c ##NEEDED, lo_response type to_rest_response, lv_json type string ##NEEDED. ls_request_prop-url-path = '/v1/classifiers/{classifier_id}'. replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_classifier_id ignoring case. "" standard headers ls_request_prop-header_accept = I_accept. set_default_query_parameters( changing c_url = ls_request_prop-url ). "" execute HTTP DELETE request lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). endmethod. * ---------------------------------------------------------------------------------------+ * | Instance Private Method ZCL_IBMC_NAT_LANG_CLASS_V1->SET_DEFAULT_QUERY_PARAMETERS * +-------------------------------------------------------------------------------------------------+ * | [<-->] C_URL TYPE TS_URL * +-------------------------------------------------------------------------------------- method set_default_query_parameters. endmethod. ENDCLASS. ",5758,False,988.3632092709248,median " list p=16f877 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _CPD_OFF & _LVP_OFF #include cblock 0x20 COUNTH COUNTM COUNTL Table_Counter lcd_tmp lcd_d1 lcd_d2 com dat ; was in sample code count ; used to convert optime to decimal for display ones ; ones digit of the converted binary number tens ; tens digit of the converted binary number huns ; hundreds digit of the converted binary number (hopefully not used) binary_num ; move optime to this variable to allow binary --> decimal for display w_temp ; saves the value in the working register status_temp ; saves the current state of the status register (for ISR) barrel1:4 barrel2:4 ;41 barrel3:4 ;44 barrel4:4 ;47 barrel5:4 ;50 barrel6:4 ;53 barrel7:4 ;56 ;1: Stores Tall/Short Barrel, Stores E/HF/F ;2: Location (stores distance < 256 cm) ;3: Location (if distance > 256 cm) barrelnum ;current barrel number barreltemp option_temp Delay1 Delay2 TIMCNT voltage_IR counter_IR lastop_IR ;checks last operation of IR IR_DETECT Time_High Time_Low ad_store dis_counter ;increments to 17 for the encoder dis_counter4 ;increments to 4 before incrementing 17 times for the encoder min:2 ;temporary registers for operation time sec:2 initmin:2 initsec:2 finalmin:2 finalsec:2 armextend ;set to 1 when arm extended Dis_Ones Dis_Tens Dis_Hunds Dis_Thous ultra_time threshold_time barrel_data endc cblock 0x70 COUNTH1 ;const used in delay COUNTM1 ;const used in delay COUNTL1 ;const used in delay endc ;Declare constants for pin assignments (LCD on PORTD) #define RS PORTD,2 #define E PORTD,3 ;ANALOG PINS #define IR1 PORTA,0 #define IR2 PORTA,1 #define IR3 PORTA,2 #define IR4 PORTA,3 #define IR5 PORTA,5 #define IR6 PORTE,0 #define IR7 PORTE,1 #define IR8 PORTE,2 ;DIGITAL PINS #define DCA1 PORTC,1 ;DC motor A1 PWM #define DCA2 PORTC,0 ;DC motor A2 #define DCB1 PORTC,2 ;DC motor B1 PWM #define DCB2 PORTD,5 ;DC motor B2 ;A7 #define DCC1 PORTD,6 ;DC motor C1 #define DCC2 PORTD,4 ;DC motor C2 #define US_TRIG PORTC,5 ;Ultrasonic TRIGGER #define US_ECHO PORTC,6 ;Ultrasonic ECHO #define LS PORTC,7 ;Laser Sensor Bottom - Digital ;#define LSH PORTD,1 ;Laser Sensor Top - Digital #define ES PORTD,0 ;encoder sensor ORG 0x0000 ;RESET vector must always be at 0x00 goto init ;Just jump to the main code section. ;DCB??? ;*************************************** ; Delay: ~160us macro ;*************************************** LCD_DELAY macro movlw 0xFF movwf lcd_d1 decfsz lcd_d1,f goto $-1 endm ;*************************************** ; Display macro ;*************************************** Display macro Message local loop_ local end_ clrf Table_Counter clrw loop_ movf Table_Counter,W call Message xorlw B'00000000' ;check WORK reg to see if 0 is returned btfsc STATUS,Z goto end_ call WR_DATA incf Table_Counter,F goto loop_ end_ endm bank0 macro bcf STATUS, RP0 bcf STATUS, RP1 endm bank1 macro bcf STATUS, RP0 bsf STATUS, RP1 endm bank2 macro bsf STATUS, RP0 bcf STATUS, RP1 endm bank3 macro bsf STATUS, RP0 bcf STATUS, RP1 endm binconv macro movwf binary_num call BIN2BCD movf huns,W call WR_DATA movf tens,W call WR_DATA movf ones,W call WR_DATA endm ;*************************************** ; Initialize LCD ;*************************************** init clrf INTCON ; No interrupts ; bsf INTCON, GIE ; enable global interrupts ; bsf INTCON, 5 ; enable timer 0 interrupts ; bcf INTCON, 4 ; clear timer0 interrupt flag ; bcf INTCON, 2 ; disable internal interrupts (from Port B) ; bcf INTCON, 1 ; clear internal interrupt flag. ; NEED TO FIX THESE SETTINGS bsf STATUS,RP0 ; select bank 1 movlw b'00101111' ; set RA4 as output movlw b'11111011' ; Set required keypad inputs movwf TRISB clrf TRISC ; All port C is output ;Set SDA and SCL to high-Z first as required for I2C bsf TRISC,4 bsf TRISC,3 bsf TRISC,7 bsf TRISC,6 ;US_ECHO clrf TRISD bsf TRISD,0 ;the encoder is an input bsf TRISD,1 movlw b'00000111' ;set RE0-3 as input for IR sensors movwf TRISE bcf STATUS,RP0 ; select bank 0 clrf PORTA clrf PORTB clrf PORTC clrf PORTD clrf PORTE ;Set up I2C for communication call i2c_common_setup ;rtc_resetAll ;Used to set up time in RTC, load to the PIC when RTC is used for the first time call set_rtc_time call InitLCD ;Initialize the LCD (code in lcd.asm; imported by lcd.inc) ; Set up Pulse Width Modulation (PWM) bsf STATUS,RP0 ; Bank1 movlw b'11111001' ; Configure PR2 with 10 kHz movwf PR2 bcf STATUS,RP0 ; Bank0 movlw b'00001111' ; Configure RC1 and RC2 as PWM outputs movwf CCP2CON ; RC1 movwf CCP1CON movlw b'00000100' ; Configure Timer2 movwf T2CON ; Set to prescaler 1:1, postscaler 1:1 , enabled movwf T1CON ; Initialize motor variable clrf CCPR2L ; Set RC1 to 0% duty cycle clrf CCPR1L ;bcf PORTB,0 ;bcf PORTC,0 ;bcf PORTC,2 ;bsf PORTC,5 ;bcf PORTC,6 ;*************************************** ; Main code ;*************************************** Main btfss PORTB, 1 goto $-1 Display Welcome_Msg1 btfsc PORTB, 1 ;check if cleared goto $-1 btfss PORTB, 1 goto $-1 call Switch_Lines Display Welcome_Msg2 test btfss PORTB, 1 ;check for input from KEYPAD goto $-1 ;if NOT, keep polling swapf PORTB, W ;when input is detected, swamp nibbles ;PORTB <7-4> moved to <3-0> in w andlw 0x0F xorlw b'00001100' ;checks if 12th key is pressed * btfss STATUS, Z ;if pressed, then Z=1 goto test ;if NOT, then keep checking until * is pressed btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto START ;*************************************** ; Look up table ;*************************************** Welcome_Msg1 addwf PCL,F dt ""Welcome!"", 0 Welcome_Msg2 addwf PCL,F dt ""Press * to Start"", 0 Message1 addwf PCL,F dt ""T"", 0 Message2 addwf PCL,F dt "" B:"", 0 Message3 addwf PCL,F dt ""Press * to Reset"", 0 Message4 addwf PCL,F dt ""Press # for Info"", 0 Message5 addwf PCL,F dt "" TP:"", 0 Message6 addwf PCL,F dt ""L:"", 0 Message7 addwf PCL,F dt ""D:"", 0 Message8 addwf PCL,F dt "" OT"", 0 ;*************************************** ; OPERATION CODE ;*************************************** START call Clear_Display ;initializing ;intialize barrel1/2/3/4/5/6/7 movlw b'01011000' ;ASCII X movwf barrel1 movwf barrel2 movwf barrel3 movwf barrel4 movwf barrel5 movwf barrel6 movwf barrel7 ;intialize barrel1/2/3/4/5/6/7 + 1 movlw b'00100011' ;# movwf barrel1+1 movwf barrel2+1 movwf barrel3+1 movwf barrel4+1 movwf barrel5+1 movwf barrel6+1 movwf barrel7+1 movwf barrel1+2 movwf barrel2+2 movwf barrel3+2 movwf barrel4+2 movwf barrel5+2 movwf barrel6+2 movwf barrel7+2 movwf barrel1+3 movwf barrel2+3 movwf barrel3+3 movwf barrel4+3 movwf barrel5+3 movwf barrel6+3 movwf barrel7+3 movlw d'0' movwf barrelnum movwf barreltemp movlw b'00110000' movwf Dis_Ones movlw b'00110000' movwf Dis_Tens movlw b'00110000' movwf Dis_Hunds movlw b'00110000' movwf Dis_Thous movlw d'0' movwf IR_DETECT movwf threshold_time bsf STATUS, C ;preset C to 1 movlw b'0' movwf Time_High movlw b'0' movwf Time_Low movwf dis_counter movwf dis_counter4 ;check if ALl the IRs work ;TEST_IR ; call CHECK_IR1 ; movfw IR_DETECT ; call CHECK_DETECT ; ; call CHECK_IR2 ; movfw IR_DETECT ; call CHECK_DETECT ; ; call CHECK_IR3 ; movfw IR_DETECT ; call CHECK_DETECT ; ; call CHECK_IR4 ; movfw IR_DETECT ; call CHECK_DETECT ; ; call Clear_Display ; goto TEST_IR ; ; ;CHECK_DETECT ; xorlw b'1' ; btfss STATUS,Z ; goto SHOWLOW ; call SHOWHIGH ;CHECK_EXIT ; return ; ;SHOWHIGH ; movlw '1' ; call WR_DATA ; return ; ; ;SHOWLOW ; movlw '0' ; call WR_DATA ; goto CHECK_EXIT ; OPERATION_ENCODER movlw b'0' ;reset the counter movwf dis_counter ;call Clear_Display btfss ES ;check if ES gets a HIGH goto OPERATION_ENCODER ;call DISTANCECALL17 ;check if 4 divisions are counted incf dis_counter4 movfw dis_counter4 xorlw d'4' btfss STATUS, Z ;Z=1 when dis_counter4=4 goto OPERATION_ENCODER call DISTANCECALL17 goto OPERATION_ENCODER DISTANCECALL17 movlw b'0' movwf dis_counter4 movfw dis_counter xorlw d'17' ;Z=1 if dis_counter=17 btfsc STATUS,Z return ;if Z=1, return call Distance_Count incf dis_counter goto DISTANCECALL17 ; OPERATION_START ;call Realtime ;call CHECK_DISTANCE ;btfsc STATUS, C ;if not set, then continue ;goto END_OPERATION ;if set, then turn back ;btfss ES ;check if Encoder Sensor detects ;goto START1; if doesn't detect, continue ;call Distance_Count ;if so, increment the Distance START1 ;DISTANCE DISPLAY FOR DEBUGGING ONLY ;movlw "" "" ;call WR_DATA ;movfw Dis_Hunds ;call WR_DATA ;movfw Dis_Tens ;call WR_DATA ;movfw Dis_Ones ;call WR_DATA ;call Clear_Display ;DISTANCE DISPLAY FOR DEBUGGING ONLY ;movfw armextend ;xorlw b'0' ;btfss STATUS,Z ;goto RETRACT_ARM_BACK ;else, retract arm ;at this point, it is clear we have no obstructions, turn on the motors ;turn on the left motor, turn on the right motor call MOTOR_ON_RC1 call MOTOR_ON_RC2 ;*************TEST* ;call RETRACT_ARM_BACK ;just to see the arm rotate back and forth with delay of 1 second ;*************TEST* ;we continue to operate until any of the 8 IR sensors detects something and ;at the same time, we are detecting if there is a column w/ the ultrasonic sesnor ;this is effectively a VERY FAST poll that checks between the IR sensors and the ultrasonic sensors CHECK_IRSENSORS ;checks all 8 IR sensors call CHECK_IR1 movfw IR_DETECT call CHECK_DETECT call CHECK_IR2 movfw IR_DETECT call CHECK_DETECT call CHECK_IR3 movfw IR_DETECT call CHECK_DETECT call CHECK_IR4 movfw IR_DETECT call CHECK_DETECT call CHECK_IR5 movfw IR_DETECT call CHECK_DETECT call CHECK_IR6 movfw IR_DETECT call CHECK_DETECT call CHECK_IR7 movfw IR_DETECT call CHECK_DETECT call CHECK_IR8 movfw IR_DETECT call CHECK_DETECT ;if none sensors detected, check US sensor goto CHECK_US CHECK_DETECT xorlw b'1' btfss STATUS,Z ;Z=1 if IR_DETECT = 1 return ; if Z=0, return and check the next sensor goto DETECTED ;if detected, check US ;;PURPOSE: Checks the ultrasonic, if detects it, it will stop the motors, rotate the arm ;; ;and them come back and turn the motors back on so that it can ;; ;continue to check for barrels again ;; ;if does not detect, then it will jump to keeping the motors on and ;; ;continue to check for barrels again CHECK_US call ULTRASONIC ;C is set when Time_High > 3 movlw b'11' ;3 subwf Time_High,W btfss STATUS, C call RETRACT_ARM_BACK ;this means C<3, retract arm call MOTOR_ON_RC1 call MOTOR_ON_RC2 goto CHECK_IRSENSORS ;this means C>3, go back to checking DETECTED ;at this point, the LSL has been detected, so stop the motors call MOTOR_BOTH_OFF ;now check if the LSH detects anything, if it does, it means it is a ;large barrel, if not, then it is a small barrel btfss LS; if the laser detects AND the IR sensors detect, it is a large barrel goto SHORTBARREL ;it is a short barrel goto TALLBARRELL ;it is a large barel ;at this point, done recording and continue with operation goto OPERATION_START END_OPERATION ;turn back call RETRACT_ARM ;reset the distance movlw b'00110000' movwf Dis_Ones movlw b'00110000' movwf Dis_Tens movlw b'00110000' movwf Dis_Hunds END_LOOP ;add in to retrieve final operation time bsf DCA ;turn on motos to travel back bsf DCB call CHECK_DISTANCE btfss STATUS, C ;if set, then end goto END_LOOP ;if not, keep going bcf DCA ;turn off DC motors bcf DCB goto END_DISPLAY ;exit END_DISPLAY call Clear_Display Display Message3 call Switch_Lines Display Message4 CHECK_PRESS1 btfss PORTB, 1 ;check for input from KEYPAD goto $-1 ;if NOT, keep polling swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F goto OPTION1 OPTION1 ;checks if * was pressed movwf option_temp xorlw b'00001100' ; Check to see if 12th key btfss STATUS,Z ; If status Z goes to 0, it is the 13th key, skip goto OPTION2 ; If not check if it's B call Clear_Display goto Main ; If it is, restart OPTION2 ;checks if # was pressed movf option_temp, W xorlw b'00001110' btfss STATUS,Z goto CHECK_PRESS1 ;resume polling call Clear_Display btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto POLL1 POLL1 btfss PORTB, 1 ;check for input from KEYPAD goto Polltime1 ;if no input, poll INFO swapf PORTB, W ;when input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS1 ;check which key was pressed Polltime1 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""1"" ;displays barrel # call WR_DATA Display Message5 movfw barrel1 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel1 call Check_Height Display Message7 movfw barrel1+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel1+2 call WR_DATA movfw barrel1+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL1 CHECKPRESS1 BACKWARD1 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD1 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL7 FORWARD1 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL1 ;resume polling call Clear_Display goto POLL2 ;*************************************** ; BARREL2 ;*************************************** POLL2 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime2 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS2 Polltime2 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""2"" ;displays barrel # call WR_DATA Display Message5 movfw barrel2 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel2 call Check_Height Display Message7 movfw barrel2+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel2+2 call WR_DATA movfw barrel2+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL2 CHECKPRESS2 BACKWARD2 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD2 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL1 FORWARD2 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL2 ;resume polling call Clear_Display goto POLL3 ;*************************************** ; BARREL3 ;*************************************** POLL3 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime3 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS3 Polltime3 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""3"" ;displays barrel # call WR_DATA Display Message5 movfw barrel3 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel3 call Check_Height Display Message7 movfw barrel3+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel3+2 call WR_DATA movfw barrel3+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL3 CHECKPRESS3 BACKWARD3 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD3 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL2 FORWARD3 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL2 ;resume polling call Clear_Display goto POLL4 ;*************************************** ; BARREL4 ;*************************************** POLL4 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime4 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS4 Polltime4 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""4"" ;displays barrel # call WR_DATA Display Message5 movfw barrel4 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel4 call Check_Height Display Message7 movfw barrel4+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel4+2 call WR_DATA movfw barrel4+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL4 CHECKPRESS4 BACKWARD4 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD4 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL3 FORWARD4 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL4 ;resume polling call Clear_Display goto POLL5 ;*************************************** ; BARREL5 ;*************************************** POLL5 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime5 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS5 Polltime5 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""5"" ;displays barrel # call WR_DATA Display Message5 movfw barrel5 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel5 call Check_Height Display Message7 movfw barrel5+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel5+2 call WR_DATA movfw barrel5+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL5 CHECKPRESS5 BACKWARD5 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD5 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL4 FORWARD5 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL5 ;resume polling call Clear_Display goto POLL6 ;*************************************** ; BARREL6 ;*************************************** POLL6 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime6 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS6 Polltime6 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""6"" ;displays barrel # call WR_DATA Display Message5 movfw barrel6 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel6 call Check_Height Display Message7 movfw barrel6+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel6+2 call WR_DATA movfw barrel6+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL6 CHECKPRESS6 BACKWARD6 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD6 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL5 FORWARD6 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL6 ;resume polling call Clear_Display goto POLL7 ;*************************************** ; BARREL7 ;*************************************** POLL7 btfss PORTB, 1 ;check for input from KEYPAD ;goto $-1 ;if NOT, keep polling goto Polltime7 swapf PORTB, W ;When input is detected, read it in to W andlw 0x0F btfsc PORTB, 1 ;keep iterating until key is released goto $-1 goto CHECKPRESS7 Polltime7 movlw ""T"" ;displays T for Real Time call WR_DATA call Realtime ;displays Real Time Display Message2 ;displays B: movlw ""7"" ;displays barrel # call WR_DATA Display Message5 movfw barrel7 ;T/S/E/HF/F call Check_Type call Switch_Lines Display Message6 movfw barrel7 call Check_Height Display Message7 movfw barrel7+3 ;ten digit first, how is this stored? Leave as O's for now call WR_DATA movfw barrel7+2 call WR_DATA movfw barrel7+1 call WR_DATA Display Message8 call HalfS call Clear_Display goto POLL7 CHECKPRESS7 BACKWARD7 ;checks if 1 was pressed movwf option_temp xorlw b'00000000' ;checks to see if ""1"" was pressed btfss STATUS,Z ;if status Z goes to 0, it is not ""1"" goto FORWARD7 ;if not, check to see if ""2"" was pressed call Clear_Display goto POLL6 FORWARD7 ;checks if 2 was pressed movf option_temp, W xorlw b'00000001' btfss STATUS,Z goto POLL7 ;resume polling call Clear_Display goto POLL1 goto $ ;1: Stores Tall/Short Barrel, Stores E/HF/F ;2: Location (stores distance < 256 cm) ;3: Location (if distance > 256 cm) ;; ;; ;; ;;ShiftDisplayLeft ; ;call Clear_Display ; ;; Display Welcome_Msg2 ;;ChangeToQuestionMark ;; movlw b'11001011' ;; call WR_INS ;; movlw ""?"" ;; call WR_DATA ; ; ; ;;Left movlw b'00011000' ;Move to the left ;; call WR_INS ;; call HalfS ;; goto Left ;repeat operation ;; ;*************************************** ; MAIN PROGRAM SUBROUTINES ;*************************************** ;*************************************** ; IR SENSOR CODE ;*************************************** CHECK_IR1 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11000001' ;to select IR1 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR2 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11001001' ;to select IR2 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR3 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11010001' ;to select IR3 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR4 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11011001' ;to select IR4 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR5 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11100001' ;to select IR5 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR6 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11101001' ;to select IR6 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR7 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11110001' ;to select IR7 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE CHECK_IR8 ;initialize IR_DETECT movlw b'0' movwf IR_DETECT movlw b'11111001' ;to select IR8 movwf ad_store movfw ad_store call IR_MAINLOOP return ;GO BACK TO OPERATION CODE IR_MAINLOOP movfw ad_store ;storing the ADCON value call AD_CONV movwf voltage_IR call CHECK_IR btfss STATUS,C goto DISPLAYCHECKHIGH goto DISPLAYLOW return ;C is set when voltage >= 4.1 CHECK_IR movlw b'10111101' subwf voltage_IR,W return DISPLAYLOW movlw d'0' movwf lastop_IR movlw b'0' movwf IR_DETECT return DISPLAYCHECKHIGH movfw lastop_IR ;check if last call was a 1 xorlw d'1' btfsc STATUS, Z goto INCREMENT_IR ;if it is, increment movlw d'1' ;else, set lastop = 1 movwf lastop_IR movlw d'1' ;set counter = 1 movwf counter_IR goto IR_MAINLOOP ;return INCREMENT_IR movfw counter_IR xorlw d'4' btfsc STATUS,Z goto DISPLAYHIGH incf counter_IR movfw counter_IR xorlw d'4' btfsc STATUS,Z goto DISPLAYHIGH goto IR_MAINLOOP ;return DISPLAYHIGH movlw b'1' movwf IR_DETECT return ;*************************************** ; ULTRASONIC SENSOR CODE ;*************************************** ULTRASONIC movlw d'16' ;initialize timer module movwf T1CON movlw d'0' movwf TMR1L movlw d'0' movwf TMR1H bsf US_TRIG ;10us TRIGGER HIGH call DelayL bcf US_TRIG ;TRIGGER LOW btfss US_ECHO ;waiting to detect echo (HIGH) goto $-1 bsf T1CON, 0 ;turn timer on / TMR1ON=1 btfsc US_ECHO ;waiting for echo to go LOW goto $-1 bcf T1CON, 0 ;turn timer off movfw TMR1L movwf Time_Low movfw TMR1H movwf Time_High return ;;*************************************** ;; ENCODER SUBROUTINE ;;*************************************** ;; ;; btfss PORTB, 1 ;; goto $-1 ;; call Clear_Display ;; call Distance_Count ;; movfw Dis_Hunds ;; call WR_DATA ;; movfw Dis_Tens ;; call WR_DATA ;; movfw Dis_Ones ;; call WR_DATA ;; btfsc PORTB, 1 ;; goto $-1 ;; goto TEST_ENCODER ;; goto $ ; ;*************************************** ; DISTANCE COUNT SUBROUTINE ;*************************************** Distance_Count ;movlw 0x0C ;Wait to begin ;Keypad movfw Dis_Ones xorlw b'00111001' btfsc STATUS,Z goto Skip_Ten incf Dis_Ones,1 return Skip_Ten movfw Dis_Tens xorlw b'00111001' btfsc STATUS,Z goto Skip_Hund incf Dis_Tens,1 movlw b'00110000' movwf Dis_Ones return Skip_Hund movfw Dis_Hunds xorlw b'00111001' ;ASCII 9 btfsc STATUS,Z goto Skip_Thou incf Dis_Hunds,1 movlw b'00110000' movwf Dis_Ones movwf Dis_Tens return Skip_Thou incf Dis_Thous,1 movlw b'00110000' ;ASCII 0 movwf Dis_Ones movwf Dis_Tens movwf Dis_Hunds return ;;*************************************** ;; RETRACT ARM SUBROUTINE ;;*************************************** ; ;RETRACT_ARM_BACK ; ;bcf DCA1 ;turn off wheel motors ; ;bcf DCB1 ;turn off wheel motors ; bcf DCC1 ; bsf DCC2 ;turn on DC motor ; ;for X seconds, need to be tested ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; ; bcf DCC2 ;turn off DC motor ; ; ; ;dont move for 3 seconds ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; ; bsf DCC1 ; bcf DCC2 ;reverse arm DC direction ; ; ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; ; bcf DCC1 ; ; ; return ;*TEST RETRACT_ARM FOR DEMO* ;RETRACT_ARM_BACK ; bcf DCC1 ; bsf DCC2 ;turn on DC motor ; ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; ; ; bsf DCC1 ; bcf DCC2 ;reverse arm DC direction ; ; ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; call HalfS ; ; ; ; return ; ;*************************************** ; CHECK DISTANCE SUBROUTINE ;*************************************** CHECK_DISTANCE movfw Dis_Hunds ;this must be <=4 movlw b'00110100' ;max value for the hundreds place subwf Dis_Hunds, W ;Dis_Hunds <- Dis_Hunds - 4 return ;*************************************** ; SHORTBARREL SUBROUTINE ;*************************************** SHORTBARREL incf barrelnum, 1 ;increment barrel count call CHECK_IR1 ;check if IR1 detects movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto SHORTBARREL1 ;IR1 does not detect, then check IR5 goto SFULLORHALF ;IR1 detects, at this point, the barrel is either FULL or HALFFULL SHORTBARREL1 call CHECK_IR5 ;check if IR5 detects movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto RECORD_SE ;IR1 and IR5 both don't detect, it is SMALL+EMPTY goto SFULLORHALF ;IR5 detects, at this point, the barrel is either FULL or HALFFULL SFULLORHALF call CHECK_IR3 ;check if IR3 detects movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto SFULLORHALF1 ;IR3 does not detect, check IR7 on the other side goto RECORD_SF ;IR3 detects, it must be SMALL + FULL SFULLORHALF1 call CHECK_IR7 ;check if IR7 detects movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto RECORD_SHF ;IR3 and IR7 does not detect, but either IR1 or IR5 detected, so this must be SMALL + HALFFULL goto RECORD_SF ;IR7 detects, it must be SMALL + FULL ;*************************************** ; TALLBARREL SUBROUTINE ;*************************************** TALLBARRELL incf barrelnum, 1 call CHECK_IR2 ;check if IR2 detects movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto TALLBARRELL1 ;if IR2 does not detect, check IR6 on the other side of the arm goto TFULLORHALF ;if IR2 detects, the barrel is either FULL or HALFFULL TALLBARRELL1 call CHECK_IR6 movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto RECORD_TE ;if IR6 does not detect either, it must be EMPTY goto TFULLORHALF ;if IR6 detects, the barrel is either FULL or HALFFULL TFULLORHALF call CHECK_IR4 movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto TFULLORHALF1 ;if IR4 does not detect, check IR8 on the other side of the arm goto RECORD_TF ;if IR4 detects, it must be TALL + FULL TFULLORHALF1 call CHECK_IR8 movfw IR_DETECT xorlw b'1' btfss STATUS, Z goto RECORD_THF ;if IR8 does not detect either, it must be TALL + HALLFULL goto RECORD_TF ;if IR8 detects, it is TALL + FULL ;*************************************** ; MOVE INFO TO BARREL_DATA SUBROUTINE ;*************************************** RECORD_SE movlw b'00001100' ;(S=1/T=0)/E/HF/F movwf barrel_data ;store it so it can be recorded goto RECORD RECORD_SHF movlw b'00001010' movwf barrel_data goto RECORD RECORD_SF movlw b'00001001' movwf barrel_data goto RECORD RECORD_TE movlw b'00000100' movwf barrel_data goto RECORD RECORD_THF movlw b'00000010' movwf barrel_data goto RECORD RECORD_TF movlw b'00000001' movwf barrel_data goto RECORD ;*************************************** ; MAIN RECORD ;*************************************** RECORD ;main record ;first need to determine which barrel it is B_ONE movfw barrelnum ;move barrelnum to working register xorlw b'00000001' ; 1 btfsc STATUS, Z goto RECORD_ONE goto B_TWO B_TWO movfw barrelnum xorlw b'00000010' ; 2 btfsc STATUS, Z goto RECORD_TWO goto B_THREE B_THREE movfw barrelnum xorlw b'00000011' ;3 btfsc STATUS, Z goto RECORD_THREE goto B_FOUR B_FOUR movfw barrelnum xorlw b'00000100' ;4 btfsc STATUS, Z goto RECORD_FOUR goto B_FIVE B_FIVE movfw barrelnum xorlw b'00000101' ;5 btfsc STATUS, Z goto RECORD_FIVE goto B_SIX B_SIX movfw barrelnum xorlw b'00000110' ;6 btfsc STATUS, Z goto RECORD_SIX goto B_SEVEN B_SEVEN goto RECORD_SEVEN ;has to be barrel 7 at this point ;*************************************** ; RECORD WHEN BARREL NUMBER IS KNOWN ;*************************************** RECORD_ONE ;stores the E/HF/F bits movfw barrel_data movwf barrel1 ;move the data into barrel1, althought only the last three move bits are important goto OPERATION_START ;go back to program RECORD_TWO movfw barrel_data movwf barrel2 goto OPERATION_START RECORD_THREE movfw barrel_data movwf barrel3 goto OPERATION_START RECORD_FOUR movfw barrel_data movwf barrel4 goto OPERATION_START RECORD_FIVE movfw barrel_data movwf barrel5 goto OPERATION_START RECORD_SIX movfw barrel_data movwf barrel6 goto OPERATION_START RECORD_SEVEN movfw barrel_data movwf barrel7 goto OPERATION_START ;*************************************** ; ULTRASONIC DELAYS (10 us) ;*************************************** DelayL movlw 0x30 ; b'00110000' movwf 0x53 ; general purpose register CONT3L decfsz 0x53, f goto CONT3L return ;*************************************** ; MOTOR SUBROUTINE (PWM) ;*************************************** MOTOR_ON_RC1 movlw b'11111111' movwf CCPR2L bsf PORTC, 1 return MOTOR_ON_RC2 movlw b'11111111' movwf CCPR1L bsf PORTC,2 return MOTOR_BOTH_OFF movlw b'00000000' movwf CCPR2L movwf CCPR1L return ;100% 11111111 255 ;80% 11000111 199 ;60% 10010101 149 ;0% 00000000 ;*************************************** ; LCD control ;*************************************** Switch_Lines movlw B'11000000' call WR_INS return Clear_Display movlw B'00000001' call WR_INS return ;*************************************** ; Delay 0.5s ;*************************************** HalfS local HalfS_0 movlw 0x88 movwf COUNTH movlw 0xBD movwf COUNTM movlw 0x03 movwf COUNTL HalfS_0 decfsz COUNTH, f goto $+2 decfsz COUNTM, f goto $+2 decfsz COUNTL, f goto HalfS_0 goto $+1 nop nop return ;*************************************** ; STORING BARREL INFO ON LCD SUBROUTINE ;*************************************** Check_Type CHECKE movwf barreltemp ;STORE IT TEMPORARY, LEST XORLW WILL ALTER IT ;check if barrel has been accessed movfw barreltemp xorlw b'01011000' ;ASCII X btfsc STATUS, Z ;Z=1 if ASCII X goto PRINTDEFAULT ;Z=1, so display X movfw barreltemp ;Z!=1, so continue btfss barreltemp,2 goto CHECKHF movlw ""E"" call WR_DATA return CHECKHF movfw barreltemp btfss barreltemp,1 goto CHECKF movlw ""H"" call WR_DATA movlw ""F"" call WR_DATA return CHECKF ;must be FULL at this point movlw ""F"" call WR_DATA return PRINTDEFAULT movlw ""X"" call WR_DATA return Check_Height CHECKSHORT movwf barreltemp ;STORE IN HERE TEMPORARILY ;check if barrel has been accessed movfw barreltemp xorlw b'01011000' ;ASCII X btfsc STATUS, Z ;Z=1 if ASCII X goto PRINTDEFAULT1 ;Z=1, so display X movfw barreltemp ;Z!=1, so continue btfss barreltemp,3 goto CHECKTALL movlw ""S"" call WR_DATA movlw "" "" call WR_DATA return CHECKTALL ;must be TALL at this point movlw ""T"" call WR_DATA movlw "" "" call WR_DATA return PRINTDEFAULT1 movlw ""X"" call WR_DATA movlw "" "" call WR_DATA return ;******* LCD-related subroutines ******* ;*********************************** InitLCD bcf STATUS,RP0 bsf E ;E default high ;Wait for LCD POR to finish (~15ms) call lcdLongDelay call lcdLongDelay call lcdLongDelay ;Ensure 8-bit mode first (no way to immediately guarantee 4-bit mode) ; -> Send b'0011' 3 times movlw b'00110011' call WR_INS call lcdLongDelay call lcdLongDelay movlw b'00110010' call WR_INS call lcdLongDelay call lcdLongDelay ; 4 bits, 2 lines, 5x7 dots movlw b'00101000' call WR_INS call lcdLongDelay call lcdLongDelay ; display on/off movlw b'00001100' call WR_INS call lcdLongDelay call lcdLongDelay ; Entry mode movlw b'00000110' call WR_INS call lcdLongDelay call lcdLongDelay ; Clear ram movlw b'00000001' call WR_INS call lcdLongDelay call lcdLongDelay return ;************************************ ;ClrLCD: Clear the LCD display ClrLCD movlw B'00000001' call WR_INS return ;**************************************** ; Write command to LCD - Input : W , output : - ;**************************************** WR_INS bcf RS ;clear RS movwf com ;W --> com andlw 0xF0 ;mask 4 bits MSB w = X0 movwf PORTD ;Send 4 bits MSB bsf E ; call lcdLongDelay ;__ __ bcf E ; |__| swapf com,w andlw 0xF0 ;1111 0010 movwf PORTD ;send 4 bits LSB bsf E ; call lcdLongDelay ;__ __ bcf E ; |__| call lcdLongDelay return ;**************************************** ; Write data to LCD - Input : W , output : - ;**************************************** WR_DATA bsf RS movwf dat movf dat,w andlw 0xF0 addlw 4 movwf PORTD bsf E ; call lcdLongDelay ;__ __ bcf E ; |__| swapf dat,w andlw 0xF0 addlw 4 movwf PORTD bsf E ; call lcdLongDelay ;__ __ bcf E ; |__| return lcdLongDelay movlw d'20' movwf lcd_d2 LLD_LOOP LCD_DELAY decfsz lcd_d2,f goto LLD_LOOP return ;********* ; BIN2BCD ; Converts a binary number to ASCII ; characters for display on the LCD ; Written by: A. Borowski ; Sourced from: piclist.com --> 8 bit to ASCII Decimal 3 digits ;********** BIN2BCD movlw 8 movwf count clrf huns clrf tens clrf ones BCDADD3 movlw 5 subwf huns, 0 btfsc STATUS, C CALL ADD3HUNS movlw 5 subwf tens, 0 btfsc STATUS, C CALL ADD3TENS movlw 5 subwf ones, 0 btfsc STATUS, C CALL ADD3ONES decf count, 1 bcf STATUS, C rlf binary_num, 1 rlf ones, 1 btfsc ones,4 ; CALL CARRYONES rlf tens, 1 btfsc tens,4 ; CALL CARRYTENS rlf huns,1 bcf STATUS, C movf count, 0 btfss STATUS, Z goto BCDADD3 movf huns, 0 ; add ASCII Offset addlw h'30' movwf huns movf tens, 0 ; add ASCII Offset addlw h'30' movwf tens movf ones, 0 ; add ASCII Offset addlw h'30' movwf ones return ADD3HUNS movlw 3 addwf huns,1 return ADD3TENS movlw 3 addwf tens,1 return ADD3ONES movlw 3 addwf ones,1 return CARRYONES bcf ones, 4 bsf STATUS, C return CARRYTENS bcf tens, 4 bsf STATUS, C return ;call AD_CONV ;call WR_DATA ;call HalfS ;call Clear_Display ;goto Main ;********* ; ADC ;********** goto INITA INITA bsf STATUS,RP0 ;select bank 1 bcf INTCON,GIE ;disable global interrupt movlw B'00000000' ;configure ADCON1 movwf ADCON1 clrf TRISB ;configure PORTB as output bcf STATUS,RP0 ;select bank 0 goto ADSTART ;*************************************************************** ; MAIN PROGRAM ;*************************************************************** ADSTART call AD_CONV ;call the A2D subroutine movwf PORTB ;display the high 8-bit result to the LEDs ENDLP goto ENDLP ;endless loop ;*************************************************************** ; AD CONVERT ROUTINE ;*************************************************************** AD_CONV ;movlw B'10000001' ;configure ADCON0 movwf ADCON0 call TIM20 ;wait for required acquisition time bsf ADCON0,GO ;start the conversion WAIT btfsc ADCON0,GO ;wait until the conversion is completed goto WAIT ;poll the GO bit in ADCON0 movf ADRESH,W ;move the high 8-bit to W return ;************************************************************** ; TIME DELAY ROUTINE FOR 20us ; ; - delay of 400 cycles ; - 400*0.05us = 20us ;************************************************************** TIM20 movlw 084H ;1 cycle movwf TIMCNT ;1 cycle TIMLP decfsz TIMCNT,F ;(3*132)-1 = 395 cycles goto TIMLP nop ;1 cycle return ;2 cycles ;*************************************** ; Real Time ;*************************************** show_RTC ;clear LCD screen movlw b'00000001' call WR_INS ;Get year ;movlw ""2"" ;First line shows 20**/**/** ;call WR_DATA ;movlw ""0"" ;call WR_DATA ;rtc_read 0x06 ;Read Address 0x06 from DS1307---year ;movfw 0x77 ;call WR_DATA ;movfw 0x78 ;call WR_DATA ;movlw ""/"" ;call WR_DATA ;Get month ;rtc_read 0x05 ;Read Address 0x05 from DS1307---month ;movfw 0x77 ;call WR_DATA ;movfw 0x78 ;call WR_DATA ;movlw ""/"" ;call WR_DATA ;Get day ;rtc_read 0x04 ;Read Address 0x04 from DS1307---day ;movfw 0x77 ;call WR_DATA ;movfw 0x78 ;call WR_DATA ;movlw B'11000000' ;Next line displays (hour):(min):(sec) **:**:** ;call WR_INS ;NEXT LINE ;Get hour ;rtc_read 0x02 ;Read Address 0x02 from DS1307---hour ;movfw 0x77 ;call WR_DATA ;movfw 0x78 ;call WR_DATA ;movlw "":"" ;call WR_DATA ;Get minute Realtime rtc_read 0x01 ;Read Address 0x01 from DS1307---min movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA movlw "":"" call WR_DATA ;Get seconds rtc_read 0x00 ;Read Address 0x00 from DS1307---seconds movfw 0x77 call WR_DATA movfw 0x78 call WR_DATA return call OneS ;Delay for exactly one seconds and read DS1307 again goto show_RTC Operationtime rtc_read 0x01 ;Read Address 0x01 from DS1307---min movfw 0x77 movwf min ;call WR_DATA movfw 0x78 movwf min+1 ;call WR_DATA ;movlw "":"" ;call WR_DATA ;Get seconds rtc_read 0x00 ;Read Address 0x00 from DS1307---seconds movfw 0x77 movwf sec ;call WR_DATA movfw 0x78 movwf sec+1 ;call WR_DATA return ;call OneS ;Delay for exactly one seconds and read DS1307 again ;goto show_RTC ;;*************************************** ;; Setup RTC with time defined by user ;;*************************************** set_rtc_time ;rtc_resetAll ;reset rtc ;rtc_set 0x00, B'10000000' ;set time ;rtc_set 0x06, B'00010000' ; Year ;rtc_set 0x05, B'00000100' ; Month ;rtc_set 0x04, B'00000110' ; Date ;rtc_set 0x03, B'00000010' ; Day ;rtc_set 0x02, B'00010010' ; Hours ;rtc_set 0x01, B'00110000' ; Minutes ;rtc_set 0x00, B'00000000' ; Seconds ;return ;*************************************** ; Delay 1s ;*************************************** OneS local OneS_0 movlw 0x10 movwf COUNTH1 movlw 0x7A movwf COUNTM1 movlw 0x06 movwf COUNTL1 OneS_0 decfsz COUNTH1, f goto $+2 decfsz COUNTM1, f goto $+2 decfsz COUNTL1, f goto OneS_0 goto $+1 nop nop return END ",16313,True,3153.910140762434,median "COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1994 -- All Rights Reserved PROJECT: Clavin MODULE: Driver map -- implementation FILE: dmapCode.asm AUTHOR: Adam de Boor, Mar 30, 1994 ROUTINES: Name Description ---- ----------- EXT DMapAlloc Allocate & initialize a driver map EXT DMapRegisterFileChange Register a driver map for file-change notificaiton EXT DMapInit Prepare a driver map for a new GEOS session. INT DMapMarkDirChanged Cope with the driver directory having changed. INT DMapGetDriverDirIDs Fetch the FilePathIDs for the directories that currently make up the driver directory, for use in handling file-change notification. INT DMapLock Lock a DMap down and point DS to it. INT DMapPopDirAndUnlock Pop the current directory stack & unlock the DMap INT DMapSearchCallback Callback function for DMapSearchMap to find an entry with an appropriate token. INT DMapSearchMap Search the map for a driver with the given token. INT DMapEnumFindByName See if the current entry has the same name as the current file. If so, stop enumerating (which will cause the file to be rejected) INT DMapEnumCallback Callback routine to make sure we're not finding a driver we've already seen before. INT DMapEnumPerformEnum Perform the actual FileEnum to look for drivers we've not seen before. INT DMapEnumFetchToken Open the given driver and fetch its 32-bit token from the dword after the DriverInfoStruct. INT DMapEnumAddDriver Add the current DriverMapEntry to the end of the array INT DMapEnumForDriver Look in the filesystem for a driver with a particular token INT DMapFindDriver Locate or create an entry for the driver with the passed token. INT DMapFindDriverLow Look for a driver entry now the map is locked down EXT DMapCheckExists See if the system contains a driver with the given 32-bit token. EXT DMapLoad Load the driver with the given 32-bit token. INT DMapLoadCallCallback Call the passed callback, if it's for the driver just loaded EXT DMapGetAttributes Retrieve the attributes word for the given driver. The attributes follow immediately the 32-bit token in the driver's DriverTable EXT DMapGetDriverHandle Retrive the handle of a driver that is already loaded EXT DMapUnload Unloads a driver EXT DMapGetAllTokens Retrieve the tokens of all known drivers in the passed map. If DMF_DRIVER_DIR_CHANGED, then driver directory is rescanned for new transports. INT DMapGetAllTokensCallback Callback function to fetch all the tokens stored in a driver map. EXT DMapRegisterLoadCallback Register a callback routine for when the driver for the indicated token next gets loaded. EXT DMapFileChange Take note of a change in the filesystem to see if we should update the DMF_DRIVER_DIR_CHANGED flag INT DMapMarkChangedIfIDMatches Something's changed in the filesystem that could mean a new driver is available for the map. See if the disk & id in the notification corresponds to one of the FilePathIDs for the driver directory. If it does, then flag the directory as having changed. INT DMapStandardPathAdded Note that another standard path has been added, which might (if the affected path is an ancestor of the driver directory) mean there are more drivers. REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 3/30/94 Initial revision DESCRIPTION: Implementation of the DMap abstraction $Id: dmapCode.asm,v 1.1 97/04/05 01:19:39 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ Init segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapAlloc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Allocate & initialize a driver map CALLED BY: (EXTERNAL) PASS: ds:si = pointer to GeodeToken to match es:di = subdirectory of SP_SYSTEM in which to look ax = major protocol number expected from drivers bx = minor protocol number expected cx = entry number of routine to call when driver added to the map dl = DMapFlags RETURN: ax = map handle for subsequent calls DESTROYED: bx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapAlloc proc near tokenPtr local fptr.GeodeToken push ds, si subdir local fptr.char push es, di proto local ProtocolNumber push bx, ax initFunc local word push cx result local word uses cx, si, di, ds, es .enter ; ; Error-check the parameters. ; EC < cmp cx, DMAP_NO_INIT_ROUTINE > EC < je initRoutineOk > EC < mov ax, cx > EC < mov bx, handle 0 > EC < call ProcGetLibraryEntry ; let this ec the thing > EC Assert fptr, dssi Assert fptr, esdi Assert record, dl, DMapFlags ; ; Allocate a block in the admin file for the beast. ; call MailboxGetAdminFile ; bx <- file ; ; Compute the size (*not* the length) of the path below SP_SYSTEM, so ; we know how big to make the map's header. ; LocalStrSize includeNull ; cx <- # bytes in es:di add cx, size DriverMapHeader; cx <- # bytes of header ; (includes LMemBlockHeader) mov ax, LMEM_TYPE_GENERAL call VMAllocLMem mov ss:[result], ax ; ; Now gain exclusive access to the block. ; push bp call VMLock pop bp mov es, ax ; for upcoming movsbs ; ; Copy the path below SP_SYSTEM to the end of the header while we've got ; the total header size in CX still. ; ; XXX: Should we parse this down to a std path and store the SP + path? ; It would be more general, and take care if we ever make these things ; std paths in their own right... ; sub cx, size DriverMapHeader; cx <- # bytes in path lds si, ss:[subdir] mov di, offset DMH_sysPath rep movsb ; ; Shift the protocol number into the header. ; movdw es:[DMH_protocol], ss:[proto], ax ; ; Copy the GeodeToken there as well. ; lds si, ss:[tokenPtr] mov di, offset DMH_token mov cx, size GeodeToken rep movsb ; ; Store the init routine in the header ; mov ax, ss:[initFunc] mov es:[DMH_init], ax ; ; Create an array for DriverMapEntry structures. ; segmov ds, es EC < segmov es, cs ; so it's not pointing to map> EC < ; in case it moves during> EC < ; DMapMarkDirChanged > push bx mov bx, size DriverMapEntry clr si, cx ; allocate chunk, please and ; use default header call ChunkArrayCreate EC < cmp si, ds:[LMBH_offset] > EC < ERROR_NE DMAP_ALLOCATED_ARRAY_NOT_FIRST_CHUNK > ; ; Create an array for DriverMapCallback structures. ; mov bx, size DriverMapCallback clr si, cx call ChunkArrayCreate pop bx mov ds:[DMH_callbacks], si ; ; Initialize the flags. ; mov ds:[DMH_flags], dl ; ; Initialize DMH_fcnIDs -- the actual ids will be gotten when ; DMapInit is called, later. ; mov ds:[DMH_fcnIDs], 0 ; ; No error messages known for any driver yet. ; mov ds:[DMH_errMsgs], 0 ; ; Set the user ID properly (primarily for EC). ; mov ax, ss:[result] ; ax <- map handle mov cx, MBVMID_DRIVER_MAP call VMModifyUserID ; ; Perform initial scan, if necessary, else mark as scan needed. ; call DMapMarkDirChanged ; ; Array is now initialized. ; call UtilVMDirtyDS call UtilVMUnlockDS .leave ret DMapAlloc endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapRegisterFileChange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Register a driver map for file-change notification. CALLED BY: (EXTERNAL) AdminInit PASS: ax = map handle RETURN: nothing DESTROYED: cx, dx SIDE EFFECTS: map is registered for file-change notification PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- AY 4/25/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapRegisterFileChange proc near ; ; Register a callback function for file-change notification ; (callback isn't saved to state, so we have to register at the ; start of each session, and we can use a vseg...) ; mov cx, vseg DMapFileChange mov dx, offset DMapFileChange call UtilRegisterFileChangeCallback ret DMapRegisterFileChange endp Init ends DMap segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapInit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Prepare a driver map for a new GEOS session. CALLED BY: (EXTERNAL) PASS: ax = map handle RETURN: nothing DESTROYED: ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapInit proc far uses ds, si, cx, dx .enter ; ; Lock down the map so we can play. ; call DMapLock ; ; Fix the chunk array of DriverMapEntry's and the chunk array of ; DriverMapCallback. ; call UtilFixChunkArrayFar mov_tr ax, si mov si, ds:[DMH_callbacks] call UtilFixChunkArrayFar mov_tr si, ax ; ; Mark all existing drivers not loaded. ; call DMapMarkDriversNotLoaded ; ; Force a scan on next search for unknown token, as who knows what ; happened to the directory while we were gone. ; call DMapMarkDirChanged ; ; Fetch the FilePathIDs for the driver dir. ; call DMapGetDriverDirIDs ; ; Release the map. ; call UtilVMDirtyDS call UtilVMUnlockDS .leave ret DMapInit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapMarkDriversNotLoaded %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Mark that no existing drivers are loaded. CALLED BY: (INTERNAL) DMapInit PASS: *ds:si = driver map RETURN: nothing DESTROYED: nothing SIDE EFFECTS: block is NOT marked dirty even though things are changed. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- AY 1/ 5/95 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapMarkDriversNotLoaded proc near uses bx,di .enter mov bx, cs mov di, offset DMapMarkDriversNotLoadedCB call ChunkArrayEnum .leave ret DMapMarkDriversNotLoaded endp DMapMarkDriversNotLoadedCB proc far and ds:[di].DME_handle, 0 ; 4 bytes (shorter than clr), also ; clears CF ret DMapMarkDriversNotLoadedCB endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapMarkDirChanged %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Cope with the driver directory having changed. CALLED BY: (INTERNAL) DMapInit, DMapMarkChangedIfIDMatches, DMapStandardPathAdded PASS: ds = dmap segment RETURN: ds = fixed up (NOT marked dirty -- assume caller will in a moment) DESTROYED: nothing SIDE EFFECTS: either DMF_DRIVER_DIR_CHANGED is set in DMH_flags or, if DMF_AUTO_DETECT, driver directory will be scanned and drivers possibly added PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapMarkDirChanged proc far uses cx, dx, si, ax, bx .enter ornf ds:[DMH_flags], mask DMF_DRIVER_DIR_CHANGED test ds:[DMH_flags], mask DMF_AUTO_DETECT jnz processDir done: .leave ret processDir: ; ; Search for an impossible token (Geoworks manufacturer ID + -1 for the ; ID number) ; clr cx mov dx, -1 mov si, ds:[LMBH_offset] call DMapFindDriverLow call FilePopDir jmp done DMapMarkDirChanged endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapGetDriverDirIDs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Fetch the FilePathIDs for the directories that currently make up the driver directory, for use in handling file-change notification. CALLED BY: (INTERNAL) DMapInit PASS: ds = locked driver map RETURN: nothing DESTROYED: ax SIDE EFFECTS: existing ds:[DMH_fcnIDs] is freed and replaced by a new one, if possible (set to 0 if driver dir doesn't exist) block is *not* marked dirty PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapGetDriverDirIDs proc near uses bx, dx .enter ; ; Nuke old array, if present, leaving header field 0. ; clr ax xchg ds:[DMH_fcnIDs], ax tst ax jz getIDs call LMemFree getIDs: ; ; Change to driver directory. ; call FilePushDir mov bx, SP_SYSTEM mov dx, offset DMH_sysPath call FileSetCurrentPath jc popDirDone ; ; Go fetch all the id's for the directory. ; call FileGetCurrentPathIDs jc popDirDone mov ds:[DMH_fcnIDs], ax popDirDone: call FilePopDir .leave ret DMapGetDriverDirIDs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapLock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock a DMap down and point DS to it. CALLED BY: (INTERNAL) PASS: ax = driver map handle RETURN: *ds:si = locked map DESTROYED: nothing SIDE EFFECTS: map is locked for exclusive access PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 6/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapLock proc near uses bp, ax, bx .enter call MailboxGetAdminFile EC < call ECVMCheckVMFile > EC < push ax, cx, di > EC < call VMInfo > EC < ERROR_C INVALID_DMAP_HANDLE > EC < cmp di, MBVMID_DRIVER_MAP > EC < ERROR_NE INVALID_DMAP_HANDLE > EC < pop ax, cx, di > call VMLock mov ds, ax mov si, ds:[LMBH_offset] EC < call ECLMemValidateHeap > EC < call ECLMemValidateHandle > .leave ret DMapLock endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapPopDirAndUnlock %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Pop the current directory stack & unlock the DMap CALLED BY: (INTERNAL) DMapCheckExists, DMapLoad, DMapGetAttributes PASS: ds = locked DMap RETURN: nothing DESTROYED: nothing (flags preserved) SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapPopDirAndUnlock proc near call FilePopDir call UtilVMUnlockDS ret DMapPopDirAndUnlock endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapSearchCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback function for DMapSearchMap to find an entry with an appropriate token. CALLED BY: (INTERNAL) DMapSearchMap via ChunkArrayEnum PASS: ds:di = DriverMapEntry ax = index of current element cxdx = token being sought RETURN: carry set if element found (stop enum): ax = index of current element carry clear if element not found (keep going): ax = index of next element DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapSearchCallback proc far .enter ; ; See if the token sought matches the entry. ; cmpdw ds:[di].DME_token, cxdx stc ; assume yes, so stop enum & leave ; elt counter alone je done inc ax ; not it, so advance elt counter for clc ; next callback and keep enumerating done: .leave ret DMapSearchCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapSearchMap %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Search the map for a driver with the given token. CALLED BY: (INTERNAL) DMapFindDriver PASS: *ds:si = map ChunkArray cxdx = token for which we seek RETURN: carry set if no entry for the token ax = destroyed carry clear if found entry: ds:si = DriverMapEntry ax = element # DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapSearchMap proc near uses bx, di .enter clr ax ; start elt counter at 0 mov bx, cs mov di, offset cs:DMapSearchCallback call ChunkArrayEnum cmc ; get CF set if found, but want t'other jc done ; ; Deref the element, since we found it. ; call ChunkArrayElementToPtr mov si, di done: .leave ret DMapSearchMap endp DMapEnumParams struct DMEP_common FileEnumParams DMEP_matchAttrs FileExtAttrDesc 2 dup(<>) DMEP_returnAttrs FileExtAttrDesc 2 dup(<>) DMapEnumParams ends COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumFindByName %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: See if the current entry has the same name as the current file. If so, stop enumerating (which will cause the file to be rejected) CALLED BY: (INTERNAL) DMapEnumCallback via ChunkArrayEnum PASS: ds:di = DriverMapEntry es:dx = name of current file RETURN: carry set on match (stop enumerating) DESTROYED: si, di, ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumFindByName proc far .enter lea si, ds:[di].DME_name mov di, dx compareLoop: DBCS < lodsw > DBCS < scasw > SBCS < lodsb > SBCS < scasb > clc ; assume no match jne done DBCS < tst ax > SBCS < tst al > jnz compareLoop stc done: .leave ret DMapEnumFindByName endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback routine to make sure we're not finding a driver we've already seen before. CALLED BY: (INTERNAL) DMapEnumPerformEnum via FileEnum PASS: ds = FileEnumCallbackData bp = inherited stack frame RETURN: carry set to reject the file carry clear to accept the file DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumCallback proc far params:DMapEnumParams uses ax, ds, bx, di, es, cx .enter inherit far mov ax, FEA_NAME mov si, offset FECD_attrs call FileEnumLocateAttr EC < ERROR_C NAME_ATTRIBUTE_NOT_GIVEN_TO_ENUM_CALLBACK > EC < tst es:[di].FEAD_value.segment > EC < ERROR_Z FILE_HAS_NO_NAME_ATTRIBUTE > les dx, es:[di].FEAD_value mov bx, cs mov di, offset cs:DMapEnumFindByName lds si, ss:[params].DMEP_common.FEP_cbData1 call ChunkArrayEnum ; carry <- set on match ; => reject .leave ret DMapEnumCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumPerformEnum %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform the actual FileEnum to look for drivers we've not seen before. CALLED BY: (INTERNAL) DMapEnumForDriver PASS: *ds:si = map RETURN: carry set if error or no new drivers found: bx, ax = destroyed carry clear if found at least one new driver: bx = handle of block holding DriverMapEntry structures ax = # drivers found DESTROYED: nothing SIDE EFFECTS: Current thread left pushed to the directory holding the drivers. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumPerformEnum proc near uses cx, dx, bp .enter ; ; If the directory hasn't changed since the last complete enum, ; don't bother. ; test ds:[DMH_flags], mask DMF_DRIVER_DIR_CHANGED jz noneFound ; ; Make room for the massive numbers of parameters for FileEnum, plus ; our own additions. ; sub sp, size DMapEnumParams mov bp, sp ; ; Looking for GEOS executables only, and we're using a callback routine. ; mov ss:[bp].DMEP_common.FEP_searchFlags, mask FESF_GEOS_EXECS or mask FESF_CALLBACK ; ; Special return attributes, to place the FEA_NAME in the right place ; in the DriverMapEntry. ; lea ax, ss:[bp].DMEP_returnAttrs mov ss:[bp].DMEP_common.FEP_returnAttrs.offset, ax mov ss:[bp].DMEP_common.FEP_returnAttrs.segment, ss mov ss:[bp].DMEP_returnAttrs[0].FEAD_attr, FEA_NAME mov ss:[bp].DMEP_returnAttrs[0].FEAD_value.offset, \\ offset DME_name mov ss:[bp].DMEP_returnAttrs[0].FEAD_size, size DME_name mov ss:[bp].DMEP_returnAttrs[1*FileExtAttrDesc].FEAD_attr,\\ FEA_END_OF_LIST ; ; Each returned structure is a DriverMapEntry, please. ; mov ss:[bp].DMEP_common.FEP_returnSize, size DriverMapEntry ; ; Make sure the thing's got the right token (as stored in the map's ; header). First point to the attribute array, then initialize said ; array. ; lea ax, ss:[bp].DMEP_matchAttrs mov ss:[bp].DMEP_common.FEP_matchAttrs.offset, ax mov ss:[bp].DMEP_common.FEP_matchAttrs.segment, ss mov ss:[bp].DMEP_matchAttrs[0].FEAD_attr, FEA_TOKEN mov ss:[bp].DMEP_matchAttrs[0].FEAD_value.offset, offset DMH_token mov ss:[bp].DMEP_matchAttrs[0].FEAD_value.segment, ds mov ss:[bp].DMEP_matchAttrs[0].FEAD_size, size GeodeToken mov ss:[bp].DMEP_matchAttrs[1*FileExtAttrDesc].FEAD_attr, FEA_END_OF_LIST ; ; Give us everything you can, please (never know where the driver might ; be, you know...) ; mov ss:[bp].DMEP_common.FEP_bufSize, FE_BUFSIZE_UNLIMITED ; ; Don't skip nuthin' ; mov ss:[bp].DMEP_common.FEP_skipCount, 0 ; ; Set up the callback, but we need no extra attributes. Pass the map's ; location in cbData1 ; mov ss:[bp].DMEP_common.FEP_callback.offset, offset cs:DMapEnumCallback mov ss:[bp].DMEP_common.FEP_callback.segment, SEGMENT_CS mov ss:[bp].DMEP_common.FEP_callbackAttrs.segment, 0 movdw ss:[bp].DMEP_common.FEP_cbData1, dssi ; ; Endlich! Call the silly routine. ; call FileEnum ; ; Clear off our additional stuff w/o messing with the carry. ; lea sp, ss:[bp+size DMapEnumParams] ; ; Return carry set on error or no drivers found. ; jc done mov_tr ax, cx ; return # drivers in ax tst_clc ax jnz done noneFound: stc done: .leave ret DMapEnumPerformEnum endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumFetchToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Open the given driver and fetch its 32-bit token from the dword after the DriverInfoStruct. CALLED BY: (INTERNAL) DMapEnumForDriver PASS: es:di = DriverMapEntry ds:0 - DriverMapHeader current dir = driver dir RETURN: carry set if couldn't get token carry clear if got token: es:di.DME_token = set DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumFetchToken proc near uses ax, bx, ds, dx, cx .enter ; ; First we need to open the driver file. Open it read-only and ; deny-write, just in case... ; push ds segmov ds, es lea dx, ds:[di].DME_name mov al, FileAccessFlags call FileOpen pop ds jc done ; ; On XIP systems, there will be a little stub file in the GFS so the ; transport drivers show up via FileEnum, but the actual geode lives ; in the XIP image. If we only find a stub file, then load and ; unload the geode from the XIP image. ; mov_tr bx, ax ; bx <- file handle call FileSize tst dx jnz notStub cmp ax, size GeosFileHeader jbe loadFromXIP notStub: ; ; Seek to the part of the header where the resource id & offset of ; the driver's DriverTable is stored. ; movdw cxdx, <(offset GFH_coreBlock.GH_driverTab)> mov al, FILE_POS_START call FilePos ; ; Now read in that dword. ; call readCXDX ; cx <- resid, dx <- offset jc closeDone ; => bogus ; ; Seek the file to the dword following the DriverInfoStruct, which is ; where the 32-bit token for the driver is stored. ; add dx, size DriverInfoStruct call GeodeFindResource ; ; Read in the token & the ""attributes"" for the driver. ; segmov ds, es lea dx, ds:[di].DME_token mov cx, size DME_token + size DME_attrs clr al call FileRead closeDone: pushf ; save error flag clr al ; allow errs on close...(as if...) call FileClose popf done: .leave ret loadFromXIP: ; ; Load the driver from the XIP image, copy the data from after the ; DriverInfoStruct record, then unload the geode... ; push bx, si, ds, di mov ax, ds:[DMH_protocol].PN_major mov bx, ds:[DMH_protocol].PN_minor segmov ds, es lea si, ds:[di].DME_name call GeodeUseDriver WARNING_C COULD_NOT_LOAD_DRIVER_FROM_XIP_IMAGE jc couldNotLoad call GeodeInfoDriver ;DS:SI <- ptr to DriverInfoStruct add si, size DriverInfoStruct mov cx, size DME_token + size DME_attrs .assert offset DME_token eq 0 rep movsb call GeodeFreeDriver clc couldNotLoad: pop bx, si, ds, di jmp closeDone ;-------------------- ; Read the four bytes at the current seek position into CXDX (high ; word into CX, low word into DX) ; ; Pass: bx = file handle ; Return: ds = ss ; carry set on error: ; ax = FileError ; carry clear if ok: ; cxdx = dword read ; ax = destroyed readCXDX: mov cx, size fptr ; cx <- # bytes to read sub sp, cx segmov ds, ss mov dx, sp ; ds:dx <- buffer clr al ; return errs, please call FileRead popdw cxdx ; cx <- resid, dx <- offset retn DMapEnumFetchToken endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumAddDriver %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Add the current DriverMapEntry to the end of the array CALLED BY: (INTERNAL) DMapEnumForDriver PASS: *ds:si = map array es:di = entry to add RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumAddDriver proc near uses ax, cx, si, di, es .enter ; ; Add an entry to the array. Might cause the block to move, of course. ; push es, di call ChunkArrayAppend ; ds:di <- new entry ; ; Move dem bytes... ; segmov es, ds ; es:di <- dest for move pop ds, si ; ds:si <- src for move mov cx, size DriverMapEntry ; cx <- # bytes rep movsb segmov ds, es ; ds <- DMap block again ; ; Call init routine, if one exists. ; mov ax, ds:[DMH_init] CheckHack inc ax je done ; ; Load registers: ; ds:si <- driver name (in current dir) ; cxdx <- driver token. ; dec ax push ds:[LMBH_handle] push dx, bx lea si, ds:[di-size DriverMapEntry].DME_name movdw cxdx, mov bx, handle 0 call ProcGetLibraryEntry ; bx:ax <- vfptr of routine pushdw bxax ; put routine on stack for call mov bx, ds:[LMBH_handle] call VMMemBlockToVMBlock ; ax <- VM block of map call PROCCALLFIXEDORMOVABLE_PASCAL pop dx, bx call MemDerefStackDS done: .leave ret DMapEnumAddDriver endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapEnumForDriver %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Look in the filesystem for a driver with a particular token CALLED BY: (INTERNAL) DMapFindDriver PASS: *ds:si = map array cxdx = token being sought current dir = driver dir RETURN: carry set if driver not found ax = destroyed carry clear if driver found: ds:si = DriverMapEntry ax = element # DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: enumerate all drivers, using a callback to screen the ones we've seen. results are DriverMapEntry structs for each new driver: open it find its DriverTable read its token close it store the token in the entry if token matches, break out store new entries we opened on the way to finding the one we want at the end of the array. the rest get discarded (we're assuming here that the stuff to read the token is more expensive than the enumeration, so it's best to stop once we find the driver, discarding the enum results, rather than spending the time to get the tokens for the remaining drivers) if new one found, return ds:si pointing to it REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapEnumForDriver proc near uses bp, di, bx, es .enter ; ; Find all the driver's we've not seen yet. ; call DMapEnumPerformEnum jc done ; => nothing new, so token not ; viable ; ; Now loop through the drivers found. ; push ax call MemLock mov es, ax pop ax clr di ; es:di <- current DriverMapEntry xchg ax, cx ; cx <- # drivers, ax <- token.high driverLoop: ; ; Fetch the token from the current driver. ; call DMapEnumFetchToken jc nextDriver ; => couldn't get token, so ignore ; the driver (wouldn't be able to ; load it anyway, if we can't open ; the darn thing...) ; ; DriverMapEntry now complete -- append it to the array. ; clr es:[di].DME_handle ; driver not loaded yet call DMapEnumAddDriver ; ; See if the token matches the one for which we seek. ; cmpdw axdx, es:[di].DME_token jne nextDriver ; ; It does. Point ds:si to the last entry in the array (which we just ; added). (es:di, you'll recall, points to the entry returned by ; FileEnum, which isn't useful to our caller.) ; call ChunkArrayGetCount dec cx ; cx <- index of last elt xchg ax, cx ; ax <- elt #, cx <- token.high call ChunkArrayElementToPtr ; ds:di <- elt mov si, di ; return it in ds:si, please xchg ax, cx ; ax <- token.high, cx <- elt # clc ; return success jmp doneLoop ; go free the enum block nextDriver: ; ; That wasn't the trick. Advance to the next driver we found. ; add di, size DriverMapEntry loop driverLoop ; ; No driver matched, so return an error after indicating we've ; gone through the entire directory. ; andnf ds:[DMH_flags], not mask DMF_DRIVER_DIR_CHANGED stc doneLoop: ; ; Free the FileEnum result block. ; pushf call MemFree call UtilVMDirtyDS popf xchg cx, ax ; restore token.high, and possibly ; return elt # (only if added) done: .leave ret DMapEnumForDriver endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapFindDriver %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Locate or create an entry for the driver with the passed token. CALLED BY: (INTERNAL) DMapCheckExists, DMapLoad PASS: cxdx = token for driver ax = map handle RETURN: ds = DMap block current directory pushed to that containing the drivers carry set if couldn't find entry ax = destroyed carry clear if found it: ds:si = DriverMapEntry ax = entry # DESTROYED: bx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapFindDriver proc near .enter ; ; Lock the data block for shared access, on the assumption we've ; already seen the token. ; call DMapLock ; *ds:si <- map call DMapFindDriverLow .leave ret DMapFindDriver endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapFindDriverLow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Look for a driver entry now the map is locked down CALLED BY: (INTERNAL) DMapFindDriver, DMapMarkDirChanged PASS: *ds:si = map array cxdx = token to look for RETURN: current directory pushed to that containing the drivers carry set if couldn't find entry ax = destroyed carry clear if found it: ds:si = DriverMapEntry ax = entry # DESTROYED: bx SIDE EFFECTS: PSEUDO CODE/STRATEGY: This function always pushes to the directory because it is most often used when loading a driver, or when looking for new drivers that have just been added to the system by adding a standard path. In both cases we'll need to be in the directory shortly after the call (when loading) or during the course of the call (when enumerating), so work isn't wasted most of the time. REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/11/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapFindDriverLow proc near .enter ; ; Push to the driver directory. ; push dx call FilePushDir mov dx, offset DMH_sysPath mov bx, SP_SYSTEM call FileSetCurrentPath pop dx ; token jc done call DMapSearchMap jnc done ; ; Still not there. Go look for the driver & add an entry for it. ; call DMapEnumForDriver done: .leave ret DMapFindDriverLow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapCheckExists %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: See if the system contains a driver with the given 32-bit token. CALLED BY: (EXTERNAL) PASS: cxdx = 32-bit token for which to search ax = handle of driver map RETURN: carry set if driver exists carry clear if driver does not exist DESTROYED: ax SIDE EFFECTS: DMap block may move if the driver has to be searched for and added to the map. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapCheckExists proc far uses ds, si, bx .enter ; ; Just use the common utility routine to locate the entry in the ; array or find the driver itself... ; call DMapFindDriver ; carry, ds:si <- result cmc ; want carry set if driver ; found ; ; Release the exclusive lock on the data block. ; call DMapPopDirAndUnlock .leave ret DMapCheckExists endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapLoad %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Load the driver with the given 32-bit token. CALLED BY: (EXTERNAL) MailboxLoadTransportDriver, MailboxLoadDataDriver PASS: cxdx = 32-bit token for driver ax = handle of driver map RETURN: carry set if couldn't load: ax = GeodeLoadError bx = destroyed carry clear if driver loaded: bx = driver handle ax = destroyed DESTROYED: nothing SIDE EFFECTS: DMap block may move if the driver has to be searched for and added to the map. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/30/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapLoad proc far uses ds, si, dx, di .enter ; ; Find or create the entry for the driver in the map. ; call DMapFindDriver jnc haveDriver mov ax, GLE_FILE_NOT_FOUND ; assume not there & couldn't ; be found jmp done haveDriver: ; ; Have an entry, and we're in the driver directory, so try and load the ; thing. ; add si, offset DME_name ; ds:si <- filename mov_tr dx, ax tryAgain: push dx mov ax, ds:[DMH_protocol].PN_major mov bx, ds:[DMH_protocol].PN_minor call GeodeUseDriver pop dx ; dx <- entry # jc checkErrMsg ; ; See if we need to store the handle. (We don't need to if the drive ; has been load earlier.) If not, we avoid marking the block dirty. ; cmp ds:[si - offset DME_name].DME_handle, bx je stored mov ds:[si - offset DME_name].DME_handle, bx call UtilVMDirtyDS stored: ; ; Driver loaded. Call any load-callbacks registered for the driver. ; test ds:[DMH_flags], mask DMF_HAVE_CALLBACK jz done push bx, cx lea dx, ds:[si-offset DME_name] mov cx, bx mov bx, cs mov di, offset DMapLoadCallCallback mov si, ds:[DMH_callbacks] call ChunkArrayEnum ; block marked dirty if some cb deleted ; ; Clear the DMF_HAVE_CALLBACK flag if no more callbacks. ; call ChunkArrayGetCount tst cx jnz callbacksLeft andnf ds:[DMH_flags], not mask DMF_HAVE_CALLBACK ; no need to mark block dirty because ; DMapLoadCallCallback has done so. callbacksLeft: pop bx, cx done: call DMapPopDirAndUnlock .leave ret checkErrMsg: cmp ax, GLE_FILE_NOT_FOUND stc jne done call DMapUseCustomError jc done jmp tryAgain DMapLoad endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapUseCustomError %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Put up a dialog with the custom error string for the driver, if there is one. CALLED BY: (INTERNAL) DMapLoad PASS: dx = entry # of driver that we attempted to load ds = dmap block RETURN: carry set if no custom error message or user doesn't want us to try again. carry clear if should try to load the driver again DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 11/ 7/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapUseCustomError proc near uses ax, bx, cx, dx, si, di, bp .enter ; ; Look for a custom error message for this driver. ; dx = entry # ; mov bx, offset DMH_errMsgs - offset DMEM_next findErrMsgLoop: mov bx, ds:[bx].DMEM_next tst bx jz noErrMsg mov bx, ds:[bx] cmp ds:[bx].DMEM_entry, dx jne findErrMsgLoop ; ; Found it. Put up an affirmation error box with our amusing triggers ; and the custom string. ; sub sp, size StandardDialogParams mov bp, sp mov ss:[bp].SDP_customFlags, CustomDialogBoxFlags < 1, ; CDBF_SYSTEM_MODAL CDT_ERROR, ; CDBF_DIALOG_TYPE GIT_AFFIRMATION, ; CDBF_INTERACTION_TYPE 0 ; CDBF_DESTRUCTIVE_ACTION > lea ax, ds:[bx].DMEM_msg movdw ss:[bp].SDP_customString, dsax clr ax ; no argument strings mov ss:[bp].SDP_stringArg1.segment, ax mov ss:[bp].SDP_stringArg2.segment, ax mov ss:[bp].SDP_customTriggers.segment, cs mov ss:[bp].SDP_customTriggers.offset, offset dmapDriverLoadErrorTriggerTable mov ss:[bp].SDP_helpContext.segment, cs mov ss:[bp].SDP_helpContext.offset, offset dmapDriverLoadErrorHelpContext push ds:[LMBH_handle] ; save for deref call UserStandardDialog pop bx call MemDerefDS ; ; If user answered yes (Done That), tell caller to retry the load. ; cmp ax, IC_YES je done noErrMsg: ; ; Anything else means don't retry -- just return the error. ; stc done: .leave ret DMapUseCustomError endp dmapDriverLoadErrorTriggerTable StandardDialogResponseTriggerTable < length dmapDriverLoadErrorTriggers > dmapDriverLoadErrorTriggers StandardDialogResponseTriggerEntry < uiDoneThatMoniker, IC_YES >, < uiGiveItUpMoniker, IC_NO > dmapDriverLoadErrorHelpContext char 'dbDriverLoadErr', 0 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapLoadCallCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call the passed callback, if it's for the driver just loaded CALLED BY: (INTERNAL) DMapLoad via ChunkArrayEnum PASS: ds:di = DriverMapCallback ds:dx = DriverMapEntry of just-loaded driver cx = handle of just-loaded driver RETURN: carry set to stop enumerating (always returned clear) DESTROYED: bx, si, di all allowed ax SIDE EFFECTS: block marked dirty if some callback is deleted. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapLoadCallCallback proc far .enter ; ; See if the callback is for this driver. ; mov bx, dx mov ax, ds:[bx].DME_token.low mov bx, ds:[bx].DME_token.high cmpdw bxax, ds:[di].DMC_token jne done ; no ; ; Fetch the vfptr for the routine to call and push it on the stack, ; as we need to pass something in BX. ; push si, cx, dx mov bx, handle 0 mov ax, ds:[di].DMC_routine call ProcGetLibraryEntry pushdw bxax ; ; Load the registers and issue the callback: ; bx <- driver handle ; cx <- CX passed to DMapRegisterLoadCallback ; dx <- DX passed to DMapRegisterLoadCallback ; mov bx, cx mov cx, ds:[di].DMC_cx mov dx, ds:[di].DMC_dx call PROCCALLFIXEDORMOVABLE_PASCAL pop si, cx, dx ; ; If carry clear, delete the callback from the array. ; Assert segment, ds ; make sure hasn't moved jc done call ChunkArrayDelete call UtilVMDirtyDS done: clc .leave ret DMapLoadCallCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapGetAttributes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Retrieve the attributes word for the given driver. The attributes follow immediately the 32-bit token in the driver's DriverTable CALLED BY: (EXTERNAL) PASS: cxdx = 32-bit token ax = map handle RETURN: carry set if no such driver: ax = destroyed carry clear if driver found: ax = attributes DESTROYED: nothing SIDE EFFECTS: DMapData block may move if the driver has to be searched for and added to the map. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/ 4/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapGetAttributes proc far uses ds, si, bx .enter ; ; Locate the driver, one way or another. ; call DMapFindDriver jc done ; ; Found it -- load up the attributes. ; mov ax, ds:[si].DME_attrs done: ; ; Release the DMapData block. ; call DMapPopDirAndUnlock .leave ret DMapGetAttributes endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapGetDriverHandle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Retrive the handle of a driver that is already loaded CALLED BY: (EXTERNAL) PASS: cxdx = 32-bit token of desired driver ax = map handle RETURN: carry set if no such driver, or driver not loaded carry clear if driver is loaded: bx = driver handle DESTROYED: nothing SIDE EFFECTS: none. This routine does NOT add new drivers found in the file system. It only searches whatever is already in the driver map. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- AY 8/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapGetDriverHandle proc far uses ax,si,ds .enter ; ; Search the map for DriverMapEntry ; call DMapLock ; *ds:si = driver map call DMapSearchMap ; ds:si = DriverMapEntry, CF jc unlock mov bx, ds:[si].DME_handle sub bx, 1 ; sets CF if bx = null (2 bytes) inc bx ; preserves CF (1 byte) unlock: call UtilVMUnlockDS ; flags preserved .leave ret DMapGetDriverHandle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapUnload %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Unloads a driver CALLED BY: (EXTERNAL) PASS: cxdx = 32-bit token of desired driver ax = map handle RETURN: carry set if driver exited DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- AY 8/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapUnload proc far uses bx,si,ds,ax .enter ; ; Search the map for DriverMapEntry ; call DMapLock ; *ds:si = driver map call DMapSearchMap ; ds:si = DriverMapEntry, CF mov bx, ds:[si].DME_handle EC < call ECCheckGeodeHandle > call GeodeFreeDriver jnc done mov ds:[si].DME_handle, 0 ; driver was exited, so clear the ; field out call UtilVMDirtyDS done: call UtilVMUnlockDS ; flags preserved .leave ret DMapUnload endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapGetAllTokens %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Retrieve the tokens of all known drivers in the passed map. If DMF_DRIVER_DIR_CHANGED, then driver directory is rescanned for new transports. CALLED BY: (EXTERNAL) MTAddMedium PASS: ds = lmem block in which to allocate array ax = map handle RETURN: *ds:ax = ChunkArray of 32-bit tokens for all known drivers DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapGetAllTokens proc far uses cx, bx, di, es, si .enter ; ; Create an array for the results. ; push ax mov bx, size dword clr cx, si, ax call ChunkArrayCreate segmov es, ds mov cx, si pop ax ; ; Lock down and enumerate the map. ; call DMapLock ; *ds:si <- map mov bx, cs mov di, offset DMapGetAllTokensCallback call ChunkArrayEnum call UtilVMUnlockDS ; ; Restore DS to the (possibly moved) segment containing the array and ; return the array chunk in AX, as promised. ; segmov ds, es mov_tr ax, cx .leave ret DMapGetAllTokens endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapGetAllTokensCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback function to fetch all the tokens stored in a driver map. CALLED BY: (INTERNAL) DMapGetAllTokens via ChunkArrayEnum PASS: ds:di = DriverMapEntry *es:cx = result array RETURN: carry set to stop enumerating (carry always clear) DESTROYED: bx, si, di allowed SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/13/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapGetAllTokensCallback proc far .enter mov bx, di segxchg ds, es ; es:bx <- DriverMapEntry mov si, cx ; *ds:si <- result array call ChunkArrayAppend; ds:di <- new element movdw ({dword}ds:[di]), es:[bx].DME_token, ax segxchg ds, es clc .leave ret DMapGetAllTokensCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapRegisterLoadCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Register a callback routine for when the driver for the indicated token next gets loaded. CALLED BY: (EXTERNAL) PASS: ax = map handle bx = entry # of routine to call Pass: cx, dx = as passed bx = driver handle Return: carry clear if callback may be deleted carry set if callback should be made again on next load Destroy:cx, dx cx, dx = data for callback sidi = 32-bit token of driver whose loading should trigger the callback RETURN: nothing DESTROYED: ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapRegisterLoadCallback proc far driver local dword push si, di uses ds, si, di .enter ; ; Validate the routine # ; EC < push ax, bx > EC < mov_tr ax, bx > EC < mov bx, handle 0 > EC < call ProcGetLibraryEntry > EC < pop ax, bx > call DMapLock ; ; Append an entry to the callback array for the map. ; mov si, ds:[DMH_callbacks] call ChunkArrayAppend ; ds:di <- new entry ; ; Copy the parameters into the new entry. ; movdw ds:[di].DMC_token, ss:[driver], ax mov ds:[di].DMC_routine, bx mov ds:[di].DMC_cx, cx mov ds:[di].DMC_dx, dx ; ; Set the flag so DMapLoad knows it needs to look through the array. ; ornf ds:[DMH_flags], mask DMF_HAVE_CALLBACK ; ; Release the map. ; call UtilVMDirtyDS call UtilVMUnlockDS .leave ret DMapRegisterLoadCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapFileChange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Take note of a change in the filesystem to see if we should update the DMF_DRIVER_DIR_CHANGED flag CALLED BY: (EXTERNAL) PASS: es:di = FileChangeNotificationData dx = FileChangeNotificationType ax = map handle RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapFileChange proc far .enter cmp dx, FCNT_CREATE je checkID cmp dx, FCNT_ADD_SP_DIRECTORY jne done call DMapStandardPathAdded done: .leave ret checkID: call DMapMarkChangedIfIDMatches jmp done DMapFileChange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapMarkChangedIfIDMatches %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Something's changed in the filesystem that could mean a new driver is available for the map. See if the disk & id in the notification corresponds to one of the FilePathIDs for the driver directory. If it does, then flag the directory as having changed. CALLED BY: (INTERNAL) DMapFileChange PASS: es:di = FileChangeNotificationData ax = map handle RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapMarkChangedIfIDMatches proc near uses ds, si, cx, dx, ax, bx .enter ; ; Point to the array of FilePathIDs. ; call DMapLock mov si, ds:[DMH_fcnIDs] tst si jz done ChunkSizeHandle ds, si, cx jcxz done ; ; Set up registers for the loop: ; ds:si <- current FilePathID to check ; ax <- disk from notification data ; bxdx <- ID from notification data ; cx = # bytes in the id array ; mov si, ds:[si] mov ax, es:[di].FCND_disk movdw bxdx, es:[di].FCND_id checkLoop: ; ; Check the components of the FilePathID against the notification data. ; cmp ax, ds:[si].FPID_disk jne nextID cmpdw bxdx, ds:[si].FPID_id je found nextID: ; ; Advance to the next ID, please. ; add si, size FilePathID sub cx, size FilePathID jnz checkLoop done: call UtilVMUnlockDS .leave ret found: ; ; The affected directory is the driver directory, so mark the thing ; as changed. ; call DMapMarkDirChanged call UtilVMDirtyDS jmp done DMapMarkChangedIfIDMatches endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapStandardPathAdded %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Note that another standard path has been added, which might (if the affected path is an ancestor of the driver directory) mean there are more drivers. CALLED BY: (INTERNAL) DMapFileChange PASS: es:di = FileChangeNotificationData ax = map handle RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 4/23/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapStandardPathAdded proc near uses bp, bx .enter mov bp, es:[di].FCND_disk ; bp <- path for which component ; was added ; ; If SP_SYSTEM got a new component, the driver directory could ; definitely have been affected. ; cmp bp, SP_SYSTEM je isAffected ; ; If SP_SYSTEM is a subdirectory of the affected directory, the ; directory could have been affected. ; mov bx, SP_SYSTEM push ax call FileStdPathCheckIfSubDir tst ax pop ax jz isAffected done: .leave ret isAffected: push ds, si call DMapLock call DMapMarkDirChanged call DMapGetDriverDirIDs call UtilVMDirtyDS call UtilVMUnlockDS pop ds, si jmp done DMapStandardPathAdded endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DMapStoreErrorMsg %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Store a custom error message for a driver. CALLED BY: (EXTERNAL) PASS: ax = map block handle cxdx = 32-bit token for the driver ^lbx:si = null-terminated error string to store RETURN: nothing DESTROYED: nothing SIDE EFFECTS: in the future, if the driver is loaded and cannot be found, the user will be prompted with this error string PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 11/ 7/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DMapStoreErrorMsg proc far errMsg local optr.char push bx, si uses ds, si, di, ax .enter call DMapLock call DMapSearchMap ; ax <- element # EC < ERROR_C CANNOT_REGISTER_ERROR_FOR_UNKNOWN_DRIVER > ; ; Nuke any existing message for the driver. ; mov si, offset DMH_errMsgs - offset DMEM_next findExistingLoop: mov bx, si mov si, ds:[bx].DMEM_next tst si jz createNew mov si, ds:[si] cmp ds:[si].DMEM_entry, ax jne findExistingLoop push ax mov ax, ds:[si].DMEM_next xchg ds:[bx].DMEM_next, ax call LMemFree pop ax createNew: ; ; Copy the string chunk in, leaving room for our beloved header ; movdw bxsi, ss:[errMsg] mov cx, size DriverMapErrMsg call UtilCopyChunkWithHeader ; ; Store the driver's entry number ; mov di, ds:[si] mov ds:[di].DMEM_entry, ax ; ; Link this error message as the head of the list. ; mov_tr ax, si xchg ds:[DMH_errMsgs], ax mov ds:[di].DMEM_next, ax .leave ret DMapStoreErrorMsg endp DMap ends ",16249,True,3829.7266836276995,median "/* ExtUTF8.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); u8g2.begin(); } const uint16_t my_kerning_table[] = { /* first char, second char, gap reduction value */ 0x646, 0x627, 4, /* ن and ا */ 0x627, 0x647, 5, /* ا and ه */ 0x647, 0x62C, 6, /* ه and ج */ 0x645, 0x627, 3, /* م and ا */ 0x627, 0x644, 4, /* ا and ل */ 0x644, 0x633, 2, /* ل and س */ /* this line terminates the table */ 0xffff, 0xffff, 0xffff }; void loop(void) { u8g2.firstPage(); do { u8g2.setFont(u8g2_font_unifont_t_arabic); u8g2.drawExtUTF8(120, 15, 1, NULL, ""سلام جهان""); /* Hello World */ u8g2.drawExtUTF8(120, 30, 1, my_kerning_table, ""سلام جهان""); /* Hello World */ } while ( u8g2.nextPage() ); //delay(1000); } ",12515,True,3773.7450092124336,median "############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 4, 0x90 POLY: .quad 0x1, 0xC200000000000000 TWOONE: .quad 0x1, 0x100000000 SHUF_CONST: .quad 0x8090a0b0c0d0e0f, 0x1020304050607 MASK1: .quad 0xffffffffffffffff, 0x0 MASK2: .quad 0x0, 0xffffffffffffffff INC_1: .quad 1,0 .p2align 4, 0x90 .globl _AesGcmPrecompute_avx _AesGcmPrecompute_avx: movdqu (%rsi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd TWOONE(%rip), %xmm4 pand POLY(%rip), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm3 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm3 pxor %xmm15, %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movdqu %xmm0, (%rdi) movdqu %xmm1, (16)(%rdi) movdqu %xmm2, (32)(%rdi) ret .p2align 4, 0x90 .globl _AesGcmMulGcm_avx _AesGcmMulGcm_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rsi), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) ret .p2align 4, 0x90 .globl _AesGcmAuth_avx _AesGcmAuth_avx: movdqa (%rdi), %xmm0 pshufb SHUF_CONST(%rip), %xmm0 movdqa (%rcx), %xmm1 movslq %edx, %rdx .p2align 4, 0x90 .Lauth_loopgas_3: movdqu (%rsi), %xmm2 pshufb SHUF_CONST(%rip), %xmm2 add $(16), %rsi pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %rdx jnz .Lauth_loopgas_3 pshufb SHUF_CONST(%rip), %xmm0 movdqa %xmm0, (%rdi) ret .p2align 4, 0x90 .globl _AesGcmEnc_avx _AesGcmEnc_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_4 .p2align 4, 0x90 .Lblks4_loopgas_4: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm6, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm6, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm6, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm6, %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm1 pxor (48)(%rsp), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm2 pxor (64)(%rsp), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm3 pxor (80)(%rsp), %xmm3 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_4 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm0, %xmm6 movdqa %xmm0, %xmm5 pxor %xmm0, %xmm6 pclmulqdq $(0), %xmm10, %xmm0 pshufd $(78), %xmm1, %xmm13 movdqa %xmm1, %xmm12 pxor %xmm1, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 pclmulqdq $(0), %xmm10, %xmm1 pxor %xmm4, %xmm0 psllq $(5), %xmm0 pxor %xmm4, %xmm0 psllq $(57), %xmm0 pshufd $(78), %xmm0, %xmm6 movdqa %xmm6, %xmm0 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm0 pxor %xmm4, %xmm0 pxor %xmm6, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm0 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 psrlq $(1), %xmm0 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pxor %xmm1, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm1 pxor %xmm13, %xmm12 movdqa %xmm1, %xmm11 movdqa %xmm1, %xmm13 movdqa %xmm1, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm1 pxor %xmm11, %xmm12 movdqa %xmm1, %xmm13 psrlq $(5), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm1, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm1 pxor %xmm12, %xmm1 pshufd $(78), %xmm2, %xmm6 movdqa %xmm2, %xmm5 pxor %xmm2, %xmm6 pclmulqdq $(0), %xmm10, %xmm2 pshufd $(78), %xmm3, %xmm13 movdqa %xmm3, %xmm12 pxor %xmm3, %xmm13 pclmulqdq $(17), %xmm10, %xmm5 pclmulqdq $(0), %xmm9, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 pshufd $(78), %xmm6, %xmm4 movdqa %xmm4, %xmm6 pand MASK2(%rip), %xmm4 pand %xmm14, %xmm6 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm4 psllq $(1), %xmm2 pclmulqdq $(0), %xmm10, %xmm3 pxor %xmm4, %xmm2 psllq $(5), %xmm2 pxor %xmm4, %xmm2 psllq $(57), %xmm2 pshufd $(78), %xmm2, %xmm6 movdqa %xmm6, %xmm2 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm6 pand MASK2(%rip), %xmm2 pxor %xmm4, %xmm2 pxor %xmm6, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm2 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm3, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm3 pxor %xmm13, %xmm12 movdqa %xmm3, %xmm11 movdqa %xmm3, %xmm13 movdqa %xmm3, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm3 pxor %xmm11, %xmm12 movdqa %xmm3, %xmm13 psrlq $(5), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm3, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm3 pxor %xmm12, %xmm3 movdqa %xmm0, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm2, (64)(%rsp) movdqa %xmm3, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm0, %xmm5 pshufd $(78), %xmm10, %xmm6 pxor %xmm0, %xmm5 pxor %xmm10, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm0, %xmm4 pclmulqdq $(0), %xmm10, %xmm0 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm10, %xmm4 pxor %xmm0, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm0 movdqa %xmm0, %xmm6 movdqa %xmm0, %xmm5 movdqa %xmm0, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm0 pxor %xmm6, %xmm4 movdqa %xmm0, %xmm5 psrlq $(5), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm0, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm0 pxor %xmm4, %xmm0 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm9, %xmm6 pxor %xmm1, %xmm5 pxor %xmm9, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm9, %xmm1 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm9, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm6 movdqa %xmm1, %xmm5 movdqa %xmm1, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm1 pxor %xmm6, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm2, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm8, %xmm2 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm6 movdqa %xmm2, %xmm5 movdqa %xmm2, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm2 pxor %xmm6, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm5 pshufd $(78), %xmm8, %xmm6 pxor %xmm3, %xmm5 pxor %xmm8, %xmm6 pclmulqdq $(0), %xmm6, %xmm5 movdqa %xmm3, %xmm4 pclmulqdq $(0), %xmm8, %xmm3 pxor %xmm6, %xmm6 pclmulqdq $(17), %xmm8, %xmm4 pxor %xmm3, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm6 pslldq $(8), %xmm5 pxor %xmm6, %xmm4 pxor %xmm5, %xmm3 movdqa %xmm3, %xmm6 movdqa %xmm3, %xmm5 movdqa %xmm3, %xmm15 psllq $(63), %xmm6 psllq $(62), %xmm5 psllq $(57), %xmm15 pxor %xmm5, %xmm6 pxor %xmm15, %xmm6 movdqa %xmm6, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm6 pxor %xmm5, %xmm3 pxor %xmm6, %xmm4 movdqa %xmm3, %xmm5 psrlq $(5), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm3, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm3 pxor %xmm4, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%rsp) .Lsingle_block_procgas_4: test %rax, %rax jz .Lquitgas_4 .p2align 4, 0x90 .Lblk_loopgas_4: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm0 pxor (32)(%rsp), %xmm0 movdqa (%rbx), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 movdqa %xmm0, %xmm4 movdqa %xmm0, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp pop %rbx ret .p2align 4, 0x90 .globl _AesGcmDec_avx _AesGcmDec_avx: push %rbx sub $(128), %rsp mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx movdqa SHUF_CONST(%rip), %xmm4 movdqu (%rax), %xmm0 movdqu (%rbx), %xmm1 movdqu (%rcx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%rsp) movdqa %xmm1, (16)(%rsp) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%rsp) movdqa %xmm1, (48)(%rsp) movdqa %xmm1, (64)(%rsp) movdqa %xmm1, (80)(%rsp) mov (168)(%rsp), %rbx movdqa (32)(%rbx), %xmm10 pshufd $(78), %xmm10, %xmm9 pxor %xmm10, %xmm9 movdqa %xmm9, (96)(%rsp) movslq %edx, %rdx mov %r9, %rcx mov %rdx, %rax and $(63), %rax and $(-64), %rdx jz .Lsingle_block_procgas_5 .p2align 4, 0x90 .Lblks4_loopgas_5: movdqa INC_1(%rip), %xmm6 movdqa SHUF_CONST(%rip), %xmm5 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, %xmm2 paddd INC_1(%rip), %xmm2 movdqa %xmm2, %xmm3 paddd INC_1(%rip), %xmm3 movdqa %xmm3, %xmm4 paddd INC_1(%rip), %xmm4 movdqa %xmm4, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%rsp), %xmm0 movdqa %xmm4, (16)(%rsp) movdqu (%rsi), %xmm4 movdqu (16)(%rsi), %xmm5 movdqu (32)(%rsi), %xmm6 movdqu (48)(%rsi), %xmm7 add $(64), %rsi pxor %xmm4, %xmm0 movdqu %xmm0, (%rdi) pshufb SHUF_CONST(%rip), %xmm4 pxor (32)(%rsp), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%rdi) pshufb SHUF_CONST(%rip), %xmm5 pxor (48)(%rsp), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%rdi) pshufb SHUF_CONST(%rip), %xmm6 pxor (64)(%rsp), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%rdi) pshufb SHUF_CONST(%rip), %xmm7 pxor (80)(%rsp), %xmm7 add $(64), %rdi cmp $(64), %rdx je .Lcombine_hashgas_5 movdqa MASK1(%rip), %xmm14 pshufd $(78), %xmm4, %xmm2 movdqa %xmm4, %xmm1 pxor %xmm4, %xmm2 pclmulqdq $(0), %xmm10, %xmm4 pshufd $(78), %xmm5, %xmm13 movdqa %xmm5, %xmm12 pxor %xmm5, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm0 psllq $(1), %xmm4 pclmulqdq $(0), %xmm10, %xmm5 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 pshufd $(78), %xmm4, %xmm2 movdqa %xmm2, %xmm4 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm4 pxor %xmm0, %xmm4 pxor %xmm2, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm4 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 psrlq $(1), %xmm4 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pxor %xmm5, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm5 pxor %xmm13, %xmm12 movdqa %xmm5, %xmm11 movdqa %xmm5, %xmm13 movdqa %xmm5, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm5 pxor %xmm11, %xmm12 movdqa %xmm5, %xmm13 psrlq $(5), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm5, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm5 pxor %xmm12, %xmm5 pshufd $(78), %xmm6, %xmm2 movdqa %xmm6, %xmm1 pxor %xmm6, %xmm2 pclmulqdq $(0), %xmm10, %xmm6 pshufd $(78), %xmm7, %xmm13 movdqa %xmm7, %xmm12 pxor %xmm7, %xmm13 pclmulqdq $(17), %xmm10, %xmm1 pclmulqdq $(0), %xmm9, %xmm2 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm0 movdqa %xmm0, %xmm2 pand MASK2(%rip), %xmm0 pand %xmm14, %xmm2 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm0 psllq $(1), %xmm6 pclmulqdq $(0), %xmm10, %xmm7 pxor %xmm0, %xmm6 psllq $(5), %xmm6 pxor %xmm0, %xmm6 psllq $(57), %xmm6 pshufd $(78), %xmm6, %xmm2 movdqa %xmm2, %xmm6 pclmulqdq $(17), %xmm10, %xmm12 pand %xmm14, %xmm2 pand MASK2(%rip), %xmm6 pxor %xmm0, %xmm6 pxor %xmm2, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm6 pclmulqdq $(0), %xmm9, %xmm13 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm7, %xmm13 pxor %xmm12, %xmm13 pshufd $(78), %xmm13, %xmm11 movdqa %xmm11, %xmm13 pand MASK2(%rip), %xmm11 pand %xmm14, %xmm13 pxor %xmm11, %xmm7 pxor %xmm13, %xmm12 movdqa %xmm7, %xmm11 movdqa %xmm7, %xmm13 movdqa %xmm7, %xmm15 psllq $(63), %xmm11 psllq $(62), %xmm13 psllq $(57), %xmm15 pxor %xmm13, %xmm11 pxor %xmm15, %xmm11 movdqa %xmm11, %xmm13 pslldq $(8), %xmm13 psrldq $(8), %xmm11 pxor %xmm13, %xmm7 pxor %xmm11, %xmm12 movdqa %xmm7, %xmm13 psrlq $(5), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm7, %xmm13 psrlq $(1), %xmm13 pxor %xmm13, %xmm7 pxor %xmm12, %xmm7 movdqa %xmm4, (32)(%rsp) movdqa %xmm5, (48)(%rsp) movdqa %xmm6, (64)(%rsp) movdqa %xmm7, (80)(%rsp) sub $(64), %rdx movdqa (%rsp), %xmm0 cmp $(64), %rdx jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: movdqa (%rbx), %xmm8 movdqa (16)(%rbx), %xmm9 pshufd $(78), %xmm4, %xmm2 pshufd $(78), %xmm10, %xmm0 pxor %xmm4, %xmm2 pxor %xmm10, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm4, %xmm1 pclmulqdq $(0), %xmm10, %xmm4 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm10, %xmm1 pxor %xmm4, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm4 movdqa %xmm4, %xmm0 movdqa %xmm4, %xmm2 movdqa %xmm4, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm4 pxor %xmm0, %xmm1 movdqa %xmm4, %xmm2 psrlq $(5), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm4, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm4 pxor %xmm1, %xmm4 pshufd $(78), %xmm5, %xmm2 pshufd $(78), %xmm9, %xmm0 pxor %xmm5, %xmm2 pxor %xmm9, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm5, %xmm1 pclmulqdq $(0), %xmm9, %xmm5 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm9, %xmm1 pxor %xmm5, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm5 movdqa %xmm5, %xmm0 movdqa %xmm5, %xmm2 movdqa %xmm5, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm5 pxor %xmm0, %xmm1 movdqa %xmm5, %xmm2 psrlq $(5), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm5, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm5 pxor %xmm1, %xmm5 pshufd $(78), %xmm6, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm6, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm6, %xmm1 pclmulqdq $(0), %xmm8, %xmm6 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm6, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm6 movdqa %xmm6, %xmm0 movdqa %xmm6, %xmm2 movdqa %xmm6, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm6 pxor %xmm0, %xmm1 movdqa %xmm6, %xmm2 psrlq $(5), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm6, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm6 pxor %xmm1, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm2 pshufd $(78), %xmm8, %xmm0 pxor %xmm7, %xmm2 pxor %xmm8, %xmm0 pclmulqdq $(0), %xmm0, %xmm2 movdqa %xmm7, %xmm1 pclmulqdq $(0), %xmm8, %xmm7 pxor %xmm0, %xmm0 pclmulqdq $(17), %xmm8, %xmm1 pxor %xmm7, %xmm2 pxor %xmm1, %xmm2 palignr $(8), %xmm2, %xmm0 pslldq $(8), %xmm2 pxor %xmm0, %xmm1 pxor %xmm2, %xmm7 movdqa %xmm7, %xmm0 movdqa %xmm7, %xmm2 movdqa %xmm7, %xmm15 psllq $(63), %xmm0 psllq $(62), %xmm2 psllq $(57), %xmm15 pxor %xmm2, %xmm0 pxor %xmm15, %xmm0 movdqa %xmm0, %xmm2 pslldq $(8), %xmm2 psrldq $(8), %xmm0 pxor %xmm2, %xmm7 pxor %xmm0, %xmm1 movdqa %xmm7, %xmm2 psrlq $(5), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm7, %xmm2 psrlq $(1), %xmm2 pxor %xmm2, %xmm7 pxor %xmm1, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%rsp) .Lsingle_block_procgas_5: test %rax, %rax jz .Lquitgas_5 .p2align 4, 0x90 .Lblk_loopgas_5: movdqa (%rsp), %xmm0 movdqa %xmm0, %xmm1 paddd INC_1(%rip), %xmm1 movdqa %xmm1, (%rsp) movdqa (%rcx), %xmm0 mov %rcx, %r10 pshufb SHUF_CONST(%rip), %xmm1 pxor %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 mov %r8d, %r11d sub $(1), %r11 .p2align 4, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (16)(%r10), %xmm0 add $(16), %r10 dec %r11 jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%rsp), %xmm0 movdqa %xmm1, (16)(%rsp) movdqu (%rsi), %xmm1 add $(16), %rsi pxor %xmm1, %xmm0 movdqu %xmm0, (%rdi) add $(16), %rdi pshufb SHUF_CONST(%rip), %xmm1 pxor (32)(%rsp), %xmm1 movdqa (%rbx), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 movdqa %xmm1, %xmm4 movdqa %xmm1, %xmm15 psllq $(63), %xmm2 psllq $(62), %xmm4 psllq $(57), %xmm15 pxor %xmm4, %xmm2 pxor %xmm15, %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%rsp) sub $(16), %rax jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (%rsp), %xmm0 movdqa (16)(%rsp), %xmm1 movdqa (32)(%rsp), %xmm2 mov (152)(%rsp), %rax mov (160)(%rsp), %rbx mov (144)(%rsp), %rcx pshufb SHUF_CONST(%rip), %xmm0 movdqu %xmm0, (%rax) movdqu %xmm1, (%rbx) pshufb SHUF_CONST(%rip), %xmm2 movdqu %xmm2, (%rcx) add $(128), %rsp pop %rbx ret ",16216,True,4909.050467879443,median "/* IBM Wheelwriter hack Pin 0: connected through MOSFET to Wheelwriter bus Will pull down the bus when set to zero Pin 2: ALSO connected to the bus, but listens instead of sending data */ //#include #define LETTER_DELAY 450 #define CARRIAGE_WAIT_BASE 200 #define CARRIAGE_WAIT_MULTIPLIER 15 bool bold = false; // off to start bool underline = false; // off to start bool reverseText = false; // for printing in reverse int LED = 13; // the LED light // on an Arduino Nano, ATmega328, the following will delay roughly 5.25us #define pulseDelay() { for (int i=0;i<16;i++) { __asm__ __volatile__(""nop\\n\\t""); } } byte asciiTrans[128] = //col: 0 1 2 3 4 5 6 7 8 9 a b c d e f row: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1 // sp ! "" # $ % & ' ( ) * + , - . / 0x00, 0x49, 0x4b, 0x38, 0x37, 0x39, 0x3f, 0x4c, 0x23, 0x16, 0x36, 0x3b, 0xc, 0x0e, 0x57, 0x28, // 2 // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 0x30, 0x2e, 0x2f, 0x2c, 0x32, 0x31, 0x33, 0x35, 0x34, 0x2a ,0x4e, 0x50, 0x00, 0x4d, 0x00, 0x4a, // 3 // @ A B C D E F G H I J K L M N O 0x3d, 0x20, 0x12, 0x1b, 0x1d, 0x1e, 0x11, 0x0f, 0x14, 0x1F, 0x21, 0x2b, 0x18, 0x24, 0x1a, 0x22, // 4 // P Q R S T U V W X Y Z [ \\ ] ^ _ 0x15, 0x3e, 0x17, 0x19, 0x1c, 0x10, 0x0d, 0x29, 0x2d, 0x26, 0x13, 0x41, 0x00, 0x40, 0x00, 0x4f, // 5 // ` a b c d e f g h i j k l m n o 0x00, 0x01, 0x59, 0x05, 0x07, 0x60, 0x0a, 0x5a, 0x08, 0x5d, 0x56, 0x0b, 0x09, 0x04, 0x02, 0x5f, // 6 // p q r s t u v w x y z { | } ~ DEL 0x5c, 0x52, 0x03, 0x06, 0x5e, 0x5b, 0x53, 0x55, 0x51, 0x58, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00}; // 7 int microspaceCount = 0; void setup() { // initialize serial communication at 115200 bits per second: Serial.begin(115200); Serial.setTimeout(25); // Digital pins pinMode(2,OUTPUT); // pin that will trigger the bus pinMode(3, INPUT); // listening pin pinMode(4, INPUT_PULLUP); // for the button pinMode(LED, OUTPUT); // start the input pin off (meaning the bus is high, normal state) PORTD &= 0b11111011; //resetTypewriter(); // Arduino resets whenever a new serial connection is made... //microspaceCount = readMicrospacesFromEEPROM(); } // the loop routine runs over and over again forever: void loop() { static int charCount = 0; //static int microspaceCount = 0; unsigned char buffer[70]; // 64 plus a few extra for some run-over commands (e.g., reverse) uint8_t readLength = 65; uint8_t bytesRead = 0; uint8_t bufferPos = 0; uint16_t bytesToPrint; if (Serial.available() > 0) { // read one byte, and see if it is a command // Commands: // 0: next two bytes will be the number of characters we are going // to send // 1: image bits (next two bytes will be the width and height) // 2: Toggle Bold // 3: Toggle Underline // 4: Reset typewriter // 5: TBA // 6: TBA // 7: Beep typewriter (traditional 0x07 beep char) // If the byte is >= 5, just treat as one character bytesRead = Serial.readBytes(buffer, 1); digitalWrite(LED,1); //Serial.print(""Read ""); //Serial.println(bytesRead); //Serial.println("" bytes.""); char command = buffer[0]; //Serial.println(int(command)); if (command == 0) { // text to print // look for next two bytes Serial.readBytes(buffer,3); bytesToPrint = buffer[0] + (buffer[1] << 8); // little-endian int spacing = buffer[2]; // microspaceCount should not count bold and underline characters // but that will get taken care of when we actually print the characters microspaceCount = microspaceCount + bytesToPrint * spacing; //writeMicrospacesToEEPROM(microspaceCount); //Serial.write(0x04); // terminate with 0x04 (end of transmission) charCount = printAllChars(buffer,bytesToPrint,charCount, spacing); Serial.print(""microspaceCount: ""); Serial.println(microspaceCount); Serial.write(0x04); delay(LETTER_DELAY); } else if (command == 1) { // image to print //Serial.println(""image""); printImage(buffer); } else if (command == 2) { bold = !bold; // toggle Serial.println(""ok""); } else if (command == 3) { underline = !underline; Serial.println(""ok""); } else if (command == 4) { // reset the typewriter so we know we are on the begining of a line resetTypewriter(); //writeMicrospacesToEEPROM(0); microspaceCount = 0; bold = underline = reverseText = false; Serial.println(""reset""); Serial.write(0x04); // terminate with 0x04 (end of transmission) } else if (command == 5) { // position cursor horizontally and vertically from current position // we expect four more bytes, as follows: // byte 0: little end of 2-byte horizontal value // byte 1: big end of 2-byte horizontal value // // byte 2: little end of 2-byte vertical value // byte 3: big end of 2-byte vertical value // Negative values will be in two's complement format for 16-bit int values Serial.readBytes(buffer,4); int horizontal = buffer[0] + (buffer[1] << 8); // little-endian int vertical = buffer[2] + (buffer[3] << 8); // little endian moveCursor(horizontal,vertical); microspaceCount += horizontal; Serial.println(""moved cursor by "" + String(horizontal) + "" horizontal microspaces and "" + String(vertical) + "" vertical microspaces""); Serial.write(0x04); // terminate with 0x04 (end of transmission) } else if (command == 6) { // returns the cursor to the beginning of the line, based on microspaceCount // also moves the cursor vertically by the amount given in the next two bytes Serial.readBytes(buffer,2); int vertical = buffer[0] + (buffer[1] << 8); // little endian moveCursor(-microspaceCount, vertical); Serial.print(""sent cursor to beginning of line with ""); Serial.print(-microspaceCount); Serial.println("" microspaces""); Serial.write(0x04); // terminate with 0x04 (end of transmission) //writeMicrospacesToEEPROM(0); microspaceCount = 0; } else if (command == 7) { beepTypewriter(); Serial.println(""ok""); } else if (command == 8) { // report on microspaceCount Serial.print(""microspaceCount: ""); Serial.println(microspaceCount); Serial.write(0x04); // terminate with 0x04 (end of transmission) } else { charCount = printOne(command,charCount); } digitalWrite(LED,0); // turn off LED when we are finished processing } // button for testing /* byte button = digitalRead(4); if (button == 0) { //printOne(""a"",1); //paper_vert(1,1); //micro_backspace(25); //paper_vert(1,100); //forwardSpaces(5); //fastText(""this is really fast""); //send_letter(0b000000001); // 'a' //send_letter(0b001011001); // 'b' //send_letter(0b000000100); // 'm' //send_letter(); digitalWrite(13,1); // led delay(100); digitalWrite(13,0); resetTypewriter(); }*/ delay(10); } int printOne(int charToPrint, int charCount) { // print the character, and return the number of chars on the line that are left. // E.g., if we start with 6 and we print a character, then we return 7. // But, if we print a return, then that clears the charCount to 0, and if we // go left by one, that subtracts it, etc. if (charToPrint < 0) { charToPrint += 256; // correct for signed char } if (charToPrint == '\\r' or charToPrint == '\\n') { send_return(charCount); charCount = 0; } else if (charToPrint == 128 or charToPrint == 129) { paper_vert((charToPrint == 128 ? 0 : 1),8); // full line up/down } else if (charToPrint == 133) { // micro-down, ctrl-d is 4 paper_vert(1,1); } else if (charToPrint == 21) { // micro-up, ctrl-u is 21 paper_vert(0,1); } else if (charToPrint == 130 or charToPrint == 0x7f) { // left arrow or delete if (charCount > 0) { backspace_no_correct(); charCount--; } } else if (charToPrint == 131) { // micro-backspace // DOES NOT UPDATE CHARCOUNT! // THIS WILL CAUSE PROBLEMS WITH RETURN! // TODO: FIX THIS ISSUE micro_backspace(1); } else if (charToPrint == 132) { // micro-forwardspace // DOES NOT UPDATE CHARCOUNT! // THIS WILL CAUSE PROBLEMS WITH RETURN! // TODO: FIX THIS ISSUE forwardSpaces(1); } else { //Serial.println(""about to print""); //send_letter(asciiTrans[charToPrint]); send_letter_without_space(asciiTrans[charToPrint]); charCount++; } Serial.println(""ok""); // sends back our characters (one) printed Serial.flush(); delay(10); //Bean.setLed(255, 0, 0); //Bean.sleep(10); //Bean.setLed(0,0,0); return charCount; } int printAllChars(char buffer[], uint16_t bytesToPrint, int charCount, int spacing) { uint8_t readLength = 65; bool fastPrinting = false; uint16_t bytesPrinted = 0; uint8_t bufferPos = 0; uint8_t bytesRead = 0; while (bytesToPrint > 0) { // read bytes from serial //Serial.print(""about to print ""); //Serial.print(bytesToPrint); //Serial.println("" bytes""); bytesPrinted = 0; // wait for more bytes, but only wait up to 5 seconds unsigned long startTime = millis(); bool timeout = false; while (not Serial.available() and not timeout) { if (millis() - startTime > 5000) { timeout = true; } delay(10); } if (timeout) { if (fastPrinting) { fastTextFinish(); fastPrinting = false; send_return(charCount); charCount = 0; } break; } bytesRead = Serial.readBytes(buffer, readLength-1); //Serial.println(bytesRead); bufferPos = 0; while (bufferPos < bytesRead) { // print all the bytes // check for underline and bold if (buffer[bufferPos] == 2) { // bold bold = !bold; // decrement microspaceCount microspaceCount -= spacing; } else if (buffer[bufferPos] == 3) { // underline underline = !underline; // decrement microspaceCount microspaceCount -= spacing; } else if (buffer[bufferPos] == 5) { // reverse instruction // we might need to read in more of the command, which // is four bytes long int bytesToRead = 4 - (bytesRead - bufferPos); while (bytesToRead > 0) { // read necessary bytes int extraBytesRead = Serial.readBytes(buffer+bytesRead, bytesToRead); bytesRead += extraBytesRead; bytesToRead -= extraBytesRead; } // now we have enough bytes int print_dir = buffer[bufferPos+1]; int numSpaces = buffer[bufferPos+2]; int spacesDir = buffer[bufferPos+3]; bufferPos += 4; // } else if (buffer[bufferPos] != '\\r' and buffer[bufferPos] != '\\n') { // begin fast printing if (!fastPrinting) { fastTextInit(); fastPrinting = true; } fastTextChars(buffer + bufferPos, 1, spacing); if (reverseText) { charCount--; if (charCount < 0) { charCount = 0; } } else { charCount++; } } else { if (fastPrinting) { fastTextFinish(); fastPrinting = false; } send_return(charCount); charCount = 0; } bufferPos++; bytesToPrint--; bytesPrinted++; } } if (fastPrinting) { fastTextFinish(); } return charCount; } void printImage(char *buffer) { // will read 3-tuples of bytes // first byte is low-order byte for run length, // second byte is high-order byte for run length, // third byte is the byte to print (typically, period, space, or return) uint32_t rowBitsPrinted = 0; int bitsRead = 0; while (1) { // keep reading bytes until we get (0,0,0) // read bytes from serial // wait for more bytes, but only wait up to 2 seconds unsigned long startTime = millis(); bool timeout = false; bool first = true; while (Serial.available() == 0 and not timeout) { if (first) { Serial.println(""Please send.""); first = false; } if (millis() - startTime > 2000) { timeout = true; } delay(50); //Bean.sleep(10); } if (timeout) { paper_vert(1,1); Serial.println(""timeout""); micro_backspace(rowBitsPrinted * 3); break; } bitsRead = Serial.readBytes(buffer, 3); //Serial.println(bitsRead); // should always be 3 if (buffer[0] == 0 and buffer[1] == 0 and buffer[2] == 0) { Serial.println(""end received""); break; // no more bits to print } // we do have a run to print uint16_t runLength = buffer[0] + (buffer[1] << 8); printRun(runLength,buffer[2]); } Serial.println(""done""); } void printRun(uint16_t runLength, char c) { static bool inFastText = false; if (c == '\\n') { fastTextFinish(); //delay(LETTER_DELAY); paper_vert(1,1); // Move down one pixel if (runLength > 0) { micro_backspace(runLength * 3); } inFastText = false; } else { if (c == ' ') { // turn off fastText if it is on if (inFastText) { fastTextFinish(); inFastText = false; } forwardSpaces(runLength); } else if (!inFastText) { fastTextInit(); inFastText = true; fastTextCharsMicro(c,runLength); } } } void print_str(char *s) { while (*s != '\\0') { send_letter(asciiTrans[*s++]); } } void print_strln(char *s) { // prints a line and then a carriage return print_str(s); send_return(strlen(s)); } inline void sendByteOnPin(int command) { // This will actually send 10 bytes, // starting with a zero (always) // and then the next nine bytes // when the pin is high (on), the bus is pulled low noInterrupts(); // turn off interrupts so we don't get disturbed // unrolled for consistency, will send nine bits // with a zero initial bit // pull low for 5.75us (by turning on the pin) PORTD |= 0b00000100; pulseDelay(); // fudge factor for 5.75 // send low order bit (LSB endian) int nextBit = (command & 0b000000001); if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); // special shortened... } // next bit (000000010) nextBit = (command & 0b000000010) >> 1; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); } // next bit (000000100) nextBit = (command & 0b000000100) >> 2; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); } // next bit (000001000) nextBit = (command & 0b000001000) >> 3; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); } // next bit (000010000) nextBit = (command & 0b000010000) >> 4; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); } // next bit (000100000) nextBit = (command & 0b000100000) >> 5; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1){ // turn off PORTD &= 0b11111011; pulseDelay(); } // next bit (001000000) nextBit = (command & 0b001000000) >> 6; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1) { // turn off PORTD &= 0b11111011; pulseDelay(); } // next to last bit (010000000) nextBit = (command & 0b010000000) >> 7; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); } else if (nextBit == 1){ // turn off PORTD &= 0b11111011; pulseDelay(); } // final bit (100000000) nextBit = (command & 0b100000000) >> 8; if (nextBit == 0) { // turn on PORTD |= 0b00000100; pulseDelay(); // last one is special :) } else if (nextBit == 1){ // turn off PORTD &= 0b11111011; pulseDelay(); } // make sure we aren't still pulling down PORTD &= 0b11111011; // re-enable interrupts interrupts(); } void send_letter(int letter) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); if (underline) { sendByte(0b000000000); // no space sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans['_']); } if (bold) { sendByte(0b000000001); // one microspace sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); sendByte(0b000001001); } else { // not bold sendByte(0b000001010); // spacing for one character } //delay(LETTER_DELAY); // before next character } void send_letter_without_space(int letter) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); if (underline) { sendByte(0b000000000); // no space sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans['_']); } if (bold) { sendByte(0b000000001); // one microspace sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); sendByte(0b000001001); } else { // not bold sendByte(0b000000000); // spacing for one character } //delay(LETTER_DELAY); // before next character } void letterNoSpace(int letter) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); sendByte(0); // don't send any spaces delay(LETTER_DELAY); // before next character } void letterMicrospace(int letter) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(letter); sendByte(2); // send one microspace delay(LETTER_DELAY); // before next character } void paper_vert(int direction) { // 0 == up // 1 == down // 4 == micro-down (paper down) // 21 == micro-up (paper up) sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000101); if (direction == 0) { // cursor-up (paper-down) sendByte(0b000001000); } else if (direction == 1) { sendByte(0b010001000); // cursor-down (paper-up) } else if (direction == 4) { sendByte(0b010000010); // cursor-micro-down (paper-micro-up) } else if (direction == 21) { sendByte(0b000000010); // cursor-micro-up (paper-micro-down) } sendByte(0b100100001); sendByte(0b000001011); delay(LETTER_DELAY); // give it a bit more time } void paper_vert(int direction, int microspaces) { // 0 == up // 1 == down // can only send up to 127 at a time while (microspaces > 127) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000101); //sendByte((direction << 7) | (microspaces << 1)); sendByte((direction << 7) | 127); sendByte(0b100100001); sendByte(0b000001011); delay(LETTER_DELAY); microspaces -= 127; } sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000101); sendByte((direction << 7) | microspaces); sendByte(0b100100001); sendByte(0b000001011); } void backspace_no_correct() { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000100); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b000000000); sendByte(0b000001010); /*sendByte(0b100100001); // send one more byte but don't wait explicitly for the response // of 0b000000100 sendByteOnPin(0b000001011);*/ //delay(LETTER_DELAY / 10); // a bit more time } void send_return(int numChars) { // calculations for further down int byte1 = (numChars * 5) >> 7; int byte2 = ((numChars * 5) & 0x7f) << 1; sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000111); sendByte(0b100100001); sendByte(0b000000110); // We will send two bytes from a 10-bit number // which is numChars * 5. The top three bits // of the 10-bit number comprise the first byte, // and the remaining 7 bits comprise the second // byte, although the byte needs to be shifted // left by one (not sure why) // the numbers are calculated above for timing reasons sendByte(byte1); sendByte(byte2); // each char is worth 10 sendByte(0b100100001); // right now, the platten is moving, maybe? sendByte(0b000000101); sendByte(0b010010000); // wait for carriage //delay(CARRIAGE_WAIT_BASE + CARRIAGE_WAIT_MULTIPLIER * numChars); } void horiz_space(int microspaces) { int neg = 0; if (microspaces > 0) { neg = 0b10000000; } else { microspaces = -microspaces; } int byte1 = microspaces >> 8; int byte2 = microspaces & 0xff; sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000111); sendByte(0b100100001); sendByte(0b000000110); // We will send two bytes from a 10-bit number // which is numChars * 5. The top three bits // of the 10-bit number comprise the first byte, // and the remaining 7 bits comprise the second // byte, although the byte needs to be shifted // left by one (not sure why) // the numbers are calculated above for timing reasons sendByte(neg | byte1); sendByte(byte2); // each char is worth 10 sendByte(0b100100001); // right now, the platten is moving, maybe? //sendByte(0b000000101); sendByte(0b010010000); // wait for carriage //delay(CARRIAGE_WAIT_BASE + CARRIAGE_WAIT_MULTIPLIER * numChars); } void send_return_microspaces(int numSpaces) { // calculations for further down int byte1 = (numSpaces) >> 7; int byte2 = ((numSpaces) & 0x7f) << 1; sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000111); sendByte(0b100100001); sendByte(0b000000110); // We will send two bytes from a 10-bit number // which is numChars * 5. The top three bits // of the 10-bit number comprise the first byte, // and the remaining 7 bits comprise the second // byte, although the byte needs to be shifted // left by one (not sure why) // the numbers are calculated above for timing reasons sendByte(byte1); sendByte(byte2); // each char is worth 10 sendByte(0b100100001); // right now, the platten is moving, maybe? sendByte(0b000000101); sendByte(0b010010000); /* sendByte(0b100100001); // send one more byte but don't wait explicitly for the response // of 0b001010000 sendByteOnPin(0b000001011);*/ // wait for carriage //delay(CARRIAGE_WAIT_BASE + CARRIAGE_WAIT_MULTIPLIER * numChars); } void correct_letter(int letter) { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000101); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b000000000); sendByte(0b000001010); sendByte(0b100100001); sendByte(0b000000100); sendByte(letter); sendByte(0b000001010); sendByte(0b100100001); sendByte(0b000001100); sendByte(0b010010000); } void micro_backspace(int microspaces) { // 10 microspaces is one space // max is 255 while (microspaces > 255) { sendByte(0b100100001); sendByte(0b000001110); sendByte(0b011010000); sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000100); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b000000000); sendByte(0xff); delay(LETTER_DELAY); microspaces -= 255; //sendByte(0b000000010); } sendByte(0b100100001); sendByte(0b000001110); sendByte(0b011010000); sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000100); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b000000000); sendByte(microspaces); /* sendByte(0b100100001); // send one more byte but don't wait explicitly for the response // of 0b000000100 sendByteOnPin(0b000001011);*/ } void forwardSpaces(int microspaces) { // ten microspaces is one real space // max is 255 while (microspaces > 255) { sendByte(0b100100001); sendByte(0b000001110); sendByte(0b010010110); sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000110); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); //sendByte(0b001111100); sendByte(0xff); delay(LETTER_DELAY); microspaces-=255; } sendByte(0b100100001); sendByte(0b000001110); sendByte(0b010010110); sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000110); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); //sendByte(0b001111100); sendByte(microspaces); } void spin() { sendByte(0b100100001); sendByte(0b000000111); } void unknownCommand() { sendByte(0b100100001); sendByte(0b000001001); sendByte(0b010000000); } void sendByte(int b) { //Serial.println(""sending byte!""); sendByteOnPin(b); while (((PIND & 0b00001000) >> 3) == 1) { // busy } while (((PIND & 0b00001000) >> 3) == 0) { // busy } delayMicroseconds(LETTER_DELAY); // wait a bit before sending next char } void fastTextInit() { sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001001); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000001010); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000000110); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000000101); sendByte(0b010000000); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000010010); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); sendByte(0b000000000); } void fastTextChars(char *s, int length, int spacing) { // letters start here for (int i=0; i < length; i++) { sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans[*s++]); if (underline) { sendByte(0b000000000); // no space sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans['_']); } if (bold) { sendByte(0b000000001); // one microspace sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans[*(s-1)]); sendByte(0b000001001); } else { if (reverseText) { sendByte(0); // no forward space micro_backspace(0b1010); // full space back } else { // full space //sendByte(0b000001010); sendByte(spacing); } } } } void fastTextCharsMicro(char s, uint16_t length) { // letters start here if (s == ' ') { // just make a fast run of spaces sendByte(0b100100001); sendByte(0b000000011); sendByte(0b000000000); sendByte(0b11 * length); } else { for (uint16_t i=0; i < length; i++) { sendByte(0b100100001); sendByte(0b000000011); sendByte(asciiTrans[s]); sendByte(0b000000011); // 1 microspace } } //delay(LETTER_DELAY + LETTER_DELAY / 10 * length / 5); } void fastTextFinish() { sendByte(0b100100001); sendByte(0b000001001); sendByte(0b000000000); //delay(LETTER_DELAY * 2); // a bit more time } void resetTypewriter() { sendByte(0b100100001); sendByte(0b000000000); //sendByte(0b000100110); // receives this... sendByte(0b100100001); sendByte(0b000000001); sendByte(0b000100000); sendByte(0b100100001); sendByte(0b000001001); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000010010); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000001101); sendByte(0b000001001); sendByte(0b100100001); sendByte(0b000000110); sendByte(0b010000000); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000001010); sendByte(0b000000000); sendByte(0b100100001); sendByte(0b000000111); sendByte(0b100100001); sendByte(0b000001100); sendByte(0b000000001); } void beepTypewriter() { spin(); // not currently working /* sendByte(0b100100001); sendByte(0b000001011); sendByte(0b100100001); sendByte(0b000001011); */ } void moveCursor(int horizontal, int vertical) { // move horizontally first horiz_space(horizontal); // move vertically // (forgot why these commands are not symmetrical...) if (vertical > 0) { paper_vert(1,vertical); } else { paper_vert(0,-vertical); } } /* int readMicrospacesFromEEPROM() { return EEPROM.read(0) + (EEPROM.read(1) << 8); } void writeMicrospacesToEEPROM(int m) { // write little endian to bytes 0,1 EEPROM.update(0,m & 0xff); EEPROM.update(1,(m >> 8) & 0xff); } */ ",12045,False,2193.599341816692,median "COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1990 -- All Rights Reserved PROJECT: PC GEOS MODULE: CommonUI/CMain FILE: cmainAppDocumentControl.asm ROUTINES: Name Description ---- ----------- GLB OLDocumentGroup Open look document control class REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version DESCRIPTION: $Id: cmainAppDocumentControl.asm,v 1.1 97/04/07 10:52:18 newdeal Exp $ ------------------------------------------------------------------------------@ CommonUIClassStructures segment resource OLDocumentGroupClass mask CLASSF_NEVER_SAVED or \\ mask CLASSF_DISCARD_ON_SAVE CommonUIClassStructures ends ;--------------------------------------------------- DocInit segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupAppStartup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do what we must when application first starts up. CALLED BY: MSG_META_APP_STARTUP PASS: *ds:si = GenDocumentGroup object ^hdx = AppLaunchBlock RETURN: nothing DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/19/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupAppStartup method dynamic OLDocumentGroupClass, MSG_META_APP_STARTUP .enter ; give ourselves a one way upward link to the UI document control ; so that GUP stuff will work push dx EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset movdw cxdx, ds:[di].GDGI_documentControl call GenSetUpwardLink pop dx ; let any children that have come back from the dead know about this. mov ax, MSG_META_APP_STARTUP call GenSendToChildren Destroy ax, cx, dx, bp .leave ret OLDocumentGroupAppStartup endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupAttach %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Make sure that any UserDoDialog won't block the UI from finishing MSG_META_ATTACH -- force queue in front the attach if in a single-threaded app. PASS: *ds:si - instance data ds:di - ptr to start of master instance data es - segment of class ax - MSG_META_ATTACH cx, dx, bp - ? RETURN: nothing ALLOWED TO DESTROY: bx, si, di, ds, es PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- doug 4/30/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupAttach method dynamic OLDocumentGroupClass, MSG_META_ATTACH clr bx push si call GeodeGetAppObject pop si call ObjTestIfObjBlockRunByCurThread jne twoThreaded ; If single-threaded, do the ATTACH after the current method is ; finished being handled, so that the UI thread finished its ; MSG_META_ATTACH. -- Doug 4/30/93 ; mov ax, MSG_OLDG_ATTACH mov bx, ds:[LMBH_handle] mov di, mask MF_FORCE_QUEUE GOTO ObjMessage twoThreaded: ; Allow two-threaded apps to just go ahead & finish the attached, ; since the UI is free to finish the ATTACH over on its side. ; FALL_THRU OLDocumentGroupOLDGAttach OLDocumentGroupAttach endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupOLDGAttach -- MSG_OLDG_ATTACH for OLDocumentGroupClass DESCRIPTION: Send attach to children PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_OLDG_ATTACH cx, dx, bp - Same as that passed in MSG_META_ATTACH RETURN: none DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version Doug 4/30/93 Changed to happen *after* MSG_META_ATTACH done ------------------------------------------------------------------------------@ OLDocumentGroupOLDGAttach method OLDocumentGroupClass, MSG_OLDG_ATTACH mov ax, MSG_META_ATTACH call GenSendToChildren Destroy ax, cx, dx, bp ret OLDocumentGroupOLDGAttach endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupOpenDefaultDoc -- MSG_GEN_DOCUMENT_GROUP_OPEN_DEFAULT_DOC for OLDocumentGroupClass DESCRIPTION: Open the default document (if one exists) PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_OPEN_DEFAULT_DOC dx - size DocumentCommonParams ss:bp - DocumentCommonParams RETURN: none DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupOpenDefaultDoc method dynamic \\ OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_OPEN_DEFAULT_DOC if UNTITLED_DOCS_ON_SP_TOP mov ax, ATTR_GEN_PATH_DATA call ObjVarFindData jc skipRedwoodDirectoryStuff ; ; In for floppy-based-systems with untitled docs on the local disk, ; try the document floppy first, without creating a new document. ; Then try the local disk. ; ; mov ss:[bp].DCP_diskHandle, SP_DOCUMENT mov {TCHAR}ss:[bp].DCP_path[0], 0 mov ss:[bp].DCP_flags, mask DOF_NO_ERROR_DIALOG ;don't create! ;(and don't complain on errors) openDoc:: push bp mov ax, MSG_GEN_DOCUMENT_GROUP_OPEN_DOC call ObjCallInstanceNoLock pop bp jnc done ;doc found, done ornf ss:[bp].DCP_docAttrs, mask GDA_UNTITLED mov ss:[bp].DCP_diskHandle, SP_TOP skipRedwoodDirectoryStuff: endif ; if UNTITLED_DOCS_ON_SP_TOP mov ss:[bp].DCP_flags, mask DOF_CREATE_FILE_IF_FILE_DOES_NOT_EXIST mov ax, MSG_GEN_DOCUMENT_GROUP_OPEN_DOC call ObjCallInstanceNoLock jnc done ; *** handle error opening default file done: Destroy ax, cx, dx ret OLDocumentGroupOpenDefaultDoc endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupUpdateModelExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: Provide default model node behavior PASS: *ds:si - instance data ds:di - ptr to start of master instance data es - segment of class ax - model messages RETURN: nothing ALLOWED TO DESTROY: bx, si, di, ds, es PSEUDO CODE/STRATEGY/KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- doug 9/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupUpdateModelExcl method OLDocumentGroupClass, MSG_META_GAINED_MODEL_EXCL, MSG_META_LOST_MODEL_EXCL, MSG_META_GAINED_SYS_MODEL_EXCL, MSG_META_LOST_SYS_MODEL_EXCL mov bp, MSG_META_GAINED_MODEL_EXCL ; pass base message in bp mov bx, offset Vis_offset mov di, offset OLDGI_modelExcl GOTO FlowUpdateHierarchicalGrab OLDocumentGroupUpdateModelExcl endm DocInit ends ;--- DocExit segment resource COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupDetach -- MSG_META_DETACH for OLDocumentGroupClass DESCRIPTION: Send attach to children PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_META_DETACH or MSG_META_APP_SHUTDOWN cx - caller's ID dx:bp - OD for MSG_META_ACK RETURN: none DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupDetach method dynamic OLDocumentGroupClass, MSG_META_DETACH, MSG_META_APP_SHUTDOWN push ax, cx, dx, bp call ObjInitDetach ; increment detach count for each child push ax mov ax, MSG_GEN_COUNT_CHILDREN call ObjCallInstanceNoLock ;dx = # of children pop ax mov cx, dx jcxz done 10$: call ObjIncDetach loop 10$ ; send to children mov dx, ds:[LMBH_handle] mov bp, si ;dx:bp = OD for ACK call GenSendToChildren done: pop ax, cx, dx, bp mov di, offset OLDocumentGroupClass call ObjCallSuperNoLock call ObjEnableDetach Destroy ax, cx, dx, bp ret OLDocumentGroupDetach endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupShutdownComplete DESCRIPTION: Nukes generic one-way upward link, once children have shut down. PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_META_SHUTDOWN_COMPLETE cx - caller's ID dx:bp - OD for MSG_META_ACK RETURN: none DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 5/92 Initial version ardeb 10/19/92 Changed to SHUTDOWN_COMPLETE ------------------------------------------------------------------------------@ OLDocumentGroupShutdownComplete method dynamic OLDocumentGroupClass, MSG_META_SHUTDOWN_COMPLETE mov di, ds:[si] add di, ds:[di].Gen_offset mov ds:[di].GI_link.LP_next.handle, 0 ; nuke upward one-way mov ds:[di].GI_link.LP_next.chunk, 0 ; link mov di, offset OLDocumentGroupClass GOTO ObjCallSuperNoLock OLDocumentGroupShutdownComplete endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupQuit -- MSG_META_QUIT for OLDocumentGroupClass DESCRIPTION: Handle a user request to quit. PASS: *ds:si - instance data es - segment of OLApAppocumentControlClass ax - MSG_META_QUIT RETURN: none DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: ptr = first child; status = CONTINUE; while ((ptr != NULL) && (STATUS == CONTINUE)) { status = MSG_GEN_DOCUMENT_USER_CLOSE(ptr); ptr = NextSibling(ptr); } KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupQuit method dynamic OLDocumentGroupClass, MSG_META_QUIT ; Save the optr with the current model grab mov ax, MSG_META_GET_MODEL_EXCL call ObjCallInstanceNoLock ;cx:dx = cur model pushdw cxdx mov cx, ds:[di].OLDGI_quitObj.handle mov dx, ds:[di].OLDGI_quitObj.chunk tst cx jnz while ; begin at first child EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset mov cx, ds:[di].GI_comp.CP_firstChild.handle mov dx, ds:[di].GI_comp.CP_firstChild.chunk tst cx ;check for no children jz finished ; cx:dx = child ; ds:di = spec offset while: test dx, LP_IS_PARENT jnz finished push si ; find next sibling (in case this object is removed in the call) mov di, ds:[si] add di, ds:[di].Vis_offset mov bx, cx mov si, dx ;bx:si = child to call call ObjLockObjBlock mov es, ax mov bp, es:[si] add bp, es:[bp].Gen_offset mov ax, es:[bp].GI_link.LP_next.handle mov ds:[di].OLDGI_quitObj.handle, ax mov ax, es:[bp].GI_link.LP_next.chunk mov ds:[di].OLDGI_quitObj.chunk, ax call MemUnlock EC < push ax > ; ec shouldn't trash EC < mov ax, NULL_SEGMENT > ; to avoid ec crash EC < mov_tr es, ax > EC < pop ax > ; ec shouldn't trash movdw bxsi, cxdx mov ax, MSG_META_GRAB_MODEL_EXCL mov di, mask MF_FIXUP_DS call ObjMessage mov ax, MSG_GEN_DOCUMENT_CLOSE clr bp ; user-initiated mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage ;cx = DocQuitStatus pop si cmp cx, DQS_SAVE_ERROR jz cancel cmp cx, DQS_CANCEL jz cancel cmp cx, DQS_DELAYED jz delayed ; continue, but clear the queue first popdw bxdx call restoreModel mov ax, MSG_META_QUIT mov bx, ds:[LMBH_handle] mov di, mask MF_FORCE_QUEUE GOTO ObjMessage ; all done ! finished: popdw cxdx clr cx jmp common ; delayed (in the middle of a ""save as"") delayed: popdw bxdx ret ; cancel quitting cancel: popdw bxdx call restoreModel mov cx, -1 ;cx = non-zero (abort) common: clr ax mov di, ds:[si] add di, ds:[di].Vis_offset mov ds:[di].OLDGI_quitObj.handle, ax mov ds:[di].OLDGI_quitObj.chunk, ax mov ax, MSG_META_QUIT_ACK call SendToUIDocControl Destroy ax, cx, dx, bp ret restoreModel: ; restore the model grab to the doc which had it initially xchg dx, si mov ax, MSG_META_GRAB_MODEL_EXCL mov di, mask MF_FIXUP_DS call ObjMessage ;restore the cur model xchg dx, si retn OLDocumentGroupQuit endm SendToUIDocControl proc far class OLDocumentGroupClass EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset mov bx, ds:[di].GDGI_documentControl.handle mov si, ds:[di].GDGI_documentControl.chunk mov di, mask MF_FIXUP_DS GOTO ObjMessage SendToUIDocControl endp DocExit ends ;--- DocCommon segment resource COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetTotalSize -- MSG_OLDG_GET_TOTAL_SIZE for OLDocumentGroupClass DESCRIPTION: Returns total size of all child documents. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_OLDG_GET_TOTAL_SIZE RETURN: dx.cx -- total size bp - non-zero if an individual file was too large ax - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 1/16/94 Initial Version ------------------------------------------------------------------------------@ if FLOPPY_BASED_DOCUMENTS OLDocumentGroupGetTotalSize method dynamic OLDocumentGroupClass, \\ MSG_OLDG_GET_TOTAL_SIZE clrdw dxcx ; initialize size clr bp ; no individual files too large yet mov ax, MSG_OL_DOCUMENT_ADD_SIZE_TO_TOTAL clr bx ; initial child (first push bx ; child of push bx ; composite) mov bx, offset GI_link ; Pass offset to LinkPart push bx clr bx ; Use standard function push bx mov bx,OCCT_DONT_SAVE_PARAMS_DONT_TEST_ABORT push bx EC< call GenCheckGenAssumption ; Make sure gen data exists > mov bx, offset Gen_offset mov di, offset GI_comp call ObjCompProcessChildren ;must use a call (no GOTO) since ;parameters are passed on the stack ret OLDocumentGroupGetTotalSize endm endif COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupMarkDirty -- MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY for OLDocumentGroupClass DESCRIPTION: Mark a document as dirty PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY cx:dx - document to mark dirty. If 0 then the target document is marked as dirty RETURN: DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupMarkDirty method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY mov ax, MSG_GEN_DOCUMENT_MARK_DIRTY FALL_THRU SendToCXDXOrTargetDocument OLDocumentGroupMarkDirty endm COMMENT @---------------------------------------------------------------------- FUNCTION: SendToCXDXOrTargetDocument DESCRIPTION: Send a method to the document in cx:dx or to the target document if cx:dx is 0 CALLED BY: GLOBAL PASS: *ds:si - GenDocumentGroup ax - method to send cx:dx - document or 0 to send to target RETURN: none DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ SendToCXDXOrTargetDocument proc far tst cx jnz common pushdw bxsi mov bx, segment GenDocumentClass mov si, offset GenDocumentClass mov di, mask MF_RECORD call ObjMessage popdw bxsi mov cx, di mov dx, TO_MODEL mov ax, MSG_META_SEND_CLASSED_EVENT GOTO ObjCallInstanceNoLock common: movdw bxsi, cxdx mov di, mask MF_FIXUP_DS GOTO ObjMessage SendToCXDXOrTargetDocument endp COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupSendClassedEvent DESCRIPTION: Sends ""TO_MODEL"" messages on to current Model exclusive PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_META_SEND_CLASSED_EVENT cx - handle of classed event dx - TargetObject RETURN: REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 7/91 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupSendClassedEvent method OLDocumentGroupClass, \\ MSG_META_SEND_CLASSED_EVENT cmp dx, TO_MODEL je toModelDoc mov di, offset OLDocumentGroupClass GOTO ObjCallSuperNoLock toModelDoc: movdw bxbp, ds:[di].OLDGI_modelExcl.HG_OD clr di call FlowDispatchSendOnOrDestroyClassedEvent ret OLDocumentGroupSendClassedEvent endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetDocByFile -- MSG_GEN_DOCUMENT_GROUP_GET_DOC_BY_FILE for OLDocumentGroupClass DESCRIPTION: Set the output PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_GET_DOC_BY_FILE cx - file handle open to the document RETURN: cx:dx - OD (0 if none) cx - unchanged ALLOWED TO DESTROY: ax bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetDocByFile method OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_DOC_BY_FILE doc local optr .enter ; ; Use ObjCompProcessChildren to send MSG_GEN_DOCUMENT_TEST_FOR_FILE ; to each of our GenDocument children. If the file handle passed in CX ; doesn't belong to the child, it will return carry clear with CX ; unmodified, so we can tell OCPC to not save the parameters. If the ; file does belong to the child, it will mark itself dirty and return ; carry set, causing the processing of the children to abort. ; clr ax mov doc.handle, ax mov doc.chunk, ax push bp mov dx, ss lea bp, doc push ax ; Start with the first child push ax mov di, offset GI_link push di push ax ; Use canned callback mov ax, OCCT_DONT_SAVE_PARAMS_TEST_ABORT push ax mov bx, offset Gen_offset mov di, offset GI_comp mov ax, MSG_GEN_DOCUMENT_TEST_FOR_FILE call ObjCompProcessChildren pop bp mov cx, doc.handle mov dx, doc.chunk .leave ret OLDocumentGroupGetDocByFile endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupMarkDirtyByFile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Locate the document that has the given file open and mark it dirty CALLED BY: MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY_BY_FILE PASS: *ds:si = instance data es = segment of OLDocumentGroupClass ax = MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY_BY_FILE cx = file handle RETURN: nothing DESTROYED: ? PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/ 9/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupMarkDirtyByFile method OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY_BY_FILE call OLDocumentGroupGetDocByFile ;cx:dx = OD EC < tst cx > EC < ERROR_Z PASSED_FILE_NOT_OPENED_BY_DOCUMENT_CONTROL > mov bx, cx mov si, dx mov ax, MSG_GEN_DOCUMENT_MARK_DIRTY mov di, mask MF_FIXUP_DS GOTO ObjMessage OLDocumentGroupMarkDirtyByFile endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupAutoSaveByFile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Locate the document that has the given file open and trigger an autosave CALLED BY: MSG_GEN_DOCUMENT_GROUP_AUTO_SAVE_BY_FILE PASS: *ds:si = instance data es = segment of OLDocumentGroupClass ax = MSG_GEN_DOCUMENT_GROUP_AUTO_SAVE_BY_FILE cx = file handle RETURN: nothing DESTROYED: cx, dx, bx, si, ax, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- rg 4/10/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupAutoSaveByFile method OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_AUTO_SAVE_BY_FILE call OLDocumentGroupGetDocByFile ;cx:dx = OD jcxz notMyDoc mov bx, cx mov si, dx mov ax, MSG_GEN_DOCUMENT_AUTO_SAVE mov di, mask MF_FIXUP_DS GOTO ObjMessage notMyDoc: ret OLDocumentGroupAutoSaveByFile endp COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupFileChanged -- MSG_OLDG_FILE_CHANGED for OLDocumentGroupClass DESCRIPTION: Update the UI for the document control (pass this on to the UI document control) PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_OLDG_FILE_CHANGED dx - size DocumentFileChangedParams ss:bp - DocumentFileChangedParams RETURN: cx, dx, bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupFileChanged method dynamic OLDocumentGroupClass, MSG_OLDG_FILE_CHANGED EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset mov bx, ds:[di].GDGI_documentControl.handle mov si, ds:[di].GDGI_documentControl.chunk mov ax, MSG_GEN_DOCUMENT_CONTROL_FILE_CHANGED mov dx, size DocumentFileChangedParams mov di, mask MF_STACK GOTO ObjMessage OLDocumentGroupFileChanged endm ;------ OLDocumentGroupGetUIAttrs method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_UI_ATTRS mov ax, MSG_GEN_DOCUMENT_CONTROL_GET_ATTRS GOTO CallUIDocControl OLDocumentGroupGetUIAttrs endm ;------ OLDocumentGroupGetTemplateDir method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_TEMPLATE_DIR mov ax, MSG_GEN_DOCUMENT_CONTROL_GET_TEMPLATE_DIR GOTO CallUIDocControl OLDocumentGroupGetTemplateDir endm ;------ OLDocumentGroupGetUIFeatures method dynamic \\ OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_UI_FEATURES mov ax, MSG_GEN_DOCUMENT_CONTROL_GET_FEATURES FALL_THRU CallUIDocControl OLDocumentGroupGetUIFeatures endm ;------ CallUIDocControl proc far class OLDocumentGroupClass EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset mov bx, ds:[di].GDGI_documentControl.handle mov si, ds:[di].GDGI_documentControl.chunk mov di, mask MF_CALL or mask MF_FIXUP_DS GOTO ObjMessage CallUIDocControl endp COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetOutput -- MSG_GEN_DOCUMENT_GROUP_GET_OUTPUT for OLDocumentGroupClass DESCRIPTION: Get the output PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_GET_OUTPUT cx:dx - output RETURN: bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetOutput method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_OUTPUT add bx, ds:[bx].Gen_offset movdw cxdx, ds:[bx].GDGI_output ret OLDocumentGroupGetOutput endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetAttrs -- MSG_GEN_DOCUMENT_GROUP_GET_ATTRS for OLDocumentGroupClass DESCRIPTION: Get the DocumentControlAttrs PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_GET_ATTRS RETURN: ax - GenDocumentGroupAttrs cx, dx, bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetAttrs method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_ATTRS add bx, ds:[bx].Gen_offset mov ax, ds:[bx].GDGI_attrs ret OLDocumentGroupGetAttrs endm DocCommon ends ;--- DocNewOpen segment resource COMMENT @---------------------------------------------------------------------- MESSAGE: OLDocumentGroupAlterFTVMCExcl -- MSG_META_MUP_ALTER_FTVMC_EXCL for OLDocumentGroupClass DESCRIPTION: Alter an exclusive PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message cx:dx - object bp - flags RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 5/ 4/92 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupAlterFTVMCExcl method dynamic OLDocumentGroupClass, MSG_META_MUP_ALTER_FTVMC_EXCL ; Since we're a model node, check to see if this request ; includes a change to the focus hierarchy. test bp, mask MAEF_MODEL jz callSuper ; if not, skip & send to superclass ; Call Flow utility routine to handle modifying the node push ax ; save message mov ax, MSG_META_GAINED_MODEL_EXCL ;pass gained message push bp ; save original flags ; Pass only the ""GRAB"" flag & ; which hierarchy this node is. and bp, mask MAEF_GRAB or mask MAEF_MODEL mov bx, offset Vis_offset mov di, offset OLDGI_modelExcl call FlowAlterHierarchicalGrab pop bp ; restore original flags pop ax ; restore message ; Now that we've updated the focus node, clear that portion ; of the request from the flags and bp, not mask MAEF_MODEL ; If request was also to grab/release on other nodes, pass on request test bp, MAEF_MASK_OF_ALL_HIERARCHIES jz done ; otherwise done. callSuper: ; Pass message on to superclass for handling outside of this class. mov di, offset OLDocumentGroupClass call ObjCallSuperNoLock done: ret OLDocumentGroupAlterFTVMCExcl endm COMMENT @---------------------------------------------------------------------- FUNCTION: CreateDocObject DESCRIPTION: Create a new document object and add it as a child of this object. Send it a new or open method and send the correct notification CALLED BY: INTERNAL PASS: *ds:si - GenDocumentGroup object ax - method to send to document dx - size DocumentCommonParams ss:bp - DocumentCommonParams RETURN: cx:dx - new Document object created (0 if error) DESTROYED: ax, bx, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version Steve 2/92 Added duplicate resource option ------------------------------------------------------------------------------@ CreateDocObject proc far class OLDocumentGroupClass if CUSTOM_DOCUMENT_PATH call CustomDocPathInitDocCommonParams endif ; CUSTOM_DOCUMENT_PATH push ax ;message push bp ;stack frame offset ; create a new object EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset tst ds:[di].GDGI_genDocument.handle LONG jnz duplicateDocumentResource les di, ds:[di].GDGI_documentClass push si ;doc control chunk mov bx, ds:[LMBH_handle] ;put it in this block call ObjInstantiate ;create new object (bx:si) mov dx, si ;new document chunk pop si ;doc control chunk addDocument: pop bp ;stack frame offset push bp ;stack frame offset ; If opening for an IACP connection, set ; ATTR_GEN_DOCUMENT_OPEN_FOR_IACP_ONLY on the new object ; ; { test ss:[bp].DCP_flags, mask DOF_OPEN_FOR_IACP_ONLY jz afterPrintCheck push dx, si ;new chunk, control chunk mov si, dx ;new chunk mov dx, size AddVarDataParams sub sp, dx mov bp, sp clr ax mov ss:[bp].AVDP_data.segment, ax mov ss:[bp].AVDP_data.offset, ax mov ss:[bp].AVDP_dataSize, ax mov ss:[bp].AVDP_dataType, ATTR_GEN_DOCUMENT_OPEN_FOR_IACP_ONLY mov ax, MSG_META_ADD_VAR_DATA mov di, mask MF_FIXUP_DS call ObjMessage add sp, size AddVarDataParams pop dx, si ;new chunk, control chunk afterPrintCheck: ; } ; add new document object as child of document control mov cx, bx ;new document handle mov bp, CCO_FIRST or mask CCF_MARK_DIRTY mov ax, MSG_GEN_ADD_CHILD call ObjCallInstanceNoLock ; Update the number of documents NKE < call OLDocumentGroupUpdateDocumentCount > ; mark the new document object as usable push dx, si ;new chunk, control chunk mov si, dx ;new chunk mov ax, MSG_GEN_SET_USABLE mov dl, VUM_MANUAL mov di, mask MF_FIXUP_DS call ObjMessage pop dx, si ;new chunk, control chunk ; send new document object the file name pop bp ;stack frame offset pop ax ;ax = method to send to doc push si ;document control chunk mov si, dx ;^lbx:si = new document mov dx, size DocumentCommonParams mov di,mask MF_FIXUP_DS or mask MF_CALL or mask MF_STACK call ObjMessage ;carry - set if error ;bp = file handle mov cx, bx ;cx:dx = document mov dx, si pop si ;*ds:si = control jnc done ; error -- remove new document from document control push si ;save doc control mov ax, MSG_OLDG_REMOVE_DOC call ObjCallInstanceNoLock mov ax, MSG_OLDC_TEST_FOR_DISPLAY_MAIN_DIALOG call SendToUIDocControl clr cx clr dx pop si ;*ds:si = doc control stc done: ret duplicateDocumentResource: mov bx,ds:[di].GDGI_genDocument.handle ;resource handle clr ax ; have current geode own block clr cx ; have current thread run block call ObjDuplicateResource mov dx,ds:[di].GDGI_genDocument.chunk jmp addDocument CreateDocObject endp if CUSTOM_DOCUMENT_PATH COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CustomDocPathInitDocCommonParams %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initializes the passed DocumentCommonParams with the values in ATTR_GEN_PATH_DATA if present. CALLED BY: (INTERNAL) CreateDocObject, OLDocumentGroupGetDefaultName PASS: *ds:si - Object containing ATTR_GEN_PATH_DATA ss:bp - DocumentCommonParams RETURN: DocumentCommonParams structure modified if ATTR_GEN_PATH_DATA present. DESTROYED: nothing SIDE EFFECTS: none PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ptrinh 12/16/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CustomDocPathInitDocCommonParams proc near uses ax,bx,si,di,es .enter ; ; Only copy if there wasn't passed a diskhandle or path... ; tst ss:[bp].DCP_diskHandle jnz done tst {TCHAR}ss:[bp].DCP_path[0] jnz done ; ; and if exists ATTR_GEN_PATH_DATA... ; mov ax, ATTR_GEN_PATH_DATA call ObjVarFindData ; ds:bx - GenFilePath jnc done ; ; Copy disk handle and path name -- optimized based on ; assumptions. (See CheckHack.) ; segmov es, ss, di lea di, ss:[bp].DCP_diskHandle ; es:di - dst lea si, ds:[bx].GFP_disk ; ds:si - src movsw ; DiskHandle CheckHack < size GFP_disk eq size word > LocalCopyString ; Path CheckHack < offset DCP_diskHandle + 2 eq offset DCP_path > CheckHack < offset GFP_disk + 2 eq offset GFP_path > done: .leave ret CustomDocPathInitDocCommonParams endp endif ; CUSTOM_DOCUMENT_PATH COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupUpdateDocumentCount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Update the number of documents CALLED BY: CreateDocObject OLDocumentGroupRemoveDoc PASS: *ds:si = GenDocumentGroup RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/ 8/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupOpenDoc -- MSG_GEN_DOCUMENT_GROUP_OPEN_DOC for OLDocumentGroupClass DESCRIPTION: Open a file PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_OPEN_DOC dx - size DocumentCommonParams ss:bp - DocumentCommonParams RETURN: cx:dx - new Document object created (0 if error) DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupOpenDoc method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_OPEN_DOC ornf ss:[bp].DCP_flags, mask DOF_RAISE_APP_AND_DOC ; If we are being asked to FORCE template behavior, then ALWAYS ; ""open"" the document (since it really opens the document and copies ; it into a new document). --JimG 9/2/94 test ss:[bp].DCP_flags, mask DOF_FORCE_TEMPLATE_BEHAVIOR jnz openIt call OLDocumentGroupSearchForDoc jc done openIt: mov ax, MSG_GEN_DOCUMENT_OPEN call CreateDocObject done: ret OLDocumentGroupOpenDoc endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupSearchForDoc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Search our generic children for one that has a document open CALLED BY: MSG_GEN_DOCUMENT_GROUP_SEARCH_FOR_DOC PASS: *ds:si = GenDocumentGroup object ss:bp = DocumentCommonParams describing the document RETURN: carry set if document found DESTROYED: ax, bx, di SIDE EFFECTS: the document and app may be raised, if DOF_RAISE_APP_AND_DOC is set in the DCP and the document is found. PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupSearchForDoc method OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_SEARCH_FOR_DOC .enter test ss:[bp].DCP_flags, mask DOF_NAME_HOLDS_FILE_ID jnz haveID ; ; Fetch the real ID for the document. ; push ds, si segmov ds, ss lea dx, ss:[bp].DCP_path lea si, ss:[bp].DCP_name mov bx, ss:[bp].DCP_diskHandle call IACPGetDocumentID pop ds, si ; ; Save the first four bytes of DCP_name and the original disk handle. ; pushdw ({FileID}ss:[bp].DCP_name) push ss:[bp].DCP_diskHandle ; ; Replace them with the 48-bit file ID. ; movdw ({FileID}ss:[bp].DCP_name), cxdx mov ss:[bp].DCP_diskHandle, ax haveID: push ss:[bp].DCP_flags ; save so we know what to pop ornf ss:[bp].DCP_flags, mask DOF_NAME_HOLDS_FILE_ID clr ax push ax, ax ;first child mov ax, offset GI_link push ax clr ax push ax ;callback.segment mov ax, OCCT_SAVE_PARAMS_TEST_ABORT push ax ;callback.offset mov bx, offset Gen_offset mov di, offset GI_comp mov ax, MSG_GEN_DOCUMENT_SEARCH_FOR_DOC call ObjCompProcessChildren ; ; Restore disk handle and first four bytes of the name if necessary. ; lahf pop bx test bx, mask DOF_NAME_HOLDS_FILE_ID jnz done pop ss:[bp].DCP_diskHandle popdw ({FileID}ss:[bp].DCP_name) done: sahf .leave ret OLDocumentGroupSearchForDoc endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetDefaultName -- MSG_GEN_DOCUMENT_GROUP_GET_DEFAULT_NAME for OLDocumentGroupClass DESCRIPTION: Get the DocumentControlAttrs PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_GET_DEFAULT_NAME cx:dx - DocumentCommonParams buffer RETURN: ax - DocumentControlAttrs cx, dx, bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetDefaultName method dynamic \\ OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_DEFAULT_NAME uses cx, dx .enter mov es, cx mov di, dx ; default documents retrieved from us are always in the DOCUMENT ; directory 7/29/93 cbh if UNTITLED_DOCS_ON_SP_TOP mov es:[di].DCP_diskHandle, SP_TOP elseif CUSTOM_DOCUMENT_PATH mov es:[di].DCP_diskHandle, 0 else mov es:[di].DCP_diskHandle, SP_DOCUMENT endif mov {TCHAR}es:[di].DCP_path[0], 0 if CUSTOM_DOCUMENT_PATH call CustomDocPathInitDocCommonParams endif ; CUSTOM_DOCUMENT_PATH ; copy default name from our instance data. mov si, ds:[si] add si, ds:[si].Gen_offset mov ax, ds:[si].GDGI_attrs ; return attrs in ax mov si, ds:[si].GDGI_untitledName mov si, ds:[si] ;ds:si = source (default name) CheckHack ChunkSizePtr ds, si, cx SBCS > DBCS > EC < ERROR_A OLAPPDC_DEFAULT_NAME_TOO_LONG > rep movsb .leave ret OLDocumentGroupGetDefaultName endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetToken -- MSG_GEN_DOCUMENT_GROUP_GET_TOKEN for OLDocumentGroupClass DESCRIPTION: Get the token from the UI doc control PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message cx:dx - address to store token RETURN: cx, dx, bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetToken method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_TOKEN mov ax, MSG_GEN_DOCUMENT_CONTROL_GET_TOKEN call CallUIDocControl ret OLDocumentGroupGetToken endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetProtocol -- MSG_GEN_DOCUMENT_GROUP_GET_PROTOCOL for OLDocumentGroupClass DESCRIPTION: Get the protocol PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_GET_PROTOCOL RETURN: cx - major protocol dx - minor protocol bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetProtocol method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_PROTOCOL add bx, ds:[bx].Gen_offset mov cx, ds:[bx].GDGI_protocolMajor mov dx, ds:[bx].GDGI_protocolMinor ret OLDocumentGroupGetProtocol endm COMMENT @---------------------------------------------------------------------- MESSAGE: OLDocumentGroupGetView -- MSG_APP_GEN_DOCUMENT_CONTROL_GET_VIEW for OLDocumentGroupClass DESCRIPTION: Return to associated GenView PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message RETURN: cx:dx - GenView ax, bp - unchanged DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 7/25/91 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetView method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_VIEW add bx, ds:[bx].Gen_offset movdw cxdx, ds:[bx].GDGI_genView ret OLDocumentGroupGetView endm COMMENT @---------------------------------------------------------------------- MESSAGE: OLDocumentGroupGetDisplay -- MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY for OLDocumentGroupClass DESCRIPTION: Return to associated GenDisplay PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message RETURN: cx:dx - GenDisplay ax, bp - unchanged DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 7/25/91 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetDisplay method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY add bx, ds:[bx].Gen_offset movdw cxdx, ds:[bx].GDGI_genDisplay ret OLDocumentGroupGetDisplay endm COMMENT @---------------------------------------------------------------------- MESSAGE: OLDocumentGroupGetDisplayGroup -- MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY_GROUP for OLDocumentGroupClass DESCRIPTION: Return to associated GenDisplayGroup PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message RETURN: cx:dx - GenDisplayGroup ax, bp - unchanged DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 7/25/91 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetDisplayGroup method dynamic \\ OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY_GROUP add bx, ds:[bx].Gen_offset movdw cxdx, ds:[bx].GDGI_genDisplayGroup ret OLDocumentGroupGetDisplayGroup endm DocNewOpen ends ;--- DocNew segment resource OLDocumentGroupGetCreator method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_GET_CREATOR mov ax, MSG_GEN_DOCUMENT_CONTROL_GET_CREATOR call CallUIDocControl ret OLDocumentGroupGetCreator endm DocNew ends ;--- DocMisc segment resource COMMENT @---------------------------------------------------------------------- MESSAGE: OLDocumentGroupImportNewDoc -- MSG_GEN_DOCUMENT_GROUP_IMPORT_NEW_DOC for OLDocumentGroupClass DESCRIPTION: Create a new document and import into it PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - The message ss:bp - ImpexTranslationParams dx -- size ImpexTranslationParams RETURN: cx:dx - new Document object created carry - set if error DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 6/ 9/92 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupImportNewDoc method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_IMPORT_NEW_DOC push bp sub sp, size DocumentCommonParams mov bp, sp clr ax mov ss:[bp].DCP_flags, mask DOF_FORCE_REAL_EMPTY_DOCUMENT mov ss:[bp].DCP_diskHandle, ax mov ss:[bp].DCP_connection, ax mov ss:[bp].DCP_docAttrs, mask GDA_UNTITLED mov ax, MSG_GEN_DOCUMENT_NEW call CreateDocObject lahf add sp, size DocumentCommonParams sahf pop bp jc done push bp movdw bxsi, cxdx mov dx, size ImpexTranslationParams mov ax, MSG_GEN_DOCUMENT_IMPORT mov di, mask MF_FIXUP_DS call ObjMessage movdw cxdx, bxsi pop bp done: pushf mov ax, ss:[bp].ITP_returnMsg movdw bxsi, ss:[bp].ITP_impexOD mov dx, size ImpexTranslationParams mov di, mask MF_STACK call ObjMessage popf ret OLDocumentGroupImportNewDoc endm DocMisc ends ;--- DocObscure segment resource COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupGetDocName-- MSG_PRINT_GET_DOC_NAME for OLDocumentGroupClass DESCRIPTION: Get the document name from the target document PASS: DS:DI = OLDocumentGroupClass specific instance data DS:BX = Deref'd OLDocumentGroupClass ES = Segment of OLApAppocumentControlClass CX:DX = OD to send method name to (PrintControlClass) BP = Method to send to OD (MSG_PRINT_CONTROL_SET_DOC_NAME) RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: I allocate more than the necessary number of bytes on the stack, as that is what the DocumentClass expects. Actually, though, the name cannot exceed FILE_LONGNAME_LENGTH+1, include the null terminator. REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupGetDocName method dynamic OLDocumentGroupClass, \\ MSG_PRINT_GET_DOC_NAME .enter ; Allocate memory for the block ; mov bx, di ; OLAppDocInstance => DS:BX sub sp, FILE_LONGNAME_BUFFER_SIZE ; bytes to allocate mov di, sp ; store buffer => AX push cx, dx ; store the SPC OD mov {byte} ss:[di], 0 ; null terminate the string mov cx, ss mov dx, di ; buffer => CX:DX ; Ask the target document to fill the block ; mov si, ds:[bx].OLDGI_modelExcl.HG_OD.chunk mov bx, ds:[bx].OLDGI_modelExcl.HG_OD.handle tst bx ; any target document ?? jz done ; nope, so return empty string mov ax, MSG_GEN_DOCUMENT_GET_FILE_NAME mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage ; fill that block! ; Now send the document name off to the SpoolPrintControl ; done: pop bx, si ; PrintControl OD => BX:SI mov ax, bp ; method => AX mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage ; send the document name add sp, FILE_LONGNAME_BUFFER_SIZE .leave ret OLDocumentGroupGetDocName endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupSetOutput -- MSG_GEN_DOCUMENT_GROUP_SET_OUTPUT for OLDocumentGroupClass DESCRIPTION: Set the output PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_GEN_DOCUMENT_GROUP_SET_OUTPUT cx:dx - output RETURN: cx, dx, bp - unchanged DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupSetOutput method dynamic OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_SET_OUTPUT mov di, ds:[si] add di, ds:[di].Gen_offset mov ds:[di].GDGI_output.handle, cx mov ds:[di].GDGI_output.chunk, dx ret OLDocumentGroupSetOutput endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OLDocumentGroupGetModelExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Gets the model exclusive for this app. CALLED BY: GLOBAL PASS: nada RETURN: cx:dx - model object carry set DESTROYED: nada PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- atw 5/14/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OLDocumentGroupGetModelExcl method dynamic OLDocumentGroupClass, MSG_META_GET_MODEL_EXCL .enter movdw cxdx, ds:[di].OLDGI_modelExcl.HG_OD stc .leave ret OLDocumentGroupGetModelExcl endp DocObscure ends ;--- DocSaveAsClose segment resource COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupRemoveDoc -- MSG_OLDG_REMOVE_DOC for OLDocumentGroupClass DESCRIPTION: Remove an already closed document PASS: *ds:si - instance data es - segment of OLDocumentGroupClass ax - MSG_OLDG_REMOVE_DOC cx:dx - document to remove RETURN: DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupRemoveDoc method dynamic OLDocumentGroupClass, MSG_OLDG_REMOVE_DOC ; release all exclusives for the document push cx, dx, si mov ax, MSG_META_RELEASE_MODEL_EXCL movdw bxsi, cxdx mov di, mask MF_FIXUP_DS call ObjMessage ; make the document not usable mov ax, MSG_GEN_SET_NOT_USABLE mov dl, VUM_NOW mov di, mask MF_FIXUP_DS call ObjMessage pop cx, dx, si ; remove the document clr bp ;don't bother marking dirty mov ax, MSG_GEN_REMOVE_CHILD call ObjCallInstanceNoLock ; Update the number of documents NKE < call OLDocumentGroupUpdateDocumentCount > ; if this document was the target document then zero the target ; OR if this document was the last document push cx,dx ;document OD ; free the document. If the genDocument.handle field is ; non-zero, it means that a resource was duplicated to ; create the document and we must free the block ; that resulted from duplicating the resource. Otherwise ; the document was created with ObjInstantiate in the ; same block as the Control and we should just free the object EC < call GenCheckGenAssumption > mov di, ds:[si] add di, ds:[di].Gen_offset tst ds:[di].GDGI_genDocument.handle jnz freeBlock mov ax,MSG_META_OBJ_FREE ; free object only jmp freeIt freeBlock: mov ax,MSG_META_BLOCK_FREE ; free whole block freeIt: pop bx,si ; document OD mov di,mask MF_FIXUP_DS call ObjMessage ret OLDocumentGroupRemoveDoc endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupSaveAsCancelled -- MSG_GEN_DOCUMENT_GROUP_SAVE_AS_CANCELLED for OLDocumentGroupClass DESCRIPTION: Cancel quitting PASS: *ds:si - instance data es - segment of OLApAppocumentControlClass ax - MSG_GEN_DOCUMENT_GROUP_SAVE_AS_CANCELLED RETURN: DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupSaveAsCancelled method dynamic \\ OLDocumentGroupClass, MSG_GEN_DOCUMENT_GROUP_SAVE_AS_CANCELLED mov ax, MSG_OLDG_USER_CLOSE_CANCELLED call ObjCallInstanceNoLock ; inform target document mov ax, MSG_GEN_DOCUMENT_SAVE_AS_CANCELLED clr cx call SendToCXDXOrTargetDocument ; ; Clear out any pending query-save-documents reply. 3/30/94 cbh ; clr cx mov ax, MSG_META_QUERY_SAVE_DOCUMENTS GOTO ObjCallInstanceNoLock OLDocumentGroupSaveAsCancelled endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupUserCloseCancelled -- MSG_OLDG_USER_CLOSE_CANCELLED for OLDocumentGroupClass DESCRIPTION: User close cancelled PASS: *ds:si - instance data es - segment of OLApAppocumentControlClass ax - MSG_OLDG_USER_CLOSE_CANCELLED RETURN: DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupUserCloseCancelled method dynamic \\ OLDocumentGroupClass, MSG_OLDG_USER_CLOSE_CANCELLED clr ax mov ds:[di].OLDGI_quitObj.chunk, ax xchg ax, ds:[di].OLDGI_quitObj.handle tst ax jz notQuitting mov cx, -1 ;cx = non-zero (abort) mov ax, MSG_META_QUIT_ACK push si ;save app doc control ptr call SendToUIDocControl pop si ;restore ptr notQuitting: ret OLDocumentGroupUserCloseCancelled endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupUserCloseOK -- MSG_OLDG_USER_CLOSE_OK for OLDocumentGroupClass DESCRIPTION: User close OK PASS: *ds:si - instance data es - segment of OLApAppocumentControlClass ax - MSG_OLDG_USER_CLOSE_OK RETURN: DESTROYED: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 1/90 Initial version ------------------------------------------------------------------------------@ OLDocumentGroupUserCloseOK method dynamic \\ OLDocumentGroupClass, MSG_OLDG_USER_CLOSE_OK tst ds:[di].OLDGI_quitObj.handle jz notQuitting mov ax, MSG_META_QUIT ;continue call ObjCallInstanceNoLock notQuitting: ret OLDocumentGroupUserCloseOK endm COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupQuerySaveDocuments -- MSG_META_QUERY_SAVE_DOCUMENTS for OLDocumentGroupClass DESCRIPTION: Queries user to save any opened documents, prior to switching applications. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_META_QUERY_SAVE_DOCUMENTS cx - event to use after we`ve done our duty RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 6/23/93 Initial Version ------------------------------------------------------------------------------@ if VOLATILE_SYSTEM_STATE OLDocumentGroupQuerySaveDocuments method dynamic OLDocumentGroupClass, \\ MSG_META_QUERY_SAVE_DOCUMENTS ; ; Save the passed event to use when we're done. ; If there's already an event hanging around, let's nuke it. ; mov bx, ds:[di].OLDGI_appSwitchMsg ;get current message mov ds:[di].OLDGI_appSwitchMsg, cx ;store new message tst bx ;no old message, branch jz 10$ call ObjFreeMessage 10$: ; ; If no message was passed in cx, the system is trying to flush ; out the query message because of a user cancel, so we'll do ; nothing further. 3/30/94 cbh ; tst cx jz exit mov ax, MSG_OL_DOCUMENT_WAIT_FOR_QUERY call GenSendToChildren ;have documents wait for query ;if anyone is clean, mark them now mov ax, MSG_OLDG_DOC_MARKED_CLEAN call ObjCallInstanceNoLock exit: ret OLDocumentGroupQuerySaveDocuments endm endif COMMENT @---------------------------------------------------------------------- METHOD: OLDocumentGroupDocMarkedClean -- MSG_OLDG_DOC_MARKED_CLEAN for OLDocumentGroupClass DESCRIPTION: Sent when a document marks itself clean. PASS: *ds:si - instance data es - segment of MetaClass ax - MSG_OLDG_DOC_MARKED_CLEAN RETURN: nothing ax, cx, dx, bp - destroyed ALLOWED TO DESTROY: bx, si, di, ds, es REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- chris 7/26/93 Initial Version ------------------------------------------------------------------------------@ if VOLATILE_SYSTEM_STATE OLDocumentGroupDocMarkedClean method dynamic OLDocumentGroupClass, \\ MSG_OLDG_DOC_MARKED_CLEAN ; ; Not in app switching mode, exit ; mov cx, ds:[di].OLDGI_appSwitchMsg tst cx jz exit ; ; Collect the number of currently dirty documents. ; push cx call CheckDirtyDocuments ;counts number of dirties pop bx ;restore app switch message jc stillDirty ;still a dirty document, branch ; ; Fire off the stored app switching message. ; mov di, mask MF_FORCE_QUEUE call MessageDispatch ; ; Event fired off, nuke references to it. ; EC < call VisCheckVisAssumption > mov di, ds:[si] add di, ds:[di].Vis_offset clr ds:[di].OLDGI_appSwitchMsg jmp short exit stillDirty: ; ; Still at least one dirty document open, go fire off another ; MSG_META_QUERY_SAVE_DOCUMENTS to a document that is waiting for it. ; call QueryFirstDocumentWaiting exit: ret OLDocumentGroupDocMarkedClean endm endif COMMENT @---------------------------------------------------------------------- ROUTINE: QueryFirstDocumentWaiting SYNOPSIS: Sends message to the first document still waiting for a query. CALLED BY: OLDocumentGroupDocMarkedClean PASS: nothing RETURN: nothing DESTROYED: ax, bx, cx, dx, bp, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 8/27/93 Initial version ------------------------------------------------------------------------------@ if VOLATILE_SYSTEM_STATE QueryFirstDocumentWaiting proc near mov ax, MSG_OL_DOCUMENT_QUERY_IF_WAITING clr bx ; initial child (first push bx ; child of push bx ; composite) mov bx,offset GI_link ;pass offset to LinkPart push bx clr bx push bx ;send message ; ornf bx, OCCT_SAVE_PARAMS_TEST_ABORT push bx mov bx,offset Gen_offset ;pass offset to master part mov di,offset GI_comp ;pass offset to composite call ObjCompProcessChildren ret QueryFirstDocumentWaiting endp endif DocSaveAsClose ends Resident segment resource COMMENT @---------------------------------------------------------------------- ROUTINE: CheckDirtyDocuments, CheckDocumentDirty SYNOPSIS: Checks if any document dirty, or on the ramdisk. CALLED BY: OLDocumentGroupDocMarkedClean PASS: *ds:si -- doc group/ document RETURN: carry set if any dirty documents DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 7/26/93 Initial version ------------------------------------------------------------------------------@ if VOLATILE_SYSTEM_STATE CheckDirtyDocuments proc far mov bx, offset CheckDocumentDirty clr di ;do all children call OLResidentProcessGenChildrenFromDI ret CheckDirtyDocuments endp CheckDocumentDirty proc far ; ; ; class GenDocumentClass mov di, ds:[si] add di, ds:[di].Gen_offset test ds:[di].GDI_attrs, mask GDA_AUTO_SAVE_STOPPED ;no autosave, hopefully means clc ; shutting down, ignore whether ; on ramdisk and exit c=0 jnz exit call DocCheckIfOnRamdisk ;document still on the ramdisk, jz dirty ; we need to return ""dirty"". test ds:[di].GDI_attrs, mask GDA_DIRTY jz exit dirty: stc ;return carry set and quit exit: ret CheckDocumentDirty endp endif Resident ends ",16171,True,4020.740787978791,median "COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1989 -- All Rights Reserved PROJECT: PC GEOS MODULE: Calendar/Year FILE: yearYearMain.asm AUTHOR: Don Reeves, August 24, 1989 ROUTINES: Name Description ---- ----------- InitCode: YearInit MSG_YEAR_INIT handler YearClassSpecBuild MSG_SPEC_BUILD handler YearViewToday MSG_YEAR_VIEW_TODAY handler GeometryCode: YearRecalcSize MSG_VIS_RECALC_SIZE handler YearCheckWidthMinMax Ensure width of a month is within tolerances YearCheckHeightMinMax Ensure height of a month is within tolerances StartMonthsBoundsCalc Recalculate the size/bounds of all the months YearSetMonthsBounds Recalculate the size/bounds of one month (CB) YearSetMonthSize MSG_YEAR_SET_MONTH_SIZE handler YearCode: YearPosition MSG_VIS_POSITION_BRANCH handler YearTrackScrolling MSG_META_CONTENT_TRACK_SCROLLING YearDraw MSG_VIS_DRAW handler YearDrawSelection Draw the selected dates (if any) for a year YearChangeMonthMap MSG_YEAR_CHANGE_MONTH_MAP handler YearChangeYear MSG_YEAR_CHANGE_YEAR handler YearChangeNow MSG_YEAR_CHANGE_NOW handler YearSetMonthAndYear MSG_YEAR_SET_MONTH_AND_YEAR handler SetAllMonths Set all the months to the proper month/year PositionYearDocument Re-positions the make the correct month visible YearNameDisplay Esnure the year (number) is displayed properly YearSelectedDatesToDP MSG_YEAR_SELECTED_DATES_TO_DP handler YearSelectDates MSG_YEAR_SELECT_DATES handler YearGetDate MSG_YEAR_GET_DATE handler (if Responder) REVISION HISTORY: Name Date Description ---- ---- ----------- Don 8/25/89 Initial revision Don 12/4/89 Use new class & method declarations Don 5/1/92 Reorganized resources DESCRIPTION: Define the procedures that operate on the year object $Id: yearYearMain.asm,v 1.1 97/04/04 14:49:11 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InitCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearInit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initialize the year object CALLED BY: (MSG_YEAR_INIT) PASS: ES = DGroup DS:*SI = YearClass instance data DS:DI = YearClass specific instance data BP = Year DX = Month/Day RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: This call takes a long time to complete! REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/5/89 Initial version Don 10/11/90 Added AWLAYS_TODAY code %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearInit method YearClass, MSG_YEAR_INIT ; Always grab the trarget exclusive ; mov ax, MSG_META_GRAB_TARGET_EXCL call ObjCallInstanceNoLock ; Mark object as dirty, and check to see if we need to init stuff ; mov ax, si ; chunk handle => AX mov bx, mask OCF_DIRTY ; bits to set in BL,reset in BH call ObjSetFlags ; change the flags mov di, ds:[si] add di, ds:[di].Year_offset test ds:[di].YI_flags, YI_NEEDS_INIT ; need to be initialized jnz resetSelect ; yes, so do the work test es:[showFlags], mask SF_SHOW_TODAY_ON_RELAUNCH jnz resetSelect ; select & display today if... ; Preference option is set ; Call for loading the events for the day(s) already selected ; or ds:[di].YI_flags, (YI_SEL_REGION or YI_MANUAL_CHANGE) call YearNameDisplay call MonthNameDisplay and ds:[di].YI_flags, not (YI_MANUAL_CHANGE) mov ax, MSG_YEAR_COMPLETE_SELECTION GOTO ObjCallInstanceNoLock ; bring up the range of events ; Set the selected region ; resetSelect: mov ax, MSG_YEAR_VIEW_TODAY GOTO ObjCallInstanceNoLock ; send the method YearInit endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearClassSpecBuild %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Visually build a YearClass CALLED BY: UI (MSG_SPEC_BUILD) PASS: AX = MSG_SPEC_BUILD DS:*SI = Instance data ES = DGroup RETURN: Nothing DESTROYED: AX, CX, DX, BP, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/5/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearClassSpecBuild method YearClass, MSG_SPEC_BUILD ; Call superclass to perform a normal Vis Build ; mov di, offset YearClass call ObjCallSuperNoLock ; call my superclass ; Now set up our state ; mov di, ds:[si] ; dereference the handle add di, ds:[di].Vis_offset ; access visual data or ds:[di].VCI_geoAttrs, mask VCGA_CUSTOM_MANAGE_CHILDREN ; Since this thing's size depends on things (the subview dimensions) ; other than what it's passed by the geometry manager, it ; needs to always have its geometry done, regardless of its ; invalid flags. ; or ds:[di].VI_geoAttrs, mask VGA_ALWAYS_RECALC_SIZE ; Ensure the color scheme is set up, and attempt to initialize stuff ; call CalendarColorScheme ; set the color scheme ; If we are running on a TV, switch to the system font (likely ; FID_BERKELEY) to increase readablity. ; and al, mask DT_DISP_ASPECT_RATIO cmp al, DAR_TV shl offset DT_DISP_ASPECT_RATIO jne done mov ax, MSG_MONTH_SET_FONT mov cx, dx call GenSendToChildren done: ret YearClassSpecBuild endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearViewToday %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Force today's events to come up. CALLED BY: GLOBAL (MSG_YEAR_VIEW_TODAY) PASS: DS:DI = YearClass specific instance data ES = DGroup RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/11/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearViewToday method YearClass, MSG_YEAR_VIEW_TODAY ; Set the selected region ; call TimerGetDateAndTime ; get the date information xchg bh, bl ; put month in high byte mov ds:[di].YI_startYear, ax mov {word} ds:[di].YI_startDay, bx mov ds:[di].YI_endYear, ax mov {word} ds:[di].YI_endDay, bx mov ds:[di].YI_curYear, ax ; first year is current mov ds:[di].YI_curMonth, bh ; first month is current ; Set the correct year & months ; or ds:[di].YI_flags, YI_MANUAL_CHANGE or YI_IMAGE_INVALID clr ch xchg ch, ds:[di].YI_curMonth ; set to zero to force redraw clr dx xchg dx, ds:[di].YI_curYear ; set to zero to force redraw mov ax, MSG_YEAR_SET_MONTH_AND_YEAR ; set the current display call ObjCallInstanceNoLock ; send the method mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access instance data ; Now call for loading the events ; and ds:[di].YI_flags, not (YI_MANUAL_CHANGE or YI_NEEDS_INIT) or ds:[di].YI_flags, YI_SEL_REGION ; set this flag mov ax, MSG_YEAR_COMPLETE_SELECTION GOTO ObjCallInstanceNoLock ; bring up the range of events YearViewToday endp InitCode ends GeometryCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearRecalcSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the proper size of the year object CALLED BY: UI - (MSG_VIS_RECALC_SIZE) PASS: CX = Width hint DX = Height hint DS:*SI = Instance data ES = DGroup RETURN: CX = Desired width DX = Desired height DESTROYED: DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/7/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearRecalcSize method YearClass, MSG_VIS_RECALC_SIZE ; First obtain and store the view's dimmensions ; mov ax, MSG_VIS_CONTENT_GET_WIN_SIZE ; get size of view call VisCallParent ; mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access instance data mov ds:[di].YI_viewWidth, cx ; Width in CX mov ds:[di].YI_viewHeight, dx ; Height in DX ; Work on the One Month Size ; mov ax, cx ; width => AX call YearCheckWidthMinMax mov ds:[di].YI_maxMonthWidth, bx ; store the width mov ax, dx ; height => AX call YearCheckHeightMinMax mov ds:[di].YI_maxMonthHeight, bx ; store the height ; Work on the Small (twelve) Month Size ; mov ax, cx ; width => AX shr ax, 1 shr ax, 1 call YearCheckWidthMinMax mov ds:[di].YI_minMonthWidth, bx mov ax, dx ; height => DX clr dx mov bx, 3 div bx call YearCheckHeightMinMax mov ds:[di].YI_minMonthHeight, bx ; Now re-size the months ; test ds:[di].YI_flags, YI_ONE_MONTH_SIZE jne oneMonth mov ax, ds:[di].YI_minMonthWidth mov bx, ds:[di].YI_minMonthHeight jmp doResize oneMonth: mov ax, ds:[di].YI_maxMonthWidth mov bx, ds:[di].YI_maxMonthHeight ; Store the approriate month size, and return total width/height doResize: mov ds:[di].YI_monthWidth, ax ; store the month width mov ds:[di].YI_monthHeight, bx ; store the month height shl ax, 1 ; 2 * width => AX shl ax, 1 ; 4 * width => AX mov cx, ax ; 4 * width => CX mov dx, bx ; total height => DX test ds:[di].YI_flags, YI_ONE_MONTH_SIZE jz yearLayout ; jump if not one month layout ; Year width = 12 * month width; year height = 1 * month height ; shl ax, 1 ; 8 * width => AX add cx, ax ; total width => CX ret ; Year width = 4 * month width; year height = 3 * month height ; yearLayout: shl bx, 1 ; 2 * height => BX add dx, bx ; total height => DX ret YearRecalcSize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearCheckWidthMinMax, YearCheckHeightMinMax %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check the for width or height in the proper range CALLED BY: GLOBAL PASS: AX = New width/height RETURN: BX = Width/Height in range DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 6/14/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ NPZ PZ MIN_DATE_WIDTH = 20 MIN_MONTH_WIDTH = (2 * MONTH_BORDER_HORIZ) + (7 * MIN_DATE_WIDTH) + 1 MIN_DATE_HEIGHT = (MIN_CHAR_POINT_SIZE + 5) MIN_MONTH_HEIGHT = (2 * MONTH_BORDER_TOP) + (8 * MIN_DATE_HEIGHT) + 3 ; the graphics system can only support a size of 4000h, so max month ; dimension = 4000h / 12 = 1365.33 ; MAX_MONTH_WIDTH = 1350 MAX_MONTH_HEIGHT = 1350 YearCheckWidthMinMax proc near mov bx, MIN_MONTH_WIDTH cmp bx, ax jg done mov bx, MAX_MONTH_WIDTH cmp bx, ax jl done mov bx, ax done: ret YearCheckWidthMinMax endp YearCheckHeightMinMax proc near mov bx, MIN_MONTH_HEIGHT cmp bx, ax jg done mov bx, MAX_MONTH_HEIGHT cmp bx, ax jl done mov bx, ax done: ret YearCheckHeightMinMax endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearPosition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Called to position the year's children, and possibly scrolls the document to present the correct month. CALLED BY: UI (MSG_VIS_POSITION_BRANCH) PASS: DS:*SI = Year instance data ES = DGroup RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: Assumes that MSG_GEN_VIEW_SET_DOC_BOUNDS is sent between the RecalcSize and the Position of the content object, so that the size of the view is correct when it receives any positioning. REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 1/21/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearPosition method YearClass, MSG_VIS_POSITION_BRANCH ; Now the real work ; call StartMonthsBoundsCalc ; move the months call PositionYearDocument ; re-position the document ret YearPosition endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% StartMonthsBoundsCalc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Begin the month bounds calculation CALLED BY: YearRecalcSize PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: Set up the callback routine to process children KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/8/89 Initial version Don 5/12/90 Added formal month size invalidation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ StartMonthsBoundsCalc proc near class YearClass ; friend to this class ; Set up the increment values for the scrollbar ; push si sub sp, size PointDWord mov bp, sp mov cx, ds:[di].YI_monthWidth ; horiz increment amount mov dx, ds:[di].YI_monthHeight ; vertical increment amount shr dx ; divide by two mov ss:[bp].PD_x.low, cx mov ss:[bp].PD_y.low, dx clr dx mov ss:[bp].PD_x.high, dx mov ss:[bp].PD_y.high, dx mov si, offset Interface:YearView ; DS:*SI points at the view mov ax, MSG_GEN_VIEW_SET_INCREMENT call ObjCallInstanceNoLock add sp, size PointDWord pop si ; Get the bounds information ; call VisGetBounds ; get my boundaries mov dx, bx ; top bounds into DX mov cx, ax ; left bounds into CX clr al ; clear the count byte mov bp, Month12 ; last object ; Start the callback routine ; clr bx push bx ; start with the first object push bx ; in the composite mov bx, offset VI_link push bx ; push offset to the LinkPart push cs ; segment of callback routine mov bx, offset GeometryCode:YearSetMonthsBounds push bx ; offset of callback routine mov bx, offset Vis_offset ; offset to master part offset mov di, offset VCI_comp ; offset to CompPart call ObjCompProcessChildren ; process my children ; Ensure all the font sizes are correct ; CallMod SetAllMonths ; set all the months ret StartMonthsBoundsCalc endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearSetMonthsBounds %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback routine to determine the month objects' boundaries CALLED BY: StartMonthsBoundsCalc() PASS: DS:*SI = Month instance data ES:*DI = Year instance data AL = Position counter (varies between 0 & 3 or 0 & 11) CX = Left boundary for this month DX = Top boundary for this month BP = Last object to process RETURN: Carry Set if done!! DESTROYED: BX, SI, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/8/89 Initial version Don 5/12/90 Removed nasty month-invalid hack %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearSetMonthsBounds proc far ; Perform some set-up work ; push si ; save month handle push ax, cx ; save the counter value, pos mov ax, MSG_MONTH_SET_STATE ; invalidate the month clr cl ; clear no flags mov ch, MI_NEW_SIZE ; set this flag call ObjCallInstanceNoLock ; send the method segmov es, ds, ax ; restore the seg register pop ax, cx ; restore counter value, pos mov di, es:[di] ; dereference year handle mov bx, di ; move deref'd handle (year) add di, es:[di].Year_offset ; access my instance data mov si, ds:[si] ; dereference month handle add si, ds:[si].Vis_offset ; access the visual bounds ; Set the month's boundaries ; push cx, dx ; save the upper-left corner mov ds:[si].VI_bounds.R_left, cx ; save left bounds mov ds:[si].VI_bounds.R_top, dx ; save top bounds add cx, es:[di].YI_monthWidth ; calculate month width add dx, es:[di].YI_monthHeight ; calculate month height dec cx dec dx mov ds:[si].VI_bounds.R_right, cx ; save right bounds mov ds:[si].VI_bounds.R_bottom, dx ; save bottom bounds pop cx, dx ; restore the upper-left corner ; Prepare for the next call ; inc al ; increment counter add cx, es:[di].YI_monthWidth ; get next month mov ah, 12 ; assume month view test ds:[di].YI_flags, YI_ONE_MONTH_SIZE jnz checkRightEdge mov ah, 4 checkRightEdge: cmp al, ah ; month too far over ?? jl done clr al ; reset counter add dx, es:[di].YI_monthHeight ; go down add bx, es:[bx].Vis_offset ; access instance data mov cx, es:[bx].VI_bounds.R_left ; start at left boundary again done: pop si ; restore the month handle cmp si, bp ; compare stop with current cmc ; invert the carry ret YearSetMonthsBounds endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearSetMonthSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the size of the months CALLED BY: GLOBAL (MSG_YEAR_SET_MONTH_SIZE) PASS: *DS:SI = YearClass object DS:DI = YearClassInstance CX = YearInfoFlags YI_ONE_MONTH_SIZE YI_SMALL_MONTH_SIZE RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 5/11/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearSetMonthSize method dynamic YearClass, MSG_YEAR_SET_MONTH_SIZE .enter ; Some set-up work ; test ds:[di].YI_flags, cx jnz exit ; if already set, do nothing and ds:[di].YI_flags, not (YI_SMALL_MONTH_SIZE or YI_ONE_MONTH_SIZE) or ds:[di].YI_flags, cx ; set the new size flag ; Assume ""one-month"" size values, else use ""small-month"" values ; mov ax, ds:[di].YI_maxMonthWidth mov bx, ds:[di].YI_maxMonthHeight mov dx, MPOT_GR_MONTH ; default print action mov bp, (LG_TITLE_FONT_SIZE shl 8) or LG_DATE_FONT_SIZE cmp cx, YI_ONE_MONTH_SIZE je common mov ax, ds:[di].YI_minMonthWidth mov bx, ds:[di].YI_minMonthHeight inc dx ; MPOT_GR_YEAR => DX mov bp, (SM_TITLE_FONT_SIZE shl 8) or SM_DATE_FONT_SIZE ; Store the new month dimensions common: mov ds:[di].YI_monthWidth, ax ; store the month width mov ds:[di].YI_monthHeight, bx ; store the month height mov {word} ds:[di].YI_smallFontSize, bp ; store the font sizes ; Change three things depending on what mode we're in: ; 1) Make the scrollbars on the YearView appear or not ; 2) Display the MonthValueObject or not ; 3) Display the YearValue moniker or not ; push si mov ax, MSG_GEN_SET_USABLE mov dx, mask GVDA_DONT_DISPLAY_SCROLLBAR mov bp, offset YearValueMonikerFake cmp cx, YI_ONE_MONTH_SIZE je setScrollbarState mov ax, MSG_GEN_SET_NOT_USABLE xchg dl, dh mov bp, offset YearValueMonikerReal setScrollbarState: push ax ; save message push bp ; save moniker ; Accomplish #1 mov ax, MSG_GEN_VIEW_SET_DIMENSION_ATTRS mov cx, dx mov bp, VUM_DELAYED_VIA_UI_QUEUE GetResourceHandleNS Interface, bx mov si, offset Interface:YearView mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage_geometry_call ; Accomplish #2 mov ax, MSG_GEN_USE_VIS_MONIKER pop cx mov dl, VUM_DELAYED_VIA_UI_QUEUE mov si, offset Interface:YearValue call ObjMessage_geometry_call ; Accomplish #3 pop ax mov si, offset Interface:MonthValueObject mov dl, VUM_DELAYED_VIA_UI_QUEUE call ObjMessage_geometry_call pop si ; Ensure the document size is set correctly ; mov cl, mask VOF_GEOMETRY_INVALID ; mark our geometry invalid mov dl, VUM_NOW ; do it now, please call VisMarkInvalid call PositionYearDocument ; and move the document origin mov di, ds:[si] add di, ds:[di].Year_offset call MonthNameDisplay ; ensure month name is correct exit: .leave ret YearSetMonthSize endm GeometryCode ends CommonCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearGainedTargetExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Note that we've gained the target CALLED BY: GLOBAL (MSG_META_GAINED_TARGET_EXCL) PASS: ES = DGroup *DS:SI = YearClass object DS:DI = YearClassInstance RETURN: Nothing DESTROYED: AX, CX, DX, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/10/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearGainedTargetExcl method dynamic YearClass, MSG_META_GAINED_TARGET_EXCL ; First call our superclass ; mov di, offset YearClass call ObjCallSuperNoLock ; Record the fact that we are now selected, and cause ; the months' titles to be re-drawn to reflect this fact. ; mov cx, MI_HAS_FOCUS shl 8 ; set this flag call InvalidateMonthTitles if not _TODO ; Tell the DayPlan to remove the selected object ; mov ax, MSG_DP_SET_SELECT GetResourceHandleNS DayPlanObject, bx mov si, offset DayPlanObject clr bp call ObjMessage_common_send ; Now set the ViewType ; mov cx, VT_CALENDAR GOTO UpdateViewType else ret endif YearGainedTargetExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearLostTargetExcl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Note that we've lost the target CALLED BY: GLOBAL (MSG_META_LOST_TARGET_EXCL) PASS: ES = DGroup *DS:SI = YearClass object DS:DI = YearClassInstance RETURN: Nothing DESTROYED: AX, CX, DX, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/10/93 Initial version Don 6/13/95 Changed to TARGET, to avoid screen flashing when bringing down menus %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearLostTargetExcl method dynamic YearClass, MSG_META_LOST_TARGET_EXCL ; Re-draw the titles in the month objects ; mov cx, MI_HAS_FOCUS ; clear this flag call InvalidateMonthTitles ; Now call our superclass ; mov di, offset YearClass GOTO ObjCallSuperNoLock YearLostTargetExcl endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InvalidateMonthTitles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Invalidate the title of every month object that is a child of the Year object CALLED BY: YearGainedFocusExcl, YearLostFocusExcl PASS: *DS:SI = Year object CL = MonthInfoFlags to clear (MI_HAS_FOCUS) CH = MonthInfoFlags to set (MI_HAS_FOCUS) RETURN: Nothing DESTROYED: AX, CX, DX, BP, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/21/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InvalidateMonthTitles proc near .enter ; Tell the month objects about their new state ; mov ax, MSG_MONTH_SET_STATE call VisSendToChildren ; If the window exists, tell each month object to ; invalidate its title. Else, do nothing ; call GetYearViewOrigin call VisQueryWindow ; origin => (CX, DX) tst di jz done mov ax, MSG_MONTH_INVALIDATE_TITLE mov bp, di ; Window handle => BP call VisSendToChildren done: .leave ret InvalidateMonthTitles endp CommonCode ends YearCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearTrackScrolling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Normalize the scrolling of the year object. Only normalize when in OneMonth mode. CALLED BY: UI (MSG_META_CONTENT_TRACK_SCROLLING) PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data ES = DGroup SS:BP = TrackScrollingParams CX = Scrollbar handle RETURN: Nothing DESTROYED: AX, BX, DX, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/21/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearTrackScrolling method YearClass, MSG_META_CONTENT_TRACK_SCROLLING .enter ; If we haven't been initialized or are in the 12-month mode, do ; not change the scroll. If we are in the middle of a document ; size change, then determine the new origin rather than ; ""normalizing"" the scroll ; call GenSetupTrackingArgs ; set up some extra values mov di, ds:[si] add di, ds:[di].Year_offset ; YearInstance => DS:DI test ds:[di].YI_flags, YI_SMALL_MONTH_SIZE or YI_NEEDS_INIT jnz done ; if no work, we're done test ss:[bp].TSP_flags, mask SF_DOC_SIZE_CHANGE jnz calcOrigin ; calculate the new origin ; Normalize the scroll ; mov ax, ss:[bp].TSP_newOrigin.PD_x.low ; get the next X origin clr dx ; dividend => DX:AX mov bx, ds:[di].YI_monthWidth ; divisor => BX tst bx ; normalize before visible ?? jz done ; if so, don't change anything div bx ; perform the division inc al shr bx, 1 ; divide divisor by 2 cmp dx, bx ; check the remainder jl rounded ; round down! sub dx, ds:[di].YI_monthWidth ; else negative difference=>DX inc al ; go to the next month rounded: EC < cmp al, 1 ; must at least by Jan > EC < ERROR_L YEAR_ILLEGAL_CURRENT_MONTH > EC < cmp al, 12 ; must be less than Dec > EC < ERROR_G YEAR_ILLEGAL_CURRENT_MONTH > ; We now know what month to display, and the difference (if any) ; between the offset the user requested, and the one we're going to ; give him/her. Store our changes, and we're done ; mov ds:[di].YI_curMonth, al ; store the new current month! mov_tr ax, dx cwd subdw ss:[bp].TSP_change.PD_x, dxax subdw ss:[bp].TSP_newOrigin.PD_x, dxax done: call GenReturnTrackingArgs ; return arguments .leave ret ; Calculate the new origin calcOrigin: mov ax, ds:[di].YI_monthWidth mov dl, ds:[di].YI_curMonth clr dl dec dx ; make it zero-based mul dx ; origin.x => AX mov ss:[bp].TSP_newOrigin.PD_x.low, ax clr ss:[bp].TSP_newOrigin.PD_y.low or ss:[bp].TSP_flags, mask SF_ABSOLUTE jmp done YearTrackScrolling endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearDraw %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the year object, then draw the month children CALLED BY: GLOBAL PASS: CL = DrawFlags BP = GState to use DS:*SI = Instance data ES = DGroup RETURN: Nothing DESTROYED: TBD PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/6/89 Initial version Chris 7/ 3/91 Fixed to not assume MSG_VIS_DRAW preserves bp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearDraw method YearClass, MSG_VIS_DRAW .enter ; Set up the Gstate first ; test ds:[di].YI_flags, YI_NEEDS_INIT ; need to be initialized ?? jnz quit ; if so, do nothing. mov di, bp ; GState to DI call GrSaveState ; save the GState' state push cx, cx ; save the DrawFlag, twice ; Set the appropriate colors. Text and the line colors are always ; black, and the background color is read from a variable. ; movdw bxax, es:[monthBGColor] call GrSetAreaColor ; set the background color mov ax, CF_INDEX shl 8 or TEXT_COLOR call GrSetLineColor call GrSetTextColor ; set the foreground colors ; Simply call my superclass to draw the months ; mov di, bp ; move GState to DI call VisGetBounds ; get my bounds call GrFillRect ; clear the window first pop cx ; DrawFlag => CL push bp ; preserve bp mov ax, MSG_VIS_DRAW ; method to pass mov di, offset YearClass call ObjCallSuperNoLock ; call my SuperClass pop bp ; restore bp if PZ_PCGEOS ; Pizza ; DESTROYED: cx, di, ax ; Check holiday setting mode ; push bx, dx, bp, si mov ax, MSG_JC_SHIC_GET_USABLE GetResourceHandleNS SetHoliday, bx mov si, offset SetHoliday mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop bx, dx, bp, si jnc nextJob ; if not usable pop cx ; DrawFlag => CL jmp done nextJob: endif ; Do we need to hi-light an area ?? ; pop cx ; DrawFlag => CL test cl, mask DF_PRINT ; if we're printing... jnz done ; then skip all this crap mov di, ds:[si] ; dereference this handle add di, ds:[di].Year_offset ; access instance data test ds:[di].YI_flags, YI_SEL_REGION ; selected region ?? jz done ; no, so do nothing clr ax ; assume in bounds test ds:[di].YI_flags, YI_OUT_OF_BOUNDS jz drawSelection ; yes - in bounds mov ax, 1 ; else use the old bounds drawSelection: call YearDrawSelection ; draw using current dates ; Clean up ; done: mov di, bp ; GState handle => DI call GrRestoreState ; restore the GState' state quit: .leave ret YearDraw endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearDrawSelection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw any selection that appears in this year CALLED BY: GLOBAL PASS: DS:*SI = YearClass instance data BP = GState or nothing AX = 0 for the current range AX = 1 for the old range RETURN: Nothing DESTROYED: AX, BX, CX, DX PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/1/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearDrawSelection proc near class YearClass ; friend to this class ; Some set-up work ; mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access instance data tst ax ; old or new jne old ; Get the current range ; mov ax, ds:[di].YI_startYear mov bx, ds:[di].YI_endYear mov cx, {word} ds:[di].YI_startDay mov dx, {word} ds:[di].YI_endDay jmp common ; Get the old range old: mov ax, ds:[di].YI_oldStartYear mov bx, ds:[di].YI_oldEndYear mov cx, {word} ds:[di].YI_oldStartDay mov dx, {word} ds:[di].YI_oldEndDay ; Get the start boundary common: cmp ax, ds:[di].YI_curYear ; start year with current jg done ; if greater, done! je last ; if equal, check last date mov cx, (1 shl 8) or 1 ; January 1st last: cmp bx, ds:[di].YI_curYear ; last year with current jl done ; if less than current, done je draw ; if equal, draw now mov dx, (12 shl 8) or 31 ; else use the last date draw: call DrawSelection ; draw selection in CX:DX done: ret YearDrawSelection endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearChangeMonthMap %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: A change removing or adding days with events has occurred. Call for the update of the appropriate months. CALLED BY: DBNotifyMonthChange (MSG_YEAR_CHANGE_MONTH_MAP) PASS: DS:DI = YearClass specific instance data BP = Year (or 0 for every month) DH = Month RETURN: Nothing DESTROYED: AX, BX, CX, DX, BP, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 6/1/90 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearChangeMonthMap method YearClass, MSG_YEAR_CHANGE_MONTH_MAP .enter ; Do we need to do anything ; clr dl ; assume all months tst bp ; any month ?? jz startWork ; yes, setup for loop cmp bp, ds:[di].YI_curYear ; change to current year ?? jne done ; no, so do nothing mov dl, dh ; changed month => DL ; Perform some set-up work ; startWork: mov bp, ds:[di].YI_curYear ; current year => BP call GeodeGetProcessHandle ; process handle => BX mov cx, offset Month1 ; first month handle => CX mov dh, 1 ; start with the first month ; Loop here until done methodLoop: tst dl ; work with any month je doCall ; yes cmp dl, dh ; else comapre the months jne next doCall: mov ax, MSG_DB_GET_MONTH_MAP clr di call ObjMessage next: inc dh ; go to the next month add cx, 2 ; go to the next chunk cmp dh, 12 ; compare with last month jle methodLoop ; continue until done done: .leave ret YearChangeMonthMap endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearChangeYear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change the year that is displayed CALLED BY: UI (MSG_YEAR_CHANGE_YEAR) PASS: DS:DI = YearClass specific instance data DS:*SI = YearClass instance data DX = Year RETURN: Nothing DESTROYED: DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/27/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearChangeYear method dynamic YearClass, MSG_YEAR_CHANGE_YEAR mov ds:[di].YI_changeYear, dx ; set the change year mov bx, ds:[LMBH_handle] ; BX:SI points to me mov di, mask MF_FORCE_QUEUE or mask MF_CHECK_DUPLICATE mov ax, MSG_YEAR_CHANGE_NOW GOTO ObjMessage YearChangeYear endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearChangeNow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change the year and month displayed now (if necessary) CALLED BY: Internal (MSG_YEAR_CHANGE_NOW) PASS: DS:DI = YearClass specific instance data DS:*SI = YearClass instance data RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/27/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearChangeNow method dynamic YearClass, MSG_YEAR_CHANGE_NOW .enter mov ch, ds:[di].YI_changeMonth mov dx, ds:[di].YI_changeYear tst ch jnz alter tst dx jz done ; Something has changed - reset the months alter: clr ax mov ds:[di].YI_changeMonth, al ; clear the change value mov ds:[di].YI_changeYear, ax ; clear the change value call YearSetMonthAndYear done: .leave ret YearChangeNow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearSetMonthAndYear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the given month & year as the displayed month CALLED BY: [Decrement,Increment][Month,Year], MSG_YEAR_SET_MONTH_AND_YEAR PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data CH = Month (or 0 to do nothing) DX = Year (or 0 to do nothing) RETURN: Nothing DESTROYED: BX, DI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: Set the new month and year Update display as needed REVISION HISTORY: Name Date Description ---- ---- ----------- Don 8/28/89 Initial version Don 12/27/89 Modified to allow RangeGadget kho 8/26/96 Handle CLAIM_UNUSED_MONTH_SPACE. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearSetMonthAndYear method YearClass, MSG_YEAR_SET_MONTH_AND_YEAR uses ax, cx, dx, si .enter ; Check the month & the year ; tst ch ; do nothing with month ?? jz checkYear ; if zero, check the year cmp ch, ds:[di].YI_curMonth ; compare the months je checkYear ornf ds:[di].YI_flags, YI_MANUAL_CHANGE mov ds:[di].YI_curMonth, ch ; save the new month call MonthNameDisplay ; display the month text checkYear: tst dx je update cmp dx, ds:[di].YI_curYear ; compare the years je update mov ds:[di].YI_curYear, dx ; save the new year or ds:[di].YI_flags, YI_IMAGE_INVALID call YearNameDisplay ; display the year text call SetAllMonths ; set all the months mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access my instance data and ds:[di].YI_flags, not (YI_NEEDS_INIT) ; Reset the months (if necessary) ; update: test ds:[di].YI_flags, YI_MANUAL_CHANGE ; if not a manual change jz checkInvalid ; ...don't mess with doc pos call PositionYearDocument ; position it correctly pushf ; save the flags mov di, ds:[si] ; dereference my handle add di, ds:[di].Year_offset ; acess my instance data popf jnc checkInvalid ; jump if not re-positioned or ds:[di].YI_flags, YI_IMAGE_INVALID ; Check the invalid stuff ; checkInvalid: test ds:[di].YI_flags, YI_IMAGE_INVALID jz done if CLAIM_UNUSED_MONTH_SPACE ; Resize the YearView according to the current month. ; call ResetYearViewSize endif and ds:[di].YI_flags, not (YI_IMAGE_INVALID or YI_MANUAL_CHANGE) mov cl, mask VOF_IMAGE_INVALID mov dl, VUM_NOW mov ax, MSG_VIS_MARK_INVALID ; invalidate method call ObjCallInstanceNoLock ; send it to myself done: .leave ret YearSetMonthAndYear endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearGetMonthAndYear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the month & year that are currently displayed CALLED BY: MSG_YEAR_GET_MONTH_AND_YEAR PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data RETURN: CH = Month DX = Year DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 4/29/00 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearGetMonthAndYear method dynamic YearClass, MSG_YEAR_GET_MONTH_AND_YEAR .enter ; Just retrieve the requested information ; mov ch, ds:[di].YI_curMonth mov dx, ds:[di].YI_curYear .leave ret YearGetMonthAndYear endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetYearViewWidth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the width of YearView object according to the current month. CALLED BY: (INTERNAL) YearSetMonthAndYear PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- kho 8/26/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if CLAIM_UNUSED_MONTH_SPACE ResetYearViewSize proc near class YearClass uses ax, bx, cx, dx, si, di, bp .enter Assert objectPtr, dssi, YearClass ; ; Find the active month object. ; mov si, Month1 ; first handle => SI mov al, ds:[di].YI_curMonth clr ah dec al ; change to zero-based shl ax ; double to make a ; handle add si, ax ; starting handle => SI ; ; Get the MonthInfoFlags of the month object. ; mov ax, MSG_MONTH_GET_STATE call ObjCallInstanceNoLock ; cl <- MonthInfoFlags ; ; Set the size of YeaarView object, depending on the info flag. ; mov ax, SpecWidth test cl, MI_SPAN_6_WEEKS jz smallView mov ax, SpecWidth smallView: ; ; Set up SetSizeArgs. ; sub sp, size SetSizeArgs mov bp, sp ; ss:bp = SetSizeArgs mov ss:[bp].SSA_width, ax mov ss:[bp].SSA_height, SpecHeight <> clr ss:[bp].SSA_count mov ss:[bp].SSA_updateMode, VUM_NOW ; ; Call YearView. ; GetResourceHandleNS YearView, bx mov si, offset YearView mov ax, MSG_GEN_SET_FIXED_SIZE mov dx, size SetSizeArgs mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage ; ax, cx, dx, bp gone add sp, size SetSizeArgs ; ; Reset the size of CalendarRight. ; mov ax, MSG_VIS_MARK_INVALID GetResourceHandleNS CalendarSizeControl, bx mov si, offset CalendarSizeControl mov cl, mask VOF_GEOMETRY_INVALID mov dl, VUM_MANUAL mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage .leave ret ResetYearViewSize endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetAllMonths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the month objects to their appropriate month & year CALLED BY: YearSetMonthAndYear PASS: DS:*SI Year instance data RETURN: Nothing DESTROYED: AX, CX, DX, BP, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/11/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetAllMonths proc far class YearClass ; friend to this class uses si .enter ; Access the instance data to determine current month and year ; mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access instance data mov bp, ds:[di].YI_curYear ; get current year mov cx, {word} ds:[di].YI_smallFontSize ; large => CH, small => CL mov dh, 1 ; January as the start month mov bl, 12 ; count up to twelve mov si, offset Month1 ; handle of the first month ; Now loop through the months resetLoop: mov ax, MSG_MONTH_SET_MONTH ; method to send call ObjCallInstanceNoLock ; send the method add si, 2 ; next month object inc dh ; increment month dec bl jg resetLoop .leave ret SetAllMonths endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PositionYearDocument %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Position the year ""document"" such that the first selected month is visible. CALLED BY: GLOBAL PASS: DS:*SI = Year instance data RETURN: Carry = Set if the document was moved = Clear if not DESTROYED: AX, BX, CX, DX, DI, BP PSEUDO CODE/STRATEGY: The monthWidth & monthHeight must be correct!!! KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 12/12/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PositionYearDocument proc far class YearClass uses si .enter ; Get the current document position ; mov di, si ; Year object => DI call GetYearViewOrigin ; Is our frame in the window's boundary? If not, must re-position ; mov di, ds:[di] ; dereference the Year handle add di, ds:[di].Year_offset ; access the instance data test ds:[di].YI_flags, YI_NEEDS_INIT ; need to be initialized ?? jnz done ; if so, do nothing. mov bl, ds:[di].YI_curMonth ; get the current month dec bl ; change to zero-based clr bh shl bx, 1 ; from 0, count by two add bx, Month1 ; DS:*BX => MonthObject mov bx, ds:[bx] ; dereference the month handle tst ds:[bx].Vis_offset ; are we visually built yet ?? jz done ; if not vis-built, done add bx, ds:[bx].Vis_offset ; access the visual data cmp cx, ds:[bx].VI_bounds.R_left jg reset cmp dx, ds:[bx].VI_bounds.R_top jg reset add cx, ds:[di].YI_viewWidth add dx, ds:[di].YI_viewHeight cmp cx, ds:[bx].VI_bounds.R_right jl reset cmp dx, ds:[bx].VI_bounds.R_bottom jge done ; Now set the document position ; reset: mov cx, ds:[bx].VI_bounds.R_left ; new X offset mov dx, ds:[bx].VI_bounds.R_top ; new Y offset sub sp, size PointDWord mov bp, sp mov ss:[bp].PD_x.low, cx mov ss:[bp].PD_y.low, dx clr dx mov ss:[bp].PD_x.high, dx mov ss:[bp].PD_y.high, dx mov si, offset Interface:YearView mov ax, MSG_GEN_VIEW_SET_ORIGIN call ObjCallInstanceNoLock add sp, size PointDWord stc ; clear the carry bit done: .leave ret PositionYearDocument endp GetYearViewOrigin proc far uses bx, si .enter sub sp, size PointDWord mov dx, sp mov cx, ss ; pass buffer in cx:dx mov si, offset Interface:YearView mov ax, MSG_GEN_VIEW_GET_ORIGIN call ObjCallInstanceNoLock mov bp, dx mov cx, ss:[bp].PD_x.low ; get origin in cx, dx mov dx, ss:[bp].PD_y.low add sp, size PointDWord .leave ret GetYearViewOrigin endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearNameDisplay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Write out a string CALLED BY: YearInit, YearSetMonthAndYear PASS: DS:*SI = Month instance data DS:DI = Dereference instance data RETURN: Nothing DESTROYED: AX, CX, DX, BP PSEUDO CODE/STRATEGY: Display the new year string KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/21/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearNameDisplay proc far class YearClass ; friend to this class .enter ; Change the displayed year ; push si ; save the year handle mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE mov cx, ds:[di].YI_curYear ; get the current jump year clr bp ; a ""determinate"" value mov si, offset Interface:YearValue call ObjCallInstanceNoLock pop si ; restore the year handle mov di, ds:[si] ; dereference it add di, ds:[di].Year_offset ; access the year data .leave ret YearNameDisplay endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MonthNameDisplay %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the month name to be displayed CALLED BY: YearInit, YearSetMonthAndYear PASS: DS:*SI = Month instance data DS:DI = Dereference instance data RETURN: Nothing DESTROYED: Nothing PSEUDO CODE/STRATEGY: Display the new month string KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 7/21/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ MonthNameDisplay proc far class YearClass ; friend to this class uses ax, cx, dx, bp .enter ; Change the displayed year ; push si ; save the year handle mov ax, MSG_GEN_VALUE_SET_INTEGER_VALUE mov cl, ds:[di].YI_curMonth ; get the current month clr ch clr bp ; a ""determinate"" value mov si, offset Interface:MonthValueObject call ObjCallInstanceNoLock pop si ; restore the year handle mov di, ds:[si] ; dereference it add di, ds:[di].Year_offset ; access the year data .leave ret MonthNameDisplay endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearCompleteSelection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Send the selected range (dates) to the DayPlanObject CALLED BY: UI (MSG_YEAR_COMPLETE_SELECTION) PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific instance data RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: Check to see if a region is selected If not, put up GenSummons, quit If so, tell the DayPlan the range to open KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 9/22/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearCompleteSelection method dynamic YearClass, MSG_YEAR_COMPLETE_SELECTION ; Access instance data ; test ds:[di].YI_flags, YI_SEL_REGION ; is a region selected ?? jnz checkDates ; yes, so jump ; Nothing selected - re-draw the old selection ; noRegion: call OldRangeToCurrent ; move the old range to new clr bp ; no GState clr ax ; use the current range call YearDrawSelection ; re-draw the selection ret ; Load the days into registers ; checkDates: mov ax, {word} ds:[di].YI_startDay mov bx, ds:[di].YI_startYear ; AX = M/D, BX = Year (start) mov dx, {word} ds:[di].YI_endDay mov bp, ds:[di].YI_endYear ; DX = M/D, BP = Year (end) ; Now fixup the dates - if necessary (check the start date) ; tst al ; first bad case jne intFirst ; jump if OK mov al, 1 ; should be 1st of the month jmp checkSecond intFirst: cmp al, 63 ; second bad case jne checkSecond ; jump if OK mov al, 1 ; reset to 1st day... inc ah ; ...of the next month cmp ah, 12 ; check for overflow jle checkSecond mov ah, 1 ; else month = January inc bx ; and increment the year ; Check the second date ; checkSecond: tst dl ; first bad case jne intSecond dec dh ; back up one month jg fixSecond mov dh, 12 dec bp jmp fixSecond intSecond: cmp dl, 63 ; second bad case jne new ; jump if OK fixSecond: call CalcDaysInMonth ; get days in the month mov dl, ch ; last day to DL ; Finally, check for the end of month 1 to begin of month 2 case ; new: mov cx, dx ; last M/D to CX mov dx, bp ; last Year to DX cmp bx, dx ; compare the years jg noRegion ; if greater, no region jl go ; if less, OK cmp ax, cx ; compare the month & day jg noRegion ; if greater, no region ; Selected - set up struct to pass to DuplicateDayPlan ; go: mov {word} ds:[di].YI_startDay, ax mov {word} ds:[di].YI_endDay, cx mov ds:[di].YI_startYear, bx mov ds:[di].YI_endYear, dx if PZ_PCGEOS ; Pizza ; DESTROYED: ax, bx, si, di ; Check holiday setting mode ; push cx, dx, bp mov ax, MSG_JC_SHIC_GET_USABLE GetResourceHandleNS SetHoliday, bx mov si, offset SetHoliday mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage jnb notHolidaySetting ; if not usable ; Set holiday range ; mov ax, MSG_JC_SHIC_SET_RANGE GetResourceHandleNS SetHoliday, bx mov si, offset SetHoliday mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop cx, dx, bp ret ; <-EXIT notHolidaySetting: pop cx, dx, bp endif ; Now make the call ; mov ax, MSG_DP_SET_RANGE GetResourceHandleNS DayPlanObject, bx mov si, offset DayPlanObject mov di, mask MF_CHECK_DUPLICATE or \\ mask MF_REPLACE or \\ mask MF_FORCE_QUEUE GOTO ObjMessage ; set the range to view YearCompleteSelection endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearSetSelection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Used to set the dates to show as selected within the Year CALLED BY: DayPlanSetRange (MSG_YEAR_SET_SELECTION) PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific intstance data SS:BP = RangeStruct RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 11/17/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearSetSelection method dynamic YearClass, MSG_YEAR_SET_SELECTION .enter ; First unselect any selected area ; test ds:[di].YI_flags, YI_SEL_REGION ; a selected region ?? jz newZoom ; no, so jump push bp ; save the RangeStruct clr ax, bp ; current range no GState call YearDrawSelection ; clear the selection pop bp ; restore the RangeStruct ; Load the year with the new selection range newZoom: mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; go to instance data and ds:[di].YI_flags, (not YI_SEL_REGION) call CurrentRangeToOld ; update old range data mov dx, ss:[bp].RS_endYear mov ds:[di].YI_endYear, dx ; ...and the end year mov dx, {word} ss:[bp].RS_endDay mov {word} ds:[di].YI_endDay, dx ; ...and the end M/D mov dx, ss:[bp].RS_startYear mov ds:[di].YI_startYear, dx ; save the start year mov cx, {word} ss:[bp].RS_startDay mov {word} ds:[di].YI_startDay, cx ; ...and the start M/D ; Show a new year (??) and draw the selection ; push bp or ds:[di].YI_flags, YI_MANUAL_CHANGE call YearSetMonthAndYear ; set the years mov di, ds:[si] ; dereference the handle add di, ds:[di].Year_offset ; access instance data or ds:[di].YI_flags, YI_SEL_REGION and ds:[di].YI_flags, not YI_MANUAL_CHANGE clr bp clr ax ; use the new current range call YearDrawSelection ; and draw it... pop bp .leave ret YearSetSelection endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearGetSelection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Gets the selected days in the Year (Calendar View) CALLED BY: GLOBAL (MSG_YEAR_GET_SELECTION) PASS: *DS:SI = YearClass object DS:DI = YearClassInstance DX:BP = RangeStruct to fill CX = YearRangeType RETURN: DX:BP = RangeStruct (filled) CX = # of days in range DESTROYED: AX, DI, SI, ES PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 2/14/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearGetSelection method dynamic YearClass, MSG_YEAR_GET_SELECTION .enter ; See if we are getting the old or new range ; EC < cmp cx, YearRangeType > EC < ERROR_AE YEAR_ILLEGAL_YEAR_RANGE_TYPE > mov si, di add si, offset YI_oldStartDay cmp cx, YRT_PREVIOUS je copyRange sub si, (offset YI_oldStartDay) - (offset YI_startDay) ; Load the structure, and determine the # of days in the range copyRange: mov es, dx mov di, bp ; RangeStruct => ES:DI mov cx, size RangeStruct / 2 rep movsw ; copy those words call CalcDaysInRange ; days => CX .leave ret YearGetSelection endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% YearSwitchToMonth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Switch to a different month CALLED BY: MonthValueObject (MSG_YEAR_SWITCH_TO_MONTH) PASS: DS:*SI = YearClass instance data DS:DI = YearClass specific intstance data DX = New month (1-based) RETURN: Nothing DESTROYED: AX, CX, DX, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/7/99 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ YearSwitchToMonth method dynamic YearClass, MSG_YEAR_SWITCH_TO_MONTH .enter ; See if we really need to do any work. Unless no month is ; selected, we always forece a change, as the user could have ; been silly and scrolled the month around. D'oh! ; mov ch, dl ; month => CH clr ds:[di].YI_curMonth ; force change! ; Yes, we need to do some work. ; clr dx ; don't change the year mov ax, MSG_YEAR_SET_MONTH_AND_YEAR call ObjCallInstanceNoLock .leave ret YearSwitchToMonth endp YearCode ends ",16265,True,3742.375286444733,median "/* ButtonTest.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif // Please UNCOMMENT one of the contructor lines below // U8x8 Contructor List // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing //U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 6, /* dc=*/ 4, /* reset=*/ 12); // Arduboy (DevKit) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy 10 (Production, Kickstarter Edition) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_HW_SPI u8x8(/* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); // Digispark ATTiny85 //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display //U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SSD1306_128X64_ALT0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SH1106_128X64_WINSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8X8_SH1106_128X32_VISIONOX_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X32_VISIONOX_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_72X40_WISE_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_64X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_PIMORONI_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_SEEED_128X128_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_128X128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1108_160X160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_128X32_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_64X48_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8X8_SSD1306_48X64_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_1F_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_96X16_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" //U8X8_SSD1306_72X40_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" //U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1317_96X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1317_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1318_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1318_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1326_ER_256X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8X8_SSD1327_SEEED_96X96_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_SEEED_96X96_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_EA_W128128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_EA_W128128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ A4, /* dc=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather 32u4 Basic Proto //U8X8_SSD1305_128X32_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCD8544_84X48_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCF8812_96X65_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_PCF8812_96X65_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_HX1230_96X68_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_HX1230_96X68_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_EA_DOGM132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_ZOLEN_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ZOLEN_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LM6059_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_LM6059_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_KS0713_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_KS0713_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_LX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_ALT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_ERC12864_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_PI_132X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_PI_132X64_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_64X32_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7567_HEM6432_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7571_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX25664_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C //U8X8_ST75320_JLX320240_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75320_JLX320240_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7588_JLX12864_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8X8_ST7588_JLX12864_HW_I2C u8x8(/* reset=*/ 5); //U8X8_IST3020_ERC19264_6800 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8X8_IST3020_ERC19264_8080 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8X8_IST3020_ERC19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_IST7920_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_IST7920_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_UC1601_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1601_128X32_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_UC1601_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_ERC24064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_DEM240064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_ERC240120_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_240X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1610_EA_DOGXL160_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1610_EA_DOGXL160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1611_EA_DOGM240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_IDS4073_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_IDS4073_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_SW_I2C u8x8(/* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); // u8g2 test board: I2C clock/data is same as SPI, I2C default address is 0x78 //U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8X8_SSD1607_GS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8X8_SSD1607_WS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8X8_IL3820_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT //U8X8_IL3820_V2_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, optimized (lesser screen flicker) //U8X8_ST7511_AVD_320X240_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Connect RD pin with 3.3V/5V //U8X8_S1D15721_240X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_S1D15721_240X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // End of constructor list void setup(void) { // U8g2 SH1106 Proto-Shield u8x8.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 7, /* menu_up_pin= */ 6, /* menu_down_pin= */ 5, /* menu_home_pin= */ 3); u8x8.setPowerSave(0); u8x8.clear(); u8x8.setFont(u8x8_font_chroma48medium8_r); } void loop(void) { uint8_t e; u8x8.drawUTF8(0, 0, ""Event Test""); e = u8x8.getMenuEvent(); switch(e) { case U8X8_MSG_GPIO_MENU_SELECT: u8x8.drawUTF8(0, 1, ""Select""); break; case U8X8_MSG_GPIO_MENU_NEXT: u8x8.drawUTF8(0, 1, ""Next ""); break; case U8X8_MSG_GPIO_MENU_PREV: u8x8.drawUTF8(0, 1, ""Prev ""); break; case U8X8_MSG_GPIO_MENU_HOME: u8x8.drawUTF8(0, 1, ""Home ""); break; case U8X8_MSG_GPIO_MENU_UP: u8x8.drawUTF8(0, 1, ""Up ""); break; case U8X8_MSG_GPIO_MENU_DOWN: u8x8.drawUTF8(0, 1, ""Down ""); break; } } ",12130,True,3633.9541279366276,median "############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"""",%progbits .text .p2align 5, 0x90 CONST_TABLE: _poly: .quad 0x1, 0xC200000000000000 _twoone: .quad 0x1, 0x100000000 _u128_str: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 _mask1: .quad 0xffffffffffffffff, 0x0 _mask2: .quad 0x0, 0xffffffffffffffff _inc1: .quad 1,0 .p2align 5, 0x90 .globl g9_AesGcmPrecompute_avx .type g9_AesGcmPrecompute_avx, @function g9_AesGcmPrecompute_avx: push %ebp mov %esp, %ebp push %esi lea CONST_TABLE, %esi movl (8)(%ebp), %eax movdqu (%eax), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd ((_twoone-CONST_TABLE))(%esi), %xmm4 pand ((_poly-CONST_TABLE))(%esi), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 psllq $(1), %xmm3 pxor %xmm1, %xmm3 psllq $(5), %xmm3 pxor %xmm1, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 psllq $(1), %xmm3 pxor %xmm2, %xmm3 psllq $(5), %xmm3 pxor %xmm2, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movl (12)(%ebp), %eax movdqu %xmm0, (%eax) movdqu %xmm1, (16)(%eax) movdqu %xmm2, (32)(%eax) pop %esi pop %ebp ret .Lfe1: .size g9_AesGcmPrecompute_avx, .Lfe1-(g9_AesGcmPrecompute_avx) .p2align 5, 0x90 .globl g9_AesGcmMulGcm_avx .type g9_AesGcmMulGcm_avx, @function g9_AesGcmMulGcm_avx: push %ebp mov %esp, %ebp push %esi push %edi lea CONST_TABLE, %esi movl (8)(%ebp), %edi movl (12)(%ebp), %eax movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .Lfe2: .size g9_AesGcmMulGcm_avx, .Lfe2-(g9_AesGcmMulGcm_avx) .p2align 5, 0x90 .globl g9_AesGcmAuth_avx .type g9_AesGcmAuth_avx, @function g9_AesGcmAuth_avx: push %ebp mov %esp, %ebp push %esi push %edi lea CONST_TABLE, %esi movl (8)(%ebp), %edi movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movl (20)(%ebp), %eax movdqa (%eax), %xmm1 movl (12)(%ebp), %ecx movl (16)(%ebp), %edx .p2align 5, 0x90 .Lauth_loopgas_3: movdqu (%ecx), %xmm2 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm2 add $(16), %ecx pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %edx jnz .Lauth_loopgas_3 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .Lfe3: .size g9_AesGcmAuth_avx, .Lfe3-(g9_AesGcmAuth_avx) .p2align 5, 0x90 .globl g9_AesGcmEnc_avx .type g9_AesGcmEnc_avx, @function g9_AesGcmEnc_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax lea CONST_TABLE, %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_4 .p2align 5, 0x90 .Lblks4_loopgas_4: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm1 pxor (48)(%ebx), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm2 pxor (64)(%ebx), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm3 pxor (80)(%ebx), %xmm3 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm7 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_4 pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 movdqa %xmm0, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm2, (64)(%ebx) movdqa %xmm3, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 movdqa (16)(%eax), %xmm7 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 movdqa (%eax), %xmm7 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%ebx) .Lsingle_block_procgas_4: cmpl $(0), (132)(%ebx) jz .Lquitgas_4 .p2align 5, 0x90 .Lblk_loopgas_4: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe4: .size g9_AesGcmEnc_avx, .Lfe4-(g9_AesGcmEnc_avx) .p2align 5, 0x90 .globl g9_AesGcmDec_avx .type g9_AesGcmDec_avx, @function g9_AesGcmDec_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax lea CONST_TABLE, %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_5 .p2align 5, 0x90 .Lblks4_loopgas_5: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm4 pxor (32)(%ebx), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm5 pxor (48)(%ebx), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm6 pxor (64)(%ebx), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm7 pxor (80)(%ebx), %xmm7 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm0 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_5 pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 movdqa %xmm4, (32)(%ebx) movdqa %xmm5, (48)(%ebx) movdqa %xmm6, (64)(%ebx) movdqa %xmm7, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 movdqa (16)(%eax), %xmm0 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 movdqa (%eax), %xmm0 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%ebx) .Lsingle_block_procgas_5: cmpl $(0), (132)(%ebx) jz .Lquitgas_5 .p2align 5, 0x90 .Lblk_loopgas_5: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm1 pxor (32)(%ebx), %xmm1 movdqa (%eax), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 psllq $(1), %xmm2 pxor %xmm1, %xmm2 psllq $(5), %xmm2 pxor %xmm1, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe5: .size g9_AesGcmDec_avx, .Lfe5-(g9_AesGcmDec_avx) ",16332,True,4916.903422953811,median "# Copyright (C) 2011-2018 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF # THE POSSIBILITY OF SUCH DAMAGE. # Crash course on the language that this is written in (which I just call # ""assembly"" even though it's more than that): # # - Mostly gas-style operand ordering. The last operand tends to be the # destination. So ""a := b"" is written as ""mov b, a"". But unlike gas, # comparisons are in-order, so ""if (a < b)"" is written as # ""bilt a, b, ..."". # # - ""b"" = byte, ""h"" = 16-bit word, ""i"" = 32-bit word, ""p"" = pointer. # For 32-bit, ""i"" and ""p"" are interchangeable except when an op supports one # but not the other. # # - In general, valid operands for macro invocations and instructions are # registers (eg ""t0""), addresses (eg ""4[t0]""), base-index addresses # (eg ""7[t0, t1, 2]""), absolute addresses (eg ""0xa0000000[]""), or labels # (eg ""_foo"" or "".foo""). Macro invocations can also take anonymous # macros as operands. Instructions cannot take anonymous macros. # # - Labels must have names that begin with either ""_"" or ""."". A ""."" label # is local and gets renamed before code gen to minimize namespace # pollution. A ""_"" label is an extern symbol (i.e. "".globl""). The ""_"" # may or may not be removed during code gen depending on whether the asm # conventions for C name mangling on the target platform mandate a ""_"" # prefix. # # - A ""macro"" is a lambda expression, which may be either anonymous or # named. But this has caveats. ""macro"" can take zero or more arguments, # which may be macros or any valid operands, but it can only return # code. But you can do Turing-complete things via continuation passing # style: ""macro foo (a, b) b(a, a) end foo(foo, foo)"". Actually, don't do # that, since you'll just crash the assembler. # # - An ""if"" is a conditional on settings. Any identifier supplied in the # predicate of an ""if"" is assumed to be a #define that is available # during code gen. So you can't use ""if"" for computation in a macro, but # you can use it to select different pieces of code for different # platforms. # # - Arguments to macros follow lexical scoping rather than dynamic scoping. # Const's also follow lexical scoping and may override (hide) arguments # or other consts. All variables (arguments and constants) can be bound # to operands. Additionally, arguments (but not constants) can be bound # to macros. # The following general-purpose registers are available: # # - cfr and sp hold the call frame and (native) stack pointer respectively. # They are callee-save registers, and guaranteed to be distinct from all other # registers on all architectures. # # - lr is defined on non-X86 architectures (ARM64, ARMv7, ARM, # ARMv7_TRADITIONAL, MIPS and CLOOP) and holds the return PC # # - pc holds the (native) program counter on 32-bits ARM architectures (ARM, # ARMv7, ARMv7_TRADITIONAL) # # - t0, t1, t2, t3, t4 and optionally t5 are temporary registers that can get trashed on # calls, and are pairwise distinct registers. t4 holds the JS program counter, so use # with caution in opcodes (actually, don't use it in opcodes at all, except as PC). # # - r0 and r1 are the platform's customary return registers, and thus are # two distinct registers # # - a0, a1, a2 and a3 are the platform's customary argument registers, and # thus are pairwise distinct registers. Be mindful that: # + On X86, there are no argument registers. a0 and a1 are edx and # ecx following the fastcall convention, but you should still use the stack # to pass your arguments. The cCall2 and cCall4 macros do this for you. # + On X86_64_WIN, you should allocate space on the stack for the arguments, # and the return convention is weird for > 8 bytes types. The only place we # use > 8 bytes return values is on a cCall, and cCall2 and cCall4 handle # this for you. # # - The only registers guaranteed to be caller-saved are r0, r1, a0, a1 and a2, and # you should be mindful of that in functions that are called directly from C. # If you need more registers, you should push and pop them like a good # assembly citizen, because any other register will be callee-saved on X86. # # You can additionally assume: # # - a3, t2, t3, t4 and t5 are never return registers; t0, t1, a0, a1 and a2 # can be return registers. # # - t4 and t5 are never argument registers, t3 can only be a3, t1 can only be # a1; but t0 and t2 can be either a0 or a2. # # - On 64 bits, there are callee-save registers named csr0, csr1, ... csrN. # The last three csr registers are used used to store the PC base and # two special tag values. Don't use them for anything else. # # Additional platform-specific details (you shouldn't rely on this remaining # true): # # - For consistency with the baseline JIT, t0 is always r0 (and t1 is always # r1 on 32 bits platforms). You should use the r version when you need return # registers, and the t version otherwise: code using t0 (or t1) should still # work if swapped with e.g. t3, while code using r0 (or r1) should not. There # *may* be legacy code relying on this. # # - On all platforms other than X86, t0 can only be a0 and t2 can only be a2. # # - On all platforms other than X86 and X86_64, a2 is not a return register. # a2 is r0 on X86 (because we have so few registers) and r1 on X86_64 (because # the ABI enforces it). # # The following floating-point registers are available: # # - ft0-ft5 are temporary floating-point registers that get trashed on calls, # and are pairwise distinct. # # - fa0 and fa1 are the platform's customary floating-point argument # registers, and are both distinct. On 64-bits platforms, fa2 and fa3 are # additional floating-point argument registers. # # - fr is the platform's customary floating-point return register # # You can assume that ft1-ft5 or fa1-fa3 are never fr, and that ftX is never # faY if X != Y. # First come the common protocols that both interpreters use. Note that each # of these must have an ASSERT() in LLIntData.cpp # Work-around for the fact that the toolchain's awareness of armv7k / armv7s # results in a separate slab in the fat binary, yet the offlineasm doesn't know # to expect it. if ARMv7k end if ARMv7s end # These declarations must match interpreter/JSStack.h. const PtrSize = constexpr (sizeof(void*)) if JSVALUE64 const CallFrameHeaderSlots = 5 else const CallFrameHeaderSlots = 4 const CallFrameAlignSlots = 1 end const SlotSize = 8 const JSLexicalEnvironment_variables = (sizeof JSLexicalEnvironment + SlotSize - 1) & ~(SlotSize - 1) const DirectArguments_storage = (sizeof DirectArguments + SlotSize - 1) & ~(SlotSize - 1) const StackAlignment = 16 const StackAlignmentSlots = 2 const StackAlignmentMask = StackAlignment - 1 const CallerFrameAndPCSize = 2 * PtrSize const CallerFrame = 0 const ReturnPC = CallerFrame + PtrSize const CodeBlock = ReturnPC + PtrSize const Callee = CodeBlock + SlotSize const ArgumentCount = Callee + SlotSize const ThisArgumentOffset = ArgumentCount + SlotSize const FirstArgumentOffset = ThisArgumentOffset + SlotSize const CallFrameHeaderSize = ThisArgumentOffset # Some value representation constants. if JSVALUE64 const TagBitTypeOther = 0x2 const TagBitBool = 0x4 const TagBitUndefined = 0x8 const ValueEmpty = 0x0 const ValueFalse = TagBitTypeOther | TagBitBool const ValueTrue = TagBitTypeOther | TagBitBool | 1 const ValueUndefined = TagBitTypeOther | TagBitUndefined const ValueNull = TagBitTypeOther const TagTypeNumber = 0xffff000000000000 const TagMask = TagTypeNumber | TagBitTypeOther else const Int32Tag = -1 const BooleanTag = -2 const NullTag = -3 const UndefinedTag = -4 const CellTag = -5 const EmptyValueTag = -6 const DeletedValueTag = -7 const LowestTag = DeletedValueTag end # PutByIdFlags data const PutByIdPrimaryTypeMask = constexpr PutByIdPrimaryTypeMask const PutByIdPrimaryTypeSecondary = constexpr PutByIdPrimaryTypeSecondary const PutByIdPrimaryTypeObjectWithStructure = constexpr PutByIdPrimaryTypeObjectWithStructure const PutByIdPrimaryTypeObjectWithStructureOrOther = constexpr PutByIdPrimaryTypeObjectWithStructureOrOther const PutByIdSecondaryTypeMask = constexpr PutByIdSecondaryTypeMask const PutByIdSecondaryTypeBottom = constexpr PutByIdSecondaryTypeBottom const PutByIdSecondaryTypeBoolean = constexpr PutByIdSecondaryTypeBoolean const PutByIdSecondaryTypeOther = constexpr PutByIdSecondaryTypeOther const PutByIdSecondaryTypeInt32 = constexpr PutByIdSecondaryTypeInt32 const PutByIdSecondaryTypeNumber = constexpr PutByIdSecondaryTypeNumber const PutByIdSecondaryTypeString = constexpr PutByIdSecondaryTypeString const PutByIdSecondaryTypeSymbol = constexpr PutByIdSecondaryTypeSymbol const PutByIdSecondaryTypeObject = constexpr PutByIdSecondaryTypeObject const PutByIdSecondaryTypeObjectOrOther = constexpr PutByIdSecondaryTypeObjectOrOther const PutByIdSecondaryTypeTop = constexpr PutByIdSecondaryTypeTop const CallOpCodeSize = 9 if X86_64 or ARM64 or C_LOOP const maxFrameExtentForSlowPathCall = 0 elsif ARM or ARMv7_TRADITIONAL or ARMv7 const maxFrameExtentForSlowPathCall = 24 elsif X86 or X86_WIN const maxFrameExtentForSlowPathCall = 40 elsif MIPS const maxFrameExtentForSlowPathCall = 40 elsif X86_64_WIN const maxFrameExtentForSlowPathCall = 64 end if X86_64 or X86_64_WIN or ARM64 const CalleeSaveSpaceAsVirtualRegisters = 3 else const CalleeSaveSpaceAsVirtualRegisters = 0 end const CalleeSaveSpaceStackAligned = (CalleeSaveSpaceAsVirtualRegisters * SlotSize + StackAlignment - 1) & ~StackAlignmentMask # Watchpoint states const ClearWatchpoint = constexpr ClearWatchpoint const IsWatched = constexpr IsWatched const IsInvalidated = constexpr IsInvalidated # ShadowChicken data const ShadowChickenTailMarker = constexpr ShadowChicken::Packet::tailMarkerValue # ArithProfile data const ArithProfileInt = 0x400000 const ArithProfileIntInt = 0x480000 const ArithProfileNumber = 0x800000 const ArithProfileNumberInt = 0x880000 const ArithProfileNumberNumber = 0x900000 const ArithProfileIntNumber = 0x500000 # Some register conventions. if JSVALUE64 # - Use a pair of registers to represent the PC: one register for the # base of the bytecodes, and one register for the index. # - The PC base (or PB for short) must be stored in a callee-save register. # - C calls are still given the Instruction* rather than the PC index. # This requires an add before the call, and a sub after. const PC = t4 # When changing this, make sure LLIntPC is up to date in LLIntPCRanges.h if ARM64 const PB = csr7 const tagTypeNumber = csr8 const tagMask = csr9 elsif X86_64 const PB = csr2 const tagTypeNumber = csr3 const tagMask = csr4 elsif X86_64_WIN const PB = csr4 const tagTypeNumber = csr5 const tagMask = csr6 elsif C_LOOP const PB = csr0 const tagTypeNumber = csr1 const tagMask = csr2 end macro loadisFromInstruction(offset, dest) loadis offset * 8[PB, PC, 8], dest end macro loadpFromInstruction(offset, dest) loadp offset * 8[PB, PC, 8], dest end macro loadisFromStruct(offset, dest) loadis offset[PB, PC, 8], dest end macro loadpFromStruct(offset, dest) loadp offset[PB, PC, 8], dest end macro storeisToInstruction(value, offset) storei value, offset * 8[PB, PC, 8] end macro storepToInstruction(value, offset) storep value, offset * 8[PB, PC, 8] end macro storeisFromStruct(value, offset) storei value, offset[PB, PC, 8] end macro storepFromStruct(value, offset) storep value, offset[PB, PC, 8] end else const PC = t4 # When changing this, make sure LLIntPC is up to date in LLIntPCRanges.h macro loadisFromInstruction(offset, dest) loadis offset * 4[PC], dest end macro loadpFromInstruction(offset, dest) loadp offset * 4[PC], dest end macro storeisToInstruction(value, offset) storei value, offset * 4[PC] end macro loadisFromStruct(offset, dest) loadis offset[PC], dest end macro loadpFromStruct(offset, dest) loadp offset[PC], dest end macro storeisToStruct(value, offset) storei value, offset[PC] end end if X86_64_WIN const extraTempReg = t0 else const extraTempReg = t5 end # Constants for reasoning about value representation. if BIG_ENDIAN const TagOffset = 0 const PayloadOffset = 4 else const TagOffset = 4 const PayloadOffset = 0 end # Constant for reasoning about butterflies. const IsArray = constexpr IsArray const IndexingShapeMask = constexpr IndexingShapeMask const NoIndexingShape = constexpr NoIndexingShape const Int32Shape = constexpr Int32Shape const DoubleShape = constexpr DoubleShape const ContiguousShape = constexpr ContiguousShape const ArrayStorageShape = constexpr ArrayStorageShape const SlowPutArrayStorageShape = constexpr SlowPutArrayStorageShape # Type constants. const StringType = constexpr StringType const SymbolType = constexpr SymbolType const ObjectType = constexpr ObjectType const FinalObjectType = constexpr FinalObjectType const JSFunctionType = constexpr JSFunctionType const ArrayType = constexpr ArrayType const DerivedArrayType = constexpr DerivedArrayType const ProxyObjectType = constexpr ProxyObjectType # The typed array types need to be numbered in a particular order because of the manually written # switch statement in get_by_val and put_by_val. const Int8ArrayType = constexpr Int8ArrayType const Uint8ArrayType = constexpr Uint8ArrayType const Uint8ClampedArrayType = constexpr Uint8ClampedArrayType const Int16ArrayType = constexpr Int16ArrayType const Uint16ArrayType = constexpr Uint16ArrayType const Int32ArrayType = constexpr Int32ArrayType const Uint32ArrayType = constexpr Uint32ArrayType const Float32ArrayType = constexpr Float32ArrayType const Float64ArrayType = constexpr Float64ArrayType const FirstArrayType = constexpr FirstTypedArrayType const NumberOfTypedArrayTypesExcludingDataView = constexpr NumberOfTypedArrayTypesExcludingDataView const TypedArrayPoisonIndexMask = constexpr TypedArrayPoisonIndexMask # Type flags constants. const MasqueradesAsUndefined = constexpr MasqueradesAsUndefined const ImplementsDefaultHasInstance = constexpr ImplementsDefaultHasInstance # Bytecode operand constants. const FirstConstantRegisterIndex = constexpr FirstConstantRegisterIndex # Code type constants. const GlobalCode = constexpr GlobalCode const EvalCode = constexpr EvalCode const FunctionCode = constexpr FunctionCode const ModuleCode = constexpr ModuleCode # The interpreter steals the tag word of the argument count. const LLIntReturnPC = ArgumentCount + TagOffset # String flags. const HashFlags8BitBuffer = 8 # Copied from PropertyOffset.h const firstOutOfLineOffset = 100 # ResolveType const GlobalProperty = constexpr GlobalProperty const GlobalVar = constexpr GlobalVar const GlobalLexicalVar = constexpr GlobalLexicalVar const ClosureVar = constexpr ClosureVar const LocalClosureVar = constexpr LocalClosureVar const ModuleVar = constexpr ModuleVar const GlobalPropertyWithVarInjectionChecks = constexpr GlobalPropertyWithVarInjectionChecks const GlobalVarWithVarInjectionChecks = constexpr GlobalVarWithVarInjectionChecks const GlobalLexicalVarWithVarInjectionChecks = constexpr GlobalLexicalVarWithVarInjectionChecks const ClosureVarWithVarInjectionChecks = constexpr ClosureVarWithVarInjectionChecks const ResolveTypeMask = constexpr GetPutInfo::typeBits const InitializationModeMask = constexpr GetPutInfo::initializationBits const InitializationModeShift = constexpr GetPutInfo::initializationShift const NotInitialization = constexpr InitializationMode::NotInitialization const MarkedBlockSize = constexpr MarkedBlock::blockSize const MarkedBlockMask = ~(MarkedBlockSize - 1) const MarkedBlockFooterOffset = constexpr MarkedBlock::offsetOfFooter const BlackThreshold = constexpr blackThreshold # Allocation constants if JSVALUE64 const JSFinalObjectSizeClassIndex = 1 else const JSFinalObjectSizeClassIndex = 3 end # This must match wtf/Vector.h const VectorBufferOffset = 0 if JSVALUE64 const VectorSizeOffset = 12 else const VectorSizeOffset = 8 end # Some common utilities. macro crash() if C_LOOP cloopCrash else call _llint_crash end end macro assert(assertion) if ASSERT_ENABLED assertion(.ok) crash() .ok: end end # The probe macro can be used to insert some debugging code without perturbing scalar # registers. Presently, the probe macro only preserves scalar registers. Hence, the # C probe callback function should not trash floating point registers. # # The macro you pass to probe() can pass whatever registers you like to your probe # callback function. However, you need to be mindful of which of the registers are # also used as argument registers, and ensure that you don't trash the register value # before storing it in the probe callback argument register that you desire. # # Here's an example of how it's used: # # probe( # macro() # move cfr, a0 # pass the ExecState* as arg0. # move t0, a1 # pass the value of register t0 as arg1. # call _cProbeCallbackFunction # to do whatever you want. # end # ) # if X86_64 macro probe(action) # save all the registers that the LLInt may use. push a0, a1 push a2, a3 push t0, t1 push t2, t3 push t4, t5 action() # restore all the registers we saved previously. pop t5, t4 pop t3, t2 pop t1, t0 pop a3, a2 pop a1, a0 end end macro checkStackPointerAlignment(tempReg, location) if ARM64 or C_LOOP # ARM64 will check for us! # C_LOOP does not need the alignment, and can use a little perf # improvement from avoiding useless work. else if ARM or ARMv7 or ARMv7_TRADITIONAL # ARM can't do logical ops with the sp as a source move sp, tempReg andp StackAlignmentMask, tempReg else andp sp, StackAlignmentMask, tempReg end btpz tempReg, .stackPointerOkay move location, tempReg break .stackPointerOkay: end end if C_LOOP or ARM64 or X86_64 or X86_64_WIN const CalleeSaveRegisterCount = 0 elsif ARM or ARMv7_TRADITIONAL or ARMv7 const CalleeSaveRegisterCount = 7 elsif MIPS const CalleeSaveRegisterCount = 1 elsif X86 or X86_WIN const CalleeSaveRegisterCount = 3 end const CalleeRegisterSaveSize = CalleeSaveRegisterCount * PtrSize # VMEntryTotalFrameSize includes the space for struct VMEntryRecord and the # callee save registers rounded up to keep the stack aligned const VMEntryTotalFrameSize = (CalleeRegisterSaveSize + sizeof VMEntryRecord + StackAlignment - 1) & ~StackAlignmentMask macro pushCalleeSaves() if C_LOOP or ARM64 or X86_64 or X86_64_WIN elsif ARM or ARMv7_TRADITIONAL emit ""push {r4-r10}"" elsif ARMv7 emit ""push {r4-r6, r8-r11}"" elsif MIPS emit ""addiu $sp, $sp, -4"" emit ""sw $s4, 0($sp)"" # save $gp to $s4 so that we can restore it after a function call emit ""move $s4, $gp"" elsif X86 emit ""push %esi"" emit ""push %edi"" emit ""push %ebx"" elsif X86_WIN emit ""push esi"" emit ""push edi"" emit ""push ebx"" end end macro popCalleeSaves() if C_LOOP or ARM64 or X86_64 or X86_64_WIN elsif ARM or ARMv7_TRADITIONAL emit ""pop {r4-r10}"" elsif ARMv7 emit ""pop {r4-r6, r8-r11}"" elsif MIPS emit ""lw $s4, 0($sp)"" emit ""addiu $sp, $sp, 4"" elsif X86 emit ""pop %ebx"" emit ""pop %edi"" emit ""pop %esi"" elsif X86_WIN emit ""pop ebx"" emit ""pop edi"" emit ""pop esi"" end end macro preserveCallerPCAndCFR() if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS push lr push cfr elsif X86 or X86_WIN or X86_64 or X86_64_WIN push cfr elsif ARM64 push cfr, lr else error end move sp, cfr end macro restoreCallerPCAndCFR() move cfr, sp if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS pop cfr pop lr elsif X86 or X86_WIN or X86_64 or X86_64_WIN pop cfr elsif ARM64 pop lr, cfr end end macro preserveCalleeSavesUsedByLLInt() subp CalleeSaveSpaceStackAligned, sp if C_LOOP elsif ARM or ARMv7_TRADITIONAL elsif ARMv7 elsif ARM64 emit ""stp x27, x28, [x29, #-16]"" emit ""stp xzr, x26, [x29, #-32]"" elsif MIPS elsif X86 elsif X86_WIN elsif X86_64 storep csr4, -8[cfr] storep csr3, -16[cfr] storep csr2, -24[cfr] elsif X86_64_WIN storep csr6, -8[cfr] storep csr5, -16[cfr] storep csr4, -24[cfr] end end macro restoreCalleeSavesUsedByLLInt() if C_LOOP elsif ARM or ARMv7_TRADITIONAL elsif ARMv7 elsif ARM64 emit ""ldp xzr, x26, [x29, #-32]"" emit ""ldp x27, x28, [x29, #-16]"" elsif MIPS elsif X86 elsif X86_WIN elsif X86_64 loadp -24[cfr], csr2 loadp -16[cfr], csr3 loadp -8[cfr], csr4 elsif X86_64_WIN loadp -24[cfr], csr4 loadp -16[cfr], csr5 loadp -8[cfr], csr6 end end macro copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(vm, temp) if ARM64 or X86_64 or X86_64_WIN loadp VM::topEntryFrame[vm], temp vmEntryRecord(temp, temp) leap VMEntryRecord::calleeSaveRegistersBuffer[temp], temp if ARM64 storep csr0, [temp] storep csr1, 8[temp] storep csr2, 16[temp] storep csr3, 24[temp] storep csr4, 32[temp] storep csr5, 40[temp] storep csr6, 48[temp] storep csr7, 56[temp] storep csr8, 64[temp] storep csr9, 72[temp] stored csfr0, 80[temp] stored csfr1, 88[temp] stored csfr2, 96[temp] stored csfr3, 104[temp] stored csfr4, 112[temp] stored csfr5, 120[temp] stored csfr6, 128[temp] stored csfr7, 136[temp] elsif X86_64 storep csr0, [temp] storep csr1, 8[temp] storep csr2, 16[temp] storep csr3, 24[temp] storep csr4, 32[temp] elsif X86_64_WIN storep csr0, [temp] storep csr1, 8[temp] storep csr2, 16[temp] storep csr3, 24[temp] storep csr4, 32[temp] storep csr5, 40[temp] storep csr6, 48[temp] end end end macro restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(vm, temp) if ARM64 or X86_64 or X86_64_WIN loadp VM::topEntryFrame[vm], temp vmEntryRecord(temp, temp) leap VMEntryRecord::calleeSaveRegistersBuffer[temp], temp if ARM64 loadp [temp], csr0 loadp 8[temp], csr1 loadp 16[temp], csr2 loadp 24[temp], csr3 loadp 32[temp], csr4 loadp 40[temp], csr5 loadp 48[temp], csr6 loadp 56[temp], csr7 loadp 64[temp], csr8 loadp 72[temp], csr9 loadd 80[temp], csfr0 loadd 88[temp], csfr1 loadd 96[temp], csfr2 loadd 104[temp], csfr3 loadd 112[temp], csfr4 loadd 120[temp], csfr5 loadd 128[temp], csfr6 loadd 136[temp], csfr7 elsif X86_64 loadp [temp], csr0 loadp 8[temp], csr1 loadp 16[temp], csr2 loadp 24[temp], csr3 loadp 32[temp], csr4 elsif X86_64_WIN loadp [temp], csr0 loadp 8[temp], csr1 loadp 16[temp], csr2 loadp 24[temp], csr3 loadp 32[temp], csr4 loadp 40[temp], csr5 loadp 48[temp], csr6 end end end macro preserveReturnAddressAfterCall(destinationRegister) if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or ARM64 or MIPS # In C_LOOP case, we're only preserving the bytecode vPC. move lr, destinationRegister elsif X86 or X86_WIN or X86_64 or X86_64_WIN pop destinationRegister else error end end macro unpoison(poison, field, scratch) if POISON loadp poison, scratch xorp scratch, field end end macro functionPrologue() if X86 or X86_WIN or X86_64 or X86_64_WIN push cfr elsif ARM64 push cfr, lr elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS push lr push cfr end move sp, cfr end macro functionEpilogue() if X86 or X86_WIN or X86_64 or X86_64_WIN pop cfr elsif ARM64 pop lr, cfr elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS pop cfr pop lr end end macro vmEntryRecord(entryFramePointer, resultReg) subp entryFramePointer, VMEntryTotalFrameSize, resultReg end macro getFrameRegisterSizeForCodeBlock(codeBlock, size) loadi CodeBlock::m_numCalleeLocals[codeBlock], size lshiftp 3, size addp maxFrameExtentForSlowPathCall, size end macro restoreStackPointerAfterCall() loadp CodeBlock[cfr], t2 getFrameRegisterSizeForCodeBlock(t2, t2) if ARMv7 subp cfr, t2, t2 move t2, sp else subp cfr, t2, sp end end macro traceExecution() if COLLECT_STATS callSlowPath(_llint_count_opcode) end if EXECUTION_TRACING callSlowPath(_llint_trace) end end macro traceSlowPathExecution() if COLLECT_STATS callSlowPath(_llint_count_opcode_slow_path) end end macro callOpcodeSlowPath(slowPath) traceSlowPathExecution() callSlowPath(slowPath) end macro callTargetFunction(callee) if C_LOOP cloopCallJSFunction callee else call callee end restoreStackPointerAfterCall() dispatchAfterCall() end macro prepareForRegularCall(callee, temp1, temp2, temp3) addp CallerFrameAndPCSize, sp end # sp points to the new frame macro prepareForTailCall(callee, temp1, temp2, temp3) restoreCalleeSavesUsedByLLInt() loadi PayloadOffset + ArgumentCount[cfr], temp2 loadp CodeBlock[cfr], temp1 loadp CodeBlock::m_numParameters[temp1], temp1 bilteq temp1, temp2, .noArityFixup move temp1, temp2 .noArityFixup: # We assume < 2^28 arguments muli SlotSize, temp2 addi StackAlignment - 1 + CallFrameHeaderSize, temp2 andi ~StackAlignmentMask, temp2 move cfr, temp1 addp temp2, temp1 loadi PayloadOffset + ArgumentCount[sp], temp2 # We assume < 2^28 arguments muli SlotSize, temp2 addi StackAlignment - 1 + CallFrameHeaderSize, temp2 andi ~StackAlignmentMask, temp2 if ARM or ARMv7_TRADITIONAL or ARMv7 or ARM64 or C_LOOP or MIPS addp 2 * PtrSize, sp subi 2 * PtrSize, temp2 loadp PtrSize[cfr], lr else addp PtrSize, sp subi PtrSize, temp2 loadp PtrSize[cfr], temp3 storep temp3, [sp] end subp temp2, temp1 loadp [cfr], cfr .copyLoop: subi PtrSize, temp2 loadp [sp, temp2, 1], temp3 storep temp3, [temp1, temp2, 1] btinz temp2, .copyLoop move temp1, sp jmp callee end macro slowPathForCall(slowPath, prepareCall) traceSlowPathExecution() callCallSlowPath( slowPath, # Those are r0 and r1 macro (callee, calleeFramePtr) btpz calleeFramePtr, .dontUpdateSP move calleeFramePtr, sp prepareCall(callee, t2, t3, t4) .dontUpdateSP: callTargetFunction(callee) end) end macro arrayProfile(cellAndIndexingType, profile, scratch) const cell = cellAndIndexingType const indexingType = cellAndIndexingType loadi JSCell::m_structureID[cell], scratch storei scratch, ArrayProfile::m_lastSeenStructureID[profile] loadb JSCell::m_indexingTypeAndMisc[cell], indexingType end macro skipIfIsRememberedOrInEden(cell, slowPath) memfence bba JSCell::m_cellState[cell], BlackThreshold, .done slowPath() .done: end macro notifyWrite(set, slow) bbneq WatchpointSet::m_state[set], IsInvalidated, slow end macro checkSwitchToJIT(increment, action) loadp CodeBlock[cfr], t0 baddis increment, CodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter[t0], .continue action() .continue: end macro checkSwitchToJITForEpilogue() checkSwitchToJIT( 10, macro () callOpcodeSlowPath(_llint_replace) end) end macro assertNotConstant(index) assert(macro (ok) bilt index, FirstConstantRegisterIndex, ok end) end macro functionForCallCodeBlockGetter(targetRegister, scratch) if JSVALUE64 loadp Callee[cfr], targetRegister else loadp Callee + PayloadOffset[cfr], targetRegister end loadp JSFunction::m_executable[targetRegister], targetRegister unpoison(_g_JSFunctionPoison, targetRegister, scratch) loadp FunctionExecutable::m_codeBlockForCall[targetRegister], targetRegister loadp ExecutableToCodeBlockEdge::m_codeBlock[targetRegister], targetRegister end macro functionForConstructCodeBlockGetter(targetRegister, scratch) if JSVALUE64 loadp Callee[cfr], targetRegister else loadp Callee + PayloadOffset[cfr], targetRegister end loadp JSFunction::m_executable[targetRegister], targetRegister unpoison(_g_JSFunctionPoison, targetRegister, scratch) loadp FunctionExecutable::m_codeBlockForConstruct[targetRegister], targetRegister loadp ExecutableToCodeBlockEdge::m_codeBlock[targetRegister], targetRegister end macro notFunctionCodeBlockGetter(targetRegister, ignored) loadp CodeBlock[cfr], targetRegister end macro functionCodeBlockSetter(sourceRegister) storep sourceRegister, CodeBlock[cfr] end macro notFunctionCodeBlockSetter(sourceRegister) # Nothing to do! end # Do the bare minimum required to execute code. Sets up the PC, leave the CodeBlock* # in t1. May also trigger prologue entry OSR. macro prologue(codeBlockGetter, codeBlockSetter, osrSlowPath, traceSlowPath) # Set up the call frame and check if we should OSR. preserveCallerPCAndCFR() if EXECUTION_TRACING subp maxFrameExtentForSlowPathCall, sp callSlowPath(traceSlowPath) addp maxFrameExtentForSlowPathCall, sp end codeBlockGetter(t1, t2) if not C_LOOP baddis 5, CodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter[t1], .continue if JSVALUE64 move cfr, a0 move PC, a1 cCall2(osrSlowPath) else # We are after the function prologue, but before we have set up sp from the CodeBlock. # Temporarily align stack pointer for this call. subp 8, sp move cfr, a0 move PC, a1 cCall2(osrSlowPath) addp 8, sp end btpz r0, .recover move cfr, sp # restore the previous sp # pop the callerFrame since we will jump to a function that wants to save it if ARM64 pop lr, cfr elsif ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS pop cfr pop lr else pop cfr end jmp r0 .recover: codeBlockGetter(t1, t2) .continue: end codeBlockSetter(t1) preserveCalleeSavesUsedByLLInt() # Set up the PC. if JSVALUE64 loadp CodeBlock::m_instructions[t1], PB unpoison(_g_CodeBlockPoison, PB, t3) move 0, PC else loadp CodeBlock::m_instructions[t1], PC end # Get new sp in t0 and check stack height. getFrameRegisterSizeForCodeBlock(t1, t0) subp cfr, t0, t0 bpa t0, cfr, .needStackCheck loadp CodeBlock::m_poisonedVM[t1], t2 unpoison(_g_CodeBlockPoison, t2, t3) if C_LOOP bpbeq VM::m_cloopStackLimit[t2], t0, .stackHeightOK else bpbeq VM::m_softStackLimit[t2], t0, .stackHeightOK end .needStackCheck: # Stack height check failed - need to call a slow_path. # Set up temporary stack pointer for call including callee saves subp maxFrameExtentForSlowPathCall, sp callSlowPath(_llint_stack_check) bpeq r1, 0, .stackHeightOKGetCodeBlock move r1, cfr dispatch(0) # Go to exception handler in PC .stackHeightOKGetCodeBlock: # Stack check slow path returned that the stack was ok. # Since they were clobbered, need to get CodeBlock and new sp codeBlockGetter(t1, t2) getFrameRegisterSizeForCodeBlock(t1, t0) subp cfr, t0, t0 .stackHeightOK: move t0, sp if JSVALUE64 move TagTypeNumber, tagTypeNumber addp TagBitTypeOther, tagTypeNumber, tagMask end end # Expects that CodeBlock is in t1, which is what prologue() leaves behind. # Must call dispatch(0) after calling this. macro functionInitialization(profileArgSkip) # Profile the arguments. Unfortunately, we have no choice but to do this. This # code is pretty horrendous because of the difference in ordering between # arguments and value profiles, the desire to have a simple loop-down-to-zero # loop, and the desire to use only three registers so as to preserve the PC and # the code block. It is likely that this code should be rewritten in a more # optimal way for architectures that have more than five registers available # for arbitrary use in the interpreter. loadi CodeBlock::m_numParameters[t1], t0 addp -profileArgSkip, t0 # Use addi because that's what has the peephole assert(macro (ok) bpgteq t0, 0, ok end) btpz t0, .argumentProfileDone loadp CodeBlock::m_argumentValueProfiles + VectorBufferOffset[t1], t3 mulp sizeof ValueProfile, t0, t2 # Aaaaahhhh! Need strength reduction! lshiftp 3, t0 addp t2, t3 .argumentProfileLoop: if JSVALUE64 loadq ThisArgumentOffset - 8 + profileArgSkip * 8[cfr, t0], t2 subp sizeof ValueProfile, t3 storeq t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets[t3] else loadi ThisArgumentOffset + TagOffset - 8 + profileArgSkip * 8[cfr, t0], t2 subp sizeof ValueProfile, t3 storei t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets + TagOffset[t3] loadi ThisArgumentOffset + PayloadOffset - 8 + profileArgSkip * 8[cfr, t0], t2 storei t2, profileArgSkip * sizeof ValueProfile + ValueProfile::m_buckets + PayloadOffset[t3] end baddpnz -8, t0, .argumentProfileLoop .argumentProfileDone: end macro doReturn() restoreCalleeSavesUsedByLLInt() restoreCallerPCAndCFR() ret end # stub to call into JavaScript or Native functions # EncodedJSValue vmEntryToJavaScript(void* code, VM* vm, ProtoCallFrame* protoFrame) # EncodedJSValue vmEntryToNativeFunction(void* code, VM* vm, ProtoCallFrame* protoFrame) if C_LOOP _llint_vm_entry_to_javascript: else global _vmEntryToJavaScript _vmEntryToJavaScript: end doVMEntry(makeJavaScriptCall) if C_LOOP _llint_vm_entry_to_native: else global _vmEntryToNative _vmEntryToNative: end doVMEntry(makeHostFunctionCall) if not C_LOOP # void sanitizeStackForVMImpl(VM* vm) global _sanitizeStackForVMImpl _sanitizeStackForVMImpl: # We need three non-aliased caller-save registers. We are guaranteed # this for a0, a1 and a2 on all architectures. if X86 or X86_WIN loadp 4[sp], a0 end const vm = a0 const address = a1 const zeroValue = a2 loadp VM::m_lastStackTop[vm], address bpbeq sp, address, .zeroFillDone move 0, zeroValue .zeroFillLoop: storep zeroValue, [address] addp PtrSize, address bpa sp, address, .zeroFillLoop .zeroFillDone: move sp, address storep address, VM::m_lastStackTop[vm] ret # VMEntryRecord* vmEntryRecord(const EntryFrame* entryFrame) global _vmEntryRecord _vmEntryRecord: if X86 or X86_WIN loadp 4[sp], a0 end vmEntryRecord(a0, r0) ret end if C_LOOP # Dummy entry point the C Loop uses to initialize. _llint_entry: crash() else macro initPCRelative(pcBase) if X86_64 or X86_64_WIN or X86 or X86_WIN call _relativePCBase _relativePCBase: pop pcBase elsif ARM64 elsif ARMv7 _relativePCBase: move pc, pcBase subp 3, pcBase # Need to back up the PC and set the Thumb2 bit elsif ARM or ARMv7_TRADITIONAL _relativePCBase: move pc, pcBase subp 8, pcBase elsif MIPS la _relativePCBase, pcBase setcallreg pcBase # needed to set $t9 to the right value for the .cpload created by the label. _relativePCBase: end end # The PC base is in t1, as this is what _llint_entry leaves behind through # initPCRelative(t1) macro setEntryAddress(index, label) if X86_64 or X86_64_WIN leap (label - _relativePCBase)[t1], t3 move index, t4 storep t3, [a0, t4, 8] elsif X86 or X86_WIN leap (label - _relativePCBase)[t1], t3 move index, t4 storep t3, [a0, t4, 4] elsif ARM64 pcrtoaddr label, t1 move index, t4 storep t1, [a0, t4, 8] elsif ARM or ARMv7 or ARMv7_TRADITIONAL mvlbl (label - _relativePCBase), t4 addp t4, t1, t4 move index, t3 storep t4, [a0, t3, 4] elsif MIPS la label, t4 la _relativePCBase, t3 subp t3, t4 addp t4, t1, t4 move index, t3 storep t4, [a0, t3, 4] end end global _llint_entry # Entry point for the llint to initialize. _llint_entry: functionPrologue() pushCalleeSaves() if X86 or X86_WIN loadp 20[sp], a0 end initPCRelative(t1) # Include generated bytecode initialization file. include InitBytecodes popCalleeSaves() functionEpilogue() ret end _llint_program_prologue: prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue) dispatch(0) _llint_module_program_prologue: prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue) dispatch(0) _llint_eval_prologue: prologue(notFunctionCodeBlockGetter, notFunctionCodeBlockSetter, _llint_entry_osr, _llint_trace_prologue) dispatch(0) _llint_function_for_call_prologue: prologue(functionForCallCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_call, _llint_trace_prologue_function_for_call) functionInitialization(0) dispatch(0) _llint_function_for_construct_prologue: prologue(functionForConstructCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_construct, _llint_trace_prologue_function_for_construct) functionInitialization(1) dispatch(0) _llint_function_for_call_arity_check: prologue(functionForCallCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_call_arityCheck, _llint_trace_arityCheck_for_call) functionArityCheck(.functionForCallBegin, _slow_path_call_arityCheck) .functionForCallBegin: functionInitialization(0) dispatch(0) _llint_function_for_construct_arity_check: prologue(functionForConstructCodeBlockGetter, functionCodeBlockSetter, _llint_entry_osr_function_for_construct_arityCheck, _llint_trace_arityCheck_for_construct) functionArityCheck(.functionForConstructBegin, _slow_path_construct_arityCheck) .functionForConstructBegin: functionInitialization(1) dispatch(0) # Value-representation-specific code. if JSVALUE64 include LowLevelInterpreter64 else include LowLevelInterpreter32_64 end # Value-representation-agnostic code. _llint_op_create_direct_arguments: traceExecution() callOpcodeSlowPath(_slow_path_create_direct_arguments) dispatch(constexpr op_create_direct_arguments_length) _llint_op_create_scoped_arguments: traceExecution() callOpcodeSlowPath(_slow_path_create_scoped_arguments) dispatch(constexpr op_create_scoped_arguments_length) _llint_op_create_cloned_arguments: traceExecution() callOpcodeSlowPath(_slow_path_create_cloned_arguments) dispatch(constexpr op_create_cloned_arguments_length) _llint_op_create_this: traceExecution() callOpcodeSlowPath(_slow_path_create_this) dispatch(constexpr op_create_this_length) _llint_op_new_object: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_object) dispatch(constexpr op_new_object_length) _llint_op_new_func: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_func) dispatch(constexpr op_new_func_length) _llint_op_new_generator_func: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_generator_func) dispatch(constexpr op_new_generator_func_length) _llint_op_new_async_generator_func: traceExecution() callSlowPath(_llint_slow_path_new_async_generator_func) dispatch(constexpr op_new_async_generator_func_length) _llint_op_new_async_generator_func_exp: traceExecution() callSlowPath(_llint_slow_path_new_async_generator_func_exp) dispatch(constexpr op_new_async_generator_func_exp_length) _llint_op_new_async_func: traceExecution() callSlowPath(_llint_slow_path_new_async_func) dispatch(constexpr op_new_async_func_length) _llint_op_new_array: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_array) dispatch(constexpr op_new_array_length) _llint_op_new_array_with_spread: traceExecution() callOpcodeSlowPath(_slow_path_new_array_with_spread) dispatch(constexpr op_new_array_with_spread_length) _llint_op_spread: traceExecution() callOpcodeSlowPath(_slow_path_spread) dispatch(constexpr op_spread_length) _llint_op_new_array_with_size: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_array_with_size) dispatch(constexpr op_new_array_with_size_length) _llint_op_new_array_buffer: traceExecution() callOpcodeSlowPath(_slow_path_new_array_buffer) dispatch(constexpr op_new_array_buffer_length) _llint_op_new_regexp: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_regexp) dispatch(constexpr op_new_regexp_length) _llint_op_less: traceExecution() callOpcodeSlowPath(_slow_path_less) dispatch(constexpr op_less_length) _llint_op_lesseq: traceExecution() callOpcodeSlowPath(_slow_path_lesseq) dispatch(constexpr op_lesseq_length) _llint_op_greater: traceExecution() callOpcodeSlowPath(_slow_path_greater) dispatch(constexpr op_greater_length) _llint_op_greatereq: traceExecution() callOpcodeSlowPath(_slow_path_greatereq) dispatch(constexpr op_greatereq_length) _llint_op_below: traceExecution() compareUnsigned( macro (left, right, result) cib left, right, result end) _llint_op_beloweq: traceExecution() compareUnsigned( macro (left, right, result) cibeq left, right, result end) _llint_op_mod: traceExecution() callOpcodeSlowPath(_slow_path_mod) dispatch(constexpr op_mod_length) _llint_op_pow: traceExecution() callOpcodeSlowPath(_slow_path_pow) dispatch(constexpr op_pow_length) _llint_op_typeof: traceExecution() callOpcodeSlowPath(_slow_path_typeof) dispatch(constexpr op_typeof_length) _llint_op_is_object_or_null: traceExecution() callOpcodeSlowPath(_slow_path_is_object_or_null) dispatch(constexpr op_is_object_or_null_length) _llint_op_is_function: traceExecution() callOpcodeSlowPath(_slow_path_is_function) dispatch(constexpr op_is_function_length) _llint_op_in: traceExecution() callOpcodeSlowPath(_slow_path_in) dispatch(constexpr op_in_length) _llint_op_try_get_by_id: traceExecution() callOpcodeSlowPath(_llint_slow_path_try_get_by_id) dispatch(constexpr op_try_get_by_id_length) _llint_op_del_by_id: traceExecution() callOpcodeSlowPath(_llint_slow_path_del_by_id) dispatch(constexpr op_del_by_id_length) _llint_op_del_by_val: traceExecution() callOpcodeSlowPath(_llint_slow_path_del_by_val) dispatch(constexpr op_del_by_val_length) _llint_op_put_by_index: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_by_index) dispatch(constexpr op_put_by_index_length) _llint_op_put_getter_by_id: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_getter_by_id) dispatch(constexpr op_put_getter_by_id_length) _llint_op_put_setter_by_id: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_setter_by_id) dispatch(constexpr op_put_setter_by_id_length) _llint_op_put_getter_setter_by_id: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_getter_setter_by_id) dispatch(constexpr op_put_getter_setter_by_id_length) _llint_op_put_getter_by_val: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_getter_by_val) dispatch(constexpr op_put_getter_by_val_length) _llint_op_put_setter_by_val: traceExecution() callOpcodeSlowPath(_llint_slow_path_put_setter_by_val) dispatch(constexpr op_put_setter_by_val_length) _llint_op_define_data_property: traceExecution() callOpcodeSlowPath(_slow_path_define_data_property) dispatch(constexpr op_define_data_property_length) _llint_op_define_accessor_property: traceExecution() callOpcodeSlowPath(_slow_path_define_accessor_property) dispatch(constexpr op_define_accessor_property_length) _llint_op_jtrue: traceExecution() jumpTrueOrFalse( macro (value, target) btinz value, target end, _llint_slow_path_jtrue) _llint_op_jfalse: traceExecution() jumpTrueOrFalse( macro (value, target) btiz value, target end, _llint_slow_path_jfalse) _llint_op_jless: traceExecution() compare( macro (left, right, target) bilt left, right, target end, macro (left, right, target) bdlt left, right, target end, _llint_slow_path_jless) _llint_op_jnless: traceExecution() compare( macro (left, right, target) bigteq left, right, target end, macro (left, right, target) bdgtequn left, right, target end, _llint_slow_path_jnless) _llint_op_jgreater: traceExecution() compare( macro (left, right, target) bigt left, right, target end, macro (left, right, target) bdgt left, right, target end, _llint_slow_path_jgreater) _llint_op_jngreater: traceExecution() compare( macro (left, right, target) bilteq left, right, target end, macro (left, right, target) bdltequn left, right, target end, _llint_slow_path_jngreater) _llint_op_jlesseq: traceExecution() compare( macro (left, right, target) bilteq left, right, target end, macro (left, right, target) bdlteq left, right, target end, _llint_slow_path_jlesseq) _llint_op_jnlesseq: traceExecution() compare( macro (left, right, target) bigt left, right, target end, macro (left, right, target) bdgtun left, right, target end, _llint_slow_path_jnlesseq) _llint_op_jgreatereq: traceExecution() compare( macro (left, right, target) bigteq left, right, target end, macro (left, right, target) bdgteq left, right, target end, _llint_slow_path_jgreatereq) _llint_op_jngreatereq: traceExecution() compare( macro (left, right, target) bilt left, right, target end, macro (left, right, target) bdltun left, right, target end, _llint_slow_path_jngreatereq) _llint_op_jbelow: traceExecution() compareUnsignedJump( macro (left, right, target) bib left, right, target end) _llint_op_jbeloweq: traceExecution() compareUnsignedJump( macro (left, right, target) bibeq left, right, target end) _llint_op_loop_hint: traceExecution() checkSwitchToJITForLoop() dispatch(constexpr op_loop_hint_length) _llint_op_check_traps: traceExecution() loadp CodeBlock[cfr], t1 loadp CodeBlock::m_poisonedVM[t1], t1 unpoison(_g_CodeBlockPoison, t1, t2) loadb VM::m_traps+VMTraps::m_needTrapHandling[t1], t0 btpnz t0, .handleTraps .afterHandlingTraps: dispatch(constexpr op_check_traps_length) .handleTraps: callTrapHandler(.throwHandler) jmp .afterHandlingTraps .throwHandler: jmp _llint_throw_from_slow_path_trampoline # Returns the packet pointer in t0. macro acquireShadowChickenPacket(slow) loadp CodeBlock[cfr], t1 loadp CodeBlock::m_poisonedVM[t1], t1 unpoison(_g_CodeBlockPoison, t1, t2) loadp VM::m_shadowChicken[t1], t2 loadp ShadowChicken::m_logCursor[t2], t0 bpaeq t0, ShadowChicken::m_logEnd[t2], slow addp sizeof ShadowChicken::Packet, t0, t1 storep t1, ShadowChicken::m_logCursor[t2] end _llint_op_nop: dispatch(constexpr op_nop_length) _llint_op_super_sampler_begin: callOpcodeSlowPath(_llint_slow_path_super_sampler_begin) dispatch(constexpr op_super_sampler_begin_length) _llint_op_super_sampler_end: traceExecution() callOpcodeSlowPath(_llint_slow_path_super_sampler_end) dispatch(constexpr op_super_sampler_end_length) _llint_op_switch_string: traceExecution() callOpcodeSlowPath(_llint_slow_path_switch_string) dispatch(0) _llint_op_new_func_exp: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_func_exp) dispatch(constexpr op_new_func_exp_length) _llint_op_new_generator_func_exp: traceExecution() callOpcodeSlowPath(_llint_slow_path_new_generator_func_exp) dispatch(constexpr op_new_generator_func_exp_length) _llint_op_new_async_func_exp: traceExecution() callSlowPath(_llint_slow_path_new_async_func_exp) dispatch(constexpr op_new_async_func_exp_length) _llint_op_set_function_name: traceExecution() callOpcodeSlowPath(_llint_slow_path_set_function_name) dispatch(constexpr op_set_function_name_length) _llint_op_call: traceExecution() arrayProfileForCall() doCall(_llint_slow_path_call, prepareForRegularCall) _llint_op_tail_call: traceExecution() arrayProfileForCall() checkSwitchToJITForEpilogue() doCall(_llint_slow_path_call, prepareForTailCall) _llint_op_construct: traceExecution() doCall(_llint_slow_path_construct, prepareForRegularCall) macro doCallVarargs(frameSlowPath, slowPath, prepareCall) callOpcodeSlowPath(frameSlowPath) branchIfException(_llint_throw_from_slow_path_trampoline) # calleeFrame in r1 if JSVALUE64 move r1, sp else # The calleeFrame is not stack aligned, move down by CallerFrameAndPCSize to align if ARMv7 subp r1, CallerFrameAndPCSize, t2 move t2, sp else subp r1, CallerFrameAndPCSize, sp end end slowPathForCall(slowPath, prepareCall) end _llint_op_call_varargs: traceExecution() doCallVarargs(_llint_slow_path_size_frame_for_varargs, _llint_slow_path_call_varargs, prepareForRegularCall) _llint_op_tail_call_varargs: traceExecution() checkSwitchToJITForEpilogue() # We lie and perform the tail call instead of preparing it since we can't # prepare the frame for a call opcode doCallVarargs(_llint_slow_path_size_frame_for_varargs, _llint_slow_path_call_varargs, prepareForTailCall) _llint_op_tail_call_forward_arguments: traceExecution() checkSwitchToJITForEpilogue() # We lie and perform the tail call instead of preparing it since we can't # prepare the frame for a call opcode doCallVarargs(_llint_slow_path_size_frame_for_forward_arguments, _llint_slow_path_tail_call_forward_arguments, prepareForTailCall) _llint_op_construct_varargs: traceExecution() doCallVarargs(_llint_slow_path_size_frame_for_varargs, _llint_slow_path_construct_varargs, prepareForRegularCall) _llint_op_call_eval: traceExecution() # Eval is executed in one of two modes: # # 1) We find that we're really invoking eval() in which case the # execution is perfomed entirely inside the slow_path, and it # returns the PC of a function that just returns the return value # that the eval returned. # # 2) We find that we're invoking something called eval() that is not # the real eval. Then the slow_path returns the PC of the thing to # call, and we call it. # # This allows us to handle two cases, which would require a total of # up to four pieces of state that cannot be easily packed into two # registers (C functions can return up to two registers, easily): # # - The call frame register. This may or may not have been modified # by the slow_path, but the convention is that it returns it. It's not # totally clear if that's necessary, since the cfr is callee save. # But that's our style in this here interpreter so we stick with it. # # - A bit to say if the slow_path successfully executed the eval and has # the return value, or did not execute the eval but has a PC for us # to call. # # - Either: # - The JS return value (two registers), or # # - The PC to call. # # It turns out to be easier to just always have this return the cfr # and a PC to call, and that PC may be a dummy thunk that just # returns the JS value that the eval returned. slowPathForCall(_llint_slow_path_call_eval, prepareForRegularCall) _llint_generic_return_point: dispatchAfterCall() _llint_op_strcat: traceExecution() callOpcodeSlowPath(_slow_path_strcat) dispatch(constexpr op_strcat_length) _llint_op_push_with_scope: traceExecution() callOpcodeSlowPath(_slow_path_push_with_scope) dispatch(constexpr op_push_with_scope_length) _llint_op_identity_with_profile: traceExecution() dispatch(constexpr op_identity_with_profile_length) _llint_op_unreachable: traceExecution() callOpcodeSlowPath(_slow_path_unreachable) dispatch(constexpr op_unreachable_length) _llint_op_yield: notSupported() _llint_op_create_lexical_environment: traceExecution() callOpcodeSlowPath(_slow_path_create_lexical_environment) dispatch(constexpr op_create_lexical_environment_length) _llint_op_throw: traceExecution() callOpcodeSlowPath(_llint_slow_path_throw) dispatch(constexpr op_throw_length) _llint_op_throw_static_error: traceExecution() callOpcodeSlowPath(_slow_path_throw_static_error) dispatch(constexpr op_throw_static_error_length) _llint_op_debug: traceExecution() loadp CodeBlock[cfr], t0 loadi CodeBlock::m_debuggerRequests[t0], t0 btiz t0, .opDebugDone callOpcodeSlowPath(_llint_slow_path_debug) .opDebugDone: dispatch(constexpr op_debug_length) _llint_native_call_trampoline: nativeCallTrampoline(NativeExecutable::m_function) _llint_native_construct_trampoline: nativeCallTrampoline(NativeExecutable::m_constructor) _llint_internal_function_call_trampoline: internalFunctionCallTrampoline(InternalFunction::m_functionForCall) _llint_internal_function_construct_trampoline: internalFunctionCallTrampoline(InternalFunction::m_functionForConstruct) _llint_op_get_enumerable_length: traceExecution() callOpcodeSlowPath(_slow_path_get_enumerable_length) dispatch(constexpr op_get_enumerable_length_length) _llint_op_has_indexed_property: traceExecution() callOpcodeSlowPath(_slow_path_has_indexed_property) dispatch(constexpr op_has_indexed_property_length) _llint_op_has_structure_property: traceExecution() callOpcodeSlowPath(_slow_path_has_structure_property) dispatch(constexpr op_has_structure_property_length) _llint_op_has_generic_property: traceExecution() callOpcodeSlowPath(_slow_path_has_generic_property) dispatch(constexpr op_has_generic_property_length) _llint_op_get_direct_pname: traceExecution() callOpcodeSlowPath(_slow_path_get_direct_pname) dispatch(constexpr op_get_direct_pname_length) _llint_op_get_property_enumerator: traceExecution() callOpcodeSlowPath(_slow_path_get_property_enumerator) dispatch(constexpr op_get_property_enumerator_length) _llint_op_enumerator_structure_pname: traceExecution() callOpcodeSlowPath(_slow_path_next_structure_enumerator_pname) dispatch(constexpr op_enumerator_structure_pname_length) _llint_op_enumerator_generic_pname: traceExecution() callOpcodeSlowPath(_slow_path_next_generic_enumerator_pname) dispatch(constexpr op_enumerator_generic_pname_length) _llint_op_to_index_string: traceExecution() callOpcodeSlowPath(_slow_path_to_index_string) dispatch(constexpr op_to_index_string_length) _llint_op_create_rest: traceExecution() callOpcodeSlowPath(_slow_path_create_rest) dispatch(constexpr op_create_rest_length) _llint_op_instanceof: traceExecution() callOpcodeSlowPath(_llint_slow_path_instanceof) dispatch(constexpr op_instanceof_length) _llint_op_get_by_id_with_this: traceExecution() callOpcodeSlowPath(_slow_path_get_by_id_with_this) dispatch(constexpr op_get_by_id_with_this_length) _llint_op_get_by_val_with_this: traceExecution() callOpcodeSlowPath(_slow_path_get_by_val_with_this) dispatch(constexpr op_get_by_val_with_this_length) _llint_op_put_by_id_with_this: traceExecution() callOpcodeSlowPath(_slow_path_put_by_id_with_this) dispatch(constexpr op_put_by_id_with_this_length) _llint_op_put_by_val_with_this: traceExecution() callOpcodeSlowPath(_slow_path_put_by_val_with_this) dispatch(constexpr op_put_by_val_with_this_length) _llint_op_resolve_scope_for_hoisting_func_decl_in_eval: traceExecution() callOpcodeSlowPath(_slow_path_resolve_scope_for_hoisting_func_decl_in_eval) dispatch(constexpr op_resolve_scope_for_hoisting_func_decl_in_eval_length) # Lastly, make sure that we can link even though we don't support all opcodes. # These opcodes should never arise when using LLInt or either JIT. We assert # as much. macro notSupported() if ASSERT_ENABLED crash() else # We should use whatever the smallest possible instruction is, just to # ensure that there is a gap between instruction labels. If multiple # smallest instructions exist, we should pick the one that is most # likely result in execution being halted. Currently that is the break # instruction on all architectures we're interested in. (Break is int3 # on Intel, which is 1 byte, and bkpt on ARMv7, which is 2 bytes.) break end end ",16336,False,2423.459520403247,median ";this file for FamiTone2 library generated by FamiStudio silver_surfer_c_stephen_ruddy_music_data: db 1 dw @instruments dw @samples-3 dw @song0ch0,@song0ch1,@song0ch2,@song0ch3,@song0ch4 db <(@tempo_env6), >(@tempo_env6), 0, 0 @instruments: dw @env59,@env38,@env34,@env31 dw @env50,@env43,@env34,@env31 dw @env39,@env38,@env34,@env31 dw @env44,@env38,@env34,@env31 dw @env20,@env47,@env34,@env31 dw @env13,@env41,@env34,@env31 dw @env36,@env42,@env34,@env31 dw @env30,@env38,@env34,@env31 dw @env11,@env40,@env34,@env31 dw @env14,@env32,@env37,@env31 dw @env14,@env1,@env15,@env31 dw @env14,@env1,@env34,@env31 dw @env14,@env1,@env35,@env31 dw @env14,@env1,@env6,@env31 dw @env54,@env26,@env34,@env10 dw @env54,@env25,@env6,@env49 dw @env52,@env25,@env6,@env49 dw @env17,@env1,@env35,@env61 dw @env5,@env1,@env34,@env31 dw @env29,@env1,@env35,@env28 dw @env55,@env12,@env6,@env31 dw @env58,@env1,@env37,@env31 dw @env14,@env4,@env34,@env31 dw @env8,@env1,@env35,@env31 dw @env7,@env1,@env34,@env23 dw @env7,@env19,@env34,@env31 dw @env7,@env1,@env37,@env23 dw @env7,@env1,@env35,@env23 dw @env55,@env1,@env34,@env31 dw @env53,@env1,@env35,@env51 dw @env46,@env1,@env6,@env3 dw @env56,@env27,@env34,@env31 dw @env60,@env57,@env34,@env31 @samples: @env0: db $c0,$cc,$c3,$cf,$c7,$d3,$cc,$d8,$c7,$cc,$cf,$d3,$00,$00 @env1: db $c0,$7f,$00,$00 @env2: db $c0,$02,$c4,$02,$c9,$02,$c4,$c4,$c4,$00,$00 @env3: db $00,$c0,$08,$c0,$bf,$be,$bd,$be,$bf,$c0,$c1,$c2,$c3,$c2,$c1,$00,$03 @env4: db $c0,$03,$b4,$00,$02 @env5: db $04,$c5,$00,$01,$c4,$03,$c3,$03,$c2,$00,$08 @env6: db $c3,$7f,$00,$00 @env7: db $00,$c2,$c4,$c5,$c6,$c4,$00,$05 @env8: db $00,$c1,$c2,$c3,$c4,$00,$04 @env9: db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c7,$c7,$d3,$d3,$00,$00 @env10: db $00,$c0,$c0,$c1,$00,$03 @env11: db $00,$c7,$c5,$c5,$c4,$c4,$c3,$c3,$c2,$c2,$c1,$c1,$c0,$00,$0c @env12: db $c0,$c0,$cc,$00,$02 @env13: db $00,$c5,$c4,$03,$c3,$04,$c2,$00,$06 @env14: db $04,$cf,$7f,$00,$01 @env15: db $c0,$c0,$c1,$c1,$c0,$c0,$00,$00 @env16: db $c0,$02,$c5,$02,$c8,$02,$c5,$c5,$c5,$00,$00 @env17: db $00,$c8,$c7,$c6,$c5,$c4,$c3,$c2,$c1,$03,$c2,$c4,$c3,$c2,$c1,$c1,$c2,$c4,$c3,$c2,$c1,$c1,$c2,$c6,$c5,$c4,$c3,$c2,$c1,$c4,$c3,$c2,$c1,$02,$c3,$c2,$c1,$02,$c2,$c4,$c3,$c2,$c1,$c1,$c4,$00,$01 @env18: db $c0,$cc,$c4,$d0,$c7,$d3,$cc,$d8,$c7,$cc,$cf,$d3,$00,$00 @env19: db $c0,$c0,$b4,$b4,$c0,$c0,$00,$00 @env20: db $0b,$c7,$c3,$10,$c2,$05,$c1,$05,$c0,$00,$08,$c1,$c2,$00,$0c @env21: db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c7,$c7,$d3,$d3,$cb,$cb,$d7,$d7,$00,$00 @env22: db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c6,$c6,$d2,$d2,$c9,$c9,$d5,$d5,$00,$00 @env23: db $00,$c0,$09,$c0,$be,$bc,$be,$c0,$c2,$c4,$c2,$00,$03 @env24: db $c0,$02,$c4,$02,$c7,$02,$c4,$c4,$c4,$00,$00 @env25: db $c0,$d3,$c0,$00,$02 @env26: db $c0,$cc,$c0,$00,$02 @env27: db $c0,$be,$ba,$b6,$b4,$b2,$00,$05 @env28: db $00,$b5,$c4,$d3,$e2,$f1,$ff,$00,$01 @env29: db $04,$c3,$7f,$00,$01 @env30: db $00,$c4,$03,$c3,$03,$c2,$00,$05 @env31: db $00,$c0,$7f,$00,$01 @env32: db $c0,$bf,$be,$bd,$bc,$bb,$ba,$b9,$b8,$b7,$b6,$b5,$00,$00 @env33: db $c0,$02,$c5,$02,$c9,$02,$c5,$c5,$c5,$00,$00 @env34: db $7f,$00,$00 @env35: db $c2,$7f,$00,$00 @env36: db $00,$c5,$c4,$02,$c3,$03,$c2,$04,$c1,$00,$08 @env37: db $c1,$7f,$00,$00 @env38: db $c0,$c2,$00,$01 @env39: db $00,$c3,$c3,$c2,$c1,$c0,$00,$05 @env40: db $c0,$c3,$00,$01 @env41: db $c0,$c6,$00,$01 @env42: db $c0,$c4,$00,$01 @env43: db $c0,$c5,$00,$01 @env44: db $00,$c4,$02,$c3,$02,$c2,$02,$c1,$00,$07 @env45: db $c0,$c0,$cc,$cc,$c4,$c4,$cf,$cf,$c7,$c7,$d3,$d3,$cc,$cc,$d8,$d8,$c7,$c7,$cc,$cc,$cf,$cf,$d3,$d3,$00,$00 @env46: db $04,$c5,$00,$01,$c3,$c1,$00,$05 @env47: db $c0,$c4,$02,$c5,$03,$c6,$04,$c7,$00,$07 @env48: db $c0,$02,$c5,$02,$c7,$02,$c5,$c5,$c5,$00,$00 @env49: db $00,$c0,$c1,$00,$02 @env50: db $00,$c5,$c3,$c2,$c1,$c0,$00,$05 @env51: db $00,$c0,$03,$c0,$bf,$be,$bd,$be,$bf,$c0,$c1,$c2,$c3,$c2,$c1,$00,$03 @env52: db $00,$c4,$c3,$c4,$c4,$c2,$c1,$00,$06 @env53: db $04,$c4,$00,$01,$c2,$c1,$00,$05 @env54: db $04,$c4,$7f,$00,$01 @env55: db $00,$c5,$c5,$c4,$c4,$00,$01 @env56: db $00,$cf,$05,$c0,$00,$03 @env57: db $c0,$bf,$00,$01 @env58: db $00,$c5,$c5,$c4,$02,$c3,$00,$05 @env59: db $00,$c5,$c4,$c4,$c3,$02,$c2,$02,$c1,$00,$08 @env60: db $00,$cf,$cf,$c0,$00,$03 @env61: db $00,$bf,$c0,$00,$02 @env62: db $00,$c0,$bf,$be,$02,$bf,$c1,$c2,$02,$c1,$00,$01 @tempo_env6: db $01,$05,$80 @song0ch0: @ref0: db $72,$96,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89 @ref1: db $33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89 @song0ch0loop: @ref2: db $66,$fb,<(@tempo_env6),>(@tempo_env6),$7f,$64,<(@env18),>(@env18),$a4,$25,$c5,$64,<(@env0),>(@env0),$62,$27,$b1,$f9,$91,$64,<(@env18),>(@env18),$2a,$ad @ref3: db $62,$2c,$f7,$b1,$f9,$91 @ref4: db $67,$25,$c5,$64,<(@env0),>(@env0),$62,$27,$b1,$f9,$91,$64,<(@env18),>(@env18),$2a,$ad db $ff,$05 dw @ref3 db $ff,$08 dw @ref4 db $ff,$05 dw @ref3 @ref5: db $67,$2c,$95 @ref6: db $74,$64,<(@env45),>(@env45),$96,$28,$f7,$c5 @ref7: db $64,<(@env22),>(@env22),$28,$f7,$c5 @ref8: db $7f,$64,<(@env1),>(@env1),$66,$9c,$24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1b,$91,$00,$81,$1a,$91,$00,$81,$1b,$91,$00,$81 @ref9: db $24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1f,$91,$00,$81,$22,$91,$00,$81,$24,$91,$00,$81 @ref10: db $24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1b,$91,$00,$81,$1a,$91,$00,$81,$1b,$91,$00,$81 db $ff,$2c dw @ref9 db $ff,$2c dw @ref10 db $ff,$2c dw @ref9 db $ff,$2c dw @ref10 db $ff,$2c dw @ref9 db $ff,$2c dw @ref10 db $ff,$2c dw @ref9 db $ff,$2c dw @ref10 db $ff,$2c dw @ref9 db $ff,$2c dw @ref10 db $ff,$2c dw @ref9 @ref11: db $64,<(@env16),>(@env16),$aa,$2b,$dd,$64,<(@env2),>(@env2),$2c,$dd @ref12: db $64,<(@env33),>(@env33),$29,$dd,$64,<(@env48),>(@env48),$2b,$ad,$64,<(@env24),>(@env24),$2b,$ad @ref13: db $64,<(@env16),>(@env16),$62,$2b,$dd,$64,<(@env2),>(@env2),$2c,$dd db $ff,$06 dw @ref12 db $ff,$04 dw @ref13 db $ff,$06 dw @ref12 db $ff,$04 dw @ref13 db $ff,$06 dw @ref12 @ref14: db $73,$64,<(@env1),>(@env1),$66,$98,$30,$ad,$62,$61,$fd,$30,$48,$f7,$95 @ref15: db $f7,$c7 @ref16: db $7f,$a2,$57,$dd,$57,$dd @ref17: db $57,$dd,$57,$dd @ref18: db $57,$dd,$57,$dd @ref19: db $57,$dd,$57,$dd @ref20: db $9e,$23,$95,$17,$95,$23,$95,$17,$95,$23,$95,$17,$95,$23,$95,$17,$95 @ref21: db $21,$95,$a0,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89 db $ff,$10 dw @ref20 db $ff,$1e dw @ref21 db $ff,$10 dw @ref20 db $ff,$1e dw @ref21 db $ff,$10 dw @ref20 db $ff,$1e dw @ref21 @ref22: db $64,<(@env9),>(@env9),$b8,$24,$f7,$c5 @ref23: db $64,<(@env21),>(@env21),$22,$f7,$c5 @ref24: db $64,<(@env9),>(@env9),$24,$f7,$c5 db $ff,$03 dw @ref23 @ref25: db $64,<(@env9),>(@env9),$21,$f7,$c5 @ref26: db $64,<(@env21),>(@env21),$1f,$f7,$c5 db $ff,$03 dw @ref25 db $ff,$03 dw @ref26 @ref27: db $64,<(@env1),>(@env1),$66,$a8,$17,$85,$19,$85,$1b,$85,$1e,$85,$23,$85,$25,$85,$27,$85,$2a,$85,$2f,$85,$31,$85,$33,$85,$36,$85,$33,$85,$31,$85,$2f,$85,$2a,$85,$27,$85,$25,$85,$23,$85,$1e,$85,$1b,$85,$19,$85,$17,$85,$12,$85 @ref28: db $19,$85,$1b,$85,$1d,$85,$20,$85,$25,$85,$27,$85,$29,$85,$2c,$85,$31,$85,$33,$85,$35,$85,$38,$85,$35,$85,$33,$85,$31,$85,$2c,$85,$29,$85,$27,$85,$25,$85,$20,$85,$1d,$85,$1b,$85,$19,$85,$14,$85 @ref29: db $17,$85,$19,$85,$1b,$85,$1e,$85,$23,$85,$25,$85,$27,$85,$2a,$85,$2f,$85,$31,$85,$33,$85,$36,$85,$33,$85,$31,$85,$2f,$85,$2a,$85,$27,$85,$25,$85,$23,$85,$1e,$85,$1b,$85,$19,$85,$17,$85,$12,$85 db $ff,$30 dw @ref28 db $ff,$30 dw @ref29 db $ff,$30 dw @ref29 @ref30: db $17,$85,$1b,$85,$1d,$85,$20,$85,$23,$85,$27,$85,$29,$85,$2c,$85,$2f,$85,$33,$85,$35,$85,$38,$85,$35,$85,$33,$85,$2f,$85,$2c,$85,$29,$85,$27,$85,$23,$85,$20,$85,$1d,$85,$1b,$85,$17,$85,$14,$85 db $ff,$30 dw @ref30 db $ff,$20 dw @ref0 db $ff,$1c dw @ref1 db $fd dw @song0ch0loop @song0ch1: @ref31: db $7f,$a6,$61,$fe,$2f,$44,$f7,$c5 @ref32: db $f7,$af @song0ch1loop: @ref33: db $74,$98,$30,$31,$9b,$61,$0f,$31,$2c,$91,$72,$61,$0f,$31,$2c,$91,$74,$32,$33,$9b,$61,$13,$33,$2c,$91,$72,$61,$13,$33,$2c,$91,$74,$34,$35,$36,$89,$63,<(@env62),>(@env62),$9d,$63,<(@env31),>(@env31),$65,$81 @ref34: db $37,$38,$8d,$63,<(@env62),>(@env62),$f7,$8b,$63,<(@env31),>(@env31),$65,$81,$61,$0c,$38,$32,$91,$72,$61,$0c,$38,$32,$91 @ref35: db $74,$9a,$3c,$3d,$9b,$61,$0f,$3d,$34,$91,$72,$61,$0f,$3d,$34,$91,$74,$3e,$3f,$9b,$61,$16,$3f,$32,$91,$72,$61,$16,$3f,$32,$91,$74,$40,$41,$42,$89,$63,<(@env62),>(@env62),$9d,$63,<(@env31),>(@env31),$65,$81 @ref36: db $43,$44,$8d,$63,<(@env62),>(@env62),$f7,$8b,$63,<(@env31),>(@env31),$65,$81,$61,$0d,$44,$39,$91,$72,$61,$0d,$44,$39,$91 @ref37: db $74,$98,$43,$44,$9b,$61,$0f,$44,$38,$91,$72,$61,$0f,$44,$38,$91,$74,$45,$46,$9b,$61,$14,$46,$36,$91,$72,$61,$14,$46,$36,$91,$74,$47,$48,$49,$87,$63,<(@env62),>(@env62),$9f,$63,<(@env31),>(@env31),$65,$81 @ref38: db $4a,$4b,$8d,$63,<(@env62),>(@env62),$f7,$8b,$63,<(@env31),>(@env31),$65,$81,$61,$0c,$4b,$3d,$91,$72,$61,$0c,$4b,$3d,$91 @ref39: db $00,$95 @ref40: db $74,$46,$47,$97,$63,<(@env62),>(@env62),$f7,$81,$63,<(@env31),>(@env31),$65,$81,$61,$0c,$47,$3b,$91,$72,$61,$0c,$47,$3b,$91 @ref41: db $74,$48,$49,$8d,$63,<(@env62),>(@env62),$f7,$89,$63,<(@env31),>(@env31),$65,$81,$61,$0b,$49,$3c,$93,$72,$61,$0c,$49,$3c,$91 @ref42: db $7f,$ae,$2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 @ref43: db $2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 @ref44: db $7f,$2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 db $ff,$40 dw @ref43 @ref45: db $70,$00,$95,$ac,$30,$83,$71,$85,$35,$89,$37,$89,$32,$72,$89,$33,$89,$35,$87,$73,$81,$2e,$89,$33,$89,$30,$83,$74,$85,$35,$89,$37,$89,$32,$75,$89,$33,$89,$35,$87,$76,$81 @ref46: db $70,$00,$95,$3c,$83,$71,$85,$41,$89,$43,$89,$3e,$72,$89,$3f,$89,$41,$87,$73,$81,$3a,$89,$3f,$89,$3c,$83,$74,$85,$41,$89,$43,$89,$3e,$75,$89,$3f,$89,$41,$87,$76,$81 @ref47: db $7f,$b0,$3e,$89,$3e,$89,$3e,$89,$3e,$9d,$00,$81,$3e,$89,$3f,$89,$41,$91,$00,$81,$3e,$89,$3f,$91,$00,$81,$3c,$89,$3e,$91,$00,$81 @ref48: db $3a,$89,$3a,$89,$3a,$89,$3c,$89,$37,$89,$3c,$89,$3e,$89,$3f,$89,$43,$a9,$00,$81,$41,$a9,$00,$81 @ref49: db $b2,$3e,$89,$3e,$89,$3e,$89,$3e,$9d,$00,$81,$3e,$89,$3f,$89,$41,$91,$00,$81,$3e,$89,$3f,$91,$00,$81,$3c,$89,$3e,$91,$00,$81 db $ff,$18 dw @ref48 @ref50: db $b6,$43,$c1,$00,$81,$41,$89,$3f,$89,$3e,$c1,$00,$81,$3f,$89,$41,$89 @ref51: db $3e,$c1,$00,$81,$3f,$89,$41,$89,$3c,$62,$3d,$81,$3e,$8b,$00,$81,$3d,$62,$3c,$62,$3b,$8d,$00,$81,$3a,$62,$39,$62,$38,$62,$37,$8b,$00,$81,$38,$62,$39,$62,$3a,$62,$3b,$62,$3c,$62,$3d,$62,$3e,$85,$00,$81 @ref52: db $3f,$c1,$00,$81,$3e,$89,$3c,$89,$3e,$c1,$00,$81,$3c,$89,$37,$89 @ref53: db $3a,$d9,$00,$81,$3c,$a9,$00,$81,$3e,$a9,$00,$81 @ref54: db $b4,$2b,$c1,$00,$81,$29,$89,$27,$89,$26,$c1,$00,$81,$27,$89,$29,$89 @ref55: db $26,$c1,$00,$81,$27,$89,$29,$89,$24,$62,$25,$81,$26,$8b,$00,$81,$25,$62,$24,$62,$23,$8d,$00,$81,$22,$62,$21,$62,$20,$62,$1f,$8b,$00,$81,$20,$62,$21,$62,$22,$62,$23,$62,$24,$62,$25,$62,$26,$85,$00,$81 @ref56: db $27,$c1,$00,$81,$26,$89,$24,$89,$26,$c1,$00,$81,$24,$89,$1f,$89 @ref57: db $22,$d9,$00,$81,$24,$a9,$00,$81,$26,$a9,$00,$81 @ref58: db $b0,$37,$c1,$00,$81,$35,$89,$33,$89,$32,$c1,$00,$81,$33,$89,$35,$89 @ref59: db $32,$c1,$00,$81,$33,$89,$35,$89,$30,$62,$31,$81,$32,$8b,$00,$81,$31,$62,$30,$62,$2f,$8d,$00,$81,$2e,$62,$2d,$62,$2c,$62,$2b,$8b,$00,$81,$2c,$62,$2d,$62,$2e,$62,$2f,$62,$30,$62,$31,$62,$32,$85,$00,$81 @ref60: db $33,$c1,$00,$81,$32,$89,$30,$89,$32,$c1,$00,$81,$30,$89,$2b,$89 @ref61: db $2e,$d9,$00,$81,$30,$a9,$00,$81,$32,$a9,$00,$81 @ref62: db $73,$68,$00,$98,$37,$dd,$62,$61,$fe,$37,$60,$dd @ref63: db $f7,$c5,$00 @ref64: db $7f,$a2,$60,$dd,$60,$dd @ref65: db $60,$dd,$60,$dd @ref66: db $60,$f7,$c5 @ref67: db $60,$dd,$60,$dd @ref68: db $9e,$28,$95,$1c,$95,$28,$95,$1c,$95,$28,$95,$1c,$95,$28,$95,$1c,$95 @ref69: db $26,$95,$a0,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89 db $ff,$10 dw @ref68 db $ff,$1e dw @ref69 @ref70: db $9e,$2a,$95,$1e,$95,$2a,$95,$1e,$95,$2a,$95,$1e,$95,$2a,$95,$1e,$95 @ref71: db $28,$95,$a0,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89 db $ff,$10 dw @ref70 db $ff,$1e dw @ref71 @ref72: db $bc,$30,$89,$2d,$2b,$81,$f9,$81,$00,$2e,$30,$81,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$89,$34,$31,$30,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$83,$f9,$81,$00,$3a,$3c,$87,$39,$37,$81,$f9,$81,$00,$34,$83,$f9,$81,$00,$35,$89,$32,$83,$f9,$81,$00,$34,$83,$f9,$81,$00,$31,$30,$87,$2d,$2b,$81,$f9,$81,$00 @ref73: db $2e,$95,$31,$32,$81,$f9,$81,$00,$30,$a1,$32,$a1,$34,$a1,$35,$95,$38,$39,$8d,$f9,$81,$00 @ref74: db $36,$33,$62,$30,$f9,$81,$00,$2d,$2b,$81,$f9,$81,$00,$2e,$30,$81,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$89,$34,$31,$30,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$83,$f9,$81,$00,$3a,$3c,$87,$39,$37,$81,$f9,$81,$00,$34,$83,$f9,$81,$00,$35,$89,$32,$83,$f9,$81,$00,$34,$83,$f9,$81,$00,$31,$30,$87,$2d,$2b,$81,$f9,$81,$00 db $ff,$16 dw @ref73 @ref75: db $74,$98,$39,$36,$33,$31,$97,$61,$0f,$31,$2c,$91,$72,$61,$0f,$31,$2c,$91,$74,$31,$32,$9b,$61,$0e,$32,$2d,$91,$72,$61,$0e,$32,$2d,$91,$74,$32,$34,$9b,$61,$0f,$34,$2e,$8d @ref76: db $83,$72,$61,$0f,$34,$2e,$91,$74,$34,$36,$9b,$61,$0e,$36,$30,$91,$72,$61,$0e,$36,$30,$91,$74,$36,$37,$9b,$61,$10,$37,$31,$8d,$37,$39,$9b,$61,$0e,$39,$33,$8d @ref77: db $7f,$ba,$38,$95,$36,$34,$8d,$f9,$81,$00,$32,$31,$8d,$f9,$81,$00,$33,$35,$36,$91,$34,$95,$32,$31,$8d,$f9,$81,$00,$2f,$2d,$8d,$f9,$81,$00,$2f,$31,$8d,$f9,$81,$00 @ref78: db $32,$95,$30,$2f,$93,$2d,$2b,$8d,$f9,$81,$00,$2d,$2f,$31,$33,$34,$8d,$32,$31,$93,$2f,$2d,$8d,$f9,$81,$00,$2f,$31,$33,$35,$36,$89,$f9,$81,$34,$32,$8f,$f9,$81 @ref79: db $34,$36,$d7,$f9,$81,$38,$3a,$3b,$d5,$f9,$81 @ref80: db $3d,$a9,$f9,$81,$3b,$39,$38,$a5,$f9,$81,$36,$a9,$f9,$81,$35,$a9,$f9,$81 @ref81: db $36,$a9,$f9,$81,$34,$33,$a7,$f9,$81,$35,$37,$39,$3b,$a3,$f9,$81,$3d,$3f,$a7,$f9,$62,$3e @ref82: db $3d,$d9,$f9,$81,$3f,$41,$d7,$f9,$81 @ref83: db $74,$98,$36,$9d,$61,$0e,$36,$30,$91,$72,$61,$0e,$36,$30,$91,$74,$35,$9d,$61,$0e,$35,$2f,$91,$72,$61,$0e,$35,$2f,$91,$74,$31,$9d,$61,$0e,$31,$2d,$8d @ref84: db $33,$dd,$35,$ad,$36,$ad @ref85: db $38,$dd,$3a,$3c,$3e,$40,$41,$d5 @ref86: db $81,$43,$44,$87,$42,$41,$87,$3f,$89,$3d,$3b,$87,$3a,$89,$38,$89,$36,$35,$87,$33,$89,$31,$2f,$87,$2e,$89,$2c,$89,$2a,$29,$87,$27,$89,$25,$23,$87,$22,$89,$20,$87 db $ff,$03 dw @ref31 @ref87: db $f7,$af db $fd dw @song0ch1loop @song0ch2: @ref88: db $f7,$c7 @ref89: db $f7,$c0,$2e,$89,$2e,$89,$2e,$95 @song0ch2loop: @ref90: db $be,$25,$89,$96,$19,$b9,$be,$25,$89,$96,$1b,$89,$00,$ad,$be,$25,$89,$96,$1e,$a1 @ref91: db $be,$25,$89,$96,$20,$89,$1e,$89,$20,$89,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$20,$a9,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$20,$85,$c0,$2e,$81,$96,$20,$85,$c0,$2e,$81,$96,$20,$91 db $ff,$0e dw @ref90 db $ff,$20 dw @ref91 db $ff,$0e dw @ref90 db $ff,$20 dw @ref91 @ref92: db $be,$25,$89,$96,$20,$89 @ref93: db $be,$25,$89,$96,$1c,$89,$1a,$1b,$1c,$91,$c0,$2f,$81,$96,$23,$91,$1a,$1b,$1c,$91,$be,$25,$89,$96,$1c,$89,$1b,$1c,$87,$be,$25,$89,$96,$1c,$89,$1b,$1c,$87,$be,$25,$89,$96,$1b,$89 @ref94: db $be,$25,$89,$96,$19,$89,$17,$18,$19,$91,$c0,$2c,$81,$96,$20,$91,$17,$18,$19,$91,$be,$25,$89,$96,$19,$89,$18,$19,$87,$be,$25,$89,$96,$19,$89,$18,$19,$87,$be,$25,$89,$96,$1b,$89 @ref95: db $be,$25,$89,$96,$18,$85,$00,$81,$18,$91,$00,$81,$c0,$2e,$81,$96,$24,$85,$18,$85,$00,$81,$18,$89,$be,$25,$89,$96,$1d,$91,$00,$81,$be,$25,$89,$96,$1b,$89,$c0,$2e,$81,$96,$1a,$91,$1b,$89,$c0,$2e,$81,$96,$1b,$85 @ref96: db $be,$25,$89,$96,$18,$85,$00,$81,$18,$91,$00,$81,$c0,$2e,$81,$96,$24,$85,$18,$85,$00,$81,$18,$89,$be,$25,$89,$96,$1d,$91,$00,$81,$be,$25,$89,$96,$1b,$89,$c0,$2e,$81,$96,$22,$85,$c0,$2e,$81,$96,$22,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 db $ff,$28 dw @ref95 db $ff,$2e dw @ref96 @ref97: db $be,$25,$f7,$c5 @ref98: db $f7,$c7 @ref99: db $25,$89,$00,$a1,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$a1,$2e,$89 @ref100: db $be,$25,$ad,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$89,$2e,$89,$2e,$89,$2e,$89 @ref101: db $be,$25,$ad,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$a1,$2e,$89 db $ff,$10 dw @ref100 db $ff,$0c dw @ref101 db $ff,$10 dw @ref100 db $ff,$0c dw @ref101 db $ff,$10 dw @ref100 db $ff,$0c dw @ref101 db $ff,$10 dw @ref100 @ref102: db $be,$25,$89,$96,$18,$a1,$c0,$2e,$81,$96,$18,$9d,$be,$25,$89,$96,$18,$95,$be,$25,$89,$96,$18,$89,$c0,$2e,$81,$96,$22,$85,$24,$89,$1f,$89,$c0,$2e,$81,$96,$1f,$85 @ref103: db $be,$25,$89,$96,$18,$a1,$c0,$2e,$81,$96,$18,$9d,$be,$25,$89,$96,$18,$95,$be,$25,$89,$96,$18,$89,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85 db $ff,$1c dw @ref102 db $ff,$20 dw @ref103 @ref104: db $be,$25,$89,$96,$15,$a1,$c0,$2e,$81,$96,$15,$9d,$be,$25,$89,$96,$15,$95,$be,$25,$89,$96,$15,$89,$c0,$2e,$81,$96,$1f,$85,$21,$89,$1c,$89,$c0,$2e,$81,$96,$1c,$85 @ref105: db $be,$25,$89,$96,$15,$a1,$c0,$2e,$81,$96,$15,$9d,$be,$25,$89,$96,$15,$95,$be,$25,$89,$96,$15,$89,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85 db $ff,$1c dw @ref104 db $ff,$20 dw @ref105 @ref106: db $be,$25,$89,$96,$1e,$a1,$c0,$2e,$81,$96,$1e,$9d,$be,$25,$89,$96,$1e,$95,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$28,$85,$2a,$89,$25,$89,$c0,$2e,$81,$96,$25,$85 @ref107: db $be,$25,$89,$96,$1e,$a1,$c0,$2e,$81,$96,$1e,$9d,$be,$25,$89,$96,$1e,$95,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85 db $ff,$1c dw @ref106 db $ff,$20 dw @ref107 db $ff,$1c dw @ref106 db $ff,$20 dw @ref107 @ref108: db $be,$25,$89,$96,$1d,$a1,$c0,$2e,$81,$96,$1d,$9d,$be,$25,$89,$96,$1d,$95,$be,$25,$89,$96,$1d,$89,$c0,$2e,$81,$96,$27,$85,$29,$89,$24,$89,$c0,$2e,$81,$96,$24,$85 @ref109: db $be,$25,$89,$96,$1d,$a1,$c0,$2e,$81,$96,$1d,$9d,$be,$25,$89,$96,$1d,$95,$be,$25,$89,$96,$1d,$89,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85 @ref110: db $be,$25,$89,$96,$1b,$89,$00,$f7,$ad db $ff,$07 dw @ref89 db $fd dw @song0ch2loop @song0ch3: @ref111: db $73,$92,$2c,$ab,$72,$99,$71,$99,$00,$db @ref112: db $71,$94,$23,$89,$24,$83,$72,$85,$25,$89,$26,$73,$89,$27,$87,$74,$81,$28,$89,$29,$83,$75,$85,$2a,$89,$2b,$89,$2c,$87,$77,$81,$7f,$90,$26,$89,$26,$89,$26,$95 @song0ch3loop: @ref113: db $88,$25,$c1,$f9,$81,$25,$c1,$f9,$81,$25,$a9,$f9,$81 @ref114: db $25,$95,$84,$2b,$89,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$95,$84,$2b,$89,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$89,$26,$89,$26,$95 db $ff,$0c dw @ref113 db $ff,$1a dw @ref114 db $ff,$0c dw @ref113 db $ff,$1a dw @ref114 @ref115: db $8a,$27,$95 @ref116: db $8c,$29,$95,$8e,$2b,$95,$90,$26,$95,$8e,$2b,$95,$8c,$29,$a1,$29,$a1,$29,$95 @ref117: db $29,$95,$8e,$2b,$95,$90,$26,$95,$8e,$2b,$95,$8c,$29,$a1,$29,$a1,$29,$95 @ref118: db $7f,$80,$27,$95,$86,$2b,$95,$90,$26,$95,$86,$2b,$89,$82,$27,$89,$86,$2b,$89,$84,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$95,$84,$2b,$89,$90,$26,$89 @ref119: db $80,$27,$95,$86,$2b,$95,$90,$26,$95,$86,$2b,$89,$82,$27,$89,$86,$2b,$89,$84,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$89,$26,$89,$26,$89,$26,$89 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 @ref120: db $75,$96,$27,$74,$22,$9b,$73,$9f,$72,$9f,$71,$9f,$00,$bd @ref121: db $f7,$8b,$71,$22,$83,$23,$72,$83,$24,$83,$73,$25,$83,$26,$81,$74,$81,$27,$83,$28,$75,$83,$29,$83,$76,$2a,$83,$2b,$81,$77,$81 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$18 dw @ref118 db $ff,$1a dw @ref119 db $ff,$06 dw @ref111 db $ff,$1e dw @ref112 db $fd dw @song0ch3loop @song0ch4: @ref122: db $f7,$c7 @ref123: db $f7,$af @song0ch4loop: @ref124: db $f7,$c7 @ref125: db $f7,$c7 @ref126: db $f7,$c7 @ref127: db $f7,$c7 @ref128: db $f7,$c7 @ref129: db $f7,$c7 @ref130: db $97 @ref131: db $f7,$c7 @ref132: db $f7,$c7 @ref133: db $f7,$c7 @ref134: db $f7,$c7 @ref135: db $f7,$c7 @ref136: db $f7,$c7 @ref137: db $f7,$c7 @ref138: db $f7,$c7 @ref139: db $f7,$c7 @ref140: db $f7,$c7 @ref141: db $f7,$c7 @ref142: db $f7,$c7 @ref143: db $f7,$c7 @ref144: db $f7,$c7 @ref145: db $f7,$c7 @ref146: db $f7,$c7 @ref147: db $f7,$c7 @ref148: db $f7,$c7 @ref149: db $f7,$c7 @ref150: db $f7,$c7 @ref151: db $f7,$c7 @ref152: db $f7,$c7 @ref153: db $f7,$c7 @ref154: db $f7,$c7 @ref155: db $f7,$c7 @ref156: db $f7,$c7 @ref157: db $f7,$c7 @ref158: db $f7,$c7 @ref159: db $f7,$c7 @ref160: db $f7,$c7 @ref161: db $f7,$c7 @ref162: db $f7,$c7 @ref163: db $f7,$c7 @ref164: db $f7,$c7 @ref165: db $f7,$c7 @ref166: db $f7,$c7 @ref167: db $f7,$c7 @ref168: db $f7,$c7 @ref169: db $f7,$c7 @ref170: db $f7,$c7 @ref171: db $f7,$c7 @ref172: db $f7,$c7 @ref173: db $f7,$c7 @ref174: db $f7,$c7 @ref175: db $f7,$c7 @ref176: db $f7,$c7 @ref177: db $f7,$c7 @ref178: db $f7,$c7 @ref179: db $f7,$c7 @ref180: db $f7,$c7 @ref181: db $f7,$c7 @ref182: db $f7,$c7 @ref183: db $f7,$c7 @ref184: db $f7,$c7 @ref185: db $f7,$c7 @ref186: db $f7,$af db $fd dw @song0ch4loop ",16152,True,3979.419654904104,median "#include #include #include //#include ""Elcano_C4_Planner.h"" /* Elcano Module C4: Path Planner. Output to C6: Desired route and speed curves and whether it exits a road or changes lane. Input: RNDF, MDF and initial position files from memory stick. Input from C5: Speed and position of obstacles. Input from C6: Position, orientation, velocity and acceleration. Files: RNDF (Route Network Definition File). Format is defined on http://archive.darpa.mil/grandchallenge/docs/RNDF_MDF_Formats_031407.pdf. This is a digital map of all roads in the area where the vehicle will be operating. The camera will locate road edges or lane markers and the vehicle will follow them. Thus location can be determined primarily from odometry. MDF (Mission Definition File). These are latitudes and longitudes that the vehicle is required to visit. Initial position. Specifies the starting location and orientation. Velocity is zero. If this is a file, it is read by C4 (Path Planner) and passed to C6 (Navigator). If it is user input, it is read by C6 (Navigator). The present C4 module is the only micro-controller that has a file system. USB: All Arduinos contain a USB port that lets them download code from a PC. Since a USB connection is not a network, the Arduinos cannot talk to each other over USB. To enable USB, one of the Arduinos must include a USB server. If there is a USB server, it might be C4, which may have an OS, or C6, which needs to talk to lots of instruments, or C7, which may have a USB link to a camera, or we could have another processor whose sole function is communication. */ /*---------------------------------------------------------------------------------------*/ #define PI ((float) 3.1415925) #ifndef NULL #define NULL 0 #endif #define START -1 #define EMPTY -2 void DataReady(); extern bool DataAvailable; /*---------------------------------------------------------------------------------------*/ // EDIT for route // CONES includes start and stop #define CONES 5 long goal_lat[CONES] = { 47621881, 47621825, 47623144, 47620616, 47621881}; long goal_lon[CONES] = {-122349894, -122352120, -122351987, -122351087, -122349894}; /* mph mm/s 3 1341 5 2235 8 3576 10 4470 15 6706 20 8941 25 11176 30 13411 45 20117 60 26822 */ #define DESIRED_SPEED_mmPs 2235 /*---------------------------------------------------------------------------------------*/ #define MAX_WAYPOINTS 20 /* There are two coordinate systems. MDF and RNDF use latitude and longitude. C3 and C6 assume that the earth is flat at the scale that they deal with */ /* Nodes and Links define the road network. The path for the robot is an array of pointers to Nodes. LATITUDE_ORIGIN and LONGITUDE_ORIGIN define (0,0) on the mm coordinate system. Start is the position of the robot as it begins a new leg of the journey. Destination is the next goal position in mission. Path joins Start and Destination. Finding it is the major task of this Path Planner module. The Distance numbers are initially multipliers giving path roughness. They are replaced by their product with the actual distance. Route is a finer scale list of waypoints from present or recent position. Exit is the route from Path[last]-> location to Destination. */ #define MAP_POINTS 16 struct curve Links[20]; struct junction Nodes[MAP_POINTS] = { -140828, 221434, 3 , 1 , END, END, 1, 1, 1, 1, // 0 -140986, 88800, 0 , 2 , 5 , END, 1, 1, 1, 1, // 1 -144313, -42065, 1 , 6 , END, END, 1, 1, 1, 1, // 2 -78568, 222090, 0 , 4 , END, END, 1, 1, 1, 1, // 3 -38276, 222290, 3 , 5 , END, END, 1, 1, 1, 1, // 4 -39558, 87844, 1 , 4 , 8 , 6 , 1, 1, 1, 1, // 5 -46528, -41631, 2 , 5 , 7 , 9 , 1, 1, 1, 1, // 6 -45764, -135413, 6 , 10, END, END, 1, 1, 1, 1, // 7 51834, 87232, 5 , 9 , 14, END, 1, 1, 1, 1, // 8 53041, -41220, 6 , 8 , 10, 13 , 1, 1, 1, 1, // 9 53438, -133901, 7 , 9 , 11, END, 1, 1, 1, 1, // 10 108750, -134590, 10 , 12 , END, END, 1, 1, 1, 1, // 11 130021, -143108, 11 , END, END, END, 1, 1, 1, 1, // 12 182559, -41031, 9 , END, END, END, 1, 1, 1, 1, // 13 177598, 86098, 8 , 15, END, END, 1, 1, 1, 1, // 14 170313, 69008, 14 , END, END, END, 1, 1, 1, 1 // 15 }; struct AStar { int ParentID; long CostFromStart; long CostToGoal; long TotalCost; } Open[MAP_POINTS]; class waypoint Origin, Start; waypoint Path[MAX_WAYPOINTS]; // course route to goal waypoint FinePath[MAX_WAYPOINTS]; // a low level part of path that smoothes the corners. waypoint mission[CONES]; // aka MDF int waypoints = CONES; /*---------------------------------------------------------------------------------------*/ // Fill in the rest of Nodes void ConstructNetwork(junction *Map, int MapPoints) { double deltaX, deltaY; int jj; for (int i = 0; i < MapPoints; i++) { if( Map[i].east_mm == INVALID) continue; for (int j = 0; j< 4; j++) { jj = Map[i].destination[j]; if (jj == END) continue; deltaX = Map[i].east_mm; deltaX -= Map[jj].east_mm; deltaY = Map[i].north_mm; deltaY -= Map[jj].north_mm; // Distance[] is initially a roughness scale. Map[i].Distance[j] *= sqrt(deltaX*deltaX + deltaY*deltaY); } } } /*---------------------------------------------------------------------------------------*/ // Set up mission structure from cone latitude and longitude list. void GetGoals(waypoint *Waypoint, int Goals) { double deltaX, deltaY, Distance; for (int i = 0; i < CONES; i++) { mission[i].latitude = goal_lat[i]; mission[i].longitude = goal_lon[i]; mission[i].Compute_mm(); /* Serial.print(mission[i].latitude); Serial.print("",""); Serial.print(mission[i].longitude); Serial.print("",""); Serial.print(mission[i].east_mm); Serial.print("",""); Serial.println(mission[i].north_mm); */ mission[i].speed_mmPs = DESIRED_SPEED_mmPs; mission[i].index = 1 | GOAL; mission[i].sigma_mm = 1000; mission[i].time_ms = 0; if (i == 0) { // only needed if CONES == 1 mission[i].Evector_x1000 = 1000; mission[i].Nvector_x1000 = 0; } else { deltaX = mission[i].east_mm - mission[i-1].east_mm; deltaY = mission[i].north_mm - mission[i-1].north_mm; Distance = sqrt(deltaX*deltaX + deltaY*deltaY); mission[i-1].Evector_x1000 = (deltaX * 1000.) / Distance; mission[i-1].Nvector_x1000 = (deltaY * 1000.) / Distance; } if (i == CONES-1) { mission[i].Evector_x1000 = mission[i-1].Evector_x1000; mission[i].Nvector_x1000 = mission[i-1].Nvector_x1000; mission[i].index |= END; } } } /*---------------------------------------------------------------------------------------*/ // Find the distance from (east_mm, north_mm) to a road segment Nodes[i].distance[j] // return distance in mm, and per cent of completion from i to j. // distance is negative if (east_mm, north_mm) lies to the left of the road // when road direction is from i to j // Compare this routine to distance() in C3 Pilot long distance(int i, int *k, // index into Nodes[] long east_mm, long north_mm, int* perCent) // per cent of segment that has been completed { float deltaX, deltaY, dist_mm; int j, jj; long Eunit_x1000, Nunit_x1000; long closest_mm = MAX_DISTANCE; long Road_distance, RoadDX_mm, RoadDY_mm; // int pathCompletion; long pc; *perCent = 0; *k = 0; closest_mm = MAX_DISTANCE; for (j=0; j < 4; j++) { // Don't make computations twice. jj = Nodes[i].destination[j]; if (jj == END || jj < i) continue; // compute road unit vectors from i to j RoadDX_mm = -Nodes[i].east_mm + Nodes[jj].east_mm; int Eunit_x1000 = RoadDX_mm * 1000 / Nodes[i].Distance[j]; RoadDY_mm = -Nodes[i].north_mm + Nodes[jj].north_mm; int Nunit_x1000 = RoadDY_mm * 1000 / Nodes[i].Distance[j]; // if (abs(RoadDX_mm) >= abs(RoadDY_mm)) // { // pathCompletion = 100 * (east_mm - Nodes[i].east_mm) / RoadDX_mm; // } // else // { // pathCompletion = 100 * (north_mm - Nodes[i].north_mm) / RoadDY_mm; // } // normal vector is (Nunit, -Eunit) deltaX = -Nodes[i].east_mm + east_mm ; deltaY = -Nodes[i].north_mm + north_mm; // sign of return value gives which side of road it is on. Road_distance = (-deltaY * Eunit_x1000 + deltaX * Nunit_x1000) / 1000; pc = (deltaX * Eunit_x1000 + deltaY * Nunit_x1000) / (Nodes[i].Distance[j] * 10); /* Serial.print(""(""); Serial.print(east_mm); Serial.print("", ""); Serial.print(north_mm); Serial.print("") ""); Serial.print(""(""); Serial.print(Nodes[i].east_mm); Serial.print("", ""); Serial.print(Nodes[i].north_mm); Serial.print("") ""); Serial.print(""(""); Serial.print(Nodes[jj].east_mm); Serial.print("", ""); Serial.print(Nodes[jj].north_mm); Serial.print("") ""); Serial.print(Nodes[i].Distance[j]); Serial.print(""(""); Serial.print(Eunit_x1000); Serial.print("", ""); Serial.print(Nunit_x1000); Serial.print("") ""); Serial.print(""(""); Serial.print(Road_distance); Serial.print("", ""); // Serial.print(pathCompletion); Serial.print("", ""); Serial.print(pc); Serial.println("") ""); */ if (abs(Road_distance) < abs(closest_mm) && pc >= 0 && pc <= 100) { closest_mm = Road_distance; *k = jj; *perCent = pc; } } return closest_mm; } /*---------------------------------------------------------------------------------------*/ void FindClosestRoad(waypoint *start, waypoint *road) // information returned { long closest_mm = MAX_DISTANCE; long dist; int close_index; int perCent; long done = 2000; int i, j; // find closest road. for (i = 0; i < MAP_POINTS; i++) { dist = distance(i, &j, start->east_mm, start->north_mm, &perCent); if (abs(dist) < abs(closest_mm)) { close_index = j; closest_mm = dist; done = perCent; road->index = i; road->sigma_mm = j; } } if (closest_mm < MAX_DISTANCE) { // Serial.println(done); i = road->index; j = close_index; road->east_mm = Nodes[i].east_mm + done *(Nodes[j].east_mm - Nodes[i].east_mm) / 100; road->north_mm = Nodes[i].north_mm + done *(Nodes[j].north_mm - Nodes[i].north_mm) / 100; /* Serial.print(""(""); Serial.print(Nodes[i].east_mm); Serial.print("", ""); Serial.print(Nodes[i].north_mm); Serial.print("") ""); Serial.print(""(""); Serial.print(Nodes[j].east_mm); Serial.print("", ""); Serial.print(Nodes[j].north_mm); Serial.print("") ""); Serial.print(""(""); Serial.print(road->east_mm); Serial.print("", ""); Serial.print(road->north_mm); Serial.print("") ""); Serial.println(j); */ } else { // find closest node for (i = 0; i < MAP_POINTS; i++) { dist = start->distance_mm(Nodes[i].east_mm, Nodes[i].north_mm); if (dist < closest_mm) { close_index = i; closest_mm = dist; } } road->index = road->sigma_mm = close_index; road->east_mm = Nodes[close_index].east_mm; road->north_mm = Nodes[close_index].north_mm; } road->Evector_x1000 = 1000; road->Nvector_x1000 = 0; road->time_ms = 0; road->speed_mmPs = DESIRED_SPEED_mmPs; } /*---------------------------------------------------------------------------------------*/ // start and destination are on the road network given in Nodes. // start is in Path[1]. // Place other junction waypoints into Path. // Returned value is next index into Path. // start->index identifies the closest node. // sigma_mm holds the index to the other node. // A* is traditionally done with pushing and popping node from an Open and Closed list. // Since we have a small number of nodes, we instead reserve a slot on Open and Closed // for each node. int BuildPath (int j, waypoint* start, waypoint* destination) { // Done; we have reached the node that leads to goal turn-off // Construct path backward to start. int last = 1; int route[MAP_POINTS]; int i, k, node; long dist_mm; k = MAP_POINTS-1; route[k] = j; // Serial.println(k); while(Open[j].ParentID != START) { j = route[--k] = Open[j].ParentID; // Serial.println(k); } Path[last] = start; for ( ; k < MAP_POINTS; k++) { node = route[k]; Path[++last].east_mm = Nodes[node].east_mm; Path[last].north_mm = Nodes[node].north_mm; // Serial.print(last); Serial.print("", ""); // Serial.print(Path[last].east_mm); Serial.print("", ""); // Serial.println(Path[last].north_mm); } Path[++last] = destination; for (k = 0; k <= last; k++) { if(k > 0) Path[k].sigma_mm = 10; // map should be good to a cm. Path[k].index = k; Path[k].speed_mmPs = DESIRED_SPEED_mmPs; Path[k].Compute_LatLon(); // this is never used } last++; for (j = 0; j < last-1; j++) { Path[j].vectors(&Path[j+1]); } return last; } // end of BuildPath /*---------------------------------------------------------------------------------------*/ int FindPath(waypoint *start, waypoint *destination) { long ClosedCost[MAP_POINTS]; // int OpenIndex = 0; // int ClosedIndex = 1; int i, j, k; long NewCost, NewStartCost, NewCostToGoal; long NewIndex; long BestCost, BestID; bool Processed = false; for (i = 0; i < MAP_POINTS; i++) { // mark all nodes as empty Open[i].TotalCost = MAX_DISTANCE; ClosedCost[i] = MAX_DISTANCE; } // get successor nodes of start i = start->index; Open[i].CostFromStart = start->distance_mm(Nodes[i].east_mm, Nodes[i].north_mm); Open[i].CostToGoal = destination->distance_mm(Nodes[i].east_mm, Nodes[i].north_mm); Open[i].TotalCost = Open[i].CostFromStart + Open[i].CostToGoal; Open[i].ParentID = START; // SendPath(start, 1); // SendPath(destination, 1); // Serial.println(i); i = start->sigma_mm; Open[i].CostFromStart = start->distance_mm(Nodes[i].east_mm, Nodes[i].north_mm); Open[i].CostToGoal = destination->distance_mm(Nodes[i].east_mm, Nodes[i].north_mm); Open[i].TotalCost = Open[i].CostFromStart + Open[i].CostToGoal; Open[i].ParentID = START; // Serial.println(i); // Serial.println(""Start A*""); // Serial.flush(); BestCost = 0; while (BestCost < MAX_DISTANCE) { BestCost = MAX_DISTANCE; BestID = -1; // Serial.println(BestCost); // pop lowest cost node from Open; i.e. find index of lowest cost item for (i = 0; i < MAP_POINTS; i++) { // Serial.print(i); Serial.print("", ""); Serial.print(Open[i].TotalCost); // Serial.print("", ""); Serial.println(ClosedCost[i]); if (Open[i].TotalCost < BestCost) { BestID = i; BestCost = Open[i].TotalCost; // Serial.print(""Best: ""); Serial.print(i); Serial.print("", ""); Serial.println(BestCost); } } if (BestID < 0) { // Serial.println(""No path found.""); // Serial.flush(); return INVALID; } Open[BestID].TotalCost = MAX_DISTANCE; // Remove node from ""stack"". if (BestID == destination->index || BestID == destination->sigma_mm) { // Done; we have reached the node that leads to goal turn-off // Construct path backward to start. // Serial.println(""Found a path.""); // Serial.flush(); return BuildPath(BestID, start, destination); } // get successor nodes from map i = BestID; // Serial.print(i); Serial.print("", ""); Serial.println(BestCost); for (j = 0; j < 4; j++) { NewIndex = Nodes[i].destination[j]; if (NewIndex == END) continue; // no successor in this slot NewStartCost = Open[i].CostFromStart + Nodes[i].Distance[j]; NewCostToGoal = destination->distance_mm (Nodes[NewIndex].east_mm, Nodes[NewIndex].north_mm); NewCost = NewStartCost + NewCostToGoal; // check if this node is already on Open or Closed. if (NewCost >= ClosedCost[NewIndex]) continue; // Have already looked at this node else if (ClosedCost[NewIndex] != MAX_DISTANCE) { // looked at this node before, but at a higher cost ClosedCost[NewIndex] = MAX_DISTANCE; // remove node from Closed } if (NewCost >= Open[NewIndex].TotalCost) continue; // This node is a less efficient way of getting to a node on the list. // Push successor node onto stack. Open[NewIndex].CostFromStart = NewStartCost; Open[NewIndex].CostToGoal = NewCostToGoal; Open[NewIndex].TotalCost = NewCost; Open[NewIndex].ParentID = i; } // end of successor nodes // Push node onto Closed ClosedCost[BestID] = BestCost; } // end of while Open is not empty return 0; // failure } /*---------------------------------------------------------------------------------------*/ // Low level path is a straight line from start to detination. // PathPlan makes an intermediate level path that uses as many roads as possible. int PlanPath (waypoint *start, waypoint *destination) { waypoint roadOrigin, roadDestination; int last = 0; Path[0] = start; Path[0].index = 0; // SendPath( start, 1); // SendPath( destination, 1); FindClosestRoad( start, &roadOrigin ); FindClosestRoad( destination, &roadDestination ); // SendPath( start, 1); // SendPath( destination, 1); // SendPath( &roadOrigin, 1); // SendPath( &roadDestination, 1); if (abs(start->east_mm - roadOrigin.east_mm) + abs(start->north_mm - roadOrigin.north_mm) + abs(destination->east_mm - roadDestination.east_mm) + abs(destination->north_mm - roadDestination.north_mm) >= abs(start->east_mm - destination->east_mm) + abs(start->north_mm - destination->north_mm)) { // don't use roads; go direct last = 1; // Serial.println(""Direct route""); } else { // use A* with the road network Path[1] = roadOrigin; Path[1].index = 1; // Serial.println(""Use A*""); // SendPath(Path, 2); last = FindPath(&roadOrigin, &roadDestination); // Serial.print(""A* finds last = ""); Serial.println(last); } Path[last] = destination; Path[last-1].vectors(&Path[last]); Path[last].Evector_x1000 = Path[last-1].Evector_x1000; Path[last].Nvector_x1000 = Path[last-1].Nvector_x1000; Path[last].index = last | END; return last; } /*---------------------------------------------------------------------------------------*/ // Transmit the path to C3 Pilot over a serial line. void SendPath(waypoint *course, int count) { char *dataString; for( int i = 0; i < count; i++) { dataString = course[i].formPointString(); checksum(dataString); Serial.println(dataString); if (course[i].index & END) break; } } /*---------------------------------------------------------------------------------------*/ void initialize() { int last; Origin.Evector_x1000 = INVALID; Origin.Nvector_x1000 = INVALID; Origin.east_mm = 0; Origin.north_mm = 0; Origin.latitude = INVALID; Origin.longitude = INVALID; ConstructNetwork(Nodes, MAP_POINTS); /* If (initial position is provided) // used when GPS is unavailable or inaccurate { ReadPosition(); // latitude and longitude // The origin in the (east_mm, north_mm) coordinate system is defined to be the // latitude and longitude at which the robot starts. // (Evector, Nvector) is initial robot attitude. SendInitialPosition(C6); // latitude and longitude } */ /* Convert latitude and longitude positions to flat earth coordinates. Fill in waypoint structure */ GetGoals(mission, CONES); // Send mission to C3. SendPath(mission, CONES); Serial.println(); /* Plan a Path (using map) between each Node. Use the A* algorithm as given in Bryan Stout ""The Basics of A* for Path Planning"" in Mark DeLoura (ed) Game Programming Gems, Charles River Media, 2000. */ last = PlanPath (&mission[0], &mission[1]); Path[last].index |= GOAL; /* PlanPath does not look at obstacles; The Pilot (C3) does that. As the vehicle position diverges from expectations due to obstacles, C4 keeps updating the plan. The output from PlanPath is a sequence of waypoints Path[] where each waypoint is associated with a junction. We must then supplement the junction points with all the intermediate non-junction points in the RNDF so that the vehicle can follow curves in the road. The first section of this is Route. We now have a sequence of segments that defines the mission from the origin to the destination. We will need finer grain that the Route waypoints from the map. */ SendPath(Path, MAX_WAYPOINTS); Serial.println(); /* Read vehicle position, attitude and velocity. ReceiveState(C6); fill in Origin.latitude, Origin.longitude, Origin.bearing set Start to Origin; GetPosition supplements each pair of waypoints with an Hermite curve that links them. Foley et al., Introduction to Computer Graphics. */ /* Construct the speed profiles over the Route. Consider how much time we want to come up to speed, time to decelerate and reduced speed around turns. ConstructSpeeds(); */ /* Send the Route and initial speed profile to C6. C6 will add current vehicle position, attitude, velocity and acceleration to create the vehicle state. The state information is sent on to C3 and fed back to C4. SendState(C6); */ } /*---------------------------------------------------------------------------------------*/ /*void setup() { pinMode(Rx0, INPUT); pinMode(Tx0, OUTPUT); pinMode(LED, OUTPUT); Serial.begin(9600); Serial.flush(); Serial.println(); Serial.println(); pinMode(DATA_READY, INPUT); DataAvailable = false; attachInterrupt(0, DataReady, FALLING); initialize(); } /*---------------------------------------------------------------------------------------*/ /*void loop() { static int Goal = 1; int last; /* Maintain a list of waypoints from current position to destination. Eliminate any waypoints that have already been visited. ReceiveState(C6); // This may be at the interrupt level PlanPath(); // only from current position to next waypoint UpdateRoute(); ConstructSpeeds(); SendState(C6); About once a second, write the current position and remaining mission, so that if we get a reset, we can start from where we left off. */ // Serial.println(""Loop""); /* if (DataAvailable) { // read vehicle position from C6 readline(0); // send data to C3 writeline(0); digitalWrite(C4_DATA_SENT, HIGH); // transition interrupts the processor delay(1); digitalWrite(C4_DATA_SENT, LOW); Start.readPointString(1000, 0); last = PlanPath (&Start, &mission[Goal]); Path[last].index |= GOAL; // TO DO: Make a fine path, providing proper curve path if (last < MAX_WAYPOINTS/2 && Goal < CONES) { last = PlanPath (&Start, &mission[++Goal]); Path[last].index |= GOAL; } SendPath(Path, MAX_WAYPOINTS); Serial.println(); } else { // delay for 1 sec, waiting for data long end_time = millis() + 1000; while (millis() < end_time) { if (DataAvailable) break; } } }*/ /*-----------------------------------------------------------------------------------------------*/ /* ConstructNetwork tests Inputs: junction *Map, int MapPoints Expected values for *Map: array of junctions Expected values for MapPoints: MAP_POINTS junction values: long east_mm, long north_mm, int destination[4], long Distance[4] destination is the index of the graph nodes this junction has an edge to Distance is initially the distance multiplier for each destination node. After this function is called, Distance is changed to actual distance calculation (in mm). */ // Happy path test with small map // Verifies that the distances are correctly updated in the map passed to // the function. test(ConstructNetwork_small) { int m = 4; // input junction junction actual[4] = { 0, 0, 1 , END, END, END, 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 0, 0, 0 , END, END, END, 1, 1, 1, 1, // 2 0, 0, 0 , END, END, END, 1, 1, 1, 1, // 3 }; // expected output junction expected[4] = { 0, 0, 1 , END, END, END, 5, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 5, 1, 1, 1, // 1 0, 0, 0 , END, END, END, 0, 1, 1, 1, // 2 0, 0, 0 , END, END, END, 0, 1, 1, 1, // 3 }; // Call the function being tested ConstructNetwork(actual, m); // Verify the data in the array passed to the function is updated // Because we don't have a print overload for junction, we need to // make assertations on individual pieces of data within the struct. // The same applies to arrays. for(int i = 0; i < m; i++) { assertEqual(actual[i].east_mm, expected[i].east_mm); assertEqual(actual[i].north_mm, expected[i].north_mm); for(int j = 0; j < 4; j++){ assertEqual(actual[i].destination[j], expected[i].destination[j]); assertEqual(actual[i].Distance[j], expected[i].Distance[j]); } } } // Happy path test with large map // Verifies that the distances are correctly updated in the map passed to // the function. // 113 was the largest number of nodes we could test without the Mega 2560 throwing an error test(ConstructNetwork_large) { int m = 110; // input junction junction actual[110] = { 0, 0, 1 , 2 , 3 , 4 , 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 2 0, 0, 0 , END, END, END, 1, 1, 1, 1, // 3 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 4 }; // expected output junction expected[110] = { 0, 0, 1 , 2 , 3 , 4 , 5, 5, 0, 5, // 0 3, 4, 0 , END, END, END, 5, 1, 1, 1, // 1 3, 4, 0 , END, END, END, 5, 1, 1, 1, // 2 0, 0, 0 , END, END, END, 0, 1, 1, 1, // 3 3, 4, 0 , END, END, END, 5, 1, 1, 1, // 4 }; // Call the function being tested ConstructNetwork(actual, m); // Verify the data in the array passed to the function is updated // Because we don't have a print overload for junction, we need to // make assertations on individual pieces of data within the struct. // The same applies to arrays. for(int i = 0; i < m; i++) { assertEqual(actual[i].east_mm, expected[i].east_mm); assertEqual(actual[i].north_mm, expected[i].north_mm); for(int j = 0; j < 4; j++){ assertEqual(actual[i].destination[j], expected[i].destination[j]); assertEqual(actual[i].Distance[j], expected[i].Distance[j]); } } } // Test for empty Map test(ConstructNetwork_empty_map) { int m = 0; // input junction junction actual[0] = {}; // Call the function being tested ConstructNetwork(actual, m); // This test just verifies that it doesn't crash; the assertion is to show // that it did not crash and the test passed. assertTrue(true); } // Test for MapPoints being smaller than the size of the array // Verifies that the distances are correctly updated in the map passed to // the function. test(ConstructNetwork_less_mappoints) { int m = 1; // input junction junction actual[2] = { 0, 0, 1 , END, END, END, 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 }; // expected output junction expected[2] = { 0, 0, 1 , END, END, END, 5, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 }; // Call the function being tested ConstructNetwork(actual, m); // Verify the data in the array passed to the function is updated // Because we don't have a print overload for junction, we need to // make assertations on individual pieces of data within the struct. // The same applies to arrays. for(int i = 0; i < m; i++) { assertEqual(actual[i].east_mm, expected[i].east_mm); assertEqual(actual[i].north_mm, expected[i].north_mm); for(int j = 0; j < 4; j++){ assertEqual(actual[i].destination[j], expected[i].destination[j]); assertEqual(actual[i].Distance[j], expected[i].Distance[j]); } } } // Test for MapPoints being larger than the size of the array // Verifies that the distances are correctly updated in the map passed to // the function. test(ConstructNetwork_more_mappoints) { int m = 3; // input junction junction actual[2] = { 0, 0, 1 , END, END, END, 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 }; // expected output junction expected[2] = { 0, 0, 1 , END, END, END, 5, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 5, 1, 1, 1, // 1 }; // Call the function being tested ConstructNetwork(actual, m); // Verify the data in the array passed to the function is updated // Because we don't have a print overload for junction, we need to // make assertations on individual pieces of data within the struct. // The same applies to arrays. for(int i = 0; i < 2; i++) { assertEqual(actual[i].east_mm, expected[i].east_mm); assertEqual(actual[i].north_mm, expected[i].north_mm); for(int j = 0; j < 4; j++){ assertEqual(actual[i].destination[j], expected[i].destination[j]); assertEqual(actual[i].Distance[j], expected[i].Distance[j]); } } } // Test for MapPoints being negative // Verifies that the distances are correctly updated in the map passed to // the function. test(ConstructNetwork_negative_mappoints) { int m = -1; // input junction junction actual[2] = { 0, 0, 1 , END, END, END, 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 }; // expected output junction expected[2] = { 0, 0, 1 , END, END, END, 1, 1, 1, 1, // 0 3, 4, 0 , END, END, END, 1, 1, 1, 1, // 1 }; // Call the function being tested ConstructNetwork(actual, m); // Verify the data in the array passed to the function is updated // Because we don't have a print overload for junction, we need to // make assertations on individual pieces of data within the struct. // The same applies to arrays. for(int i = 0; i < 2; i++) { assertEqual(actual[i].east_mm, expected[i].east_mm); assertEqual(actual[i].north_mm, expected[i].north_mm); for(int j = 0; j < 4; j++){ assertEqual(actual[i].destination[j], expected[i].destination[j]); assertEqual(actual[i].Distance[j], expected[i].Distance[j]); } } } /*-----------------------------------------------------------------------------------------------*/ /* distance tests Inputs: int i, int *k, long east_mm, long north_mm, int *perCent Expected values for i: a value between 0 and the last index in Nodes[] Expected values for *k: an address Expected values for east_mm: any value (long) Expected values for north_mm: any value (long) Expected values for *perCent: an address Finds the distance from the east, north coordinates to the node at index i junction values: long east_mm, long north_mm, int destination[4], long Distance[4] */ // Happy path test for distance() /*test(distance_standard_skip) { /* Nodes[0].east_mm = 3; Nodes[0].north_mm = 4; for(int j = 0; j < 4; j++) { Nodes[0].destination[j] = (j+1)%16; Nodes[0].Distance[j] = 1; } for(int i = 1; i < 16; i++) { Nodes[i].east_mm = 0; Nodes[i].north_mm = 0; for(int j = 0; j < 4; j++) { Nodes[i].destination[j] = j; Nodes[i].Distance[j] = 1; } }*/ /* ConstructNetwork(Nodes, MAP_POINTS); // This function does not work until after distances are calculated GetGoals(mission, CONES); for(int i = 0; i < 16; i++) { Serial.print(Nodes[i].east_mm); Serial.print(','); Serial.print(Nodes[i].north_mm); Serial.print(','); for(int j = 0; j < 4; j++) { Serial.print(Nodes[i].destination[j]); Serial.print(','); } for(int j = 0; j < 4; j++) { Serial.print(Nodes[i].Distance[j]); Serial.print(','); } Serial.println(); } int i = 0; int k; long east_mm = 0; long north_mm = 0; int perCent; for (i; i < 16; i++) { long dist = distance(i, &k, east_mm, north_mm, &perCent); Serial.print(dist); Serial.print(','); Serial.print(k); Serial.print(','); Serial.println(perCent); } } /*-----------------------------------------------------------------------------------------------*/ /* FindClosestRoad tests Inputs: waypoint *start, waypoint *road Expected values for *start: an address to a waypoint Expected values for *road: an address to a waypoint Finds the closest road to a waypoint waypoint data: long latitude, long longitude, long east_mm, long_north_mm, long sigma_mm, unsigned long time_ms, int Evector_x1000, int Nvector_x1000, long speed_mmPs, int index waypoint functions: void Compute_mm() void Compute)LatLon() char* formPointString() bool readPointString(unsigned long max_wait_ms, int channel) void operator=(waypoint& other) void operator=(waypoint* other) long distance_mm(waypoint* other) void vectors(waypoint *other) long distance_mm(long east_mm, long north_mm) */ // Happy Path test for FindClosest Road // Verifies that the node closest to the start location is found test(FindClosestRoad_standard) { waypoint start; waypoint road; start.east_mm = Nodes[4].east_mm + 1; start.north_mm = Nodes[4].north_mm + 1; FindClosestRoad(&start, &road); assertEqual(road.east_mm, Nodes[4].east_mm); assertEqual(road.north_mm, Nodes[4].north_mm); } // FindClosestRoad test for bottom-left test(FindClosestRoad_bottom_left) { waypoint start; waypoint road; start.east_mm = -2147483647; start.north_mm = -2147483647; FindClosestRoad(&start, &road); assertNotEqual(road.east_mm, 2147483647); // We don't expect the bottom-leftmost point assertNotEqual(road.north_mm, 2147483647); // to be closest to the top-rightmost point } // FindClosestRoad test for top-left test(FindClosestRoad_top_left) { waypoint start; waypoint road; start.east_mm = -2147483647; start.north_mm = 2147483647; FindClosestRoad(&start, &road); assertNotEqual(road.east_mm, 2147483647); // We don't expect the top-leftmost point assertNotEqual(road.north_mm, -2147483647); // to be closest to the bottom-rightmost point } // FindClosestRoad test for top-right test(FindClosestRoad_top_right) { waypoint start; waypoint road; start.east_mm = 2147483647; start.north_mm = 2147483647; FindClosestRoad(&start, &road); assertNotEqual(road.east_mm, -2147483647); // We don't expect the top-rightmost point assertNotEqual(road.north_mm, -2147483647); // to be closest to the bottom-leftmost point } // FindClosestRoad test for bottom-right test(FindClosestRoad_bottom_right) { waypoint start; waypoint road; start.east_mm = 2147483647; start.north_mm = -2147483647; FindClosestRoad(&start, &road); assertNotEqual(road.east_mm, -2147483647); // We don't expect the bottom-rightmost point assertNotEqual(road.north_mm, 2147483647); // to be closest to the top-leftmost point } /*-----------------------------------------------------------------------------------------------*/ /* FindPath tests Inputs: waypoint *start, waypoint *destination Expected values for *start: an address to a waypoint Expected values for *destination: an address to a waypoint Output: integer 0 = failure INVALID = No path found other = BuildPath return value, which is an index into Path[] struct AStar Open[].ParentID changed to START Finds a path from start to destination. waypoint data: long latitude, long longitude, long east_mm, long_north_mm, long sigma_mm, unsigned long time_ms, int Evector_x1000, int Nvector_x1000, long speed_mmPs, int index waypoint functions: void Compute_mm() void Compute)LatLon() char* formPointString() bool readPointString(unsigned long max_wait_ms, int channel) void operator=(waypoint& other) void operator=(waypoint* other) long distance_mm(waypoint* other) void vectors(waypoint *other) long distance_mm(long east_mm, long north_mm) */ // Happy path test for FindPath. // Verifies the output is correct. // Verifies the Open parent ID is set correctly. test(FindPath_Standard) { Origin.Evector_x1000 = INVALID; Origin.Nvector_x1000 = INVALID; Origin.east_mm = 0; Origin.north_mm = 0; Origin.latitude = INVALID; Origin.longitude = INVALID; Nodes[0].east_mm = 3; Nodes[0].north_mm = 4; Nodes[0].destination[0] = 1; Nodes[0].destination[1] = 3; Nodes[0].destination[2] = 4; Nodes[0].destination[3] = END; Nodes[0].Distance[0] = 3; Nodes[0].Distance[1] = sqrt(6*6 + 4*4); Nodes[0].Distance[2] = 4; Nodes[0].Distance[3] = 1; Nodes[1].east_mm = 0; Nodes[1].north_mm = 4; Nodes[1].destination[0] = 0; Nodes[1].destination[1] = 2; Nodes[1].destination[2] = END; Nodes[1].destination[3] = END; Nodes[1].Distance[0] = 3; Nodes[1].Distance[1] = 3; Nodes[1].Distance[2] = 1; Nodes[1].Distance[3] = 1; Nodes[2].east_mm = -3; Nodes[2].north_mm = 4; Nodes[2].destination[0] = 1; Nodes[2].destination[1] = 3; Nodes[2].destination[2] = END; Nodes[2].destination[3] = END; Nodes[2].Distance[0] = 3; Nodes[2].Distance[1] = 4; Nodes[2].Distance[2] = 1; Nodes[2].Distance[3] = 1; Nodes[3].east_mm = -3; Nodes[3].north_mm = 0; Nodes[3].destination[0] = 0; Nodes[3].destination[1] = 2; Nodes[3].destination[2] = 4; Nodes[3].destination[3] = END; Nodes[3].Distance[0] = sqrt(6*6 + 4*4); Nodes[3].Distance[1] = 4; Nodes[3].Distance[2] = 6; Nodes[3].Distance[3] = 1; Nodes[4].east_mm = 3; Nodes[4].north_mm = 0; Nodes[4].destination[0] = 3; Nodes[4].destination[1] = 0; Nodes[4].destination[2] = END; Nodes[4].destination[3] = END; Nodes[4].Distance[0] = 6; Nodes[4].Distance[1] = 4; Nodes[4].Distance[2] = 1; Nodes[4].Distance[3] = 1; waypoint start; waypoint destination; start.index = 0; start.sigma_mm = 0; start.east_mm = Nodes[0].east_mm; start.north_mm = Nodes[0].north_mm; destination.index = 3; destination.sigma_mm = 0; destination.east_mm = Nodes[3].east_mm; destination.north_mm = Nodes[3].north_mm; int actual = FindPath(&start, &destination); Serial.println(actual); Serial.print(Path[0].formPointString()); Serial.print(Nodes[0].east_mm); Serial.print("", ""); Serial.println(Nodes[0].north_mm); Serial.print(Path[1].formPointString()); Serial.print(Nodes[1].east_mm); Serial.print("", ""); Serial.println(Nodes[1].north_mm); Serial.print(Path[2].formPointString()); Serial.print(Nodes[2].east_mm); Serial.print("", ""); Serial.println(Nodes[2].north_mm); Serial.print(Path[3].formPointString()); Serial.print(Nodes[3].east_mm); Serial.print("", ""); Serial.println(Nodes[3].north_mm); Serial.print(Path[4].formPointString()); Serial.print(Nodes[4].east_mm); Serial.print("", ""); Serial.println(Nodes[4].north_mm); assertEqual(Open[1].ParentID, start.index); } void setup() { Serial.begin(115200); Test::out = &Serial; // Output test results to the Serial monitor Test::exclude(""*_skip""); // Skips all test with ""_skip"" at the end of the name Test::exclude(""*_large""); // Skips all test with ""_large"" at the end of the name } void loop() { Test::run(); } ",12402,False,2031.3564903284225,median "/* * Copyright 2018 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the ""Software""), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ var SQ_WAVE_STATUS_INST_ATC_SHIFT = 23 var SQ_WAVE_STATUS_INST_ATC_MASK = 0x00800000 var SQ_WAVE_STATUS_SPI_PRIO_MASK = 0x00000006 var SQ_WAVE_STATUS_HALT_MASK = 0x2000 var SQ_WAVE_LDS_ALLOC_LDS_SIZE_SHIFT = 12 var SQ_WAVE_LDS_ALLOC_LDS_SIZE_SIZE = 9 var SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SHIFT = 8 var SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SIZE = 6 var SQ_WAVE_GPR_ALLOC_SGPR_SIZE_SHIFT = 24 var SQ_WAVE_GPR_ALLOC_SGPR_SIZE_SIZE = 4 var SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SHIFT = 24 var SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SIZE = 4 var SQ_WAVE_IB_STS2_WAVE64_SHIFT = 11 var SQ_WAVE_IB_STS2_WAVE64_SIZE = 1 var SQ_WAVE_TRAPSTS_SAVECTX_MASK = 0x400 var SQ_WAVE_TRAPSTS_EXCE_MASK = 0x1FF var SQ_WAVE_TRAPSTS_SAVECTX_SHIFT = 10 var SQ_WAVE_TRAPSTS_MEM_VIOL_MASK = 0x100 var SQ_WAVE_TRAPSTS_MEM_VIOL_SHIFT = 8 var SQ_WAVE_TRAPSTS_PRE_SAVECTX_MASK = 0x3FF var SQ_WAVE_TRAPSTS_PRE_SAVECTX_SHIFT = 0x0 var SQ_WAVE_TRAPSTS_PRE_SAVECTX_SIZE = 10 var SQ_WAVE_TRAPSTS_POST_SAVECTX_MASK = 0xFFFFF800 var SQ_WAVE_TRAPSTS_POST_SAVECTX_SHIFT = 11 var SQ_WAVE_TRAPSTS_POST_SAVECTX_SIZE = 21 var SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK = 0x800 var SQ_WAVE_IB_STS_RCNT_SHIFT = 16 var SQ_WAVE_IB_STS_FIRST_REPLAY_SHIFT = 15 var SQ_WAVE_IB_STS_REPLAY_W64H_SHIFT = 25 var SQ_WAVE_IB_STS_REPLAY_W64H_SIZE = 1 var SQ_WAVE_IB_STS_REPLAY_W64H_MASK = 0x02000000 var SQ_WAVE_IB_STS_FIRST_REPLAY_SIZE = 1 var SQ_WAVE_IB_STS_RCNT_SIZE = 6 var SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK = 0x003F8000 var SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK_NEG = 0x00007FFF var SQ_BUF_RSRC_WORD1_ATC_SHIFT = 24 var SQ_BUF_RSRC_WORD3_MTYPE_SHIFT = 27 // bits [31:24] unused by SPI debug data var TTMP11_SAVE_REPLAY_W64H_SHIFT = 31 var TTMP11_SAVE_REPLAY_W64H_MASK = 0x80000000 var TTMP11_SAVE_RCNT_FIRST_REPLAY_SHIFT = 24 var TTMP11_SAVE_RCNT_FIRST_REPLAY_MASK = 0x7F000000 // SQ_SEL_X/Y/Z/W, BUF_NUM_FORMAT_FLOAT, (0 for MUBUF stride[17:14] // when ADD_TID_ENABLE and BUF_DATA_FORMAT_32 for MTBUF), ADD_TID_ENABLE var S_SAVE_BUF_RSRC_WORD1_STRIDE = 0x00040000 var S_SAVE_BUF_RSRC_WORD3_MISC = 0x10807FAC var S_SAVE_SPI_INIT_ATC_MASK = 0x08000000 var S_SAVE_SPI_INIT_ATC_SHIFT = 27 var S_SAVE_SPI_INIT_MTYPE_MASK = 0x70000000 var S_SAVE_SPI_INIT_MTYPE_SHIFT = 28 var S_SAVE_SPI_INIT_FIRST_WAVE_MASK = 0x04000000 var S_SAVE_SPI_INIT_FIRST_WAVE_SHIFT = 26 var S_SAVE_PC_HI_RCNT_SHIFT = 26 var S_SAVE_PC_HI_RCNT_MASK = 0xFC000000 var S_SAVE_PC_HI_FIRST_REPLAY_SHIFT = 25 var S_SAVE_PC_HI_FIRST_REPLAY_MASK = 0x02000000 var S_SAVE_PC_HI_REPLAY_W64H_SHIFT = 24 var S_SAVE_PC_HI_REPLAY_W64H_MASK = 0x01000000 var s_sgpr_save_num = 108 var s_save_spi_init_lo = exec_lo var s_save_spi_init_hi = exec_hi var s_save_pc_lo = ttmp0 var s_save_pc_hi = ttmp1 var s_save_exec_lo = ttmp2 var s_save_exec_hi = ttmp3 var s_save_status = ttmp12 var s_save_trapsts = ttmp5 var s_save_xnack_mask = ttmp6 var s_wave_size = ttmp7 var s_save_buf_rsrc0 = ttmp8 var s_save_buf_rsrc1 = ttmp9 var s_save_buf_rsrc2 = ttmp10 var s_save_buf_rsrc3 = ttmp11 var s_save_mem_offset = ttmp14 var s_save_alloc_size = s_save_trapsts var s_save_tmp = s_save_buf_rsrc2 var s_save_m0 = ttmp15 var S_RESTORE_BUF_RSRC_WORD1_STRIDE = S_SAVE_BUF_RSRC_WORD1_STRIDE var S_RESTORE_BUF_RSRC_WORD3_MISC = S_SAVE_BUF_RSRC_WORD3_MISC var S_RESTORE_SPI_INIT_ATC_MASK = 0x08000000 var S_RESTORE_SPI_INIT_ATC_SHIFT = 27 var S_RESTORE_SPI_INIT_MTYPE_MASK = 0x70000000 var S_RESTORE_SPI_INIT_MTYPE_SHIFT = 28 var S_RESTORE_SPI_INIT_FIRST_WAVE_MASK = 0x04000000 var S_RESTORE_SPI_INIT_FIRST_WAVE_SHIFT = 26 var S_WAVE_SIZE = 25 var S_RESTORE_PC_HI_RCNT_SHIFT = S_SAVE_PC_HI_RCNT_SHIFT var S_RESTORE_PC_HI_RCNT_MASK = S_SAVE_PC_HI_RCNT_MASK var S_RESTORE_PC_HI_FIRST_REPLAY_SHIFT = S_SAVE_PC_HI_FIRST_REPLAY_SHIFT var S_RESTORE_PC_HI_FIRST_REPLAY_MASK = S_SAVE_PC_HI_FIRST_REPLAY_MASK var s_restore_spi_init_lo = exec_lo var s_restore_spi_init_hi = exec_hi var s_restore_mem_offset = ttmp12 var s_restore_alloc_size = ttmp3 var s_restore_tmp = ttmp6 var s_restore_mem_offset_save = s_restore_tmp var s_restore_m0 = s_restore_alloc_size var s_restore_mode = ttmp7 var s_restore_flat_scratch = ttmp2 var s_restore_pc_lo = ttmp0 var s_restore_pc_hi = ttmp1 var s_restore_exec_lo = ttmp14 var s_restore_exec_hi = ttmp15 var s_restore_status = ttmp4 var s_restore_trapsts = ttmp5 var s_restore_xnack_mask = ttmp13 var s_restore_buf_rsrc0 = ttmp8 var s_restore_buf_rsrc1 = ttmp9 var s_restore_buf_rsrc2 = ttmp10 var s_restore_buf_rsrc3 = ttmp11 var s_restore_size = ttmp7 shader main asic(DEFAULT) type(CS) wave_size(32) s_branch L_SKIP_RESTORE //NOT restore. might be a regular trap or save L_JUMP_TO_RESTORE: s_branch L_RESTORE L_SKIP_RESTORE: s_getreg_b32 s_save_status, hwreg(HW_REG_STATUS) //save STATUS since we will change SCC s_andn2_b32 s_save_status, s_save_status, SQ_WAVE_STATUS_SPI_PRIO_MASK s_getreg_b32 s_save_trapsts, hwreg(HW_REG_TRAPSTS) s_and_b32 ttmp2, s_save_trapsts, SQ_WAVE_TRAPSTS_SAVECTX_MASK //check whether this is for save s_cbranch_scc1 L_SAVE // If STATUS.MEM_VIOL is asserted then halt the wave to prevent // the exception raising again and blocking context save. s_and_b32 ttmp2, s_save_trapsts, SQ_WAVE_TRAPSTS_MEM_VIOL_MASK s_cbranch_scc0 L_FETCH_2ND_TRAP s_or_b32 s_save_status, s_save_status, SQ_WAVE_STATUS_HALT_MASK L_FETCH_2ND_TRAP: // Preserve and clear scalar XNACK state before issuing scalar loads. // Save IB_STS.REPLAY_W64H[25], RCNT[21:16], FIRST_REPLAY[15] into // unused space ttmp11[31:24]. s_andn2_b32 ttmp11, ttmp11, (TTMP11_SAVE_REPLAY_W64H_MASK | TTMP11_SAVE_RCNT_FIRST_REPLAY_MASK) s_getreg_b32 ttmp2, hwreg(HW_REG_IB_STS) s_and_b32 ttmp3, ttmp2, SQ_WAVE_IB_STS_REPLAY_W64H_MASK s_lshl_b32 ttmp3, ttmp3, (TTMP11_SAVE_REPLAY_W64H_SHIFT - SQ_WAVE_IB_STS_REPLAY_W64H_SHIFT) s_or_b32 ttmp11, ttmp11, ttmp3 s_and_b32 ttmp3, ttmp2, SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK s_lshl_b32 ttmp3, ttmp3, (TTMP11_SAVE_RCNT_FIRST_REPLAY_SHIFT - SQ_WAVE_IB_STS_FIRST_REPLAY_SHIFT) s_or_b32 ttmp11, ttmp11, ttmp3 s_andn2_b32 ttmp2, ttmp2, (SQ_WAVE_IB_STS_REPLAY_W64H_MASK | SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK) s_setreg_b32 hwreg(HW_REG_IB_STS), ttmp2 // Read second-level TBA/TMA from first-level TMA and jump if available. // ttmp[2:5] and ttmp12 can be used (others hold SPI-initialized debug data) // ttmp12 holds SQ_WAVE_STATUS s_getreg_b32 ttmp14, hwreg(HW_REG_SHADER_TMA_LO) s_getreg_b32 ttmp15, hwreg(HW_REG_SHADER_TMA_HI) s_lshl_b64 [ttmp14, ttmp15], [ttmp14, ttmp15], 0x8 s_load_dwordx2 [ttmp2, ttmp3], [ttmp14, ttmp15], 0x0 glc:1 // second-level TBA s_waitcnt lgkmcnt(0) s_load_dwordx2 [ttmp14, ttmp15], [ttmp14, ttmp15], 0x8 glc:1 // second-level TMA s_waitcnt lgkmcnt(0) s_and_b64 [ttmp2, ttmp3], [ttmp2, ttmp3], [ttmp2, ttmp3] s_cbranch_scc0 L_NO_NEXT_TRAP // second-level trap handler not been set s_setpc_b64 [ttmp2, ttmp3] // jump to second-level trap handler L_NO_NEXT_TRAP: s_getreg_b32 s_save_trapsts, hwreg(HW_REG_TRAPSTS) s_and_b32 s_save_trapsts, s_save_trapsts, SQ_WAVE_TRAPSTS_EXCE_MASK s_cbranch_scc1 L_EXCP_CASE // Exception, jump back to the shader program directly. s_add_u32 ttmp0, ttmp0, 4 // S_TRAP case, add 4 to ttmp0 s_addc_u32 ttmp1, ttmp1, 0 L_EXCP_CASE: s_and_b32 ttmp1, ttmp1, 0xFFFF // Restore SQ_WAVE_IB_STS. s_lshr_b32 ttmp2, ttmp11, (TTMP11_SAVE_RCNT_FIRST_REPLAY_SHIFT - SQ_WAVE_IB_STS_FIRST_REPLAY_SHIFT) s_and_b32 ttmp3, ttmp2, SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK s_lshr_b32 ttmp2, ttmp11, (TTMP11_SAVE_REPLAY_W64H_SHIFT - SQ_WAVE_IB_STS_REPLAY_W64H_SHIFT) s_and_b32 ttmp2, ttmp2, SQ_WAVE_IB_STS_REPLAY_W64H_MASK s_or_b32 ttmp2, ttmp2, ttmp3 s_setreg_b32 hwreg(HW_REG_IB_STS), ttmp2 // Restore SQ_WAVE_STATUS. s_and_b64 exec, exec, exec // Restore STATUS.EXECZ, not writable by s_setreg_b32 s_and_b64 vcc, vcc, vcc // Restore STATUS.VCCZ, not writable by s_setreg_b32 s_setreg_b32 hwreg(HW_REG_STATUS), s_save_status s_rfe_b64 [ttmp0, ttmp1] L_SAVE: //check whether there is mem_viol s_getreg_b32 s_save_trapsts, hwreg(HW_REG_TRAPSTS) s_and_b32 s_save_trapsts, s_save_trapsts, SQ_WAVE_TRAPSTS_MEM_VIOL_MASK s_cbranch_scc0 L_NO_PC_REWIND //if so, need rewind PC assuming GDS operation gets NACKed s_mov_b32 s_save_tmp, 0 s_setreg_b32 hwreg(HW_REG_TRAPSTS, SQ_WAVE_TRAPSTS_MEM_VIOL_SHIFT, 1), s_save_tmp //clear mem_viol bit s_and_b32 s_save_pc_hi, s_save_pc_hi, 0x0000ffff //pc[47:32] s_sub_u32 s_save_pc_lo, s_save_pc_lo, 8 //pc[31:0]-8 s_subb_u32 s_save_pc_hi, s_save_pc_hi, 0x0 L_NO_PC_REWIND: s_mov_b32 s_save_tmp, 0 s_setreg_b32 hwreg(HW_REG_TRAPSTS, SQ_WAVE_TRAPSTS_SAVECTX_SHIFT, 1), s_save_tmp //clear saveCtx bit s_getreg_b32 s_save_xnack_mask, hwreg(HW_REG_SHADER_XNACK_MASK) s_getreg_b32 s_save_tmp, hwreg(HW_REG_IB_STS, SQ_WAVE_IB_STS_RCNT_SHIFT, SQ_WAVE_IB_STS_RCNT_SIZE) s_lshl_b32 s_save_tmp, s_save_tmp, S_SAVE_PC_HI_RCNT_SHIFT s_or_b32 s_save_pc_hi, s_save_pc_hi, s_save_tmp s_getreg_b32 s_save_tmp, hwreg(HW_REG_IB_STS, SQ_WAVE_IB_STS_FIRST_REPLAY_SHIFT, SQ_WAVE_IB_STS_FIRST_REPLAY_SIZE) s_lshl_b32 s_save_tmp, s_save_tmp, S_SAVE_PC_HI_FIRST_REPLAY_SHIFT s_or_b32 s_save_pc_hi, s_save_pc_hi, s_save_tmp s_getreg_b32 s_save_tmp, hwreg(HW_REG_IB_STS, SQ_WAVE_IB_STS_REPLAY_W64H_SHIFT, SQ_WAVE_IB_STS_REPLAY_W64H_SIZE) s_lshl_b32 s_save_tmp, s_save_tmp, S_SAVE_PC_HI_REPLAY_W64H_SHIFT s_or_b32 s_save_pc_hi, s_save_pc_hi, s_save_tmp s_getreg_b32 s_save_tmp, hwreg(HW_REG_IB_STS) //clear RCNT and FIRST_REPLAY and REPLAY_W64H in IB_STS s_and_b32 s_save_tmp, s_save_tmp, SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK_NEG s_setreg_b32 hwreg(HW_REG_IB_STS), s_save_tmp /* inform SPI the readiness and wait for SPI's go signal */ s_mov_b32 s_save_exec_lo, exec_lo //save EXEC and use EXEC for the go signal from SPI s_mov_b32 s_save_exec_hi, exec_hi s_mov_b64 exec, 0x0 //clear EXEC to get ready to receive s_sendmsg sendmsg(MSG_SAVEWAVE) //send SPI a message and wait for SPI's write to EXEC L_SLEEP: // sleep 1 (64clk) is not enough for 8 waves per SIMD, which will cause // SQ hang, since the 7,8th wave could not get arbit to exec inst, while // other waves are stuck into the sleep-loop and waiting for wrexec!=0 s_sleep 0x2 s_cbranch_execz L_SLEEP /* setup Resource Contants */ s_mov_b32 s_save_buf_rsrc0, s_save_spi_init_lo //base_addr_lo s_and_b32 s_save_buf_rsrc1, s_save_spi_init_hi, 0x0000FFFF //base_addr_hi s_or_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, S_SAVE_BUF_RSRC_WORD1_STRIDE s_mov_b32 s_save_buf_rsrc2, 0 //NUM_RECORDS initial value = 0 (in bytes) although not neccessarily inited s_mov_b32 s_save_buf_rsrc3, S_SAVE_BUF_RSRC_WORD3_MISC s_and_b32 s_save_tmp, s_save_spi_init_hi, S_SAVE_SPI_INIT_ATC_MASK s_lshr_b32 s_save_tmp, s_save_tmp, (S_SAVE_SPI_INIT_ATC_SHIFT-SQ_BUF_RSRC_WORD1_ATC_SHIFT) s_or_b32 s_save_buf_rsrc3, s_save_buf_rsrc3, s_save_tmp //or ATC s_and_b32 s_save_tmp, s_save_spi_init_hi, S_SAVE_SPI_INIT_MTYPE_MASK s_lshr_b32 s_save_tmp, s_save_tmp, (S_SAVE_SPI_INIT_MTYPE_SHIFT-SQ_BUF_RSRC_WORD3_MTYPE_SHIFT) s_or_b32 s_save_buf_rsrc3, s_save_buf_rsrc3, s_save_tmp //or MTYPE s_mov_b32 s_save_m0, m0 /* global mem offset */ s_mov_b32 s_save_mem_offset, 0x0 s_getreg_b32 s_wave_size, hwreg(HW_REG_IB_STS2,SQ_WAVE_IB_STS2_WAVE64_SHIFT,SQ_WAVE_IB_STS2_WAVE64_SIZE) s_lshl_b32 s_wave_size, s_wave_size, S_WAVE_SIZE s_or_b32 s_wave_size, s_save_spi_init_hi, s_wave_size //share s_wave_size with exec_hi, it's at bit25 /* save HW registers */ L_SAVE_HWREG: // HWREG SR memory offset : size(VGPR)+size(SVGPR)+size(SGPR) get_vgpr_size_bytes(s_save_mem_offset, s_wave_size) get_svgpr_size_bytes(s_save_tmp) s_add_u32 s_save_mem_offset, s_save_mem_offset, s_save_tmp s_add_u32 s_save_mem_offset, s_save_mem_offset, get_sgpr_size_bytes() s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_pc_lo, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_pc_hi, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_exec_lo, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_exec_hi, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_status, s_save_buf_rsrc0, s_save_mem_offset) s_getreg_b32 s_save_trapsts, hwreg(HW_REG_TRAPSTS) write_hwreg_to_mem(s_save_trapsts, s_save_buf_rsrc0, s_save_mem_offset) write_hwreg_to_mem(s_save_xnack_mask, s_save_buf_rsrc0, s_save_mem_offset) s_getreg_b32 s_save_m0, hwreg(HW_REG_MODE) write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset) s_getreg_b32 s_save_m0, hwreg(HW_REG_SHADER_FLAT_SCRATCH_LO) write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset) s_getreg_b32 s_save_m0, hwreg(HW_REG_SHADER_FLAT_SCRATCH_HI) write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset) /* the first wave in the threadgroup */ s_and_b32 s_save_tmp, s_save_spi_init_hi, S_SAVE_SPI_INIT_FIRST_WAVE_MASK s_mov_b32 s_save_exec_hi, 0x0 s_or_b32 s_save_exec_hi, s_save_tmp, s_save_exec_hi // save first wave bit to s_save_exec_hi.bits[26] /* save SGPRs */ // Save SGPR before LDS save, then the s0 to s4 can be used during LDS save... // SGPR SR memory offset : size(VGPR)+size(SVGPR) get_vgpr_size_bytes(s_save_mem_offset, s_wave_size) get_svgpr_size_bytes(s_save_tmp) s_add_u32 s_save_mem_offset, s_save_mem_offset, s_save_tmp s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // backup s_save_buf_rsrc0,1 to s_save_pc_lo/hi, since write_16sgpr_to_mem function will change the rsrc0 s_mov_b32 s_save_xnack_mask, s_save_buf_rsrc0 s_add_u32 s_save_buf_rsrc0, s_save_buf_rsrc0, s_save_mem_offset s_addc_u32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0 s_mov_b32 m0, 0x0 //SGPR initial index value =0 s_nop 0x0 //Manually inserted wait states L_SAVE_SGPR_LOOP: // SGPR is allocated in 16 SGPR granularity s_movrels_b64 s0, s0 //s0 = s[0+m0], s1 = s[1+m0] s_movrels_b64 s2, s2 //s2 = s[2+m0], s3 = s[3+m0] s_movrels_b64 s4, s4 //s4 = s[4+m0], s5 = s[5+m0] s_movrels_b64 s6, s6 //s6 = s[6+m0], s7 = s[7+m0] s_movrels_b64 s8, s8 //s8 = s[8+m0], s9 = s[9+m0] s_movrels_b64 s10, s10 //s10 = s[10+m0], s11 = s[11+m0] s_movrels_b64 s12, s12 //s12 = s[12+m0], s13 = s[13+m0] s_movrels_b64 s14, s14 //s14 = s[14+m0], s15 = s[15+m0] write_16sgpr_to_mem(s0, s_save_buf_rsrc0, s_save_mem_offset) s_add_u32 m0, m0, 16 //next sgpr index s_cmp_lt_u32 m0, 96 //scc = (m0 < first 96 SGPR) ? 1 : 0 s_cbranch_scc1 L_SAVE_SGPR_LOOP //first 96 SGPR save is complete? //save the rest 12 SGPR s_movrels_b64 s0, s0 //s0 = s[0+m0], s1 = s[1+m0] s_movrels_b64 s2, s2 //s2 = s[2+m0], s3 = s[3+m0] s_movrels_b64 s4, s4 //s4 = s[4+m0], s5 = s[5+m0] s_movrels_b64 s6, s6 //s6 = s[6+m0], s7 = s[7+m0] s_movrels_b64 s8, s8 //s8 = s[8+m0], s9 = s[9+m0] s_movrels_b64 s10, s10 //s10 = s[10+m0], s11 = s[11+m0] write_12sgpr_to_mem(s0, s_save_buf_rsrc0, s_save_mem_offset) // restore s_save_buf_rsrc0,1 s_mov_b32 s_save_buf_rsrc0, s_save_xnack_mask /* save first 4 VGPR, then LDS save could use */ // each wave will alloc 4 vgprs at least... s_mov_b32 s_save_mem_offset, 0 s_mov_b32 exec_lo, 0xFFFFFFFF //need every thread from now on s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_SAVE_4VGPR_EXEC_HI s_mov_b32 exec_hi, 0x00000000 s_branch L_SAVE_4VGPR_WAVE32 L_ENABLE_SAVE_4VGPR_EXEC_HI: s_mov_b32 exec_hi, 0xFFFFFFFF s_branch L_SAVE_4VGPR_WAVE64 L_SAVE_4VGPR_WAVE32: s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR Allocated in 4-GPR granularity buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128 buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128*2 buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128*3 s_branch L_SAVE_LDS L_SAVE_4VGPR_WAVE64: s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR Allocated in 4-GPR granularity buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256 buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256*2 buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256*3 /* save LDS */ L_SAVE_LDS: // Change EXEC to all threads... s_mov_b32 exec_lo, 0xFFFFFFFF //need every thread from now on s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_SAVE_LDS_EXEC_HI s_mov_b32 exec_hi, 0x00000000 s_branch L_SAVE_LDS_NORMAL L_ENABLE_SAVE_LDS_EXEC_HI: s_mov_b32 exec_hi, 0xFFFFFFFF L_SAVE_LDS_NORMAL: s_getreg_b32 s_save_alloc_size, hwreg(HW_REG_LDS_ALLOC,SQ_WAVE_LDS_ALLOC_LDS_SIZE_SHIFT,SQ_WAVE_LDS_ALLOC_LDS_SIZE_SIZE) s_and_b32 s_save_alloc_size, s_save_alloc_size, 0xFFFFFFFF //lds_size is zero? s_cbranch_scc0 L_SAVE_LDS_DONE //no lds used? jump to L_SAVE_DONE s_barrier //LDS is used? wait for other waves in the same TG s_and_b32 s_save_tmp, s_save_exec_hi, S_SAVE_SPI_INIT_FIRST_WAVE_MASK s_cbranch_scc0 L_SAVE_LDS_DONE // first wave do LDS save; s_lshl_b32 s_save_alloc_size, s_save_alloc_size, 6 //LDS size in dwords = lds_size * 64dw s_lshl_b32 s_save_alloc_size, s_save_alloc_size, 2 //LDS size in bytes s_mov_b32 s_save_buf_rsrc2, s_save_alloc_size //NUM_RECORDS in bytes // LDS at offset: size(VGPR)+size(SVGPR)+SIZE(SGPR)+SIZE(HWREG) // get_vgpr_size_bytes(s_save_mem_offset, s_wave_size) get_svgpr_size_bytes(s_save_tmp) s_add_u32 s_save_mem_offset, s_save_mem_offset, s_save_tmp s_add_u32 s_save_mem_offset, s_save_mem_offset, get_sgpr_size_bytes() s_add_u32 s_save_mem_offset, s_save_mem_offset, get_hwreg_size_bytes() s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes //load 0~63*4(byte address) to vgpr v0 v_mbcnt_lo_u32_b32 v0, -1, 0 v_mbcnt_hi_u32_b32 v0, -1, v0 v_mul_u32_u24 v0, 4, v0 s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_mov_b32 m0, 0x0 s_cbranch_scc1 L_SAVE_LDS_W64 L_SAVE_LDS_W32: s_mov_b32 s3, 128 s_nop 0 s_nop 0 s_nop 0 L_SAVE_LDS_LOOP_W32: ds_read_b32 v1, v0 s_waitcnt 0 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 s_add_u32 m0, m0, s3 //every buffer_store_lds does 256 bytes s_add_u32 s_save_mem_offset, s_save_mem_offset, s3 v_add_nc_u32 v0, v0, 128 //mem offset increased by 128 bytes s_cmp_lt_u32 m0, s_save_alloc_size //scc=(m0 < s_save_alloc_size) ? 1 : 0 s_cbranch_scc1 L_SAVE_LDS_LOOP_W32 //LDS save is complete? s_branch L_SAVE_LDS_DONE L_SAVE_LDS_W64: s_mov_b32 s3, 256 s_nop 0 s_nop 0 s_nop 0 L_SAVE_LDS_LOOP_W64: ds_read_b32 v1, v0 s_waitcnt 0 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 s_add_u32 m0, m0, s3 //every buffer_store_lds does 256 bytes s_add_u32 s_save_mem_offset, s_save_mem_offset, s3 v_add_nc_u32 v0, v0, 256 //mem offset increased by 256 bytes s_cmp_lt_u32 m0, s_save_alloc_size //scc=(m0 < s_save_alloc_size) ? 1 : 0 s_cbranch_scc1 L_SAVE_LDS_LOOP_W64 //LDS save is complete? L_SAVE_LDS_DONE: /* save VGPRs - set the Rest VGPRs */ L_SAVE_VGPR: // VGPR SR memory offset: 0 s_mov_b32 exec_lo, 0xFFFFFFFF //need every thread from now on s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_SAVE_VGPR_EXEC_HI s_mov_b32 s_save_mem_offset, (0+128*4) // for the rest VGPRs s_mov_b32 exec_hi, 0x00000000 s_branch L_SAVE_VGPR_NORMAL L_ENABLE_SAVE_VGPR_EXEC_HI: s_mov_b32 s_save_mem_offset, (0+256*4) // for the rest VGPRs s_mov_b32 exec_hi, 0xFFFFFFFF L_SAVE_VGPR_NORMAL: s_getreg_b32 s_save_alloc_size, hwreg(HW_REG_GPR_ALLOC,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SHIFT,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SIZE) s_add_u32 s_save_alloc_size, s_save_alloc_size, 1 s_lshl_b32 s_save_alloc_size, s_save_alloc_size, 2 //Number of VGPRs = (vgpr_size + 1) * 4 (non-zero value) //determine it is wave32 or wave64 s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_SAVE_VGPR_WAVE64 s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR Allocated in 4-GPR granularity // VGPR store using dw burst s_mov_b32 m0, 0x4 //VGPR initial index value =4 s_cmp_lt_u32 m0, s_save_alloc_size s_cbranch_scc0 L_SAVE_VGPR_END L_SAVE_VGPR_W32_LOOP: v_movrels_b32 v0, v0 //v0 = v[0+m0] v_movrels_b32 v1, v1 //v1 = v[1+m0] v_movrels_b32 v2, v2 //v2 = v[2+m0] v_movrels_b32 v3, v3 //v3 = v[3+m0] buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128 buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128*2 buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:128*3 s_add_u32 m0, m0, 4 //next vgpr index s_add_u32 s_save_mem_offset, s_save_mem_offset, 128*4 //every buffer_store_dword does 128 bytes s_cmp_lt_u32 m0, s_save_alloc_size //scc = (m0 < s_save_alloc_size) ? 1 : 0 s_cbranch_scc1 L_SAVE_VGPR_W32_LOOP //VGPR save is complete? s_branch L_SAVE_VGPR_END L_SAVE_VGPR_WAVE64: s_mov_b32 s_save_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR store using dw burst s_mov_b32 m0, 0x4 //VGPR initial index value =4 s_cmp_lt_u32 m0, s_save_alloc_size s_cbranch_scc0 L_SAVE_VGPR_END L_SAVE_VGPR_W64_LOOP: v_movrels_b32 v0, v0 //v0 = v[0+m0] v_movrels_b32 v1, v1 //v1 = v[1+m0] v_movrels_b32 v2, v2 //v2 = v[2+m0] v_movrels_b32 v3, v3 //v3 = v[3+m0] buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256 buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256*2 buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 offset:256*3 s_add_u32 m0, m0, 4 //next vgpr index s_add_u32 s_save_mem_offset, s_save_mem_offset, 256*4 //every buffer_store_dword does 256 bytes s_cmp_lt_u32 m0, s_save_alloc_size //scc = (m0 < s_save_alloc_size) ? 1 : 0 s_cbranch_scc1 L_SAVE_VGPR_W64_LOOP //VGPR save is complete? //Below part will be the save shared vgpr part (new for gfx10) s_getreg_b32 s_save_alloc_size, hwreg(HW_REG_LDS_ALLOC,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SHIFT,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SIZE) s_and_b32 s_save_alloc_size, s_save_alloc_size, 0xFFFFFFFF //shared_vgpr_size is zero? s_cbranch_scc0 L_SAVE_VGPR_END //no shared_vgpr used? jump to L_SAVE_LDS s_lshl_b32 s_save_alloc_size, s_save_alloc_size, 3 //Number of SHARED_VGPRs = shared_vgpr_size * 8 (non-zero value) //m0 now has the value of normal vgpr count, just add the m0 with shared_vgpr count to get the total count. //save shared_vgpr will start from the index of m0 s_add_u32 s_save_alloc_size, s_save_alloc_size, m0 s_mov_b32 exec_lo, 0xFFFFFFFF s_mov_b32 exec_hi, 0x00000000 L_SAVE_SHARED_VGPR_WAVE64_LOOP: v_movrels_b32 v0, v0 //v0 = v[0+m0] buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1 s_add_u32 m0, m0, 1 //next vgpr index s_add_u32 s_save_mem_offset, s_save_mem_offset, 128 s_cmp_lt_u32 m0, s_save_alloc_size //scc = (m0 < s_save_alloc_size) ? 1 : 0 s_cbranch_scc1 L_SAVE_SHARED_VGPR_WAVE64_LOOP //SHARED_VGPR save is complete? L_SAVE_VGPR_END: s_branch L_END_PGM L_RESTORE: /* Setup Resource Contants */ s_mov_b32 s_restore_buf_rsrc0, s_restore_spi_init_lo //base_addr_lo s_and_b32 s_restore_buf_rsrc1, s_restore_spi_init_hi, 0x0000FFFF //base_addr_hi s_or_b32 s_restore_buf_rsrc1, s_restore_buf_rsrc1, S_RESTORE_BUF_RSRC_WORD1_STRIDE s_mov_b32 s_restore_buf_rsrc2, 0 //NUM_RECORDS initial value = 0 (in bytes) s_mov_b32 s_restore_buf_rsrc3, S_RESTORE_BUF_RSRC_WORD3_MISC s_and_b32 s_restore_tmp, s_restore_spi_init_hi, S_RESTORE_SPI_INIT_ATC_MASK s_lshr_b32 s_restore_tmp, s_restore_tmp, (S_RESTORE_SPI_INIT_ATC_SHIFT-SQ_BUF_RSRC_WORD1_ATC_SHIFT) s_or_b32 s_restore_buf_rsrc3, s_restore_buf_rsrc3, s_restore_tmp //or ATC s_and_b32 s_restore_tmp, s_restore_spi_init_hi, S_RESTORE_SPI_INIT_MTYPE_MASK s_lshr_b32 s_restore_tmp, s_restore_tmp, (S_RESTORE_SPI_INIT_MTYPE_SHIFT-SQ_BUF_RSRC_WORD3_MTYPE_SHIFT) s_or_b32 s_restore_buf_rsrc3, s_restore_buf_rsrc3, s_restore_tmp //or MTYPE //determine it is wave32 or wave64 s_getreg_b32 s_restore_size, hwreg(HW_REG_IB_STS2,SQ_WAVE_IB_STS2_WAVE64_SHIFT,SQ_WAVE_IB_STS2_WAVE64_SIZE) s_lshl_b32 s_restore_size, s_restore_size, S_WAVE_SIZE s_or_b32 s_restore_size, s_restore_spi_init_hi, s_restore_size s_and_b32 s_restore_tmp, s_restore_spi_init_hi, S_RESTORE_SPI_INIT_FIRST_WAVE_MASK s_cbranch_scc0 L_RESTORE_VGPR /* restore LDS */ L_RESTORE_LDS: s_mov_b32 exec_lo, 0xFFFFFFFF //need every thread from now on s_lshr_b32 m0, s_restore_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_RESTORE_LDS_EXEC_HI s_mov_b32 exec_hi, 0x00000000 s_branch L_RESTORE_LDS_NORMAL L_ENABLE_RESTORE_LDS_EXEC_HI: s_mov_b32 exec_hi, 0xFFFFFFFF L_RESTORE_LDS_NORMAL: s_getreg_b32 s_restore_alloc_size, hwreg(HW_REG_LDS_ALLOC,SQ_WAVE_LDS_ALLOC_LDS_SIZE_SHIFT,SQ_WAVE_LDS_ALLOC_LDS_SIZE_SIZE) s_and_b32 s_restore_alloc_size, s_restore_alloc_size, 0xFFFFFFFF //lds_size is zero? s_cbranch_scc0 L_RESTORE_VGPR //no lds used? jump to L_RESTORE_VGPR s_lshl_b32 s_restore_alloc_size, s_restore_alloc_size, 6 //LDS size in dwords = lds_size * 64dw s_lshl_b32 s_restore_alloc_size, s_restore_alloc_size, 2 //LDS size in bytes s_mov_b32 s_restore_buf_rsrc2, s_restore_alloc_size //NUM_RECORDS in bytes // LDS at offset: size(VGPR)+size(SVGPR)+SIZE(SGPR)+SIZE(HWREG) // get_vgpr_size_bytes(s_restore_mem_offset, s_restore_size) get_svgpr_size_bytes(s_restore_tmp) s_add_u32 s_restore_mem_offset, s_restore_mem_offset, s_restore_tmp s_add_u32 s_restore_mem_offset, s_restore_mem_offset, get_sgpr_size_bytes() s_add_u32 s_restore_mem_offset, s_restore_mem_offset, get_hwreg_size_bytes() s_mov_b32 s_restore_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes s_lshr_b32 m0, s_wave_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_mov_b32 m0, 0x0 s_cbranch_scc1 L_RESTORE_LDS_LOOP_W64 L_RESTORE_LDS_LOOP_W32: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1 // first 64DW s_add_u32 m0, m0, 128 // 128 DW s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 128 //mem offset increased by 128DW s_cmp_lt_u32 m0, s_restore_alloc_size //scc=(m0 < s_restore_alloc_size) ? 1 : 0 s_cbranch_scc1 L_RESTORE_LDS_LOOP_W32 //LDS restore is complete? s_branch L_RESTORE_VGPR L_RESTORE_LDS_LOOP_W64: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1 // first 64DW s_add_u32 m0, m0, 256 // 256 DW s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 256 //mem offset increased by 256DW s_cmp_lt_u32 m0, s_restore_alloc_size //scc=(m0 < s_restore_alloc_size) ? 1 : 0 s_cbranch_scc1 L_RESTORE_LDS_LOOP_W64 //LDS restore is complete? /* restore VGPRs */ L_RESTORE_VGPR: // VGPR SR memory offset : 0 s_mov_b32 s_restore_mem_offset, 0x0 s_mov_b32 exec_lo, 0xFFFFFFFF //need every thread from now on s_lshr_b32 m0, s_restore_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_RESTORE_VGPR_EXEC_HI s_mov_b32 exec_hi, 0x00000000 s_branch L_RESTORE_VGPR_NORMAL L_ENABLE_RESTORE_VGPR_EXEC_HI: s_mov_b32 exec_hi, 0xFFFFFFFF L_RESTORE_VGPR_NORMAL: s_getreg_b32 s_restore_alloc_size, hwreg(HW_REG_GPR_ALLOC,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SHIFT,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SIZE) s_add_u32 s_restore_alloc_size, s_restore_alloc_size, 1 s_lshl_b32 s_restore_alloc_size, s_restore_alloc_size, 2 //Number of VGPRs = (vgpr_size + 1) * 4 (non-zero value) //determine it is wave32 or wave64 s_lshr_b32 m0, s_restore_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_RESTORE_VGPR_WAVE64 s_mov_b32 s_restore_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR load using dw burst s_mov_b32 s_restore_mem_offset_save, s_restore_mem_offset // restore start with v1, v0 will be the last s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 128*4 s_mov_b32 m0, 4 //VGPR initial index value = 4 L_RESTORE_VGPR_WAVE32_LOOP: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:128 buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:128*2 buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:128*3 s_waitcnt vmcnt(0) v_movreld_b32 v0, v0 //v[0+m0] = v0 v_movreld_b32 v1, v1 v_movreld_b32 v2, v2 v_movreld_b32 v3, v3 s_add_u32 m0, m0, 4 //next vgpr index s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 128*4 //every buffer_load_dword does 128 bytes s_cmp_lt_u32 m0, s_restore_alloc_size //scc = (m0 < s_restore_alloc_size) ? 1 : 0 s_cbranch_scc1 L_RESTORE_VGPR_WAVE32_LOOP //VGPR restore (except v0) is complete? /* VGPR restore on v0 */ buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:128 buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:128*2 buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:128*3 s_branch L_RESTORE_SGPR L_RESTORE_VGPR_WAVE64: s_mov_b32 s_restore_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes // VGPR load using dw burst s_mov_b32 s_restore_mem_offset_save, s_restore_mem_offset // restore start with v4, v0 will be the last s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 256*4 s_mov_b32 m0, 4 //VGPR initial index value = 4 L_RESTORE_VGPR_WAVE64_LOOP: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256 buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*2 buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*3 s_waitcnt vmcnt(0) v_movreld_b32 v0, v0 //v[0+m0] = v0 v_movreld_b32 v1, v1 v_movreld_b32 v2, v2 v_movreld_b32 v3, v3 s_add_u32 m0, m0, 4 //next vgpr index s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 256*4 //every buffer_load_dword does 256 bytes s_cmp_lt_u32 m0, s_restore_alloc_size //scc = (m0 < s_restore_alloc_size) ? 1 : 0 s_cbranch_scc1 L_RESTORE_VGPR_WAVE64_LOOP //VGPR restore (except v0) is complete? //Below part will be the restore shared vgpr part (new for gfx10) s_getreg_b32 s_restore_alloc_size, hwreg(HW_REG_LDS_ALLOC,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SHIFT,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SIZE) //shared_vgpr_size s_and_b32 s_restore_alloc_size, s_restore_alloc_size, 0xFFFFFFFF //shared_vgpr_size is zero? s_cbranch_scc0 L_RESTORE_V0 //no shared_vgpr used? s_lshl_b32 s_restore_alloc_size, s_restore_alloc_size, 3 //Number of SHARED_VGPRs = shared_vgpr_size * 8 (non-zero value) //m0 now has the value of normal vgpr count, just add the m0 with shared_vgpr count to get the total count. //restore shared_vgpr will start from the index of m0 s_add_u32 s_restore_alloc_size, s_restore_alloc_size, m0 s_mov_b32 exec_lo, 0xFFFFFFFF s_mov_b32 exec_hi, 0x00000000 L_RESTORE_SHARED_VGPR_WAVE64_LOOP: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 s_waitcnt vmcnt(0) v_movreld_b32 v0, v0 //v[0+m0] = v0 s_add_u32 m0, m0, 1 //next vgpr index s_add_u32 s_restore_mem_offset, s_restore_mem_offset, 128 s_cmp_lt_u32 m0, s_restore_alloc_size //scc = (m0 < s_restore_alloc_size) ? 1 : 0 s_cbranch_scc1 L_RESTORE_SHARED_VGPR_WAVE64_LOOP //VGPR restore (except v0) is complete? s_mov_b32 exec_hi, 0xFFFFFFFF //restore back exec_hi before restoring V0!! /* VGPR restore on v0 */ L_RESTORE_V0: buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256 buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*2 buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save slc:1 glc:1 offset:256*3 s_waitcnt vmcnt(0) /* restore SGPRs */ //will be 2+8+16*6 // SGPR SR memory offset : size(VGPR)+size(SVGPR) L_RESTORE_SGPR: get_vgpr_size_bytes(s_restore_mem_offset, s_restore_size) get_svgpr_size_bytes(s_restore_tmp) s_add_u32 s_restore_mem_offset, s_restore_mem_offset, s_restore_tmp s_add_u32 s_restore_mem_offset, s_restore_mem_offset, get_sgpr_size_bytes() s_sub_u32 s_restore_mem_offset, s_restore_mem_offset, 20*4 //s108~s127 is not saved s_mov_b32 s_restore_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes s_mov_b32 m0, s_sgpr_save_num read_4sgpr_from_mem(s0, s_restore_buf_rsrc0, s_restore_mem_offset) s_waitcnt lgkmcnt(0) s_sub_u32 m0, m0, 4 // Restore from S[0] to S[104] s_nop 0 // hazard SALU M0=> S_MOVREL s_movreld_b64 s0, s0 //s[0+m0] = s0 s_movreld_b64 s2, s2 read_8sgpr_from_mem(s0, s_restore_buf_rsrc0, s_restore_mem_offset) s_waitcnt lgkmcnt(0) s_sub_u32 m0, m0, 8 // Restore from S[0] to S[96] s_nop 0 // hazard SALU M0=> S_MOVREL s_movreld_b64 s0, s0 //s[0+m0] = s0 s_movreld_b64 s2, s2 s_movreld_b64 s4, s4 s_movreld_b64 s6, s6 L_RESTORE_SGPR_LOOP: read_16sgpr_from_mem(s0, s_restore_buf_rsrc0, s_restore_mem_offset) s_waitcnt lgkmcnt(0) s_sub_u32 m0, m0, 16 // Restore from S[n] to S[0] s_nop 0 // hazard SALU M0=> S_MOVREL s_movreld_b64 s0, s0 //s[0+m0] = s0 s_movreld_b64 s2, s2 s_movreld_b64 s4, s4 s_movreld_b64 s6, s6 s_movreld_b64 s8, s8 s_movreld_b64 s10, s10 s_movreld_b64 s12, s12 s_movreld_b64 s14, s14 s_cmp_eq_u32 m0, 0 //scc = (m0 < s_sgpr_save_num) ? 1 : 0 s_cbranch_scc0 L_RESTORE_SGPR_LOOP /* restore HW registers */ L_RESTORE_HWREG: // HWREG SR memory offset : size(VGPR)+size(SVGPR)+size(SGPR) get_vgpr_size_bytes(s_restore_mem_offset, s_restore_size) get_svgpr_size_bytes(s_restore_tmp) s_add_u32 s_restore_mem_offset, s_restore_mem_offset, s_restore_tmp s_add_u32 s_restore_mem_offset, s_restore_mem_offset, get_sgpr_size_bytes() s_mov_b32 s_restore_buf_rsrc2, 0x1000000 //NUM_RECORDS in bytes read_hwreg_from_mem(s_restore_m0, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_pc_lo, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_pc_hi, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_exec_lo, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_exec_hi, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_status, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_trapsts, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_xnack_mask, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_mode, s_restore_buf_rsrc0, s_restore_mem_offset) read_hwreg_from_mem(s_restore_flat_scratch, s_restore_buf_rsrc0, s_restore_mem_offset) s_waitcnt lgkmcnt(0) s_setreg_b32 hwreg(HW_REG_SHADER_FLAT_SCRATCH_LO), s_restore_flat_scratch read_hwreg_from_mem(s_restore_flat_scratch, s_restore_buf_rsrc0, s_restore_mem_offset) s_waitcnt lgkmcnt(0) //from now on, it is safe to restore STATUS and IB_STS s_setreg_b32 hwreg(HW_REG_SHADER_FLAT_SCRATCH_HI), s_restore_flat_scratch s_mov_b32 s_restore_tmp, s_restore_pc_hi s_and_b32 s_restore_pc_hi, s_restore_tmp, 0x0000ffff //pc[47:32] //Do it here in order not to affect STATUS s_mov_b32 m0, s_restore_m0 s_mov_b32 exec_lo, s_restore_exec_lo s_mov_b32 exec_hi, s_restore_exec_hi s_and_b32 s_restore_m0, SQ_WAVE_TRAPSTS_PRE_SAVECTX_MASK, s_restore_trapsts s_setreg_b32 hwreg(HW_REG_TRAPSTS, SQ_WAVE_TRAPSTS_PRE_SAVECTX_SHIFT, SQ_WAVE_TRAPSTS_PRE_SAVECTX_SIZE), s_restore_m0 s_setreg_b32 hwreg(HW_REG_SHADER_XNACK_MASK), s_restore_xnack_mask s_and_b32 s_restore_m0, SQ_WAVE_TRAPSTS_POST_SAVECTX_MASK, s_restore_trapsts s_lshr_b32 s_restore_m0, s_restore_m0, SQ_WAVE_TRAPSTS_POST_SAVECTX_SHIFT s_setreg_b32 hwreg(HW_REG_TRAPSTS, SQ_WAVE_TRAPSTS_POST_SAVECTX_SHIFT, SQ_WAVE_TRAPSTS_POST_SAVECTX_SIZE), s_restore_m0 s_setreg_b32 hwreg(HW_REG_MODE), s_restore_mode s_and_b32 s_restore_m0, s_restore_tmp, S_SAVE_PC_HI_RCNT_MASK s_lshr_b32 s_restore_m0, s_restore_m0, S_SAVE_PC_HI_RCNT_SHIFT s_lshl_b32 s_restore_m0, s_restore_m0, SQ_WAVE_IB_STS_RCNT_SHIFT s_mov_b32 s_restore_mode, 0x0 s_or_b32 s_restore_mode, s_restore_mode, s_restore_m0 s_and_b32 s_restore_m0, s_restore_tmp, S_SAVE_PC_HI_FIRST_REPLAY_MASK s_lshr_b32 s_restore_m0, s_restore_m0, S_SAVE_PC_HI_FIRST_REPLAY_SHIFT s_lshl_b32 s_restore_m0, s_restore_m0, SQ_WAVE_IB_STS_FIRST_REPLAY_SHIFT s_or_b32 s_restore_mode, s_restore_mode, s_restore_m0 s_and_b32 s_restore_m0, s_restore_tmp, S_SAVE_PC_HI_REPLAY_W64H_MASK s_lshr_b32 s_restore_m0, s_restore_m0, S_SAVE_PC_HI_REPLAY_W64H_SHIFT s_lshl_b32 s_restore_m0, s_restore_m0, SQ_WAVE_IB_STS_REPLAY_W64H_SHIFT s_or_b32 s_restore_mode, s_restore_mode, s_restore_m0 s_and_b32 s_restore_m0, s_restore_status, SQ_WAVE_STATUS_INST_ATC_MASK s_lshr_b32 s_restore_m0, s_restore_m0, SQ_WAVE_STATUS_INST_ATC_SHIFT s_setreg_b32 hwreg(HW_REG_IB_STS), s_restore_mode s_and_b64 exec, exec, exec // Restore STATUS.EXECZ, not writable by s_setreg_b32 s_and_b64 vcc, vcc, vcc // Restore STATUS.VCCZ, not writable by s_setreg_b32 s_setreg_b32 hwreg(HW_REG_STATUS), s_restore_status // SCC is included, which is changed by previous salu s_barrier //barrier to ensure the readiness of LDS before access attemps from any other wave in the same TG s_rfe_b64 s_restore_pc_lo //Return to the main shader program and resume execution L_END_PGM: s_endpgm end function write_hwreg_to_mem(s, s_rsrc, s_mem_offset) s_mov_b32 exec_lo, m0 s_mov_b32 m0, s_mem_offset s_buffer_store_dword s, s_rsrc, m0 glc:1 s_add_u32 s_mem_offset, s_mem_offset, 4 s_mov_b32 m0, exec_lo end function write_16sgpr_to_mem(s, s_rsrc, s_mem_offset) s_buffer_store_dwordx4 s[0], s_rsrc, 0 glc:1 s_buffer_store_dwordx4 s[4], s_rsrc, 16 glc:1 s_buffer_store_dwordx4 s[8], s_rsrc, 32 glc:1 s_buffer_store_dwordx4 s[12], s_rsrc, 48 glc:1 s_add_u32 s_rsrc[0], s_rsrc[0], 4*16 s_addc_u32 s_rsrc[1], s_rsrc[1], 0x0 end function write_12sgpr_to_mem(s, s_rsrc, s_mem_offset) s_buffer_store_dwordx4 s[0], s_rsrc, 0 glc:1 s_buffer_store_dwordx4 s[4], s_rsrc, 16 glc:1 s_buffer_store_dwordx4 s[8], s_rsrc, 32 glc:1 s_add_u32 s_rsrc[0], s_rsrc[0], 4*12 s_addc_u32 s_rsrc[1], s_rsrc[1], 0x0 end function read_hwreg_from_mem(s, s_rsrc, s_mem_offset) s_buffer_load_dword s, s_rsrc, s_mem_offset glc:1 s_add_u32 s_mem_offset, s_mem_offset, 4 end function read_16sgpr_from_mem(s, s_rsrc, s_mem_offset) s_sub_u32 s_mem_offset, s_mem_offset, 4*16 s_buffer_load_dwordx16 s, s_rsrc, s_mem_offset glc:1 end function read_8sgpr_from_mem(s, s_rsrc, s_mem_offset) s_sub_u32 s_mem_offset, s_mem_offset, 4*8 s_buffer_load_dwordx8 s, s_rsrc, s_mem_offset glc:1 end function read_4sgpr_from_mem(s, s_rsrc, s_mem_offset) s_sub_u32 s_mem_offset, s_mem_offset, 4*4 s_buffer_load_dwordx4 s, s_rsrc, s_mem_offset glc:1 end function get_lds_size_bytes(s_lds_size_byte) s_getreg_b32 s_lds_size_byte, hwreg(HW_REG_LDS_ALLOC, SQ_WAVE_LDS_ALLOC_LDS_SIZE_SHIFT, SQ_WAVE_LDS_ALLOC_LDS_SIZE_SIZE) s_lshl_b32 s_lds_size_byte, s_lds_size_byte, 8 //LDS size in dwords = lds_size * 64 *4Bytes // granularity 64DW end function get_vgpr_size_bytes(s_vgpr_size_byte, s_size) s_getreg_b32 s_vgpr_size_byte, hwreg(HW_REG_GPR_ALLOC,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SHIFT,SQ_WAVE_GPR_ALLOC_VGPR_SIZE_SIZE) s_add_u32 s_vgpr_size_byte, s_vgpr_size_byte, 1 s_lshr_b32 m0, s_size, S_WAVE_SIZE s_and_b32 m0, m0, 1 s_cmp_eq_u32 m0, 1 s_cbranch_scc1 L_ENABLE_SHIFT_W64 s_lshl_b32 s_vgpr_size_byte, s_vgpr_size_byte, (2+7) //Number of VGPRs = (vgpr_size + 1) * 4 * 32 * 4 (non-zero value) s_branch L_SHIFT_DONE L_ENABLE_SHIFT_W64: s_lshl_b32 s_vgpr_size_byte, s_vgpr_size_byte, (2+8) //Number of VGPRs = (vgpr_size + 1) * 4 * 64 * 4 (non-zero value) L_SHIFT_DONE: end function get_svgpr_size_bytes(s_svgpr_size_byte) s_getreg_b32 s_svgpr_size_byte, hwreg(HW_REG_LDS_ALLOC,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SHIFT,SQ_WAVE_LDS_ALLOC_VGPR_SHARED_SIZE_SIZE) s_lshl_b32 s_svgpr_size_byte, s_svgpr_size_byte, (3+7) end function get_sgpr_size_bytes return 512 end function get_hwreg_size_bytes return 128 end ",16350,True,3334.5609889462276,median "/* HelloWorld.ino ""Hello World"" version for U8x8 API Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif // Please UNCOMMENT one of the contructor lines below // U8x8 Contructor List // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing //U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 6, /* dc=*/ 4, /* reset=*/ 12); // Arduboy (DevKit) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy 10 (Production, Kickstarter Edition) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_HW_SPI u8x8(/* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); // Digispark ATTiny85 //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display //U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SSD1306_128X64_ALT0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_102X64_EA_OLEDS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SH1106_128X64_WINSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8X8_SH1106_128X32_VISIONOX_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X32_VISIONOX_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_72X40_WISE_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_64X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_PIMORONI_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_SEEED_128X128_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_128X128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1108_160X160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_128X32_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_64X48_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8X8_SSD1306_48X64_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_1F_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_96X16_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" //U8X8_SSD1306_72X40_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" //U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1317_96X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1317_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1318_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1318_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1326_ER_256X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8X8_SSD1327_SEEED_96X96_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_SEEED_96X96_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_EA_W128128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_EA_W128128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ A4, /* dc=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather 32u4 Basic Proto //U8X8_SSD1305_128X32_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_HD44102_100X64 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_T7932_150X32 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCD8544_84X48_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCF8812_96X65_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_PCF8812_96X65_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_HX1230_96X68_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_HX1230_96X68_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_EA_DOGM132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_ZOLEN_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ZOLEN_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LM6059_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_LM6059_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_KS0713_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_KS0713_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_LX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_ALT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_ERC12864_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_PI_132X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_PI_132X64_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_64X32_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7567_HEM6432_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7571_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX25664_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C //U8X8_ST75320_JLX320240_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75320_JLX320240_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7588_JLX12864_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8X8_ST7588_JLX12864_HW_I2C u8x8(/* reset=*/ 5); //U8X8_IST3020_ERC19264_6800 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8X8_IST3020_ERC19264_8080 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8X8_IST3020_ERC19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_IST7920_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_IST7920_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_UC1601_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1601_128X32_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_UC1601_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_ERC24064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_DEM240064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_ERC240120_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_240X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1610_EA_DOGXL160_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1610_EA_DOGXL160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1611_EA_DOGM240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_IDS4073_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_IDS4073_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_SW_I2C u8x8(/* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); // u8g2 test board: I2C clock/data is same as SPI, I2C default address is 0x78 //U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8X8_SSD1607_GS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8X8_SSD1607_WS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8X8_IL3820_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT //U8X8_IL3820_V2_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, optimized (lesser screen flicker) //U8X8_ST7511_AVD_320X240_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Connect RD pin with 3.3V/5V //U8X8_S1D15721_240X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_S1D15721_240X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); u8x8.begin(); u8x8.setPowerSave(0); } void loop(void) { u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.drawString(0,1,""Hello World!""); u8x8.drawString(0,0,""Line 0""); u8x8.drawString(0,8,""Line 8""); u8x8.drawString(0,9,""Line 9""); u8x8.refreshDisplay(); // only required for SSD1606/7 delay(2000); } ",12401,True,3667.6927863549136,median "/* GraphicsTest.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! // End of constructor list void u8g2_prepare(void) { u8g2.setFont(u8g2_font_6x10_tf); u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); u8g2.setFontPosTop(); u8g2.setFontDirection(0); } void u8g2_box_title(uint8_t a) { u8g2.drawStr( 10+a*2, 5, ""U8g2""); u8g2.drawStr( 10, 20, ""GraphicsTest""); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); } void u8g2_box_frame(uint8_t a) { u8g2.drawStr( 0, 0, ""drawBox""); u8g2.drawBox(5,10,20,10); u8g2.drawBox(10+a,15,30,7); u8g2.drawStr( 0, 30, ""drawFrame""); u8g2.drawFrame(5,10+30,20,10); u8g2.drawFrame(10+a,15+30,30,7); } void u8g2_disc_circle(uint8_t a) { u8g2.drawStr( 0, 0, ""drawDisc""); u8g2.drawDisc(10,18,9); u8g2.drawDisc(24+a,16,7); u8g2.drawStr( 0, 30, ""drawCircle""); u8g2.drawCircle(10,18+30,9); u8g2.drawCircle(24+a,16+30,7); } void u8g2_r_frame(uint8_t a) { u8g2.drawStr( 0, 0, ""drawRFrame/Box""); u8g2.drawRFrame(5, 10,40,30, a+1); u8g2.drawRBox(50, 10,25,40, a+1); } void u8g2_string(uint8_t a) { u8g2.setFontDirection(0); u8g2.drawStr(30+a,31, "" 0""); u8g2.setFontDirection(1); u8g2.drawStr(30,31+a, "" 90""); u8g2.setFontDirection(2); u8g2.drawStr(30-a,31, "" 180""); u8g2.setFontDirection(3); u8g2.drawStr(30,31-a, "" 270""); } void u8g2_line(uint8_t a) { u8g2.drawStr( 0, 0, ""drawLine""); u8g2.drawLine(7+a, 10, 40, 55); u8g2.drawLine(7+a*2, 10, 60, 55); u8g2.drawLine(7+a*3, 10, 80, 55); u8g2.drawLine(7+a*4, 10, 100, 55); } void u8g2_triangle(uint8_t a) { uint16_t offset = a; u8g2.drawStr( 0, 0, ""drawTriangle""); u8g2.drawTriangle(14,7, 45,30, 10,40); u8g2.drawTriangle(14+offset,7-offset, 45+offset,30-offset, 57+offset,10-offset); u8g2.drawTriangle(57+offset*2,10, 45+offset*2,30, 86+offset*2,53); u8g2.drawTriangle(10+offset,40+offset, 45+offset,30+offset, 86+offset,53+offset); } void u8g2_ascii_1() { char s[2] = "" ""; uint8_t x, y; u8g2.drawStr( 0, 0, ""ASCII page 1""); for( y = 0; y < 6; y++ ) { for( x = 0; x < 16; x++ ) { s[0] = y*16 + x + 32; u8g2.drawStr(x*7, y*10+10, s); } } } void u8g2_ascii_2() { char s[2] = "" ""; uint8_t x, y; u8g2.drawStr( 0, 0, ""ASCII page 2""); for( y = 0; y < 6; y++ ) { for( x = 0; x < 16; x++ ) { s[0] = y*16 + x + 160; u8g2.drawStr(x*7, y*10+10, s); } } } void u8g2_extra_page(uint8_t a) { u8g2.drawStr( 0, 0, ""Unicode""); u8g2.setFont(u8g2_font_unifont_t_symbols); u8g2.setFontPosTop(); u8g2.drawUTF8(0, 24, ""☀ ☁""); switch(a) { case 0: case 1: case 2: case 3: u8g2.drawUTF8(a*3, 36, ""☂""); break; case 4: case 5: case 6: case 7: u8g2.drawUTF8(a*3, 36, ""☔""); break; } } void u8g2_xor(uint8_t a) { uint8_t i; u8g2.drawStr( 0, 0, ""XOR""); u8g2.setFontMode(1); u8g2.setDrawColor(2); for( i = 0; i < 5; i++) { u8g2.drawBox(10+i*16, 18 + (i&1)*4, 21,31); } u8g2.drawStr( 5+a, 19, ""XOR XOR XOR XOR""); u8g2.setDrawColor(0); u8g2.drawStr( 5+a, 29, ""CLR CLR CLR CLR""); u8g2.setDrawColor(1); u8g2.drawStr( 5+a, 39, ""SET SET SET SET""); u8g2.setFontMode(0); } #define cross_width 24 #define cross_height 24 static const unsigned char cross_bits[] U8X8_PROGMEM = { 0x00, 0x18, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0xC0, 0x00, 0x03, 0x38, 0x3C, 0x1C, 0x06, 0x42, 0x60, 0x01, 0x42, 0x80, 0x01, 0x42, 0x80, 0x06, 0x42, 0x60, 0x38, 0x3C, 0x1C, 0xC0, 0x00, 0x03, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x18, 0x00, }; #define cross_fill_width 24 #define cross_fill_height 24 static const unsigned char cross_fill_bits[] U8X8_PROGMEM = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x18, 0x64, 0x00, 0x26, 0x84, 0x00, 0x21, 0x08, 0x81, 0x10, 0x08, 0x42, 0x10, 0x10, 0x3C, 0x08, 0x20, 0x00, 0x04, 0x40, 0x00, 0x02, 0x80, 0x00, 0x01, 0x80, 0x18, 0x01, 0x80, 0x18, 0x01, 0x80, 0x00, 0x01, 0x40, 0x00, 0x02, 0x20, 0x00, 0x04, 0x10, 0x3C, 0x08, 0x08, 0x42, 0x10, 0x08, 0x81, 0x10, 0x84, 0x00, 0x21, 0x64, 0x00, 0x26, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; #define cross_block_width 14 #define cross_block_height 14 static const unsigned char cross_block_bits[] U8X8_PROGMEM = { 0xFF, 0x3F, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0xC1, 0x20, 0xC1, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0x01, 0x20, 0xFF, 0x3F, }; void u8g2_bitmap_overlay(uint8_t a) { uint8_t frame_size = 28; u8g2.drawStr(0, 0, ""Bitmap overlay""); u8g2.drawStr(0, frame_size + 12, ""Solid / transparent""); u8g2.setBitmapMode(false /* solid */); u8g2.drawFrame(0, 10, frame_size, frame_size); u8g2.drawXBMP(2, 12, cross_width, cross_height, cross_bits); if(a & 4) u8g2.drawXBMP(7, 17, cross_block_width, cross_block_height, cross_block_bits); u8g2.setBitmapMode(true /* transparent*/); u8g2.drawFrame(frame_size + 5, 10, frame_size, frame_size); u8g2.drawXBMP(frame_size + 7, 12, cross_width, cross_height, cross_bits); if(a & 4) u8g2.drawXBMP(frame_size + 12, 17, cross_block_width, cross_block_height, cross_block_bits); } void u8g2_bitmap_modes(uint8_t transparent) { const uint8_t frame_size = 24; u8g2.drawBox(0, frame_size * 0.5, frame_size * 5, frame_size); u8g2.drawStr(frame_size * 0.5, 50, ""Black""); u8g2.drawStr(frame_size * 2, 50, ""White""); u8g2.drawStr(frame_size * 3.5, 50, ""XOR""); if(!transparent) { u8g2.setBitmapMode(false /* solid */); u8g2.drawStr(0, 0, ""Solid bitmap""); } else { u8g2.setBitmapMode(true /* transparent*/); u8g2.drawStr(0, 0, ""Transparent bitmap""); } u8g2.setDrawColor(0);// Black u8g2.drawXBMP(frame_size * 0.5, 24, cross_width, cross_height, cross_bits); u8g2.setDrawColor(1); // White u8g2.drawXBMP(frame_size * 2, 24, cross_width, cross_height, cross_bits); u8g2.setDrawColor(2); // XOR u8g2.drawXBMP(frame_size * 3.5, 24, cross_width, cross_height, cross_bits); } uint8_t draw_state = 0; void draw(void) { u8g2_prepare(); switch(draw_state >> 3) { case 0: u8g2_box_title(draw_state&7); break; case 1: u8g2_box_frame(draw_state&7); break; case 2: u8g2_disc_circle(draw_state&7); break; case 3: u8g2_r_frame(draw_state&7); break; case 4: u8g2_string(draw_state&7); break; case 5: u8g2_line(draw_state&7); break; case 6: u8g2_triangle(draw_state&7); break; case 7: u8g2_ascii_1(); break; case 8: u8g2_ascii_2(); break; case 9: u8g2_extra_page(draw_state&7); break; case 10: u8g2_xor(draw_state&7); break; case 11: u8g2_bitmap_modes(0); break; case 12: u8g2_bitmap_modes(1); break; case 13: u8g2_bitmap_overlay(draw_state&7); break; } } void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); u8g2.begin(); //u8g2.setFlipMode(0); } void loop(void) { // picture loop u8g2.firstPage(); do { draw(); } while( u8g2.nextPage() ); // increase the state draw_state++; if ( draw_state >= 14*8 ) draw_state = 0; // delay between each page delay(150); } ",12089,False,2358.8751743120133,median "/* ExtUTF8.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); u8g2.begin(); } const uint16_t my_kerning_table[] = { /* first char, second char, gap reduction value */ 0x646, 0x627, 4, /* ن and ا */ 0x627, 0x647, 5, /* ا and ه */ 0x647, 0x62C, 6, /* ه and ج */ 0x645, 0x627, 3, /* م and ا */ 0x627, 0x644, 4, /* ا and ل */ 0x644, 0x633, 2, /* ل and س */ /* this line terminates the table */ 0xffff, 0xffff, 0xffff }; void loop(void) { u8g2.firstPage(); do { u8g2.setFont(u8g2_font_unifont_t_arabic); u8g2.drawExtUTF8(120, 15, 1, NULL, ""سلام جهان""); /* Hello World */ u8g2.drawExtUTF8(120, 30, 1, my_kerning_table, ""سلام جهان""); /* Hello World */ } while ( u8g2.nextPage() ); //delay(1000); } ",12199,True,3645.310511698593,median "/* Sketch for SI4733-A10 / Si4735-G60 based receiver with Morse Code Readout I dedicate this sketch to all blind radio amateurs. This sketch SHOULD work with the Chinese KIT sold on AliExpress, eBay and Amazon The author of this sketch and Arduino Library does not know the seller of this kit and does not have a commercial relationship with any commercial product that uses the Arduino Library. It is important you understand that there is no guarantee that this sketch will work correctly in your current product. SO, DO NOT TRY IT IF YOU DON'T KNOW WHAT ARE YOU DOING. YOU MUST BE ABLE TO GO BACK TO THE PREVIOUS VERSION IF THIS SKETCH DOES NOT WORK FOR YOU. Please, read the user_manual.txt for more details about this sketch. ATTENTION: Turn your receiver on with the encoder push button pressed at first time to RESET the eeprom content. ARDUINO LIBRARIES: 1) This sketch uses the Rotary Encoder Class implementation from Ben Buxton (the source code is included together with this sketch). You do not need to install it; 2) Tiny4kOLED Library and TinyOLED-Fonts (on your Arduino IDE, look for this library on Tools->Manage Libraries). 3) PU2CLR SI4735 Arduino Library (on your Arduino IDE look for this library on Tools->Manage Libraries). ABOUT THE EEPROM: ATMEL says the lifetime of an EEPROM memory position is about 100,000 writes. For this reason, this sketch tries to avoid save unnecessary writes into the eeprom. So, the condition to store any status of the receiver is changing the frequency, bandwidth, volume, band or step and 10 seconds of inactivity. For example, if you switch the band and turn the receiver off immediately, no new information will be written into the eeprom. But you wait 10 seconds after changing anything, all new information will be written. ABOUT SSB PATCH: First of all, it is important to say that the SSB patch content is not part of this library. The paches used here were made available by Mr. Vadim Afonkin on his Dropbox repository. It is important to note that the author of this library does not encourage anyone to use the SSB patches content for commercial purposes. In other words, this library only supports SSB patches, the patches themselves are not part of this library. In this context, a patch is a piece of software used to change the behavior of the SI4735 device. There is little information available about patching the SI4735 or Si4732 devices. The following information is the understanding of the author of this project and it is not necessarily correct. A patch is executed internally (run by internal MCU) of the device. Usually, patches are used to fixes bugs or add improvements and new features of the firmware installed in the internal ROM of the device. Patches to the SI473X are distributed in binary form and have to be transferred to the internal RAM of the device by the host MCU (in this case Arduino). Since the RAM is volatile memory, the patch stored into the device gets lost when you turn off the system. Consequently, the content of the patch has to be transferred again to the device each time after turn on the system or reset the device. Wire up on Arduino UNO, Pro mini and SI4735-D60 | Device name | Device Pin / Description | Arduino Pin | | ---------------- | ----------------------------- | ------------ | | Display OLED | | | | | SDA | A4 | | | CLK | A5 | | (*1) SI4735 | | | | | RESET (pin 15) | 12 | | | SDIO (pin 18) | A4 | | | SCLK (pin 17) | A5 | | | SEN (pin 16) | GND | | (*2) Buttons | | | | | Switch MODE (AM/LSB/AM) | 4 | | | Banddwith | 5 | | | Volume | 6 | | | Custom button 1 (*3) | 7 | | | Band | 8 | | | Custom button 2 (*3) | 9 | | | Step | 10 | | | AGC / Attentuation | 11 | | Buzzy/ Speaker | | | | | pin + | 13 | | | pin - | GND | | | VFO/VFO Switch (Encoder) | 14 / A0 | | Encoder (*4) | | | | | A | 2 | | | B | 3 | *1 - You can use the SI4732-A10. Check on the SI4732 package the pins: RESET, SDIO, SCLK and SEN. *2 - Please, read the file user_manual.txt for more detail. *3 - You can remove this buttons from your circuit and sketch if you dont want to use them. *4 - Some encoder devices have pins A and B inverted. So, if the clockwise and counterclockwise directions are not correct for you, please, invert the settings for pins A and B. Prototype documentation: https://pu2clr.github.io/SI4735/ PU2CLR Si47XX API documentation: https://pu2clr.github.io/SI4735/extras/apidoc/html/ By Ricardo Lima Caratti, April 2021. */ #include #include #include #include // Please, install the TinyOLED-Fonts library #include ""Rotary.h"" #include ""patch_ssb_compressed.h"" // Compressed SSB patch version (saving almost 1KB) const uint16_t size_content = sizeof ssb_patch_content; // See ssb_patch_content.h const uint16_t cmd_0x15_size = sizeof cmd_0x15; // Array of lines where the 0x15 command occurs in the patch content. #define FM_BAND_TYPE 0 #define MW_BAND_TYPE 1 #define SW_BAND_TYPE 2 #define LW_BAND_TYPE 3 // OLED Diaplay constants #define RST_PIN -1 // Define proper RST_PIN if required. #define RESET_PIN 12 // Morse defined constants #define BUZZY_PIN 13 // Buzzy pin #define CW_TONE 900 // CW tone (audio frequency) #define DELAY_DOT 50 // dot time #define DELAY_BETWEEN_DASH_DOT DELAY_DOT * 4 #define DELAY_DASH DELAY_DOT * 3 // dash time #define DELAY_SPACE DELAY_DOT * 7 // space delay #define DELAY_CHAR DELAY_DOT * 6 // delay between dashes / dots // Enconder PINs - if the clockwise and counterclockwise directions are not correct for you, please, invert this settings. #define ENCODER_PIN_A 2 #define ENCODER_PIN_B 3 // Buttons controllers #define MODE_SWITCH 4 // Switch MODE (Am/LSB/USB) #define BANDWIDTH_BUTTON 5 // Used to select the banddwith. #define VOLUME_BUTTON 6 // Volume Up #define CW_READOUT_BUTTON 7 // **** Use thi button to implement a new function #define BAND_BUTTON 8 // Next band #define SOFTMUTE_BUTTON 9 // **** Use thi button to implement a new function #define AGC_BUTTON 11 // Switch AGC ON/OF #define STEP_BUTTON 10 // Used to select the increment or decrement frequency step (see tabStep) #define ENCODER_BUTTON 14 // Used to select the enconder control (BFO or VFO) and SEEK function on AM and FM modes #define MIN_ELAPSED_TIME 100 #define MIN_ELAPSED_RSSI_TIME 150 #define DEFAULT_VOLUME 45 // change it for your favorite sound volume #define FM 0 #define LSB 1 #define USB 2 #define AM 3 #define LW 4 #define SSB 1 #define STORE_TIME 10000 // Time of inactivity to make the current receiver status writable (10s / 10000 milliseconds). const uint8_t app_id = 43; // Useful to check the EEPROM content before processing useful data const int eeprom_address = 0; long storeTime = millis(); const char *bandModeDesc[] = {""FM "", ""LSB"", ""USB"", ""AM ""}; uint8_t currentMode = FM; uint8_t seekDirection = 1; bool bfoOn = false; bool ssbLoaded = false; bool fmStereo = true; bool cmdVolume = false; // if true, the encoder will control the volume. bool cmdAgcAtt = false; // if true, the encoder will control the AGC / Attenuation bool cmdStep = false; // if true, the encoder will control the step frequency bool cmdBw = false; // if true, the encoder will control the bandwidth bool cmdBand = false; // if true, the encoder will control the band bool cmdSoftMute = false; // if true, the encoder will control the Soft Mute attenuation long countRSSI = 0; int currentBFO = 0; long elapsedRSSI = millis(); long elapsedButton = millis(); // Encoder control variables volatile int encoderCount = 0; // Some variables to check the SI4735 status uint16_t currentFrequency; uint16_t previousFrequency; // uint8_t currentStep = 1; uint8_t currentBFOStep = 25; // Datatype to deal with bandwidth on AM, SSB and FM in numerical order. // Ordering by bandwidth values. typedef struct { uint8_t idx; // SI473X device bandwidth index value const char *desc; // bandwidth description } Bandwidth; int8_t bwIdxSSB = 4; Bandwidth bandwidthSSB[] = { {4, ""0.5""}, // 0 {5, ""1.0""}, // 1 {0, ""1.2""}, // 2 {1, ""2.2""}, // 3 {2, ""3.0""}, // 4 - default {3, ""4.0""} // 5 }; // 3 = 4kHz int8_t bwIdxAM = 4; const int maxFilterAM = 6; Bandwidth bandwidthAM[] = { {4, ""1.0""}, // 0 {5, ""1.8""}, // 1 {3, ""2.0""}, // 2 {6, ""2.5""}, // 3 {2, ""3.0""}, // 4 - default {1, ""4.0""}, // 5 {0, ""6.0""} // 6 }; int8_t bwIdxFM = 0; Bandwidth bandwidthFM[] = { {0, ""AUT""}, // Automatic - default {1, ""110""}, // Force wide (110 kHz) channel filter. {2, "" 84""}, {3, "" 60""}, {4, "" 40""}}; // Atenuação and AGC int8_t agcIdx = 0; uint8_t disableAgc = 0; uint8_t agcNdx = 0; int8_t smIdx = 8; int tabStep[] = {1, // 0 5, // 1 9, // 2 10, // 3 50, // 4 100}; // 5 const int lastStep = (sizeof tabStep / sizeof(int)) - 1; int idxStep = 3; /* Band data structure */ typedef struct { uint8_t bandType; // Band type (FM, MW or SW) uint16_t minimumFreq; // Minimum frequency of the band uint16_t maximumFreq; // maximum frequency of the band uint16_t currentFreq; // Default frequency or current frequency uint16_t currentStepIdx; // Idex of tabStep: Defeult frequency step (See tabStep) int8_t bandwidthIdx; // Index of the table bandwidthFM, bandwidthAM or bandwidthSSB; } Band; /* Band table To add a new band, all you have to do is insert a new line in the table below. No extra code will be needed. Remove or comment a line if you do not want a given band You have to RESET the eeprom after modiging this table. Turn your receiver on with the encoder push button pressed at first time to RESET the eeprom content. */ Band band[] = { {FM_BAND_TYPE, 6400, 8400, 7000, 3, 0}, // FM from 64 to 84 MHz {FM_BAND_TYPE, 8400, 10800, 10570, 3, 0}, {LW_BAND_TYPE, 100, 510, 300, 0, 4}, {MW_BAND_TYPE, 520, 1720, 810, 3, 4}, {MW_BAND_TYPE, 531, 1701, 783, 2, 4}, // MW for Europe, Africa and Asia {SW_BAND_TYPE, 1700, 3500, 1900, 0, 4}, // 160 meters {SW_BAND_TYPE, 3500, 4500, 3700, 0, 5}, // 80 meters {SW_BAND_TYPE, 4500, 5500, 4850, 1, 4}, {SW_BAND_TYPE, 5600, 6300, 6000, 1, 4}, {SW_BAND_TYPE, 6800, 7300, 7100, 0, 4}, // 40 meters {SW_BAND_TYPE, 7200, 7900, 7200, 1, 4}, // 41 meters {SW_BAND_TYPE, 9200, 10000, 9600, 1, 4}, {SW_BAND_TYPE, 10000, 11000, 10100, 0, 4}, // 30 meters {SW_BAND_TYPE, 11200, 12500, 11940, 1, 4}, {SW_BAND_TYPE, 13400, 13900, 13600, 1, 4}, {SW_BAND_TYPE, 14000, 14500, 14200, 0, 4}, // 20 meters {SW_BAND_TYPE, 15000, 15900, 15300, 1, 4}, {SW_BAND_TYPE, 17200, 17900, 17600, 1, 4}, {SW_BAND_TYPE, 18000, 18300, 18100, 0, 4}, // 17 meters {SW_BAND_TYPE, 21000, 21400, 21200, 0, 4}, // 15 mters {SW_BAND_TYPE, 21400, 21900, 21500, 1, 4}, // 13 mters {SW_BAND_TYPE, 24890, 26200, 24940, 0, 4}, // 12 meters {SW_BAND_TYPE, 26200, 27900, 27500, 0, 4}, // CB band (11 meters) {SW_BAND_TYPE, 28000, 30000, 28400, 0, 4} // 10 meters }; const int lastBand = (sizeof band / sizeof(Band)) - 1; int bandIdx = 1; uint8_t rssi = 0; uint8_t stereo = 1; uint8_t volume = DEFAULT_VOLUME; /************************************** * Morse Code translation dictionary **************************************/ const char *cwCode[] = { ""-----"", // 0 - 48 "".----"", // 1 - 49 ""..---"", // 2 - 50 ""...--"", // 3 - 51 ""....-"", // 4 - 52 ""....."", // 5 - 53 ""-...."", // 6 - 54 ""--..."", // 7 - 55 ""---.."", // 8 - 56 ""----."", // 9 - 57 ""#"", // - 58 Not used ""#"", // - 59 . ""#"", // - 60 . ""#"", // - 61 . ""#"", // - 62 . ""#"", // - 63 . ""#"", // - 64 Not used "".-"", // A - 65 ""-..."", // B - 66 ""-.-."", // C - 67 ""-.."", // D - 68 ""."", // E - 69 ""..-."", // F - 70 ""--."", // G - 71 ""...."", // H - 72 "".."", // I - 73 "".---"", // J - 74 ""-.-"", // K - 75 "".-.."", // L - 76 ""--"", // M - 77 ""-."", // N - 78 ""---"", // O - 79 "".--."", // P - 80 ""--.-"", // Q - 81 "".-."", // R - 82 ""..."", // S - 83 ""-"", // T - 84 ""..-"", // U - 85 ""...-"", // V - 86 "".--"", // W - 87 ""-..-"", // X - 88 ""-.--"", // Y - 89 ""--.."" // Z - 90 }; // Devices class declarations Rotary encoder = Rotary(ENCODER_PIN_A, ENCODER_PIN_B); SI4735 si4735; void setup() { // Encoder pins pinMode(ENCODER_PIN_A, INPUT_PULLUP); pinMode(ENCODER_PIN_B, INPUT_PULLUP); pinMode(BUZZY_PIN, OUTPUT); pinMode(BANDWIDTH_BUTTON, INPUT_PULLUP); pinMode(BAND_BUTTON, INPUT_PULLUP); pinMode(SOFTMUTE_BUTTON, INPUT_PULLUP); pinMode(VOLUME_BUTTON, INPUT_PULLUP); pinMode(CW_READOUT_BUTTON, INPUT_PULLUP); pinMode(ENCODER_BUTTON, INPUT_PULLUP); pinMode(AGC_BUTTON, INPUT_PULLUP); pinMode(STEP_BUTTON, INPUT_PULLUP); pinMode(MODE_SWITCH, INPUT_PULLUP); oled.begin(); oled.clear(); oled.on(); oled.setFont(FONT6X8); // Splash - Change it for your introduction text. oled.setCursor(40, 0); oled.print(""SI473X""); oled.setCursor(20, 1); oled.print(""Arduino Library""); delay(500); oled.setCursor(15, 2); oled.print(""All in One Radio""); delay(500); oled.setCursor(10, 3); oled.print(""V3.0.7x-By PU2CLR""); delay(1000); // end Splash // If you want to reset the eeprom, keep the VOLUME_UP button pressed during statup if (digitalRead(ENCODER_BUTTON) == LOW) { oled.clear(); EEPROM.write(eeprom_address, 0); oled.setCursor(0, 0); oled.print(""EEPROM RESETED""); delay(2000); oled.clear(); } delay(2000); // end Splash // Encoder interrupt attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_A), rotaryEncoder, CHANGE); attachInterrupt(digitalPinToInterrupt(ENCODER_PIN_B), rotaryEncoder, CHANGE); si4735.getDeviceI2CAddress(RESET_PIN); // Looks for the I2C bus address and set it. Returns 0 if error si4735.setup(RESET_PIN, MW_BAND_TYPE); // delay(300); // Checking the EEPROM content if (EEPROM.read(eeprom_address) == app_id) { readAllReceiverInformation(); } // Set up the radio for the current band (see index table variable bandIdx ) useBand(); currentFrequency = previousFrequency = si4735.getFrequency(); si4735.setVolume(volume); oled.clear(); showStatus(); } // Use Rotary.h and Rotary.cpp implementation to process encoder via interrupt void rotaryEncoder() { // rotary encoder events uint8_t encoderStatus = encoder.process(); if (encoderStatus) { if (encoderStatus == DIR_CW) { encoderCount = 1; } else { encoderCount = -1; } } } /* writes the conrrent receiver information into the eeprom. The EEPROM.update avoid write the same data in the same memory position. It will save unnecessary recording. */ void saveAllReceiverInformation() { int addr_offset; EEPROM.update(eeprom_address, app_id); // stores the app id; EEPROM.update(eeprom_address + 1, si4735.getVolume()); // stores the current Volume EEPROM.update(eeprom_address + 2, bandIdx); // Stores the current band EEPROM.update(eeprom_address + 3, currentMode); // Stores the current Mode (FM / AM / SSB) EEPROM.update(eeprom_address + 4, currentBFO >> 8); EEPROM.update(eeprom_address + 5, currentBFO & 0XFF); addr_offset = 6; band[bandIdx].currentFreq = currentFrequency; for (int i = 0; i <= lastBand; i++) { EEPROM.update(addr_offset++, (band[i].currentFreq >> 8)); // stores the current Frequency HIGH byte for the band EEPROM.update(addr_offset++, (band[i].currentFreq & 0xFF)); // stores the current Frequency LOW byte for the band EEPROM.update(addr_offset++, band[i].currentStepIdx); // Stores current step of the band EEPROM.update(addr_offset++, band[i].bandwidthIdx); // table index (direct position) of bandwidth } } /** * reads the last receiver status from eeprom. */ void readAllReceiverInformation() { int addr_offset; int bwIdx; volume = EEPROM.read(eeprom_address + 1); // Gets the stored volume; bandIdx = EEPROM.read(eeprom_address + 2); currentMode = EEPROM.read(eeprom_address + 3); currentBFO = EEPROM.read(eeprom_address + 4) << 8; currentBFO |= EEPROM.read(eeprom_address + 5); addr_offset = 6; for (int i = 0; i <= lastBand; i++) { band[i].currentFreq = EEPROM.read(addr_offset++) << 8; band[i].currentFreq |= EEPROM.read(addr_offset++); band[i].currentStepIdx = EEPROM.read(addr_offset++); band[i].bandwidthIdx = EEPROM.read(addr_offset++); } previousFrequency = currentFrequency = band[bandIdx].currentFreq; idxStep = tabStep[band[bandIdx].currentStepIdx]; bwIdx = band[bandIdx].bandwidthIdx; if (currentMode == LSB || currentMode == USB) { loadSSB(); bwIdxSSB = (bwIdx > 5) ? 5 : bwIdx; si4735.setSSBAudioBandwidth(bandwidthSSB[bwIdxSSB].idx); // If audio bandwidth selected is about 2 kHz or below, it is recommended to set Sideband Cutoff Filter to 0. if (bandwidthSSB[bwIdxSSB].idx == 0 || bandwidthSSB[bwIdxSSB].idx == 4 || bandwidthSSB[bwIdxSSB].idx == 5) si4735.setSBBSidebandCutoffFilter(0); else si4735.setSBBSidebandCutoffFilter(1); } else if (currentMode == AM) { bwIdxAM = bwIdx; si4735.setBandwidth(bandwidthAM[bwIdxAM].idx, 1); } else { bwIdxFM = bwIdx; si4735.setFmBandwidth(bandwidthFM[bwIdxFM].idx); } } /* * To store any change into the EEPROM, it is needed at least STORE_TIME milliseconds of inactivity. */ void resetEepromDelay() { storeTime = millis(); previousFrequency = 0; } /******************************* * Morse Code implementation *******************************/ void playMorseCode(const char *s) { si4735.setAudioMute(true); encoderCount = 0; while (*s && encoderCount == 0) { delay(DELAY_CHAR); playCharCode(*s++); } encoderCount = 0; delay(DELAY_SPACE); si4735.setAudioMute(false); } void playCharCode(char code) { uint8_t idx = code - 48; char *cw = (char *)cwCode[idx]; unsigned int duration = 0; if (code < 48 || code > 90) { delay(DELAY_SPACE); return; } do { if (*cw != '#') { if (encoderCount != 0) return; duration = (*cw == '-') ? DELAY_DASH : DELAY_DOT; tone(BUZZY_PIN, CW_TONE, duration); } cw++; delay(duration << 1 ); // duration * 2 ==> Time between dashes or dots } while (*cw); } void playReceiverStatus() { char tmp[10]; convertToChar(currentFrequency, tmp, 5, 0); playMorseCode(tmp); delay(200); playMorseCode((char *)bandModeDesc[currentMode]); } /** Converts a number to a char string and places leading zeros. It is useful to mitigate memory space used by sprintf or generic similar function */ void convertToChar(uint16_t value, char *strValue, uint8_t len, uint8_t dot) { char d; for (int i = (len - 1); i >= 0; i--) { d = value % 10; value = value / 10; strValue[i] = d + 48; } strValue[len] = '\\0'; if (dot > 0) { for (int i = len; i >= dot; i--) { strValue[i + 1] = strValue[i]; } strValue[dot] = '.'; } if (strValue[0] == '0') { strValue[0] = ' '; if (strValue[1] == '0') strValue[1] = ' '; } } /** Show current frequency */ void showFrequency() { char *unit; char freqDisplay[10]; if (band[bandIdx].bandType == FM_BAND_TYPE) { convertToChar(currentFrequency, freqDisplay, 5, 3); unit = (char *)""MHz""; } else { unit = (char *)""kHz""; if (band[bandIdx].bandType == MW_BAND_TYPE || band[bandIdx].bandType == LW_BAND_TYPE) convertToChar(currentFrequency, freqDisplay, 5, 0); else convertToChar(currentFrequency, freqDisplay, 5, 2); } oled.invertOutput(bfoOn); oled.setFont(FONT8X16ATARI); oled.setCursor(34, 0); oled.print("" ""); oled.setCursor(34, 0); oled.print(freqDisplay); oled.setFont(FONT6X8); oled.invertOutput(false); oled.setCursor(95, 0); oled.print(unit); } /** This function is called by the seek function process. */ void showFrequencySeek(uint16_t freq) { currentFrequency = freq; showFrequency(); } /** Checks the stop seeking criterias. Returns true if the user press the touch or rotates the encoder during the seek process. */ bool checkStopSeeking() { // Checks the touch and encoder return (bool)encoderCount || (digitalRead(ENCODER_BUTTON) == LOW); // returns true if the user rotates the encoder or press the push button } /** Shows some basic information on display */ void showStatus() { showFrequency(); showBandDesc(); showStep(); showBandwidth(); showAttenuation(); showRSSI(); showVolume(); } /** * Shows band information */ void showBandDesc() { char *bandMode; if (currentFrequency < 520) bandMode = (char *)""LW ""; else bandMode = (char *)bandModeDesc[currentMode]; oled.setCursor(0, 0); oled.print("" ""); oled.setCursor(0, 0); oled.invertOutput(cmdBand); oled.print(bandMode); oled.invertOutput(false); } /* ******************************* Shows RSSI status */ void showRSSI() { int bars = (rssi / 20.0) + 1; oled.setCursor(90, 3); oled.print("" ""); oled.setCursor(90, 3); oled.print("".""); for (int i = 0; i < bars; i++) oled.print('_'); oled.print('|'); if (currentMode == FM) { oled.setCursor(18, 0); oled.print("" ""); oled.setCursor(18, 0); oled.invertOutput(true); if (si4735.getCurrentPilot()) { oled.invertOutput(true); oled.print(""s""); } oled.invertOutput(false); } } /* Shows the volume level on LCD */ void showVolume() { oled.setCursor(58, 3); oled.print("" ""); oled.setCursor(58, 3); oled.invertOutput(cmdVolume); oled.print(' '); oled.invertOutput(false); oled.print(si4735.getCurrentVolume()); } void showStep() { if (bfoOn) return; oled.setCursor(93, 1); oled.print("" ""); if (currentMode == FM) return; oled.setCursor(93, 1); oled.invertOutput(cmdStep); oled.print(""S:""); oled.invertOutput(false); oled.print(tabStep[idxStep]); } /** Shows bandwidth on AM,SSB and FM mode */ void showBandwidth() { char *bw; if (currentMode == LSB || currentMode == USB) { bw = (char *)bandwidthSSB[bwIdxSSB].desc; showBFO(); } else if (currentMode == AM) { bw = (char *)bandwidthAM[bwIdxAM].desc; } else { bw = (char *)bandwidthFM[bwIdxFM].desc; } oled.setCursor(0, 3); oled.print("" ""); oled.setCursor(0, 3); oled.invertOutput(cmdBw); oled.print(""BW: ""); oled.invertOutput(false); oled.print(bw); } /* * Shows AGCC and Attenuation */ void showAttenuation() { // Show AGC Information oled.setCursor(0, 1); oled.print("" ""); oled.setCursor(0, 1); if ( currentMode != FM ) { if (cmdSoftMute) { oled.invertOutput(cmdSoftMute); oled.print(""SM""); oled.invertOutput(false); oled.print(smIdx); } else { // shows Softmute attenuation oled.invertOutput(cmdAgcAtt); if (agcIdx == 0) { oled.print(""AGC""); oled.invertOutput(false); } else { oled.print(""At""); oled.invertOutput(false); oled.print(agcNdx); } } } } /* Shows the BFO current status. Must be called only on SSB mode (LSB or USB) */ void showBFO() { oled.setCursor(0, 2); oled.print("" ""); oled.setCursor(0, 2); oled.print(""BFO: ""); oled.print(currentBFO); oled.print(""Hz ""); oled.setCursor(93, 2); oled.print("" ""); oled.setCursor(93, 2); oled.invertOutput(cmdStep); oled.print(""S:""); oled.invertOutput(false); oled.print(currentBFOStep); } char *stationName; char bufferStatioName[20]; long rdsElapsed = millis(); char oldBuffer[15]; /* * Clean the content of the third line (line 2 - remember the first line is 0) */ void cleanBfoRdsInfo() { oled.setCursor(0, 2); oled.print("" ""); } /* * Show the Station Name. */ void showRDSStation() { char *po, *pc; int col = 0; po = oldBuffer; pc = stationName; while (*pc) { if (*po != *pc) { oled.setCursor(col, 2); oled.print(*pc); } *po = *pc; po++; pc++; col += 10; } // strcpy(oldBuffer, stationName); delay(100); } /* * Checks the station name is available */ void checkRDS() { si4735.getRdsStatus(); if (si4735.getRdsReceived()) { if (si4735.getRdsSync() && si4735.getRdsSyncFound() && !si4735.getRdsSyncLost() && !si4735.getGroupLost()) { stationName = si4735.getRdsText0A(); if (stationName != NULL /* && si4735.getEndGroupB() && (millis() - rdsElapsed) > 10 */) { showRDSStation(); // si4735.resetEndGroupB(); rdsElapsed = millis(); } } } } /* Goes to the next band (see Band table) */ void bandUp() { // save the current frequency for the band band[bandIdx].currentFreq = currentFrequency; band[bandIdx].currentStepIdx = idxStep; // currentStep; if (bandIdx < lastBand) { bandIdx++; } else { bandIdx = 0; } useBand(); } /* Goes to the previous band (see Band table) */ void bandDown() { // save the current frequency for the band band[bandIdx].currentFreq = currentFrequency; band[bandIdx].currentStepIdx = idxStep; if (bandIdx > 0) { bandIdx--; } else { bandIdx = lastBand; } useBand(); } /* This function loads the contents of the ssb_patch_content array into the CI (Si4735) and starts the radio on SSB mode. */ void loadSSB() { oled.setCursor(0, 2); oled.print("" Switching to SSB ""); // si4735.setI2CFastModeCustom(700000); // It is working. Faster, but I'm not sure if it is safe. si4735.setI2CFastModeCustom(500000); si4735.queryLibraryId(); // Is it really necessary here? I will check it. si4735.patchPowerUp(); delay(50); si4735.downloadCompressedPatch(ssb_patch_content, size_content, cmd_0x15, cmd_0x15_size); si4735.setSSBConfig(bandwidthSSB[bwIdxSSB].idx, 1, 0, 1, 0, 1); si4735.setI2CStandardMode(); ssbLoaded = true; // oled.clear(); cleanBfoRdsInfo(); } /* Switch the radio to current band. The bandIdx variable points to the current band. This function change to the band referenced by bandIdx (see table band). */ void useBand() { cleanBfoRdsInfo(); if (band[bandIdx].bandType == FM_BAND_TYPE) { currentMode = FM; si4735.setTuneFrequencyAntennaCapacitor(0); si4735.setFM(band[bandIdx].minimumFreq, band[bandIdx].maximumFreq, band[bandIdx].currentFreq, tabStep[band[bandIdx].currentStepIdx]); si4735.setSeekFmLimits(band[bandIdx].minimumFreq, band[bandIdx].maximumFreq); si4735.setSeekFmSpacing(1); bfoOn = ssbLoaded = false; si4735.setRdsConfig(1, 2, 2, 2, 2); si4735.setFifoCount(1); bwIdxFM = band[bandIdx].bandwidthIdx; si4735.setFmBandwidth(bandwidthFM[bwIdxFM].idx); } else { if (band[bandIdx].bandType == MW_BAND_TYPE || band[bandIdx].bandType == LW_BAND_TYPE) si4735.setTuneFrequencyAntennaCapacitor(0); else si4735.setTuneFrequencyAntennaCapacitor(1); if (ssbLoaded) { si4735.setSSB(band[bandIdx].minimumFreq, band[bandIdx].maximumFreq, band[bandIdx].currentFreq, tabStep[band[bandIdx].currentStepIdx], currentMode); si4735.setSSBAutomaticVolumeControl(1); si4735.setSsbSoftMuteMaxAttenuation(0); // Disable Soft Mute for SSB bwIdxSSB = band[bandIdx].bandwidthIdx; si4735.setSSBAudioBandwidth(bandwidthSSB[bwIdxSSB].idx); si4735.setSSBBfo(currentBFO); } else { currentMode = AM; si4735.setAM(band[bandIdx].minimumFreq, band[bandIdx].maximumFreq, band[bandIdx].currentFreq, tabStep[band[bandIdx].currentStepIdx]); si4735.setAutomaticGainControl(disableAgc, agcNdx); si4735.setAmSoftMuteMaxAttenuation(smIdx); // // Disable Soft Mute for AM bwIdxAM = band[bandIdx].bandwidthIdx; si4735.setBandwidth(bandwidthAM[bwIdxAM].idx, 1); bfoOn = false; } si4735.setSeekAmLimits(band[bandIdx].minimumFreq, band[bandIdx].maximumFreq); // Consider the range all defined current band si4735.setSeekAmSpacing((tabStep[band[bandIdx].currentStepIdx] > 10) ? 10 : tabStep[band[bandIdx].currentStepIdx]); // Max 10kHz for spacing } delay(100); currentFrequency = band[bandIdx].currentFreq; idxStep = band[bandIdx].currentStepIdx; showStatus(); resetEepromDelay(); } /** * Changes the step frequency value based on encoder rotation */ void doStep(int8_t v) { // This command should work only for SSB mode if ((currentMode == LSB || currentMode == USB) && bfoOn) { currentBFOStep = (currentBFOStep == 25) ? 10 : 25; showBFO(); } else { idxStep = (v == 1) ? idxStep + 1 : idxStep - 1; if (idxStep > lastStep) idxStep = 0; else if (idxStep < 0) idxStep = lastStep; si4735.setFrequencyStep(tabStep[idxStep]); band[bandIdx].currentStepIdx = idxStep; si4735.setSeekAmSpacing((tabStep[idxStep] > 10) ? 10 : tabStep[idxStep]); // Max 10kHz for spacing showStep(); } delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } /** * Changes the volume based on encoder rotation */ void doVolume(int8_t v) { if (v == 1) si4735.volumeUp(); else si4735.volumeDown(); showVolume(); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } /** * Switches the AGC/Attenuation based on encoder rotation */ void doAttenuation(int8_t v) { if ( cmdAgcAtt) { agcIdx = (v == 1) ? agcIdx + 1 : agcIdx - 1; if (agcIdx < 0) agcIdx = 37; else if (agcIdx > 37) agcIdx = 0; disableAgc = (agcIdx > 0); // if true, disable AGC; esle, AGC is enable if (agcIdx > 1) agcNdx = agcIdx - 1; else agcNdx = 0; // Sets AGC on/off and gain si4735.setAutomaticGainControl(disableAgc, agcNdx); } else { // deal with Softmute attenuation smIdx = (v==1) ? smIdx + 1 : smIdx -1; if (smIdx > 32) smIdx = 0; else if (smIdx < 0) smIdx = 32; si4735.setAmSoftMuteMaxAttenuation(smIdx); } showAttenuation(); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } /** * Switches the bandwidth based on encoder rotation */ void doBandwidth(uint8_t v) { if (currentMode == LSB || currentMode == USB) { bwIdxSSB = (v == 1) ? bwIdxSSB + 1 : bwIdxSSB - 1; if (bwIdxSSB > 5) bwIdxSSB = 0; else if (bwIdxSSB < 0) bwIdxSSB = 5; band[bandIdx].bandwidthIdx = bwIdxSSB; si4735.setSSBAudioBandwidth(bandwidthSSB[bwIdxSSB].idx); // If audio bandwidth selected is about 2 kHz or below, it is recommended to set Sideband Cutoff Filter to 0. if (bandwidthSSB[bwIdxSSB].idx == 0 || bandwidthSSB[bwIdxSSB].idx == 4 || bandwidthSSB[bwIdxSSB].idx == 5) si4735.setSBBSidebandCutoffFilter(0); else si4735.setSBBSidebandCutoffFilter(1); } else if (currentMode == AM) { bwIdxAM = (v == 1) ? bwIdxAM + 1 : bwIdxAM - 1; if (bwIdxAM > maxFilterAM) bwIdxAM = 0; else if (bwIdxAM < 0) bwIdxAM = maxFilterAM; band[bandIdx].bandwidthIdx = bwIdxAM; si4735.setBandwidth(bandwidthAM[bwIdxAM].idx, 1); } else { bwIdxFM = (v == 1) ? bwIdxFM + 1 : bwIdxFM - 1; if (bwIdxFM > 4) bwIdxFM = 0; else if (bwIdxFM < 0) bwIdxFM = 4; band[bandIdx].bandwidthIdx = bwIdxFM; si4735.setFmBandwidth(bandwidthFM[bwIdxFM].idx); } showBandwidth(); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } /** * disble command buttons and keep the current status of the last command button pressed */ void disableCommand(bool *b, bool value, void (*showFunction)()) { cmdVolume = false; cmdAgcAtt = false; cmdStep = false; cmdBw = false; cmdBand = false; cmdSoftMute = false; showVolume(); showStep(); showAttenuation(); showBandwidth(); showBandDesc(); if (b != NULL) // rescues the last status of the last command only the parameter is not null *b = value; if (showFunction != NULL) // show the desired status only if it is necessary. showFunction(); elapsedRSSI = millis(); countRSSI = 0; } void loop() { // Check if the encoder has moved. if (encoderCount != 0) { if (cmdVolume) doVolume(encoderCount); else if (cmdAgcAtt || cmdSoftMute) doAttenuation(encoderCount); else if (cmdStep) doStep(encoderCount); else if (cmdBw) doBandwidth(encoderCount); else if (cmdBand) { if (encoderCount == 1) bandUp(); else bandDown(); } else if (bfoOn) { currentBFO = (encoderCount == 1) ? (currentBFO + currentBFOStep) : (currentBFO - currentBFOStep); si4735.setSSBBfo(currentBFO); previousFrequency = 0; // Forces eeprom update showBFO(); } else { if (encoderCount == 1) { si4735.frequencyUp(); seekDirection = 1; } else { si4735.frequencyDown(); seekDirection = 0; } // Show the current frequency only if it has changed currentFrequency = si4735.getFrequency(); showFrequency(); } encoderCount = 0; resetEepromDelay(); // if you moved the encoder, something was changed elapsedRSSI = millis(); countRSSI = 0; } // Check button commands if ((millis() - elapsedButton) > MIN_ELAPSED_TIME) // Is that necessary? { // check if some button is pressed if (digitalRead(BANDWIDTH_BUTTON) == LOW) { cmdBw = !cmdBw; disableCommand(&cmdBw, cmdBw, showBandwidth); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(BAND_BUTTON) == LOW) { cmdBand = !cmdBand; disableCommand(&cmdBand, cmdBand, showBandDesc); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(SOFTMUTE_BUTTON) == LOW) { if (currentMode != FM) { cmdSoftMute = !cmdSoftMute; disableCommand(&cmdSoftMute, cmdSoftMute, showAttenuation); } delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(VOLUME_BUTTON) == LOW) { cmdVolume = !cmdVolume; disableCommand(&cmdVolume, cmdVolume, showVolume); delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(CW_READOUT_BUTTON) == LOW) { playReceiverStatus(); // showStatus(); } else if (digitalRead(ENCODER_BUTTON) == LOW) { if (currentMode == LSB || currentMode == USB) { bfoOn = !bfoOn; if (bfoOn) showBFO(); showStatus(); disableCommand(NULL, false, NULL); // disable all command buttons } else if (currentMode == FM || currentMode == AM) { // Jumps up or down one space if (seekDirection) si4735.frequencyUp(); else si4735.frequencyDown(); si4735.seekStationProgress(showFrequencySeek, checkStopSeeking, seekDirection); delay(30); if (currentMode == FM) { float f = round(si4735.getFrequency() / 10.0); currentFrequency = (uint16_t)f * 10; // adjusts band space from 1 (10kHz) to 10 (100 kHz) si4735.setFrequency(currentFrequency); } else { currentFrequency = si4735.getFrequency(); // } showFrequency(); } delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(AGC_BUTTON) == LOW) { if ( currentMode != FM) { cmdAgcAtt = !cmdAgcAtt; disableCommand(&cmdAgcAtt, cmdAgcAtt, showAttenuation); } delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(STEP_BUTTON) == LOW) { if (currentMode != FM) { cmdStep = !cmdStep; disableCommand(&cmdStep, cmdStep, showStep); } delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button. } else if (digitalRead(MODE_SWITCH) == LOW) { if (currentMode != FM) { if (currentMode == AM) { // If you were in AM mode, it is necessary to load SSB patch (avery time) loadSSB(); currentMode = LSB; } else if (currentMode == LSB) { currentMode = USB; } else if (currentMode == USB) { currentMode = AM; ssbLoaded = false; bfoOn = false; } // Nothing to do if you are in FM mode band[bandIdx].currentFreq = currentFrequency; band[bandIdx].currentStepIdx = idxStep; useBand(); } } elapsedButton = millis(); } // Show RSSI status only if this condition has changed if ((millis() - elapsedRSSI) > MIN_ELAPSED_RSSI_TIME * 9) { si4735.getCurrentReceivedSignalQuality(); int aux = si4735.getCurrentRSSI(); if (rssi != aux) { rssi = aux; showRSSI(); } if (countRSSI++ > 3) { disableCommand(NULL, false, NULL); // disable all command buttons countRSSI = 0; } elapsedRSSI = millis(); } if (currentMode == FM) { if (currentFrequency != previousFrequency) { cleanBfoRdsInfo(); } else { checkRDS(); } } // Show the current frequency only if it has changed if (currentFrequency != previousFrequency) { if ((millis() - storeTime) > STORE_TIME) { saveAllReceiverInformation(); storeTime = millis(); previousFrequency = currentFrequency; } } delay(10); } ",12324,False,1987.3074311356056,median "package game.view.chat.base { import com.utils.Constants; import game.base.JTSprite; import game.manager.AssetMgr; import starling.display.Image; import starling.textures.Texture; public class JTUIBackGround extends JTSprite { public static var isTouchable:Boolean = false; public function JTUIBackGround() { var txture_ui_gongyong_dianquanheng_di6400:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di6400img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di6400); ui_gongyong_dianquanheng_di6400img_NaN.x = 640; ui_gongyong_dianquanheng_di6400img_NaN.y = 0; ui_gongyong_dianquanheng_di6400img_NaN.width = 321; ui_gongyong_dianquanheng_di6400img_NaN.height = 160; ui_gongyong_dianquanheng_di6400img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di6400img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di6400img_NaN); var txture_ui_gongyong_dianquanheng_di3200:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di3200img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di3200); ui_gongyong_dianquanheng_di3200img_NaN.x = 320; ui_gongyong_dianquanheng_di3200img_NaN.y = 0; ui_gongyong_dianquanheng_di3200img_NaN.width = 321; ui_gongyong_dianquanheng_di3200img_NaN.height = 160; ui_gongyong_dianquanheng_di3200img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di3200img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di3200img_NaN); var txture_ui_gongyong_dianquanheng_di00:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di00img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di00); ui_gongyong_dianquanheng_di00img_NaN.x = 0; ui_gongyong_dianquanheng_di00img_NaN.y = 0; ui_gongyong_dianquanheng_di00img_NaN.width = 321; ui_gongyong_dianquanheng_di00img_NaN.height = 160; ui_gongyong_dianquanheng_di00img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di00img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di00img_NaN); var txture_ui_gongyong_dianquanheng_di640160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di640160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di640160); ui_gongyong_dianquanheng_di640160img_NaN.x = 640; ui_gongyong_dianquanheng_di640160img_NaN.y = 160; ui_gongyong_dianquanheng_di640160img_NaN.width = 321; ui_gongyong_dianquanheng_di640160img_NaN.height = 160; ui_gongyong_dianquanheng_di640160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di640160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di640160img_NaN); var txture_ui_gongyong_dianquanheng_di320160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di320160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di320160); ui_gongyong_dianquanheng_di320160img_NaN.x = 320; ui_gongyong_dianquanheng_di320160img_NaN.y = 160; ui_gongyong_dianquanheng_di320160img_NaN.width = 321; ui_gongyong_dianquanheng_di320160img_NaN.height = 160; ui_gongyong_dianquanheng_di320160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di320160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di320160img_NaN); var txture_ui_gongyong_dianquanheng_di0160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di0160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di0160); ui_gongyong_dianquanheng_di0160img_NaN.x = 0; ui_gongyong_dianquanheng_di0160img_NaN.y = 160; ui_gongyong_dianquanheng_di0160img_NaN.width = 321; ui_gongyong_dianquanheng_di0160img_NaN.height = 160; ui_gongyong_dianquanheng_di0160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di0160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di0160img_NaN); var txture_ui_gongyong_dianquanheng_di640320:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di640320img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di640320); ui_gongyong_dianquanheng_di640320img_NaN.x = 640; ui_gongyong_dianquanheng_di640320img_NaN.y = 320; ui_gongyong_dianquanheng_di640320img_NaN.width = 321; ui_gongyong_dianquanheng_di640320img_NaN.height = 160; ui_gongyong_dianquanheng_di640320img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di640320img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di640320img_NaN); var txture_ui_gongyong_dianquanheng_di320320:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di320320img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di320320); ui_gongyong_dianquanheng_di320320img_NaN.x = 320; ui_gongyong_dianquanheng_di320320img_NaN.y = 320; ui_gongyong_dianquanheng_di320320img_NaN.width = 321; ui_gongyong_dianquanheng_di320320img_NaN.height = 160; ui_gongyong_dianquanheng_di320320img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di320320img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di320320img_NaN); var txture_ui_gongyong_dianquanheng_di0320:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di0320img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di0320); ui_gongyong_dianquanheng_di0320img_NaN.x = 0; ui_gongyong_dianquanheng_di0320img_NaN.y = 320; ui_gongyong_dianquanheng_di0320img_NaN.width = 321; ui_gongyong_dianquanheng_di0320img_NaN.height = 160; ui_gongyong_dianquanheng_di0320img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di0320img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di0320img_NaN); var txture_ui_gongyong_dianquanheng_di640480:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di640480img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di640480); ui_gongyong_dianquanheng_di640480img_NaN.x = 640; ui_gongyong_dianquanheng_di640480img_NaN.y = 480; ui_gongyong_dianquanheng_di640480img_NaN.width = 321; ui_gongyong_dianquanheng_di640480img_NaN.height = 160; ui_gongyong_dianquanheng_di640480img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di640480img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di640480img_NaN); var txture_ui_gongyong_dianquanheng_di320480:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di320480img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di320480); ui_gongyong_dianquanheng_di320480img_NaN.x = 320; ui_gongyong_dianquanheng_di320480img_NaN.y = 480; ui_gongyong_dianquanheng_di320480img_NaN.width = 321; ui_gongyong_dianquanheng_di320480img_NaN.height = 160; ui_gongyong_dianquanheng_di320480img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di320480img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di320480img_NaN); var txture_ui_gongyong_dianquanheng_di0480:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di0480img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di0480); ui_gongyong_dianquanheng_di0480img_NaN.x = 0; ui_gongyong_dianquanheng_di0480img_NaN.y = 480; ui_gongyong_dianquanheng_di0480img_NaN.width = 321; ui_gongyong_dianquanheng_di0480img_NaN.height = 160; ui_gongyong_dianquanheng_di0480img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di0480img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di0480img_NaN); var txture_ui_gongyong_dianquanheng_di640156:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di640156img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di640156); ui_gongyong_dianquanheng_di640156img_NaN.x = 640; ui_gongyong_dianquanheng_di640156img_NaN.y = -156; ui_gongyong_dianquanheng_di640156img_NaN.width = 321; ui_gongyong_dianquanheng_di640156img_NaN.height = 160; ui_gongyong_dianquanheng_di640156img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di640156img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di640156img_NaN); var txture_ui_gongyong_dianquanheng_di320156:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di320156img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di320156); ui_gongyong_dianquanheng_di320156img_NaN.x = 320; ui_gongyong_dianquanheng_di320156img_NaN.y = -156; ui_gongyong_dianquanheng_di320156img_NaN.width = 321; ui_gongyong_dianquanheng_di320156img_NaN.height = 160; ui_gongyong_dianquanheng_di320156img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di320156img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di320156img_NaN); var txture_ui_gongyong_dianquanheng_di0156:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di0156img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di0156); ui_gongyong_dianquanheng_di0156img_NaN.x = 0; ui_gongyong_dianquanheng_di0156img_NaN.y = -156; ui_gongyong_dianquanheng_di0156img_NaN.width = 321; ui_gongyong_dianquanheng_di0156img_NaN.height = 160; ui_gongyong_dianquanheng_di0156img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di0156img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di0156img_NaN); var txture_ui_gongyong_dianquanheng_di3160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di3160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di3160); ui_gongyong_dianquanheng_di3160img_NaN.x = -316; ui_gongyong_dianquanheng_di3160img_NaN.y = 0; ui_gongyong_dianquanheng_di3160img_NaN.width = 321; ui_gongyong_dianquanheng_di3160img_NaN.height = 160; ui_gongyong_dianquanheng_di3160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di3160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di3160img_NaN); var txture_ui_gongyong_dianquanheng_di316160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di316160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di316160); ui_gongyong_dianquanheng_di316160img_NaN.x = -316; ui_gongyong_dianquanheng_di316160img_NaN.y = 160; ui_gongyong_dianquanheng_di316160img_NaN.width = 321; ui_gongyong_dianquanheng_di316160img_NaN.height = 160; ui_gongyong_dianquanheng_di316160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di316160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di316160img_NaN); var txture_ui_gongyong_dianquanheng_di316320:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di316320img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di316320); ui_gongyong_dianquanheng_di316320img_NaN.x = -316; ui_gongyong_dianquanheng_di316320img_NaN.y = 320; ui_gongyong_dianquanheng_di316320img_NaN.width = 321; ui_gongyong_dianquanheng_di316320img_NaN.height = 160; ui_gongyong_dianquanheng_di316320img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di316320img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di316320img_NaN); var txture_ui_gongyong_dianquanheng_di316480:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di316480img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di316480); ui_gongyong_dianquanheng_di316480img_NaN.x = -316; ui_gongyong_dianquanheng_di316480img_NaN.y = 480; ui_gongyong_dianquanheng_di316480img_NaN.width = 321; ui_gongyong_dianquanheng_di316480img_NaN.height = 160; ui_gongyong_dianquanheng_di316480img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di316480img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di316480img_NaN); var txture_ui_gongyong_dianquanheng_di316156:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di316156img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di316156); ui_gongyong_dianquanheng_di316156img_NaN.x = -316; ui_gongyong_dianquanheng_di316156img_NaN.y = -156; ui_gongyong_dianquanheng_di316156img_NaN.width = 321; ui_gongyong_dianquanheng_di316156img_NaN.height = 160; ui_gongyong_dianquanheng_di316156img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di316156img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di316156img_NaN); var txture_ui_gongyong_dianquanheng_di640638:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di640638img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di640638); ui_gongyong_dianquanheng_di640638img_NaN.x = 640; ui_gongyong_dianquanheng_di640638img_NaN.y = 638; ui_gongyong_dianquanheng_di640638img_NaN.width = 321; ui_gongyong_dianquanheng_di640638img_NaN.height = 160; ui_gongyong_dianquanheng_di640638img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di640638img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di640638img_NaN); var txture_ui_gongyong_dianquanheng_di320638:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di320638img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di320638); ui_gongyong_dianquanheng_di320638img_NaN.x = 320; ui_gongyong_dianquanheng_di320638img_NaN.y = 638; ui_gongyong_dianquanheng_di320638img_NaN.width = 321; ui_gongyong_dianquanheng_di320638img_NaN.height = 160; ui_gongyong_dianquanheng_di320638img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di320638img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di320638img_NaN); var txture_ui_gongyong_dianquanheng_di0638:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di0638img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di0638); ui_gongyong_dianquanheng_di0638img_NaN.x = 0; ui_gongyong_dianquanheng_di0638img_NaN.y = 638; ui_gongyong_dianquanheng_di0638img_NaN.width = 321; ui_gongyong_dianquanheng_di0638img_NaN.height = 160; ui_gongyong_dianquanheng_di0638img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di0638img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di0638img_NaN); var txture_ui_gongyong_dianquanheng_di316638:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di316638img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di316638); ui_gongyong_dianquanheng_di316638img_NaN.x = -316; ui_gongyong_dianquanheng_di316638img_NaN.y = 638; ui_gongyong_dianquanheng_di316638img_NaN.width = 321; ui_gongyong_dianquanheng_di316638img_NaN.height = 160; ui_gongyong_dianquanheng_di316638img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di316638img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di316638img_NaN); var txture_ui_gongyong_dianquanheng_di9560:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di9560img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di9560); ui_gongyong_dianquanheng_di9560img_NaN.x = 956; ui_gongyong_dianquanheng_di9560img_NaN.y = 0; ui_gongyong_dianquanheng_di9560img_NaN.width = 321; ui_gongyong_dianquanheng_di9560img_NaN.height = 160; ui_gongyong_dianquanheng_di9560img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di9560img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di9560img_NaN); var txture_ui_gongyong_dianquanheng_di956160:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di956160img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di956160); ui_gongyong_dianquanheng_di956160img_NaN.x = 956; ui_gongyong_dianquanheng_di956160img_NaN.y = 160; ui_gongyong_dianquanheng_di956160img_NaN.width = 321; ui_gongyong_dianquanheng_di956160img_NaN.height = 160; ui_gongyong_dianquanheng_di956160img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di956160img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di956160img_NaN); var txture_ui_gongyong_dianquanheng_di956320:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di956320img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di956320); ui_gongyong_dianquanheng_di956320img_NaN.x = 956; ui_gongyong_dianquanheng_di956320img_NaN.y = 320; ui_gongyong_dianquanheng_di956320img_NaN.width = 321; ui_gongyong_dianquanheng_di956320img_NaN.height = 160; ui_gongyong_dianquanheng_di956320img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di956320img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di956320img_NaN); var txture_ui_gongyong_dianquanheng_di956480:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di956480img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di956480); ui_gongyong_dianquanheng_di956480img_NaN.x = 956; ui_gongyong_dianquanheng_di956480img_NaN.y = 480; ui_gongyong_dianquanheng_di956480img_NaN.width = 321; ui_gongyong_dianquanheng_di956480img_NaN.height = 160; ui_gongyong_dianquanheng_di956480img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di956480img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di956480img_NaN); var txture_ui_gongyong_dianquanheng_di956156:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di956156img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di956156); ui_gongyong_dianquanheng_di956156img_NaN.x = 956; ui_gongyong_dianquanheng_di956156img_NaN.y = -156; ui_gongyong_dianquanheng_di956156img_NaN.width = 321; ui_gongyong_dianquanheng_di956156img_NaN.height = 160; ui_gongyong_dianquanheng_di956156img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di956156img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di956156img_NaN); var txture_ui_gongyong_dianquanheng_di956638:Texture = AssetMgr.instance.getTexture('ui_gongyong_dianquanheng_di'); var ui_gongyong_dianquanheng_di956638img_NaN:Image = new Image(txture_ui_gongyong_dianquanheng_di956638); ui_gongyong_dianquanheng_di956638img_NaN.x = 956; ui_gongyong_dianquanheng_di956638img_NaN.y = 638; ui_gongyong_dianquanheng_di956638img_NaN.width = 321; ui_gongyong_dianquanheng_di956638img_NaN.height = 160; ui_gongyong_dianquanheng_di956638img_NaN.smoothing = Constants.smoothing; ui_gongyong_dianquanheng_di956638img_NaN.touchable = isTouchable; this.addQuiackChild(ui_gongyong_dianquanheng_di956638img_NaN); } } }",8326,True,3403.251171980956,median " /* CLOCK v4 Russ Winch Started February 2016 TODO: Hardware replace the arduino with ATMEGA chip and required accessories usb power - any electrical considerations? polyfuse? mounting of the usb power socket jumper to select between usb power or ICSP include a switch or jumper to disable sound? change the LED display to one unit? led display isn't as bright as it could be - resistor mathmatics required... protect the display with clear or slighly smoked acrylic (brightness!!) Software improve alarm tones - use alarmStarted time to change the tone / modes? implement pointers look for unused variables and remove settings mode for alarm tones? change menu to use an array of lookup values, so adding new menus is not so tedious setting for alarm sounding time play alarm tones as a test from setting Low priority add negative for temperature? settings mode for 12/24h mode? setting to enable / disable flashing dots during time implement transitions between display modes **develop this further/properly Bugs confirmFlash continues even when mode is changed changed mode detection resets if another button released - eg pressing al when still holding snooze */ #define DS3231 0x68 //I2C address of DS3231 #include //for I2C communication #include //for saving alarm and settings to EEPROM //input pins const int alarmSw0Pin = A0; //constant alarm switch const int alarmSw1Pin = A1; //momentary alarm switch const int snoozeSwPin = 4; //momentary snooze switch //output pins //A4 & A5 reserved for I2C Clock and Data, respectively const int piezoPin = 3; //piezo sounder const int snoozeLedPin = 5; //snooze led const int ledEnable = 6; //MC14489B led driver enable const int ledClock = 7; //MC14489B led driver clock const int ledData = 8; //MC14489B led driver data //mode variables const int totalLoopModes = 5;//number of modes to loop through, before settings modes const int stableModes = 3; //number of modes which don't timeout after no button pressed int displayFor = 3000; //time to display alarm before returning to clock and flash LEDs when confirming setting. int setFor = 30000; //timeout for non-stable (settings) modes int mode = 0; //main mode selector int oldMode = 0; //mode detection int settingsMode = 1; //settings mode selector int setTarget = 0; //target for settings [0=clock, 1=alarm] boolean changedModeFlag = false; //flag to detect if mode has changed boolean secondsAnim; //flag to hold setting for settings animation byte currentSetting[2]; //holds current variables when settings entered byte currentSettingMax[2] = {59, 23}; //max mins and hours allowed unsigned long lastSet = 0; //time the last button was pressed to adjust a setting unsigned long settingsTimeout = 0; //millis() for timing out of settings unsigned long changedSeconds; //millis() the last time seconds changed //clock variables byte clockData[3]; //seconds, minutes, hours byte alarm1Data[3]; //seconds, minutes, hours byte alarm2Data[2]; //minutes, hours byte tempData[2]; //integer, decimal byte statusData; //status register byte oldSeconds; //old seconds reading //temperature variables const int tempLogReadings = 10; //number of readings to average float temperature[3]; //the current temperature [0=sign, 1=integer, 2=decimal] float currentTemp; float tempLogTotal = 0; //total for average float tempLog[tempLogReadings]; //readings for average int tempLogIndex = 0; //index for average //led driver variables byte ledDisplayByte[3]; //led display data to write back [0=D0-D7, 1=D8-D15, 2=D16-D23] byte oldLedByte[4]; //data from the last update byte ledDecode = 0; //decode mode - used to turn off banks //led variables int fadeValue = 0; boolean fadeDir = false; //direction of fade boolean alarmLed = false; //alarm LED flag boolean flashDots = false; //flash seperator leds boolean confirmFlash = false; //overall confirm flag unsigned long confirmFlashTime; //time led flashing started when confirming setting //button variables const int totalButtons = 3; //total connected buttons to check boolean buttonData[totalButtons]; //current button reading boolean oldButtonData[totalButtons] = {LOW, HIGH, HIGH}; //previous button reading int buttonState[totalButtons]; //current button state [0=alSw0, 1= alSw1, 2=snSw] int oldButtonState[totalButtons]; //previous button state int bounceDelay = 50; //debounce time int holdDelay = 1000; //time to wait for button hold int longHoldDelay = 2500; //time to wait for long button hold int incDelay = 80; //time to wait between incrementing during button hold - speed int slowIncDelay = 160; //time to wait between incrementing during button hold - slow speed unsigned long bounceTime[totalButtons]; //millis() times for each button last pressed for debounce unsigned long holdTime[totalButtons]; unsigned long incTime = 0; //time since last increment //alarm variables const int totalAlarms = 3; //total software alarms boolean alarmStatus[2]; //holds the alarm triggered flags [0=AL1, 1=AL2] boolean alarmSet[2]; //holds the alarm set flags [0=AL1, 1=AL2] boolean alarmTriggered = false; int alarmTime[totalAlarms][2]; //array to hold alarm times [mins, hours] int currentAlarm = 99; //currently set alarm. set to 99 as a default, to be changed during setup() int displayedAlarm = 0; //currently displayed alarm int defaultSnooze; //snooze time in mins - will read from EEPROM int maxSnooze = 59; //maximum settable default snoozetime int setSnooze; //to store defaultSnooze while setting int snoozeLeft; //mins int alarmTimeout = 20; //alarm to stop itself after 20 mins unsigned long alarmStop = alarmTimeout * 60000; //convert mins to millis unsigned long alarmStarted; //time alarm started sounding //alarm tones boolean toneActive = false; //is there an active tone unsigned long toneStarted = 0; ///millis when tone started int toneDuration = 0; //tone duration int toneDelay = 0; //delay between tones int toneReps = 0; //cycle through the reps for the sound int t; //tone frequency variable int setTone; //user set tone option whilst in setting int currentTone; //user set tone option, will read from EEPROM int totalTones = 3; //number of available tone options (0 is reserved for off) //EEPROM const int eepromStart = 10; //address in eeprom to store alarms from const int eepromSnooze = 50; //address for snooze time setting const int eepromSeconds = 52; //address for seconds animation setting const int eepromTone = 54; //address for tone setting void setup() { //inputs pinMode(alarmSw0Pin, INPUT_PULLUP); pinMode(alarmSw1Pin, INPUT_PULLUP); pinMode(snoozeSwPin, INPUT_PULLUP); //outputs pinMode(snoozeLedPin, OUTPUT); //snooze led pinMode(ledEnable, OUTPUT); //for the led driver pinMode(ledClock, OUTPUT); //for the led driver pinMode(ledData, OUTPUT); //for the led driver // pinMode(piezoPin, OUTPUT); //tone appears to negate the need for this //random seed for alarm tones randomSeed(analogRead(A3)); //initiate wire Wire.begin(); //retrieve defaultSnooze setting defaultSnooze = (EEPROM.read(eepromSnooze) <= maxSnooze) ? EEPROM.read(eepromSnooze) : 5; //default to 5 mins if larger then max //retrieve seconds animation setting secondsAnim = (EEPROM.read(eepromSeconds) < 2) ? EEPROM.read(eepromSeconds) : 1; //default to 1 if not boolean //retrieve tone setting currentTone = (EEPROM.read(eepromTone) > 0 && EEPROM.read(eepromTone) <= totalTones) ? EEPROM.read(eepromTone) : 1; //default to 1 if below or above total available tones //update alarms getAlarm2(); //read from EEPROM and determine currentAlarm for (int e = 0; e < totalAlarms; e++) { alarmTime[e][0] = EEPROM.read(e + eepromStart); //mins alarmTime[e][1] = EEPROM.read(e + eepromStart + totalAlarms); //hours if (alarmTime[e][0] == bcdToDec(alarm2Data[0] & B01111111) && alarmTime[e][1] == bcdToDec(alarm2Data[1] & B00111111)) { //if current alarm is set in DS3231 currentAlarm = e; } } if (currentAlarm == 99) { //if alarm couldn't be determined - eg battery backup removed currentAlarm = 0; //choose alarm 0 displayedAlarm = 0; //needed for setAlarmEeprom setAlarm2(alarmTime[0][1], alarmTime[0][0]); //set to alarm 0 (hours, mins) } resetAlarms(); //so alarm can't trigger on startup //debugging stuff // Serial.begin(9600); // setTime(0,3,10); //Hours,Mins,Secs // setAlarm1(8,30); // setAlarm2(7,30); // for (int s = 0; s<51;s++){ // Serial.print(s); // Serial.print("": ""); // Serial.println(EEPROM.read(s)); // } } void loop() { getButtons(); oldMode = mode; //whilst in a display mode if (mode < totalLoopModes) { if (buttonState[2] == 2) { //if snooze button released if (alarmSet[0]) { //if snoozing mode = 7; //show snoozetime lastSet = millis(); } else { mode++; //next display mode if (mode == totalLoopModes) mode = 0; //loop round if (mode >= stableModes) settingsTimeout = millis(); //set timeout if in a non-stable mode } } if (buttonState[1] == 2 && !changedMode()) { //if al2 switch released if (alarmSet[0]) mode = 7; //if snoozing - show snoozetime else if (mode != 0) mode = 0; //else show time else { //if showing time // printTransition(); // testing mode = 6; //else show alarm displayedAlarm = currentAlarm; } lastSet = millis(); } } if (mode == 0) { if (buttonState[2] == 4 && !alarmTriggered && !alarmSet[0]) { //if showing time and snooze switch long held - go to settings currentSetting[0] = bcdToDec(clockData[1]); //mins currentSetting[1] = bcdToDec(clockData[2]); //hrs setTarget = 0; //set clock settingsMode = 1; //reset to setting hours first mode = 9; //show settings settingsTimeout = millis(); } else if (buttonState[1] == 4 && alarmSet[0]) { //if snoozing and al2 switch long held resetAlarms(); } } //if showing seconds and snooze switch long held if (mode == 1 && buttonState[2] == 4 && !changedMode()) { secondsAnim = !secondsAnim; EEPROM.update(eepromSeconds, secondsAnim); //save setting to EEPROM changedModeFlag = true; //to prevent continuous writing if button held } //if showing snoozetime and snooze button pressed if (mode == 7 && buttonState[2] == 2 && !changedMode()) { //extend snooze and display... snooze(true); //extend lastSet = millis(); } //when alarm displayed if (mode == 6) { if (buttonState[2] == 1 || buttonState[1] == 1) lastSet = millis(); //if either switch pressed, give some extra time to display if (buttonState[1] == 4 && !changedMode() && displayedAlarm != currentAlarm) { //if alarm switch long held and not setting current alarm to itself setAlarm2(alarmTime[displayedAlarm][1], alarmTime[displayedAlarm][0]); //hrs, mins currentAlarm = displayedAlarm; setTarget = 1; //writing to alarm confirm(true); //do some confirming changedModeFlag = true; //changedMode detection required to ensure writing isn't continuous when holding button (EEPROM!!) lastSet = millis(); //start counter for timeout } if (buttonState[2] == 4) { //if snooze switch long held currentSetting[0] = alarmTime[displayedAlarm][0]; //mins currentSetting[1] = alarmTime[displayedAlarm][1]; //hrs setTarget = 1; //set alarm mode = 9; //go to settings settingsMode = 1; //reset to setting hours first lastSet = millis(); settingsTimeout = millis(); //reset timeout } if (buttonState[1] == 2 && !changedMode()) { //if al2 switch released and not just switched to settings lastSet = millis(); displayedAlarm++; //show next alarm if (displayedAlarm == totalAlarms) displayedAlarm = 0; //loop back to first alarm } } //if in settings mode (and not still holding button from entering settings mode) if (mode == 9 && !changedMode()) { if (buttonState[2] == 1 || ((buttonState[2] == 3) && (millis() - incTime > slowIncDelay)) || ((buttonState[2] == 4) && (millis() - incTime > incDelay))) { //if snooze switch pressed or held or longheld and delay since last increment currentSetting[settingsMode]++; //increment current setting if (currentSetting[settingsMode] > currentSettingMax[settingsMode]) currentSetting[settingsMode] = 0; //wrap current setting lastSet = millis(); //set time since last set - so they start flashing after delay incTime = millis(); //set time since last increment - to prevent settings changing too quickly settingsTimeout = millis(); //reset timeout } else if (buttonState[1] == 2) { //if al2 switch released. else used incase both buttons held together settingsMode--; //goto next setting settingsTimeout = millis(); //reset timeout if (settingsMode < 0) { //if past end of settings - save and exit confirm(true); resetAlarms(); //so alarm doesn't trigger instantly switch (setTarget) { //determines target for settings case 0: //clock setTime(currentSetting[1], currentSetting[0], 0); //hours, mins, secs mode = 0; break; case 1: //alarm setAlarm2(currentSetting[1], currentSetting[0]); //write to DS3231 (hours, mins) alarmTime[displayedAlarm][0] = currentSetting[0]; //update alarm mins alarmTime[displayedAlarm][1] = currentSetting[1]; //update alarm hrs currentAlarm = displayedAlarm; //update current alarm mode = 6; //display alarm lastSet = millis(); //save time of setting so alarm can be displayed for a short while break; } } } } //if in print snooze mode if (mode == 3) { if (buttonState[2] == 4) { //if snooze switch long held setSnooze = defaultSnooze; //store current snoozetime mode = 10; //go to snooze settings settingsTimeout = millis(); } } //if in snooze settings mode if (mode == 10 && !changedMode()) { if (buttonState[2] == 1 || ((buttonState[2] >= 3) && (millis() - incTime > slowIncDelay)) || ((buttonState[2] == 4) && (millis() - incTime > incDelay))) { //if snooze switch pressed or held or longheld and delay since last increment setSnooze ++; //increment current setting if (setSnooze > maxSnooze) setSnooze = 1; //roll over max lastSet = millis(); //set time since last set - so they start flashing after delay incTime = millis(); //set time since last increment - to prevent settings changing too quickly settingsTimeout = millis(); //reset timeout } else if (buttonState[1] == 2) { //if al2 switch released. else used incase both buttons held together defaultSnooze = setSnooze; //update defaultSnooze EEPROM.update(eepromSnooze, defaultSnooze); //save setting to EEPROM mode = 3; //change to view mode confirm(true); setTarget = 2; //setting snooze } } //if in alarm tone display mode if (mode == 4) { if (buttonState[2] == 4) { //if snooze switch long held setTone = currentTone; //store current tone mode = 11; //go to tone settings settingsTimeout = millis(); } } //if in alarm tone settings mode if (mode == 11 && !changedMode()) { if (buttonState[2] == 1 || ((buttonState[2] >= 3) && (millis() - incTime > slowIncDelay)) || ((buttonState[2] == 4) && (millis() - incTime > incDelay))) { //if snooze switch pressed or held or longheld and delay since last increment setTone ++; //increment current setting if (setTone > totalTones) setTone = 1; //roll over max lastSet = millis(); //set time since last set - so they start flashing after delay incTime = millis(); //set time since last increment - to prevent settings changing too quickly settingsTimeout = millis(); //reset timeout } else if (buttonState[1] == 2) { //if al2 switch released. else used incase both buttons held together currentTone = setTone; //update defaultSnooze EEPROM.update(eepromTone, currentTone); //save setting to EEPROM mode = 4; //change to view mode confirm(true); setTarget = 2; //setting snooze } } //check alarms if (((alarmStatus[0] && alarmSet[0]) || (alarmStatus[1] && alarmSet[1])) && !alarmTriggered) { alarmTriggered = true; alarmStarted = millis(); resetFade(); // start fading leds from 0 mode = 0; //return to clock } //if alarm currently triggered if (alarmTriggered) { alarmSounds(currentTone); if (buttonState[1] == 4) { //if alarm momentary switch long held when alarm triggered - reset resetAlarms(); mode = 0; //show time } if (buttonState[2] == 2) { snooze(false); //if snooze switch released - snooze mode = 7; //show snoozetime lastSet = millis(); } } else alarmSounds(0); //alarm switch if (buttonState[0] == 0) { //if al1 switch on if (!alarmSet[1] && alarmStatus[1]) resetAlarms(); //if just switched on and alarm previously triggered alarmSet[1] = true; //turn on alarm // alarmSounds(1); //testing } else { //if alarm switch off alarmSet[1] = false; //deactivate alarms if (alarmTriggered || alarmSet[0]) { //if alarm triggered or snoozing resetAlarms(); if (mode == 7) mode = 0; //if showing snoozetime - return to clock } // alarmSounds(0); //testing } //if alarm or snooze displayed without button press, timeout and return to clock if ((mode == 6 || mode == 7) && (millis() - lastSet > displayFor)) mode = 0; //if alarm switch toggled off and currently in settings - exit setting if ((mode >= 9) && (buttonState[0] == 1) && (oldButtonState[0] == 0)) mode = 0; //if currently in settings and no button pressed for a while - exit setting if ((mode >= stableModes) && (millis() - settingsTimeout > setFor)) mode = 0; // //if alarm has sounded without cancel for too long if (alarmTriggered && millis() - alarmStarted > alarmStop) resetAlarms(); //when confirm flash has finished - reset if (millis() - confirmFlashTime > displayFor) confirm(false); getTime(); getTemp(); getAlarm1(); getAlarm2(); getAlarmStatus(); updateLeds(); if (oldSeconds != clockData[0]) changedSeconds = millis(); //save time when seconds changed oldSeconds = clockData[0]; //reset oldSeconds //main mode switch (mode) { case 0: printTime(); break; case 1: printSeconds(); break; case 2: printTemp(); break; case 3: printSnooze(false); //show snooze setting - display only break; case 4: // *new printTone(false); //show alarm tone setting - display only break; case 6: printAlarm(displayedAlarm); //show alarm break; case 7: printSnoozeRemain(); //show time left whilst snoozing break; case 9: printSetting(); //settings break; case 10: printSnooze(true); //show snooze setting and set break; case 11: printTone(true); //display alarm tone and set break; } //check for changes to display since last refresh (warning in datasheet about potential dim segments with continuous writing of same data) int a = 0; for (int c = 0; c < 3; c++) { //check for changes since last refresh if (oldLedByte[c] != ledDisplayByte[c]) a++; //if any display bytes have changed } if (oldLedByte[3] != ledDecode) a++; //plus, if any changes required to control byte if (a > 0) updateDisplay(); //if update required - update } //convert BCD to decimal byte bcdToDec (byte val) { return (10 * ((val & B11110000) >> 4)) + (val & B00001111); } //convert decimal to BCD byte decToBcd (byte val) { return ((val / 10) << 4) | (val % 10); } //detect changed mode boolean changedMode() { if (mode != oldMode) changedModeFlag = true; return changedModeFlag; } //check if seconds is even - for flashing of various items boolean even() { return (clockData[0] % 2) ? true : false; //if seconds are even } //deci-even - for fast flashing of various items boolean dEven() { return ((millis() / 100) % 2) ? true : false; //if millis() / 100 } void setTime(int hrs, int mins, int secs) { //clock/alarm [0=clock, 1/2=alarm], seconds, minutes, hours Wire.beginTransmission(DS3231); Wire.write(0x00); //start at byte 0 Wire.write(decToBcd(secs)); //seconds Wire.write(decToBcd(mins)); //minutes Wire.write(decToBcd(hrs)); //hours and set 24h format // Wire.write(B01000000 | decToBcd(11)); //hours to 11AM, and set 12h format ** not tested, needs indicator setting Wire.endTransmission(); } void setAlarm1(int hours, int mins, int secs) { Wire.beginTransmission(DS3231); Wire.write(0x07); //start at byte 7 Wire.write(decToBcd(secs)); //seconds Wire.write(decToBcd(mins)); //minutes Wire.write(decToBcd(hours)); //hours Wire.write(B10000000); //masked A1M4 so alarm looks for match on hours, mins and secs Wire.endTransmission(); } void setAlarm2(int hours, int mins) { Wire.beginTransmission(DS3231); Wire.write(0x0B); //start at byte 11 Wire.write(decToBcd(mins)); //minutes Wire.write(decToBcd(hours)); //hours Wire.write(B10000000); //masked A2M4 so alarm looks for match on hours and mins // Wire.write(B01000000 | day); //day of week, masked DY/DT so alarm looks for match on dayofweek, hours, mins Wire.endTransmission(); setAlarmEeprom(mins, hours, displayedAlarm); //save to EEPROM } void resetAlarms() { getAlarmStatus(); //read status Wire.beginTransmission(DS3231); Wire.write(0x0F); //start at byte 15 Wire.write(statusData & B11111100); //write back status with alarm flags reset Wire.endTransmission(); alarmTriggered = false; alarmSet[0] = false; //turn off snooze } void snooze(boolean extend) { if (alarmTriggered) resetAlarms(); int snoozeFor; if (extend) { snoozeLeft = bcdToDec((alarm1Data[1] & B01111111)) - bcdToDec(clockData[1]); //mins if (snoozeLeft < 0) snoozeLeft += 60; //rollover if necessary snoozeFor = ((snoozeLeft / 5) * 5) + 5; //increase by 5 mins if (snoozeFor > 55) snoozeFor = 5; //rollover } else snoozeFor = defaultSnooze; int snoozeAlarm[3] = { bcdToDec(clockData[0]), bcdToDec(clockData[1]) + snoozeFor, bcdToDec(clockData[2]) }; //secs, mins,hours if (snoozeAlarm[1] >= 60) { //mins rollover snoozeAlarm[1] -= 60; snoozeAlarm[2]++; if (snoozeAlarm[2] == 24) { //hours rollover snoozeAlarm[2] = 0; } } setAlarm1(snoozeAlarm[2], snoozeAlarm[1], snoozeAlarm[0]); //set Al1: hrs, mins, secs alarmSet[0] = true; //turn on snooze } void setAlarmEeprom (int m, int h, int al) { //mins, hours, alarm target EEPROM.update(al + eepromStart, m); //mins EEPROM.update(al + eepromStart + totalAlarms, h); //hours } void getTime() { Wire.beginTransmission(DS3231); Wire.write(0x00); //read from byte 0 (seconds) Wire.endTransmission(); Wire.requestFrom(DS3231, 3); //request 3 bytes - seconds, minutes, hours for (int i = 0; i < 3; i++) { clockData[i] = Wire.read(); } } void getAlarm1() { Wire.beginTransmission(DS3231); Wire.write(0x07); //read from byte 7 (alarm1 seconds) Wire.endTransmission(); Wire.requestFrom(DS3231, 3); //request 3 bytes - seconds, minutes, hours for (int i = 0; i < 3; i++) { alarm1Data[i] = Wire.read(); } } void getAlarm2() { Wire.beginTransmission(DS3231); Wire.write(0x0B); //read from byte 11 (alarm2 minutes) Wire.endTransmission(); Wire.requestFrom(DS3231, 2); //request 2 bytes - minutes, hours for (int i = 0; i < 2; i++) { alarm2Data[i] = Wire.read(); } } void getAlarmStatus() { Wire.beginTransmission(DS3231); Wire.write(0x0F); //read from byte 15 Wire.endTransmission(); Wire.requestFrom(DS3231, 1); //request 1 byte statusData = Wire.read(); alarmStatus[0] = statusData & B00000001; //alarm1 flag alarmStatus[1] = (statusData & B00000010) >> 1; //alarm2 flag } void getTemp() { Wire.beginTransmission(DS3231); Wire.write(0x11); //read from byte 17 Wire.endTransmission(); Wire.requestFrom(DS3231, 2); //request 2 bytes tempData[0] = Wire.read(); //sign, integer tempData[1] = Wire.read() >> 6; //decimal, shift right as only bytes 7 and 8 are used, +-0.25 accuracy if (oldSeconds != clockData[0]) { //update if seconds have changed. 1 reading per second refresh rate tempLogTotal -= tempLog[tempLogIndex]; //remove old data temperature[0] = (tempData[0] & B10000000) >> 7; //sign. 1=negative temperature[1] = tempData[0] & B01111111; //integer temperature[2] = float(tempData[1] * 0.25); //decimal, in .25 increments tempLog[tempLogIndex] = pow(-1, temperature[0]) * (temperature[1] + temperature[2]); //add data tempLogTotal += tempLog[tempLogIndex]; //add data to total tempLogIndex++; //advance array pointer if (tempLogIndex >= tempLogReadings) tempLogIndex = 0; //loop array pointer if (millis() < 10000) { //if just started up (and for 10 seconds every ~50 days) lazy coding :o| currentTemp = float(round((pow(-1, temperature[0]) * (temperature[1] + temperature[2])) * 2)) / 2; //last reading and round to .5 precision, because array for average will not yet be filled } else currentTemp = float(round((tempLogTotal / float(tempLogReadings)) * 2)) / 2; //calculate new average and round // oldSeconds = clockData[0]; //update oldSeconds with new data } } void getButtons() { buttonData[0] = digitalRead(alarmSw0Pin); buttonData[1] = digitalRead(alarmSw1Pin); buttonData[2] = digitalRead(snoozeSwPin); oldButtonState[0] = buttonState[0]; //save oldButtonState buttonState[0] = 1 - buttonData[0]; //just invert and write state for toggle switch - no debounce needed for (int i = 1; i < totalButtons; i++) { //momentary buttons 1 and 2 if ((millis() - bounceTime[i] > bounceDelay)) { if ((oldButtonData[i] == HIGH) && (buttonData[i] == LOW)) { //detect button press buttonState[i] = 1; holdTime[i] = millis(); //time the button started to be held } else if ((oldButtonData[i] == LOW) && (buttonData[i] == HIGH)) { //detect button release if (oldButtonState[i] == 1) buttonState[i] = 2; //release triggered after press only, not hold if (changedMode()) changedModeFlag = false; //ensure button released after changing mode, to prevent instant incrementing } oldButtonData[i] = buttonData[i]; //refresh bounceTime[i] = millis(); //store time for debounce //no debounce required for held buttons } else if ((millis() > holdTime[i] + longHoldDelay) && (oldButtonData[i] == LOW) && (buttonData[i] == LOW)) { //detect long button hold buttonState[i] = 4; } else if ((millis() > holdTime[i] + holdDelay) && (oldButtonData[i] == LOW) && (buttonData[i] == LOW)) { //detect button hold buttonState[i] = 3; } else buttonState[i] = 0; if (buttonState[i] != 0 ) oldButtonState[i] = buttonState[i]; //store previous button state if (oldButtonState[i] == 1 && buttonState[i] >= 3) incTime = millis(); //if button just started to be held } } void printTime() { ledDisplayByte[2] = dots(false, false, true); //no decimal points, dots on, flashing ledDisplayByte[1] = clockData[2]; //hours ledDisplayByte[0] = clockData[1]; //mins ledDecode = (bcdToDec(clockData[2]) / 10 == 0) ? B1000 : 0; //if leading zero, turn bank 4 off } //12h formatting // Serial.print(bcdToDec(hours & B00011111) ); //12h format mask // Serial.println(ampm( (hours & B00100000) >> 5)); //am/pm indicator, requires function below - 12h format only //String ampm (byte value) { // if (value == 1) return ""PM""; // else return ""AM""; //} void printSeconds() { int bank[8] = {4, 4, 3, 2, 1, 1, 2, 3}; //dots pattern int oct = (millis() - changedSeconds) / 125; //0-7 ledDisplayByte[2] = dots((secondsAnim) ? bank[oct] : 0, false, false); //if animation on scroll decimal points, dots off ledDisplayByte[1] = 0; //blank the left hand digits ledDisplayByte[0] = clockData[0]; //seconds ledDecode = B1100; //special decode on banks 3 & 4 to allow blanking } //display time left to snooze void printSnoozeRemain() { snoozeLeft = bcdToDec((alarm1Data[1] & B01111111)) - bcdToDec(clockData[1]); //mins if (snoozeLeft < 0) snoozeLeft += 60; //rollover if necessary ledDisplayByte[2] = dots(false, true, false); //no decimal points, dots on ledDisplayByte[1] = 0; //blank left hand digits ledDisplayByte[0] = decToBcd(snoozeLeft); ledDecode = (snoozeLeft / 10 == 0) ? B1110 : B1100; //if leading zero, turn bank 2, 3 & 4 off else turn off banks 3 & 4 } //time to snooze for void printSnooze(boolean set) { ledDisplayByte[2] = dots(B11, false, false); //decimal point 3 on, dots off ledDisplayByte[1] = B01010110; //display 5n in the left hand digits ledDisplayByte[0] = decToBcd((set) ? setSnooze : defaultSnooze); //if setting ledDecode = (bcdToDec(ledDisplayByte[0]) / 10 == 0) ? B0110 : B0100; //special decode on banks 2 & 3 to allow n and blanking, else special on 3 if ((millis() - lastSet > 1000 && even() && set) || (confirmFlash && dEven())) { //if setting and buttons not pressed and none have been pressed for over 1 second, or confirming, begin flashing ledDisplayByte[0] = 0; //set mins digit to 0 ledDecode = B0111; //special on banks 2 & 3 & 1 } } //print alarm from RTC ***only required for testing now void printAlarm2() { ledDisplayByte[2] = dots(false, true, false); //no decimal points, dots on ledDisplayByte[1] = alarm2Data[1] & B00111111; //hours ledDisplayByte[0] = alarm2Data[0] & B01111111; //mins ledDecode = (bcdToDec(alarm2Data[1]) / 10 == 0) ? B1000 : 0; //if leading zero, turn bank 4 off } //print alarms (retrieved from EEPROM, not RTC) void printAlarm(int al) { ledDisplayByte[2] = dots(false, true, false); //no decimal points, dots on ledDisplayByte[1] = decToBcd(alarmTime[al][1]); //hours ledDisplayByte[0] = decToBcd(alarmTime[al][0]); //mins ledDecode = (alarmTime[al][1] / 10 == 0) ? B1000 : 0; //if leading zero, turn bank 4 off } //general settings mode for clock and alarm void printSetting() { ledDisplayByte[2] = dots(false, true, false); //no decimal points, dots on ledDisplayByte[1] = decToBcd(currentSetting[1]); //hours ledDisplayByte[0] = decToBcd(currentSetting[0]); //mins ledDecode = (currentSetting[1] / 10 == 0) ? B1000 : 0; //if leading zero, turn bank 4 off if (millis() - lastSet > 1000 && even()) { //if buttons not pressed and none have been pressed for over 1 second, begin flashing if (settingsMode == 1) { ledDisplayByte[1] = 0; //set hrs digit to 0 ledDecode = B1100; //turn off banks 3 & 4 } else { ledDisplayByte[0] = 0; //set mins digit to 0 ledDecode = (currentSetting[1] / 10 == 0) ? B1011 : B0011; //turn off banks 1, 2 & 4 else turn off banks 1 & 2 } } } // **add check for negative flag and display it in place of the bank 4 digit? interference with bank 5 no decode? void printTemp() { ledDisplayByte[2] = dots(B11, false, false); //decimal point on, dots off ledDisplayByte[1] = decToBcd(int(currentTemp)); //left hand digits ledDisplayByte[0] = (int(currentTemp * 10) % 10) << 4 | B1100; //right hand digit with upper case C character (12) ledDecode = (int(currentTemp) / 10 == 0) ? B1000 : 0; //if leading zero in left hand digit, turn off bank 4 } //setting alarm tone void printTone(boolean set) { ledDisplayByte[2] = dots(B11, false, false); //decimal point 3 on, dots off ledDisplayByte[1] = B10100101; //display AL on left hand digits ledDisplayByte[0] = decToBcd((set) ? setTone : currentTone); //if setting ledDecode = B0110; //special decode on bank 3 for L, bank 2 for blanking if ((millis() - lastSet > 1000 && even() && set) || (confirmFlash && dEven())) { //if setting and buttons not pressed and none have been pressed for over 1 second, or confirming, begin flashing ledDisplayByte[0] = 0; //set mins digit to 0 ledDecode = B0111; //special on banks 2 & 3 & 1 } } //transition between display modes void printTransition() { int del = 70; //!! testing only !!! byte oldT[3]; byte newT[3]; for (int d = 0; d < 3; d++) { oldT[d] = ledDisplayByte[d]; } printAlarm(displayedAlarm); //update ledDisplay byte with new values for (int e = 0; e < 3; e++) { newT[e] = ledDisplayByte[e]; } ledDisplayByte[2] = dots(false, false, false); //keep dots off ledDisplayByte[1] = oldT[1] >> 4; ledDisplayByte[0] = (oldT[0] >> 4) | (oldT[1] << 4); ledDecode = B1000; updateDisplay(); delay(del); ledDisplayByte[1] = 0; ledDisplayByte[0] = oldT[1]; ledDecode = B1100; updateDisplay(); delay(del); ledDisplayByte[0] = oldT[1] >> 4; ledDecode = B1110; updateDisplay(); delay(del); ledDisplayByte[1] = newT[0] << 4; ledDisplayByte[0] = 0; ledDecode = B0111; updateDisplay(); delay(del); ledDisplayByte[1] = newT[0]; ledDecode = B0011; updateDisplay(); delay(del); ledDisplayByte[1] = newT[1] << 4 | (newT[0] >> 4); ledDisplayByte[0] = newT[0] << 4; ledDecode = B0001; updateDisplay(); delay(del); mode = 6; } //write to the display void updateDisplay() { byte ledControlByte; ledControlByte = B11100001; //low power mode off, special decode selected for all banks but enabled on bank 5 only ledControlByte |= ledDecode << 1; //enable led decode on individual banks 1-4 B00011110 oldLedByte[3] = ledDecode; //store new control byte decode //write to display register digitalWrite(ledEnable, LOW); for (int d = 2; d >= 0; d--) { shiftOut(ledData, ledClock, MSBFIRST, ledDisplayByte[d]); // shift out brightness, decimal points and other leds data oldLedByte[d] = ledDisplayByte[d]; //store existing value } digitalWrite(ledEnable, HIGH); //write data to configuration register digitalWrite(ledEnable, LOW); shiftOut(ledData, ledClock, MSBFIRST, ledControlByte); digitalWrite(ledEnable, HIGH); } void updateLeds() { //fade leds if (fadeDir) fadeValue--; //going down else fadeValue++; //going up if (fadeValue == 255 || fadeValue == 0) fadeDir = !fadeDir; //change direction if (alarmTriggered) { analogWrite (snoozeLedPin, fadeValue); //fade snooze LED alarmLed = dEven(); //flash alarm led } else { //if alarm not triggered analogWrite (snoozeLedPin, (alarmSet[0]) ? fadeValue : 0); //if snoozing - fade snooze led if (mode == 9 && setTarget == 1) { //if setting alarm alarmLed = !even(); //flash alarm led slowly } else if (confirmFlash && (millis() - confirmFlashTime < displayFor)) { //if confirming setting switch (setTarget) { case 0: //if time was set if (dEven()) flashDots = true; //flash dots else flashDots = false; break; case 1: //if alarm was set flashDots = true; //dots should be on whilst flashing alarm confirm if (dEven()) alarmLed = true; //flash alarm led else alarmLed = false; break; case 2: //if snooze was set flashDots = false; //dots should be on whilst flashing alarm confirm break; } } else if (alarmSet[1]) alarmLed = true; //if alarm turned on, activate alarm led else alarmLed = false; if (mode == 5 & displayedAlarm != currentAlarm) alarmLed = false; //if showing an alarm, but it's not currently set } } //reset the fading of the snooze LED void resetFade() { fadeValue = 0; fadeDir = 0; } //control flashing of LEDs to confirm settings void confirm(boolean activate) { if (activate) { confirmFlash = true; confirmFlashTime = millis(); } else confirmFlash = false; } //control of bank 5 and decimal points byte dots(byte decimal, boolean separator, boolean flash) { //[1XX = decimal point on, X1X = dots on, X01 = flashing dots] int d = 0; //counter for which dots to use **better and more clever way to do this with different pins and mathmatics? byte b = B10000000; //full brightness b |= (decimal << 4); //decimal point B01110000 if (alarmLed) d += 1; //alarm led if ((confirmFlash && flashDots) || (!confirmFlash && (separator || (flash && even())))) d += 2 ; //if confirming with dots, or flashing dots or dots on switch (d) { case 1: b |= B00001000; break; case 2: b |= B00000011; break; case 3: b |= B00000010; break; } return b; } //control alarm sounds void alarmSounds(int type) { if (type == 0) { //alarm off if (toneActive) { noTone(piezoPin); pinMode(piezoPin, INPUT); //stop that annoying quiet buzzing sound... toneReps = 0; //reset toneActive = false; } } else if ((millis() - toneStarted) > (toneDuration + toneDelay)) { unsigned long alarmAlapsed = millis() - alarmStarted; toneActive = true; switch (type) { case 1: switch (toneReps) { //cool but harsh - some variation due to the multipliers case 0: t = 30; toneReps++; break; case 1: if (t < (alarmAlapsed / 500)+random(31,100)) { sound(random(alarmAlapsed/1000),t+random(1,20), 0); t *= 1.1; } else toneReps++; break; case 2: t = 50; toneReps++; break; case 3: if (t < (alarmAlapsed / 900)+random(51,100)) { sound(t, (alarmAlapsed / random(10,2000))+10, 0); t *= 1.25; } else toneReps = 0; break; } break; // switch (toneReps) { //cool but harsh - some variation due to the multipliers // case 0: // t = 50; // toneReps++; // break; // case 1: // if (t < 2500) { // sound(t, 60, 0); // t *= 1.45; // } else toneReps++; // break; // case 2: // t = 50; // toneReps++; // break; // case 3: // if (t < 4000) { // sound(t, 20, 0); // t *= 1.5; // } else toneReps = 0; // break; case 2: switch (toneReps) { //siren case 0: t = 5; toneReps++; break; case 1: if (t < 1500) { sound(t, 10, 0); t += 5; } else toneReps++; break; case 2: if (t > 5) { sound(t, 10, 0); t -= 5; } else toneReps = 0; break; } break; case 3: switch (toneReps) { case 0: sound(100, 50, 120); toneReps++; break; case 1: sound(200, 50, 120); toneReps++; break; case 2: sound(300, 50, 120); toneReps++; break; case 3: sound(800, 50, 120); toneReps++; break; case 4: sound(2000, 100, 120); toneReps = 0; break; } break; } } } //generate sound using tone void sound(int freq, int dur, int del) { tone(piezoPin, freq, dur); toneDuration = dur; toneDelay = del; toneStarted = millis(); } ",12082,False,2082.1239616195016,median "//Author : Sandhan Sarma //Date : 16th December 2018 #include #include #include U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Copy the contents of your .xbm file below #define skeletor_width 64 #define skeletor_height 64 const static unsigned char skeletor_bits[4][512] PROGMEM = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf9, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xfe, 0xbf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0xff, 0x7f, 0x02, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xff, 0xff, 0x09, 0x00, 0x00, 0x00, 0x00, 0x24, 0xfe, 0x3f, 0x12, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xfd, 0xdf, 0x37, 0x00, 0x00, 0x00, 0x00, 0xda, 0xfb, 0xef, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x8d, 0xff, 0xff, 0x58, 0x00, 0x00, 0x00, 0x80, 0x05, 0xfe, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x30, 0x06, 0xd0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x90, 0x04, 0xd0, 0x00, 0x00, 0x00, 0xc0, 0x05, 0xc8, 0x09, 0xd0, 0x01, 0x00, 0x00, 0xc0, 0x06, 0xce, 0x39, 0xb0, 0x01, 0x00, 0x00, 0xe0, 0xfa, 0xff, 0xff, 0xaf, 0x03, 0x00, 0x00, 0xe0, 0xfe, 0xfe, 0xbf, 0xbf, 0x03, 0x00, 0x00, 0x70, 0x7f, 0xff, 0x7f, 0x7f, 0x07, 0x00, 0x00, 0x70, 0xbf, 0x5f, 0xfd, 0x7e, 0x07, 0x00, 0x00, 0x70, 0xbf, 0x6f, 0xfb, 0x7e, 0x07, 0x00, 0x00, 0x78, 0xcf, 0x6b, 0xeb, 0x79, 0x0f, 0x00, 0x00, 0x78, 0x4f, 0x6d, 0x5b, 0x79, 0x0f, 0x00, 0x00, 0x38, 0x86, 0x0d, 0xd8, 0x30, 0x0e, 0x00, 0x00, 0x3c, 0x82, 0x00, 0x80, 0x20, 0x1e, 0x00, 0x00, 0x3c, 0x10, 0x00, 0x00, 0x04, 0x1e, 0x00, 0x00, 0x3c, 0x18, 0x60, 0x03, 0x0c, 0x1e, 0x00, 0x00, 0x3c, 0x3c, 0x6c, 0x1b, 0x1e, 0x1e, 0x00, 0x00, 0x3c, 0x3c, 0x5c, 0x1d, 0x1e, 0x1e, 0x00, 0x00, 0x3e, 0x3c, 0xf7, 0x77, 0x1e, 0x3e, 0x00, 0x00, 0x3e, 0x3c, 0xfd, 0x5f, 0x1e, 0x3e, 0x00, 0x00, 0x3e, 0x78, 0xfe, 0x3f, 0x0f, 0x3e, 0x00, 0x00, 0x3e, 0xf8, 0xff, 0xff, 0x0f, 0x3e, 0x00, 0x00, 0x3e, 0xf8, 0xff, 0xff, 0x0f, 0x3e, 0x00, 0x00, 0x3f, 0xf8, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x1f, 0xfc, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x07, 0xf0, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x01, 0xc0, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x80, 0x07, 0x7e, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xc0, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0x01, 0xe0, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0x03, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0xfc, 0xff, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xe0, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf9, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xfe, 0xbf, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0xff, 0x7f, 0x02, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xff, 0xff, 0x09, 0x00, 0x00, 0x00, 0x00, 0x24, 0xfe, 0x3f, 0x12, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xfd, 0xdf, 0x37, 0x00, 0x00, 0x00, 0x00, 0xda, 0xfb, 0xef, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x8d, 0xff, 0xff, 0x58, 0x00, 0x00, 0x00, 0x80, 0x05, 0xfe, 0x3f, 0xd0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x30, 0x06, 0xd0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x90, 0x04, 0xd0, 0x00, 0x00, 0x00, 0xc0, 0x05, 0xc8, 0x09, 0xd0, 0x01, 0x00, 0x00, 0xc0, 0x06, 0xce, 0x39, 0xb0, 0x01, 0x00, 0x00, 0xe0, 0xfa, 0xff, 0xff, 0xaf, 0x03, 0x00, 0x00, 0xe0, 0xfe, 0xfe, 0xbf, 0xbf, 0x03, 0x00, 0x00, 0x70, 0x7f, 0xff, 0x7f, 0x7f, 0x07, 0x00, 0x00, 0x70, 0xbf, 0x5f, 0xfd, 0x7e, 0x07, 0x00, 0x00, 0x70, 0xbf, 0x6f, 0xfb, 0x7e, 0x07, 0x00, 0x00, 0x78, 0xcf, 0x6b, 0xeb, 0x79, 0x0f, 0x00, 0x00, 0x78, 0x4f, 0x6d, 0x5b, 0x79, 0x0f, 0x00, 0x00, 0x38, 0x86, 0x0d, 0xd8, 0x30, 0x0e, 0x00, 0x00, 0x3c, 0x82, 0x00, 0x80, 0x20, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x3c, 0x10, 0x00, 0x00, 0x04, 0x1e, 0x00, 0x00, 0x3e, 0x18, 0x60, 0x03, 0x0c, 0x3e, 0x00, 0x00, 0x3e, 0x3c, 0x6c, 0x1b, 0x1e, 0x3e, 0x00, 0x00, 0x3e, 0x3c, 0x5c, 0x1d, 0x1e, 0x3e, 0x00, 0x00, 0x3e, 0x3c, 0xf7, 0x77, 0x1e, 0x3e, 0x00, 0x00, 0x3e, 0x3c, 0xfd, 0x5f, 0x1e, 0x3e, 0x00, 0x00, 0x3f, 0x78, 0xfe, 0x3f, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x1f, 0xfc, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x07, 0xf0, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf8, 0x01, 0xc0, 0x0f, 0x7e, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x80, 0x07, 0x7e, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0x00, 0xc0, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0x01, 0xe0, 0xff, 0x07, 0x00, 0x00, 0xf0, 0xff, 0x03, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xf8, 0xff, 0x1f, 0x00, 0x00, 0xfc, 0xff, 0x0f, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0xfc, 0xff, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xe0, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0xf8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfc, 0x1f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0x30, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xff, 0xff, 0x19, 0x00, 0x00, 0x00, 0x00, 0xec, 0xff, 0xff, 0x3b, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x80, 0x08, 0xff, 0xff, 0x88, 0x00, 0x00, 0x00, 0x80, 0x08, 0xff, 0xff, 0x88, 0x00, 0x00, 0x00, 0xc0, 0xfc, 0xfe, 0x3f, 0xbf, 0x01, 0x00, 0x00, 0x40, 0xf6, 0xfd, 0xdf, 0x77, 0x01, 0x00, 0x00, 0xa0, 0xe3, 0xff, 0xff, 0xe3, 0x02, 0x00, 0x00, 0xb0, 0x01, 0xff, 0x7f, 0x80, 0x06, 0x00, 0x00, 0xb0, 0x01, 0x38, 0x0e, 0x80, 0x06, 0x00, 0x00, 0x30, 0x01, 0x38, 0x0e, 0x80, 0x06, 0x00, 0x00, 0x30, 0x01, 0x98, 0x08, 0xc0, 0x06, 0x00, 0x00, 0x38, 0x01, 0xc4, 0x11, 0xc0, 0x0e, 0x00, 0x00, 0xd8, 0x01, 0xc7, 0x71, 0xc0, 0x0d, 0x00, 0x00, 0x9c, 0xfe, 0xff, 0xff, 0xbf, 0x1d, 0x00, 0x00, 0x9c, 0x7f, 0xff, 0x7f, 0xff, 0x1d, 0x00, 0x00, 0xee, 0xbf, 0xff, 0xff, 0xfc, 0x3b, 0x00, 0x00, 0xce, 0xbf, 0xff, 0xff, 0xfc, 0x3b, 0x00, 0x00, 0xce, 0xdf, 0x5f, 0xfd, 0xf9, 0x3b, 0x00, 0x00, 0xde, 0xdf, 0x6b, 0xeb, 0xf9, 0x3b, 0x00, 0x00, 0xdf, 0xe3, 0x6d, 0xdb, 0xe7, 0x79, 0x00, 0x00, 0xdf, 0xa3, 0x6e, 0xbb, 0xe6, 0x79, 0x00, 0x00, 0x8f, 0xc1, 0x06, 0xb0, 0xc1, 0x70, 0x00, 0x80, 0x8f, 0x40, 0x00, 0x00, 0x81, 0xf0, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x08, 0x00, 0x00, 0x18, 0xf8, 0x00, 0xc0, 0x0f, 0x0c, 0x60, 0x03, 0x38, 0xf8, 0x01, 0xc0, 0x0f, 0x1f, 0x6c, 0x1b, 0x7c, 0xf8, 0x01, 0x80, 0x0f, 0x1e, 0x5e, 0x3d, 0x7c, 0xf8, 0x01, 0x80, 0x0f, 0x9e, 0xf7, 0xef, 0x7c, 0xf8, 0x01, 0x80, 0x0f, 0x9e, 0xfe, 0xbf, 0x3c, 0xf8, 0x00, 0xc0, 0x0f, 0x3c, 0xff, 0x7f, 0x1e, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x01, 0xc0, 0x1f, 0xfc, 0x1f, 0xfc, 0x1f, 0xf8, 0x01, 0xc0, 0x1f, 0xfc, 0x07, 0xf0, 0x1f, 0xfc, 0x01, 0xc0, 0x1f, 0xfc, 0x01, 0x80, 0x1f, 0xfc, 0x01, 0xc0, 0x1f, 0xf8, 0x00, 0x00, 0x0f, 0xfc, 0x01, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xe0, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xf0, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0x07, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xf8, 0xff, 0x07, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xe0, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00, 0x3c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfc, 0x1f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x30, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0x30, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xff, 0xff, 0x19, 0x00, 0x00, 0x00, 0x00, 0xec, 0xff, 0xff, 0x3b, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x80, 0x08, 0xff, 0xff, 0x88, 0x00, 0x00, 0x00, 0x80, 0x08, 0xff, 0xff, 0x88, 0x00, 0x00, 0x00, 0xc0, 0xfc, 0xfe, 0x3f, 0xbf, 0x01, 0x00, 0x00, 0x40, 0xf6, 0xfd, 0xdf, 0x77, 0x01, 0x00, 0x00, 0xa0, 0xe3, 0xff, 0xff, 0xe3, 0x02, 0x00, 0x00, 0xb0, 0x01, 0xff, 0x7f, 0x80, 0x06, 0x00, 0x00, 0xb0, 0x01, 0x38, 0x0e, 0x80, 0x06, 0x00, 0x00, 0x30, 0x01, 0x38, 0x0e, 0x80, 0x06, 0x00, 0x00, 0x30, 0x01, 0x98, 0x08, 0xc0, 0x06, 0x00, 0x00, 0x38, 0x01, 0xc4, 0x11, 0xc0, 0x0e, 0x00, 0x00, 0xd8, 0x01, 0xc7, 0x71, 0xc0, 0x0d, 0x00, 0x00, 0x9c, 0xfe, 0xff, 0xff, 0xbf, 0x1d, 0x00, 0x00, 0x9c, 0x7f, 0xff, 0x7f, 0xff, 0x1d, 0x00, 0x00, 0xee, 0xbf, 0xff, 0xff, 0xfc, 0x3b, 0x00, 0x00, 0xce, 0xbf, 0xff, 0xff, 0xfc, 0x3b, 0x00, 0x00, 0xce, 0xdf, 0x5f, 0xfd, 0xf9, 0x3b, 0x00, 0x00, 0xde, 0xdf, 0x6b, 0xeb, 0xf9, 0x3b, 0x00, 0x00, 0xdf, 0xe3, 0x6d, 0xdb, 0xe7, 0x79, 0x00, 0x00, 0xdf, 0xa3, 0x6e, 0xbb, 0xe6, 0x79, 0x00, 0x00, 0x8f, 0xc1, 0x06, 0xb0, 0xc1, 0x70, 0x00, 0x80, 0x8f, 0x40, 0x00, 0x00, 0x81, 0xf0, 0x00, 0x80, 0x0f, 0x08, 0x00, 0x00, 0x18, 0xf8, 0x00, 0x80, 0x0f, 0x0c, 0x60, 0x03, 0x38, 0xf8, 0x00, 0x80, 0x0f, 0x1f, 0x6c, 0x1b, 0x7c, 0xf8, 0x00, 0x80, 0x0f, 0x1e, 0x5e, 0x3d, 0x7c, 0xf8, 0x00, 0xc0, 0x0f, 0x9e, 0xf7, 0xef, 0x7c, 0xf8, 0x01, 0xc0, 0x0f, 0x9e, 0xfe, 0xbf, 0x3c, 0xf8, 0x01, 0x80, 0x0f, 0x3c, 0xff, 0x7f, 0x1e, 0xf8, 0x01, 0x80, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x01, 0x80, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x00, 0xc0, 0x0f, 0xfc, 0xff, 0xff, 0x1f, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0x1f, 0xfc, 0x1f, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0x07, 0xf0, 0x1f, 0xf8, 0x01, 0xc0, 0x0f, 0xfc, 0x01, 0x80, 0x1f, 0xf8, 0x01, 0xc0, 0x1f, 0xf8, 0x00, 0x00, 0x0f, 0xf8, 0x01, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xe0, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xf0, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0x07, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0xf8, 0xff, 0x07, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xe0, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x0f, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; void draw(void) { // graphic commands to redraw the complete screen should be placed here static uint8_t frame = 0 ; switch(frame){ case 0: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[0]);break; case 1: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[1]);break; case 2: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[0]);break; case 3: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[1]);break; case 4: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[2]);break; case 5: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[3]);break; case 6: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[2]);break; case 7: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[3]);break; case 8: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[2]);break; case 9: u8g2.drawXBMP( 32, 0, skeletor_width, skeletor_height, skeletor_bits[1]);break; } frame++; if(frame>9){ frame = 0; } } void setup(void) { u8g2.begin(); } void loop(void) { // picture loop u8g2.firstPage(); do { draw(); } while ( u8g2.nextPage() ); // rebuild the picture after some delay delay(70); } ",12202,True,3804.5815397898364,median "############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 6, 0x90 .globl _k0_cpMontSqr1024_avx2 _k0_cpMontSqr1024_avx2: push %rbx push %rbp push %r12 push %r13 push %r14 sub $(64), %rsp movslq %ecx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rcx,8) vmovdqu %ymm11, (%rdx,%rcx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) movq %rcx, (24)(%rsp) movq %r8, (32)(%rsp) mov $(40), %rcx mov %r9, %rdi movq %rdi, (48)(%rsp) lea (%rdi,%rcx,8), %rbx lea (%rbx,%rcx,8), %r9 movq %r9, (40)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_1 .p2align 6, 0x90 .Lsqr1024_loop4gas_1: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_1: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_1 movq (48)(%rsp), %rdi movq (16)(%rsp), %rcx movq (32)(%rsp), %r8 mov $(38), %r9 movq (%rdi), %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rdi), %ymm1 vmovdqu (64)(%rdi), %ymm2 vmovdqu (96)(%rdi), %ymm3 vmovdqu (128)(%rdi), %ymm4 vmovdqu (160)(%rdi), %ymm5 vmovdqu (192)(%rdi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rdi), %ymm7 vmovdqu (256)(%rdi), %ymm8 vmovdqu (288)(%rdi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_1: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_1 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rdi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rdi), %ymm14, %ymm9 add $(32), %rdi sub $(2), %r9 jnz .Lreduction_loopgas_1 .Lexit_reduction_loopgas_1: movq (%rsp), %rdi movq %r12, (%rdi) movq %r13, (8)(%rdi) vmovdqu %ymm1, (16)(%rdi) vmovdqu %ymm2, (48)(%rdi) vmovdqu %ymm3, (80)(%rdi) vmovdqu %ymm4, (112)(%rdi) vmovdqu %ymm5, (144)(%rdi) vmovdqu %ymm6, (176)(%rdi) vmovdqu %ymm7, (208)(%rdi) vmovdqu %ymm8, (240)(%rdi) vmovdqu %ymm9, (272)(%rdi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_1: addq (%rdi), %rax add $(8), %rdi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (-8)(%rdi) sub $(1), %r9 jg .Lnorm_loopgas_1 movq %rax, (%rdi) add $(64), %rsp vzeroupper pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .p2align 6, 0x90 .globl _k0_cpSqr1024_avx2 _k0_cpSqr1024_avx2: push %rbx sub $(48), %rsp movslq %edx, %rdx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rdx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) mov $(40), %rdx mov %rcx, %rdi movq %rdi, (32)(%rsp) lea (%rdi,%rdx,8), %rbx lea (%rbx,%rdx,8), %r9 movq %r9, (24)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_2 .p2align 6, 0x90 .Lsqr1024_loop4gas_2: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_2: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_2 movq (32)(%rsp), %rsi movq (%rsp), %rdi mov $(76), %r9 xor %rax, %rax .Lnorm_loopgas_2: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_2 movq %rax, (%rdi) add $(48), %rsp vzeroupper pop %rbx ret .p2align 6, 0x90 .globl _k0_cpMontRed1024_avx2 _k0_cpMontRed1024_avx2: push %r12 push %r13 movslq %ecx, %r9 mov %rdx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rdx,%r9,8) movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_3: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_3 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rsi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rsi), %ymm14, %ymm9 add $(32), %rsi sub $(2), %r9 jnz .Lreduction_loopgas_3 .Lexit_reduction_loopgas_3: movq (%rsp), %rsi movq %r12, (%rsi) movq %r13, (8)(%rsi) vmovdqu %ymm1, (16)(%rsi) vmovdqu %ymm2, (48)(%rsi) vmovdqu %ymm3, (80)(%rsi) vmovdqu %ymm4, (112)(%rsi) vmovdqu %ymm5, (144)(%rsi) vmovdqu %ymm6, (176)(%rsi) vmovdqu %ymm7, (208)(%rsi) vmovdqu %ymm8, (240)(%rsi) vmovdqu %ymm9, (272)(%rsi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_3: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_3 movq %rax, (%rdi) vzeroupper pop %r13 pop %r12 ret ",16367,True,4221.562829994452,median ";Intel® 64 and IA-32 Architectures Software Developer’s Manual. Vol 1 (2015-01) ;5.1 GENERAL-PURPOSE INSTRUCTIONS ;5.1.1 Data Transfer Instructions mov|cmove|cmovz|cmovne|cmovnz|cmova|cmovnbe|cmovae|cmovnb|cmovb|cmovnae cmovbe|cmovna|cmovg|cmovnle|cmovge|cmovnl|cmovl|cmovnge|cmovle|cmovng cmovc|cmovnc|cmovo|cmovno|cmovs|cmovns|cmovp|cmovpe|cmovnp|cmovpo xchg|bswap|xadd|cmpxchg|cmpxchg8b push|pop|pusha|pushad|popa|popad cwd|cdq|cbw|cwde movsx|movzx ;5.1.2 Binary Arithmetic Instructions adcx|adox|add|adc|sub|sbb|imul|mul|idiv|div|inc|dec|neg|cmp| ;5.1.3 Decimal Arithmetic Instructions daa|das|aaa|aas|aam|aad ;5.1.4 Logical Instructions and|or|xor|not ;5.1.5 Shift and Rotate Instructions sar|shr|sal|shl|shrd|shld|ror|rol|rcr|rcl ;5.1.6 Bit and Byte Instructions bt|bts|btr|btc|bsf|bsr sete|setz|setne|setnz|seta|setnbe|setae|setnb|setnc|setb|setnae|setc setbe|setna|setg|setnle|setge|setnl|setl|setnge|setle|setng sets|setns|seto|setno|setpe|setp|setpo|setnp test|crc32|popcnt ;5.1.7 Control Transfer Instructions jmp|je|jz|jne|jnz|ja|jnbe|jae|jnb|jb|jnae|jbe|jna|jg|jnle|jge|jnl|jl|jnge|jle|jng jc|jnc|jo|jno|js|jns|jpo|jnp|jpe|jp|jcxz|jecxz loop|loopz|loope|loopnz|loopne call|ret|iret|int|into|bound|enter|leave ;5.1.8 String Instructions movs|movsb|movs|movsw|movs|movsd cmps|cmpsb|cmps|cmpsw|cmps|cmpsd scas|scasb|scas|scasw|scas|scasd lods|lodsb|lods|lodsw|lods|lodsd stos|stosb|stos|stosw|stos|stosd rep|repe|repz|repne|repnz ;5.1.9 I/O Instructions in|out|ins|insb|ins|insw|ins|insd|outs|outsb|outs|outsw|outs|outsd ;5.1.10 Enter and Leave Instructions enter|leave ;5.1.11 Flag Control (EFLAG) Instructions stc|clc|cmc|cld|std|lahf|sahf|pushf|pushfd|popf|popfd|sti|cli ;5.1.12 Segment Register Instructions lds|les|lfs|lgs|lss ;5.1.13 Miscellaneous Instructions lea|nop|ud2|xlat|xlatb|cpuid|movbe|prefetchw|prefetchwt1 ;5.1.14 Random Number Generator Instructions rdrand|rdseed ;5.1.15 BMI1, BMI2 andn|bextr|blsi|blsmsk|blsr|bzhi|lzcnt|mulx|pdep|pext|rorx|sarx|shlx|shrx|tzcnt ;5.2 X87 FPU INSTRUCTIONS ;5.2.1 x87 FPU Data Transfer Instructions fld|fst|fstp|fild|fist|fistp|fbld|fbstp|fxch fcmove|fcmovne|fcmovb|fcmovbe|fcmovnb|fcmovnbe|fcmovu|fcmovnu ;5.2.2 x87 FPU Basic Arithmetic Instructions fadd|faddp|fiadd|fsub|fsubp|fisub|fsubr|fsubrp|fisubr fmul|fmulp|fimul|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr fprem|fprem1|fabs|fchs|frndint|fscale|fsqrt|fxtract ;5.2.3 x87 FPU Comparison Instructions fcom|fcomp|fcompp|fucom|fucomp|fucompp|ficom|ficomp|fcomi|fucomi|fcomip|fucomip|ftst|fxam ;5.2.4 x87 FPU Transcendental Instructions fsin|fcos|fsincos|fptan|fpatan|f2xm1|fyl2x|fyl2xp1 ;5.2.5 x87 FPU Load Constants Instructions fld1|fldz|fldpi|fldl2e|fldln2|fldl2t|fldlg2 ;5.2.6 x87 FPU Control Instructions fincstp|fdecstp|ffree|finit|fninit|fclex|fnclex|fstcw|fnstcw fldcw|fstenv|fnstenv|fldenv|fsave|fnsave|frstor|fstsw|fnstsw wait|fwait|fnop ;5.3 X87 FPU AND SIMD STATE MANAGEMENT INSTRUCTIONS fxsave|fxrstor ;5.4 MMX™ INSTRUCTIONS ;5.4.1 MMX Data Transfer Instructions movd|movq ;5.4.2 MMX Conversion Instructions packsswb|packssdw|packuswb|punpckhbw|punpckhwd|punpckhdq|punpcklbw|punpcklwd|punpckldq ;5.4.3 MMX Packed Arithmetic Instructions paddb|paddw|paddd|paddsb|paddsw|paddusb|paddusw psubb|psubw|psubd|psubsb|psubsw|psubusb|psubusw pmulhw|pmullw|pmaddwd ;5.4.4 MMX Comparison Instructions pcmpeqb|pcmpeqw|pcmpeqd|pcmpgtb|pcmpgtw|pcmpgtd ;5.4.5 MMX Logical Instructions pand|pandn|por|pxor ;5.4.6 MMX Shift and Rotate Instructions psllw|pslld|psllq|psrlw|psrld|psrlq|psraw|psrad ;5.4.7 MMX State Management Instructions emms ;5.5 SSE INSTRUCTIONS ;5.5.1 SSE SIMD Single-Precision Floating-Point Instructions ;5.5.1.1 SSE Data Transfer Instructions movaps|movups|movhps|movhlps|movlps|movlhps|movmskps|movss ;5.5.1.2 SSE Packed Arithmetic Instructions addps|addss|subps|subss|mulss|mulps|divps|divss rcpps|rcpss|sqrtps|sqrtss|rsqrtps|rsqrtss maxps|maxss|minps|minss ;5.5.1.3 SSE Comparison Instructions cmpps|cmpss|comiss|ucomiss ;5.5.1.4 SSE Logical Instructions andps|andnps|orps|xorps ;5.5.1.5 SSE Shuffle and Unpack Instructions shufps|unpckhps|unpcklps ;5.5.1.6 SSE Conversion Instructions cvtpi2ps|cvtsi2ss|cvtps2pi|cvttps2pi|cvtss2si|cvttss2si ;5.5.2 SSE MXCSR State Management Instructions ldmxcsr|stmxcsr ;5.5.3 SSE 64-Bit SIMD Integer Instructions pavgb|pavgw|pextrw|pinsrw|pmaxub|pmaxsw|pminub|pminsw|pmovmskb|pmulhuw|psadbw|pshufw ;5.5.4 SSE Cacheability Control, Prefetch, and Instruction Ordering Instructions maskmovq|movntps|sfence prefetchnta|prefetcht0|prefetcht1|prefetcht2|prefetchw|prefetchwt1 ;5.6 SSE2 INSTRUCTIONS ;5.6.1 SSE2 Packed and Scalar Double-Precision Floating-Point Instructions ;5.6.1.1 SSE2 Data Movement Instructions movapd|movupd|movhpd|movlpd|movmskpd|movsd ;5.6.1.2 SSE2 Packed Arithmetic Instructions addpd|addsd|subpd|subsd|mulpd|mulsd|divpd|divsd|sqrtpd|sqrtsd|maxpd|maxsd|minpd|minsd ;5.6.1.3 SSE2 Logical Instructions andpd|andnpd|orpd|xorpd ;5.6.1.4 SSE2 Compare Instructions cmppd|cmpsd|comisd|ucomisd ;5.6.1.5 SSE2 Shuffle and Unpack Instructions shufpd|unpckhpd|unpcklpd ;5.6.1.6 SSE2 Conversion Instructions cvtpd2pi|cvttpd2pi|cvtpi2pd|cvtpd2dq|cvttpd2dq|cvtdq2pd|cvtps2pd|cvtpd2ps|cvtss2sd|cvtsd2ss|cvtsd2si|cvttsd2si|cvtsi2sd ;5.6.2 SSE2 Packed Single-Precision Floating-Point Instructions cvtdq2ps|cvtps2dq|cvttps2dq ;5.6.3 SSE2 128-Bit SIMD Integer Instructions movdqa|movdqu|movq2dq|movdq2q|pmuludq|paddq|psubq|pshuflw|pshufhw|pshufd|pslldq|psrldq|punpckhqdq|punpcklqdq ;5.6.4 SSE2 Cacheability Control and Ordering Instructions clflush|lfence|mfence|pause|maskmovdqu|movntpd|movntdq|movnti ;5.7 SSE3 INSTRUCTIONS ;5.7.1 SSE3 x87-FP Integer Conversion Instruction fisttp ;5.7.2 SSE3 Specialized 128-bit Unaligned Data Load Instruction lddqu ;5.7.3 SSE3 SIMD Floating-Point Packed ADD/SUB Instructions addsubps|addsubpd ;5.7.4 SSE3 SIMD Floating-Point Horizontal ADD/SUB Instructions haddps|hsubps|haddpd|hsubpd ;5.7.5 SSE3 SIMD Floating-Point LOAD/MOVE/DUPLICATE Instructions movshdup|movsldup|movddup ;5.7.6 SSE3 Agent Synchronization Instructions monitor|mwait ;5.8 SUPPLEMENTAL STREAMING SIMD EXTENSIONS 3 (SSSE3) INSTRUCTIONS ;5.8.1 Horizontal Addition/Subtraction phaddw|phaddsw|phaddd|phsubw|phsubsw|phsubd ;5.8.2 Packed Absolute Values pabsb|pabsw|pabsd ;5.8.3 Multiply and Add Packed Signed and Unsigned Bytes pmaddubsw ;5.8.4 Packed Multiply High with Round and Scale pmulhrsw ;5.8.5 Packed Shuffle Bytes pshufb ;5.8.6 Packed Sign psignb|psignw|psignd ;5.8.7 Packed Align Right palignr ;5.9 SSE4 INSTRUCTIONS ;5.10 SSE4.1 INSTRUCTIONS ;5.10.1 Dword Multiply Instructions pmulld|pmuldq ;5.10.2 Floating-Point Dot Product Instructions dppd|dpps ;5.10.3 Streaming Load Hint Instruction movntdqa ;5.10.4 Packed Blending Instructions blendpd|blendps|blendvpd|blendvps|pblendvb|pblendw ;5.10.5 Packed Integer MIN/MAX Instructions pminuw|pminud|pminsb|pminsd|pmaxuw|pmaxud|pmaxsb|pmaxsd ;5.10.6 Floating-Point Round Instructions with Selectable Rounding Mode roundps|roundpd|roundss|roundsd ;5.10.7 Insertion and Extractions from XMM Registers extractps|insertps|pinsrb|pinsrd|pinsrq|pextrb|pextrw|pextrd|pextrq ;5.10.8 Packed Integer Format Conversions pmovsxbw|pmovzxbw|pmovsxbd|pmovzxbd|pmovsxwd|pmovzxwd|pmovsxbq|pmovzxbq|pmovsxwq|pmovzxwq|pmovsxdq|pmovzxdq ;5.10.9 Improved Sums of Absolute Differences (SAD) for 4-Byte Blocks mpsadbw ;5.10.10 Horizontal Search phminposuw ;5.10.11 Packed Test ptest ;5.10.12 Packed Qword Equality Comparisons pcmpeqq ;5.10.13 Dword Packing With Unsigned Saturation packusdw ;5.11 SSE4.2 INSTRUCTION SET ;5.11.1 String and Text Processing Instructions pcmpestri|pcmpestrm|pcmpistri|pcmpistrm ;5.11.2 Packed Comparison SIMD integer Instruction pcmpgtq ;5.12 AESNI AND PCLMULQDQ aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|pclmulqdq ;5.13 INTEL® ADVANCED VECTOR EXTENSIONS (INTEL® AVX) ;Table 14-2. Promoted 256-Bit and 128-bit Arithmetic AVX Instructions sqrtps, sqrtpd, rsqrtps, rcpps addps, addpd, subps, subpd mulps, mulpd, divps, divpd cvtps2pd, cvtpd2ps cvtdq2ps, cvtps2dq cvttps2dq, cvttpd2dq cvtpd2dq, cvtdq2pd minps, minpd, maxps, maxpd haddpd, haddps, hsubpd, hsubps cmpps, cmppd addsubpd, addsubps, dpps roundpd, roundps ;Table 14-3. Promoted 256-bit and 128-bit Data Movement AVX Instructions movaps, movapd, movdqa movups, movupd, movdqu movmskps, movmskpd lddqu, movntps, movntpd, movntdq, movntdqa movshdup, movsldup, movddup ;Table 14-3. Promoted 256-bit and 128-bit Data Movement AVX Instructions unpckhpd, unpckhps, unpcklpd blendps, blendpd shufpd, shufps, unpcklps blendvps, blendvpd ptest, movmskpd, movmskps xorps, xorpd, orps, orpd andnpd, andnps, andpd, andps ;Table 14-4. 256-bit AVX Instruction Enhancement vbroadcastf128|vbroadcastsd|vbroadcastss|vextractf128|vinsertf128|vmaskmovps|vmaskmovpd|vmaskmovps|vmaskmovpd vpermilpd|vpermilpd|vpermilps|vpermilps|vperm2f128|vtestps|vtestpd|vzeroall|vzeroupper ;Table 14-5. Promotion of Legacy SIMD ISA to 128-bit Arithmetic AVX instruction cvtpi2ps, cvtpi2pd, cvtpd2pi cvttps2pi, cvttpd2pi, cvtps2pi cvtsi2ss, cvtsi2sd, cvtsd2si cvttss2si, cvttsd2si, cvtss2si comisd, rsqrtss, rcpss ucomiss, ucomisd, comiss addss, addsd, subss, subsd mulss, mulsd, divss, divsd sqrtss, sqrtsd cvtss2sd, cvtsd2ss minss, minsd, maxss, maxsd pand, pandn, por, pxor pcmpgtb, pcmpgtw, pcmpgtd pmaddwd, pmaddubsw pavgb, pavgw, pmuludq pcmpeqb, pcmpeqw, pcmpeqd pmullw, pmulhuw, pmulhw psubsw, paddsw, psadbw paddusb, paddusw, paddsb psubusb, psubusw, psubsb pminub, pminsw pmaxub, pmaxsw paddb, paddw, paddd, paddq psubb, psubw, psubd, psubq psllw, pslld, psllq, psraw psrlw, psrld, psrlq, psrad phsubw, phsubd, phsubsw phaddw, phaddd, phaddsw pmulhrsw psignb, psignw, psignd pabsb, pabsw, pabsd dppd phminposuw, mpsadbw pmaxsb, pmaxsd, pmaxud pminsb, pminsd, pminud pmaxuw, pminuw pmovsxbw, pmovzxbw, pmovsxbd, pmovzxbd, pmovsxwd, pmovzxwd, pmovsxbq, pmovzxbq, pmovsxwq, pmovzxwq, pmovsxdq, pmovzxdq pmuldq, pmulld roundsd, roundss popcnt pcmpgtq crc32 pcmpestri, pcmpestrm pcmpistri, pcmpistrm pclmulqdq aesdec, aesdeclast aesenc, aesenclast aesimc, aeskeygenassist ;Table 14-6. 128-bit AVX Instruction Enhancement vbroadcastss|vmaskmovps|vmaskmovpd|vmaskmovps|vmaskmovpd|vpermilpd|vpermilpd|vpermilps|vpermilps|vtestps|vtestpd ;Table 14-7. Promotion of Legacy SIMD ISA to 128-bit Non-Arithmetic AVX instruction movq2dq, movdq2q ldmxcsr, stmxcsr movss, movsd, cmpss, cmpsd movhps, movhpd movhps, movhpd movlhps, movhlps movq, movd packuswb, packssdw, packsswb punpckhbw, punpckhwd punpcklbw, punpcklwd punpckhdq, punpckldq punpcklqdq, punpckhqdq pshufhw, pshuflw, pshufd pmovmskb, maskmovdqu pand, pandn, por, pxor pinsrw, pextrw palignr, pshufb extractps, insertps packusdw, pcmpeqq pblendvb, pblendw pextrw, pextrb, pextrd, pextrq pinsrb, pinsrd, pinsrq ;5.14 16-BIT FLOATING-POINT CONVERSION vcvtph2ps|vcvtps2ph ;5.15 FUSED-MULTIPLY-ADD (FMA) ;Table 14-15. FMA Instructions vfmadd132pd|vfmadd213pd|vfmadd231pd vfmadd132ps|vfmadd213ps|vfmadd231ps vfmadd132sd|vfmadd213sd|vfmadd231sd vfmadd132ss|vfmadd213ss|vfmadd231ss vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps vfmsub132pd|vfmsub213pd|vfmsub231pd vfmsub132ps|vfmsub213ps|vfmsub231ps vfmsub132sd|vfmsub213sd|vfmsub231sd vfmsub132ss|vfmsub213ss|vfmsub231ss vfnmadd132pd|vfnmadd213pd|vfnmadd231pd vfnmadd132ps|vfnmadd213ps|vfnmadd231ps vfnmadd132sd|vfnmadd213sd|vfnmadd231sd vfnmadd132ss|vfnmadd213ss|vfnmadd231ss vfnmsub132pd|vfnmsub213pd|vfnmsub231pd vfnmsub132ps|vfnmsub213ps|vfnmsub231ps vfnmsub132sd|vfnmsub213sd|vfnmsub231sd vfnmsub132ss|vfnmsub213ss|vfnmsub231ss ;5.16 INTEL® ADVANCED VECTOR EXTENSIONS 2 (INTEL® AVX2) ;Table 14-18. Promoted Vector Integer SIMD Instructions in AVX2 punpcklbw|punpcklwd|punpckldq|packsswb|pcmpgtb|pcmpgtw|pcmpgtd|packuswb punpckhbw|punpckhwd|punpckhdq|packssdw|punpcklqdq|punpckhqdq|movd|movq|movdqa|movdqu pshufd|pshufhw|pshuflw|pcmpeqb|pcmpeqw|pcmpeqd|movdqa|movdqu|pinsrw|pextrw psrlw|psrld|psrlq|paddq|pmullw|pmovmskb|psubusb|psubusw|pminub|pand|paddusb|paddusw pmaxub|pandn|pavgb|psraw|psrad|pavgw|pmulhuw|pmulhw|movntdq|psubsb|psubsw|pminsw por|paddsb|paddsw|pmaxsw|pxor|lddqu|psllw|pslld|psllq|pmuludq|pmaddwd psadbw|psubb|psubw|psubd|psubq|paddb|paddw|paddd|phaddw|phaddsw|phaddd phsubw|phsubsw|phsubd|pmaddubsw|palignr|pshufb|pmulhrsw|psignb|psignw|psignd pabsb|pabsw|pabsd|movntdqa|mpsadbw|packusdw|pblendvb|pblendw|pcmpeqq pextrd|pextrq|pextrb|pextrw|phminposuw|pinsrb|pinsrd|pinsrq pmaxsb|pmaxsd|pmaxud|pmaxuw|pminsb|pminsd|pminud|pminuw pmovsxbw|pmovzxbw|pmovsxbd|pmovzxbd|pmovsxwd|pmovzxwd|pmovsxbq|pmovzxbq|pmovsxwq|pmovzxwq|pmovsxdq|pmovzxdq pmuldq|pmulld|ptest|pcmpgtq|pcmpestri|pcmpestrm|pcmpistri|pcmpistrm aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|pclmulqdq ;Table 14-19. VEX-Only SIMD Instructions in AVX and AVX2 vbroadcasti128|vbroadcastf128 vbroadcastsd|vbroadcastsd vbroadcastss|vbroadcastss vextracti128|vextractf128 vinserti128|vinsertf128 vpmaskmovd|vmaskmovps vpmaskmovq|vmaskmovpd vpermilpd|vpermilps vperm2i128|vperm2f128 vpermd|vpermps|vpermq|vpermpd vtestpd|vtestps vpblendd|vpsllvd|vpsllvq|vpsravd|vpsrlvd|vpsrlvq vgatherdpd|vgatherdqpd|vgatherdps|vgatherdqps|vpgatherdd|vpgatherqd|vpgatherdq|vpgatherqq ;Table 14-20. New Primitive in AVX2 Instructions vpermd|vpermpd|vpermps|vpermq vpsllvd|vpsllvq|vpsllvd|vpsllvq vpsravd|vpsrlvd|vpsrlvq|vpsrlvd|vpsrlvq vgatherdd|vgatherqd|vgatherdd|vgatherqd|vgatherdpd|vgatherqpd|vgatherdpd|vgatherqpd vgatherdps|vgatherqps|vgatherdps|vgatherqps|vgatherdq|vgatherqq|vgatherdq|vgatherqq ;5.17 INTEL® TRANSACTIONAL SYNCHRONIZATION EXTENSIONS (TSX) xabort|xacquire|xrelease|xbegin|xend|xtest ;5.18 SYSTEM INSTRUCTIONS clac|stac|lgdt|sgdt|lldt|sldt|ltr|str|lidt|sidt|mov|lmsw|smsw clts|arpl|lar|lsl|verr|verw|mov|invd|wbinvd|invlpg|invpcid lock hlt|rsm|rdmsr|wrmsr|rdpmc|rdtsc|rdtscp|sysenter|sysexit xsave|xsaveopt|xrstor|xgetbv|xsetbv|rdfsbase|rdgsbase|wrfsbase|wrgsbase ;5.19 64-BIT MODE INSTRUCTIONS cdqe|cmpsq|cmpxchg16b|lodsq|movsq|movzx|stosq|swapgs|syscall|sysret ;5.20 VIRTUAL-MACHINE EXTENSIONS vmptrld|vmptrst|vmclear|vmread|vmwrite|vmlaunch|vmresume|vmxoff|vmxon|invept|invvpid|vmcall|vmfunc ;5.21 SAFER MODE EXTENSIONS getsec [capabilities|enteraccs|exitac|senter|sexit|parameters|smctrl|wakeup] ;==================================================================== ;Intel® 64 and IA-32 Architectures Software Developer’s Manual. Vol 2 (2015-01) aaa|aad|aam|aas|adc|adcx|add|addpd|addps|addsd|addss|addsubpd|addsubps|adox aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist and|andn|andpd|andps|andnpd|andnps|arpl blendpd|bextr|blendps|blendvpd|blendvps|blsi|blsmsk|blsr|bound|bsf|bsr|bswap|bt|btc|btr|bts|bzhi call|cbw|cwde|cdqe|clac|clc|cld|clflush|cli|clts|cmc cmova|cmovae|cmovb|cmovbe|cmovc|cmove|cmovg|cmovge|cmovl|cmovle cmovna|cmovnae|cmovnb|cmovnbe|cmovnc|cmovne|cmovng|cmovnge|cmovnl|cmovnle cmovno|cmovnp|cmovns|cmovnz|cmovo|cmovp|cmovpe|cmovpo|cmovs|cmovz cmp|cmppd|cmpps|cmps|cmpsb|cmpsw|cmpsd|cmpsq|cmpsd|cmpss|cmpxchg|cmpxchg8b|cmpxchg16b|comisd|comiss|cpuid|crc32 cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtpi2ps|cvtps2dq|cvtps2pd|cvtps2pi|cvtsd2si|cvtsd2ss cvtsi2sd|cvtsi2ss|cvtss2sd|cvtss2si|cvttpd2dq|cvttpd2pi|cvttps2dq|cvttps2pi|cvttsd2si|cvttss2si|cwd|cdq|cqo daa|das|dec|div|divpd|divps|divsd|divss|dppd|dpps emms|enter|extractps f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex fcmovb|fcmove|fcmovbe|fcmovu|fcmovnb|fcmovne|fcmovnbe|fcmovnu fcom|fcomp|fcompp|fcomi|fcomip|fucomi|fucomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree ficom|ficomp|fild|fincstp|finit|fninit|fist|fistp|fisttp|fld|fld1|fldl2t|fldl2e|fldpi|fldlg2|fldln2|fldz|fldcw|fldenv fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp fstcw|fnstcw|fstenv|fnstenv|fstsw|fnstsw|fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fxam|fxch fxrstor|fxrstor64|fxsave|fxsave64|fxtract|fyl2x|fyl2xp1 haddpd|haddps|hlt|hsubpd|hsubps idiv|imul|in|inc|ins|insb|insw|insd|insertps|int n|into|int 3|invd|invlpg|invpcid|iret|iretd|iretq ja|jae|jb|jbe|jc|jcxz|jecxz|jrcxz|je|jg|jge|jl|jle|jna|jnae|jnb|jnbe|jnc|jne|jng|jnge|jnl|jnle|jno|jnp|jns|jnz|jo|jp|jpe|jpo|js|jz jmp lahf|lar|lddqu|ldmxcsr|lds|les|lfs|lgs|lss|lea|leave|lfence|lgdt|lidt|lldt|lmsw|lock|lods|lodsb|lodsw|lodsd|lodsq loop|loope|loopne lsl|ltr|lzcnt maskmovdqu|maskmovq|maxpd|maxps|maxsd|maxss|mfence|minpd|minps|minsd|minss|monitor mov|movapd|movaps|movbe|movd|movq|movddup|movdqa|movdqu|movdq2q|movhlps|movhpd|movhps|movlhps|movlpd|movlps movmskpd|movmskps|movntdqa|movntdq|movnti|movntpd|movntps|movntq|movq2dq|movs|movsb|movsw|movsd|movsq movshdup|movsldup|movss|movsx|movsxd|movupd|movups|movzx|mpsadbw|mul|mulpd|mulps|mulsd|mulss|mulx|mwait neg|nop|not or|orpd|orps|out|outs|outsb|outsw|outsd pabsb|pabsw|pabsd|packsswb|packssdw|packusdw|packuswb|paddb|paddw|paddd|paddq|paddsb|paddsw|paddusb|paddusw palignr|pand|pandn|pause|pavgb|pavgw|pblendvb|pblendw|pclmulqdq pcmpeqb|pcmpeqw|pcmpeqd|pcmpeqq|pcmpestri|pcmpestrm|pcmpgtb|pcmpgtw|pcmpgtd|pcmpgtq|pcmpistri|pcmpistrm pdep|pext|pextrb|pextrd|pextrq|pextrw|phaddw|phaddd|phaddsw|phminposuw|phsubw|phsubd|phsubsw|pinsrb|pinsrd|pinsrq|pinsrw pmaddubsw|pmaddwd|pmaxsb|pmaxsd|pmaxsw|pmaxub|pmaxud|pmaxuw|pminsb|pminsd|pminsw|pminub|pminud|pminuw|pmovmskb pmovsxbw|pmovsxbd|pmovsxbq|pmovsxwd|pmovsxwq|pmovsxdq pmovzxbw|pmovzxbd|pmovzxbq|pmovzxwd|pmovzxwq|pmovzxdq pmuldq|pmulhrsw|pmulhuw|pmulhw|pmulld|pmullw|pmuludq|pop|popa|popad|popcnt|popf|popfd|popfq|por prefetcht0|prefetcht1|prefetcht2|prefetchnta|prefetchw|prefetchwt1 psadbw|pshufb|pshufd|pshufhw|pshuflw|pshufw|psignb|psignw|psignd pslldq|psllw|pslld|psllq|psraw|psrad|psrldq|psrlw|psrld|psrlq psubb|psubw|psubd|psubq|psubsb|psubsw|psubusb|psubusw|ptest punpckhbw|punpckhwd|punpckhdq|punpckhqdq|punpcklbw|punpcklwd|punpckldq|punpcklqdq push|pusha|pushad|pushf|pushfd|pushfq|pxor rcl|rcr|rol|ror|rcpps|rcpss|rdfsbase|rdgsbase|rdmsr|rdpkru|rdpmc|rdrand|rdseed|rdtsc|rdtscp rep|repe|repz|repne|repnz|ret|rorx|roundpd|roundps|roundsd|roundss|rsm|rsqrtps|rsqrtss sahf|sal|sar|shl|shr|sarx|shlx|shrx|sbb|scas|scasb|scasw|scasd|scasq seta|setae|setb|setbe|setc|sete|setg|setge|setl|setle|seto|setp|setpe|setpo|sets|setz setna|setnae|setnb|setnbe|setnc|setne|setng|setnge|setnl|setnle|setno|setnp|setns|setnz sfence|sgdt|shld|shrd|shufpd|shufps|sidt|sldt|smsw|sqrtpd|sqrtps|sqrtsd|sqrtss stac|stc|std|sti|stmxcsr|stos|stosb|stosw|stosd|stosq|str|sub|subpd|subps|subsd|subss|swapgs|syscall|sysenter|sysexit|sysret test|tzcnt ucomisd|ucomiss|ud2|unpckhpd|unpckhps|unpcklpd|unpcklps vbroadcastss|vbroadcastsd|vbroadcastf128 vcvtph2ps|vcvtps2ph|verr|verw vextractf128|vextracti128|vfmadd132pd|vfmadd213pd|vfmadd231pd|vfmadd132ps|vfmadd213ps|vfmadd231ps|vfmadd132sd|vfmadd213sd|vfmadd231sd|vfmadd132ss|vfmadd213ss|vfmadd231ss vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd|vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd|vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps vfmsub132pd|vfmsub213pd|vfmsub231pd|vfmsub132ps|vfmsub213ps|vfmsub231ps|vfmsub132sd|vfmsub213sd|vfmsub231sd|vfmsub132ss|vfmsub213ss|vfmsub231ss vfnmadd132pd|vfnmadd213pd|vfnmadd231pd|vfnmadd132ps|vfnmadd213ps|vfnmadd231ps|vfnmadd132sd|vfnmadd213sd|vfnmadd231sd|vfnmadd132ss|vfnmadd213ss|vfnmadd231ss vfnmsub132pd|vfnmsub213pd|vfnmsub231pd|vfnmsub132ps|vfnmsub213ps|vfnmsub231ps|vfnmsub132sd|vfnmsub213sd|vfnmsub231sd|vfnmsub132ss|vfnmsub213ss|vfnmsub231ss vgatherdpd|vgatherqpd|vgatherdps|vgatherqps|vpgatherdd|vpgatherqd|vpgatherdq|vpgatherqq vinsertf128|vinserti128|vmaskmovps|vmaskmovpd|vpblendd vpbroadcastb|vpbroadcastw|vpbroadcastd|vpbroadcastq|vbroadcasti128 vpermd|vpermpd|vpermps|vpermq|vperm2i128|vpermilpd|vpermilps|vperm2f128|vpmaskmovd|vpmaskmovq vpsllvd|vpsllvq|vpsravd|vpsrlvd|vpsrlvq|vtestpd|vtestps|vzeroall|vzeroupper wait|fwait|wbinvd|wrfsbase|wrgsbase|wrmsr|wrpkru xacquire|xrelease|xabort|xadd|xbegin|xchg|xend|xgetbv|xlat|xlatb|xor|xorpd|xorps xrstor|xrstor64|xrstors|xrstors64|xsave|xsave64|xsavec|xsavec64|xsaveopt|xsaveopt64|xsaves|xsaves64|xsetbv|xtest getsec[capabilities]|getsec[enteraccs]|getsec[exitac]|getsec[senter]|getsec[sexit]|getsec[parameters]|getsec[smctrl]|getsec[wakeup]| ;==================================================================== ;Intel® Architecture Instruction Set Extensions Programming Reference (2014-10) ;6 OPMASK ;6.1 MASK INSTRUCTIONS kaddw|kaddb|kaddq|kaddd kandw|kandb|kandq|kandd kandnw|kandnb|kandnq|kandnd kmovw|kmovb|kmovq|kmovd kunpckbw|kunpckwd|kunpckdq knotw|knotb|knotq|knotd korw|korb|korq|kord kortestw|kortestb|kortestq|kortestd kshiftlw|kshiftlb|kshiftlq|kshiftld kshiftrw|kshiftrb|kshiftrq|kshiftrd kxnorw|kxnorb|kxnorq|kxnord ktestw|ktestb|ktestq|ktestd kxorw|kxorb|kxorq|kxord ;7 ADDITIONAL 512-BIT INSTRUCTION EXTENSIONS ;7.2 INSTRUCTION SET REFERENCE vexp2pd|vexp2ps vrcp28pd|vrcp28sd|vrcp28ps|vrcp28ss vrsqrt28pd|vrsqrt28sd|vrsqrt28ps|vrsqrt28ss vgatherpf0dps|vgatherpf0qps|vgatherpf0dpd|vgatherpf0qpd vgatherpf1dps|vgatherpf1qps|vgatherpf1dpd|vgatherpf1qpd vscatterpf0dps|vscatterpf0qps|vscatterpf0dpd|vscatterpf0qpd vscatterpf1dps|vscatterpf1qps|vscatterpf1dpd|vscatterpf1qpd ;8 INTEL® SHA EXTENSIONS ;8.3 SHA EXTENSIONS REFERENCE sha1rnds4|sha1nexte|sha1msg1|sha1msg2 sha256rnds2|sha256msg1|sha256msg2 ;9 INTEL® MEMORY PROTECTION EXTENSIONS ;9.4 INTEL MPX INSTRUCTION REFERENCE bndmk|bndcl|bndcu|bndcn|bndmov|bndldx|bndstx ;10 ADDITIONAL NEW INSTRUCTIONS prefetchwt1 ;11 MEMORY INSTRUCTIONS ;11.4 INSTRUCTION SET REFERENCE clflushopt|clwb|pcommit ;==================================================================== ;AMD64 Architecture Programmer’s Manual Volume 2: System Programming (2011-12) ;6 System-Management Instructions arpl|clgi|cli|clts|hlt|int3|invd|invlpg|invlpga iret|iret|iretw|iretd|iretq lar|lgdt|lidt|lldt|lmsw|lsl|ltr|monitor|mwait|rdfsbase|rdgsbase|rdmsr|rdpmc|rdtsc|rdtscp|rsm|sgdt|sidt|skinit|sldt smsw|sti|stgi|str|swapgs|syscall|sysenter|sysexit|sysret|ud2|verr|verw|vmload|vmmcall|vmrun|vmsave|wbinvd|wrfsbase|wrgsbase|wrmsr ;7 Memory System ;7.5.2 Write Combining movntsd|movntss ;7.6.3 Cache and Memory Management Instructions prefetch|prefetchw ;==================================================================== ;AMD64 Architecture Programmer’s Manual Volume 3: General-Purpose and System Instructions (2015-06) ;3 General-Purpose Instruction Reference aaa|aad|aam|aas|adc|add|and|andn bextr|blcfill|blci|blcic|blcmsk|blcs|blsfill|blsi|blsic|blsmsk|blsr|bound|bsf|bsr|bswap|bt|btc|btr|bts|bzhi call|cbw|cwde|cdqe|cwd|cdq|cqo|clc|cld|clflush|cmc cmovo|cmovno|cmovb|cmovc|cmovnae|cmovnb|cmovnc|cmovae|cmovz|cmove|cmovnz|cmovne|cmovbe|cmovna|cmovnbe cmova|cmovs|cmovns|cmovp|cmovpe|cmovnp|cmovpo|cmovl|cmovnge|cmovnl|cmovge|cmovle|cmovng|cmovnle|cmovg cmp|cmps|cmpsb|cmpsw|cmpsd|cmpsq|cmpxchg|cmpxchg8b|cmpxchg16b|cpuid|crc32 daa|das|dec|div enter idiv|imul|in|inc|ins|insb|insw|insd|int|into jo|jno|jb|jc|jnae|jnb|jnc|jae|jz|je|jnz|jne|jbe|jna|jnbe|ja|js|jns|jp|jpe|jnp|jpo|jl|jnge|jnl|jge|jle|jng|jnle|jg|jcxz|jecxz|jrcxz|jmp lahf|lds|les|lfs|lgs|lss|lea|leave|lfence|llwpcb|lods|lodsb|lodsw|lodsd|lodsq|loop|loope|loopne|loopnz|loopz|lwpins|lwpval|lzcnt mfence|mov|movbe|movd|movmskpd|movmskps|movnti|movs|movsb|movsw|movsd|movsq|movsx|movsxd|movzx|mul|mulx neg|nop|not or|out|outs|outsb|outsw|outsd pause|pdep|pext|pop|popa|popad|popcnt|popf|popfd|popfq|prefetch|prefetchw|prefetchnta|prefetcht0|prefetcht1|prefetcht2|push|pusha|pushad|pushf|pushfd|pushfq rcl|rcr|rdfsbase|rdgsbase|rdrand|ret|rol|ror|rorx sahf|sal|shl|sar|sarx|sbb|scas|scasb|scasw|scasd|scasq seto|setno|setb|setc|setnae|setnb|setnc|setae|setz|sete|setnz|setne|setbe|setna|setnbe|seta|sets|setns|setp|setpe|setnp|setpo|setl|setnge|setnl|setge|setle|setng|setnle|setg sfence|shl|shld|shlx|shr|shrd|shrx|slwpcb|stc|std|stos|stosb|stosw|stosd|stosq|sub t1mskc|test|tzcnt|tzmsk wrfsbase|wrgsbase xadd|xchg|xlat|xlatb|xor ;4 System Instruction Reference arpl|clgi|cli|clts|hlt|int 3|invd|invlpg|invlpga|iret|iretd|iretq|lar|lgdt|lidt|lldt|lmsw|lsl|ltr monitor|monitorx|mov crn|mov drn|mwait|mwaitx|rdmsr|rdpmc|rdtsc|rdtscp|rsm sgdt|sidt|skinit|sldt|smsw|sti|stgi|str|swapgs|syscall|sysenter|sysexit|sysret ud2|verr|verw|vmload|vmmcall|vmrun|vmsave|wbinvd|wrmsr ; Zen Architecture clzero ;==================================================================== ;AMD64 Architecture Programmer’s Manual Volume 4: 128-Bit and 256-Bit Media Instructions (2013-05) addpd|vaddpd|addps|vaddps|addsd|vaddsd|addss|vaddss|addsubpd|vaddsubpd|addsubps|vaddsubps aesdec|vaesdec|aesdeclast|vaesdeclast|aesenc|vaesenc|aesenclast|vaesenclast|aesimc|vaesimc aeskeygenassist|vaeskeygenassist|andnpd|vandnpd|andnps|vandnps|andpd|vandpd|andps|vandps blendpd|vblendpd|blendps|vblendps|blendvpd|vblendvpd|blendvps|vblendvps cmppd|vcmppd|cmpps|vcmpps|cmpsd|vcmpsd|cmpss|vcmpss|comisd|vcomisd|comiss|vcomiss cvtdq2pd|vcvtdq2pd|cvtdq2ps|vcvtdq2ps|cvtpd2dq|vcvtpd2dq|cvtpd2ps|vcvtpd2ps|cvtps2dq|vcvtps2dq cvtps2pd|vcvtps2pd|cvtsd2si|vcvtsd2si|cvtsd2ss|vcvtsd2ss|cvtsi2sd|vcvtsi2sd|cvtsi2ss|vcvtsi2ss cvtss2sd|vcvtss2sd|cvtss2si|vcvtss2si|cvttpd2dq|vcvttpd2dq|cvttps2dq|vcvttps2dq|cvttsd2si|vcvttsd2si|cvttss2si|vcvttss2si divpd|vdivpd|divps|vdivps|divsd|vdivsd|divss|vdivss|dppd|vdppd|dpps|vdpps extractps|vextractps|extrq haddpd|vhaddpd|haddps|vhaddps|hsubpd|vhsubpd|hsubps|vhsubps insertps|vinsertps|insertq lddqu|vlddqu|ldmxcsr|vldmxcsr maskmovdqu|vmaskmovdqu|maxpd|vmaxpd|maxps|vmaxps|maxsd|vmaxsd|maxss|vmaxss|minpd|vminpd|minps|vminps|minsd|vminsd|minss|vminss movapd|vmovapd|movaps|vmovaps|movd|vmovd|movddup|vmovddup|movdqa|vmovdqa|movdqu|vmovdqu|movhlps|vmovhlps movhpd|vmovhpd|movhps|vmovhps|movlhps|vmovlhps|movlpd|vmovlpd|movlps|vmovlps|movmskpd|vmovmskpd|movmskps|vmovmskps movntdq|vmovntdq|movntdqa|vmovntdqa|movntpd|vmovntpd|movntps|vmovntps|movntsd|movntss|movq|vmovq|movsd|vmovsd movshdup|vmovshdup|movsldup|vmovsldup|movss|vmovss|movupd|vmovupd|movups|vmovups|mpsadbw|vmpsadbw mulpd|vmulpd|mulps|vmulps|mulsd|vmulsd|mulss|vmulss orpd|vorpd|orps|vorps pabsb|vpabsb|pabsd|vpabsd|pabsw|vpabsw|packssdw|vpackssdw|packsswb|vpacksswb|packusdw|vpackusdw|packuswb|vpackuswb paddb|vpaddb|paddd|vpaddd|paddq|vpaddq|paddsb|vpaddsb|paddsw|vpaddsw|paddusb|vpaddusb|paddusw|vpaddusw|paddw|vpaddw palignr|vpalignr|pand|vpand|pandn|vpandn|pavgb|vpavgb|pavgw|vpavgw pblendvb|vpblendvb|pblendw|vpblendw|pclmulqdq|vpclmulqdq pcmpeqb|vpcmpeqb|pcmpeqd|vpcmpeqd|pcmpeqq|vpcmpeqq|pcmpeqw|vpcmpeqw|pcmpestri|vpcmpestri|pcmpestrm|vpcmpestrm pcmpgtb|vpcmpgtb|pcmpgtd|vpcmpgtd|pcmpgtq|vpcmpgtq|pcmpgtw|vpcmpgtw|pcmpistri|vpcmpistri|pcmpistrm|vpcmpistrm pextrb|vpextrb|pextrd|vpextrd|pextrq|vpextrq|pextrw|vpextrw|phaddd|vphaddd|phaddsw|vphaddsw|phaddw|vphaddw phminposuw|vphminposuw|phsubd|vphsubd|phsubsw|vphsubsw|phsubw|vphsubw|pinsrb|vpinsrb|pinsrd|vpinsrd|pinsrq|vpinsrq|pinsrw|vpinsrw pmaddubsw|vpmaddubsw|pmaddwd|vpmaddwd|pmaxsb|vpmaxsb|pmaxsd|vpmaxsd|pmaxsw|vpmaxsw|pmaxub|vpmaxub|pmaxud|vpmaxud|pmaxuw|vpmaxuw pminsb|vpminsb|pminsd|vpminsd|pminsw|vpminsw|pminub|vpminub|pminud|vpminud|pminuw|vpminuw|pmovmskb|vpmovmskb pmovsxbd|vpmovsxbd|pmovsxbq|vpmovsxbq|pmovsxbw|vpmovsxbw|pmovsxdq|vpmovsxdq|pmovsxwd|vpmovsxwd|pmovsxwq|vpmovsxwq pmovzxbd|vpmovzxbd|pmovzxbq|vpmovzxbq|pmovzxbw|vpmovzxbw|pmovzxdq|vpmovzxdq|pmovzxwd|vpmovzxwd|pmovzxwq|vpmovzxwq pmuldq|vpmuldq|pmulhrsw|vpmulhrsw|pmulhuw|vpmulhuw|pmulhw|vpmulhw|pmulld|vpmulld|pmullw|vpmullw|pmuludq|vpmuludq por|vpor|psadbw|vpsadbw|pshufb|vpshufb|pshufd|vpshufd|pshufhw|vpshufhw|pshuflw|vpshuflw|psignb|vpsignb|psignd|vpsignd|psignw|vpsignw pslld|vpslld|pslldq|vpslldq|psllq|vpsllq|psllw|vpsllw|psrad|vpsrad|psraw|vpsraw|psrld|vpsrld|psrldq|vpsrldq|psrlq|vpsrlq|psrlw|vpsrlw psubb|vpsubb|psubd|vpsubd|psubq|vpsubq|psubsb|vpsubsb|psubsw|vpsubsw|psubusb|vpsubusb|psubusw|vpsubusw|psubw|vpsubw|ptest|vptest punpckhbw|vpunpckhbw|punpckhdq|vpunpckhdq|punpckhqdq|vpunpckhqdq|punpckhwd|vpunpckhwd punpcklbw|vpunpcklbw|punpckldq|vpunpckldq|punpcklqdq|vpunpcklqdq|punpcklwd|vpunpcklwd|pxor|vpxor rcpps|vrcpps|rcpss|vrcpss|roundpd|vroundpd|roundps|vroundps|roundsd|vroundsd|roundss|vroundss|rsqrtps|vrsqrtps|rsqrtss|vrsqrtss shufpd|vshufpd|shufps|vshufps|sqrtpd|vsqrtpd|sqrtps|vsqrtps|sqrtsd|vsqrtsd|sqrtss|vsqrtss|stmxcsr|vstmxcsr|subpd|vsubpd|subps|vsubps|subsd|vsubsd|subss|vsubss ucomisd|vucomisd|ucomiss|vucomiss|unpckhpd|vunpckhpd|unpckhps|vunpckhps|unpcklpd|vunpcklpd|unpcklps|vunpcklps vbroadcastf128|vbroadcastsd|vbroadcastss|vcvtph2ps|vcvtps2ph|vextractf128 vfmaddpd|vfmadd132pd|vfmadd213pd|vfmadd231pd|vfmaddps|vfmadd132ps|vfmadd213ps|vfmadd231ps vfmaddsd|vfmadd132sd|vfmadd213sd|vfmadd231sd|vfmaddss|vfmadd132ss|vfmadd213ss|vfmadd231ss vfmaddsubpd|vfmaddsub132pd|vfmaddsub213pd|vfmaddsub231pd|vfmaddsubps|vfmaddsub132ps|vfmaddsub213ps|vfmaddsub231ps vfmsubaddpd|vfmsubadd132pd|vfmsubadd213pd|vfmsubadd231pd|vfmsubaddps|vfmsubadd132ps|vfmsubadd213ps|vfmsubadd231ps vfmsubpd|vfmsub132pd|vfmsub213pd|vfmsub231pd|vfmsubps|vfmsub132ps|vfmsub213ps|vfmsub231ps vfmsubsd|vfmsub132sd|vfmsub213sd|vfmsub231sd|vfmsubss|vfmsub132ss|vfmsub213ss|vfmsub231ss vfnmaddpd|vfnmadd132pd|vfnmadd213pd|vfnmadd231pd|vfnmaddps|vfnmadd132ps|vfnmadd213ps|vfnmadd231ps vfnmaddsd|vfnmadd132sd|vfnmadd213sd|vfnmadd231sd|vfnmaddss|vfnmadd132ss|vfnmadd213ss|vfnmadd231ss vfnmsubpd|vfnmsub132pd|vfnmsub213pd|vfnmsub231pd|vfnmsubps|vfnmsub132ps|vfnmsub213ps|vfnmsub231ps vfnmsubsd|vfnmsub132sd|vfnmsub213sd|vfnmsub231sd|vfnmsubss|vfnmsub132ss|vfnmsub213ss|vfnmsub231ss vfrczpd|vfrczps|vfrczsd|vfrczss|vinsertf128|vmaskmovpd|vmaskmovps vpcmov|vpcomb|vpcomd|vpcomq|vpcomub|vpcomud|vpcomuq|vpcomuw|vpcomw vperm2f128|vpermil2pd|vpermil2ps|vpermilpd|vpermilps vphaddbd|vphaddbq|vphaddbw|vphadddq|vphaddubd|vphaddubq|vphaddubw|vphaddudq|vphadduwd|vphadduwq|vphaddwd|vphaddwq vphsubbw|vphsubdq|vphsubwd|vpmacsdd|vpmacsdqh|vpmacsdql|vpmacssdd|vpmacssdqh|vpmacssdql|vpmacsswd|vpmacssww|vpmacswd|vpmacsww vpmadcsswd|vpmadcswd|vpperm|vprotb|vprotd|vprotq|vprotw|vpshab|vpshad|vpshaq|vpshaw|vpshlb|vpshld|vpshlq|vpshlw vtestpd|vtestps|vzeroall|vzeroupper xgetbv|xorpd|vxorpd|xorps|vxorps|xrstor|xsave|xsaveopt|xsetbv ;AMD64 Architecture Programmer’s Manual Volume 5: 64-Bit Media and x87 Floating-Point Instructions (2013-05) ;1 64-Bit Media Instruction Reference cvtpd2pi|cvtpi2pd|cvtpi2ps|cvtps2pi|cvttpd2pi|cvttps2pi emms|femms frstor|fsave|fnsave|fxrstor|fxsave maskmovq|movd|movdq2q|movntq|movq|movq2dq packssdw|packsswb|packuswb paddb|paddd|paddq|paddsb|paddsw|paddusb|paddusw|paddw|pand|pandn|pavgb|pavgusb|pavgw pcmpeqb|pcmpeqd|pcmpeqw|pcmpgtb|pcmpgtd|pcmpgtw pextrw pf2id|pf2iw|pfacc|pfadd|pfcmpeq|pfcmpge|pfcmpgt|pfmax|pfmin|pfmul|pfnacc|pfpnacc|pfrcp|pfrcpit1|pfrcpit2|pfrsqit1|pfrsqrt|pfsub|pfsubr pi2fd|pi2fw|pinsrw|pmaddwd|pmaxsw|pmaxub|pminsw|pminub|pmovmskb|pmulhrw|pmulhuw|pmulhw|pmullw|pmuludq|por|psadbw|pshufw pslld|psllq|psllw|psrad|psraw|psrld|psrlq|psrlw|psubb|psubd|psubq|psubsb|psubsw|psubusb|psubusw|psubw|pswapd punpckhbw|punpckhdq|punpckhwd|punpcklbw|punpckldq|punpcklwd|pxor ;2 x87 Floating-Point Instruction Reference f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex fcmovb|fcmovbe|fcmove|fcmovnb|fcmovnbe|fcmovne|fcmovnu|fcmovu fcom|fcomp|fcompp|fcomi|fcomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree|ficom|ficomp|fild|fincstp|finit|fninit fist|fistp|fisttp|fld|fld1|fldcw|fldenv|fldl2e|fldl2t|fldlg2|fldln2|fldpi|fldz|fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp|fstcw|fnstcw|fstenv|fnstenv|fstsw|fnstsw fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fucomi|fucomip|fwait|wait|fxam|fxch|fxrstor|fxsave|fxtract|fyl2x|fyl2xp1 ;==================================================================== ;legacy retn|retf ;undocumented icebp int1 smi int03 ; Instead of INT3 ud1 ; No documented mnemonic for this one sqrtps xmm0,[ebx+10] ; SSE opcode paddsiw mm0,[ebx+10] ; Cyrix opcode with the same byte seq. ;==================================================================== ;old samples label: vaddpd xmm10, [rax+r15*4] vaddps ymm1, ymm2, yword [rax] lock add st0, mm1 .text db 'test\\0' ",16306,True,3581.5551116691504,median ";-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 3.6.0 #9615 (MINGW32) ;-------------------------------------------------------- .module Interrupts .optsdcc -mmcs51 --model-large ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _U2F_BLUE .globl _U2F_GREEN .globl _U2F_RED .globl _U2F_BUTTON_VAL .globl _U2F_BUTTON .globl _UART1FCN1_TFRQ .globl _UART1FCN1_TXNF .globl _UART1FCN1_TXHOLD .globl _UART1FCN1_TIE .globl _UART1FCN1_RFRQ .globl _UART1FCN1_RXTO1 .globl _UART1FCN1_RXTO0 .globl _UART1FCN1_RIE .globl _TMR4CN0_TF4H .globl _TMR4CN0_TF4L .globl _TMR4CN0_TF4LEN .globl _TMR4CN0_TF4CEN .globl _TMR4CN0_T4SPLIT .globl _TMR4CN0_TR4 .globl _TMR4CN0_T4XCLK1 .globl _TMR4CN0_T4XCLK0 .globl _TMR2CN0_TF2H .globl _TMR2CN0_TF2L .globl _TMR2CN0_TF2LEN .globl _TMR2CN0_TF2CEN .globl _TMR2CN0_T2SPLIT .globl _TMR2CN0_TR2 .globl _TMR2CN0_T2XCLK1 .globl _TMR2CN0_T2XCLK0 .globl _TCON_TF1 .globl _TCON_TR1 .globl _TCON_TF0 .globl _TCON_TR0 .globl _TCON_IE1 .globl _TCON_IT1 .globl _TCON_IE0 .globl _TCON_IT0 .globl _SPI0CN0_SPIF .globl _SPI0CN0_WCOL .globl _SPI0CN0_MODF .globl _SPI0CN0_RXOVRN .globl _SPI0CN0_NSSMD1 .globl _SPI0CN0_NSSMD0 .globl _SPI0CN0_TXNF .globl _SPI0CN0_SPIEN .globl _SMB0CN0_MASTER .globl _SMB0CN0_TXMODE .globl _SMB0CN0_STA .globl _SMB0CN0_STO .globl _SMB0CN0_ACKRQ .globl _SMB0CN0_ARBLOST .globl _SMB0CN0_ACK .globl _SMB0CN0_SI .globl _SCON1_OVR .globl _SCON1_PERR .globl _SCON1_REN .globl _SCON1_TBX .globl _SCON1_RBX .globl _SCON1_TI .globl _SCON1_RI .globl _SCON0_SMODE .globl _SCON0_MCE .globl _SCON0_REN .globl _SCON0_TB8 .globl _SCON0_RB8 .globl _SCON0_TI .globl _SCON0_RI .globl _PSW_CY .globl _PSW_AC .globl _PSW_F0 .globl _PSW_RS1 .globl _PSW_RS0 .globl _PSW_OV .globl _PSW_F1 .globl _PSW_PARITY .globl _PCA0CN0_CF .globl _PCA0CN0_CR .globl _PCA0CN0_CCF2 .globl _PCA0CN0_CCF1 .globl _PCA0CN0_CCF0 .globl _P3_B1 .globl _P3_B0 .globl _P2_B3 .globl _P2_B2 .globl _P2_B1 .globl _P2_B0 .globl _P1_B7 .globl _P1_B6 .globl _P1_B5 .globl _P1_B4 .globl _P1_B3 .globl _P1_B2 .globl _P1_B1 .globl _P1_B0 .globl _P0_B7 .globl _P0_B6 .globl _P0_B5 .globl _P0_B4 .globl _P0_B3 .globl _P0_B2 .globl _P0_B1 .globl _P0_B0 .globl _IP_PSPI0 .globl _IP_PT2 .globl _IP_PS0 .globl _IP_PT1 .globl _IP_PX1 .globl _IP_PT0 .globl _IP_PX0 .globl _IE_EA .globl _IE_ESPI0 .globl _IE_ET2 .globl _IE_ES0 .globl _IE_ET1 .globl _IE_EX1 .globl _IE_ET0 .globl _IE_EX0 .globl _B_B7 .globl _B_B6 .globl _B_B5 .globl _B_B4 .globl _B_B3 .globl _B_B2 .globl _B_B1 .globl _B_B0 .globl _ADC0CN0_ADEN .globl _ADC0CN0_ADBMEN .globl _ADC0CN0_ADINT .globl _ADC0CN0_ADBUSY .globl _ADC0CN0_ADWINT .globl _ADC0CN0_ADCM2 .globl _ADC0CN0_ADCM1 .globl _ADC0CN0_ADCM0 .globl _ACC_ACC7 .globl _ACC_ACC6 .globl _ACC_ACC5 .globl _ACC_ACC4 .globl _ACC_ACC3 .globl _ACC_ACC2 .globl _ACC_ACC1 .globl _ACC_ACC0 .globl __XPAGE .globl _TMR4RL .globl _TMR4 .globl _TMR3RL .globl _TMR3 .globl _TMR2RL .globl _TMR2 .globl _SBRL1 .globl _PCA0 .globl _PCA0CP2 .globl _PCA0CP1 .globl _PCA0CP0 .globl _DP .globl _ADC0LT .globl _ADC0 .globl _ADC0GT .globl _XBR2 .globl _XBR1 .globl _XBR0 .globl _WDTCN .globl _VDM0CN .globl _USB0XCN .globl _USB0DAT .globl _USB0CF .globl _USB0CDSTA .globl _USB0CDCN .globl _USB0CDCF .globl _USB0AEC .globl _USB0ADR .globl _UART1LIN .globl _UART1FCT .globl _UART1FCN1 .globl _UART1FCN0 .globl _TMR4RLL .globl _TMR4RLH .globl _TMR4L .globl _TMR4H .globl _TMR4CN1 .globl _TMR4CN0 .globl _TMR3RLL .globl _TMR3RLH .globl _TMR3L .globl _TMR3H .globl _TMR3CN1 .globl _TMR3CN0 .globl _TMR2RLL .globl _TMR2RLH .globl _TMR2L .globl _TMR2H .globl _TMR2CN1 .globl _TMR2CN0 .globl _TMOD .globl _TL1 .globl _TL0 .globl _TH1 .globl _TH0 .globl _TCON .globl _SPI0FCT .globl _SPI0FCN1 .globl _SPI0FCN0 .globl _SPI0DAT .globl _SPI0CN0 .globl _SPI0CKR .globl _SPI0CFG .globl _SP .globl _SMOD1 .globl _SMB0TC .globl _SMB0RXLN .globl _SMB0FCT .globl _SMB0FCN1 .globl _SMB0FCN0 .globl _SMB0DAT .globl _SMB0CN0 .globl _SMB0CF .globl _SMB0ADR .globl _SMB0ADM .globl _SFRSTACK .globl _SFRPGCN .globl _SFRPAGE .globl _SCON1 .globl _SCON0 .globl _SBUF1 .globl _SBUF0 .globl _SBRLL1 .globl _SBRLH1 .globl _SBCON1 .globl _RSTSRC .globl _REVID .globl _REG1CN .globl _REG0CN .globl _REF0CN .globl _PSW .globl _PSCTL .globl _PRTDRV .globl _PFE0CN .globl _PCON1 .globl _PCON0 .globl _PCA0PWM .globl _PCA0POL .globl _PCA0MD .globl _PCA0L .globl _PCA0H .globl _PCA0CPM2 .globl _PCA0CPM1 .globl _PCA0CPM0 .globl _PCA0CPL2 .globl _PCA0CPL1 .globl _PCA0CPL0 .globl _PCA0CPH2 .globl _PCA0CPH1 .globl _PCA0CPH0 .globl _PCA0CN0 .globl _PCA0CLR .globl _PCA0CENT .globl _P3MDOUT .globl _P3MDIN .globl _P3 .globl _P2SKIP .globl _P2MDOUT .globl _P2MDIN .globl _P2MAT .globl _P2MASK .globl _P2 .globl _P1SKIP .globl _P1MDOUT .globl _P1MDIN .globl _P1MAT .globl _P1MASK .globl _P1 .globl _P0SKIP .globl _P0MDOUT .globl _P0MDIN .globl _P0MAT .globl _P0MASK .globl _P0 .globl _LFO0CN .globl _IT01CF .globl _IPH .globl _IP .globl _IE .globl _I2C0STAT .globl _I2C0SLAD .globl _I2C0FCT .globl _I2C0FCN1 .globl _I2C0FCN0 .globl _I2C0DOUT .globl _I2C0DIN .globl _I2C0CN0 .globl _HFOCN .globl _HFO1CAL .globl _HFO0CAL .globl _FLKEY .globl _EMI0CN .globl _EIP2H .globl _EIP2 .globl _EIP1H .globl _EIP1 .globl _EIE2 .globl _EIE1 .globl _DPL .globl _DPH .globl _DEVICEID .globl _DERIVID .globl _CRC0ST .globl _CRC0IN .globl _CRC0FLIP .globl _CRC0DAT .globl _CRC0CNT .globl _CRC0CN1 .globl _CRC0CN0 .globl _CMP1MX .globl _CMP1MD .globl _CMP1CN1 .globl _CMP1CN0 .globl _CMP0MX .globl _CMP0MD .globl _CMP0CN1 .globl _CMP0CN0 .globl _CLKSEL .globl _CKCON1 .globl _CKCON0 .globl _B .globl _ADC0TK .globl _ADC0PWR .globl _ADC0MX .globl _ADC0LTL .globl _ADC0LTH .globl _ADC0L .globl _ADC0H .globl _ADC0GTL .globl _ADC0GTH .globl _ADC0CN1 .globl _ADC0CN0 .globl _ADC0CF .globl _ADC0AC .globl _ACC .globl _SMB_crc .globl _SMB_preflags .globl _SMB_write_ext_buf .globl _SMB_read_buf .globl _SMB_write_buf .globl _SMB_FLAGS .globl _SMB_crc_offset .globl _SMB_write_ext_offset .globl _SMB_write_ext_len .globl _SMB_read_offset .globl _SMB_read_len .globl _SMB_write_offset .globl _SMB_write_len .globl _SMB_addr .globl __MS_ ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 G$ACC$0$0 == 0x00e0 _ACC = 0x00e0 G$ADC0AC$0$0 == 0x00b3 _ADC0AC = 0x00b3 G$ADC0CF$0$0 == 0x00bc _ADC0CF = 0x00bc G$ADC0CN0$0$0 == 0x00e8 _ADC0CN0 = 0x00e8 G$ADC0CN1$0$0 == 0x00b2 _ADC0CN1 = 0x00b2 G$ADC0GTH$0$0 == 0x00c4 _ADC0GTH = 0x00c4 G$ADC0GTL$0$0 == 0x00c3 _ADC0GTL = 0x00c3 G$ADC0H$0$0 == 0x00be _ADC0H = 0x00be G$ADC0L$0$0 == 0x00bd _ADC0L = 0x00bd G$ADC0LTH$0$0 == 0x00c6 _ADC0LTH = 0x00c6 G$ADC0LTL$0$0 == 0x00c5 _ADC0LTL = 0x00c5 G$ADC0MX$0$0 == 0x00bb _ADC0MX = 0x00bb G$ADC0PWR$0$0 == 0x00df _ADC0PWR = 0x00df G$ADC0TK$0$0 == 0x00b9 _ADC0TK = 0x00b9 G$B$0$0 == 0x00f0 _B = 0x00f0 G$CKCON0$0$0 == 0x008e _CKCON0 = 0x008e G$CKCON1$0$0 == 0x00a6 _CKCON1 = 0x00a6 G$CLKSEL$0$0 == 0x00a9 _CLKSEL = 0x00a9 G$CMP0CN0$0$0 == 0x009b _CMP0CN0 = 0x009b G$CMP0CN1$0$0 == 0x0099 _CMP0CN1 = 0x0099 G$CMP0MD$0$0 == 0x009d _CMP0MD = 0x009d G$CMP0MX$0$0 == 0x009f _CMP0MX = 0x009f G$CMP1CN0$0$0 == 0x00bf _CMP1CN0 = 0x00bf G$CMP1CN1$0$0 == 0x00ac _CMP1CN1 = 0x00ac G$CMP1MD$0$0 == 0x00ab _CMP1MD = 0x00ab G$CMP1MX$0$0 == 0x00aa _CMP1MX = 0x00aa G$CRC0CN0$0$0 == 0x00ce _CRC0CN0 = 0x00ce G$CRC0CN1$0$0 == 0x0086 _CRC0CN1 = 0x0086 G$CRC0CNT$0$0 == 0x00d3 _CRC0CNT = 0x00d3 G$CRC0DAT$0$0 == 0x00de _CRC0DAT = 0x00de G$CRC0FLIP$0$0 == 0x00cf _CRC0FLIP = 0x00cf G$CRC0IN$0$0 == 0x00dd _CRC0IN = 0x00dd G$CRC0ST$0$0 == 0x00d2 _CRC0ST = 0x00d2 G$DERIVID$0$0 == 0x00ad _DERIVID = 0x00ad G$DEVICEID$0$0 == 0x00b5 _DEVICEID = 0x00b5 G$DPH$0$0 == 0x0083 _DPH = 0x0083 G$DPL$0$0 == 0x0082 _DPL = 0x0082 G$EIE1$0$0 == 0x00e6 _EIE1 = 0x00e6 G$EIE2$0$0 == 0x00ce _EIE2 = 0x00ce G$EIP1$0$0 == 0x00f3 _EIP1 = 0x00f3 G$EIP1H$0$0 == 0x00f5 _EIP1H = 0x00f5 G$EIP2$0$0 == 0x00f4 _EIP2 = 0x00f4 G$EIP2H$0$0 == 0x00f6 _EIP2H = 0x00f6 G$EMI0CN$0$0 == 0x00e7 _EMI0CN = 0x00e7 G$FLKEY$0$0 == 0x00b7 _FLKEY = 0x00b7 G$HFO0CAL$0$0 == 0x00c7 _HFO0CAL = 0x00c7 G$HFO1CAL$0$0 == 0x00d6 _HFO1CAL = 0x00d6 G$HFOCN$0$0 == 0x00ef _HFOCN = 0x00ef G$I2C0CN0$0$0 == 0x00ba _I2C0CN0 = 0x00ba G$I2C0DIN$0$0 == 0x00bc _I2C0DIN = 0x00bc G$I2C0DOUT$0$0 == 0x00bb _I2C0DOUT = 0x00bb G$I2C0FCN0$0$0 == 0x00ad _I2C0FCN0 = 0x00ad G$I2C0FCN1$0$0 == 0x00ab _I2C0FCN1 = 0x00ab G$I2C0FCT$0$0 == 0x00f5 _I2C0FCT = 0x00f5 G$I2C0SLAD$0$0 == 0x00bd _I2C0SLAD = 0x00bd G$I2C0STAT$0$0 == 0x00b9 _I2C0STAT = 0x00b9 G$IE$0$0 == 0x00a8 _IE = 0x00a8 G$IP$0$0 == 0x00b8 _IP = 0x00b8 G$IPH$0$0 == 0x00f2 _IPH = 0x00f2 G$IT01CF$0$0 == 0x00e4 _IT01CF = 0x00e4 G$LFO0CN$0$0 == 0x00b1 _LFO0CN = 0x00b1 G$P0$0$0 == 0x0080 _P0 = 0x0080 G$P0MASK$0$0 == 0x00fe _P0MASK = 0x00fe G$P0MAT$0$0 == 0x00fd _P0MAT = 0x00fd G$P0MDIN$0$0 == 0x00f1 _P0MDIN = 0x00f1 G$P0MDOUT$0$0 == 0x00a4 _P0MDOUT = 0x00a4 G$P0SKIP$0$0 == 0x00d4 _P0SKIP = 0x00d4 G$P1$0$0 == 0x0090 _P1 = 0x0090 G$P1MASK$0$0 == 0x00ee _P1MASK = 0x00ee G$P1MAT$0$0 == 0x00ed _P1MAT = 0x00ed G$P1MDIN$0$0 == 0x00f2 _P1MDIN = 0x00f2 G$P1MDOUT$0$0 == 0x00a5 _P1MDOUT = 0x00a5 G$P1SKIP$0$0 == 0x00d5 _P1SKIP = 0x00d5 G$P2$0$0 == 0x00a0 _P2 = 0x00a0 G$P2MASK$0$0 == 0x00fc _P2MASK = 0x00fc G$P2MAT$0$0 == 0x00fb _P2MAT = 0x00fb G$P2MDIN$0$0 == 0x00f3 _P2MDIN = 0x00f3 G$P2MDOUT$0$0 == 0x00a6 _P2MDOUT = 0x00a6 G$P2SKIP$0$0 == 0x00cc _P2SKIP = 0x00cc G$P3$0$0 == 0x00b0 _P3 = 0x00b0 G$P3MDIN$0$0 == 0x00f4 _P3MDIN = 0x00f4 G$P3MDOUT$0$0 == 0x009c _P3MDOUT = 0x009c G$PCA0CENT$0$0 == 0x009e _PCA0CENT = 0x009e G$PCA0CLR$0$0 == 0x009c _PCA0CLR = 0x009c G$PCA0CN0$0$0 == 0x00d8 _PCA0CN0 = 0x00d8 G$PCA0CPH0$0$0 == 0x00fc _PCA0CPH0 = 0x00fc G$PCA0CPH1$0$0 == 0x00ea _PCA0CPH1 = 0x00ea G$PCA0CPH2$0$0 == 0x00ec _PCA0CPH2 = 0x00ec G$PCA0CPL0$0$0 == 0x00fb _PCA0CPL0 = 0x00fb G$PCA0CPL1$0$0 == 0x00e9 _PCA0CPL1 = 0x00e9 G$PCA0CPL2$0$0 == 0x00eb _PCA0CPL2 = 0x00eb G$PCA0CPM0$0$0 == 0x00da _PCA0CPM0 = 0x00da G$PCA0CPM1$0$0 == 0x00db _PCA0CPM1 = 0x00db G$PCA0CPM2$0$0 == 0x00dc _PCA0CPM2 = 0x00dc G$PCA0H$0$0 == 0x00fa _PCA0H = 0x00fa G$PCA0L$0$0 == 0x00f9 _PCA0L = 0x00f9 G$PCA0MD$0$0 == 0x00d9 _PCA0MD = 0x00d9 G$PCA0POL$0$0 == 0x0096 _PCA0POL = 0x0096 G$PCA0PWM$0$0 == 0x00f7 _PCA0PWM = 0x00f7 G$PCON0$0$0 == 0x0087 _PCON0 = 0x0087 G$PCON1$0$0 == 0x009a _PCON1 = 0x009a G$PFE0CN$0$0 == 0x00c1 _PFE0CN = 0x00c1 G$PRTDRV$0$0 == 0x00f6 _PRTDRV = 0x00f6 G$PSCTL$0$0 == 0x008f _PSCTL = 0x008f G$PSW$0$0 == 0x00d0 _PSW = 0x00d0 G$REF0CN$0$0 == 0x00d1 _REF0CN = 0x00d1 G$REG0CN$0$0 == 0x00c9 _REG0CN = 0x00c9 G$REG1CN$0$0 == 0x00c6 _REG1CN = 0x00c6 G$REVID$0$0 == 0x00b6 _REVID = 0x00b6 G$RSTSRC$0$0 == 0x00ef _RSTSRC = 0x00ef G$SBCON1$0$0 == 0x0094 _SBCON1 = 0x0094 G$SBRLH1$0$0 == 0x0096 _SBRLH1 = 0x0096 G$SBRLL1$0$0 == 0x0095 _SBRLL1 = 0x0095 G$SBUF0$0$0 == 0x0099 _SBUF0 = 0x0099 G$SBUF1$0$0 == 0x0092 _SBUF1 = 0x0092 G$SCON0$0$0 == 0x0098 _SCON0 = 0x0098 G$SCON1$0$0 == 0x00c8 _SCON1 = 0x00c8 G$SFRPAGE$0$0 == 0x00a7 _SFRPAGE = 0x00a7 G$SFRPGCN$0$0 == 0x00cf _SFRPGCN = 0x00cf G$SFRSTACK$0$0 == 0x00d7 _SFRSTACK = 0x00d7 G$SMB0ADM$0$0 == 0x00d6 _SMB0ADM = 0x00d6 G$SMB0ADR$0$0 == 0x00d7 _SMB0ADR = 0x00d7 G$SMB0CF$0$0 == 0x00c1 _SMB0CF = 0x00c1 G$SMB0CN0$0$0 == 0x00c0 _SMB0CN0 = 0x00c0 G$SMB0DAT$0$0 == 0x00c2 _SMB0DAT = 0x00c2 G$SMB0FCN0$0$0 == 0x00c3 _SMB0FCN0 = 0x00c3 G$SMB0FCN1$0$0 == 0x00c4 _SMB0FCN1 = 0x00c4 G$SMB0FCT$0$0 == 0x00ef _SMB0FCT = 0x00ef G$SMB0RXLN$0$0 == 0x00c5 _SMB0RXLN = 0x00c5 G$SMB0TC$0$0 == 0x00ac _SMB0TC = 0x00ac G$SMOD1$0$0 == 0x0093 _SMOD1 = 0x0093 G$SP$0$0 == 0x0081 _SP = 0x0081 G$SPI0CFG$0$0 == 0x00a1 _SPI0CFG = 0x00a1 G$SPI0CKR$0$0 == 0x00a2 _SPI0CKR = 0x00a2 G$SPI0CN0$0$0 == 0x00f8 _SPI0CN0 = 0x00f8 G$SPI0DAT$0$0 == 0x00a3 _SPI0DAT = 0x00a3 G$SPI0FCN0$0$0 == 0x009a _SPI0FCN0 = 0x009a G$SPI0FCN1$0$0 == 0x009b _SPI0FCN1 = 0x009b G$SPI0FCT$0$0 == 0x00f7 _SPI0FCT = 0x00f7 G$TCON$0$0 == 0x0088 _TCON = 0x0088 G$TH0$0$0 == 0x008c _TH0 = 0x008c G$TH1$0$0 == 0x008d _TH1 = 0x008d G$TL0$0$0 == 0x008a _TL0 = 0x008a G$TL1$0$0 == 0x008b _TL1 = 0x008b G$TMOD$0$0 == 0x0089 _TMOD = 0x0089 G$TMR2CN0$0$0 == 0x00c8 _TMR2CN0 = 0x00c8 G$TMR2CN1$0$0 == 0x00fd _TMR2CN1 = 0x00fd G$TMR2H$0$0 == 0x00cd _TMR2H = 0x00cd G$TMR2L$0$0 == 0x00cc _TMR2L = 0x00cc G$TMR2RLH$0$0 == 0x00cb _TMR2RLH = 0x00cb G$TMR2RLL$0$0 == 0x00ca _TMR2RLL = 0x00ca G$TMR3CN0$0$0 == 0x0091 _TMR3CN0 = 0x0091 G$TMR3CN1$0$0 == 0x00fe _TMR3CN1 = 0x00fe G$TMR3H$0$0 == 0x0095 _TMR3H = 0x0095 G$TMR3L$0$0 == 0x0094 _TMR3L = 0x0094 G$TMR3RLH$0$0 == 0x0093 _TMR3RLH = 0x0093 G$TMR3RLL$0$0 == 0x0092 _TMR3RLL = 0x0092 G$TMR4CN0$0$0 == 0x0098 _TMR4CN0 = 0x0098 G$TMR4CN1$0$0 == 0x00ff _TMR4CN1 = 0x00ff G$TMR4H$0$0 == 0x00a5 _TMR4H = 0x00a5 G$TMR4L$0$0 == 0x00a4 _TMR4L = 0x00a4 G$TMR4RLH$0$0 == 0x00a3 _TMR4RLH = 0x00a3 G$TMR4RLL$0$0 == 0x00a2 _TMR4RLL = 0x00a2 G$UART1FCN0$0$0 == 0x009d _UART1FCN0 = 0x009d G$UART1FCN1$0$0 == 0x00d8 _UART1FCN1 = 0x00d8 G$UART1FCT$0$0 == 0x00fa _UART1FCT = 0x00fa G$UART1LIN$0$0 == 0x009e _UART1LIN = 0x009e G$USB0ADR$0$0 == 0x00ae _USB0ADR = 0x00ae G$USB0AEC$0$0 == 0x00b2 _USB0AEC = 0x00b2 G$USB0CDCF$0$0 == 0x00b6 _USB0CDCF = 0x00b6 G$USB0CDCN$0$0 == 0x00be _USB0CDCN = 0x00be G$USB0CDSTA$0$0 == 0x00bf _USB0CDSTA = 0x00bf G$USB0CF$0$0 == 0x00b5 _USB0CF = 0x00b5 G$USB0DAT$0$0 == 0x00af _USB0DAT = 0x00af G$USB0XCN$0$0 == 0x00b3 _USB0XCN = 0x00b3 G$VDM0CN$0$0 == 0x00ff _VDM0CN = 0x00ff G$WDTCN$0$0 == 0x0097 _WDTCN = 0x0097 G$XBR0$0$0 == 0x00e1 _XBR0 = 0x00e1 G$XBR1$0$0 == 0x00e2 _XBR1 = 0x00e2 G$XBR2$0$0 == 0x00e3 _XBR2 = 0x00e3 G$ADC0GT$0$0 == 0x00c3 _ADC0GT = 0x00c3 G$ADC0$0$0 == 0x00bd _ADC0 = 0x00bd G$ADC0LT$0$0 == 0x00c5 _ADC0LT = 0x00c5 G$DP$0$0 == 0x0082 _DP = 0x0082 G$PCA0CP0$0$0 == 0x00fb _PCA0CP0 = 0x00fb G$PCA0CP1$0$0 == 0x00e9 _PCA0CP1 = 0x00e9 G$PCA0CP2$0$0 == 0x00eb _PCA0CP2 = 0x00eb G$PCA0$0$0 == 0x00f9 _PCA0 = 0x00f9 G$SBRL1$0$0 == 0x0095 _SBRL1 = 0x0095 G$TMR2$0$0 == 0x00cc _TMR2 = 0x00cc G$TMR2RL$0$0 == 0x00ca _TMR2RL = 0x00ca G$TMR3$0$0 == 0x0094 _TMR3 = 0x0094 G$TMR3RL$0$0 == 0x0092 _TMR3RL = 0x0092 G$TMR4$0$0 == 0x00a4 _TMR4 = 0x00a4 G$TMR4RL$0$0 == 0x00a2 _TMR4RL = 0x00a2 G$_XPAGE$0$0 == 0x00aa __XPAGE = 0x00aa ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 G$ACC_ACC0$0$0 == 0x00e0 _ACC_ACC0 = 0x00e0 G$ACC_ACC1$0$0 == 0x00e1 _ACC_ACC1 = 0x00e1 G$ACC_ACC2$0$0 == 0x00e2 _ACC_ACC2 = 0x00e2 G$ACC_ACC3$0$0 == 0x00e3 _ACC_ACC3 = 0x00e3 G$ACC_ACC4$0$0 == 0x00e4 _ACC_ACC4 = 0x00e4 G$ACC_ACC5$0$0 == 0x00e5 _ACC_ACC5 = 0x00e5 G$ACC_ACC6$0$0 == 0x00e6 _ACC_ACC6 = 0x00e6 G$ACC_ACC7$0$0 == 0x00e7 _ACC_ACC7 = 0x00e7 G$ADC0CN0_ADCM0$0$0 == 0x00e8 _ADC0CN0_ADCM0 = 0x00e8 G$ADC0CN0_ADCM1$0$0 == 0x00e9 _ADC0CN0_ADCM1 = 0x00e9 G$ADC0CN0_ADCM2$0$0 == 0x00ea _ADC0CN0_ADCM2 = 0x00ea G$ADC0CN0_ADWINT$0$0 == 0x00eb _ADC0CN0_ADWINT = 0x00eb G$ADC0CN0_ADBUSY$0$0 == 0x00ec _ADC0CN0_ADBUSY = 0x00ec G$ADC0CN0_ADINT$0$0 == 0x00ed _ADC0CN0_ADINT = 0x00ed G$ADC0CN0_ADBMEN$0$0 == 0x00ee _ADC0CN0_ADBMEN = 0x00ee G$ADC0CN0_ADEN$0$0 == 0x00ef _ADC0CN0_ADEN = 0x00ef G$B_B0$0$0 == 0x00f0 _B_B0 = 0x00f0 G$B_B1$0$0 == 0x00f1 _B_B1 = 0x00f1 G$B_B2$0$0 == 0x00f2 _B_B2 = 0x00f2 G$B_B3$0$0 == 0x00f3 _B_B3 = 0x00f3 G$B_B4$0$0 == 0x00f4 _B_B4 = 0x00f4 G$B_B5$0$0 == 0x00f5 _B_B5 = 0x00f5 G$B_B6$0$0 == 0x00f6 _B_B6 = 0x00f6 G$B_B7$0$0 == 0x00f7 _B_B7 = 0x00f7 G$IE_EX0$0$0 == 0x00a8 _IE_EX0 = 0x00a8 G$IE_ET0$0$0 == 0x00a9 _IE_ET0 = 0x00a9 G$IE_EX1$0$0 == 0x00aa _IE_EX1 = 0x00aa G$IE_ET1$0$0 == 0x00ab _IE_ET1 = 0x00ab G$IE_ES0$0$0 == 0x00ac _IE_ES0 = 0x00ac G$IE_ET2$0$0 == 0x00ad _IE_ET2 = 0x00ad G$IE_ESPI0$0$0 == 0x00ae _IE_ESPI0 = 0x00ae G$IE_EA$0$0 == 0x00af _IE_EA = 0x00af G$IP_PX0$0$0 == 0x00b8 _IP_PX0 = 0x00b8 G$IP_PT0$0$0 == 0x00b9 _IP_PT0 = 0x00b9 G$IP_PX1$0$0 == 0x00ba _IP_PX1 = 0x00ba G$IP_PT1$0$0 == 0x00bb _IP_PT1 = 0x00bb G$IP_PS0$0$0 == 0x00bc _IP_PS0 = 0x00bc G$IP_PT2$0$0 == 0x00bd _IP_PT2 = 0x00bd G$IP_PSPI0$0$0 == 0x00be _IP_PSPI0 = 0x00be G$P0_B0$0$0 == 0x0080 _P0_B0 = 0x0080 G$P0_B1$0$0 == 0x0081 _P0_B1 = 0x0081 G$P0_B2$0$0 == 0x0082 _P0_B2 = 0x0082 G$P0_B3$0$0 == 0x0083 _P0_B3 = 0x0083 G$P0_B4$0$0 == 0x0084 _P0_B4 = 0x0084 G$P0_B5$0$0 == 0x0085 _P0_B5 = 0x0085 G$P0_B6$0$0 == 0x0086 _P0_B6 = 0x0086 G$P0_B7$0$0 == 0x0087 _P0_B7 = 0x0087 G$P1_B0$0$0 == 0x0090 _P1_B0 = 0x0090 G$P1_B1$0$0 == 0x0091 _P1_B1 = 0x0091 G$P1_B2$0$0 == 0x0092 _P1_B2 = 0x0092 G$P1_B3$0$0 == 0x0093 _P1_B3 = 0x0093 G$P1_B4$0$0 == 0x0094 _P1_B4 = 0x0094 G$P1_B5$0$0 == 0x0095 _P1_B5 = 0x0095 G$P1_B6$0$0 == 0x0096 _P1_B6 = 0x0096 G$P1_B7$0$0 == 0x0097 _P1_B7 = 0x0097 G$P2_B0$0$0 == 0x00a0 _P2_B0 = 0x00a0 G$P2_B1$0$0 == 0x00a1 _P2_B1 = 0x00a1 G$P2_B2$0$0 == 0x00a2 _P2_B2 = 0x00a2 G$P2_B3$0$0 == 0x00a3 _P2_B3 = 0x00a3 G$P3_B0$0$0 == 0x00b0 _P3_B0 = 0x00b0 G$P3_B1$0$0 == 0x00b1 _P3_B1 = 0x00b1 G$PCA0CN0_CCF0$0$0 == 0x00d8 _PCA0CN0_CCF0 = 0x00d8 G$PCA0CN0_CCF1$0$0 == 0x00d9 _PCA0CN0_CCF1 = 0x00d9 G$PCA0CN0_CCF2$0$0 == 0x00da _PCA0CN0_CCF2 = 0x00da G$PCA0CN0_CR$0$0 == 0x00de _PCA0CN0_CR = 0x00de G$PCA0CN0_CF$0$0 == 0x00df _PCA0CN0_CF = 0x00df G$PSW_PARITY$0$0 == 0x00d0 _PSW_PARITY = 0x00d0 G$PSW_F1$0$0 == 0x00d1 _PSW_F1 = 0x00d1 G$PSW_OV$0$0 == 0x00d2 _PSW_OV = 0x00d2 G$PSW_RS0$0$0 == 0x00d3 _PSW_RS0 = 0x00d3 G$PSW_RS1$0$0 == 0x00d4 _PSW_RS1 = 0x00d4 G$PSW_F0$0$0 == 0x00d5 _PSW_F0 = 0x00d5 G$PSW_AC$0$0 == 0x00d6 _PSW_AC = 0x00d6 G$PSW_CY$0$0 == 0x00d7 _PSW_CY = 0x00d7 G$SCON0_RI$0$0 == 0x0098 _SCON0_RI = 0x0098 G$SCON0_TI$0$0 == 0x0099 _SCON0_TI = 0x0099 G$SCON0_RB8$0$0 == 0x009a _SCON0_RB8 = 0x009a G$SCON0_TB8$0$0 == 0x009b _SCON0_TB8 = 0x009b G$SCON0_REN$0$0 == 0x009c _SCON0_REN = 0x009c G$SCON0_MCE$0$0 == 0x009d _SCON0_MCE = 0x009d G$SCON0_SMODE$0$0 == 0x009f _SCON0_SMODE = 0x009f G$SCON1_RI$0$0 == 0x00c8 _SCON1_RI = 0x00c8 G$SCON1_TI$0$0 == 0x00c9 _SCON1_TI = 0x00c9 G$SCON1_RBX$0$0 == 0x00ca _SCON1_RBX = 0x00ca G$SCON1_TBX$0$0 == 0x00cb _SCON1_TBX = 0x00cb G$SCON1_REN$0$0 == 0x00cc _SCON1_REN = 0x00cc G$SCON1_PERR$0$0 == 0x00ce _SCON1_PERR = 0x00ce G$SCON1_OVR$0$0 == 0x00cf _SCON1_OVR = 0x00cf G$SMB0CN0_SI$0$0 == 0x00c0 _SMB0CN0_SI = 0x00c0 G$SMB0CN0_ACK$0$0 == 0x00c1 _SMB0CN0_ACK = 0x00c1 G$SMB0CN0_ARBLOST$0$0 == 0x00c2 _SMB0CN0_ARBLOST = 0x00c2 G$SMB0CN0_ACKRQ$0$0 == 0x00c3 _SMB0CN0_ACKRQ = 0x00c3 G$SMB0CN0_STO$0$0 == 0x00c4 _SMB0CN0_STO = 0x00c4 G$SMB0CN0_STA$0$0 == 0x00c5 _SMB0CN0_STA = 0x00c5 G$SMB0CN0_TXMODE$0$0 == 0x00c6 _SMB0CN0_TXMODE = 0x00c6 G$SMB0CN0_MASTER$0$0 == 0x00c7 _SMB0CN0_MASTER = 0x00c7 G$SPI0CN0_SPIEN$0$0 == 0x00f8 _SPI0CN0_SPIEN = 0x00f8 G$SPI0CN0_TXNF$0$0 == 0x00f9 _SPI0CN0_TXNF = 0x00f9 G$SPI0CN0_NSSMD0$0$0 == 0x00fa _SPI0CN0_NSSMD0 = 0x00fa G$SPI0CN0_NSSMD1$0$0 == 0x00fb _SPI0CN0_NSSMD1 = 0x00fb G$SPI0CN0_RXOVRN$0$0 == 0x00fc _SPI0CN0_RXOVRN = 0x00fc G$SPI0CN0_MODF$0$0 == 0x00fd _SPI0CN0_MODF = 0x00fd G$SPI0CN0_WCOL$0$0 == 0x00fe _SPI0CN0_WCOL = 0x00fe G$SPI0CN0_SPIF$0$0 == 0x00ff _SPI0CN0_SPIF = 0x00ff G$TCON_IT0$0$0 == 0x0088 _TCON_IT0 = 0x0088 G$TCON_IE0$0$0 == 0x0089 _TCON_IE0 = 0x0089 G$TCON_IT1$0$0 == 0x008a _TCON_IT1 = 0x008a G$TCON_IE1$0$0 == 0x008b _TCON_IE1 = 0x008b G$TCON_TR0$0$0 == 0x008c _TCON_TR0 = 0x008c G$TCON_TF0$0$0 == 0x008d _TCON_TF0 = 0x008d G$TCON_TR1$0$0 == 0x008e _TCON_TR1 = 0x008e G$TCON_TF1$0$0 == 0x008f _TCON_TF1 = 0x008f G$TMR2CN0_T2XCLK0$0$0 == 0x00c8 _TMR2CN0_T2XCLK0 = 0x00c8 G$TMR2CN0_T2XCLK1$0$0 == 0x00c9 _TMR2CN0_T2XCLK1 = 0x00c9 G$TMR2CN0_TR2$0$0 == 0x00ca _TMR2CN0_TR2 = 0x00ca G$TMR2CN0_T2SPLIT$0$0 == 0x00cb _TMR2CN0_T2SPLIT = 0x00cb G$TMR2CN0_TF2CEN$0$0 == 0x00cc _TMR2CN0_TF2CEN = 0x00cc G$TMR2CN0_TF2LEN$0$0 == 0x00cd _TMR2CN0_TF2LEN = 0x00cd G$TMR2CN0_TF2L$0$0 == 0x00ce _TMR2CN0_TF2L = 0x00ce G$TMR2CN0_TF2H$0$0 == 0x00cf _TMR2CN0_TF2H = 0x00cf G$TMR4CN0_T4XCLK0$0$0 == 0x0098 _TMR4CN0_T4XCLK0 = 0x0098 G$TMR4CN0_T4XCLK1$0$0 == 0x0099 _TMR4CN0_T4XCLK1 = 0x0099 G$TMR4CN0_TR4$0$0 == 0x009a _TMR4CN0_TR4 = 0x009a G$TMR4CN0_T4SPLIT$0$0 == 0x009b _TMR4CN0_T4SPLIT = 0x009b G$TMR4CN0_TF4CEN$0$0 == 0x009c _TMR4CN0_TF4CEN = 0x009c G$TMR4CN0_TF4LEN$0$0 == 0x009d _TMR4CN0_TF4LEN = 0x009d G$TMR4CN0_TF4L$0$0 == 0x009e _TMR4CN0_TF4L = 0x009e G$TMR4CN0_TF4H$0$0 == 0x009f _TMR4CN0_TF4H = 0x009f G$UART1FCN1_RIE$0$0 == 0x00d8 _UART1FCN1_RIE = 0x00d8 G$UART1FCN1_RXTO0$0$0 == 0x00d9 _UART1FCN1_RXTO0 = 0x00d9 G$UART1FCN1_RXTO1$0$0 == 0x00da _UART1FCN1_RXTO1 = 0x00da G$UART1FCN1_RFRQ$0$0 == 0x00db _UART1FCN1_RFRQ = 0x00db G$UART1FCN1_TIE$0$0 == 0x00dc _UART1FCN1_TIE = 0x00dc G$UART1FCN1_TXHOLD$0$0 == 0x00dd _UART1FCN1_TXHOLD = 0x00dd G$UART1FCN1_TXNF$0$0 == 0x00de _UART1FCN1_TXNF = 0x00de G$UART1FCN1_TFRQ$0$0 == 0x00df _UART1FCN1_TFRQ = 0x00df G$U2F_BUTTON$0$0 == 0x0095 _U2F_BUTTON = 0x0095 G$U2F_BUTTON_VAL$0$0 == 0x0096 _U2F_BUTTON_VAL = 0x0096 G$U2F_RED$0$0 == 0x0091 _U2F_RED = 0x0091 G$U2F_GREEN$0$0 == 0x0090 _U2F_GREEN = 0x0090 G$U2F_BLUE$0$0 == 0x0087 _U2F_BLUE = 0x0087 ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- .area REG_BANK_0 (REL,OVR,DATA) .ds 8 ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area DSEG (DATA) G$_MS_$0$0==. __MS_:: .ds 4 G$SMB_addr$0$0==. _SMB_addr:: .ds 1 G$SMB_write_len$0$0==. _SMB_write_len:: .ds 1 G$SMB_write_offset$0$0==. _SMB_write_offset:: .ds 1 G$SMB_read_len$0$0==. _SMB_read_len:: .ds 1 G$SMB_read_offset$0$0==. _SMB_read_offset:: .ds 1 G$SMB_write_ext_len$0$0==. _SMB_write_ext_len:: .ds 1 G$SMB_write_ext_offset$0$0==. _SMB_write_ext_offset:: .ds 1 G$SMB_crc_offset$0$0==. _SMB_crc_offset:: .ds 1 G$SMB_FLAGS$0$0==. _SMB_FLAGS:: .ds 1 ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area ISEG (DATA) ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- .area IABS (ABS,DATA) .area IABS (ABS,DATA) ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area BSEG (BIT) ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- .area PSEG (PAG,XDATA) ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area XABS (ABS,XDATA) ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- .area XISEG (XDATA) G$SMB_write_buf$0$0==. _SMB_write_buf:: .ds 3 G$SMB_read_buf$0$0==. _SMB_read_buf:: .ds 3 G$SMB_write_ext_buf$0$0==. _SMB_write_ext_buf:: .ds 3 G$SMB_preflags$0$0==. _SMB_preflags:: .ds 1 G$SMB_crc$0$0==. _SMB_crc:: .ds 2 .area HOME (CODE) .area GSINIT0 (CODE) .area GSINIT1 (CODE) .area GSINIT2 (CODE) .area GSINIT3 (CODE) .area GSINIT4 (CODE) .area GSINIT5 (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area CSEG (CODE) ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) C$Interrupts.c$35$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:35: uint32_t __data _MS_ = 0; clr a mov __MS_,a mov (__MS_ + 1),a mov (__MS_ + 2),a mov (__MS_ + 3),a C$Interrupts.c$52$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:52: __data uint8_t SMB_addr = 0; ; 1-genFromRTrack replaced mov _SMB_addr,#0x00 mov _SMB_addr,a C$Interrupts.c$54$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:54: __data uint8_t SMB_write_len = 0; ; 1-genFromRTrack replaced mov _SMB_write_len,#0x00 mov _SMB_write_len,a C$Interrupts.c$55$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:55: __data uint8_t SMB_write_offset = 0; ; 1-genFromRTrack replaced mov _SMB_write_offset,#0x00 mov _SMB_write_offset,a C$Interrupts.c$56$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:56: __data uint8_t SMB_read_len = 0; ; 1-genFromRTrack replaced mov _SMB_read_len,#0x00 mov _SMB_read_len,a C$Interrupts.c$57$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:57: __data uint8_t SMB_read_offset = 0; ; 1-genFromRTrack replaced mov _SMB_read_offset,#0x00 mov _SMB_read_offset,a C$Interrupts.c$60$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:60: __data uint8_t SMB_write_ext_len = 0; ; 1-genFromRTrack replaced mov _SMB_write_ext_len,#0x00 mov _SMB_write_ext_len,a C$Interrupts.c$61$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:61: __data uint8_t SMB_write_ext_offset = 0; ; 1-genFromRTrack replaced mov _SMB_write_ext_offset,#0x00 mov _SMB_write_ext_offset,a C$Interrupts.c$64$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:64: __data uint8_t SMB_crc_offset = 0; ; 1-genFromRTrack replaced mov _SMB_crc_offset,#0x00 mov _SMB_crc_offset,a C$Interrupts.c$65$0$0 ==. ; D:\\Freelancer_projects\\jan333\\sdcc_project\\src\\Interrupts.c:65: __data volatile uint8_t SMB_FLAGS = 0; ; 1-genFromRTrack replaced mov _SMB_FLAGS,#0x00 mov _SMB_FLAGS,a ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) FInterrupts$__xinit_SMB_write_buf$0$0 == . __xinit__SMB_write_buf: .byte #0x00,#0x00,#0x00 FInterrupts$__xinit_SMB_read_buf$0$0 == . __xinit__SMB_read_buf: .byte #0x00,#0x00,#0x00 FInterrupts$__xinit_SMB_write_ext_buf$0$0 == . __xinit__SMB_write_ext_buf: .byte #0x00,#0x00,#0x00 FInterrupts$__xinit_SMB_preflags$0$0 == . __xinit__SMB_preflags: .db #0x00 ; 0 FInterrupts$__xinit_SMB_crc$0$0 == . __xinit__SMB_crc: .byte #0x00,#0x00 ; 0 .area CABS (ABS,CODE) ",16308,True,3823.642569855974,median "/* FlipMode.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* Preconditions: Uno with DOGS102 Shield */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display // End of constructor list void setup(void) { u8g2.begin(); u8g2.setFont(u8g2_font_6x10_tr); } void draw(const char *s) { u8g2.firstPage(); do { u8g2.drawStr(0,15,""Hello World!""); u8g2.drawStr(0,30,s); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); } while ( u8g2.nextPage() ); delay(2000); } void loop(void) { u8g2.setDisplayRotation(U8G2_R0); u8g2.setFlipMode(0); draw(""R0,F0""); u8g2.setFlipMode(1); draw(""R0,F1""); u8g2.setDisplayRotation(U8G2_R1); u8g2.setFlipMode(0); draw(""R1,F0""); u8g2.setFlipMode(1); draw(""R1,F1""); u8g2.setDisplayRotation(U8G2_R2); u8g2.setFlipMode(0); draw(""R2,F0""); u8g2.setFlipMode(1); draw(""R2,F1""); u8g2.setDisplayRotation(U8G2_R3); u8g2.setFlipMode(0); draw(""R3,F0""); u8g2.setFlipMode(1); draw(""R3,F1""); } ",12363,True,3694.0057966891372,median "/* A Node for the rf24hub based on esp8266. Can be used as switch or a matrix display Build in Parts (selectable): Relais Matrix Display NeoPixel Dallas Temperature Sensor 18B20 Rf24GW On Branch: rf24hub@rpi2 => master !!!!! */ //**************************************************** // My definitions for my nodes based on this sketch // Select only one at one time !!!! //#define TEICHPUMPE //#define TERASSENNODE //#define FLURLICHT #define WOHNZIMMERNODE //#define TESTNODE //#define WITTYNODE //#define RF24GWTEST //#define ESPMINI //#define TESTNODE //**************************************************** // Default settings are in ""default.h"" !!!!! #include ""defaults.h"" // Default settings for the individual nodes are in ""Node_settings.h"" #include ""Node_settings.h"" //----------------------------------------------------- //***************************************************** /* Configuration of NTP */ #define MY_NTP_SERVER ""de.pool.ntp.org"" #define MY_TZ ""CET-1CEST,M3.5.0/02,M10.5.0/03"" /* Configuration of update server */ //#define ATOMIC_FS_UPDATE // ------ End of configuration part ------------ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ""secrets.h"" #include ""version.h"" #include ""defaults.h"" #include ""Node_settings.h"" #include ""version.h"" #if defined(SENSOR_18B20) #include #include #endif #if defined(RF24GW) #include #include ""rf24_config.h"" #include ""dataformat.h"" #endif #if defined(LEDMATRIX) #include #endif #if defined(NEOPIXEL) #include #endif ESP8266WebServer httpServer(80); ESP8266HTTPUpdateServer httpUpdater; WiFiClient mqtt_wifi_client; #if defined(MQTT) PubSubClient mqttClient(mqtt_wifi_client); #endif Logger logger(LOGGER_NUMLINES,LOGGER_LINESIZE); #if defined(SENSOR_18B20) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); #endif #if defined(RF24GW) WiFiUDP udp; RF24 radio(RADIO_CE_PIN,RADIO_CSN_PIN); #endif #if defined(LEDMATRIX) LED_Matrix matrix(LEDMATRIX_DIN, LEDMATRIX_CLK, LEDMATRIX_CS, LEDMATRIX_DEVICES_X, LEDMATRIX_DEVICES_Y); #endif #if defined(NEOPIXEL) Adafruit_NeoPixel pixels(NEOPIXELNUM, NEOPIXELPIN, NEO_GRB + NEO_KHZ800); #endif typedef enum {message=0, sensorweb, sensormqtt} call_t; typedef enum {ok_json=0, ok_html, ok_text, nochange, epromchange, error} status_t; typedef enum {on=0, off, toggle, state, unknown} tristate_t; time_t now; tm tm; char timeStr[9]; char mytopic[TOPIC_BUFFER_SIZE]; char info_str[INFOSIZE]; unsigned long lastDbg = 0; unsigned long lastMsg = 0; unsigned long lastInfo = 0; const char c_on[] = ""Ein""; const char c_off[] = ""Aus""; #if defined(NEOPIXEL) uint32_t rgb = RGBINIT; #endif //bool log_startup = false; #if defined(SWITCH1) bool state_switch1 = SWITCH1INITSTATE; #endif #if defined(SWITCH2) bool state_switch2 = SWITCH2INITSTATE; #endif #if defined(SWITCH3) bool state_switch3 = SWITCH3INITSTATE; #endif #if defined(SWITCH4) bool state_switch4 = SWITCH4INITSTATE; #endif #if defined(RF24GW) payload_t payload; udpdata_t udpdata; uint8_t rf24_node2hub[] = RF24_NODE2HUB; uint8_t rf24_hub2node[] = RF24_HUB2NODE; uint16_t rf24_verboselevel = RF24GW_STARTUPVERBOSELEVEL; #endif struct eeprom_t { uint32_t magicNo; bool logfile; bool logger; bool log_startup; bool log_rf24; bool log_sensor; bool log_mqtt; bool log_webcmd; bool log_sysinfo; }; eeprom_t eepromdata; void setup() { pinMode(BUILTIN_LED, OUTPUT); digitalWrite(BUILTIN_LED, LOW); Serial.begin(115200); EEPROM.begin(512); EEPROM.get( 0, eepromdata ); //EEPROM.end(); if ( eepromdata.magicNo != MAGICNO ) { eepromdata.magicNo = MAGICNO; eepromdata.logfile = false; eepromdata.logger = false; eepromdata.log_startup = false; eepromdata.log_rf24 = false; eepromdata.log_sensor = false; eepromdata.log_mqtt = false; eepromdata.log_webcmd = false; eepromdata.log_sysinfo = false; EEPROM.put( 0, eepromdata ); EEPROM.commit(); } logger.begin(); httpServer.begin(); if (!LittleFS.begin()) { ESP.restart(); return; } else { if (eepromdata.log_startup) { snprintf(info_str,INFOSIZE,""%s"",F(""+++++ Begin Startup ++++++ LittleFS mounted +++++"")); write2log(info_str); } } WiFi.persistent(false); WiFi.mode(WIFI_STA); WiFi.hostname(HOSTNAME); WiFi.begin(ssid, password); // ... Give ESP 10 seconds to connect to station. unsigned int i=0; while (WiFi.status() != WL_CONNECTED && i < 100) { delay(200); i++; } configTime(MY_TZ, MY_NTP_SERVER); while (WiFi.status() != WL_CONNECTED) { delay(3000); ESP.restart(); } if (eepromdata.log_startup) { snprintf(info_str,INFOSIZE,""%s %s %s %s"", F(""Connected to ""), ssid, F("" IP address: ""), WiFi.localIP().toString().c_str() ); write2log(info_str); } #if defined(RF24GW) udp.begin(GW_UDP_PORTNO); if (eepromdata.log_startup) { snprintf(info_str,INFOSIZE,""%s %u"", F(""Opened UDP Port: ""), GW_UDP_PORTNO ); write2log(info_str); } #endif //MQTT #if defined(MQTT) mqttClient.setServer(MQTT_SERVER, 1883); mqttClient.setCallback(callback); mqttClient.setBufferSize(512); if (eepromdata.log_startup) { snprintf(info_str,INFOSIZE,""%s %s %s"", F(""MQTT: Connected to Server ""), MQTT_SERVER, F("" Port: 1883"") ); write2log(info_str); } #endif // OTA ArduinoOTA.setHostname(HOSTNAME); ArduinoOTA.begin(); MDNS.begin(HOSTNAME); httpUpdater.setup(&httpServer); httpServer.begin(); MDNS.addService(""http"", ""tcp"", 80); setupFS(); httpServer.on(""/"", handleWebRoot); httpServer.on(""/cmd"", handleCmd); httpServer.on(""/restart"", []() { httpServer.send(304, ""message/http""); ESP.restart(); }); httpServer.on(""/console"", []() { httpServer.send(200, ""text/plain"", logger.printBuffer()); }); httpServer.onNotFound([]() { if (!handleFile(httpServer.urlDecode(httpServer.uri()))) httpServer.send(404, ""text/plain"", ""FileNotFound""); }); // Init additional modules #if defined(RF24GW) // init rf24 radio.begin(); delay(100); radio.setChannel(RF24_CHANNEL); radio.setDataRate(RF24_SPEED); radio.setPALevel(RF24_PA_MAX); radio.setRetries(0, 0); radio.setAutoAck(false); radio.disableDynamicPayloads(); radio.setPayloadSize(32); radio.setCRCLength(RF24_CRC_16); radio.openWritingPipe(rf24_hub2node); radio.openReadingPipe(1,rf24_node2hub); radio.startListening(); radio.printDetails(); #endif #if defined(LEDMATRIX) matrix.begin(); for (int address=0; address < (LEDMATRIX_DEVICES_X * LEDMATRIX_DEVICES_Y); address++) { matrix.displayTest(address, true); delay(200); matrix.displayTest(address, false); } matrix.setFont(2); matrix.setIntensity(1); matrix.setCursor(3,8); matrix.print(""Init""); matrix.display(); delay(500); matrix.off(); delay(500); matrix.on(); delay(500); matrix.clear(); matrix.display(); #endif #if defined(NEOPIXEL) pixels.begin(); #endif // Init sensors #if defined(SENSOR_18B20) sensors.begin(); #endif #if defined(SWITCH1) #if defined(SWITCH1PIN1) pinMode(SWITCH1PIN1, OUTPUT); #endif #if defined(SWITCH1PIN2) pinMode(SWITCH1PIN2, OUTPUT); #endif if (SWITCH1INITSTATE) { handleSwitch1(on); } else { handleSwitch1(off); } #endif #if defined(SWITCH2) #if defined(SWITCH2PIN1) pinMode(SWITCH2PIN1, OUTPUT); #endif #if defined(SWITCH2PIN2) pinMode(SWITCH2PIN2, OUTPUT); #endif if (SWITCH2INITSTATE) { handleSwitch2(on); } else { handleSwitch2(off); } #endif #if defined(SWITCH3) #if defined(SWITCH3PIN1) pinMode(SWITCH3PIN1, OUTPUT); #endif #if defined(SWITCH3PIN2) pinMode(SWITCH3PIN2, OUTPUT); #endif if (SWITCH3INITSTATE) { handleSwitch3(on); } else { handleSwitch3(off); } #endif #if defined(SWITCH4) #if defined(SWITCH4PIN1) pinMode(SWITCH4PIN1, OUTPUT); #endif #if defined(SWITCH4PIN2) pinMode(SWITCH4PIN2, OUTPUT); #endif if (SWITCH4INITSTATE) { handleSwitch4(on); } else { handleSwitch4(off); } #endif #if defined(VALUE1_PIN) pinMode(VALUE1_PIN, INPUT); #endif delay(200); if (eepromdata.log_startup) { snprintf(info_str,INFOSIZE,""%s"", F(""-------------------Ende Startup-------------------------"")); write2log(info_str); } digitalWrite(BUILTIN_LED, HIGH); } tristate_t get_tristate(const char* mystate) { tristate_t retval = unknown; if (strncmp(mystate, ""Ein"", 3)==0 || strncmp(mystate, ""ein"", 3)==0 || strncmp(mystate, ""on"", 2)==0 || strncmp(mystate, ""On"", 2)==0 || strncmp(mystate, ""1"", 1)==0 ) retval = on; if (strncmp(mystate, ""Aus"", 3)==0 || strncmp(mystate, ""aus"", 3)==0 || strncmp(mystate, ""off"", 3)==0 || strncmp(mystate, ""Off"", 3)==0 || strncmp(mystate, ""0"", 1)==0 ) retval = off; // togg* oder Togg* if (strncmp(mystate, ""toggle"", 4)==0 || strncmp(mystate, ""Toggle"", 4)==0 ) retval = toggle; // state, State, status oder Status if (strncmp(mystate, ""state"", 4)==0 || strncmp(mystate, ""Stat"", 3)==0 ) retval = state; return retval; } void handleCmd() { status_t status = error; bool do_eepromchange = false; for (int argNo=0; argNo < httpServer.args(); argNo++ ) { if ( httpServer.argName(argNo) == ""dellogfile"" ) { if (LittleFS.remove(""logfile.txt"")) { snprintf(info_str,INFOSIZE,""%s"",""Logfile deleted""); status = ok_text; } } if ( httpServer.argName(argNo) == F(""saveeprom"") ) { if (httpServer.arg(argNo) == ""1"" ) { do_eepromchange = true; status = epromchange; } } if ( httpServer.argName(argNo) == F(""logfile"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.logfile) { eepromdata.logfile = true; status = epromchange; } } else { if ( eepromdata.logfile) { eepromdata.logfile = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""logger"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.logger) { eepromdata.logger = true; status = epromchange; } } else { if ( eepromdata.logger) { eepromdata.logger = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_startup"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_startup) { eepromdata.log_startup = true; status = epromchange; } } else { if ( eepromdata.log_startup) { eepromdata.log_startup = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_rf24"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_rf24) { eepromdata.log_rf24 = true; status = epromchange; } } else { if ( eepromdata.log_rf24) { eepromdata.log_rf24 = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_sensor"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_sensor) { eepromdata.log_sensor = true; status = epromchange; } } else { if ( eepromdata.log_sensor) { eepromdata.log_sensor = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_mqtt"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_mqtt) { eepromdata.log_mqtt = true; status = epromchange; } } else { if ( eepromdata.log_mqtt) { eepromdata.log_mqtt = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_webcmd"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_webcmd) { eepromdata.log_webcmd = true; status = epromchange; } } else { if ( eepromdata.log_webcmd) { eepromdata.log_webcmd = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""log_sysinfo"") ) { if (status == error) status = nochange; if (httpServer.arg(argNo) == ""1"" ) { if ( ! eepromdata.log_sysinfo) { eepromdata.log_sysinfo = true; status = epromchange; } } else { if ( eepromdata.log_sysinfo) { eepromdata.log_sysinfo = false; status = epromchange; } } } if ( httpServer.argName(argNo) == F(""sysinfo1"") ) { fill_sysinfo1(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""sysinfo2"") ) { fill_sysinfo2(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""sysinfo3"") ) { fill_sysinfo3(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""sysinfo4"") ) { fill_sysinfo4(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""sysinfo5"") ) { fill_sysinfo5(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""webcfg1"") ) { fill_webcfg1(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""webcfg2"") ) { fill_webcfg2(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""status"") ) { handlestatus(info_str); status = ok_json; } if ( httpServer.argName(argNo) == F(""sensor1"") ) { handlesensor(info_str, sensorweb); status = ok_json; } if ( httpServer.argName(argNo) == F(""message1"") ) { handlesensor(info_str, message); status = ok_json; } #if defined(SWITCH1) if ( httpServer.argName(argNo) == ""sw1"" ) { handleSwitch1(get_tristate(httpServer.arg(argNo).c_str())); status = ok_json; } #endif #if defined(SWITCH2) if ( httpServer.argName(argNo) == ""sw2"" ) { handleSwitch2(get_tristate(httpServer.arg(argNo).c_str())); status = ok_json; } #endif #if defined(SWITCH3) if ( httpServer.argName(argNo) == ""sw3"" ) { handleSwitch3(get_tristate(httpServer.arg(argNo).c_str())); status = ok_json; } #endif #if defined(SWITCH4) if ( httpServer.argName(argNo) == ""sw4"" ) { handleSwitch4(get_tristate(httpServer.arg(argNo).c_str())); status = ok_json; } #endif #if defined(RF24GW) if ( httpServer.argName(argNo) == ""rf24gw"" ) { handlerf24gw(info_str); status = ok_json; } #endif #if defined(LEDMATRIX) if ( httpServer.argName(argNo) == ""matrixFB"" ) { getMatrixFB(info_str); status = ok_text; } if ( httpServer.argName(argNo) == ""intensity"" ) { uint8_t intensity = atoi(httpServer.arg(argNo).c_str()); if ( intensity < 16) { matrix.setIntensity(intensity); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""intensity""); mqttClient.publish(mytopic, httpServer.arg(argNo).c_str()); if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""MQTT: %s : %s"",mytopic, httpServer.arg(argNo).c_str()); write2log(info_str); } } snprintf(info_str,INFOSIZE,""%s"",httpServer.arg(argNo).c_str()); status = ok_text; } #endif #if defined(NEOPIXEL) if ( httpServer.argName(argNo) == ""getrgb"" ) { snprintf(info_str,INFOSIZE,""%u"",rgb); status = ok_text; } if ( httpServer.argName(argNo) == ""setrgb"" ) { rgb = httpServer.arg(argNo).toInt(); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""RGB""); mqttClient.publish(mytopic, httpServer.arg(argNo).c_str()); if (state_switch1) set_neopixel(on); status = ok_text; } #endif } switch (status) { case ok_json: httpServer.send(200, ""application/json"", info_str ); break; case ok_text: httpServer.send(200, ""text/plain"", info_str ); break; case ok_html: httpServer.send(200, ""text/html"", info_str ); break; case epromchange: if ( do_eepromchange ) { EEPROM.put( 0, eepromdata ); EEPROM.commit(); httpServer.send(200, ""text/plain"", ""EEPROM changed"" ); } else { httpServer.send(200, ""text/plain"", ""Settings temporary changed"" ); } break; case nochange: httpServer.send(200, ""text/plain"", ""No settings changed"" ); break; case error: httpServer.send(200, ""text/plain"", ""ERROR"" ); break; } } #if defined(SWITCH1) void mqtt_send_swtch1() { snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH1MQTT); #if defined(MQTT) mqttClient.publish(mytopic, state_switch1? c_on: c_off); #endif if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""MQTT: %s : %s"",mytopic, state_switch1? c_on: c_off); write2log(info_str); } } void switchSwitch1(bool stat) { if ( stat ) { #if defined(SWITCH1PIN1) digitalWrite(SWITCH1PIN1, SWITCH1ACTIVESTATE); #endif #if defined(SWITCH1PIN2) digitalWrite(SWITCH1PIN2, SWITCH1ACTIVESTATE); #endif #if defined(LEDMATRIX) matrix.on(); #endif #if defined(NEOPIXEL) set_neopixel(on); #endif } else { #if defined(SWITCH1PIN1) digitalWrite(SWITCH1PIN1, ! SWITCH1ACTIVESTATE); #endif #if defined(SWITCH1PIN2) digitalWrite(SWITCH1PIN2, ! SWITCH1ACTIVESTATE); #endif #if defined(LEDMATRIX) matrix.off(); #endif #if defined(NEOPIXEL) set_neopixel(off); #endif } } void handleSwitch1(tristate_t stat) { if ( stat == on || stat == off || stat == toggle ) { if ( stat == on ) { state_switch1 = true; } if ( stat == off ) { state_switch1 = false; } if ( stat == toggle ) { state_switch1 = !state_switch1; } switchSwitch1(state_switch1); #if defined(SWITCH1PIN1) state_switch1 = (digitalRead(SWITCH1PIN1) == SWITCH1ACTIVESTATE); #endif mqtt_send_swtch1(); if (eepromdata.log_sensor) { snprintf(info_str,INFOSIZE, ""Schalter1 %s"", state_switch1 ? c_on : c_off); write2log(info_str); } } snprintf(info_str,INFOSIZE,""{\\""state\\"":\\""%s\\"",\\""label\\"":\\""%s\\""}"", state_switch1 ? c_on : c_off, SWITCH1TXT); } #endif #if defined(SWITCH2) void mqtt_send_swtch2() { snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH2MQTT); #if defined(MQTT) mqttClient.publish(mytopic, state_switch2? c_on: c_off); #endif if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""MQTT: %s : %s"",mytopic, state_switch2? c_on: c_off); write2log(info_str); } } void switchSwitch2(bool stat) { if ( stat ) { #if defined(SWITCH2PIN1) digitalWrite(SWITCH2PIN1, SWITCH2ACTIVESTATE); #endif #if defined(SWITCH2PIN2) digitalWrite(SWITCH2PIN2, SWITCH2ACTIVESTATE); #endif } else { #if defined(SWITCH2PIN1) digitalWrite(SWITCH2PIN1, ! SWITCH2ACTIVESTATE); #endif #if defined(SWITCH2PIN2) digitalWrite(SWITCH2PIN2, ! SWITCH2ACTIVESTATE); #endif } } void handleSwitch2(tristate_t stat) { if ( stat == on || stat == off || stat == toggle ) { if ( stat == on ) { state_switch2 = true; } if ( stat == off ) { state_switch2 = false; } if ( stat == toggle ) { state_switch2 = !state_switch2; } switchSwitch2(state_switch2); #if defined(SWITCH2PIN1) state_switch2 = (digitalRead(SWITCH2PIN1) == SWITCH2ACTIVESTATE); #endif mqtt_send_swtch2(); if (eepromdata.log_sensor) { snprintf(info_str,INFOSIZE, ""Schalter2 %s"", state_switch2 ? c_on : c_off); write2log(info_str); } } snprintf(info_str,INFOSIZE,""{\\""state\\"":\\""%s\\"",\\""label\\"":\\""%s\\""}"", state_switch2 ? c_on : c_off, SWITCH2TXT); } #endif #if defined(SWITCH3) void mqtt_send_swtch3() { snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH3MQTT); #if defined(MQTT) mqttClient.publish(mytopic, state_switch3? c_on: c_off); #endif if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""MQTT: %s : %s"",mytopic, state_switch3? c_on: c_off); write2log(info_str); } } void switchSwitch3(bool stat) { if ( stat ) { #if defined(SWITCH3PIN1) digitalWrite(SWITCH3PIN1, SWITCH3ACTIVESTATE); #endif #if defined(SWITCH3PIN2) digitalWrite(SWITCH3PIN2, SWITCH3ACTIVESTATE); #endif } else { #if defined(SWITCH3PIN1) digitalWrite(SWITCH3PIN1, ! SWITCH3ACTIVESTATE); #endif #if defined(SWITCH3PIN2) digitalWrite(SWITCH3PIN2, ! SWITCH3ACTIVESTATE); #endif } } void handleSwitch3(tristate_t stat) { if ( stat == on || stat == off || stat == toggle ) { if ( stat == on ) { state_switch3 = true; } if ( stat == off ) { state_switch3 = false; } if ( stat == toggle ) { state_switch3 = !state_switch3; } switchSwitch3(state_switch3); #if defined(SWITCH3PIN1) state_switch3 = (digitalRead(SWITCH3PIN1) == SWITCH3ACTIVESTATE); #endif mqtt_send_swtch3(); if (eepromdata.log_sensor) { snprintf(info_str,INFOSIZE, ""Schalter3 %s"", state_switch3 ? c_on : c_off); write2log(info_str); } } snprintf(info_str,INFOSIZE,""{\\""state\\"":\\""%s\\"",\\""label\\"":\\""%s\\""}"", state_switch3 ? c_on : c_off, SWITCH3TXT); } #endif #if defined(SWITCH4) void mqtt_send_swtch4() { snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH4MQTT); #if defined(MQTT) mqttClient.publish(mytopic, state_switch4? c_on: c_off); #endif if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""MQTT: %s : %s"",mytopic, state_switch4? c_on: c_off); write2log(info_str); } } void switchSwitch4(bool stat) { if ( stat ) { #if defined(SWITCH4PIN1) digitalWrite(SWITCH4PIN1, SWITCH4ACTIVESTATE); #endif #if defined(SWITCH4PIN2) digitalWrite(SWITCH4PIN2, SWITCH4ACTIVESTATE); #endif } else { #if defined(SWITCH4PIN1) digitalWrite(SWITCH4PIN1, ! SWITCH4ACTIVESTATE); #endif #if defined(SWITCH4PIN2) digitalWrite(SWITCH4PIN2, ! SWITCH4ACTIVESTATE); #endif } } void handleSwitch4(tristate_t stat) { if ( stat == on || stat == off || stat == toggle ) { if ( stat == on ) { state_switch4 = true; } if ( stat == off ) { state_switch4 = false; } if ( stat == toggle ) { state_switch4 = !state_switch4; } switchSwitch4(state_switch4); #if defined(SWITCH4PIN1) state_switch4 = (digitalRead(SWITCH4PIN1) == SWITCH4ACTIVESTATE); #endif mqtt_send_swtch4(); if (eepromdata.log_sensor) { snprintf(info_str,INFOSIZE, ""Schalter4 %s"", state_switch4 ? c_on : c_off); write2log(info_str); } } snprintf(info_str,INFOSIZE,""{\\""state\\"":\\""%s\\"",\\""label\\"":\\""%s\\""}"", state_switch4 ? c_on : c_off, SWITCH4TXT); } #endif #if defined(NEOPIXEL) void set_neopixel(tristate_t mystate) { uint32_t red; uint32_t green; uint32_t blue; Serial.print(""mystate ""); Serial.println(mystate); if ( mystate == on ) { red = rgb & 0x0000FF; green = rgb & 0x00FF00; green >>= 8; blue = rgb & 0xFF0000; blue >>= 16; Serial.print("" On ""); } if ( mystate == off ) { red = 0; green = 0; blue = 0; Serial.print("" Off ""); } Serial.print(""R:""); Serial.print(red); Serial.print("" G:""); Serial.print(green); Serial.print("" B:""); Serial.println(blue); for(int i=0; i 5) strcat(myjson,"",""); strcat(myjson,"" \\""intensity\\"":""); snprintf(tmp,10,""%u"",matrix.getIntensity()); strcat(myjson,tmp); strcat(myjson,"", \\""display\\"":""); snprintf(tmp,10,""\\""%s\\"""",matrix.displayIsOn()? c_on:c_off); strcat(myjson,tmp); #endif strcat(myjson,""}""); } void send_udp_msg(uint32_t data) { udpdata.gw_no = GW_NO; udpdata.payload.node_id = SENSOR_NODE; udpdata.payload.msg_id = 0; udpdata.payload.msg_type = PAYLOAD_TYPE_ESP; udpdata.payload.msg_flags = PAYLOAD_FLAG_LASTMESSAGE; udpdata.payload.orderno = 0; udpdata.payload.data1 = data; udpdata.payload.data2 = 0; udpdata.payload.data3 = 0; udpdata.payload.data4 = 0; udpdata.payload.data5 = 0; udpdata.payload.data6 = 0; udp.beginPacket(HUB_IP, HUB_UDP_PORTNO); udp.write((char*)&udpdata, sizeof(udpdata)); udp.endPacket(); if (eepromdata.log_rf24) write2log(printPayload(""S>H"", &udpdata.payload, info_str)); } void handlesensor(char* myjson, call_t call) { char tmp[10]; #if defined(SENSOR_18B20) uint8_t resolution = 0; float tempC = -99; uint8_t numDev = sensors.getDeviceCount(); if ( numDev > 0 ) { resolution = sensors.getResolution(); sensors.requestTemperatures(); tempC = sensors.getTempCByIndex(0); } switch ( call ) { case sensormqtt: #if defined(SENSOR_CHANNEL) snprintf(tmp,9,""%4.1f"",tempC); send_udp_msg(packTransportValue(SENSOR_CHANNEL,tmp)); #endif case sensorweb: sprintf(myjson,""{\\""Sensor\\"":\\""18B20\\"", \\""Temperatur\\"":%4.1f, \\""Resolution\\"":%u }"", tempC, resolution); break; default: sprintf(myjson,""{\\""msg1txt\\"":\\""Temperatur %4.1f °C\\""}"", tempC); } #endif #if defined(SENSOR_ANALOG) int myval = analogRead(A0); switch ( call ) { case sensorinfo: sprintf(myjson,""{\\""Sensor\\"":\\""analog an A0\\"", \\""Messwert\\"":%d }"", myval); break; default: sprintf(myjson,""{\\""msg1txt\\"":\\""%s %d\\""}"", SENSOR_TEXT, myval); } #endif #if defined(NOSENSOR) switch ( call ) { case sensorinfo: sprintf(myjson,""{\\""Sensor\\"":\\""Kein Sensor angeschlossen\\"" }""); break; default: sprintf(myjson,""{\\""msg1\\"":0}""); } #endif } void handleWebRoot() { File file = LittleFS.open(""/index.html"", ""r""); if (file.available()) { httpServer.send(200, ""text/html"", file.readString() ); } else { httpServer.send(200, ""text/plain"", ""Datei nicht vorhanden"" ); } file.close(); } void setupFS() { // Funktionsaufruf ""setupFS();"" muss im Setup eingebunden werden LittleFS.begin(); httpServer.onNotFound([]() { if (!handleFile(httpServer.urlDecode(httpServer.uri()))) httpServer.send(404, ""text/plain"", ""FileNotFound""); }); } bool handleFile(String &&path) { if (path.endsWith(""/"")) path += ""index.html""; return LittleFS.exists(path) ? ({File f = LittleFS.open(path, ""r""); httpServer.streamFile(f, mime::getContentType(path)); f.close(); true;}) : false; } void fill_sysinfo1(char* mystr) { int rssi = WiFi.RSSI(); int rssi_quality = 0; if (rssi <= -100) { rssi_quality = 0; } else if (rssi >= -50) { rssi_quality = 100; } else { rssi_quality = 2 * (rssi + 100); } snprintf (mystr,INFOSIZE, ""{\\""Hostname\\"":\\""%s\\"", \\""SSID\\"":\\""%s (%ddBm / %d%%)\\"", \\""IP\\"":\\""%s\\"", \\""Channel\\"":\\""%d\\"", \\""GW-IP\\"":\\""%s\\""}"", WiFi.hostname().c_str(), WiFi.SSID().c_str(), rssi, rssi_quality, WiFi.localIP().toString().c_str(), WiFi.channel(), WiFi.gatewayIP().toString().c_str()); } void fill_sysinfo2(char* mystr) { snprintf (mystr,INFOSIZE, ""{\\""Freespace\\"":\\""%0.0fKB\\"", \\""Sketchsize\\"":\\""%0.0fKB\\"", \\""FlashSize\\"":\\""%dMB\\"", \\""FlashFreq\\"":\\""%dMHz\\"", \\""CpuFreq\\"":\\""%dMHz\\""}"", ESP.getFreeSketchSpace() / 1024.0, ESP.getSketchSize() / 1024.0, (int)(ESP.getFlashChipSize() / 1024 / 1024), (int)(ESP.getFlashChipSpeed() / 1000000), (int)(F_CPU / 1000000) ); } void fill_sysinfo3(char* mystr) { uint32_t free; uint16_t max; uint8_t frag; ESP.getHeapStats(&free, &max, &frag); snprintf (mystr,INFOSIZE, ""{\\""MAC\\"":\\""%s\\"",\\""SubNetMask\\"":\\""%s\\"",\\""ResetReason\\"":\\""%s\\"",\\""Heap_max\\"":\\""%0.2fKB\\"",\\""Heap_free\\"":\\""%0.2fKB\\"",\\""Heap_frag\\"":\\""%u\\""}"", WiFi.macAddress().c_str(), WiFi.subnetMask().toString().c_str(), ESP.getResetReason().c_str(), (float)max/1024.0, (float)free/1024.0, frag); } void fill_sysinfo4(char* mystr) { snprintf (mystr,INFOSIZE, ""{\\""DnsIP\\"":\\""%s\\"", \\""BSSID\\"":\\""%s\\"", \\""CoreVer\\"":\\""%s\\"", \\""IdeVer\\"":\\""%u\\"", \\""SdkVer\\"":\\""%s\\""}"", WiFi.dnsIP().toString().c_str(), WiFi.BSSIDstr().c_str(), ESP.getCoreVersion().c_str(), ARDUINO, ESP.getSdkVersion()); } void fill_sysinfo5(char* mystr) { uptime::calculateUptime(); snprintf (mystr,INFOSIZE, ""{\\""MQTT-Hostname\\"":\\""%s\\"", \\""UpTime\\"":\\""%uT%02u:%02u:%02u\\"", \\""SW\\"":\\""%s / %s\\""}"", MQTT_NODENAME, uptime::getDays(), uptime::getHours(), uptime::getMinutes(), uptime::getSeconds(), SWVERSION_STR, SWDATUM ); } void fill_webcfg1(char* mystr) { sprintf(mystr, ""{\\""titel1\\"":\\""""); strcat(mystr, TITEL1); strcat(mystr, ""\\""""); #if defined(TITEL2) strcat(mystr, "",\\""titel2\\"":\\""""); strcat(mystr, TITEL2); strcat(mystr, ""\\""""); #endif #if defined(MESSAGE1) strcat(mystr, "",\\""msg1\\"":1 ""); #endif #if defined(MESSAGE2) strcat(mystr, "",\\""msg2\\"":1 ""); #endif #if defined(SWITCH1) strcat(mystr, "",\\""sw1\\"":1 ""); #endif #if defined(SWITCH2) strcat(mystr, "",\\""sw2\\"":1 ""); #endif #if defined(SWITCH3) strcat(mystr, "",\\""sw3\\"":1 ""); #endif #if defined(SWITCH4) strcat(mystr, "",\\""sw4\\"":1 ""); #endif #if defined(RF24GW) strcat(mystr, "",\\""rf24\\"":1 ""); #endif #if defined(LEDMATRIX) strcat(mystr,"", \\""ledmatrix\\"":1 ""); #endif #if defined(NEOPIXEL) strcat(mystr,"", \\""neopixel\\"":1 ""); #endif strcat(mystr,""}""); } void fill_webcfg2(char* mystr) { snprintf(mystr,INFOSIZE, ""{\\""logfile\\"":\\""%d\\"", \\""logger\\"":\\""%d\\"", \\""log_sensor\\"":\\""%d\\"", \\""log_rf24\\"":\\""%d\\"", \\""log_startup\\"":\\""%d\\"", \\""log_mqtt\\"":\\""%d\\"", \\""log_webcmd\\"":\\""%d\\"", \\""log_sysinfo\\"":\\""%d\\""}"", eepromdata.logfile, eepromdata.logger, eepromdata.log_sensor, eepromdata.log_rf24, eepromdata.log_startup, eepromdata.log_mqtt, eepromdata.log_webcmd, eepromdata.log_sysinfo); } void fill_timeStr() { time(&now); // read the current time localtime_r(&now, &tm); // update the structure tm with the current time snprintf(timeStr,9,""%02d:%02d:%02d"",tm.tm_hour,tm.tm_min,tm.tm_sec); } void write2log(char* text) { fill_timeStr(); if (eepromdata.logfile) { File f = LittleFS.open(""/logfile.txt"", ""a""); if (f) { f.print(timeStr); f.print("": ""); f.print(text); f.print(""\\n""); f.close(); } } if (eepromdata.logger) { logger.addLine(timeStr,text); } } #if defined(MQTT) void mqtt_send_stat() { char tmp[LOGGER_LINESIZE]; if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""%s"",F(""Sende MQTT stat Interval"")); write2log(info_str); } #if defined(SWITCH1) mqtt_send_swtch1(); #endif #if defined(SWITCH2) mqtt_send_swtch2(); #endif #if defined(SWITCH3) mqtt_send_swtch3(); #endif #if defined(SWITCH4) mqtt_send_swtch4(); #endif #if defined(SENSOR_18B20) || defined(SENSOR_ANALOG) handlesensor(info_str, sensormqtt); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""sensordata""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } #endif handlestatus(info_str); if ( strlen(info_str) > 5 ) { snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""devicestatus""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } } } void mqtt_send_tele() { if (eepromdata.log_mqtt) { snprintf(info_str,INFOSIZE,""%s"",F(""Sende MQTT tele Interval"")); write2log(info_str); } fill_sysinfo1(info_str); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""tele"",MQTT_NODENAME,""info1""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } fill_sysinfo2(info_str); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""tele"",MQTT_NODENAME,""info2""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } fill_sysinfo3(info_str); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""tele"",MQTT_NODENAME,""info3""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } fill_sysinfo4(info_str); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""tele"",MQTT_NODENAME,""info4""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } fill_sysinfo5(info_str); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""tele"",MQTT_NODENAME,""info5""); mqttClient.publish(mytopic, info_str); if (eepromdata.log_mqtt) { write2log(mytopic); write2log(info_str); } } void callback(char* topic, byte* payload, unsigned int length) { char delimiter[] = ""/""; char *ptr; tristate_t mystate; char part1[TOPIC_PART1_SIZE]; char part2[TOPIC_PART2_SIZE]; char part3[TOPIC_PART3_SIZE]; char msg[10]; char* cmd = (char*)malloc(length+2); snprintf(cmd,length+1,""%s"",(char*)payload); snprintf (info_str,INFOSIZE, ""Callback Msg: T:%s l:%u c:%s"", topic, length, cmd); if (eepromdata.log_mqtt) { write2log(info_str); } ptr = strtok(topic, delimiter); if(ptr != NULL) snprintf(part1, TOPIC_PART1_SIZE, ""%s"", ptr); ptr = strtok(NULL, delimiter); if(ptr != NULL) snprintf(part2, TOPIC_PART2_SIZE, ""%s"", ptr); ptr = strtok(NULL, delimiter); if(ptr != NULL) snprintf(part3, TOPIC_PART3_SIZE, ""%s"", ptr); if ( strncmp(part1,MQTT_CMD, sizeof MQTT_CMD) == 0 ) { if ( strncmp(part2, MQTT_NODENAME, sizeof MQTT_NODENAME) == 0 ) { #if defined(SWITCH1) if ( strncmp(part3, SWITCH1MQTT, sizeof SWITCH1MQTT) == 0 ) { mystate = get_tristate(cmd); handleSwitch1(mystate); snprintf(msg,10,""%s"",mystate==on? c_on: c_off); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH1MQTT); mqttClient.publish(mytopic, msg, strlen(msg) ); } #endif #if defined(SWITCH2) if ( strncmp(part3, SWITCH2MQTT, sizeof SWITCH2MQTT) == 0 ) { mystate = get_tristate(cmd); handleSwitch2(mystate); snprintf(msg,10,""%s"",mystate==on? c_on: c_off); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH2MQTT); mqttClient.publish(mytopic, msg, strlen(msg) ); } #endif #if defined(SWITCH3) if ( strncmp(part3, SWITCH3MQTT, sizeof SWITCH3MQTT) == 0 ) { mystate = get_tristate(cmd); handleSwitch3(mystate); snprintf(msg,10,""%s"",mystate==on? c_on: c_off); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH3MQTT); mqttClient.publish(mytopic, msg, strlen(msg) ); } #endif #if defined(SWITCH4) if ( strncmp(part3, SWITCH4MQTT, sizeof SWITCH4MQTT) == 0 ) { mystate = get_tristate(cmd); handleSwitch4(mystate); snprintf(msg,10,""%s"",mystate==on? c_on: c_off); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,SWITCH4MQTT); mqttClient.publish(mytopic, msg, strlen(msg) ); } #endif #if defined(LEDMATRIX) if ( strncmp(part3, ""graph"", sizeof ""graph"") == 0 ) { for(unsigned int pos=0; pos+5<=length; pos+=5){ unsigned int cur_x = (cmd[pos]-'0')*10 + (cmd[pos+1]-'0'); unsigned int cur_y = (cmd[pos+2]-'0')*10 + (cmd[pos+3]-'0'); matrix.setPixel(cur_x, cur_y, cmd[pos+4]-'0'); } matrix.display(); } if ( strncmp(part3, ""intensity"", sizeof ""intensity"") == 0 ) { uint8_t intensity = atoi(cmd); if ( intensity <16 ) { matrix.setIntensity(intensity); snprintf(info_str,INFOSIZE,""{ \\""intensity\\"":%u }"",matrix.getIntensity()); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""matrixdata""); mqttClient.publish(mytopic, info_str); } } if ( strncmp(part3, ""line"", sizeof ""line"") == 0 ) { print_line(cmd); } #endif #if defined(NEOPIXEL) if ( strncmp(part3, ""RGB"", sizeof ""RGB"") == 0 ) { char *eptr; rgb = strtoul(cmd, &eptr, 10); if (state_switch1) set_neopixel(on); snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""stat"",MQTT_NODENAME,""devicestatus""); mqttClient.publish(mytopic, cmd); } #endif } } // Free the memory free(cmd); } void mqtt_reconnect() { // Loop until we're reconnected while (!mqttClient.connected()) { // Attempt to connect if (mqttClient.connect(MQTT_NODENAME)) { // Once connected, publish an announcement... // mqtt_send_stat(); // ... and resubscribe snprintf(mytopic,TOPIC_BUFFER_SIZE,""%s/%s/%s"",""cmnd"",MQTT_NODENAME,""#""); mqttClient.subscribe(mytopic); } else { // Wait 1 seconds before retrying delay(1000); } } } #endif #if defined(RF24GW) char* printPayload(char* prefix, payload_t *payload, char* placeholder) { char buf1[10]; char buf2[10]; char buf3[10]; char buf4[10]; char buf5[10]; char buf6[10]; snprintf(placeholder,INFOSIZE,""%s: N:%u T:%u m:%u F:0x%02x O:%u H:%u (%u/%s)(%u/%s)(%u/%s)(%u/%s)(%u/%s)(%u/%s)"", prefix ,payload->node_id, payload->msg_type, payload->msg_id, payload->msg_flags, payload->orderno, payload->heartbeatno ,getChannel(payload->data1), unpackTransportValue(payload->data1, buf1) ,getChannel(payload->data2), unpackTransportValue(payload->data2, buf2) ,getChannel(payload->data3), unpackTransportValue(payload->data3, buf3) ,getChannel(payload->data4), unpackTransportValue(payload->data4, buf4) ,getChannel(payload->data5), unpackTransportValue(payload->data5, buf5) ,getChannel(payload->data6), unpackTransportValue(payload->data6, buf6) ); return placeholder; } #endif void loop() { delay(0); #if defined(RF24GW) while ( radio.available() ) { radio.read(&payload, sizeof(payload)); if (eepromdata.log_rf24) write2log(printPayload(""N>G"", &payload, info_str)); udpdata.gw_no = GW_NO; memcpy(&udpdata.payload, &payload, sizeof(payload)); udp.beginPacket(HUB_IP, HUB_UDP_PORTNO); udp.write((char*)&udpdata, sizeof(udpdata)); udp.endPacket(); } if (udp.parsePacket() > 0 ) { udp.read((char*)&udpdata, sizeof(udpdata)); memcpy(&payload, &udpdata.payload, sizeof(payload)); if (eepromdata.log_rf24) write2log(printPayload(""G>N"", &payload, info_str)); radio.stopListening(); radio.write(&payload, sizeof(payload)); radio.startListening(); } #endif #if defined(MQTT) if ( ! mqttClient.connected()) { if (eepromdata.log_mqtt) { sprintf(info_str,""%s"",F(""MQTT reconnect"")); write2log(info_str); } mqtt_reconnect(); } mqttClient.loop(); delay(0); if ((millis() - lastMsg) > STATINTERVAL) { lastMsg = millis(); mqtt_send_stat(); } if ((millis() - lastInfo) > TELEINTERVAL) { lastInfo = millis(); mqtt_send_tele(); } #endif delay(0); httpServer.handleClient(); MDNS.update(); ArduinoOTA.handle(); // Wait for OTA connection delay(0); } ",12065,False,2223.763137783386,median "void setup() { pinMode(3, OUTPUT); // put your setup code here, to run once: } void loop(){ //first verse tone(3,370,600); delay(600); tone(3,554,300); delay(300); tone(3,466,300); delay(300); tone(3,466,600); delay(600); tone(3,415,300); delay(300); tone(3,370,300); delay(300); tone(3,370,300); delay(300); tone(3,494,600);//B delay(600); tone(3,466,300); delay(300); tone(3,466,300); delay(300); tone(3,415,300); delay(300); tone(3,415,300); delay(300); tone(3,370,600); delay(600); tone(3,370,300); delay(300); tone(3,554,300); delay(300); tone(3,466,300); delay(300); tone(3,466,600); delay(600); tone(3,415,300); delay(300); tone(3,370,300); delay(300); tone(3,370,300); delay(300); tone(3,311,600); delay(600); tone(3,277,900); delay(1500); tone(3,370,300); delay(300); tone(3,370,300); delay(300); tone(3,554,300); delay(300); //At this point I made custom presets tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,494,600);//B4 delay(600); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,554,600);//C#5 delay(600); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,600);//G#4 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,415,600);//G#4 delay(600); tone(3,311,900);//D#4 delay(1500); tone(3,369,450);//F#4 delay(450); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,277,150);//C#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(450); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,369,450);//F#4 delay(450); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,494,300);//B4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,300);//G#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,415,450);//G#4 delay(450); tone(3,415,150);//G#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,311,150);//D#4 delay(150); tone(3,277,150);//C#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(600); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,622,300);//D#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,622,300);//D#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,494,300);//B4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,415,300);//G#4 delay(300); tone(3,369,600);//F#4 delay(750); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(900); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,311,300);//D#4 delay(300); tone(3,311,600);//D#4 delay(1200); //chorus tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,466,900);//A#4 delay(900); tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,466,600);//A#4 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,466,600);//A#4 delay(600); tone(3,554,600);//C#5 delay(600); tone(3,494,300);//B4 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,622,300);//D#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,600);//G#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,311,1800);//D#4 delay(1800); //Second verse tone(3,311,150);//D#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,311,150);//D#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,494,300);//B4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,466,450);//A#4 delay(450); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,311,300);//D#4 delay(300); tone(3,311,150);//D#4 delay(150); tone(3,277,300);//C#4 delay(300); tone(3,277,150);//C#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,622,450);//D#5 delay(450); tone(3,554,150);//C#5 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,450);//F#4 delay(450); tone(3,369,150);//F#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,494,300);//B4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,311,300);//D#4 delay(300); tone(3,311,450);//D#4 delay(450); tone(3,277,150);//C#4 delay(150); tone(3,622,300);//D#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,554,600);//C#5 delay(600); tone(3,466,150);//A#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,750);//F#4 delay(750); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,311,300);//D#4 delay(300); tone(3,311,300);//D#4 delay(1200); //Chorus tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,466,900);//A#4 delay(900); tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,466,600);//A#4 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,1109,600);//C#6 delay(600); tone(3,988,300);//B5 delay(300); tone(3,1109,300);//C#6 delay(300); tone(3,1245,300);//D#6 delay(300); tone(3,1480,600);//F#6 delay(600); tone(3,1661,300);//G#6 delay(300); tone(3,1480,600);//F#6 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,600);//G#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,311,1800);//D#4 delay(1800); //interlude tone(3,1109,600);//C#6 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,988,300);//B5 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,300);//F#5 delay(300); tone(3,622,300);//D#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,1109,600);//C#6 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,988,300);//B5 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,300);//F#5 delay(300); tone(3,622,300);//D#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,1109,600);//C#6 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,988,300);//B5 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,300);//F#5 delay(300); tone(3,622,300);//D#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,1109,600);//C#6 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,831,600);//G#5 delay(600); tone(3,932,300);//A#5 delay(300); tone(3,622,1800);//D#5 delay(1800); //altered chorus tone(3,466,300);//A#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,150);//F#4 delay(150); tone(3,311,150);//D#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,466,900);//A#4 delay(900); tone(3,932,300);//A#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,600);//F#5 delay(600); tone(3,932,600);//A#5 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,1109,600);//C#6 delay(600); tone(3,988,300);//B5 delay(300); tone(3,1109,300);//C#6 delay(300); tone(3,1245,300);//D#6 delay(300); tone(3,1480,1350);//F#6 delay(1350); tone(3,740,300);//F#5 delay(300); tone(3,740,300);//F#5 delay(300); tone(3,831,300);//G#5 delay(300); tone(3,740,300);//F#5 delay(300); tone(3,1109,300);//C#6 delay(300); tone(3,932,1500);//A#5 delay(1500); //bridge tone(3,369,600);//F#4 delay(600); tone(3,554,300);//C#5 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,466,600);//A#4 delay(600); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,494,600);//B4 delay(600); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,311,600);//D#4 delay(600); tone(3,277,900);//C#4 delay(1500); tone(3,622,150);//D#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,750);//C#5 delay(750); tone(3,466,150);//A#4 delay(150); tone(3,415,150);//G#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(600); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,494,300);//B4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,494,150);//B4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,494,300);//B4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,311,300);//D#4 delay(300); tone(3,277,300);//C#4 delay(300); tone(3,311,300);//D#4 delay(300); tone(3,277,300);//C#4 delay(300); tone(3,554,600);//C#5 delay(600); tone(3,466,300);//A#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,600);//F#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,466,900);//A#4 delay(1350); tone(3,622,450);//D#5 delay(450); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,554,150);//C#5 delay(150); tone(3,554,450);//C#5 delay(450); tone(3,554,300);//C#5 delay(300); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,622,150);//D#5 delay(150); tone(3,554,450);//C#5 delay(450); tone(3,466,150);//A#4 delay(150); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,494,300);//B4 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,415,300);//G#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,415,450);//G#4 delay(450); tone(3,415,150);//G#4 delay(150); tone(3,466,300);//A#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,311,150);//D#4 delay(150); tone(3,277,150);//C#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(600 ); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,622,300);//D#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,622,300);//D#5 delay(300); tone(3,466,150);//A#4 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,494,300);//B4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,415,300);//G#4 delay(300); tone(3,369,600);//F#4 delay(750); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,150);//F#4 delay(150); tone(3,369,150);//F#4 delay(150); tone(3,369,300);//F#4 delay(300); tone(3,369,600);//F#4 delay(1050); tone(3,466,150);//A#4 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,150);//C#5 delay(150); tone(3,554,150);//C#5 delay(150); tone(3,554,300);//C#5 delay(300); tone(3,554,600);//C#5 delay(1200); //final chorus tone(3,932,300);//A#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,600);//F#5 delay(600); tone(3,932,900);//A#5 delay(900); tone(3,932,300);//A#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,150);//F#5 delay(150); tone(3,622,150);//D#5 delay(150); tone(3,740,300);//F#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,740,600);//F#5 delay(600); tone(3,932,900);//A#5 delay(900); tone(3,466,600);//A#4 delay(600); tone(3,554,600);//C#5 delay(600); tone(3,494,300);//B4 delay(300); tone(3,554,300);//C#5 delay(300); tone(3,622,300);//D#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,831,300);//G#5 delay(300); tone(3,740,600);//F#5 delay(600); tone(3,369,300);//F#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,415,300);//G#4 delay(300); tone(3,369,300);//F#4 delay(300); tone(3,466,300);//A#4 delay(300); tone(3,415,600);//G#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,369,600);//F#4 delay(600); tone(3,415,600);//G#4 delay(600); tone(3,311,1200);//D#4 delay(1500); //final stretch tone(3,740,300);//F#5 delay(300); tone(3,932,600);//A#5 delay(600); tone(3,1109,605);//C#6 delay(605); tone(3,988,310);//B5 delay(310); tone(3,1109,315);//C#6 delay(315); tone(3,1245,320);//D#6 delay(320); tone(3,1480,630);//F#6 delay(630); tone(3,1661,335);//G#6 delay(335); tone(3,1480,650);//F#6 delay(650); tone(3,740,360);//F#5 delay(360); tone(3,740,370);//F#5 delay(370); tone(3,831,380);//G#5 delay(380); tone(3,740,390);//F#5 delay(390); tone(3,932,400);//A#5 delay(400); tone(3,831,710);//G#5 delay(710); tone(3,831,720);//G#5 delay(720); tone(3,740,730);//F#5 delay(730); tone(3,831,750);//G#5 delay(750); tone(3,932,475);//A#5 delay(475); tone(3,622,4000);//D#5 delay(7000); } ",12209,True,3913.4793382304006,median ";this file for FamiTone2 library generated by FamiStudio silver_surfer_c_stephen_ruddy_music_data: .db 1 .dw .instruments .dw .samples-3 .dw .song0ch0,.song0ch1,.song0ch2,.song0ch3,.song0ch4 .db LOW(.tempo_env6), HIGH(.tempo_env6), 0, 0 .instruments: .dw .env59,.env38,.env34,.env31 .dw .env50,.env43,.env34,.env31 .dw .env39,.env38,.env34,.env31 .dw .env44,.env38,.env34,.env31 .dw .env20,.env47,.env34,.env31 .dw .env13,.env41,.env34,.env31 .dw .env36,.env42,.env34,.env31 .dw .env30,.env38,.env34,.env31 .dw .env11,.env40,.env34,.env31 .dw .env14,.env32,.env37,.env31 .dw .env14,.env1,.env15,.env31 .dw .env14,.env1,.env34,.env31 .dw .env14,.env1,.env35,.env31 .dw .env14,.env1,.env6,.env31 .dw .env54,.env26,.env34,.env10 .dw .env54,.env25,.env6,.env49 .dw .env52,.env25,.env6,.env49 .dw .env17,.env1,.env35,.env61 .dw .env5,.env1,.env34,.env31 .dw .env29,.env1,.env35,.env28 .dw .env55,.env12,.env6,.env31 .dw .env58,.env1,.env37,.env31 .dw .env14,.env4,.env34,.env31 .dw .env8,.env1,.env35,.env31 .dw .env7,.env1,.env34,.env23 .dw .env7,.env19,.env34,.env31 .dw .env7,.env1,.env37,.env23 .dw .env7,.env1,.env35,.env23 .dw .env55,.env1,.env34,.env31 .dw .env53,.env1,.env35,.env51 .dw .env46,.env1,.env6,.env3 .dw .env56,.env27,.env34,.env31 .dw .env60,.env57,.env34,.env31 .samples: .env0: .db $c0,$cc,$c3,$cf,$c7,$d3,$cc,$d8,$c7,$cc,$cf,$d3,$00,$00 .env1: .db $c0,$7f,$00,$00 .env2: .db $c0,$02,$c4,$02,$c9,$02,$c4,$c4,$c4,$00,$00 .env3: .db $00,$c0,$08,$c0,$bf,$be,$bd,$be,$bf,$c0,$c1,$c2,$c3,$c2,$c1,$00,$03 .env4: .db $c0,$03,$b4,$00,$02 .env5: .db $04,$c5,$00,$01,$c4,$03,$c3,$03,$c2,$00,$08 .env6: .db $c3,$7f,$00,$00 .env7: .db $00,$c2,$c4,$c5,$c6,$c4,$00,$05 .env8: .db $00,$c1,$c2,$c3,$c4,$00,$04 .env9: .db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c7,$c7,$d3,$d3,$00,$00 .env10: .db $00,$c0,$c0,$c1,$00,$03 .env11: .db $00,$c7,$c5,$c5,$c4,$c4,$c3,$c3,$c2,$c2,$c1,$c1,$c0,$00,$0c .env12: .db $c0,$c0,$cc,$00,$02 .env13: .db $00,$c5,$c4,$03,$c3,$04,$c2,$00,$06 .env14: .db $04,$cf,$7f,$00,$01 .env15: .db $c0,$c0,$c1,$c1,$c0,$c0,$00,$00 .env16: .db $c0,$02,$c5,$02,$c8,$02,$c5,$c5,$c5,$00,$00 .env17: .db $00,$c8,$c7,$c6,$c5,$c4,$c3,$c2,$c1,$03,$c2,$c4,$c3,$c2,$c1,$c1,$c2,$c4,$c3,$c2,$c1,$c1,$c2,$c6,$c5,$c4,$c3,$c2,$c1,$c4,$c3,$c2,$c1,$02,$c3,$c2,$c1,$02,$c2,$c4,$c3,$c2,$c1,$c1,$c4,$00,$01 .env18: .db $c0,$cc,$c4,$d0,$c7,$d3,$cc,$d8,$c7,$cc,$cf,$d3,$00,$00 .env19: .db $c0,$c0,$b4,$b4,$c0,$c0,$00,$00 .env20: .db $0b,$c7,$c3,$10,$c2,$05,$c1,$05,$c0,$00,$08,$c1,$c2,$00,$0c .env21: .db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c7,$c7,$d3,$d3,$cb,$cb,$d7,$d7,$00,$00 .env22: .db $c0,$c0,$cc,$cc,$c4,$c4,$d0,$d0,$c6,$c6,$d2,$d2,$c9,$c9,$d5,$d5,$00,$00 .env23: .db $00,$c0,$09,$c0,$be,$bc,$be,$c0,$c2,$c4,$c2,$00,$03 .env24: .db $c0,$02,$c4,$02,$c7,$02,$c4,$c4,$c4,$00,$00 .env25: .db $c0,$d3,$c0,$00,$02 .env26: .db $c0,$cc,$c0,$00,$02 .env27: .db $c0,$be,$ba,$b6,$b4,$b2,$00,$05 .env28: .db $00,$b5,$c4,$d3,$e2,$f1,$ff,$00,$01 .env29: .db $04,$c3,$7f,$00,$01 .env30: .db $00,$c4,$03,$c3,$03,$c2,$00,$05 .env31: .db $00,$c0,$7f,$00,$01 .env32: .db $c0,$bf,$be,$bd,$bc,$bb,$ba,$b9,$b8,$b7,$b6,$b5,$00,$00 .env33: .db $c0,$02,$c5,$02,$c9,$02,$c5,$c5,$c5,$00,$00 .env34: .db $7f,$00,$00 .env35: .db $c2,$7f,$00,$00 .env36: .db $00,$c5,$c4,$02,$c3,$03,$c2,$04,$c1,$00,$08 .env37: .db $c1,$7f,$00,$00 .env38: .db $c0,$c2,$00,$01 .env39: .db $00,$c3,$c3,$c2,$c1,$c0,$00,$05 .env40: .db $c0,$c3,$00,$01 .env41: .db $c0,$c6,$00,$01 .env42: .db $c0,$c4,$00,$01 .env43: .db $c0,$c5,$00,$01 .env44: .db $00,$c4,$02,$c3,$02,$c2,$02,$c1,$00,$07 .env45: .db $c0,$c0,$cc,$cc,$c4,$c4,$cf,$cf,$c7,$c7,$d3,$d3,$cc,$cc,$d8,$d8,$c7,$c7,$cc,$cc,$cf,$cf,$d3,$d3,$00,$00 .env46: .db $04,$c5,$00,$01,$c3,$c1,$00,$05 .env47: .db $c0,$c4,$02,$c5,$03,$c6,$04,$c7,$00,$07 .env48: .db $c0,$02,$c5,$02,$c7,$02,$c5,$c5,$c5,$00,$00 .env49: .db $00,$c0,$c1,$00,$02 .env50: .db $00,$c5,$c3,$c2,$c1,$c0,$00,$05 .env51: .db $00,$c0,$03,$c0,$bf,$be,$bd,$be,$bf,$c0,$c1,$c2,$c3,$c2,$c1,$00,$03 .env52: .db $00,$c4,$c3,$c4,$c4,$c2,$c1,$00,$06 .env53: .db $04,$c4,$00,$01,$c2,$c1,$00,$05 .env54: .db $04,$c4,$7f,$00,$01 .env55: .db $00,$c5,$c5,$c4,$c4,$00,$01 .env56: .db $00,$cf,$05,$c0,$00,$03 .env57: .db $c0,$bf,$00,$01 .env58: .db $00,$c5,$c5,$c4,$02,$c3,$00,$05 .env59: .db $00,$c5,$c4,$c4,$c3,$02,$c2,$02,$c1,$00,$08 .env60: .db $00,$cf,$cf,$c0,$00,$03 .env61: .db $00,$bf,$c0,$00,$02 .env62: .db $00,$c0,$bf,$be,$02,$bf,$c1,$c2,$02,$c1,$00,$01 .tempo_env6: .db $01,$05,$80 .song0ch0: .ref0: .db $72,$96,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89 .ref1: .db $33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89,$33,$89,$2e,$89 .song0ch0loop: .ref2: .db $fb,LOW(.tempo_env6),HIGH(.tempo_env6),$7f,$64,LOW(.env18),HIGH(.env18),$a4,$25,$c5,$64,LOW(.env0),HIGH(.env0),$62,$27,$b1,$f9,$91,$64,LOW(.env18),HIGH(.env18),$2a,$ad .ref3: .db $62,$2c,$f7,$b1,$f9,$91 .ref4: .db $67,$25,$c5,$64,LOW(.env0),HIGH(.env0),$62,$27,$b1,$f9,$91,$64,LOW(.env18),HIGH(.env18),$2a,$ad .db $ff,$05 .dw .ref3 .db $ff,$08 .dw .ref4 .db $ff,$05 .dw .ref3 .ref5: .db $67,$2c,$95 .ref6: .db $74,$64,LOW(.env45),HIGH(.env45),$96,$28,$f7,$c5 .ref7: .db $64,LOW(.env22),HIGH(.env22),$28,$f7,$c5 .ref8: .db $7f,$64,LOW(.env1),HIGH(.env1),$66,$9c,$24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1b,$91,$00,$81,$1a,$91,$00,$81,$1b,$91,$00,$81 .ref9: .db $24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1f,$91,$00,$81,$22,$91,$00,$81,$24,$91,$00,$81 .ref10: .db $24,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$18,$85,$00,$81,$1d,$9d,$00,$81,$1b,$91,$00,$81,$1a,$91,$00,$81,$1b,$91,$00,$81 .db $ff,$2c .dw .ref9 .db $ff,$2c .dw .ref10 .db $ff,$2c .dw .ref9 .db $ff,$2c .dw .ref10 .db $ff,$2c .dw .ref9 .db $ff,$2c .dw .ref10 .db $ff,$2c .dw .ref9 .db $ff,$2c .dw .ref10 .db $ff,$2c .dw .ref9 .db $ff,$2c .dw .ref10 .db $ff,$2c .dw .ref9 .ref11: .db $64,LOW(.env16),HIGH(.env16),$aa,$2b,$dd,$64,LOW(.env2),HIGH(.env2),$2c,$dd .ref12: .db $64,LOW(.env33),HIGH(.env33),$29,$dd,$64,LOW(.env48),HIGH(.env48),$2b,$ad,$64,LOW(.env24),HIGH(.env24),$2b,$ad .ref13: .db $64,LOW(.env16),HIGH(.env16),$62,$2b,$dd,$64,LOW(.env2),HIGH(.env2),$2c,$dd .db $ff,$06 .dw .ref12 .db $ff,$04 .dw .ref13 .db $ff,$06 .dw .ref12 .db $ff,$04 .dw .ref13 .db $ff,$06 .dw .ref12 .ref14: .db $73,$64,LOW(.env1),HIGH(.env1),$66,$98,$30,$ad,$62,$61,$fd,$30,$48,$f7,$95 .ref15: .db $f7,$c7 .ref16: .db $7f,$a2,$57,$dd,$57,$dd .ref17: .db $57,$dd,$57,$dd .ref18: .db $57,$dd,$57,$dd .ref19: .db $57,$dd,$57,$dd .ref20: .db $9e,$23,$95,$17,$95,$23,$95,$17,$95,$23,$95,$17,$95,$23,$95,$17,$95 .ref21: .db $21,$95,$a0,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89,$17,$89,$17,$89,$21,$89 .db $ff,$10 .dw .ref20 .db $ff,$1e .dw .ref21 .db $ff,$10 .dw .ref20 .db $ff,$1e .dw .ref21 .db $ff,$10 .dw .ref20 .db $ff,$1e .dw .ref21 .ref22: .db $64,LOW(.env9),HIGH(.env9),$b8,$24,$f7,$c5 .ref23: .db $64,LOW(.env21),HIGH(.env21),$22,$f7,$c5 .ref24: .db $64,LOW(.env9),HIGH(.env9),$24,$f7,$c5 .db $ff,$03 .dw .ref23 .ref25: .db $64,LOW(.env9),HIGH(.env9),$21,$f7,$c5 .ref26: .db $64,LOW(.env21),HIGH(.env21),$1f,$f7,$c5 .db $ff,$03 .dw .ref25 .db $ff,$03 .dw .ref26 .ref27: .db $64,LOW(.env1),HIGH(.env1),$66,$a8,$17,$85,$19,$85,$1b,$85,$1e,$85,$23,$85,$25,$85,$27,$85,$2a,$85,$2f,$85,$31,$85,$33,$85,$36,$85,$33,$85,$31,$85,$2f,$85,$2a,$85,$27,$85,$25,$85,$23,$85,$1e,$85,$1b,$85,$19,$85,$17,$85,$12,$85 .ref28: .db $19,$85,$1b,$85,$1d,$85,$20,$85,$25,$85,$27,$85,$29,$85,$2c,$85,$31,$85,$33,$85,$35,$85,$38,$85,$35,$85,$33,$85,$31,$85,$2c,$85,$29,$85,$27,$85,$25,$85,$20,$85,$1d,$85,$1b,$85,$19,$85,$14,$85 .ref29: .db $17,$85,$19,$85,$1b,$85,$1e,$85,$23,$85,$25,$85,$27,$85,$2a,$85,$2f,$85,$31,$85,$33,$85,$36,$85,$33,$85,$31,$85,$2f,$85,$2a,$85,$27,$85,$25,$85,$23,$85,$1e,$85,$1b,$85,$19,$85,$17,$85,$12,$85 .db $ff,$30 .dw .ref28 .db $ff,$30 .dw .ref29 .db $ff,$30 .dw .ref29 .ref30: .db $17,$85,$1b,$85,$1d,$85,$20,$85,$23,$85,$27,$85,$29,$85,$2c,$85,$2f,$85,$33,$85,$35,$85,$38,$85,$35,$85,$33,$85,$2f,$85,$2c,$85,$29,$85,$27,$85,$23,$85,$20,$85,$1d,$85,$1b,$85,$17,$85,$14,$85 .db $ff,$30 .dw .ref30 .db $ff,$20 .dw .ref0 .db $ff,$1c .dw .ref1 .db $fd .dw .song0ch0loop .song0ch1: .ref31: .db $7f,$a6,$61,$fe,$2f,$44,$f7,$c5 .ref32: .db $f7,$af .song0ch1loop: .ref33: .db $74,$98,$30,$31,$9b,$61,$0f,$31,$2c,$91,$72,$61,$0f,$31,$2c,$91,$74,$32,$33,$9b,$61,$13,$33,$2c,$91,$72,$61,$13,$33,$2c,$91,$74,$34,$35,$36,$89,$63,LOW(.env62),HIGH(.env62),$9d,$63,LOW(.env31),HIGH(.env31),$65,$81 .ref34: .db $37,$38,$8d,$63,LOW(.env62),HIGH(.env62),$f7,$8b,$63,LOW(.env31),HIGH(.env31),$65,$81,$61,$0c,$38,$32,$91,$72,$61,$0c,$38,$32,$91 .ref35: .db $74,$9a,$3c,$3d,$9b,$61,$0f,$3d,$34,$91,$72,$61,$0f,$3d,$34,$91,$74,$3e,$3f,$9b,$61,$16,$3f,$32,$91,$72,$61,$16,$3f,$32,$91,$74,$40,$41,$42,$89,$63,LOW(.env62),HIGH(.env62),$9d,$63,LOW(.env31),HIGH(.env31),$65,$81 .ref36: .db $43,$44,$8d,$63,LOW(.env62),HIGH(.env62),$f7,$8b,$63,LOW(.env31),HIGH(.env31),$65,$81,$61,$0d,$44,$39,$91,$72,$61,$0d,$44,$39,$91 .ref37: .db $74,$98,$43,$44,$9b,$61,$0f,$44,$38,$91,$72,$61,$0f,$44,$38,$91,$74,$45,$46,$9b,$61,$14,$46,$36,$91,$72,$61,$14,$46,$36,$91,$74,$47,$48,$49,$87,$63,LOW(.env62),HIGH(.env62),$9f,$63,LOW(.env31),HIGH(.env31),$65,$81 .ref38: .db $4a,$4b,$8d,$63,LOW(.env62),HIGH(.env62),$f7,$8b,$63,LOW(.env31),HIGH(.env31),$65,$81,$61,$0c,$4b,$3d,$91,$72,$61,$0c,$4b,$3d,$91 .ref39: .db $00,$95 .ref40: .db $74,$46,$47,$97,$63,LOW(.env62),HIGH(.env62),$f7,$81,$63,LOW(.env31),HIGH(.env31),$65,$81,$61,$0c,$47,$3b,$91,$72,$61,$0c,$47,$3b,$91 .ref41: .db $74,$48,$49,$8d,$63,LOW(.env62),HIGH(.env62),$f7,$89,$63,LOW(.env31),HIGH(.env31),$65,$81,$61,$0b,$49,$3c,$93,$72,$61,$0c,$49,$3c,$91 .ref42: .db $7f,$ae,$2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 .ref43: .db $2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 .ref44: .db $7f,$2e,$85,$35,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$33,$85,$37,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$33,$85,$2e,$81,$37,$85,$33,$81,$2e,$85,$37,$81,$39,$85,$2e,$81,$35,$85,$39,$81,$3c,$85,$35,$81,$35,$85,$3c,$81 .db $ff,$40 .dw .ref43 .ref45: .db $70,$00,$95,$ac,$30,$83,$71,$85,$35,$89,$37,$89,$32,$72,$89,$33,$89,$35,$87,$73,$81,$2e,$89,$33,$89,$30,$83,$74,$85,$35,$89,$37,$89,$32,$75,$89,$33,$89,$35,$87,$76,$81 .ref46: .db $70,$00,$95,$3c,$83,$71,$85,$41,$89,$43,$89,$3e,$72,$89,$3f,$89,$41,$87,$73,$81,$3a,$89,$3f,$89,$3c,$83,$74,$85,$41,$89,$43,$89,$3e,$75,$89,$3f,$89,$41,$87,$76,$81 .ref47: .db $7f,$b0,$3e,$89,$3e,$89,$3e,$89,$3e,$9d,$00,$81,$3e,$89,$3f,$89,$41,$91,$00,$81,$3e,$89,$3f,$91,$00,$81,$3c,$89,$3e,$91,$00,$81 .ref48: .db $3a,$89,$3a,$89,$3a,$89,$3c,$89,$37,$89,$3c,$89,$3e,$89,$3f,$89,$43,$a9,$00,$81,$41,$a9,$00,$81 .ref49: .db $b2,$3e,$89,$3e,$89,$3e,$89,$3e,$9d,$00,$81,$3e,$89,$3f,$89,$41,$91,$00,$81,$3e,$89,$3f,$91,$00,$81,$3c,$89,$3e,$91,$00,$81 .db $ff,$18 .dw .ref48 .ref50: .db $b6,$43,$c1,$00,$81,$41,$89,$3f,$89,$3e,$c1,$00,$81,$3f,$89,$41,$89 .ref51: .db $3e,$c1,$00,$81,$3f,$89,$41,$89,$3c,$62,$3d,$81,$3e,$8b,$00,$81,$3d,$62,$3c,$62,$3b,$8d,$00,$81,$3a,$62,$39,$62,$38,$62,$37,$8b,$00,$81,$38,$62,$39,$62,$3a,$62,$3b,$62,$3c,$62,$3d,$62,$3e,$85,$00,$81 .ref52: .db $3f,$c1,$00,$81,$3e,$89,$3c,$89,$3e,$c1,$00,$81,$3c,$89,$37,$89 .ref53: .db $3a,$d9,$00,$81,$3c,$a9,$00,$81,$3e,$a9,$00,$81 .ref54: .db $b4,$2b,$c1,$00,$81,$29,$89,$27,$89,$26,$c1,$00,$81,$27,$89,$29,$89 .ref55: .db $26,$c1,$00,$81,$27,$89,$29,$89,$24,$62,$25,$81,$26,$8b,$00,$81,$25,$62,$24,$62,$23,$8d,$00,$81,$22,$62,$21,$62,$20,$62,$1f,$8b,$00,$81,$20,$62,$21,$62,$22,$62,$23,$62,$24,$62,$25,$62,$26,$85,$00,$81 .ref56: .db $27,$c1,$00,$81,$26,$89,$24,$89,$26,$c1,$00,$81,$24,$89,$1f,$89 .ref57: .db $22,$d9,$00,$81,$24,$a9,$00,$81,$26,$a9,$00,$81 .ref58: .db $b0,$37,$c1,$00,$81,$35,$89,$33,$89,$32,$c1,$00,$81,$33,$89,$35,$89 .ref59: .db $32,$c1,$00,$81,$33,$89,$35,$89,$30,$62,$31,$81,$32,$8b,$00,$81,$31,$62,$30,$62,$2f,$8d,$00,$81,$2e,$62,$2d,$62,$2c,$62,$2b,$8b,$00,$81,$2c,$62,$2d,$62,$2e,$62,$2f,$62,$30,$62,$31,$62,$32,$85,$00,$81 .ref60: .db $33,$c1,$00,$81,$32,$89,$30,$89,$32,$c1,$00,$81,$30,$89,$2b,$89 .ref61: .db $2e,$d9,$00,$81,$30,$a9,$00,$81,$32,$a9,$00,$81 .ref62: .db $73,$68,$00,$98,$37,$dd,$62,$61,$fe,$37,$60,$dd .ref63: .db $f7,$c5,$00 .ref64: .db $7f,$a2,$60,$dd,$60,$dd .ref65: .db $60,$dd,$60,$dd .ref66: .db $60,$f7,$c5 .ref67: .db $60,$dd,$60,$dd .ref68: .db $9e,$28,$95,$1c,$95,$28,$95,$1c,$95,$28,$95,$1c,$95,$28,$95,$1c,$95 .ref69: .db $26,$95,$a0,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89,$1c,$89,$1c,$89,$26,$89 .db $ff,$10 .dw .ref68 .db $ff,$1e .dw .ref69 .ref70: .db $9e,$2a,$95,$1e,$95,$2a,$95,$1e,$95,$2a,$95,$1e,$95,$2a,$95,$1e,$95 .ref71: .db $28,$95,$a0,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89,$1e,$89,$1e,$89,$28,$89 .db $ff,$10 .dw .ref70 .db $ff,$1e .dw .ref71 .ref72: .db $bc,$30,$89,$2d,$2b,$81,$f9,$81,$00,$2e,$30,$81,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$89,$34,$31,$30,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$83,$f9,$81,$00,$3a,$3c,$87,$39,$37,$81,$f9,$81,$00,$34,$83,$f9,$81,$00,$35,$89,$32,$83,$f9,$81,$00,$34,$83,$f9,$81,$00,$31,$30,$87,$2d,$2b,$81,$f9,$81,$00 .ref73: .db $2e,$95,$31,$32,$81,$f9,$81,$00,$30,$a1,$32,$a1,$34,$a1,$35,$95,$38,$39,$8d,$f9,$81,$00 .ref74: .db $36,$33,$62,$30,$f9,$81,$00,$2d,$2b,$81,$f9,$81,$00,$2e,$30,$81,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$89,$34,$31,$30,$f9,$81,$00,$33,$34,$81,$f9,$81,$00,$37,$83,$f9,$81,$00,$3a,$3c,$87,$39,$37,$81,$f9,$81,$00,$34,$83,$f9,$81,$00,$35,$89,$32,$83,$f9,$81,$00,$34,$83,$f9,$81,$00,$31,$30,$87,$2d,$2b,$81,$f9,$81,$00 .db $ff,$16 .dw .ref73 .ref75: .db $74,$98,$39,$36,$33,$31,$97,$61,$0f,$31,$2c,$91,$72,$61,$0f,$31,$2c,$91,$74,$31,$32,$9b,$61,$0e,$32,$2d,$91,$72,$61,$0e,$32,$2d,$91,$74,$32,$34,$9b,$61,$0f,$34,$2e,$8d .ref76: .db $83,$72,$61,$0f,$34,$2e,$91,$74,$34,$36,$9b,$61,$0e,$36,$30,$91,$72,$61,$0e,$36,$30,$91,$74,$36,$37,$9b,$61,$10,$37,$31,$8d,$37,$39,$9b,$61,$0e,$39,$33,$8d .ref77: .db $7f,$ba,$38,$95,$36,$34,$8d,$f9,$81,$00,$32,$31,$8d,$f9,$81,$00,$33,$35,$36,$91,$34,$95,$32,$31,$8d,$f9,$81,$00,$2f,$2d,$8d,$f9,$81,$00,$2f,$31,$8d,$f9,$81,$00 .ref78: .db $32,$95,$30,$2f,$93,$2d,$2b,$8d,$f9,$81,$00,$2d,$2f,$31,$33,$34,$8d,$32,$31,$93,$2f,$2d,$8d,$f9,$81,$00,$2f,$31,$33,$35,$36,$89,$f9,$81,$34,$32,$8f,$f9,$81 .ref79: .db $34,$36,$d7,$f9,$81,$38,$3a,$3b,$d5,$f9,$81 .ref80: .db $3d,$a9,$f9,$81,$3b,$39,$38,$a5,$f9,$81,$36,$a9,$f9,$81,$35,$a9,$f9,$81 .ref81: .db $36,$a9,$f9,$81,$34,$33,$a7,$f9,$81,$35,$37,$39,$3b,$a3,$f9,$81,$3d,$3f,$a7,$f9,$62,$3e .ref82: .db $3d,$d9,$f9,$81,$3f,$41,$d7,$f9,$81 .ref83: .db $74,$98,$36,$9d,$61,$0e,$36,$30,$91,$72,$61,$0e,$36,$30,$91,$74,$35,$9d,$61,$0e,$35,$2f,$91,$72,$61,$0e,$35,$2f,$91,$74,$31,$9d,$61,$0e,$31,$2d,$8d .ref84: .db $33,$dd,$35,$ad,$36,$ad .ref85: .db $38,$dd,$3a,$3c,$3e,$40,$41,$d5 .ref86: .db $81,$43,$44,$87,$42,$41,$87,$3f,$89,$3d,$3b,$87,$3a,$89,$38,$89,$36,$35,$87,$33,$89,$31,$2f,$87,$2e,$89,$2c,$89,$2a,$29,$87,$27,$89,$25,$23,$87,$22,$89,$20,$87 .db $ff,$03 .dw .ref31 .ref87: .db $f7,$af .db $fd .dw .song0ch1loop .song0ch2: .ref88: .db $f7,$c7 .ref89: .db $f7,$c0,$2e,$89,$2e,$89,$2e,$95 .song0ch2loop: .ref90: .db $be,$25,$89,$96,$19,$b9,$be,$25,$89,$96,$1b,$89,$00,$ad,$be,$25,$89,$96,$1e,$a1 .ref91: .db $be,$25,$89,$96,$20,$89,$1e,$89,$20,$89,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$20,$a9,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$20,$85,$c0,$2e,$81,$96,$20,$85,$c0,$2e,$81,$96,$20,$91 .db $ff,$0e .dw .ref90 .db $ff,$20 .dw .ref91 .db $ff,$0e .dw .ref90 .db $ff,$20 .dw .ref91 .ref92: .db $be,$25,$89,$96,$20,$89 .ref93: .db $be,$25,$89,$96,$1c,$89,$1a,$1b,$1c,$91,$c0,$2f,$81,$96,$23,$91,$1a,$1b,$1c,$91,$be,$25,$89,$96,$1c,$89,$1b,$1c,$87,$be,$25,$89,$96,$1c,$89,$1b,$1c,$87,$be,$25,$89,$96,$1b,$89 .ref94: .db $be,$25,$89,$96,$19,$89,$17,$18,$19,$91,$c0,$2c,$81,$96,$20,$91,$17,$18,$19,$91,$be,$25,$89,$96,$19,$89,$18,$19,$87,$be,$25,$89,$96,$19,$89,$18,$19,$87,$be,$25,$89,$96,$1b,$89 .ref95: .db $be,$25,$89,$96,$18,$85,$00,$81,$18,$91,$00,$81,$c0,$2e,$81,$96,$24,$85,$18,$85,$00,$81,$18,$89,$be,$25,$89,$96,$1d,$91,$00,$81,$be,$25,$89,$96,$1b,$89,$c0,$2e,$81,$96,$1a,$91,$1b,$89,$c0,$2e,$81,$96,$1b,$85 .ref96: .db $be,$25,$89,$96,$18,$85,$00,$81,$18,$91,$00,$81,$c0,$2e,$81,$96,$24,$85,$18,$85,$00,$81,$18,$89,$be,$25,$89,$96,$1d,$91,$00,$81,$be,$25,$89,$96,$1b,$89,$c0,$2e,$81,$96,$22,$85,$c0,$2e,$81,$96,$22,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .db $ff,$28 .dw .ref95 .db $ff,$2e .dw .ref96 .ref97: .db $be,$25,$f7,$c5 .ref98: .db $f7,$c7 .ref99: .db $25,$89,$00,$a1,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$a1,$2e,$89 .ref100: .db $be,$25,$ad,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$89,$2e,$89,$2e,$89,$2e,$89 .ref101: .db $be,$25,$ad,$c0,$2e,$a1,$be,$25,$a1,$25,$95,$c0,$2e,$a1,$2e,$89 .db $ff,$10 .dw .ref100 .db $ff,$0c .dw .ref101 .db $ff,$10 .dw .ref100 .db $ff,$0c .dw .ref101 .db $ff,$10 .dw .ref100 .db $ff,$0c .dw .ref101 .db $ff,$10 .dw .ref100 .ref102: .db $be,$25,$89,$96,$18,$a1,$c0,$2e,$81,$96,$18,$9d,$be,$25,$89,$96,$18,$95,$be,$25,$89,$96,$18,$89,$c0,$2e,$81,$96,$22,$85,$24,$89,$1f,$89,$c0,$2e,$81,$96,$1f,$85 .ref103: .db $be,$25,$89,$96,$18,$a1,$c0,$2e,$81,$96,$18,$9d,$be,$25,$89,$96,$18,$95,$be,$25,$89,$96,$18,$89,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85,$c0,$2e,$81,$96,$24,$85 .db $ff,$1c .dw .ref102 .db $ff,$20 .dw .ref103 .ref104: .db $be,$25,$89,$96,$15,$a1,$c0,$2e,$81,$96,$15,$9d,$be,$25,$89,$96,$15,$95,$be,$25,$89,$96,$15,$89,$c0,$2e,$81,$96,$1f,$85,$21,$89,$1c,$89,$c0,$2e,$81,$96,$1c,$85 .ref105: .db $be,$25,$89,$96,$15,$a1,$c0,$2e,$81,$96,$15,$9d,$be,$25,$89,$96,$15,$95,$be,$25,$89,$96,$15,$89,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85,$c0,$2e,$81,$96,$21,$85 .db $ff,$1c .dw .ref104 .db $ff,$20 .dw .ref105 .ref106: .db $be,$25,$89,$96,$1e,$a1,$c0,$2e,$81,$96,$1e,$9d,$be,$25,$89,$96,$1e,$95,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$28,$85,$2a,$89,$25,$89,$c0,$2e,$81,$96,$25,$85 .ref107: .db $be,$25,$89,$96,$1e,$a1,$c0,$2e,$81,$96,$1e,$9d,$be,$25,$89,$96,$1e,$95,$be,$25,$89,$96,$1e,$89,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85,$c0,$2e,$81,$96,$2a,$85 .db $ff,$1c .dw .ref106 .db $ff,$20 .dw .ref107 .db $ff,$1c .dw .ref106 .db $ff,$20 .dw .ref107 .ref108: .db $be,$25,$89,$96,$1d,$a1,$c0,$2e,$81,$96,$1d,$9d,$be,$25,$89,$96,$1d,$95,$be,$25,$89,$96,$1d,$89,$c0,$2e,$81,$96,$27,$85,$29,$89,$24,$89,$c0,$2e,$81,$96,$24,$85 .ref109: .db $be,$25,$89,$96,$1d,$a1,$c0,$2e,$81,$96,$1d,$9d,$be,$25,$89,$96,$1d,$95,$be,$25,$89,$96,$1d,$89,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85,$c0,$2e,$81,$96,$29,$85 .ref110: .db $be,$25,$89,$96,$1b,$89,$00,$f7,$ad .db $ff,$07 .dw .ref89 .db $fd .dw .song0ch2loop .song0ch3: .ref111: .db $73,$92,$2c,$ab,$72,$99,$71,$99,$00,$db .ref112: .db $71,$94,$23,$89,$24,$83,$72,$85,$25,$89,$26,$73,$89,$27,$87,$74,$81,$28,$89,$29,$83,$75,$85,$2a,$89,$2b,$89,$2c,$87,$77,$81,$7f,$90,$26,$89,$26,$89,$26,$95 .song0ch3loop: .ref113: .db $88,$25,$c1,$f9,$81,$25,$c1,$f9,$81,$25,$a9,$f9,$81 .ref114: .db $25,$95,$84,$2b,$89,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$95,$84,$2b,$89,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$89,$26,$89,$26,$95 .db $ff,$0c .dw .ref113 .db $ff,$1a .dw .ref114 .db $ff,$0c .dw .ref113 .db $ff,$1a .dw .ref114 .ref115: .db $8a,$27,$95 .ref116: .db $8c,$29,$95,$8e,$2b,$95,$90,$26,$95,$8e,$2b,$95,$8c,$29,$a1,$29,$a1,$29,$95 .ref117: .db $29,$95,$8e,$2b,$95,$90,$26,$95,$8e,$2b,$95,$8c,$29,$a1,$29,$a1,$29,$95 .ref118: .db $7f,$80,$27,$95,$86,$2b,$95,$90,$26,$95,$86,$2b,$89,$82,$27,$89,$86,$2b,$89,$84,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$95,$84,$2b,$89,$90,$26,$89 .ref119: .db $80,$27,$95,$86,$2b,$95,$90,$26,$95,$86,$2b,$89,$82,$27,$89,$86,$2b,$89,$84,$2b,$89,$82,$27,$89,$84,$2b,$89,$90,$26,$89,$26,$89,$26,$89,$26,$89 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .ref120: .db $75,$96,$27,$74,$22,$9b,$73,$9f,$72,$9f,$71,$9f,$00,$bd .ref121: .db $f7,$8b,$71,$22,$83,$23,$72,$83,$24,$83,$73,$25,$83,$26,$81,$74,$81,$27,$83,$28,$75,$83,$29,$83,$76,$2a,$83,$2b,$81,$77,$81 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$18 .dw .ref118 .db $ff,$1a .dw .ref119 .db $ff,$06 .dw .ref111 .db $ff,$1e .dw .ref112 .db $fd .dw .song0ch3loop .song0ch4: .ref122: .db $f7,$c7 .ref123: .db $f7,$af .song0ch4loop: .ref124: .db $f7,$c7 .ref125: .db $f7,$c7 .ref126: .db $f7,$c7 .ref127: .db $f7,$c7 .ref128: .db $f7,$c7 .ref129: .db $f7,$c7 .ref130: .db $97 .ref131: .db $f7,$c7 .ref132: .db $f7,$c7 .ref133: .db $f7,$c7 .ref134: .db $f7,$c7 .ref135: .db $f7,$c7 .ref136: .db $f7,$c7 .ref137: .db $f7,$c7 .ref138: .db $f7,$c7 .ref139: .db $f7,$c7 .ref140: .db $f7,$c7 .ref141: .db $f7,$c7 .ref142: .db $f7,$c7 .ref143: .db $f7,$c7 .ref144: .db $f7,$c7 .ref145: .db $f7,$c7 .ref146: .db $f7,$c7 .ref147: .db $f7,$c7 .ref148: .db $f7,$c7 .ref149: .db $f7,$c7 .ref150: .db $f7,$c7 .ref151: .db $f7,$c7 .ref152: .db $f7,$c7 .ref153: .db $f7,$c7 .ref154: .db $f7,$c7 .ref155: .db $f7,$c7 .ref156: .db $f7,$c7 .ref157: .db $f7,$c7 .ref158: .db $f7,$c7 .ref159: .db $f7,$c7 .ref160: .db $f7,$c7 .ref161: .db $f7,$c7 .ref162: .db $f7,$c7 .ref163: .db $f7,$c7 .ref164: .db $f7,$c7 .ref165: .db $f7,$c7 .ref166: .db $f7,$c7 .ref167: .db $f7,$c7 .ref168: .db $f7,$c7 .ref169: .db $f7,$c7 .ref170: .db $f7,$c7 .ref171: .db $f7,$c7 .ref172: .db $f7,$c7 .ref173: .db $f7,$c7 .ref174: .db $f7,$c7 .ref175: .db $f7,$c7 .ref176: .db $f7,$c7 .ref177: .db $f7,$c7 .ref178: .db $f7,$c7 .ref179: .db $f7,$c7 .ref180: .db $f7,$c7 .ref181: .db $f7,$c7 .ref182: .db $f7,$c7 .ref183: .db $f7,$c7 .ref184: .db $f7,$c7 .ref185: .db $f7,$c7 .ref186: .db $f7,$af .db $fd .dw .song0ch4loop ",16321,True,3947.408973654952,median "Dump of assembler code from 0x555555555faf to 0x555555557008: => 0x0000555555555faf: push rbp 0x0000555555555fb0: mov rbp,rsp 0x0000555555555fb3: sub rsp,0xd0 0x0000555555555fba: mov DWORD PTR [rbp-0xc4],edi 0x0000555555555fc0: mov QWORD PTR [rbp-0xd0],rsi 0x0000555555555fc7: mov ecx,0x0 0x0000555555555fcc: mov edx,0x1 0x0000555555555fd1: mov esi,0x0 0x0000555555555fd6: mov edi,0x0 0x0000555555555fdb: mov eax,0x0 0x0000555555555fe0: call 0x5555555550f0 0x0000555555555fe5: mov DWORD PTR [rbp-0xc],eax 0x0000555555555fe8: lea rdi,[rip+0x103a] # 0x555555557029 0x0000555555555fef: mov eax,0x0 0x0000555555555ff4: call 0x555555555080 0x0000555555555ff9: mov rax,QWORD PTR [rip+0x3150] # 0x555555559150 0x0000555555556000: mov rdi,rax 0x0000555555556003: call 0x5555555550d0 0x0000555555556008: mov DWORD PTR [rbp-0x4],0x0 0x000055555555600f: jmp 0x55555555603d 0x0000555555556011: mov edi,0x1 0x0000555555556016: mov eax,0x0 0x000055555555601b: call 0x555555555170 0x0000555555556020: mov edi,0x2e 0x0000555555556025: call 0x555555555040 0x000055555555602a: mov rax,QWORD PTR [rip+0x311f] # 0x555555559150 0x0000555555556031: mov rdi,rax 0x0000555555556034: call 0x5555555550d0 0x0000555555556039: add DWORD PTR [rbp-0x4],0x1 0x000055555555603d: cmp DWORD PTR [rbp-0x4],0x4 0x0000555555556041: jle 0x555555556011 0x0000555555556043: mov edi,0xa 0x0000555555556048: call 0x555555555040 0x000055555555604d: lea rdi,[rip+0xfe2] # 0x555555557036 0x0000555555556054: mov eax,0x0 0x0000555555556059: call 0x555555555080 0x000055555555605e: mov rdx,QWORD PTR [rip+0x30fb] # 0x555555559160 0x0000555555556065: lea rax,[rbp-0x40] 0x0000555555556069: mov esi,0x1e 0x000055555555606e: mov rdi,rax 0x0000555555556071: call 0x5555555550a0 0x0000555555556076: lea rax,[rbp-0x40] 0x000055555555607a: lea rsi,[rip+0xfc5] # 0x555555557046 0x0000555555556081: mov rdi,rax 0x0000555555556084: call 0x555555555130 0x0000555555556089: mov BYTE PTR [rbp-0x60],0x48 0x000055555555608d: mov BYTE PTR [rbp-0x5f],0x54 0x0000555555556091: mov BYTE PTR [rbp-0x5e],0x42 0x0000555555556095: mov BYTE PTR [rbp-0x5d],0x7b 0x0000555555556099: mov BYTE PTR [rbp-0x5c],0x77 0x000055555555609d: mov BYTE PTR [rbp-0x5b],0x30 0x00005555555560a1: mov BYTE PTR [rbp-0x5a],0x77 0x00005555555560a5: mov BYTE PTR [rbp-0x59],0x5f 0x00005555555560a9: mov BYTE PTR [rbp-0x58],0x74 0x00005555555560ad: mov BYTE PTR [rbp-0x57],0x68 0x00005555555560b1: mov BYTE PTR [rbp-0x56],0x34 0x00005555555560b5: mov BYTE PTR [rbp-0x55],0x74 0x00005555555560b9: mov BYTE PTR [rbp-0x54],0x73 0x00005555555560bd: mov BYTE PTR [rbp-0x53],0x5f 0x00005555555560c1: mov BYTE PTR [rbp-0x52],0x63 0x00005555555560c5: mov BYTE PTR [rbp-0x51],0x30 0x00005555555560c9: mov BYTE PTR [rbp-0x50],0x30 0x00005555555560cd: mov BYTE PTR [rbp-0x4f],0x30 0x00005555555560d1: mov BYTE PTR [rbp-0x4e],0x6c 0x00005555555560d5: mov BYTE PTR [rbp-0x4d],0x7d 0x00005555555560d9: lea rax,[rbp-0x40] 0x00005555555560dd: mov rdi,rax 0x00005555555560e0: call 0x555555555060 0x00005555555560e5: cmp rax,0x14 0x00005555555560e9: je 0x555555556101 0x00005555555560eb: lea rdi,[rip+0xf56] # 0x555555557048 0x00005555555560f2: call 0x555555555050 0x00005555555560f7: mov edi,0x1 0x00005555555560fc: call 0x555555555150 0x0000555555556101: movabs rax,0x6f52336543524653 0x000055555555610b: movabs rdx,0x664e584d664e584d 0x0000555555556115: mov QWORD PTR [rbp-0x80],rax 0x0000555555556119: mov QWORD PTR [rbp-0x78],rdx 0x000055555555611d: movabs rax,0x735a32587a674764 0x0000555555556127: mov QWORD PTR [rbp-0x70],rax 0x000055555555612b: mov DWORD PTR [rbp-0x68],0x3964474e 0x0000555555556132: mov BYTE PTR [rbp-0x64],0x0 0x0000555555556136: lea rax,[rbp-0x80] 0x000055555555613a: mov edx,0xa 0x000055555555613f: mov esi,0xa 0x0000555555556144: mov rdi,rax 0x0000555555556147: call 0x5555555557e2 0x000055555555614c: movabs rax,0x155509151a233529 0x0000555555556156: movabs rdx,0x1355093e1255163e 0x0000555555556160: mov QWORD PTR [rbp-0xa0],rax 0x0000555555556167: mov QWORD PTR [rbp-0x98],rdx 0x000055555555616e: mov WORD PTR [rbp-0x90],0x1c05 0x0000555555556177: mov BYTE PTR [rbp-0x8e],0x0 0x000055555555617e: lea rax,[rbp-0xa0] 0x0000555555556185: mov rdi,rax 0x0000555555556188: call 0x555555555542 0x000055555555618d: mov eax,DWORD PTR [rbp-0xc4] 0x0000555555556193: add eax,0x2 0x0000555555556196: imul eax,eax,0x64 0x0000555555556199: cmp eax,0x64 0x000055555555619c: jne 0x5555555561e1 0x000055555555619e: lea rdx,[rbp-0x60] 0x00005555555561a2: lea rax,[rbp-0x40] 0x00005555555561a6: mov rsi,rdx 0x00005555555561a9: mov rdi,rax 0x00005555555561ac: call 0x5555555550b0 0x00005555555561b1: test eax,eax 0x00005555555561b3: jne 0x5555555561cb 0x00005555555561b5: lea rdi,[rip+0xe9a] # 0x555555557056 0x00005555555561bc: call 0x555555555050 0x00005555555561c1: mov edi,0x0 0x00005555555561c6: call 0x555555555150 0x00005555555561cb: lea rdi,[rip+0xe76] # 0x555555557048 0x00005555555561d2: call 0x555555555050 0x00005555555561d7: mov edi,0x1 0x00005555555561dc: call 0x555555555150 0x00005555555561e1: mov eax,DWORD PTR [rbp-0xc4] 0x00005555555561e7: mov DWORD PTR [rbp-0x10],eax 0x00005555555561ea: mov eax,DWORD PTR [rbp-0xc4] 0x00005555555561f0: add eax,0x2 0x00005555555561f3: imul eax,eax,0x64 0x00005555555561f6: cmp eax,0x64 0x00005555555561f9: jne 0x55555555620d 0x00005555555561fb: mov QWORD PTR [rbp-0x18],0x0 0x0000555555556203: mov rax,QWORD PTR [rbp-0x18] 0x0000555555556207: mov DWORD PTR [rax],0x853 0x000055555555620d: mov BYTE PTR [rbp-0xc0],0x7 0x0000555555556214: mov BYTE PTR [rbp-0xbf],0xfe 0x000055555555621b: mov BYTE PTR [rbp-0xbe],0x8d 0x0000555555556222: mov BYTE PTR [rbp-0xbd],0xd 0x0000555555556229: mov BYTE PTR [rbp-0xbc],0xd2 0x0000555555556230: mov BYTE PTR [rbp-0xbb],0xe4 0x0000555555556237: mov BYTE PTR [rbp-0xba],0xfe 0x000055555555623e: mov BYTE PTR [rbp-0xb9],0x8 0x0000555555556245: mov BYTE PTR [rbp-0xb8],0xef 0x000055555555624c: mov BYTE PTR [rbp-0xb7],0x57 0x0000555555556253: mov BYTE PTR [rbp-0xb6],0x47 0x000055555555625a: mov BYTE PTR [rbp-0xb5],0xdb 0x0000555555556261: mov BYTE PTR [rbp-0xb4],0x4d 0x0000555555556268: mov BYTE PTR [rbp-0xb3],0x96 0x000055555555626f: mov BYTE PTR [rbp-0xb2],0x2f 0x0000555555556276: mov BYTE PTR [rbp-0xb1],0x3b 0x000055555555627d: mov BYTE PTR [rbp-0xb0],0xa8 0x0000555555556284: mov BYTE PTR [rbp-0xaf],0xbb 0x000055555555628b: mov BYTE PTR [rbp-0xae],0x70 0x0000555555556292: mov BYTE PTR [rbp-0xad],0x11 0x0000555555556299: mov BYTE PTR [rbp-0xac],0xad 0x00005555555562a0: mov DWORD PTR [rbp-0x8],0x0 0x00005555555562a7: jmp 0x555555556664 0x00005555555562ac: mov eax,DWORD PTR [rbp-0x8] 0x00005555555562af: movzx eax,BYTE PTR [rbp+rax*1-0xc0] 0x00005555555562b7: mov BYTE PTR [rbp-0x19],al 0x00005555555562ba: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555562be: shr al,0x5 0x00005555555562c1: mov edx,eax 0x00005555555562c3: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555562c7: shl eax,0x3 0x00005555555562ca: or eax,edx 0x00005555555562cc: mov BYTE PTR [rbp-0x19],al 0x00005555555562cf: not BYTE PTR [rbp-0x19] 0x00005555555562d2: add BYTE PTR [rbp-0x19],0x2f 0x00005555555562d6: xor BYTE PTR [rbp-0x19],0x26 0x00005555555562da: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555562de: shr al,0x5 0x00005555555562e1: mov edx,eax 0x00005555555562e3: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555562e7: shl eax,0x3 0x00005555555562ea: or eax,edx 0x00005555555562ec: mov BYTE PTR [rbp-0x19],al 0x00005555555562ef: sub BYTE PTR [rbp-0x19],0x2 0x00005555555562f3: neg BYTE PTR [rbp-0x19] 0x00005555555562f6: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555562fa: shr al,0x2 0x00005555555562fd: mov edx,eax 0x00005555555562ff: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556303: shl eax,0x6 0x0000555555556306: or eax,edx 0x0000555555556308: mov BYTE PTR [rbp-0x19],al 0x000055555555630b: not BYTE PTR [rbp-0x19] 0x000055555555630e: add BYTE PTR [rbp-0x19],0x47 0x0000555555556312: not BYTE PTR [rbp-0x19] 0x0000555555556315: xor BYTE PTR [rbp-0x19],0x43 0x0000555555556319: sub BYTE PTR [rbp-0x19],0x7b 0x000055555555631d: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556321: shr al,0x5 0x0000555555556324: mov edx,eax 0x0000555555556326: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555632a: shl eax,0x3 0x000055555555632d: or eax,edx 0x000055555555632f: mov BYTE PTR [rbp-0x19],al 0x0000555555556332: not BYTE PTR [rbp-0x19] 0x0000555555556335: add BYTE PTR [rbp-0x19],0x51 0x0000555555556339: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555633d: shr al,0x3 0x0000555555556340: mov edx,eax 0x0000555555556342: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556346: shl eax,0x5 0x0000555555556349: or eax,edx 0x000055555555634b: mov BYTE PTR [rbp-0x19],al 0x000055555555634e: add BYTE PTR [rbp-0x19],0x74 0x0000555555556352: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556356: shr al,0x2 0x0000555555556359: mov edx,eax 0x000055555555635b: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555635f: shl eax,0x6 0x0000555555556362: or eax,edx 0x0000555555556364: mov BYTE PTR [rbp-0x19],al 0x0000555555556367: sub BYTE PTR [rbp-0x19],0x26 0x000055555555636b: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555636f: shr al,0x6 0x0000555555556372: mov edx,eax 0x0000555555556374: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556378: shl eax,0x2 0x000055555555637b: or eax,edx 0x000055555555637d: mov BYTE PTR [rbp-0x19],al 0x0000555555556380: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556383: add BYTE PTR [rbp-0x19],al 0x0000555555556386: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556389: xor BYTE PTR [rbp-0x19],al 0x000055555555638c: neg BYTE PTR [rbp-0x19] 0x000055555555638f: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556392: xor BYTE PTR [rbp-0x19],al 0x0000555555556395: add BYTE PTR [rbp-0x19],0x79 0x0000555555556399: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555639d: shr al,0x7 0x00005555555563a0: mov edx,eax 0x00005555555563a2: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555563a6: add eax,eax 0x00005555555563a8: or eax,edx 0x00005555555563aa: mov BYTE PTR [rbp-0x19],al 0x00005555555563ad: sub BYTE PTR [rbp-0x19],0x49 0x00005555555563b1: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563b4: xor BYTE PTR [rbp-0x19],al 0x00005555555563b7: sub BYTE PTR [rbp-0x19],0x75 0x00005555555563bb: not BYTE PTR [rbp-0x19] 0x00005555555563be: add BYTE PTR [rbp-0x19],0x65 0x00005555555563c2: neg BYTE PTR [rbp-0x19] 0x00005555555563c5: add BYTE PTR [rbp-0x19],0x8 0x00005555555563c9: not BYTE PTR [rbp-0x19] 0x00005555555563cc: neg BYTE PTR [rbp-0x19] 0x00005555555563cf: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563d2: xor BYTE PTR [rbp-0x19],al 0x00005555555563d5: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563d8: sub BYTE PTR [rbp-0x19],al 0x00005555555563db: not BYTE PTR [rbp-0x19] 0x00005555555563de: add BYTE PTR [rbp-0x19],0x61 0x00005555555563e2: xor BYTE PTR [rbp-0x19],0x81 0x00005555555563e6: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563e9: sub BYTE PTR [rbp-0x19],al 0x00005555555563ec: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563ef: xor BYTE PTR [rbp-0x19],al 0x00005555555563f2: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563f5: add BYTE PTR [rbp-0x19],al 0x00005555555563f8: not BYTE PTR [rbp-0x19] 0x00005555555563fb: mov eax,DWORD PTR [rbp-0x8] 0x00005555555563fe: add BYTE PTR [rbp-0x19],al 0x0000555555556401: neg BYTE PTR [rbp-0x19] 0x0000555555556404: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556407: add BYTE PTR [rbp-0x19],al 0x000055555555640a: not BYTE PTR [rbp-0x19] 0x000055555555640d: sub BYTE PTR [rbp-0x19],0x5 0x0000555555556411: neg BYTE PTR [rbp-0x19] 0x0000555555556414: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556417: xor BYTE PTR [rbp-0x19],al 0x000055555555641a: neg BYTE PTR [rbp-0x19] 0x000055555555641d: xor BYTE PTR [rbp-0x19],0x15 0x0000555555556421: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556424: add BYTE PTR [rbp-0x19],al 0x0000555555556427: neg BYTE PTR [rbp-0x19] 0x000055555555642a: mov eax,DWORD PTR [rbp-0x8] 0x000055555555642d: sub BYTE PTR [rbp-0x19],al 0x0000555555556430: xor BYTE PTR [rbp-0x19],0x22 0x0000555555556434: add BYTE PTR [rbp-0x19],0x72 0x0000555555556438: not BYTE PTR [rbp-0x19] 0x000055555555643b: neg BYTE PTR [rbp-0x19] 0x000055555555643e: sub BYTE PTR [rbp-0x19],0x66 0x0000555555556442: xor BYTE PTR [rbp-0x19],0x61 0x0000555555556446: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556449: sub BYTE PTR [rbp-0x19],al 0x000055555555644c: xor BYTE PTR [rbp-0x19],0x2c 0x0000555555556450: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556453: add BYTE PTR [rbp-0x19],al 0x0000555555556456: xor BYTE PTR [rbp-0x19],0x1 0x000055555555645a: sub BYTE PTR [rbp-0x19],0x4d 0x000055555555645e: not BYTE PTR [rbp-0x19] 0x0000555555556461: xor BYTE PTR [rbp-0x19],0x3c 0x0000555555556465: neg BYTE PTR [rbp-0x19] 0x0000555555556468: xor BYTE PTR [rbp-0x19],0x19 0x000055555555646c: not BYTE PTR [rbp-0x19] 0x000055555555646f: add BYTE PTR [rbp-0x19],0x71 0x0000555555556473: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556477: shr al,0x7 0x000055555555647a: mov edx,eax 0x000055555555647c: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556480: add eax,eax 0x0000555555556482: or eax,edx 0x0000555555556484: mov BYTE PTR [rbp-0x19],al 0x0000555555556487: mov eax,DWORD PTR [rbp-0x8] 0x000055555555648a: add BYTE PTR [rbp-0x19],al 0x000055555555648d: xor BYTE PTR [rbp-0x19],0x40 0x0000555555556491: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556495: shr al,0x7 0x0000555555556498: mov edx,eax 0x000055555555649a: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555649e: add eax,eax 0x00005555555564a0: or eax,edx 0x00005555555564a2: mov BYTE PTR [rbp-0x19],al 0x00005555555564a5: add BYTE PTR [rbp-0x19],0x5c 0x00005555555564a9: xor BYTE PTR [rbp-0x19],0x6d 0x00005555555564ad: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555564b1: shr al,0x6 0x00005555555564b4: mov edx,eax 0x00005555555564b6: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555564ba: shl eax,0x2 0x00005555555564bd: or eax,edx 0x00005555555564bf: mov BYTE PTR [rbp-0x19],al 0x00005555555564c2: neg BYTE PTR [rbp-0x19] 0x00005555555564c5: mov eax,DWORD PTR [rbp-0x8] 0x00005555555564c8: xor BYTE PTR [rbp-0x19],al 0x00005555555564cb: mov eax,DWORD PTR [rbp-0x8] 0x00005555555564ce: add BYTE PTR [rbp-0x19],al 0x00005555555564d1: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555564d5: shr al,0x5 0x00005555555564d8: mov edx,eax 0x00005555555564da: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555564de: shl eax,0x3 0x00005555555564e1: or eax,edx 0x00005555555564e3: mov BYTE PTR [rbp-0x19],al 0x00005555555564e6: sub BYTE PTR [rbp-0x19],0x1b 0x00005555555564ea: not BYTE PTR [rbp-0x19] 0x00005555555564ed: neg BYTE PTR [rbp-0x19] 0x00005555555564f0: mov eax,DWORD PTR [rbp-0x8] 0x00005555555564f3: sub BYTE PTR [rbp-0x19],al 0x00005555555564f6: not BYTE PTR [rbp-0x19] 0x00005555555564f9: mov eax,DWORD PTR [rbp-0x8] 0x00005555555564fc: add BYTE PTR [rbp-0x19],al 0x00005555555564ff: not BYTE PTR [rbp-0x19] 0x0000555555556502: xor BYTE PTR [rbp-0x19],0x37 0x0000555555556506: sub BYTE PTR [rbp-0x19],0x16 0x000055555555650a: neg BYTE PTR [rbp-0x19] 0x000055555555650d: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556510: sub BYTE PTR [rbp-0x19],al 0x0000555555556513: neg BYTE PTR [rbp-0x19] 0x0000555555556516: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556519: xor BYTE PTR [rbp-0x19],al 0x000055555555651c: add BYTE PTR [rbp-0x19],0x63 0x0000555555556520: xor BYTE PTR [rbp-0x19],0xd9 0x0000555555556524: not BYTE PTR [rbp-0x19] 0x0000555555556527: xor BYTE PTR [rbp-0x19],0x3f 0x000055555555652b: not BYTE PTR [rbp-0x19] 0x000055555555652e: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556531: add BYTE PTR [rbp-0x19],al 0x0000555555556534: xor BYTE PTR [rbp-0x19],0x39 0x0000555555556538: mov eax,DWORD PTR [rbp-0x8] 0x000055555555653b: sub BYTE PTR [rbp-0x19],al 0x000055555555653e: not BYTE PTR [rbp-0x19] 0x0000555555556541: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556544: sub BYTE PTR [rbp-0x19],al 0x0000555555556547: neg BYTE PTR [rbp-0x19] 0x000055555555654a: not BYTE PTR [rbp-0x19] 0x000055555555654d: sub BYTE PTR [rbp-0x19],0x48 0x0000555555556551: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556555: shr al,1 0x0000555555556557: mov edx,eax 0x0000555555556559: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555655d: shl eax,0x7 0x0000555555556560: or eax,edx 0x0000555555556562: mov BYTE PTR [rbp-0x19],al 0x0000555555556565: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556568: xor BYTE PTR [rbp-0x19],al 0x000055555555656b: neg BYTE PTR [rbp-0x19] 0x000055555555656e: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556571: xor BYTE PTR [rbp-0x19],al 0x0000555555556574: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556577: add BYTE PTR [rbp-0x19],al 0x000055555555657a: not BYTE PTR [rbp-0x19] 0x000055555555657d: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556580: add BYTE PTR [rbp-0x19],al 0x0000555555556583: xor BYTE PTR [rbp-0x19],0x58 0x0000555555556587: add BYTE PTR [rbp-0x19],0x63 0x000055555555658b: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555658f: shr al,0x2 0x0000555555556592: mov edx,eax 0x0000555555556594: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556598: shl eax,0x6 0x000055555555659b: or eax,edx 0x000055555555659d: mov BYTE PTR [rbp-0x19],al 0x00005555555565a0: neg BYTE PTR [rbp-0x19] 0x00005555555565a3: add BYTE PTR [rbp-0x19],0xa 0x00005555555565a7: not BYTE PTR [rbp-0x19] 0x00005555555565aa: mov eax,DWORD PTR [rbp-0x8] 0x00005555555565ad: sub BYTE PTR [rbp-0x19],al 0x00005555555565b0: not BYTE PTR [rbp-0x19] 0x00005555555565b3: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555565b7: shr al,0x3 0x00005555555565ba: mov edx,eax 0x00005555555565bc: movzx eax,BYTE PTR [rbp-0x19] 0x00005555555565c0: shl eax,0x5 0x00005555555565c3: or eax,edx 0x00005555555565c5: mov BYTE PTR [rbp-0x19],al 0x00005555555565c8: mov eax,DWORD PTR [rbp-0x8] 0x00005555555565cb: xor BYTE PTR [rbp-0x19],al 0x00005555555565ce: mov eax,DWORD PTR [rbp-0x8] 0x00005555555565d1: add BYTE PTR [rbp-0x19],al 0x00005555555565d4: neg BYTE PTR [rbp-0x19] 0x00005555555565d7: sub BYTE PTR [rbp-0x19],0x78 0x00005555555565db: not BYTE PTR [rbp-0x19] 0x00005555555565de: xor BYTE PTR [rbp-0x19],0x59 0x00005555555565e2: neg BYTE PTR [rbp-0x19] 0x00005555555565e5: not BYTE PTR [rbp-0x19] 0x00005555555565e8: add BYTE PTR [rbp-0x19],0x2a 0x00005555555565ec: neg BYTE PTR [rbp-0x19] 0x00005555555565ef: mov eax,DWORD PTR [rbp-0x8] 0x00005555555565f2: add BYTE PTR [rbp-0x19],al 0x00005555555565f5: xor BYTE PTR [rbp-0x19],0x15 0x00005555555565f9: sub BYTE PTR [rbp-0x19],0x2f 0x00005555555565fd: not BYTE PTR [rbp-0x19] 0x0000555555556600: add BYTE PTR [rbp-0x19],0x1e 0x0000555555556604: xor BYTE PTR [rbp-0x19],0x17 0x0000555555556608: mov eax,DWORD PTR [rbp-0x8] 0x000055555555660b: sub BYTE PTR [rbp-0x19],al 0x000055555555660e: not BYTE PTR [rbp-0x19] 0x0000555555556611: sub BYTE PTR [rbp-0x19],0x1e 0x0000555555556615: mov eax,DWORD PTR [rbp-0x8] 0x0000555555556618: xor BYTE PTR [rbp-0x19],al 0x000055555555661b: movzx eax,BYTE PTR [rbp-0x19] 0x000055555555661f: shr al,0x6 0x0000555555556622: mov edx,eax 0x0000555555556624: movzx eax,BYTE PTR [rbp-0x19] 0x0000555555556628: shl eax,0x2 0x000055555555662b: or eax,edx 0x000055555555662d: mov BYTE PTR [rbp-0x19],al 0x0000555555556630: sub BYTE PTR [rbp-0x19],0x46 0x0000555555556634: neg BYTE PTR [rbp-0x19] 0x0000555555556637: movzx edx,BYTE PTR [rbp-0x19] 0x000055555555663b: mov eax,DWORD PTR [rbp-0x8] 0x000055555555663e: movzx eax,BYTE PTR [rbp+rax*1-0x40] 0x0000555555556643: movsx eax,al 0x0000555555556646: cmp edx,eax 0x0000555555556648: je 0x555555556660 0x000055555555664a: lea rdi,[rip+0x9f7] # 0x555555557048 0x0000555555556651: call 0x555555555050 0x0000555555556656: mov edi,0x1 0x000055555555665b: call 0x555555555150 0x0000555555556660: add DWORD PTR [rbp-0x8],0x1 0x0000555555556664: cmp DWORD PTR [rbp-0x8],0x14 0x0000555555556668: jbe 0x5555555562ac 0x000055555555666e: lea rdi,[rip+0x9e1] # 0x555555557056 0x0000555555556675: call 0x555555555050 0x000055555555667a: mov edi,0x0 0x000055555555667f: call 0x555555555150 0x0000555555556684: ins BYTE PTR es:[rdi],dx 0x0000555555556685: sub al,0xe8 0x0000555555556687: fdivr st(1),st 0x0000555555556689: movabs al,gs:0xc4834808ec834800 0x0000555555556693: or bl,al 0x0000555555556695: add BYTE PTR [rax],al End of assembler dump. ",16152,True,5520.491015218171,median "export UI_ParseInfos code proc UI_ParseInfos 2084 12 ADDRFP4 4 ADDRFP4 4 INDIRI4 ASGNI4 ADDRFP4 8 ADDRFP4 8 INDIRP4 ASGNP4 ADDRLP4 2052 CNSTI4 0 ASGNI4 ADDRGP4 $90 JUMPV LABELV $89 ADDRFP4 0 ARGP4 ADDRLP4 2056 ADDRGP4 COM_Parse CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 2056 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $92 ADDRGP4 $91 JUMPV LABELV $92 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $96 ARGP4 ADDRLP4 2060 ADDRGP4 qk_strcmp CALLI4 ASGNI4 ADDRLP4 2060 INDIRI4 CNSTI4 0 EQI4 $94 ADDRGP4 $97 ARGP4 ADDRGP4 Com_Printf CALLV pop ADDRGP4 $91 JUMPV LABELV $94 ADDRLP4 2052 INDIRI4 ADDRFP4 4 INDIRI4 NEI4 $98 ADDRGP4 $100 ARGP4 ADDRGP4 Com_Printf CALLV pop ADDRGP4 $91 JUMPV LABELV $98 ADDRLP4 1028 CNSTI1 0 ASGNI1 ADDRGP4 $102 JUMPV LABELV $101 ADDRFP4 0 ARGP4 CNSTI4 1 ARGI4 ADDRLP4 2064 ADDRGP4 COM_ParseExt CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 2064 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $104 ADDRGP4 $106 ARGP4 ADDRGP4 Com_Printf CALLV pop ADDRGP4 $103 JUMPV LABELV $104 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $109 ARGP4 ADDRLP4 2068 ADDRGP4 qk_strcmp CALLI4 ASGNI4 ADDRLP4 2068 INDIRI4 CNSTI4 0 NEI4 $107 ADDRGP4 $103 JUMPV LABELV $107 ADDRLP4 4 ARGP4 ADDRLP4 0 INDIRP4 ARGP4 CNSTI4 1024 ARGI4 ADDRGP4 Q_strncpyz CALLV pop ADDRFP4 0 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 2072 ADDRGP4 COM_ParseExt CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 2072 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 NEI4 $110 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $112 ARGP4 ADDRGP4 qk_strcpy CALLP4 pop LABELV $110 ADDRLP4 1028 ARGP4 ADDRLP4 4 ARGP4 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 Info_SetValueForKey CALLV pop LABELV $102 ADDRGP4 $101 JUMPV LABELV $103 ADDRLP4 1028 ARGP4 ADDRLP4 2064 ADDRGP4 qk_strlen CALLU4 ASGNU4 ADDRGP4 $113 ARGP4 ADDRLP4 2068 ADDRGP4 qk_strlen CALLU4 ASGNU4 ADDRGP4 $114 ARGP4 CNSTI4 1024 ARGI4 ADDRLP4 2072 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 2072 INDIRP4 ARGP4 ADDRLP4 2076 ADDRGP4 qk_strlen CALLU4 ASGNU4 ADDRLP4 2064 INDIRU4 ADDRLP4 2068 INDIRU4 ADDU4 ADDRLP4 2076 INDIRU4 ADDU4 CNSTU4 1 ADDU4 CVUI4 4 ARGI4 ADDRLP4 2080 ADDRGP4 UI_Alloc CALLP4 ASGNP4 ADDRLP4 2052 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 8 INDIRP4 ADDP4 ADDRLP4 2080 INDIRP4 ASGNP4 ADDRLP4 2052 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 8 INDIRP4 ADDP4 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $115 ADDRLP4 2052 INDIRI4 CNSTI4 2 LSHI4 ADDRFP4 8 INDIRP4 ADDP4 INDIRP4 ARGP4 ADDRLP4 1028 ARGP4 ADDRGP4 qk_strcpy CALLP4 pop ADDRLP4 2052 ADDRLP4 2052 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $115 LABELV $90 ADDRGP4 $89 JUMPV LABELV $91 ADDRLP4 2052 INDIRI4 RETI4 LABELV $88 endproc UI_ParseInfos 2084 12 proc UI_LoadArenasFromFile 8216 16 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 4 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 8200 ADDRGP4 trap_FS_FOpenFile CALLI4 ASGNI4 ADDRLP4 0 ADDRLP4 8200 INDIRI4 ASGNI4 ADDRLP4 4 INDIRI4 CNSTI4 0 NEI4 $118 ADDRGP4 $120 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 8204 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 8204 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop ADDRGP4 $117 JUMPV LABELV $118 ADDRLP4 0 INDIRI4 CNSTI4 8192 LTI4 $121 ADDRGP4 $123 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0 INDIRI4 ARGI4 CNSTI4 8192 ARGI4 ADDRLP4 8204 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 8204 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop ADDRGP4 $117 JUMPV LABELV $121 ADDRLP4 8 ARGP4 ADDRLP4 0 INDIRI4 ARGI4 ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_Read CALLV pop ADDRLP4 0 INDIRI4 ADDRLP4 8 ADDP4 CNSTI1 0 ASGNI1 ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop ADDRLP4 8 ARGP4 ADDRLP4 8204 ADDRGP4 ui_numArenas ASGNP4 ADDRLP4 8208 ADDRLP4 8204 INDIRP4 INDIRI4 ASGNI4 CNSTI4 1024 ADDRLP4 8208 INDIRI4 SUBI4 ARGI4 ADDRLP4 8208 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_arenaInfos ADDP4 ARGP4 ADDRLP4 8212 ADDRGP4 UI_ParseInfos CALLI4 ASGNI4 ADDRLP4 8204 INDIRP4 ADDRLP4 8208 INDIRI4 ADDRLP4 8212 INDIRI4 ADDI4 ASGNI4 LABELV $117 endproc UI_LoadArenasFromFile 8216 16 export UI_LoadArenas proc UI_LoadArenas 1528 16 ADDRLP4 1448 CNSTI4 0 ASGNI4 ADDRGP4 ui_numArenas ADDRLP4 1448 INDIRI4 ASGNI4 ADDRGP4 uiInfo+83224 ADDRLP4 1448 INDIRI4 ASGNI4 ADDRLP4 152 ARGP4 ADDRGP4 $126 ARGP4 ADDRGP4 $127 ARGP4 CNSTI4 80 ARGI4 ADDRGP4 trap_Cvar_Register CALLV pop ADDRLP4 152+16 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $128 ADDRLP4 152+16 ARGP4 ADDRGP4 UI_LoadArenasFromFile CALLV pop ADDRGP4 $129 JUMPV LABELV $128 ADDRGP4 $132 ARGP4 ADDRGP4 UI_LoadArenasFromFile CALLV pop LABELV $129 ADDRGP4 $133 ARGP4 ADDRGP4 $134 ARGP4 ADDRLP4 424 ARGP4 CNSTI4 1024 ARGI4 ADDRLP4 1452 ADDRGP4 trap_FS_GetFileList CALLI4 ASGNI4 ADDRLP4 148 ADDRLP4 1452 INDIRI4 ASGNI4 ADDRLP4 8 ADDRLP4 424 ASGNP4 ADDRLP4 140 CNSTI4 0 ASGNI4 ADDRGP4 $138 JUMPV LABELV $135 ADDRLP4 8 INDIRP4 ARGP4 ADDRLP4 1456 ADDRGP4 qk_strlen CALLU4 ASGNU4 ADDRLP4 144 ADDRLP4 1456 INDIRU4 CVUI4 4 ASGNI4 ADDRLP4 12 ARGP4 ADDRGP4 $139 ARGP4 ADDRGP4 qk_strcpy CALLP4 pop ADDRLP4 12 ARGP4 ADDRLP4 8 INDIRP4 ARGP4 ADDRGP4 qk_strcat CALLP4 pop ADDRLP4 12 ARGP4 ADDRGP4 UI_LoadArenasFromFile CALLV pop LABELV $136 ADDRLP4 1456 CNSTI4 1 ASGNI4 ADDRLP4 140 ADDRLP4 140 INDIRI4 ADDRLP4 1456 INDIRI4 ADDI4 ASGNI4 ADDRLP4 8 ADDRLP4 144 INDIRI4 ADDRLP4 1456 INDIRI4 ADDI4 ADDRLP4 8 INDIRP4 ADDP4 ASGNP4 LABELV $138 ADDRLP4 140 INDIRI4 ADDRLP4 148 INDIRI4 LTI4 $135 ADDRGP4 $140 ARGP4 ADDRGP4 ui_numArenas INDIRI4 ARGI4 ADDRLP4 1460 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 1460 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop ADDRLP4 1464 ADDRGP4 UI_OutOfMemory CALLI4 ASGNI4 ADDRLP4 1464 INDIRI4 CNSTI4 0 EQI4 $141 ADDRGP4 $143 ARGP4 ADDRGP4 trap_Print CALLV pop LABELV $141 ADDRLP4 0 CNSTI4 0 ASGNI4 ADDRGP4 $147 JUMPV LABELV $144 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+24 ADDP4 CNSTI4 -1 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_arenaInfos ADDP4 INDIRP4 ARGP4 ADDRGP4 $154 ARGP4 ADDRLP4 1468 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1468 INDIRP4 ARGP4 ADDRLP4 1472 ADDRGP4 String_Alloc CALLP4 ASGNP4 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+4 ADDP4 ADDRLP4 1472 INDIRP4 ASGNP4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_arenaInfos ADDP4 INDIRP4 ARGP4 ADDRGP4 $157 ARGP4 ADDRLP4 1476 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 1476 INDIRP4 ARGP4 ADDRLP4 1480 ADDRGP4 String_Alloc CALLP4 ASGNP4 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228 ADDP4 ADDRLP4 1480 INDIRP4 ASGNP4 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+92 ADDP4 CNSTI4 -1 ASGNI4 ADDRGP4 $164 ARGP4 ADDRLP4 1484 CNSTI4 100 ASGNI4 ADDRLP4 1484 INDIRI4 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+4 ADDP4 INDIRP4 ARGP4 ADDRLP4 1488 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 1488 INDIRP4 ARGP4 ADDRLP4 1492 ADDRGP4 String_Alloc CALLP4 ASGNP4 ADDRLP4 1484 INDIRI4 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+8 ADDP4 ADDRLP4 1492 INDIRP4 ASGNP4 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 CNSTI4 0 ASGNI4 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_arenaInfos ADDP4 INDIRP4 ARGP4 ADDRGP4 $171 ARGP4 ADDRLP4 1496 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 4 ADDRLP4 1496 INDIRP4 ASGNP4 ADDRLP4 4 INDIRP4 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $172 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $176 ARGP4 ADDRLP4 1500 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1500 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $174 ADDRLP4 1504 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1504 INDIRP4 ADDRLP4 1504 INDIRP4 INDIRI4 CNSTI4 1 BORI4 ASGNI4 LABELV $174 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $182 ARGP4 ADDRLP4 1504 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1504 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $180 ADDRLP4 1508 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1508 INDIRP4 ADDRLP4 1508 INDIRP4 INDIRI4 CNSTI4 2 BORI4 ASGNI4 LABELV $180 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $188 ARGP4 ADDRLP4 1508 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1508 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $186 ADDRLP4 1512 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1512 INDIRP4 ADDRLP4 1512 INDIRP4 INDIRI4 CNSTI4 16 BORI4 ASGNI4 LABELV $186 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $194 ARGP4 ADDRLP4 1512 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1512 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $192 ADDRLP4 1516 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1516 INDIRP4 ADDRLP4 1516 INDIRP4 INDIRI4 CNSTI4 32 BORI4 ASGNI4 LABELV $192 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $200 ARGP4 ADDRLP4 1516 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1516 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $198 ADDRLP4 1520 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1520 INDIRP4 ADDRLP4 1520 INDIRP4 INDIRI4 CNSTI4 64 BORI4 ASGNI4 LABELV $198 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 $206 ARGP4 ADDRLP4 1520 ADDRGP4 qk_strstr CALLP4 ASGNP4 ADDRLP4 1520 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $173 ADDRLP4 1524 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1524 INDIRP4 ADDRLP4 1524 INDIRP4 INDIRI4 CNSTI4 128 BORI4 ASGNI4 ADDRGP4 $173 JUMPV LABELV $172 ADDRLP4 1500 CNSTI4 100 ADDRGP4 uiInfo+83224 INDIRI4 MULI4 ADDRGP4 uiInfo+83228+20 ADDP4 ASGNP4 ADDRLP4 1500 INDIRP4 ADDRLP4 1500 INDIRP4 INDIRI4 CNSTI4 1 BORI4 ASGNI4 LABELV $173 ADDRLP4 1500 ADDRGP4 uiInfo+83224 ASGNP4 ADDRLP4 1500 INDIRP4 ADDRLP4 1500 INDIRP4 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 ADDRGP4 uiInfo+83224 INDIRI4 CNSTI4 128 LTI4 $214 ADDRGP4 $146 JUMPV LABELV $214 LABELV $145 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $147 ADDRLP4 0 INDIRI4 ADDRGP4 ui_numArenas INDIRI4 LTI4 $144 LABELV $146 LABELV $124 endproc UI_LoadArenas 1528 16 proc UI_LoadBotsFromFile 8216 16 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 4 ARGP4 CNSTI4 0 ARGI4 ADDRLP4 8200 ADDRGP4 trap_FS_FOpenFile CALLI4 ASGNI4 ADDRLP4 0 ADDRLP4 8200 INDIRI4 ASGNI4 ADDRLP4 4 INDIRI4 CNSTI4 0 NEI4 $218 ADDRGP4 $120 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 8204 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 8204 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop ADDRGP4 $217 JUMPV LABELV $218 ADDRLP4 0 INDIRI4 CNSTI4 8192 LTI4 $220 ADDRGP4 $123 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 0 INDIRI4 ARGI4 CNSTI4 8192 ARGI4 ADDRLP4 8204 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 8204 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop ADDRGP4 $217 JUMPV LABELV $220 ADDRLP4 8 ARGP4 ADDRLP4 0 INDIRI4 ARGI4 ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_Read CALLV pop ADDRLP4 0 INDIRI4 ADDRLP4 8 ADDP4 CNSTI1 0 ASGNI1 ADDRLP4 4 INDIRI4 ARGI4 ADDRGP4 trap_FS_FCloseFile CALLV pop ADDRLP4 8 ARGP4 ADDRGP4 COM_Compress CALLI4 pop ADDRLP4 8 ARGP4 ADDRLP4 8204 ADDRGP4 ui_numBots ASGNP4 ADDRLP4 8208 ADDRLP4 8204 INDIRP4 INDIRI4 ASGNI4 CNSTI4 1024 ADDRLP4 8208 INDIRI4 SUBI4 ARGI4 ADDRLP4 8208 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_botInfos ADDP4 ARGP4 ADDRLP4 8212 ADDRGP4 UI_ParseInfos CALLI4 ASGNI4 ADDRLP4 8204 INDIRP4 ADDRLP4 8208 INDIRI4 ADDRLP4 8212 INDIRI4 ADDI4 ASGNI4 LABELV $217 endproc UI_LoadBotsFromFile 8216 16 export UI_LoadBots proc UI_LoadBots 1452 16 ADDRGP4 ui_numBots CNSTI4 0 ASGNI4 ADDRLP4 144 ARGP4 ADDRGP4 $223 ARGP4 ADDRGP4 $127 ARGP4 CNSTI4 80 ARGI4 ADDRGP4 trap_Cvar_Register CALLV pop ADDRLP4 144+16 INDIRI1 CVII4 1 CNSTI4 0 EQI4 $224 ADDRLP4 144+16 ARGP4 ADDRGP4 UI_LoadBotsFromFile CALLV pop ADDRGP4 $225 JUMPV LABELV $224 ADDRGP4 $228 ARGP4 ADDRGP4 UI_LoadBotsFromFile CALLV pop LABELV $225 ADDRGP4 $133 ARGP4 ADDRGP4 $229 ARGP4 ADDRLP4 416 ARGP4 CNSTI4 1024 ARGI4 ADDRLP4 1440 ADDRGP4 trap_FS_GetFileList CALLI4 ASGNI4 ADDRLP4 140 ADDRLP4 1440 INDIRI4 ASGNI4 ADDRLP4 0 ADDRLP4 416 ASGNP4 ADDRLP4 132 CNSTI4 0 ASGNI4 ADDRGP4 $233 JUMPV LABELV $230 ADDRLP4 0 INDIRP4 ARGP4 ADDRLP4 1444 ADDRGP4 qk_strlen CALLU4 ASGNU4 ADDRLP4 136 ADDRLP4 1444 INDIRU4 CVUI4 4 ASGNI4 ADDRLP4 4 ARGP4 ADDRGP4 $139 ARGP4 ADDRGP4 qk_strcpy CALLP4 pop ADDRLP4 4 ARGP4 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 qk_strcat CALLP4 pop ADDRLP4 4 ARGP4 ADDRGP4 UI_LoadBotsFromFile CALLV pop LABELV $231 ADDRLP4 1444 CNSTI4 1 ASGNI4 ADDRLP4 132 ADDRLP4 132 INDIRI4 ADDRLP4 1444 INDIRI4 ADDI4 ASGNI4 ADDRLP4 0 ADDRLP4 136 INDIRI4 ADDRLP4 1444 INDIRI4 ADDI4 ADDRLP4 0 INDIRP4 ADDP4 ASGNP4 LABELV $233 ADDRLP4 132 INDIRI4 ADDRLP4 140 INDIRI4 LTI4 $230 ADDRGP4 $234 ARGP4 ADDRGP4 ui_numBots INDIRI4 ARGI4 ADDRLP4 1448 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 1448 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop LABELV $222 endproc UI_LoadBots 1452 16 export UI_GetBotInfoByNumber proc UI_GetBotInfoByNumber 8 8 ADDRFP4 0 ADDRFP4 0 INDIRI4 ASGNI4 ADDRFP4 0 INDIRI4 CNSTI4 0 LTI4 $238 ADDRFP4 0 INDIRI4 ADDRGP4 ui_numBots INDIRI4 LTI4 $236 LABELV $238 ADDRGP4 $239 ARGP4 ADDRFP4 0 INDIRI4 ARGI4 ADDRLP4 4 ADDRGP4 va CALLP4 ASGNP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRGP4 trap_Print CALLV pop CNSTP4 0 RETP4 ADDRGP4 $235 JUMPV LABELV $236 ADDRFP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_botInfos ADDP4 INDIRP4 RETP4 LABELV $235 endproc UI_GetBotInfoByNumber 8 8 export UI_GetBotInfoByName proc UI_GetBotInfoByName 16 8 ADDRFP4 0 ADDRFP4 0 INDIRP4 ASGNP4 ADDRLP4 0 CNSTI4 0 ASGNI4 ADDRGP4 $244 JUMPV LABELV $241 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_botInfos ADDP4 INDIRP4 ARGP4 ADDRGP4 $245 ARGP4 ADDRLP4 8 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 4 ADDRLP4 8 INDIRP4 ASGNP4 ADDRLP4 4 INDIRP4 ARGP4 ADDRFP4 0 INDIRP4 ARGP4 ADDRLP4 12 ADDRGP4 Q_stricmp CALLI4 ASGNI4 ADDRLP4 12 INDIRI4 CNSTI4 0 NEI4 $246 ADDRLP4 0 INDIRI4 CNSTI4 2 LSHI4 ADDRGP4 ui_botInfos ADDP4 INDIRP4 RETP4 ADDRGP4 $240 JUMPV LABELV $246 LABELV $242 ADDRLP4 0 ADDRLP4 0 INDIRI4 CNSTI4 1 ADDI4 ASGNI4 LABELV $244 ADDRLP4 0 INDIRI4 ADDRGP4 ui_numBots INDIRI4 LTI4 $241 CNSTP4 0 RETP4 LABELV $240 endproc UI_GetBotInfoByName 16 8 export UI_GetNumBots proc UI_GetNumBots 0 0 ADDRGP4 ui_numBots INDIRI4 RETI4 LABELV $248 endproc UI_GetNumBots 0 0 export UI_GetBotNameByNumber proc UI_GetBotNameByNumber 12 8 ADDRFP4 0 INDIRI4 ARGI4 ADDRLP4 4 ADDRGP4 UI_GetBotInfoByNumber CALLP4 ASGNP4 ADDRLP4 0 ADDRLP4 4 INDIRP4 ASGNP4 ADDRLP4 0 INDIRP4 CVPU4 4 CNSTU4 0 EQU4 $250 ADDRLP4 0 INDIRP4 ARGP4 ADDRGP4 $245 ARGP4 ADDRLP4 8 ADDRGP4 Info_ValueForKey CALLP4 ASGNP4 ADDRLP4 8 INDIRP4 RETP4 ADDRGP4 $249 JUMPV LABELV $250 ADDRGP4 $252 RETP4 LABELV $249 endproc UI_GetBotNameByNumber 12 8 bss align 4 LABELV ui_arenaInfos skip 4096 align 4 LABELV ui_numArenas skip 4 align 4 LABELV ui_botInfos skip 4096 export ui_numBots align 4 LABELV ui_numBots skip 4 import UI_RankStatusMenu import RankStatus_Cache import UI_SignupMenu import Signup_Cache import UI_LoginMenu import Login_Cache import UI_InitGameinfo import UI_SPUnlockMedals_f import UI_SPUnlock_f import UI_GetAwardLevel import UI_LogAwardData import UI_NewGame import UI_GetCurrentGame import UI_CanShowTierVideo import UI_ShowTierVideo import UI_TierCompleted import UI_SetBestScore import UI_GetBestScore import UI_GetNumSPTiers import UI_GetNumSPArenas import UI_GetNumArenas import UI_GetSpecialArenaInfo import UI_GetArenaInfoByMap import UI_GetArenaInfoByNumber import UI_NetworkOptionsMenu import UI_NetworkOptionsMenu_Cache import UI_SoundOptionsMenu import UI_SoundOptionsMenu_Cache import UI_DisplayOptionsMenu import UI_DisplayOptionsMenu_Cache import UI_SaveConfigMenu import UI_SaveConfigMenu_Cache import UI_LoadConfigMenu import UI_LoadConfig_Cache import UI_TeamOrdersMenu_Cache import UI_TeamOrdersMenu_f import UI_TeamOrdersMenu import UI_RemoveBotsMenu import UI_RemoveBots_Cache import UI_AddBotsMenu import UI_AddBots_Cache import trap_SetPbClStatus import trap_VerifyCDKey import trap_R_RemapShader import trap_RealTime import trap_CIN_SetExtents import trap_CIN_DrawCinematic import trap_CIN_RunCinematic import trap_CIN_StopCinematic import trap_CIN_PlayCinematic import trap_S_StartBackgroundTrack import trap_S_StopBackgroundTrack import trap_R_RegisterFont import trap_SetCDKey import trap_GetCDKey import trap_MemoryRemaining import trap_LAN_CompareServers import trap_LAN_ServerStatus import trap_LAN_ResetPings import trap_LAN_RemoveServer import trap_LAN_AddServer import trap_LAN_UpdateVisiblePings import trap_LAN_ServerIsVisible import trap_LAN_MarkServerVisible import trap_LAN_SaveCachedServers import trap_LAN_LoadCachedServers import trap_LAN_GetPingInfo import trap_LAN_GetPing import trap_LAN_ClearPing import trap_LAN_GetPingQueueCount import trap_LAN_GetServerPing import trap_LAN_GetServerInfo import trap_LAN_GetServerAddressString import trap_LAN_GetServerCount import trap_GetConfigString import trap_GetGlconfig import trap_GetClientState import trap_GetClipboardData import trap_Key_SetCatcher import trap_Key_GetCatcher import trap_Key_ClearStates import trap_Key_SetOverstrikeMode import trap_Key_GetOverstrikeMode import trap_Key_IsDown import trap_Key_SetBinding import trap_Key_GetBindingBuf import trap_Key_KeynumToStringBuf import trap_S_RegisterSound import trap_S_StartLocalSound import trap_CM_LerpTag import trap_UpdateScreen import trap_R_ModelBounds import trap_R_DrawStretchPic import trap_R_SetColor import trap_R_RenderScene import trap_R_AddLightToScene import trap_R_AddPolyToScene import trap_R_AddRefEntityToScene import trap_R_ClearScene import trap_R_RegisterShaderNoMip import trap_R_RegisterSkin import trap_R_RegisterModel import trap_FS_Seek import trap_FS_GetFileList import trap_FS_FCloseFile import trap_FS_Write import trap_FS_Read import trap_FS_FOpenFile import trap_Cmd_ExecuteText import trap_Argv import trap_Argc import trap_Cvar_InfoStringBuffer import trap_Cvar_Create import trap_Cvar_Reset import trap_Cvar_SetValue import trap_Cvar_VariableStringBuffer import trap_Cvar_VariableValue import trap_Cvar_Set import trap_Cvar_Update import trap_Cvar_Register import trap_Milliseconds import trap_Error import trap_Print import UI_SPSkillMenu_Cache import UI_SPSkillMenu import UI_SPPostgameMenu_f import UI_SPPostgameMenu_Cache import UI_SPArena_Start import UI_SPLevelMenu_ReInit import UI_SPLevelMenu_f import UI_SPLevelMenu import UI_SPLevelMenu_Cache import uis import UI_LoadBestScores import m_entersound import UI_StartDemoLoop import UI_Cvar_VariableString import UI_Argv import UI_ForceMenuOff import UI_PopMenu import UI_PushMenu import UI_SetActiveMenu import UI_IsFullscreen import UI_DrawTextBox import UI_AdjustFrom640 import UI_CursorInRect import UI_DrawChar import UI_DrawString import UI_ProportionalStringWidth import UI_DrawProportionalString import UI_ProportionalSizeScale import UI_DrawBannerString import UI_LerpColor import UI_SetColor import UI_UpdateScreen import UI_DrawSides import UI_DrawTopBottom import UI_DrawRect import UI_FillRect import UI_DrawHandlePic import UI_DrawNamedPic import UI_ClampCvar import UI_ConsoleCommand import UI_Refresh import UI_MouseEvent import UI_KeyEvent import UI_Shutdown import UI_Init import uiInfo import UI_RegisterClientModelname import UI_PlayerInfo_SetInfo import UI_PlayerInfo_SetModel import UI_DrawPlayer import DriverInfo_Cache import GraphicsOptions_Cache import UI_GraphicsOptionsMenu import ServerInfo_Cache import UI_ServerInfoMenu import UI_BotSelectMenu_Cache import UI_BotSelectMenu import ServerOptions_Cache import StartServer_Cache import UI_StartServerMenu import ArenaServers_Cache import UI_ArenaServersMenu import SpecifyServer_Cache import UI_SpecifyServerMenu import SpecifyLeague_Cache import UI_SpecifyLeagueMenu import Preferences_Cache import UI_PreferencesMenu import PlayerSettings_Cache import UI_PlayerSettingsMenu import PlayerModel_Cache import UI_PlayerModelMenu import UI_CDKeyMenu_f import UI_CDKeyMenu_Cache import UI_CDKeyMenu import UI_ModsMenu_Cache import UI_ModsMenu import UI_CinematicsMenu_Cache import UI_CinematicsMenu_f import UI_CinematicsMenu import Demos_Cache import UI_DemosMenu import Controls_Cache import UI_ControlsMenu import UI_DrawConnectScreen import TeamMain_Cache import UI_TeamMainMenu import UI_SetupMenu import UI_SetupMenu_Cache import UI_ConfirmMenu import ConfirmMenu_Cache import UI_InGameMenu import InGame_Cache import UI_CreditMenu import UI_UpdateCvars import UI_RegisterCvars import UI_MainMenu import MainMenu_Cache import UI_ClearScores import UI_ShowPostGame import UI_AdjustTimeByGame import _UI_SetActiveMenu import UI_LoadMenus import UI_Load import UI_Report import MenuField_Key import MenuField_Draw import MenuField_Init import MField_Draw import MField_CharEvent import MField_KeyDownEvent import MField_Clear import ui_medalSounds import ui_medalPicNames import ui_medalNames import text_color_highlight import text_color_normal import text_color_disabled import listbar_color import list_color import name_color import color_dim import color_red import color_orange import color_blue import color_yellow import color_white import color_black import menu_dim_color import menu_black_color import menu_red_color import menu_highlight_color import menu_dark_color import menu_grayed_color import menu_text_color import weaponChangeSound import menu_null_sound import menu_buzz_sound import menu_out_sound import menu_move_sound import menu_in_sound import ScrollList_Key import ScrollList_Draw import Bitmap_Draw import Bitmap_Init import Menu_DefaultKey import Menu_SetCursorToItem import Menu_SetCursor import Menu_ActivateItem import Menu_ItemAtCursor import Menu_Draw import Menu_AdjustCursor import Menu_AddItem import Menu_Focus import Menu_Cache import ui_serverStatusTimeOut import ui_bigFont import ui_smallFont import ui_scoreTime import ui_scoreShutoutBonus import ui_scoreSkillBonus import ui_scoreTimeBonus import ui_scoreBase import ui_scoreTeam import ui_scorePerfect import ui_scoreScore import ui_scoreGauntlets import ui_scoreAssists import ui_scoreDefends import ui_scoreExcellents import ui_scoreImpressives import ui_scoreAccuracy import ui_singlePlayerActive import ui_lastServerRefresh_3 import ui_lastServerRefresh_2 import ui_lastServerRefresh_1 import ui_lastServerRefresh_0 import ui_selectedPlayerName import ui_selectedPlayer import ui_currentOpponent import ui_mapIndex import ui_currentNetMap import ui_currentMap import ui_currentTier import ui_menuFiles import ui_opponentName import ui_dedicated import ui_serverFilterType import ui_netSource import ui_joinGameType import ui_actualNetGameType import ui_netGameType import ui_gameType import ui_fragLimit import ui_captureLimit import ui_cdkeychecked import ui_cdkey import ui_server16 import ui_server15 import ui_server14 import ui_server13 import ui_server12 import ui_server11 import ui_server10 import ui_server9 import ui_server8 import ui_server7 import ui_server6 import ui_server5 import ui_server4 import ui_server3 import ui_server2 import ui_server1 import ui_marks import ui_drawCrosshairNames import ui_drawCrosshair import ui_brassTime import ui_browserShowEmpty import ui_browserShowFull import ui_browserGameType import ui_browserMaster import ui_spSelection import ui_spSkill import ui_spVideos import ui_spAwards import ui_spScores5 import ui_spScores4 import ui_spScores3 import ui_spScores2 import ui_spScores1 import ui_botsFile import ui_arenasFile import ui_ctf_friendly import ui_ctf_timelimit import ui_ctf_capturelimit import ui_team_friendly import ui_team_timelimit import ui_team_fraglimit import ui_tourney_timelimit import ui_tourney_fraglimit import ui_ffa_timelimit import ui_ffa_fraglimit import trap_PC_SourceFileAndLine import trap_PC_ReadToken import trap_PC_FreeSource import trap_PC_LoadSource import trap_PC_AddGlobalDefine import Controls_SetDefaults import Controls_SetConfig import Controls_GetConfig import UI_OutOfMemory import UI_InitMemory import UI_Alloc import Display_CacheAll import Menu_SetFeederSelection import Menu_Paint import Menus_CloseAll import LerpColor import Display_HandleKey import Menus_CloseByName import Menus_ShowByName import Menus_FindByName import Menus_OpenByName import Display_KeyBindPending import Display_CursorType import Display_MouseMove import Display_CaptureItem import Display_GetContext import Menus_Activate import Menus_AnyFullScreenVisible import Menu_Reset import Menus_ActivateByName import Menu_PaintAll import Menu_New import Menu_Count import PC_Script_Parse import PC_String_Parse import PC_Rect_Parse import PC_Int_Parse import PC_Color_Parse import PC_Float_Parse import Script_Parse import String_Parse import Rect_Parse import Int_Parse import Color_Parse import Float_Parse import Menu_ScrollFeeder import Menu_HandleMouseMove import Menu_HandleKey import Menu_GetFocused import Menu_PostParse import Item_Init import Menu_Init import Display_ExpandMacros import Init_Display import String_Report import String_Init import String_Alloc import BG_PlayerTouchesItem import BG_PlayerStateToEntityStateExtraPolate import BG_PlayerStateToEntityState import BG_TouchJumpPad import BG_AddPredictableEventToPlayerstate import BG_EvaluateTrajectoryDelta import BG_EvaluateTrajectory import BG_CanItemBeGrabbed import BG_FindItemForHoldable import BG_FindItemForPowerup import BG_FindItemForWeapon import BG_FindItem import bg_numItems import bg_itemlist import Pmove import PM_UpdateViewAngles import Com_Printf import Com_Error import Info_NextPair import Info_Validate import Info_SetValueForKey_Big import Info_SetValueForKey import Info_RemoveKey_Big import Info_RemoveKey import Info_ValueForKey import Com_TruncateLongString import va import Q_CountChar import Q_CleanStr import Q_PrintStrlen import Q_strcat import Q_strncpyz import Q_stristr import Q_strupr import Q_strlwr import Q_stricmpn import Q_strncmp import Q_stricmp import Q_isintegral import Q_isanumber import Q_isalpha import Q_isupper import Q_islower import Q_isprint import Com_RandomBytes import Com_SkipCharset import Com_SkipTokens import Com_sprintf import Com_HexStrToInt import Parse3DMatrix import Parse2DMatrix import Parse1DMatrix import SkipRestOfLine import SkipBracedSection import COM_MatchToken import COM_ParseWarning import COM_ParseError import COM_Compress import COM_ParseExt import COM_Parse import COM_GetCurrentParseLine import COM_BeginParseSession import COM_DefaultExtension import COM_CompareExtension import COM_StripExtension import COM_GetExtension import COM_SkipPath import Com_Clamp import PerpendicularVector import AngleVectors import MatrixMultiply import MakeNormalVectors import RotateAroundDirection import RotatePointAroundVector import ProjectPointOnPlane import PlaneFromPoints import AngleDelta import AngleNormalize180 import AngleNormalize360 import AnglesSubtract import AngleSubtract import LerpAngle import AngleMod import BoundsIntersectPoint import BoundsIntersectSphere import BoundsIntersect import BoxOnPlaneSide import SetPlaneSignbits import AxisCopy import AxisClear import AnglesToAxis import vectoangles import Q_crandom import Q_random import Q_rand import Q_acos import Q_log2 import VectorRotate import Vector4Scale import VectorNormalize2 import VectorNormalize import CrossProduct import VectorInverse import VectorNormalizeFast import DistanceSquared import Distance import VectorLengthSquared import VectorLength import VectorCompare import AddPointToBounds import ClearBounds import RadiusFromBounds import NormalizeColor import ColorBytes4 import ColorBytes3 import _VectorMA import _VectorScale import _VectorCopy import _VectorAdd import _VectorSubtract import _DotProduct import ByteToDir import DirToByte import ClampShort import ClampChar import Q_rsqrt import Q_fabs import Q_isnan import axisDefault import vec3_origin import g_color_table import colorDkGrey import colorMdGrey import colorLtGrey import colorWhite import colorCyan import colorMagenta import colorYellow import colorBlue import colorGreen import colorRed import colorBlack import bytedirs import Hunk_AllocDebug import FloatSwap import LongSwap import ShortSwap import CopyLongSwap import CopyShortSwap import qk_acos import qk_fabs import qk_abs import qk_tan import qk_atan2 import qk_cos import qk_sin import qk_sqrt import qk_floor import qk_ceil import qk_memcpy import qk_memset import qk_memmove import qk_sscanf import qk_vsnprintf import qk_strtol import qk_atoi import qk_strtod import qk_atof import qk_toupper import qk_tolower import qk_strncpy import qk_strstr import qk_strrchr import qk_strchr import qk_strcmp import qk_strcpy import qk_strcat import qk_strlen import qk_rand import qk_srand import qk_qsort lit align 1 LABELV $252 byte 1 83 byte 1 97 byte 1 114 byte 1 103 byte 1 101 byte 1 0 align 1 LABELV $245 byte 1 110 byte 1 97 byte 1 109 byte 1 101 byte 1 0 align 1 LABELV $239 byte 1 94 byte 1 49 byte 1 73 byte 1 110 byte 1 118 byte 1 97 byte 1 108 byte 1 105 byte 1 100 byte 1 32 byte 1 98 byte 1 111 byte 1 116 byte 1 32 byte 1 110 byte 1 117 byte 1 109 byte 1 98 byte 1 101 byte 1 114 byte 1 58 byte 1 32 byte 1 37 byte 1 105 byte 1 10 byte 1 0 align 1 LABELV $234 byte 1 37 byte 1 105 byte 1 32 byte 1 98 byte 1 111 byte 1 116 byte 1 115 byte 1 32 byte 1 112 byte 1 97 byte 1 114 byte 1 115 byte 1 101 byte 1 100 byte 1 10 byte 1 0 align 1 LABELV $229 byte 1 46 byte 1 98 byte 1 111 byte 1 116 byte 1 0 align 1 LABELV $228 byte 1 115 byte 1 99 byte 1 114 byte 1 105 byte 1 112 byte 1 116 byte 1 115 byte 1 47 byte 1 98 byte 1 111 byte 1 116 byte 1 115 byte 1 46 byte 1 116 byte 1 120 byte 1 116 byte 1 0 align 1 LABELV $223 byte 1 103 byte 1 95 byte 1 98 byte 1 111 byte 1 116 byte 1 115 byte 1 70 byte 1 105 byte 1 108 byte 1 101 byte 1 0 align 1 LABELV $206 byte 1 104 byte 1 97 byte 1 114 byte 1 118 byte 1 101 byte 1 115 byte 1 116 byte 1 101 byte 1 114 byte 1 0 align 1 LABELV $200 byte 1 111 byte 1 118 byte 1 101 byte 1 114 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 0 align 1 LABELV $194 byte 1 111 byte 1 110 byte 1 101 byte 1 102 byte 1 108 byte 1 97 byte 1 103 byte 1 0 align 1 LABELV $188 byte 1 99 byte 1 116 byte 1 102 byte 1 0 align 1 LABELV $182 byte 1 116 byte 1 111 byte 1 117 byte 1 114 byte 1 110 byte 1 101 byte 1 121 byte 1 0 align 1 LABELV $176 byte 1 102 byte 1 102 byte 1 97 byte 1 0 align 1 LABELV $171 byte 1 116 byte 1 121 byte 1 112 byte 1 101 byte 1 0 align 1 LABELV $164 byte 1 108 byte 1 101 byte 1 118 byte 1 101 byte 1 108 byte 1 115 byte 1 104 byte 1 111 byte 1 116 byte 1 115 byte 1 47 byte 1 37 byte 1 115 byte 1 0 align 1 LABELV $157 byte 1 108 byte 1 111 byte 1 110 byte 1 103 byte 1 110 byte 1 97 byte 1 109 byte 1 101 byte 1 0 align 1 LABELV $154 byte 1 109 byte 1 97 byte 1 112 byte 1 0 align 1 LABELV $143 byte 1 94 byte 1 51 byte 1 87 byte 1 65 byte 1 82 byte 1 78 byte 1 73 byte 1 78 byte 1 71 byte 1 58 byte 1 32 byte 1 110 byte 1 111 byte 1 116 byte 1 32 byte 1 101 byte 1 110 byte 1 111 byte 1 117 byte 1 103 byte 1 104 byte 1 32 byte 1 109 byte 1 101 byte 1 109 byte 1 111 byte 1 114 byte 1 121 byte 1 32 byte 1 105 byte 1 110 byte 1 32 byte 1 112 byte 1 111 byte 1 111 byte 1 108 byte 1 32 byte 1 116 byte 1 111 byte 1 32 byte 1 108 byte 1 111 byte 1 97 byte 1 100 byte 1 32 byte 1 97 byte 1 108 byte 1 108 byte 1 32 byte 1 97 byte 1 114 byte 1 101 byte 1 110 byte 1 97 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $140 byte 1 37 byte 1 105 byte 1 32 byte 1 97 byte 1 114 byte 1 101 byte 1 110 byte 1 97 byte 1 115 byte 1 32 byte 1 112 byte 1 97 byte 1 114 byte 1 115 byte 1 101 byte 1 100 byte 1 10 byte 1 0 align 1 LABELV $139 byte 1 115 byte 1 99 byte 1 114 byte 1 105 byte 1 112 byte 1 116 byte 1 115 byte 1 47 byte 1 0 align 1 LABELV $134 byte 1 46 byte 1 97 byte 1 114 byte 1 101 byte 1 110 byte 1 97 byte 1 0 align 1 LABELV $133 byte 1 115 byte 1 99 byte 1 114 byte 1 105 byte 1 112 byte 1 116 byte 1 115 byte 1 0 align 1 LABELV $132 byte 1 115 byte 1 99 byte 1 114 byte 1 105 byte 1 112 byte 1 116 byte 1 115 byte 1 47 byte 1 97 byte 1 114 byte 1 101 byte 1 110 byte 1 97 byte 1 115 byte 1 46 byte 1 116 byte 1 120 byte 1 116 byte 1 0 align 1 LABELV $127 byte 1 0 align 1 LABELV $126 byte 1 103 byte 1 95 byte 1 97 byte 1 114 byte 1 101 byte 1 110 byte 1 97 byte 1 115 byte 1 70 byte 1 105 byte 1 108 byte 1 101 byte 1 0 align 1 LABELV $123 byte 1 94 byte 1 49 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 32 byte 1 116 byte 1 111 byte 1 111 byte 1 32 byte 1 108 byte 1 97 byte 1 114 byte 1 103 byte 1 101 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 32 byte 1 105 byte 1 115 byte 1 32 byte 1 37 byte 1 105 byte 1 44 byte 1 32 byte 1 109 byte 1 97 byte 1 120 byte 1 32 byte 1 97 byte 1 108 byte 1 108 byte 1 111 byte 1 119 byte 1 101 byte 1 100 byte 1 32 byte 1 105 byte 1 115 byte 1 32 byte 1 37 byte 1 105 byte 1 10 byte 1 0 align 1 LABELV $120 byte 1 94 byte 1 49 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 32 byte 1 110 byte 1 111 byte 1 116 byte 1 32 byte 1 102 byte 1 111 byte 1 117 byte 1 110 byte 1 100 byte 1 58 byte 1 32 byte 1 37 byte 1 115 byte 1 10 byte 1 0 align 1 LABELV $114 byte 1 37 byte 1 100 byte 1 0 align 1 LABELV $113 byte 1 92 byte 1 110 byte 1 117 byte 1 109 byte 1 92 byte 1 0 align 1 LABELV $112 byte 1 60 byte 1 78 byte 1 85 byte 1 76 byte 1 76 byte 1 62 byte 1 0 align 1 LABELV $109 byte 1 125 byte 1 0 align 1 LABELV $106 byte 1 85 byte 1 110 byte 1 101 byte 1 120 byte 1 112 byte 1 101 byte 1 99 byte 1 116 byte 1 101 byte 1 100 byte 1 32 byte 1 101 byte 1 110 byte 1 100 byte 1 32 byte 1 111 byte 1 102 byte 1 32 byte 1 105 byte 1 110 byte 1 102 byte 1 111 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 10 byte 1 0 align 1 LABELV $100 byte 1 77 byte 1 97 byte 1 120 byte 1 32 byte 1 105 byte 1 110 byte 1 102 byte 1 111 byte 1 115 byte 1 32 byte 1 101 byte 1 120 byte 1 99 byte 1 101 byte 1 101 byte 1 100 byte 1 101 byte 1 100 byte 1 10 byte 1 0 align 1 LABELV $97 byte 1 77 byte 1 105 byte 1 115 byte 1 115 byte 1 105 byte 1 110 byte 1 103 byte 1 32 byte 1 123 byte 1 32 byte 1 105 byte 1 110 byte 1 32 byte 1 105 byte 1 110 byte 1 102 byte 1 111 byte 1 32 byte 1 102 byte 1 105 byte 1 108 byte 1 101 byte 1 10 byte 1 0 align 1 LABELV $96 byte 1 123 byte 1 0 ",16164,True,2699.4794977983015,median "/* Terminal.ino Use display terminal to output text (using Arduino print) Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2018, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! // End of constructor list U8G2LOG u8g2log; // setup the terminal (U8G2LOG) and connect to u8g2 for automatic refresh of the display // The size (width * height) depends on the selected font and the display // assume 4x6 font #define U8LOG_WIDTH 32 #define U8LOG_HEIGHT 10 uint8_t u8log_buffer[U8LOG_WIDTH*U8LOG_HEIGHT]; void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.setFont(u8g2_font_tom_thumb_4x6_mf); // set the font for the terminal window u8g2log.begin(u8g2, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer); u8g2log.setLineHeightOffset(0); // set extra space between lines in pixel, this can be negative u8g2log.setRedrawMode(0); // 0: Update screen with newline, 1: Update screen for every char } unsigned long t = 0; // print the output of millis() to the terminal every second void loop(void) { if ( t < millis() ) { t = millis() + 15000; // every 15 seconds u8g2log.print(""\\f""); // \\f = form feed: clear the screen } u8g2log.print(""millis=""); u8g2log.print(millis()); u8g2log.print(""\\n""); delay(500); } ",12344,True,3667.6029217784835,median "// The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_F_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1317_96X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8G2_SSD1318_128X96_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1318_128X96_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_F_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_F_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_F_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_ALT_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8G2_ST7565_NHD_C12832_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_F_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_F_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_F u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_128X64_ALT_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable/wr=*/ 17, /*cs/ce=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FG with GND //U8G2_SED1330_240X128_F_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // A0 is dc pin! //U8G2_RA8835_NHD_240X128_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_F_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1604_JLX19264_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, DOGXL240 Test Board //U8G2_UC1611_EW50850_F_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_SSD1607_WS_200X200_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8G2_IL3820_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_MAX7219_64X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_32X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_MAX7219_8X8_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); //U8G2_LS013B7DH03_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS013B7DH05_144X168_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display ",12418,True,3513.054419695157,median "; FAT16B file system, third attempt. ; Let's keep it somewhat simple and not have a hack of trying to be ; generic 12/16/32 but in reality only supporting FAT16 ; No partition support, filesystem must be directly on drive ; No long file name support ; Root directory only to start ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #local ; Avoid poluting the monitor's namespace with all our variables ;----------------------------------------------------------------------- #data _RAM BPBVER DS 1 ; BPB version, 70, 40, or 34 ; Bios Parameter Block - Info about the filesystem BPB: ; 2.0 BPB BPB_SECTSIZE DS 2 ; # bytes in a sector (better be 512 for us) BPB_CLUSTSIZE DS 1 ; # of sectors per cluster BPB_RESVSECT DS 2 ; Reserved sectors BPB_NFATS DS 1 ; Number of fats BPB_DIRENTS DS 2 ; Root directory entries BPB_TSECT DS 2 ; Total sectors BPB_MEDIA DS 1 ; Media byte (Don't care) BPB_SECTFAT DS 2 ; Sectors per FAT if 0 then use BPB_SECTFAT32 ; BPB 3.4 additions BPB_SECTTRCK DS 2 ; Sectors per Track (Don't care) BPB_NHEADS DS 2 ; Number of heads (Don't care) BPB_HIDSECT DS 4 ; Number of hidden sectors (Don't care) BPB_LGTSECT DS 4 ; Large total sectors (If TSECT=0) BPB_SIZ EQU . - BPB BPB_OFFSET EQU 0Bh ; Offset within boot sector BPB40_VOLLBL EQU 0x2B BPB40_VOLID EQU 0x27 FAT_DATASTART DS 4 ; First sector of data (after fats, root dir, and reserved) FAT_ROOTLBA DS 4 ; LBA of root directory FAT_FATLBA DS 4 ; LBA of first fat FAT_ROOTSECT DS 2 ; # of sectors for root directory FAT_CLUSTCNT DS 2 ; # of clusters in volume DW_TEMP1 DS 4 ; dword temp ;----------------------------------------------------------------------- #code _ROM ;----------------------------------------------------------------------- ; Cluster ranges for various fat sizes FAT12_CLUSTER_MAX equ 0FF6h FAT16_CLUSTER_MAX equ 0FFF6h FAT32_CLUSTER_MAX equ 0FFFFFF6h BPB70_FSTYPE equ 0x52 ; Offset to FSTYPE in boot sector BPB40_FSTYPE equ 0x36 FATDIR_START_CLUSTER equ 1Ah FATDIR_SIZE equ 1Ch DIRENTSIZ EQU 32 ENT_ATTR equ 11 ; Attribute byte ENT_FS equ 0x1C ; Size of file (DWORD) ENT_CLUST equ 0x1A ; Starting cluster ; File structure ; Name FS_FNAME:: EQU 0 ; 11 Filename (8+3 padded) ; Current Index within file FS_SECT:: EQU FS_FNAME+11 ; 1 Sector within cluster FS_CLUST:: EQU FS_SECT+1 ; 2 Current cluster ; Index for directory entry FS_DIRENT:: EQU FS_CLUST+2 ; 2 Index within root directory ; Status flags FS_FLAGS:: EQU FS_DIRENT+2 ; 1 Flags: ; 80 - End of file. Current cluster is end of file ; 40 - Read only. Ignored for now (blocks writes) ; 20 ; 10 ; 08 ; 04 ; 02 - Modified. File has been written to (size may have changed) ; 01 - Open. File is opened and safe to use FS_SIZE:: EQU FS_FLAGS+1 ; 4 - Size of file (in bytes) FS_OFFSET:: EQU FS_SIZE+4 ; 4 - Current offset in bytes (For keeping track of length) FS_RESERVED EQU FS_OFFSET+4 ; Padding for future expansion FSLEN:: EQU FS_RESERVED+7 ; currently 25 bytes, pad to 32 for future use ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Initialize a drive's data structure ;----------------------------------------------------------------------- FAT_INIT:: #local LD HL, LBA CALL CLEAR32 LD HL, SECTOR CALL CF_READ ; Read in sector 0 ; Ideally should do some kind of signature check here first ; to determine that this is a FAT filesystem ; If it's BPB3.4 we can't tell for sure ; We also can't tell between BPB3.4 and older really, hopefully not an issue ; Copy in BPB 3.4 values to variables, these are common to all ; BPB types LD HL, SECTOR+BPB_OFFSET LD DE, BPB LD BC, BPB_SIZ LDIR ; Copy relevant BPB 3.4 into variables ; Figure out BPB version LD A, (SECTOR+0x42) ; Check if we're BPB 7.0 AND 0FEh CP 40 ; 40 and 41 indicate 7.0 when here JR Z, BPB70 LD A, (SECTOR+0x26) ; Check if we're BPB 4.0 AND 0FEh CP 40 ; 40 and 41 indicate 4.0 when here JR Z, BPB40 ; Otherwise we must be 3.4, fall in ; BPB version 3.4 BPB34: LD A, 034h LD (BPBVER),A ; Calculate FAT type by cluster count JR CALCFAT ; BPB version 4.0 BPB40: LD A, 040h LD (BPBVER),A LD HL, SECTOR+BPB40_FSTYPE JR FSTYPE ; BBP version 7.0 BPB70: LD A, 070h LD (BPBVER),A LD HL, SECTOR+BPB70_FSTYPE JP FAIL_BPB70 ; Unsupported for now, only normally ; used for FAT32 anyways FSTYPE: ; Examine the FSTYPE field LD DE, STR_FAT LD B, 3 CALL MEMCMP JP NZ, FAIL_UNKNOWN ; We have a FAT filesystem, what size is it? ; (Properly we need to check the full width, but we're lazy) LD A, (HL) CP ' ' ; If we find a space, then we go by JR Z, CALCFAT ; the cluster count CP '3' ; If a 3 then it must be FAT32 JP Z, FAIL_FAT32 ; CP '1' ; Only other options are 12 and 16 JP NZ, FAIL_UNKNOWN INC HL LD A,(HL) CP '2' ; FAT12 JP Z, FAIL_FAT12 CP '6' ; Anything but 6 means we're not FAT16 JP NZ, FAIL_UNKNOWN LD HL, 16 ; We must be fat 16, save for later PUSH HL JR CONT1 CALCFAT: LD HL, 0 ; Need to calculate FAT PUSH HL ; Save for later CONT1: ; We need to do some more setup before we can calculate the ; cluster count ; Convert 16-bit TSECT to LGTSECT if not already LD HL, (BPB_TSECT) ; Total sectors (16-bit) LD A, H OR L JR Z, CONT2 ; Copy 16-bit into 32-bit LD (BPB_LGTSECT), HL ; Store low bytes XOR A ; 0 LD (BPB_LGTSECT+2), A LD (BPB_LGTSECT+3), A ; Clear high bytes ; Sector count has been enlarged CONT2: CALL PRINTI .ascii ""FAT: Sectors per cluster: $"",0 LD A, (BPB_CLUSTSIZE) \\ CALL PRINTBYTE CALL PRINTNL LD HL, (BPB_SECTSIZE) ; Check sector size LD DE, 512 ; Only 512 byte sectors supported CMP16 DE JP NZ, FAIL_SECTSIZ ; Calculate cluster count in volume ; SectorsInRootDirectory = (BPB.RootDirectoryEntries * 32 + BPB.BytesPerSector - 1) / BPB.BytesPerSector LD HL, (BPB_DIRENTS) ; # of root directory entries LD (DW_TEMP1), HL LD HL, 0 LD (DW_TEMP1+2), HL ; Expand to 32-bits ; Each directory entry is 32 bytes (left shift by 5) ; Carry flag is clear from XOR LD IX, DW_TEMP1 LD B, 5 MULDIRSIZ: AND A ; Clear carry RL (IX+0) RL (IX+1) RL (IX+2) ; Top byte unneeded as DIRENTS DJNZ MULDIRSIZ ; is only 16-bits LD HL, DW_TEMP1 LD DE, 511 ; BPB.BytesPerSector - 1 CALL ADD32_16 ; (force round up when we divide) ; We need to divide by 512 (bytes per sector). ; We'll shift right by 8, then one more (>>9) ; Max size of result for FAT16 is 4096 (65535 root directory entries) LD HL, (DW_TEMP1+1) ; >> 8, no need to worry about high byte SRL H ; as (65535 * 32 + 511) = 0x2001DF RR L ; >> 9 now LD (FAT_ROOTSECT), HL ; Size of root directory in sectors ; Display size of root directory CALL PRINTI .ascii ""FAT: Sectors for root directory: $"", 0 LD BC, (FAT_ROOTSECT) CALL PRINTWORD CALL PRINTNL ; Calculate data start ; DataStart = BPB.ReservedSectors + BPB.FATs * SectorsPerFAT + SectorsInRootDirectory LD HL, FAT_DATASTART LD DE, (BPB_RESVSECT) CALL COPY32_16 CALL PRINTI .ascii ""FAT: Reserved sectors: $"", 0 LD BC, (FAT_DATASTART+0) \\ CALL PRINTWORD CALL PRINTNL CALL PRINTI .ascii ""FAT: Sectors per fat: $"", 0 LD BC, (BPB_SECTFAT) \\ CALL PRINTWORD CALL PRINTNL CALL PRINTI .ascii ""FAT: Number of fats: $"", 0 LD A, (BPB_NFATS) CALL PRINTBYTE CALL PRINTNL LD HL, FAT_DATASTART LD DE, FAT_FATLBA CALL COPY32 ; Save block of the first fat LD A, (BPB_NFATS) ; Number of fats LD B, A MULFATS: LD DE, (BPB_SECTFAT) ; Number of sectors in a fat LD HL, FAT_DATASTART CALL ADD32_16 DJNZ MULFATS ; Datastart currently points to the first block of the root ; directory, save it for easy access later LD HL, FAT_DATASTART LD DE, FAT_ROOTLBA CALL COPY32 CALL PRINTI .ascii ""FAT: Root directory LBA: $"", 0 LD BC, (FAT_ROOTLBA+2) \\ CALL PRINTWORD LD BC, (FAT_ROOTLBA+0) \\ CALL PRINTWORD CALL PRINTNL ; Finally add our sectors in the root directory LD HL, FAT_DATASTART LD DE, (FAT_ROOTSECT) CALL ADD32_16 CALL PRINTI .ascii ""FAT: Data start sector: $"", 0 LD BC, (FAT_DATASTART+2) \\ CALL PRINTWORD LD BC, (FAT_DATASTART+0) \\ CALL PRINTWORD CALL PRINTNL ; Now we can calculate the cluster count ; ClusterCount = 2 + (SectorsInVolume - DataStart) / BPB.SectorsPerCluster LD HL, BPB_LGTSECT ; Sectors in volume LD DE, DW_TEMP1 ; Keep in 32-bit for now to determine if this is FAT32 CALL COPY32 LD DE, DW_TEMP1 LD HL, FAT_DATASTART ; Data start sector CALL SUB32 ; Divide by sectors per cluster ; Well assume Sectors per cluster is a power of two like it should be ; However it's not strictly required to be, but is in practice ; We're also not allowing a value of 0 (256) LD HL, DW_TEMP1 LD A, (BPB_CLUSTSIZE) BIT 0, A ; Check that clustsiz isn't 1 JR NZ, NODIVCLUS ; If it is then don't divide DIVSCLUS: CALL SRL32 ; Shift clustcnt right 1 RRA ; Shift clustsiz right by 1 (who cares about carry in bits) BIT 0, A ; Check if we found our match JR Z, DIVSCLUS NODIVCLUS: LD HL, DW_TEMP1 LD DE, 2 CALL ADD32_16 ; + 2 ; Display calculated cluster count CALL PRINTI .ascii ""FAT: Cluster count: $"", 0 LD BC, (DW_TEMP1+2) \\ CALL PRINTWORD LD BC, (DW_TEMP1+0) \\ CALL PRINTWORD CALL PRINTNL ; DW_TEMP1 now contains the cluster count determine FAT type POP BC ; Restore fat value from earlier LD HL, (DW_TEMP1+2) LD A, H OR L ; If > 0x0000FFFF then must be FAT32 JP NZ, FAIL_FAT32 LD HL, (DW_TEMP1) LD (FAT_CLUSTCNT), HL ; Save the 16-bit cluster count LD A, H CP 0FFh JR NZ, CONT3 ; If < 0xFF00 no way of being FAT32 LD A, L CP 0F7h ; If >= 0xFFF7 then FAT32 JP NC, FAIL_FAT32 CONT3: ; Now we're either FAT16 or FAT12. Check if we have an override LD C, A ; Check fat value from before AND A JR NZ, FAT16 ; Override to FAT 16 ; Otherwise check if < 0xFF7 (FAT12) LD A, H CP 010h JR NC, FAT16 ; If > 0x0FFF then FAT16 CP 0Fh JR NZ, FAIL_FAT12 ; If < 0x0F00 then FAT12 LD A, L CP 0F7h JR C, FAIL_FAT12 ; If < 0x0FF7 then FAT12 FAT16: ; Now we know we're 100% FAT16, everything is good CALL PRINTI .ascii ""FAT: FAT16 filesystem detected "",0 CALL PRINTI .ascii ""BPB: "",0 LD A, (BPBVER) \\ CALL PRINTBYTE CALL PRINTNL LD A, (BPBVER) CP 034h JR Z, NOLBL ; BPB 3.4 volumes have no label CALL PRINTI .ascii ""FAT: Volume Label: "",0 LD HL, SECTOR+BPB40_VOLLBL LD B, 11 CALL PRINT_FIX CALL PRINTI .ascii "" ID: "",0 LD BC, (SECTOR+BPB40_VOLID) CALL PRINTWORD NOLBL: CALL PRINTNL AND A ; Clear carry for success RET ; And we're mounted! ; MOUNT FAILURES, carry set FAIL_FAT12: CALL PRINTI .ascii ""FAT: FAT12 filesystem detected, only FAT16 supported"", 0 SCF \\ RET FAIL_FAT32: CALL PRINTI .ascii ""FAT: FAT32 filesystem detected, only FAT16 supported"", 0 SCF \\ RET FAIL_UNKNOWN: CALL PRINTI .ascii ""FAT: Unknown filesystem type"", 0 SCF \\ RET FAIL_BPB70: CALL PRINTI .ascii ""FAT: BPB7.0 detected, only 3.4 and 4.0 supported"", 0 SCF \\ RET FAIL_SECTSIZ: POP HL ; Saved fat type CALL PRINTI .ascii ""FAT: Invalid sector size, only 512B supported"", 0 SCF \\ RET STR_FAT: .ascii ""FAT"" #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; List the root directory ;----------------------------------------------------------------------- FAT_DIR_ROOT:: #local LD HL, FAT_ROOTLBA ; Root directory start LD DE, LBA CALL COPY32 LD HL, SECTOR CALL CF_READ ; Read in first sector of directory CALL PRINTI .ascii ""Filename RO Size (HEX) start"",13,10 STR_LISTBREAK: .ascii ""------------------------------------"",0 ; 0 1 2 3 4 ; 01234567890123456789012345678901234567890 ; FILENAME EXT R FILESIZE CLUS CALL PRINTNL LD BC, (BPB_DIRENTS) ; Entries in root directory LD HL, SECTOR ; Start of our sector buffer PUSH BC DIRLOOP: PUSH HL CALL PRINTENT ; Print directory entry HL POP HL POP BC ; Restore counter LD A, (HL) AND A ; If a directory entry starts with JR Z, DONE ; NULL then there are no more entries DEC BC ; Dec LD A, B OR C JR Z, DONE ; If no entries left then we're done PUSH BC ; Save counter LD DE, DIRENTSIZ ADD HL, DE ; Advance to the next directory entry LD DE, SECTOR+512 ; End of sector CMP16 DE ; Compare HL with DE JR C, NOLOAD ; If < SECTOR+512 then we don't need to load next ; Otherwise Load next sector LD HL, LBA LD DE, 1 CALL ADD32_16 ; Increment LBA LD HL, SECTOR CALL CF_READ LD HL, SECTOR ; Reset HL NOLOAD: JR DIRLOOP ; DONE: LD HL, STR_LISTBREAK CALL PRINTN RET ; Print out a directory entry ; HL - points to first byte of entry PRINTENT: #local LD A, (HL) ; First byte of filename AND A RET Z ; Skip blank entries CP $E5 RET Z ; Skip deleted entries PUSH HL POP IX ; Copy pointer into IX for indexing LD A, (IX+ENT_ATTR) ; Read attribute byte ; Attb byte is: ; 1 - Read Only, 2 - Hidden , 4 - System, 8 - Volume ID ; 16 - Directory, 32 - Archive AND $0F ; Mask off low bits CP $0F ; If Read only, hidden, system, and volume_id then is a LFN entry RET Z ; Skip LFN entries AND $0E ; If HIDDEN, SYSTEM, or VOLUME_ID RET NZ ; Then don't show files ; We want our printed format to be: ; 0 1 2 3 4 ; 01234567890123456789012345678901234567890 ; FILENAME EXT R FILESIZE CLUS ; or ; DIRNAME EXT ; Print the name PUSH IX POP HL ; Move to HL LD B, 8 ; Filename is 8 ch long CALL PRINT_FIX ; EVIL: We're going to be evil and rely on PRINTFIX not preserving HL LD A, ' ' CALL PRINTCH LD B, 3 ; Extension is 3 ch long CALL PRINT_FIX ; Print extension LD B, 3 ; 3ch space CALL SPACE ; Print if Read-only or not LD A, (IX+ENT_ATTR) ; Read attribute byte AND 1 ; Check if read-only JR Z, NORDONLY LD A, 'R' CALL PRINTCH JR AFTER1 NORDONLY: LD A, ' ' CALL PRINTCH AFTER1: LD B, 4 CALL SPACE ; Print filesize or if directory LD A, (IX+ENT_ATTR) AND $10 JR NZ, ISDIR LD B, (IX+ENT_FS+3) ; High word of filesize LD C, (IX+ENT_FS+2) CALL PRINTWORD LD B, (IX+ENT_FS+1) ; Low word of filesize LD C, (IX+ENT_FS+0) CALL PRINTWORD ;CALL PRINTNL ;RET JR CLUST ISDIR: CALL PRINTI .ascii "" "",0 ;RET CLUST: CALL PRINTI .ascii "" "",0 LD BC, (IX+ENT_CLUST) CALL PRINTWORD CALL PRINTNL RET SPACE: LD A, ' ' CALL PRINTCH DJNZ SPACE RET #endlocal #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Get FAT entry for cluster DE, result in DE ;----------------------------------------------------------------------- FAT_GET: #local PUSH DE LD HL, FAT_FATLBA ; Pointer to start of first fat LD DE, LBA CALL COPY32 POP DE PUSH DE ; # of clusters per sector of fat is 512/2 = 256 ; So D contains the sector offset to add, and E*2 the entry LD HL, LBA LD E, D ; Index to correct sector LD D, 0 CALL ADD32_16 LD HL, SECTOR CALL CF_READ ; Read in sector of first FAT POP HL ; Cluster # LD H, 0 ; Only the part within this sector ADD HL, HL ; Offset of entry (each is a word) LD DE, SECTOR ADD HL, DE ; Pointer to entry LD DE, (HL) RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Set FAT entry to BC for cluster DE ;----------------------------------------------------------------------- FAT_SET: #local PUSH BC PUSH DE LD HL, FAT_FATLBA ; Pointer to start of first fat LD DE, LBA CALL COPY32 POP DE PUSH DE ; # of clusters per sector of fat is 512/2 = 256 ; So D contains the sector offset to add, and E*2 the entry LD HL, LBA LD E, D ; Index to correct sector LD D, 0 CALL ADD32_16 LD HL, SECTOR CALL CF_READ ; Read in sector of first FAT POP HL ; Cluster # LD H, 0 ; Only the part within this sector ADD HL, HL ; Offset of entry (each is a word) LD DE, SECTOR ADD HL, DE ; Pointer to entry POP BC LD (HL), BC ; Set entry in sector LD HL, SECTOR CALL CF_WRITE ; Write back sector in first fat ; Copy into all the other fats LD A, (BPB_NFATS) LD B, A JR PRE_DEC ; Pre-decrement since we may FATLOOP: ; only have 1 fat PUSH BC LD HL, LBA LD DE, (BPB_SECTFAT) ; Advance to the next FAT CALL ADD32_16 LD HL, SECTOR ; Write the same sector to the CALL CF_WRITE ; fat copies POP BC PRE_DEC: DJNZ FATLOOP RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Get the next cluster in the chain ; Input: DE - current cluster # ; Result: DE - next cluster # (0 if invalid) ; (Call FAT_GET instead if exact value desired) ;----------------------------------------------------------------------- NEXTCLUST: CALL FAT_GET ; Check if a cluster is valid, CLUSTVALID: #local LD A, D CP 00h JR NZ, TEST1 LD A, E CP 02h ; Clusters > 2 are invalid JR C, INVALID ; LD A, D TEST1: CP 0FFh ; Test FFF6-FFFF - EOF, invalid, or bad RET NZ ; LD A, E CP 0F6h RET C ; If < 0FFF6h then it's valid INVALID: LD DE, 0 ; Invalid sector, return 0 RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Convert cluster DE into LBA address (in LBA) ;----------------------------------------------------------------------- CLUST2LBA: CALL CLUSTVALID ; Check if a cluster is valid LD HL, 0 CMP16 DE ; If DE=0 then cluster is invalid SCF ; Set carry for failure RET Z DEC DE \\ DEC DE ; Clusters start at 2 from the data area ; LBA = FAT_DATASTART + (CLUSTER-2) * BPB_CLUSTSIZE ; Need to do 32-bit math here ; DE (16) * BPB_CLUSTSIZE (8) LD HL, LBA CALL COPY32_16 ; Promote cluster # to 32-bits in LBA LD A, (BPB_CLUSTSIZE) LD E, A LD D, 0 LD HL, DW_TEMP1 CALL COPY32_16 ; Promote cluster size to 32-bits in TEMP1 LD HL, LBA LD BC, DW_TEMP1 CALL MUL32 ; Multiply LD HL, FAT_DATASTART LD DE, LBA CALL ADD32 ; Add starting sector AND A ; Success (clear carry) RET ; And we're done ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Find a file in the root directory ; HL - 8+3 space padded file name ; Returns: HL - pointer to directory entry (within SECTOR) ; Carry set if file not found ;----------------------------------------------------------------------- FAT_FINDFILE: #local PUSH HL POP IX ; Save filename in IX LD HL, FAT_ROOTLBA ; Start of root directory LD DE, LBA CALL COPY32 LD HL, SECTOR CALL CF_READ ; First sector of root directory LD BC, (BPB_DIRENTS) ; Entries in root directory LD HL, SECTOR ; Start of our sector buffer PUSH BC ; (1) Save entries DIRLOOP: PUSH HL ; (2) Save sector POP IY ; (2) Copy into IY for indexing PUSH IY ; (2) Resave sector LD A, (IY+ENT_ATTR) ; Read attribute byte ; Attb byte is: ; 1 - Read Only, 2 - Hidden , 4 - System, 8 - Volume ID ; 16 - Directory, 32 - Archive AND $0F ; Mask off low bits CP $0F ; If Read only, hidden, system, and volume_id then is a LFN entry JP Z, NOTFILE2 ; We're at a directory entry, see if filename matches LD B, 11 PUSH IX ; (3) Save pointer to start of filename NAMECHECK: LD A, (IX) CP (HL) ; Compare with current file JR NZ, NOTFILE INC HL INC IX DJNZ NAMECHECK ; Filename matches, we have our file entry POP IX ; (3) Pointer to start of file name POP HL ; (2) HL points to the directory entry POP BC ; (1) Counter ; Need to invert counter ; Store index into BC PUSH HL ; (1) Dir pointer LD HL, (BPB_DIRENTS) AND A ; Clear carry SBC HL, BC ; Get index EX DE, HL ; Save in DE POP HL ; (1) Dir pointer AND A ; Clear carry RET ; File found! NOTFILE: POP IX ;(3) Pointer to start of filename NOTFILE2: POP HL ;(2) Pointer to dir ent start POP BC ;(1) Restore counter LD A, (HL) AND A ; If a directory entry starts with JR Z, DONE ; NULL then there are no more entries DEC BC ; Dec counter LD A, B OR C JR Z, DONE ; If no entries left then we're done PUSH BC ; (1) Save counter PUSH IX ; (2) Save filename LD DE, DIRENTSIZ ADD HL, DE ; Advance to the next directory entry LD DE, SECTOR+512 ; End of sector CMP16 DE ; Compare HL with DE JR C, NOLOAD ; If < SECTOR+512 then we don't need to load next ; Otherwise Load next sector LD HL, LBA LD DE, 1 CALL ADD32_16 ; Increment LBA LD HL, SECTOR CALL CF_READ LD HL, SECTOR ; Reset HL NOLOAD: POP IX ; (2) restore filename JP DIRLOOP ; DONE: ; File not found SCF ; Set carry for error RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Check if a cluster DE is the end of a file (corrupts SECTOR) ;----------------------------------------------------------------------- ISEOF: #local LD A, D OR E JR Z, YES ; File is empty, so yes CALL FAT_GET LD A, D CP 0FFh JR NZ, NO ; <0xFF00 LD A, E CP 0F6h JR NC, YES ; >=0xFFF6 NO: ; !=0, and FAT indicates it's not EOF AND A ; Clear carry RET YES: SCF ; Set carry RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Get the next free cluster from the FAT. ; Returns: ; DE - free cluster # ; Carry flag set if no clusters free ;----------------------------------------------------------------------- FAT_GETCLUSTER: #local LD HL, FAT_FATLBA LD DE, LBA CALL COPY32 ; Search fat for a 0000 entry. No need to skip first two as they're ; gauranteed not to be 0000 LD HL, SECTOR CALL CF_READ LD DE, 0 NEXT: LD BC, (HL) ; Read in entry LD A, B OR C JR Z, FOUND ; Found free entry INC HL \\ INC HL ; Next entry INC DE ; Keep track of cluster # LD BC, SECTOR+512 CMP16 BC ; Compare HL with DE JR C, NEXT ; If < SECTOR+512 then we don't need to load next ; Load next sector of FAT PUSH DE ; Save cluster # LD HL, LBA LD DE, 1 CALL ADD32_16 ; Next block LD HL, SECTOR CALL CF_READ POP DE ; cluster # ; Check if we're at the end of the disk LD HL, (FAT_CLUSTCNT) ; # of clusters on disk INC HL INC HL ; Index starts at 2 CMP16 DE ; total-cur JR Z, NOTFOUND ; cur = total JR NC, NEXT ; cur < total NOTFOUND: ; cur >= total LD DE, 0 SCF ; No space left on disk RET FOUND: ; Cluster # in DE AND A ; Clear carry RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Set the file name in the FS struct ; HL - Filename (8.3 null terminated) ; DE - Pointer to FS struct ;----------------------------------------------------------------------- FS_SETFILENAME:: #local ; Clear filename to make our life easier LD A, ' ' LD B, 11 PUSH DE CLR: LD (DE), A ; Filename is first entry in FS struct INC DE DJNZ CLR POP DE ; Copy up to 8 chars till we see either a NULL or a . LD B, 8 NAMEL: LD A, (HL) AND A JR Z, DONE ; Once we hit a null we're done CP '.' JR Z, DOEXT ; Or if we hit a dot CP 'a' JR C, NOUPPER1 CP 'z'+1 JR NC, NOUPPER1 AND 0DFH ; Force to uppercase NOUPPER1: LD (DE), A ; Otherwise copy INC HL INC DE DJNZ NAMEL ; We copied 8 characters, make sure there's a dot here... LD A, (HL) CP '.' JR Z, DOEXT ; Otherwise this was a bad filename SCF RET ; Carry indicates failure DOEXT: LD A, E ADD B ; Add remaining to get to extension LD E, A LD A, D ADC 0 LD D, A LD B, 3 EXTLOOP: INC HL LD A, (HL) AND A JR Z, DONE CP 'a' JR C, NOUPPER2 CP 'z'+1 JR NC, NOUPPER2 AND 0DFH ; Force to uppercase NOUPPER2: LD (DE), A INC DE DJNZ EXTLOOP DONE: AND A ; Clear carry RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Open a file (filename must already be set) ; HL - Pointer to FS struct (preserved) ;----------------------------------------------------------------------- FS_OPEN:: #local PUSH HL ; Save our pointer ; Search for the file in the directory CALL FAT_FINDFILE ; Search for file JR C, FAIL ; Fail if file not found ; HL points to directory entry, DE is index POP IX ; Restore FS struct into IX LD (IX+FS_DIRENT), DE ; Save directory index LD A, 0 LD (IX+FS_SECT), A ; Clear sector LD (IX+FS_OFFSET+0),A LD (IX+FS_OFFSET+1),A LD (IX+FS_OFFSET+2),A LD (IX+FS_OFFSET+3),A ; Clear offset within file LD DE, FATDIR_START_CLUSTER ADD HL, DE LD E, (HL) \\ INC HL LD D, (HL) \\ INC HL LD (IX+FS_CLUST), DE ; Start cluster ; Size is right after the cluster PUSH DE ; Save start cluster LD E, (HL) \\ INC HL ; Low word of file size LD D, (HL) \\ INC HL LD (IX+FS_SIZE), DE LD E, (HL) \\ INC HL ; high word of file size LD D, (HL) \\ INC HL LD (IX+FS_SIZE+2), DE POP DE ; Start cluster back into DE PUSH IX ; Save pointer ; Check if end of file for flags LD A, D OR E ; Check if file is empty JR Z, ISEND LD A, 01h ; Not EOF and open JR FLAG1 ISEND: LD A, 81h ; Is EOF and open FLAG1: LD (IX+FS_FLAGS), A POP HL ; Restore pointer for caller AND A ; Clear carry, success RET FAIL: POP HL SCF RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Close open file ; HL - Pointer to FS struct ;----------------------------------------------------------------------- FS_CLOSE:: #local PUSH HL POP IX BIT 0, (IX+FS_FLAGS) RET Z ; File is already closed ignore ; DEBUG: Print out fields ; Flags Sector(in cluster) Cluster Dir.ent Size Offset ; PUSHALL ; CALL PRINTI ; .ascii 10,13,""FS: DEBUG: Struct on close:"",10,13,0 ; LD A, (IX+FS_FLAGS) \\ CALL PRINTBYTE ; LD A, ' ' \\ CALL PRINTCH ; LD A, (IX+FS_SECT) \\ CALL PRINTBYTE ; LD A, ' ' \\ CALL PRINTCH ; LD BC, (IX+FS_CLUST) \\ CALL PRINTWORD ; LD A, ' ' \\ CALL PRINTCH ; LD BC, (IX+FS_DIRENT) \\ CALL PRINTWORD ; LD A, ' ' \\ CALL PRINTCH ; LD BC, (IX+FS_SIZE+2) \\ CALL PRINTWORD ; LD BC, (IX+FS_SIZE+0) \\ CALL PRINTWORD ; LD A, ' ' \\ CALL PRINTCH ; LD BC, (IX+FS_OFFSET+2) \\ CALL PRINTWORD ; LD BC, (IX+FS_OFFSET+0) \\ CALL PRINTWORD ; CALL PRINTNL ; POPALL LD A, (IX+FS_FLAGS) AND 0FEh ; Mark file as closed LD (IX+FS_FLAGS), A AND 02h ; Check if modified RET Z ; File is clean, don't update dir ; File has been modified! ; We need to return to the directory entry and update the size CALL FILE_GET_DIRENT LD DE, FATDIR_SIZE ADD HL, DE LD BC, (IX+FS_SIZE+0) LD (HL), C \\ INC HL LD (HL), B \\ INC HL LD BC, (IX+FS_SIZE+2) LD (HL), C \\ INC HL LD (HL), B \\ INC HL ; We could also update the modified time here if desired LD HL, SECTOR CALL CF_WRITE ; Write updated directory to disk AND A ; Clear carry, success RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Add amount DE to FS_OFFSET field in FS struct (HL) ;----------------------------------------------------------------------- ADD_OFFSET: LD BC, FS_OFFSET ADD HL, BC CALL ADD32_16 RET ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Compare FS_OFFSET field with FS_SIZE in FS struct (IX) ;----------------------------------------------------------------------- CMP_OFFSET_SIZE: LD HL, (IX+FS_SIZE+2) ; High word first LD DE, (IX+FS_OFFSET+2) CMP16 DE RET C ; SIZE < OFFSET RET NZ ; SIZE > OFFSET ; High bytes match, need to check low LD HL, (IX+FS_SIZE+0) ; High word first LD DE, (IX+FS_OFFSET+0) CMP16 DE RET ; C set if SIZE < OFFSET ; Z set if SIZE == OFFSET ; NC & !Z if SIZE > OFFSET ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Copy FS_OFFSET field into FS_SIZE, file has been expanded ;----------------------------------------------------------------------- OFFSET_TO_SIZE: LD HL, (IX+FS_OFFSET+2) LD (IX+FS_SIZE+2), HL LD HL, (IX+FS_OFFSET+0) LD (IX+FS_SIZE+0), HL RET ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Reaquire the directory entry for a open file ; IX points to file structure ; Returns: ; HL - pointer to directory entry within SECTOR ; LBA/SECTOR - pointing to sector of directory entry so we can ; simply write back ;----------------------------------------------------------------------- FILE_GET_DIRENT: #local LD HL, FAT_ROOTLBA LD DE, LBA CALL COPY32 LD E, (IX+FS_DIRENT) LD D, (IX+FS_DIRENT+1) ; Directory entries are 32 bytes, 16 (4 bits) fit per 512B sector ; Get sector LD BC, 0 ; Offset in sector SRL D \\ RR E \\ RR C SRL D \\ RR E \\ RR C SRL D \\ RR E \\ RR C SRL D \\ RR E \\ RR C ; >> 4, DE now contains the sector ; And BC contains the entry within the sector * 16 PUSH BC ; DE is the sector offset LD HL, LBA CALL ADD32_16 ; Add to root directory lba LD HL, SECTOR CALL CF_READ ; Read in sector in directory LD HL, SECTOR POP BC ; ADD HL, BC ; Offset in sector / 2 ADD HL, BC ; Offset in sector ; HL now points at the directory entry, LBA at the sector it's in RET #endlocal ;----------------------------------------------------------------------- ; BIOS is free to handle the far pointers more gracefully and normallize ; then before calling these functions that use them ;----------------------------------------------------------------------- ; Read next sector from open file ; IX - Pointer to FS struct (kernel space) ; C:HL - Far Pointer to buffer to read (Must be in low bank!) ; C - (low nybble only) bank pointer ;----------------------------------------------------------------------- FS_READ:: #local PUSH HL PUSH BC ; Save far pointer LD A, H AND 080H ; Sanity check our address JP NZ, FAIL ; If in high bank then error out LD A, C AND 0F0H ; Sanity check bank pointer JP NZ, FAIL ; If any high nybble data then error out ; Okay far pointer is sane, we can begin LD A, (IX+FS_FLAGS) ; Check the file is open AND 1 JP Z, FAIL ; File is not open LD A, (IX+FS_FLAGS) AND 080h ; Are we at the end already? JP NZ, EOF ; Okay try and read in the next sector LD A, (BPB_CLUSTSIZE) CP (IX+FS_SECT) ; JP Z, NEWCLUST ; We need a new cluster JP C, FAIL ; FS_SECT was >= CLUSTSIZE already, something is wrong JP SEQCLUST ; Still space left NEWCLUST: ; Load next cluster in chain LD DE, (IX+FS_CLUST) CALL NEXTCLUST LD A, D OR E JP Z, EOFMARK ; No more data (or bad block in file/fat error) LD (IX+FS_CLUST), DE ; Next cluster in chain LD (IX+FS_SECT), 0 ; Start of sector within cluster SEQCLUST: ; Read specified Cluster+sector LD DE, (IX+FS_CLUST) CALL CLUST2LBA LD HL, LBA LD D, 0 LD E, (IX+FS_SECT) CALL ADD32_16 LD HL, SECTOR CALL CF_READ ; Copy data into banked address POP BC POP DE ; Restore far pointer (dest) ; Copy SECTOR to C:DE LD A, C ; Destination bank LD HL, SECTOR ; Source LD BC, 512 ; Count PUSH IX CALL RAM_BANKCOPY ; Do a bank copy POP IX ; Add to offset the amount we read PUSH IX \\ POP HL LD DE, 512 ; Amount of bytes read CALL ADD_OFFSET ; Check if we're past the file size CALL CMP_OFFSET_SIZE JR C, EOFMARK2 ; We're at the end of the file ; Increment current sector INC (IX+FS_SECT) LD A, (BPB_CLUSTSIZE) CP (IX+FS_SECT) ; JP NZ, NOINCFIX ; We didn't force a wrap thankfully ; Need to advance to next sector or mark EOF ; Load next cluster in chain LD DE, (IX+FS_CLUST) CALL NEXTCLUST LD A, D OR E JR Z, EOFMARK2 ; No more data (or bad block in file/fat error) LD (IX+FS_CLUST), DE ; Next cluster in chain LD (IX+FS_SECT), 0 ; Start of sector within cluster NOINCFIX: ; And we're done LD A, 1 AND A ; Clear carry RET EOFMARK2: LD A, (IX+FS_FLAGS) OR 080h LD (IX+FS_FLAGS), A ; Don't advance clust or sect JR NOINCFIX EOFMARK: LD A, (IX+FS_FLAGS) OR 080h LD (IX+FS_FLAGS), A EOF: XOR A ; Indicate EOF JR FAIL2 FAIL: LD A, 0FFh ; Indicate argument error FAIL2: POP BC POP HL SCF ; Carry for error RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Write current sector to open file, advance to next ; IX - Pointer to FS struct (kernel space) ; C:HL - Far Pointer to buffer to write from ; C - (low nybble only) bank pointer ;----------------------------------------------------------------------- FS_WRITE:: #local PUSH HL PUSH BC ; Save far pointer LD A, H AND 080H ; Sanity check our address JP NZ, FAIL ; If in high bank then error out LD A, C AND 0F0H ; Sanity check bank pointer JP NZ, FAIL ; If any high nybble data then error out ; Okay far pointer is sane, we can begin LD A, (IX+FS_FLAGS) ; Check the file is open AND 1 JP Z, FAIL ; File is not open LD A, (IX+FS_FLAGS) ; Set modified flag while we're here. OR 2h LD (IX+FS_FLAGS), A ; Modified set since we're writing AND 080h ; Are we at the end already? CALL NZ, EOF_ALLOC ; Okay we'll need to allocate a new cluster ; Address specified Cluster+sector LD DE, (IX+FS_CLUST) LD A, D OR E CALL Z, EOF_ALLOC ; At start of empty file, allocate CALL CLUST2LBA LD HL, LBA LD D, 0 LD E, (IX+FS_SECT) CALL ADD32_16 ; Copy data from banked address to sector buffer POP BC POP HL ; Restore far pointer (src) ; Copy C:DE to SECTOR LD A, C ; Destination bank LD DE, SECTOR ; Destination LD BC, 512 ; Count CALL RAM_BANKCOPY ; Do a bank copy LD HL, SECTOR CALL CF_WRITE ; Write data to disk ; Add to offset the amount we wrote PUSH IX \\ POP HL LD DE, 512 ; Amount of bytes written CALL ADD_OFFSET ; Check if we're past the file size (and need to update it) CALL CMP_OFFSET_SIZE CALL C, OFFSET_TO_SIZE ; If so offset is our new size ; Okay try and point to next sector INC (IX+FS_SECT) ; Next sector within cluster LD A, (BPB_CLUSTSIZE) CP (IX+FS_SECT) ; JP C, FAIL ; FS_SECT was >= CLUSTSIZE already, something is wrong JP NZ, DONE ; More sectors still in cluster ; No more sectors in current cluster, check if there's a cluster ; already allocated after this one LD DE, (IX+FS_CLUST) CALL NEXTCLUST ; Try and get next cluster LD A, D OR E JR Z, EOF ; We're at the end of the file, set flag ; Leave FS_SECT invalid for now, should be fine ; Not at end of file LD (IX+FS_CLUST), DE ; Store next cluster LD (IX+FS_SECT), 0 ; First sector of JR DONE ; And we're done EOF: LD A, (IX+FS_FLAGS) OR 80h ; Set EOF flag LD (IX+FS_FLAGS), A ; And we're done DONE: LD A, 1 AND A ; Clear carry RET EOF_ALLOC: ; We're at the EOF and we need to write data ; We need to allocate a new cluster to this file PUSH IX CALL FAT_GETCLUSTER ; Get a new cluster in DE JP C, NOSPACE ; Append to chain POP IX \\ PUSH IX ; Restore FS pointer PUSH DE ; Save new cluster LD BC, 0FFFFh ; End of file marker CALL FAT_SET LD DE, (IX+FS_CLUST) LD A, D OR E ; Test if empty file with null cluster JR Z, EMPTYFILE POP BC ; Restore new cluster into BC PUSH BC ; Keep saved ; Skip if we're empty CALL FAT_SET ; Set current cluster's next to be the new one POP DE ; Next cluser # FINISH: POP IX LD (IX+FS_CLUST), DE ; Current is our new cluster LD (IX+FS_SECT), 0 ; First sector of new cluster LD A, (IX+FS_FLAGS) AND 07Fh ; Remove EOF flag LD (IX+FS_FLAGS), A RET EMPTYFILE: ; We need to save this new cluster into the directory entry CALL FILE_GET_DIRENT ; Get our directory entry in HL POP BC ; New cluster # LD (IX+FS_CLUST), BC ; Save into file handle LD DE, ENT_CLUST ; Cluster of this entry ADD HL, DE LD (HL),BC ; Save into directory entry LD HL, SECTOR CALL CF_WRITE ; Update directory info LD DE, (IX+FS_CLUST) JP FINISH NOSPACE: POP IX LD A, 1 ; 1 indicates out of space JR FAIL2 FAIL: LD A, 0FFh ; Indicate argument error FAIL2: POP BC POP HL SCF ; Carry for error RET #endlocal RET ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Read entire open file to memory (max size 32kB) ; IX - Pointer to FS struct (kernel space) ; C:HL - Far Pointer to buffer to read (Must be in low bank!) ; C - (low nybble only) bank pointer ;----------------------------------------------------------------------- FS_READFILE:: #local ; Assume file is open an re-wound to the start LOOP: PUSH IX PUSH BC PUSH HL CALL FS_READ JR C, RDFAIL LD A, '.' CALL PRINTCH POP HL POP BC POP IX ; Advance to next address LD DE, 512 ADD HL, DE ; Ready for next sector LD A, H AND 080H JR Z, LOOP ; Out of memory to copy to, we're done early LD A, 0FFh ; Set A to indicate truncation AND A ; Clear carry RET RDFAIL: POP HL POP BC POP IX AND A JR NZ, ERROR ; Otherwise end of file, we're done RET ; Carry already clear ERROR: SCF RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Rewind file ; HL - Pointer to file struct ;----------------------------------------------------------------------- FS_REWIND:: #local PUSH HL POP IX LD A, (IX+FS_FLAGS) ; Check the file is open AND 1 RET Z ; File is not open XOR A LD (IX+FS_SECT), A ; Sector within cluster LD (IX+FS_OFFSET+0), A LD (IX+FS_OFFSET+1), A LD (IX+FS_OFFSET+2), A LD (IX+FS_OFFSET+3), A ; Clear offset within file CALL FILE_GET_DIRENT ; Re open directory entry (for start cluster) LD DE, FATDIR_START_CLUSTER ADD HL, DE LD BC, (HL) ; Read in start cluster LD (IX+FS_CLUST), BC ; Save start cluster LD A, B OR C ; Check if start cluster is 0 (empty file) JR Z, SETEOF LD A, (IX+FS_FLAGS) ; Read in flags AND 07Fh ; Clear EOF flag LD (IX+FS_FLAGS), A RET SETEOF: LD A, (IX+FS_FLAGS) ; Read in flags OR 080h ; Set EOF flag LD (IX+FS_FLAGS), A RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Create a new file with the specified name ; HL - Pointer to FS struct with name filled in ;----------------------------------------------------------------------- FS_CREATE:: #local ; PUSHALL ; CALL PRINTI ; .ascii ""FS: DEBUG FS_CREATE: "",10,13,0 ; POPALL PUSH HL ; Save filename/struct ; First check if the file already exists CALL FAT_FINDFILE ; Search for file JP NC, EXISTS ; Fail if file already exists ; Find first free or deleted entry LD HL, FAT_ROOTLBA ; Start of root directory LD DE, LBA CALL COPY32 LD HL, SECTOR CALL CF_READ ; First sector of root directory LD BC, (BPB_DIRENTS) ; Entries in root directory LD HL, SECTOR ; Start of our sector buffer POP IX ; Save filename back into IX PUSH BC ; (1) Save entries DIRLOOP: ; PUSH HL ; LD A,'.' \\ CALL PRINTCH ; POP HL LD A, (HL) ; Check first byte of name CP 0E5h ; Deleted entry JR Z, FOUND AND A ; Empty entry JR Z, FOUND POP BC ; (1) Restore counter DEC BC ; Dec counter LD A, B OR C JP Z, NOSPACE ; If no entries left then unable to create PUSH BC ; (1) Save counter LD DE, DIRENTSIZ ADD HL, DE ; Advance to the next directory entry LD DE, SECTOR+512 ; End of sector CMP16 DE ; Compare HL with DE JR C, NOLOAD ; If < SECTOR+512 then we don't need to load next ; Otherwise Load next sector LD HL, LBA LD DE, 1 CALL ADD32_16 ; Increment LBA LD HL, SECTOR CALL CF_READ LD HL, SECTOR ; Reset HL NOLOAD: JP DIRLOOP ; FOUND: POP BC ; (1) Pop counter ; Found a free entry point (in HL) ; Initialize this entry PUSH HL ; Save pointer to entry PUSH IX POP DE LD B, 11 COPYNAME: ; Copy filename to entry LD A, (DE) LD (HL), A INC HL INC DE DJNZ COPYNAME XOR A LD (HL), A \\ INC HL ; 0B Attributes LD (HL), A \\ INC HL ; 0C Unused/extra attributes LD (HL), A \\ INC HL ; 0D Unused/Fine create time LD (HL), A \\ INC HL ; 0E Unused LD (HL), A \\ INC HL ; 0F Unused LD (HL), A \\ INC HL ; 10 Unused LD (HL), A \\ INC HL ; 11 Unused LD (HL), A \\ INC HL ; 12 Unused LD (HL), A \\ INC HL ; 13 Unused LD (HL), A \\ INC HL ; 14 Unused LD (HL), A \\ INC HL ; 15 Unused LD (HL), A \\ INC HL ; 16 (2) Last modified time LD (HL), A \\ INC HL ; 17 LD (HL), A \\ INC HL ; 18 (2) Last modified date LD (HL), A \\ INC HL ; 19 LD (HL), A \\ INC HL ; 1a (2) Start cluster LD (HL), A \\ INC HL ; 1b LD (HL), A \\ INC HL ; 1c (4) File length LD (HL), A \\ INC HL ; 1d LD (HL), A \\ INC HL ; 1e LD (HL), A \\ INC HL ; 1f LD HL, SECTOR CALL CF_WRITE CALL PRINTNL POP HL ; Return pointer to entry AND A ; Clear carry RET NOSPACE: ; No free entries left EXISTS: CALL PRINTNL SCF ; File already exists RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Delete the file with the specified name ; HL - Pointer to FS struct with name filled in ;----------------------------------------------------------------------- FS_DELETE:: #local ; PUSHALL ; CALL PRINTI ; .ascii ""FS: DEBUG FS_DELETE:"",10,13,0 ; POPALL CALL FAT_FINDFILE ; Search for file JP C, FAIL ; Fail if file not found ; HL points to directory entry of file LD (HL), 0E5h ; Mark file as deleted LD DE, ENT_CLUST ; Offset to cluster ADD HL, DE LD BC, (HL) ; Read in starting cluster ; PUSH HL \\ PUSH BC ; CALL PRINTWORD ; LD A, ""-"" \\ CALL PRINTCH ; POP BC \\ POP HL PUSH BC ; Save cluster LD (HL), 0 \\ INC HL ; Clear starting cluster LD (HL), 0 LD HL, SECTOR CALL CF_WRITE ; Write updated dir to disk POP DE ; Restore current cluster CLEARLOOP: LD A, D OR E JR Z, DONE ; Check is already empty PUSH DE ; Save current cluster CALL FAT_GET ; Value of next cluster in chain POP HL ; Previous cluster EX DE, HL ; Previous cluster into DE LD BC, 0000h ; Mark cluster as free PUSH HL ; Save next cluster CALL FAT_SET ; previous cluster now marked as free POP DE ; Next cluster ; PUSH DE ; PUSH DE \\ POP BC ; CALL PRINTWORD ; LD A, '-' \\ CALL PRINTCH ; POP DE ; Now check if we're at the end of the chain LD A, 0FFh CP D ; FF - D JR NZ, CLEARLOOP ; < FF00 ; Cluster >FF00 LD A, 0F5h CP E JR NC, CLEARLOOP ; Cluster < FFF5 DONE: ; File is empty, no need to do any more. ; CALL PRINTNL AND A RET FAIL: SCF ; No such file RET #endlocal ;----------------------------------------------------------------------- ;----------------------------------------------------------------------- ; Truncate a file to the specified number of bytes ; HL - Pointer to FS struct with name filled in (must not be open) ; DE - Pointer to dword (4 byte) length ;----------------------------------------------------------------------- FS_TRUNCATE:: #local PUSH DE CALL FAT_FINDFILE ; Search for file JP C, FAIL ; Fail if file not found ; HL points to directory entry of file PUSH HL POP IX ; Directory entry POP IY ; Pointer to new length LD HL, (IX+ENT_FS+2) ; High word of file size LD BC, (IY+2) ; High word of new size LD (IX+ENT_FS+2), BC ; Update size CMP16 BC JR C, FAIL2 ; New size > cur size JR Z, TEST2 LD HL, (IX+ENT_FS) ; Low word LD BC, (IY) LD (IX+ENT_FS), BC ; Update size JR FINISH TEST2: LD HL, (IX+ENT_FS) ; Low word LD BC, (IY) LD (IX+ENT_FS), BC ; Update size CMP16 BC JR C, FAIL2 ; New size > cur size FINISH: LD HL, SECTOR CALL CF_WRITE ; Write updated directory entry ; Now we need to truncate the FAT chain if needed ; IY contains a pointer to the new length still LD DE, (IX+ENT_CLUST) ; Starting cluster of file ; First test if the length is 0, in which case we need to ; free the entire file LD BC, (IY) LD A, B OR C LD BC, (IY+2) OR B OR C JR NZ, NOFIRST ; DE is the first cluster, we need to clear the entire chain LD BC, 0 LD (IX+ENT_CLUST), BC ; Clear starting cluster PUSH DE ; Save start LD HL, SECTOR CALL CF_WRITE ; Update directory entry POP DE ; Clear the chain ;UNFINISHED NOFIRST: ; Follow the chain until size < 0, then clear to end PUSH DE ; Save current CALL FAT_GET ; Get next ;UNFINISHED FAIL: POP DE FAIL2: SCF RET #endlocal ;----------------------------------------------------------------------- #endlocal ",16193,True,3004.7840687749913,median "############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 6, 0x90 .globl _k0_cpMontSqr1024_avx2 _k0_cpMontSqr1024_avx2: push %rbx push %rbp push %r12 push %r13 push %r14 sub $(64), %rsp movslq %ecx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rcx,8) vmovdqu %ymm11, (%rdx,%rcx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) movq %rcx, (24)(%rsp) movq %r8, (32)(%rsp) mov $(40), %rcx mov %r9, %rdi movq %rdi, (48)(%rsp) lea (%rdi,%rcx,8), %rbx lea (%rbx,%rcx,8), %r9 movq %r9, (40)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_1 .p2align 6, 0x90 .Lsqr1024_loop4gas_1: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_1: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_1 movq (48)(%rsp), %rdi movq (16)(%rsp), %rcx movq (32)(%rsp), %r8 mov $(38), %r9 movq (%rdi), %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rdi), %ymm1 vmovdqu (64)(%rdi), %ymm2 vmovdqu (96)(%rdi), %ymm3 vmovdqu (128)(%rdi), %ymm4 vmovdqu (160)(%rdi), %ymm5 vmovdqu (192)(%rdi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rdi), %ymm7 vmovdqu (256)(%rdi), %ymm8 vmovdqu (288)(%rdi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_1: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_1 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rdi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rdi), %ymm14, %ymm9 add $(32), %rdi sub $(2), %r9 jnz .Lreduction_loopgas_1 .Lexit_reduction_loopgas_1: movq (%rsp), %rdi movq %r12, (%rdi) movq %r13, (8)(%rdi) vmovdqu %ymm1, (16)(%rdi) vmovdqu %ymm2, (48)(%rdi) vmovdqu %ymm3, (80)(%rdi) vmovdqu %ymm4, (112)(%rdi) vmovdqu %ymm5, (144)(%rdi) vmovdqu %ymm6, (176)(%rdi) vmovdqu %ymm7, (208)(%rdi) vmovdqu %ymm8, (240)(%rdi) vmovdqu %ymm9, (272)(%rdi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_1: addq (%rdi), %rax add $(8), %rdi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (-8)(%rdi) sub $(1), %r9 jg .Lnorm_loopgas_1 movq %rax, (%rdi) add $(64), %rsp vzeroupper pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .p2align 6, 0x90 .globl _k0_cpSqr1024_avx2 _k0_cpSqr1024_avx2: push %rbx sub $(48), %rsp movslq %edx, %rdx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rdx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) mov $(40), %rdx mov %rcx, %rdi movq %rdi, (32)(%rsp) lea (%rdi,%rdx,8), %rbx lea (%rbx,%rdx,8), %r9 movq %r9, (24)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_2 .p2align 6, 0x90 .Lsqr1024_loop4gas_2: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_2: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_2 movq (32)(%rsp), %rsi movq (%rsp), %rdi mov $(76), %r9 xor %rax, %rax .Lnorm_loopgas_2: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_2 movq %rax, (%rdi) add $(48), %rsp vzeroupper pop %rbx ret .p2align 6, 0x90 .globl _k0_cpMontRed1024_avx2 _k0_cpMontRed1024_avx2: push %r12 push %r13 movslq %ecx, %r9 mov %rdx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rdx,%r9,8) movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_3: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_3 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rsi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rsi), %ymm14, %ymm9 add $(32), %rsi sub $(2), %r9 jnz .Lreduction_loopgas_3 .Lexit_reduction_loopgas_3: movq (%rsp), %rsi movq %r12, (%rsi) movq %r13, (8)(%rsi) vmovdqu %ymm1, (16)(%rsi) vmovdqu %ymm2, (48)(%rsi) vmovdqu %ymm3, (80)(%rsi) vmovdqu %ymm4, (112)(%rsi) vmovdqu %ymm5, (144)(%rsi) vmovdqu %ymm6, (176)(%rsi) vmovdqu %ymm7, (208)(%rsi) vmovdqu %ymm8, (240)(%rsi) vmovdqu %ymm9, (272)(%rsi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_3: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_3 movq %rax, (%rdi) vzeroupper pop %r13 pop %r12 ret ",16367,True,4223.362575477314,median "// Uncomment this to enable Arduino OTA #define UseOTA #include #include #include #include #include #ifdef UseOTA #include #include #include #endif #include ""config.h"" // Neopixel Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int ledArray[NUMPIXELS][3]; // Custom array to allow us to buffer changes before sending them // Wifi WiFiClient espClient; // MQTT PubSubClient client(espClient); const uint8_t bufferSize = 20; char buffer[bufferSize]; // Reconnect Variables unsigned long reconnectStart = 0; unsigned long lastReconnectMessage = 0; unsigned long messageInterval = 1000; int currentReconnectStep = 0; boolean offlineMode = true; boolean recovered = false; // Device specific variables (currently only used for animations specific to my stair LEDs, leave false if you are not me) boolean stairs = false; int stairPixelArray[13]; int stairPixelArrayLength = 13; // Sun Position const char* sunPositionTopic = ""sunPosition""; // This will be sent as a retained message so will be updated upon boot int sunPosition = 0; // Other unsigned long availabilityPublishTimer = 0; int availabilityPublishInterval = 30000; #pragma region Global Animation Variables const int numModes = 13; // This is the total number of modes int currentMode; // 0 int brightness = 255; int rgbValueOne[3]; // 1 int rgbValueTwo[3]; // 2 unsigned long colourDelay; // 3 int colourJump; // 4 unsigned long pixelDelay; // 5 int pixelJump; // 6 boolean randomise; // 7 unsigned long loopDelay; // 8 float highPixelDelay; // 9 float multiplier; // 10 int chance; // 11 int trailLength; // 12 unsigned long previousMillis; boolean flipFlop; int currentStep; int currentPixel; int currentColor; unsigned long colourDelaySeed; int colourJumpSeed; unsigned long pixelDelaySeed; unsigned long loopDelaySeed; float highPixelDelaySeed; float multiplierSeed; #pragma endregion void resetGlobalAnimationVariables() { currentMode = 0; for (int colour = 0;colour < 3;colour ++) { rgbValueOne[colour] = 0; rgbValueTwo[colour] = 255; } colourDelay = 0; colourJump = 1; pixelDelay = 0; pixelJump = 1; randomise = false; loopDelay = 0; highPixelDelay = 0; multiplier = 1; previousMillis = 0; flipFlop = 0; currentStep = 0; currentPixel = 0; trailLength = 0; colourDelaySeed = 0; colourJumpSeed = 1; pixelDelaySeed = 0; loopDelaySeed = 0; highPixelDelaySeed = 0; multiplierSeed = 0; chance = 100; } void setModeDefaults(int mode) { // All Off // No additional defaults // All On if (mode == 1) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; colourDelay = 2; } // Fade To Colour else if (mode == 2) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 255; colourDelay = 20; } // Strobe else if (mode == 3) { colourDelay = 40; } // Fire else if (mode == 4) { colourDelay = 20; } // Colour Phase else if (mode == 5) { colourDelay = 30; } // Sparkle else if (mode == 6) { rgbValueTwo[0] = 150; rgbValueTwo[1] = 150; rgbValueTwo[2] = 150; colourJump = 5; } // Shoot else if (mode == 7) { rgbValueTwo[0] = 50; rgbValueTwo[1] = 50; rgbValueTwo[2] = 255; colourJump = 20; loopDelay = 10000; highPixelDelay = 5; multiplier = 1.15; randomise = true; trailLength = 7; } // Mode 8 else if (mode == 8) { rgbValueTwo[0] = 100; rgbValueTwo[1] = 100; rgbValueTwo[2] = 255; colourDelay = 4; chance = 15000; } // Stairs On else if (mode == 9) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; } // Stair Shutdown else if (mode == 10) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; } // Stair Startup else if (mode == 11) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; } // Rainbow else if (mode == 12 || mode == 13) { colourDelay = 50; currentColor = 0; previousMillis = millis(); } } void reconnect() { // IF statements used to complete process in single loop if possible // 0 - Turn the LED on and log the reconnect start time if (currentReconnectStep == 0) { digitalWrite(LED_BUILTIN, LOW); reconnectStart = millis(); currentReconnectStep++; // If the ESP is reconnecting after a connection failure then wait a second before starting the reconnect routine if (offlineMode == false) { delay(1000); } } // If we've previously had a connection and have been trying to connect for more than 2 minutes then restart the ESP. // We don't do this if we've never had a connection as that means the issue isn't temporary and we don't want the relay // to turn off every 2 minutes. if (offlineMode == false && ((millis() - reconnectStart) > 120000)) { Serial.println(""Restarting!""); ESP.restart(); } // 1 - Check WiFi Connection if (currentReconnectStep == 1) { if (WiFi.status() != WL_CONNECTED) { if ((millis() - lastReconnectMessage) > messageInterval) { Serial.print(""Awaiting WiFi Connection (""); Serial.print((millis() - reconnectStart) / 1000); Serial.println(""s)""); lastReconnectMessage = millis(); } } else { Serial.println(""WiFi connected!""); Serial.print(""SSID: ""); Serial.print(WiFi.SSID()); Serial.println(""""); Serial.print(""IP address: ""); Serial.println(WiFi.localIP()); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 2; } } // 2 - Check MQTT Connection if (currentReconnectStep == 2) { if (!client.connected()) { if ((millis() - lastReconnectMessage) > messageInterval) { Serial.print(""Awaiting MQTT Connection (""); Serial.print((millis() - reconnectStart) / 1000); Serial.println(""s)""); lastReconnectMessage = millis(); String clientId = ""ESP8266Client-""; clientId += String(random(0xffff), HEX); client.connect(clientId.c_str(), mqttUser, mqttPass, availabilityTopic, 0, true, ""0""); } // Check the MQTT again and go forward if necessary if (client.connected()) { Serial.println(""MQTT connected!""); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 3; } // Check the WiFi again and go back if necessary else if (WiFi.status() != WL_CONNECTED) { currentReconnectStep = 1; } } else { Serial.println(""MQTT connected!""); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 3; } } // 3 - All connected, turn the LED back on and then subscribe to the MQTT topics if (currentReconnectStep == 3) { digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off publishAvailability(); // MQTT Subscriptions client.subscribe(sunPositionTopic); client.subscribe(rgbCommandTopic); client.subscribe(commandlTopic); client.subscribe(recoveryTopic); if (offlineMode == true) { offlineMode = false; Serial.println(""Offline Mode Deactivated""); Serial.println(""""); } currentReconnectStep = 0; // Reset } } #pragma region MiscFunctions int* randomColour() { // Not yet used but could be useful static int aRandomColour[3]; aRandomColour[0] = random(255); aRandomColour[1] = random(255); aRandomColour[2] = random(255); return aRandomColour; } void updateLedArray_singleColour(int targetColour[3]) { for (int i = 0; i < NUMPIXELS; i++) { ledArray[i][0] = targetColour[0]; ledArray[i][1] = targetColour[1]; ledArray[i][2] = targetColour[2]; } } void updateStripFromLedArray() { for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, pixels.Color(ledArray[i][0], ledArray[i][1], ledArray[i][2])); } pixels.show(); } void publishState() { if (currentMode == 0) { client.publish(stateTopic, ""0"", true); } else { client.publish(stateTopic, ""1"", true); } } void publishColour() { snprintf(buffer, bufferSize, ""%d,%d,%d"", rgbValueTwo[0], rgbValueTwo[1], rgbValueTwo[2]); client.publish(rgbStateTopic, buffer); } void publishAvailability() { client.publish(availabilityTopic, ""1"", true); } void publishRecovery() { DynamicJsonBuffer jsonBuffer; // Reserve memory space (https://bblanchon.github.io/ArduinoJson/) JsonObject& root = jsonBuffer.createObject(); // Create the JSON object // Always publish the mode so that there is a current retained message root[""0""] = currentMode; // Only publish the other variables if they are non-default if (rgbValueOne[0] != 0 | rgbValueOne[1] != 0 | rgbValueOne[2] != 0) { JsonArray& rgbValueOneArray = root.createNestedArray(""1""); rgbValueOneArray.add(rgbValueOne[0]); rgbValueOneArray.add(rgbValueOne[1]); rgbValueOneArray.add(rgbValueOne[2]); } if (rgbValueTwo[0] != 255 | rgbValueTwo[1] != 255 | rgbValueTwo[2] != 255) { JsonArray& rgbValueTwoArray = root.createNestedArray(""2""); rgbValueTwoArray.add(rgbValueTwo[0]); rgbValueTwoArray.add(rgbValueTwo[1]); rgbValueTwoArray.add(rgbValueTwo[2]); } if (colourDelay != 0) { root[""3""] = colourDelay; } if (colourJump != 1) { root[""4""] = colourJump; } if (pixelDelay != 0) { root[""5""] = pixelDelay; } if (pixelJump != 1) { root[""6""] = pixelJump; } if (randomise != false) { root[""7""] = randomise; } if (loopDelay != 0) { root[""8""] = loopDelay; } if (highPixelDelay != 0) { root[""9""] = highPixelDelay; } if (multiplier != 1) { root[""10""] = multiplier; } if (chance != 100) { root[""11""] = chance; } if (trailLength != 0) { root[""12""] = trailLength; } char buffer[256]; root.printTo(buffer, sizeof(buffer)); client.publish(recoveryTopic, buffer, true); } void publishAll() { publishColour(); publishState(); publishRecovery(); publishAvailability(); } #pragma endregion #pragma region Modes void allRgbValueOne() { if (flipFlop == 0) { // This is used updateLedArray_singleColour(rgbValueOne); updateStripFromLedArray(); flipFlop = 1; } } void allRgbValueTwo() { if (flipFlop == 0) { // This is used updateLedArray_singleColour(rgbValueTwo); updateStripFromLedArray(); flipFlop = 1; } } void stairsOn() { if (flipFlop == 0) { // This isn't used updateLedArray_singleColour(rgbValueOne); for (int i = 0; i < 3; i++) { ledArray[3][i] = rgbValueTwo[i]; ledArray[12][i] = rgbValueTwo[i]; ledArray[21][i] = rgbValueTwo[i]; ledArray[30][i] = rgbValueTwo[i]; ledArray[40][i] = rgbValueTwo[i]; ledArray[49][i] = rgbValueTwo[i]; ledArray[58][i] = rgbValueTwo[i]; ledArray[68][i] = rgbValueTwo[i]; ledArray[77][i] = rgbValueTwo[i]; ledArray[86][i] = rgbValueTwo[i]; ledArray[96][i] = rgbValueTwo[i]; ledArray[105][i] = rgbValueTwo[i]; ledArray[111][i] = rgbValueTwo[i]; } updateStripFromLedArray(); } } void stairsOff() { if (flipFlop == 0) { // This isn't used updateLedArray_singleColour(rgbValueOne); if (sunPosition == 0) { rgbValueTwo[0] = 2; rgbValueTwo[1] = 1; rgbValueTwo[2] = 0; } else if (sunPosition == 1) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; } for (int i = 0; i < 3; i++) { ledArray[0][i] = rgbValueTwo[i]; ledArray[9][i] = rgbValueTwo[i]; ledArray[18][i] = rgbValueTwo[i]; ledArray[27][i] = rgbValueTwo[i]; ledArray[37][i] = rgbValueTwo[i]; ledArray[46][i] = rgbValueTwo[i]; ledArray[55][i] = rgbValueTwo[i]; ledArray[65][i] = rgbValueTwo[i]; ledArray[74][i] = rgbValueTwo[i]; ledArray[83][i] = rgbValueTwo[i]; ledArray[93][i] = rgbValueTwo[i]; ledArray[102][i] = rgbValueTwo[i]; ledArray[111][i] = rgbValueTwo[i]; } updateStripFromLedArray(); } } void fadeToColour(bool useFlipFlop = false) { if (flipFlop == 0) { // This is used unsigned long currentMillis = millis(); if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { int count = 0; // Reset the count for (int pixel = 0;pixel < NUMPIXELS;pixel ++){ // For every pixel if (ledArray[pixel][0] != rgbValueTwo[0] | ledArray[pixel][1] != rgbValueTwo[1] | ledArray[pixel][2] != rgbValueTwo[2]) { for (int colour = 0;colour < 3;colour++) { // For each colour if (ledArray[pixel][colour] < rgbValueTwo[colour]) { // If the colour value is less that it should be ledArray[pixel][colour] += 1; // Add 1 } else if (ledArray[pixel][colour] > rgbValueTwo[colour]) { // If the colour value is more that it should be ledArray[pixel][colour] -= 1; // Subtract 1 } } pixels.setPixelColor(pixel, pixels.Color(ledArray[pixel][0], ledArray[pixel][1], ledArray[pixel][2])); } else { count ++; } } pixels.show(); if (count == NUMPIXELS && useFlipFlop == true) { flipFlop = 1; } previousMillis = currentMillis; } } } void fadePixelToTargetColour(int pixelNo) { if (millis() - previousMillis >= colourDelay) { if (ledArray[pixelNo][0] != rgbValueTwo[0] | ledArray[pixelNo][1] != rgbValueTwo[1] | ledArray[pixelNo][2] != rgbValueTwo[2]) { for (int colour = 0; colour < 3; colour++) { // For each colour if (ledArray[pixelNo][colour] < rgbValueTwo[colour]) { // If the colour value is less that it should be ledArray[pixelNo][colour] += colourJump; // Add the colour jump if (ledArray[pixelNo][colour] > rgbValueTwo[colour]) { // Jump back if we've jumped over it ledArray[pixelNo][colour] = rgbValueTwo[colour]; } } else if (ledArray[pixelNo][colour] > rgbValueTwo[colour]) { // If the colour value is more that it should be ledArray[pixelNo][colour] -= colourJump; // Subtract the colour jump if (ledArray[pixelNo][colour] < rgbValueTwo[colour]) { // Jump back if we've jumped under it ledArray[pixelNo][colour] = rgbValueTwo[colour]; } } } pixels.setPixelColor(pixelNo, pixels.Color(ledArray[pixelNo][0], ledArray[pixelNo][1], ledArray[pixelNo][2])); pixels.show(); } else { currentStep++; } previousMillis = millis(); } } void fadePixelToBaseColour(int pixelNo) { if (millis() - previousMillis >= colourDelay) { if (ledArray[pixelNo][0] != rgbValueOne[0] | ledArray[pixelNo][1] != rgbValueOne[1] | ledArray[pixelNo][2] != rgbValueOne[2]) { for (int colour = 0; colour < 3; colour++) { // For each colour if (ledArray[pixelNo][colour] < rgbValueOne[colour]) { // If the colour value is less that it should be ledArray[pixelNo][colour] += colourJump; // Add the colour jump if (ledArray[pixelNo][colour] > rgbValueOne[colour]) { // Jump back if we've jumped over it ledArray[pixelNo][colour] = rgbValueOne[colour]; } } else if (ledArray[pixelNo][colour] > rgbValueOne[colour]) { // If the colour value is more that it should be ledArray[pixelNo][colour] -= colourJump; // Subtract the colour jump if (ledArray[pixelNo][colour] < rgbValueOne[colour]) { // Jump back if we've jumped under it ledArray[pixelNo][colour] = rgbValueOne[colour]; } } } pixels.setPixelColor(pixelNo, pixels.Color(ledArray[pixelNo][0], ledArray[pixelNo][1], ledArray[pixelNo][2])); pixels.show(); } else { currentStep++; } previousMillis = millis(); } } void strobe() { unsigned long currentMillis = millis(); if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { if (flipFlop == 1) { updateLedArray_singleColour(rgbValueTwo); updateStripFromLedArray(); flipFlop = !flipFlop; } else if (flipFlop == 0) { updateLedArray_singleColour(rgbValueOne); updateStripFromLedArray(); flipFlop = !flipFlop; } previousMillis = currentMillis; } } void fire(int Cooling, int Sparking, int SpeedDelay) { // Need to tailor variables and update LED array static byte heat[NUMPIXELS]; int cooldown; // Step 1. Cool down every cell a little for( int i = 0; i < NUMPIXELS; i++) { cooldown = random(0, ((Cooling * 10) / NUMPIXELS) + 2); if(cooldown>heat[i]) { heat[i]=0; } else { heat[i]=heat[i]-cooldown; } } // Step 2. Heat from each cell drifts 'up' and diffuses a little for( int k= NUMPIXELS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3; } // Step 3. Randomly ignite new 'sparks' near the bottom if( random(255) < Sparking ) { int y = random(7); heat[y] = heat[y] + random(160,255); //heat[y] = random(160,255); } // Step 4. Convert heat to LED colors for( int j = 0; j < NUMPIXELS; j++) { setPixelHeatColor(j, heat[j] ); } pixels.show(); delay(SpeedDelay); } void setPixelHeatColor (int Pixel, byte temperature) { // Scale 'heat' down from 0-255 to 0-191 byte t192 = round((temperature/255.0)*191); // calculate ramp up from byte heatramp = t192 & 0x3F; // 0..63 heatramp <<= 2; // scale up to 0..252 // figure out which third of the spectrum we're in: if( t192 > 0x80) { // hottest pixels.setPixelColor(Pixel, 255, 255, heatramp); } else if( t192 > 0x40 ) { // middle pixels.setPixelColor(Pixel, 255, heatramp, 0); } else { // coolest pixels.setPixelColor(Pixel, heatramp, 0, 0); } } // Fire Source: https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#fire void colourPhase() { if (flipFlop == 1) { // fadeToColour will set flipFlop to 1 when complete so we use this to update the current step then reset the flipFlop currentStep++; flipFlop = 0; if (currentStep > 5) { // If the current step is greater than the number of steps we reset currentStep = 0; } } if (currentStep == 0) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 1) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 255; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 2) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 255; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 3) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 255; rgbValueTwo[2] = 255; fadeToColour(true); } else if (currentStep == 4) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 255; fadeToColour(true); } else if (currentStep == 5) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 255; rgbValueTwo[2] = 255; fadeToColour(true); } } void sparkle() { unsigned long currentMillis = millis(); // Initiator if (currentStep == 0) { allRgbValueOne(); // Sets all LEDs to rgbValueOne colourDelaySeed = colourDelay; colourJumpSeed = colourJump; pixelDelaySeed = pixelDelay; currentStep ++; } // Pixel Delay if (currentStep == 1) { if (previousMillis > currentMillis || currentMillis - previousMillis >= pixelDelay) { if (randomise == true) { pixelDelay = random(pixelDelaySeed); colourDelay = random(colourDelaySeed); // Only change between pixels so the light doesn't waver colourJump = random(1,colourJumpSeed); // Min of 1 otherwise there's a chance the loop will stop } previousMillis = currentMillis; currentStep ++; } } // Roll Up if (currentStep == 2 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay )) { if (ledArray[currentPixel][0] != rgbValueTwo[0] | ledArray[currentPixel][1] != rgbValueTwo[1] | ledArray[currentPixel][2] != rgbValueTwo[2]) { // If the pixel hasn't reached peak for (int i = 1;!(i > colourJump);i++) { for (int col = 0;col < 3;col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueTwo[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueTwo[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep ++; } previousMillis = currentMillis; } // Roll Down if (currentStep == 3 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay )) { if (ledArray[currentPixel][0] != rgbValueOne[0] | ledArray[currentPixel][1] != rgbValueOne[1] | ledArray[currentPixel][2] != rgbValueOne[2]) { // If the pixel hasn't reached base for (int i = 1;!(i > colourJump);i++) { for (int col = 0;col < 3;col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueOne[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueOne[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep = 1; // Go back to the mid pixel wait currentPixel = random(NUMPIXELS); } previousMillis = currentMillis; } } void rain() { unsigned long currentMillis = millis(); if (random(chance) == 1) { int randomPixel = random(NUMPIXELS); ledArray[randomPixel][0] = rgbValueTwo[0]; ledArray[randomPixel][1] = rgbValueTwo[1]; ledArray[randomPixel][2] = rgbValueTwo[2]; updateStripFromLedArray(); } if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { for (int pixel = 0;pixel < NUMPIXELS;pixel ++){ // For every pixel for (int i = 1;!(i > colourJump);i++) { if (ledArray[pixel][0] != rgbValueOne[0] | ledArray[pixel][1] != rgbValueOne[1] | ledArray[pixel][2] != rgbValueOne[2]) { for (int colour = 0;colour < 3;colour++) { // For each colour if (ledArray[pixel][colour] < rgbValueOne[colour]) { // If the colour value is less that it should be ledArray[pixel][colour] += 1; // Add 1 } else if (ledArray[pixel][colour] > rgbValueOne[colour]) { // If the colour value is more that it should be ledArray[pixel][colour] -= 1; // Subtract 1 } } pixels.setPixelColor(pixel, pixels.Color(ledArray[pixel][0],ledArray[pixel][1],ledArray[pixel][2])); } } } updateStripFromLedArray(); previousMillis = currentMillis; } } void shoot() { unsigned long currentMillis = millis(); // Initiator if (currentStep == 0) { allRgbValueOne(); // Sets all LEDs to rgbValueOne loopDelaySeed = loopDelay; colourJumpSeed = colourJump; multiplierSeed = multiplier; highPixelDelaySeed = highPixelDelay; // Seeded because it's multiplied not because it's randomised currentStep++; } // Loop Delay if (currentStep == 1) { if (previousMillis > currentMillis || currentMillis - previousMillis >= loopDelay) { if (randomise == true) { loopDelay = random(loopDelaySeed); colourJump = random(1, colourJumpSeed); float multiplierSeedX = (multiplier * 100.00); multiplier = (random(multiplierSeedX * 0.95, multiplierSeedX * 1.05)) / 100.00; // +-5% - Best at 1.25 } highPixelDelay = highPixelDelaySeed; previousMillis = currentMillis; currentStep++; } } // Pixel Delay if (currentStep == 2) { if (previousMillis > currentMillis || currentMillis - previousMillis >= pixelDelay) { previousMillis = currentMillis; currentStep++; } } // Roll Up if (currentPixel > (NUMPIXELS - 1)) { // Skip the roll up if we're after the last pixel (trail) currentStep = 4; } if (currentStep == 3 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay)) { if (ledArray[currentPixel][0] != rgbValueTwo[0] | ledArray[currentPixel][1] != rgbValueTwo[1] | ledArray[currentPixel][2] != rgbValueTwo[2]) { // If the pixel hasn't reached peak for (int i = 1; !(i > colourJump); i++) { for (int col = 0; col < 3; col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueTwo[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueTwo[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep++; } previousMillis = currentMillis; } // High Pixel Delay if (currentStep == 4) { if (previousMillis > currentMillis || currentMillis - previousMillis >= highPixelDelay) { previousMillis = currentMillis; highPixelDelay = (highPixelDelay * multiplier); currentStep++; } } // Roll Down if (currentStep == 5 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay)) { if (trailLength == 0) { if (ledArray[currentPixel][0] != rgbValueOne[0] | ledArray[currentPixel][1] != rgbValueOne[1] | ledArray[currentPixel][2] != rgbValueOne[2]) { // If the pixel hasn't reached base for (int i = 1; !(i > colourJump); i++) { for (int col = 0; col < 3; col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueOne[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueOne[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { if (currentPixel == (NUMPIXELS - 1)) { currentPixel = 0; currentStep = 1; } else { currentPixel++; currentStep = 2; } } } else { Serial.println(""---""); Serial.print(""currentPixel = ""); Serial.println(currentPixel); int currentTrailPixel = currentPixel; // Start with the current pixel as we're about to put the next one up while (currentTrailPixel >= (currentPixel - (trailLength + 1))) { if (currentTrailPixel >= 0 && currentTrailPixel < NUMPIXELS) { Serial.print(""trailPixelToUpdate = ""); Serial.println(currentTrailPixel); if (currentTrailPixel > (currentPixel - trailLength)) { // This is the trail int trailDifference = (currentPixel - currentTrailPixel); float trailPercentage = ((1.0 / trailLength) * (trailLength - trailDifference)); Serial.print(""trailPercentage = ""); Serial.println(trailPercentage); ledArray[currentTrailPixel][0] = (rgbValueTwo[0] * trailPercentage); ledArray[currentTrailPixel][1] = (rgbValueTwo[1] * trailPercentage); ledArray[currentTrailPixel][2] = (rgbValueTwo[2] * trailPercentage); } else { // Clear the trail ledArray[currentTrailPixel][0] = rgbValueOne[0]; ledArray[currentTrailPixel][1] = rgbValueOne[1]; ledArray[currentTrailPixel][2] = rgbValueOne[2]; } } currentTrailPixel = (currentTrailPixel - 1); } updateStripFromLedArray(); if (currentPixel == ((NUMPIXELS - 1) + trailLength)) { currentPixel = 0; currentStep = 1; } else { currentPixel++; currentStep = 2; } } previousMillis = currentMillis; } } void stairStartup() { if (currentStep == 0) { allRgbValueOne(); // Turn all the lights off first currentPixel = 12; // Start at the end currentStep++; } else if (currentStep == 1) { fadePixelToTargetColour(stairPixelArray[currentPixel]); } else if (currentStep == 2) { if ((currentPixel - 1) <= -1) { // If we've done all the pixels currentStep = 4; } else if (millis() - previousMillis >= pixelDelay) { currentPixel--; currentStep = 1; } } else if (currentStep == 4) { currentMode = 9; // stairsOn setModeDefaults(currentMode); // No need to publish state as mode 10 is considered on anyway and so has already been published publishColour(); publishRecovery(); } } void stairShutdown() { // This step fades the top LED to red to indicate shutdown if (currentStep == 0) { fadePixelToTargetColour(111); } else if (currentStep == 1) { fadePixelToBaseColour(stairPixelArray[currentPixel]); } else if (currentStep == 2) { if ((currentPixel + 1) >= stairPixelArrayLength) { // If we've done all the pixels currentStep = 3; } else if (millis() - previousMillis >= pixelDelay) { currentPixel++; currentStep = 1; } } else if (currentStep == 3) { currentMode = 0; // Off setModeDefaults(currentMode); publishAll(); } } void rainbow(int rainbowMode) { static int colorVals[3]; unsigned long currentMillis = millis(); byte WheelPos; if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { for(int i=0; i MQTT Received""); #pragma region commandlTopic if (String(commandlTopic).equals(topic)) { if (length == 1) { // Off if ((char)payload[0] == '0') { resetGlobalAnimationVariables(); currentMode = 0; // Not required as 0 is set by the reset, left in for clarity setModeDefaults(currentMode); publishState(); publishRecovery(); } // On else if ((char)payload[0] == '1') { // Only turn on if currentMode is 0 if (currentMode == 0) { resetGlobalAnimationVariables(); currentMode = 1; setModeDefaults(currentMode); publishAll(); // State + Colour + Recovery } } // Toggle - Using a re-publish ensures any changes to the On / Off routines are used for the toggle as well else if ((char)payload[0] == '2') { if (currentMode == 0) { client.publish(commandlTopic, ""1""); } else { client.publish(commandlTopic, ""0""); } } // Cycle Modes else if ((char)payload[0] == '9') { int lastMode = currentMode; resetGlobalAnimationVariables(); currentMode = ++lastMode; if (currentMode > numModes) { currentMode = 0; } setModeDefaults(currentMode); publishAll(); } } else if ((char)payload[0] == '{') { // It's a JSON char message_buff[256]; // Max of 256 characters for (int i = 0; i < length; i++) { message_buff[i] = payload[i]; if (i == (length - 1)) { // If we're at the last character message_buff[i + 1] = '\\0'; // Add a string terminator to the next character } } DynamicJsonBuffer jsonBuffer; // Step 1: Reserve memory space (https://bblanchon.github.io/ArduinoJson/) JsonObject& root = jsonBuffer.parseObject(message_buff); // Step 2: Deserialize the JSON string if (!root.success()) { Serial.println(""parseObject() failed""); } else if (root.success()) { if (root.containsKey(""0"")) { resetGlobalAnimationVariables(); // Only do this if the mode changes currentMode = root[""0""]; setModeDefaults(currentMode); // Only do this if the mode changes // We don't publish the recovery message here as other variables might have changed without the mode changing and so we wait until later publishState(); publishColour(); } if (currentMode > numModes) { // If mode is greater than is possible, set to 0 currentMode = 0; } if (root.containsKey(""1"")) { rgbValueOne[0] = root[""1""][0]; rgbValueOne[1] = root[""1""][1]; rgbValueOne[2] = root[""1""][2]; flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. } if (root.containsKey(""2"")) { rgbValueTwo[0] = root[""2""][0]; rgbValueTwo[1] = root[""2""][1]; rgbValueTwo[2] = root[""2""][2]; flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. publishColour(); } if (root.containsKey(""3"")) { colourDelay = root[""3""]; } if (root.containsKey(""4"")) { colourJump = root[""4""]; } if (root.containsKey(""5"")) { pixelDelay = root[""5""]; } if (root.containsKey(""6"")) { pixelJump = root[""6""]; } if (root.containsKey(""7"")) { randomise = root[""7""]; } if (root.containsKey(""8"")) { loopDelay = root[""8""]; } if (root.containsKey(""9"")) { highPixelDelay = root[""9""]; } if (root.containsKey(""10"")) { multiplier = root[""10""]; } if (root.containsKey(""11"")) { chance = root[""11""]; } if (root.containsKey(""12"")) { trailLength = root[""12""]; } } publishRecovery(); } } #pragma endregion #pragma region rgbCommandTopic else if (String(rgbCommandTopic).equals(topic)) { String payloadString; for (uint8_t i = 0; i < length; i++) { payloadString.concat((char)payload[i]); } uint8_t firstIndex = payloadString.indexOf(','); uint8_t lastIndex = payloadString.lastIndexOf(','); uint8_t rgb_red = payloadString.substring(0, firstIndex).toInt(); if (rgb_red < 0 || rgb_red > 255) { return; } else { rgbValueTwo[0] = rgb_red; } uint8_t rgb_green = payloadString.substring(firstIndex + 1, lastIndex).toInt(); if (rgb_green < 0 || rgb_green > 255) { return; } else { rgbValueTwo[1] = rgb_green; } uint8_t rgb_blue = payloadString.substring(lastIndex + 1).toInt(); if (rgb_blue < 0 || rgb_blue > 255) { return; } else { rgbValueTwo[2] = rgb_blue; } flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. // No need to publish the state, it can't have changed. publishColour(); publishRecovery(); } #pragma endregion #pragma region sunPositionTopic else if (String(sunPositionTopic).equals(topic)) { if ((char)payload[0] == '0') { sunPosition = 0; } else if ((char)payload[0] == '1') { sunPosition = 1; } } #pragma endregion #pragma region recoveryTopic else if (String(recoveryTopic).equals(topic) && recovered == false) { char message_buff[256]; for (int i = 0; i < length; i++) { message_buff[i] = payload[i]; if (i == (length - 1)) { // If we're at the last character message_buff[i + 1] = '\\0'; // Add a string terminator to the next character } } StaticJsonBuffer<300> jsonBuffer; // Reserve memory space (https://bblanchon.github.io/ArduinoJson/) JsonObject& root = jsonBuffer.parseObject(message_buff); // Step 2: Deserialize the JSON string if (!root.success()) { Serial.println(""parseObject() failed""); } else if (root.success()) { if (root.containsKey(""0"")) { currentMode = root[""0""]; setModeDefaults(currentMode); // Only do this if the mode changes } if (currentMode > numModes) { // If mode is greater than is possible, set to 0 currentMode = 0; } if (root.containsKey(""1"")) { rgbValueOne[0] = root[""1""][0]; rgbValueOne[1] = root[""1""][1]; rgbValueOne[2] = root[""1""][2]; } if (root.containsKey(""2"")) { rgbValueTwo[0] = root[""2""][0]; rgbValueTwo[1] = root[""2""][1]; rgbValueTwo[2] = root[""2""][2]; publishColour(); } if (root.containsKey(""3"")) { colourDelay = root[""3""]; } if (root.containsKey(""4"")) { colourJump = root[""4""]; } if (root.containsKey(""5"")) { pixelDelay = root[""5""]; } if (root.containsKey(""6"")) { pixelJump = root[""6""]; } if (root.containsKey(""7"")) { randomise = root[""7""]; } if (root.containsKey(""8"")) { loopDelay = root[""8""]; } if (root.containsKey(""9"")) { highPixelDelay = root[""9""]; } if (root.containsKey(""10"")) { multiplier = root[""10""]; } if (root.containsKey(""11"")) { chance = root[""11""]; } if (root.containsKey(""12"")) { trailLength = root[""12""]; } // No need to publish recovery message as it would match the current settings anyway publishState(); publishColour(); flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again. } recovered = true; } #pragma endregion } void loop() { if (!client.connected()) { reconnect(); } else { client.loop(); } if (currentMode == 0) { if (stairs == true) { // Special Off Mode for Stairs stairsOff(); } else { allRgbValueOne(); // Normal } } else if (currentMode == 1) { fadeToColour(true); } else if (currentMode == 2) { fadeToColour(true); } else if (currentMode == 3) { strobe(); } else if (currentMode == 4) { fire(55,120,colourDelay); } else if (currentMode == 5) { colourPhase(); } else if (currentMode == 6) { sparkle(); } else if (currentMode == 7) { shoot(); } else if (currentMode == 8) { rain(); } else if (currentMode == 9) { stairsOn(); } else if (currentMode == 10) { stairShutdown(); } else if (currentMode == 11) { stairStartup(); } else if (currentMode == 12) { rainbow(1); } else if (currentMode == 13) { rainbow(2); } if ((millis() - availabilityPublishInterval) >= availabilityPublishTimer) { publishAvailability(); availabilityPublishTimer = millis(); } #ifdef UseOTA ArduinoOTA.handle(); #endif yield(); } ",12357,False,2404.519514168894,median "/* Bluetooth console for Keiser M3 ********************************** *********************************************************************/ #define VERSION ""1.1"" #include #include // nrf52 built-in bluetooth #include // OLED library #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C // For this hardware (nrf52840) should just be able to include Wire.h #include #endif #include ""options.h"" // Options of most interest to the end user #include ""globals.h"" #include ""bike_interface.h"" // Defines the hardware connections to the bike #include ""BLE_services.h"" // Flags/fields for the BLE services #include ""power_gear_tables.h"" #include ""calibration.h"" #include ""serial_commands.h"" #include ""param_store.h"" /********************************************************************** * Optional functions and debugging **********************************************************************/ //#define QUICKTIMEOUT // Quick timeout options for testing power saving functions //#define DEBUGGING // Activates debug code. Requires USE_SERIAL for any serial console bits. // Anything here is inserted into lever_check(), usually to avoid having to wait for some condition //#define LEVER_EXTRAS batt_pct = 19; batt_low = true; // Test the low battery indicator #ifdef QUICKTIMEOUT #define DIM_TIME 20 //60 // Duration (sec) of no pedaling to dim display (if supported) #define BLANK_TIME 25 //180 // Duration (sec) to blank display #define NO_BLE_PS_TIME 30 //900 // Duration (sec) to powersave when no BLE connection #define BLE_PS_TIME 30 //1200 // Duration (sec) to powersave with BLE connection #endif #if (USE_SERIAL) && defined(DEBUGGING) #define DEBUG(x, l) \\ Serial.print(F(x)); \\ Serial.print(F(l)); #else #define DEBUG(x, l) #endif #ifdef DEBUGGING // Pauses at points in startup can be helpful in checking power consumption uint8_t stepnum = 0; #define STEP(N) \\ cadence = N; \\ display_numbers(); \\ delay(5000); #define DWAIT() \\ delay(5000); #else #define STEP(N) #define DWAIT() #endif /************************************************************************ * Miscellany ************************************************************************/ // The battery is measured through a divider providing half the voltage, // using the 3.6V reference. #define VBAT_MV_PER_LSB 7.03125 // 3600 mV ref / 1024 steps * 2.0 divider ratio // Vdd is measured without a divider. #define VDD_MV_PER_LSB VBAT_MV_PER_LSB / 2.0 // Round for positive numbers #define roundpos(x) ((x) + 0.5) #define ANALOG_OVERSAMPLE 4 // Resistance measurements can be noisy! /********************************************************************************* Display code **********************************************************************************/ #define DISPLAY_LABEL_FONT u8g2_font_helvB10_tr #define DISPLAY_NUMBER_FONT u8g2_font_helvB24_tr // Log used at startup #define LOG_FONT u8g2_font_7x14_tf #define LOG_WIDTH 9 #define LOG_HEIGHT 10 uint8_t u8log_buffer[LOG_WIDTH * LOG_HEIGHT]; U8G2LOG displog; void display_setup() { // Start the display display.begin(); display.setContrast(CONTRAST_FULL); //display.enableUTF8Print(); // Can leave this out if using no symbols display.setFontMode(1); // ""Transparent"": Character background not drawn (since we clear the display anyway) // Start the startup log display displog.begin(display, LOG_WIDTH, LOG_HEIGHT, u8log_buffer); displog.setLineHeightOffset(0); displog.setRedrawMode(0); display.setFont(LOG_FONT); displog.print(F(""KBikeBLE\\n"")); displog.println(F(VERSION)); displog.println(); } void right_just(uint16_t number, int x, int y, int width) // This works for the current font, but it ought to count pixels rather than characters. { if (number < 10) x += width; if (number < 100) x += width; display.setCursor(x, y); display.print(number); } #if HAVE_BATTERY #define BWIDTH 16 #define BHEIGHT 8 #define BUTTON 2 #define BATT_POS_X 46 #define BATT_POS_Y 0 #define roundpct(pct, max) (((pct * max) + 50) / 100) // Integer arithmetic rounded % of max void draw_batt(uint8_t pct) { display.drawFrame(BATT_POS_X, BATT_POS_Y, BWIDTH, BHEIGHT); // Battery body display.drawBox(BATT_POS_X + BWIDTH, BATT_POS_Y + ((BHEIGHT - BUTTON) / 2), BUTTON, BUTTON); // Battery ""button"" display.setDrawColor(1); display.drawBox(BATT_POS_X + 2, BATT_POS_Y + 2, roundpct(pct, (BWIDTH - 4)), (BHEIGHT - 4)); // Filled area proportional to charge estimate } void blank_batt() { display.setDrawColor(0); display.drawBox(BATT_POS_X, BATT_POS_Y, BWIDTH + BUTTON, BHEIGHT); // Erase the battery } #if (0) // not used void update_batt(uint8_t pct) { display.setDrawColor(0); // Empty interior display.drawBox(BATT_POS_X + 2, BATT_POS_Y + 2, BWIDTH - 4, BHEIGHT - 4); display.setDrawColor(1); display.drawBox(BATT_POS_X + 2, BATT_POS_Y + 2, pct * (BWIDTH - 4) / 100, (BHEIGHT - 4)); // Filled area proportional to charge estimate } #endif #endif uint16_t prev_cad = 0; uint16_t prev_rg = 0; uint16_t prev_pwr = 0; #if HAVE_BATTERY uint8_t prev_batt = 0; #endif const char *rg_labels[2] = {""GEAR"", ""RES %""}; const char *rg_label = rg_labels[0]; void display_numbers() { uint16_t rg = gear_display ? gear : roundpos(disp_resistance); uint16_t pwr = roundpos(power); uint16_t cad = roundpos(cadence); #if HAVE_BATTERY if ((cad != prev_cad) || (rg != prev_rg) || (pwr != prev_pwr) || (batt_pct != prev_batt) || batt_low) #else if ((cad != prev_cad) || (rg != prev_rg) || (pwr != prev_pwr)) #endif { display.clearBuffer(); display.setFont(DISPLAY_LABEL_FONT); display.setCursor(0, 16); display.print(""RPM""); display.setCursor(0, 58); display.print(rg_label); display.setCursor(0, 100); display.print(""WATTS""); #if HAVE_BATTERY if (!batt_low || (ticker % 2)) draw_batt(batt_pct); // Draw low batt every other time --> flash #endif display.setFont(DISPLAY_NUMBER_FONT); right_just(cad, 10, 43, 18); /* if ( !(lever_state & 0b00000001) ) // Lever not presently near the top { right_just(rg, 10, 85, 18); } else { display.setCursor(10, 85); display.print(""<->""); } */ right_just(rg, 10, 85, 18); right_just(pwr, 10, 127, 18); display.sendBuffer(); prev_cad = cad; prev_rg = rg; prev_pwr = pwr; #if HAVE_BATTERY prev_batt = batt_pct; #endif } } /********************************************************************************* Analog input processing - resistance magnet position and battery * ********************************************************************************/ // Resistance sensing is potentiometric, so Vdd is the natural reference. // This makes the scale factor independent of the individual Vdd regulator eAnalogReference analog_reference = AR_VDD4; float averageADC() { uint32_t raw_sum = 0; const uint8_t n_samp = 20; const uint8_t interval = 50; for (uint8_t i = 0; i < n_samp; i++) { raw_sum += analogRead(RESISTANCE_PIN); delay(interval); } return ((float) raw_sum) / n_samp; } void ADC_setup() // Set up the ADC for ongoing resistance measurement { analogReference(analog_reference); analogOversampling(ANALOG_OVERSAMPLE); analogSampleTime(ANALOG_SAMPLE_TIME); analogReadResolution(10); // 10 bits for better gear delineation and for battery measurement delay(1); // Let the ADC settle before any measurements. Only important if changing the reference or possibly resolution displog.printf(""\\nADC %.1f\\n"", averageADC()); //displog.printf(""T %.2f\\n"", readCPUTemperature()); displog.print(""ADC cal\\n""); analogCalibrateOffset(); displog.printf(""ADC %.1f\\n"", averageADC()); delay(LOG_PAUSE); } float readVdd() { float Vdd; if (analog_reference == AR_VDD4) { analogReference(AR_INTERNAL); delay(1); Vdd = analogReadVDD() * VDD_MV_PER_LSB / 1000.0F; analogReference(AR_VDD4); delay(1); } else { Vdd = analogReadVDD() * VDD_MV_PER_LSB / 1000.0F; } return Vdd; } /***************************************************************************************************** * Gear and power determination *****************************************************************************************************/ int gear_lookup(float resistance) { int ix = gear; // The gear points to the top bound if (resistance >= gears[ix]) { // If above the top bound, index up if (ix >= tablen) return tablen; // But not if already at the top for (; (resistance > gears[++ix]) && (ix < tablen);) ; // Index up until resistance <= top bound or at end of the table return ix; } else { for (; (resistance < gears[--ix]) && (ix > 0);) ; // Index down until resistance >= bottom bound or at end of table return ++ix; // Decremented index is pointing to the bottom bound, so add 1 } } float sinterp(const float x_ref[], const float y_ref[], const float slopes[], int index, float x) { float x1 = x_ref[index - 1]; // Index points to the top bound float y1 = y_ref[index - 1]; return y1 + (x - x1) * slopes[index]; // Slope[index] is the slopes of the trailing interval } /********************************************************************************* Bluetooth Set up and add services. Bluetooth is started at reset. In the absence of pedaling for BLE_PS_TIME sec, disconnect if connected and stop advertising. Pedal events (wakeup) restart advertising. * ********************************************************************************/ void startAdv() { Bluefruit.Advertising.addService(svc_ftms, svc_cps); // Advertise the services Bluefruit.Advertising.addData(0x16, FTMS_Adv_Data, 5); // Required data field for FTMS #if (BLEUART) Bluefruit.Advertising.addService(bleuart); #endif Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); Bluefruit.Advertising.addTxPower(); Bluefruit.Advertising.addName(); // Include name Bluefruit.Advertising.restartOnDisconnect(true); // Enable auto advertising if disconnected Bluefruit.Advertising.setInterval(32, 244); // Fast mode 20 ms, slow mode 152.5 ms, in unit of 0.625 ms // We can be pretty aggressive since BLE will turn off when not in use // For recommended advertising interval // https://developer.apple.com/library/content/qa/qa1931/_index.html Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds } void stopBLE() { //DEBUG(""Stopping BLE"", ""\\n"") // If we're connected, disconnect. Since we only allow one connection, we know that the handle is 0 // if (Bluefruit.connected(0)) Bluefruit.disconnect(0); Bluefruit.disconnect(0); // disconnect() includes check for whether connected delay(100); // If restartOnDisconnect(true), this is needed for advertising to be stopped // If we're advertising, stop advertising. // if (Bluefruit.Advertising.isRunning()) Bluefruit.Advertising.stop(); // Or should this be time-limited? Bluefruit.Advertising.stop(); // this looks like it will work even if advertising isn't running } void restartBLE() { if (!Bluefruit.connected(0) && !Bluefruit.Advertising.isRunning()) { //DEBUG(""Restarting BLE"", ""\\n"") Bluefruit.Advertising.start(0); } } void setupFTMS() { // Configure and start the FTM service // First .begin the service, prior to .begin on characteristics svc_ftms.begin(); // Note: You must call .begin() on the BLEService before calling .begin() on // any characteristic(s) within that service definition.. Calling .begin() on // a BLECharacteristic will cause it to be added to the last BLEService that // was 'begin()'ed! char_ftm_feature.setProperties(CHR_PROPS_READ); char_ftm_feature.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); char_ftm_feature.setFixedLen(sizeof(ftmf_data)); // Should the following callback be set for ftm_feature or for bike_data?? char_ftm_feature.setCccdWriteCallback(ftm_cccd_callback); // Optionally capture CCCD updates char_ftm_feature.begin(); char_ftm_feature.write(ftmf_data, sizeof(ftmf_data)); char_bike_data.setProperties(CHR_PROPS_NOTIFY); char_bike_data.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); char_bike_data.setFixedLen(sizeof(bike_data)); char_bike_data.begin(); } void setupCPS() { // Configure and start the CP service // First .begin the service, prior to .begin on characteristics svc_cps.begin(); char_cp_feature.setProperties(CHR_PROPS_READ); char_cp_feature.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); char_cp_feature.setFixedLen(sizeof(cpf_data)); char_cp_feature.begin(); char_cp_feature.write(cpf_data, sizeof(cpf_data)); char_sensor_loc.setProperties(CHR_PROPS_READ); char_sensor_loc.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); char_sensor_loc.setFixedLen(sizeof(cl_data)); char_sensor_loc.begin(); char_sensor_loc.write(cl_data, sizeof(cl_data)); char_cp_measurement.setProperties(CHR_PROPS_NOTIFY); char_cp_measurement.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); char_cp_measurement.setFixedLen(sizeof(power_data)); char_cp_measurement.setCccdWriteCallback(cps_cccd_callback); // Optionally capture CCCD updates char_cp_measurement.begin(); } void connect_callback(uint16_t conn_handle) { // Get the reference to current connection BLEConnection *connection = Bluefruit.Connection(conn_handle); char central_name[32] = {0}; connection->getPeerName(central_name, sizeof(central_name)); } /** Callback invoked when a connection is dropped @param conn_handle connection where this event happens @param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h */ void disconnect_callback(uint16_t conn_handle, uint8_t reason) { (void)conn_handle; (void)reason; // Start over with both characteristics active ftm_active = true; cp_active = true; } void ftm_cccd_callback(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value) // Notify callback for FTM characteristic { // Check the characteristic this CCCD update is associated with in case // this handler is used for multiple CCCD records. // Because we use separate callbacks, we probably do not need these conditionals. if (chr->uuid == char_bike_data.uuid) { if (chr->notifyEnabled(conn_hdl)) { cp_active = false; // Turn off notify() updates to the other characteristic } else { } } } void cps_cccd_callback(uint16_t conn_hdl, BLECharacteristic *chr, uint16_t cccd_value) // Notify callback for CPS characteristic { // Check the characteristic this CCCD update is associated with in case // this handler is used for multiple CCCD records. // Because we use separate callbacks, we probably do not need these conditionals. if (chr->uuid == char_cp_measurement.uuid) { if (chr->notifyEnabled(conn_hdl)) { ftm_active = false; // Turn off notify() updates to the other characteristic } else { } } } void format_bike_data() { // B2-3 = Instantaneous speed - UINT16 - Km/Hr with 0.01 resolution // B4-5 = Instantaneous cadence - UINT16 - 1/min with 0.5 resolution // B6-7 = Instantaneous power - UINT16 - W with 1.0 resolution uint16_t speed_int = roundpos(bspeed / 0.01); uint16_t cadence_int = roundpos(cadence / 0.5); uint16_t power_int = roundpos(power); uint16_t resistance_int = roundpos(resistance); bike_data.data[0] = speed_int; bike_data.data[1] = cadence_int; bike_data.data[2] = resistance_int; bike_data.data[3] = power_int; } void format_power_data() { // Fields are // B2-3 = Instantaneous power - UINT16 - W with 1.0 resolution // B4-5 = Crank revolutions - UINT16 - [unitless] // B6-7 = Last crank event time - UINT16 - s with 1/1024 resolution (1024 counts/sec) //uint16_t power_int = round(power); //uint16_t revs = crank_count; //uint16_t et = ((crank_event_time & 0xFFFF) * 1024 / 1000) & 0xFFFF ; // uint32 millisec to uint16 1024ths power_data.data[0] = roundpos(power); noInterrupts(); // crank_count and crank_ticks are set in the crank ISR power_data.data[1] = crank_count; power_data.data[2] = crank_ticks; interrupts(); } /********************************************************************************************* Simplified ISR for crank sensor events. Triggerd on the pin tranisitioning low (switch closure). As long as there's been more than MIN_INACTIVE time, trust the hardware and call it a crank event. Interrupts occurring closer together than MIN_ACTIVE are quickly dismissed. **********************************************************************************************/ const uint32_t MIN_INACTIVE = 300; // milliseconds (corresponds to 200 rpm) void crank_callback() { //uint32_t now = millis(); // millis() is calculated from the FreeRTOS tick count and rate, so just use the tick count uint32_t now = xTaskGetTickCountFromISR(); // This depends upon the default tick interval of 1/1024 sec uint32_t dt = now - crank_event_time; if (dt < MIN_INACTIVE) // Debounce: ignore crank events not spaced at least this far apart return; #if (POWERSAVE > 0) && (POWERSAVE != 1) if (suspended) resume(); #endif // The following are needed for the Cycling Power Measurement characteristic crank_count++; // Accumulated crank rotationst //crank_ticks += min(dt * 1024 / 1000, 0xFFFF); // Crank event clock in 1/1024 sec ticks crank_ticks = now & 0xFFFF; crank_event_time = now; new_crank_event = true; // Tell the main loop that there is new crank data //inst_cadence = 60000 / dt; // This used to be done in the main loop inst_cadence = 61440 / dt; // RPM = 60 / ( dt * 1000/1024 ); } /******************************************************************************** * Calibration: ADC reading --> normalized resistance ********************************************************************************/ void init_cal() { if (!read_param_file(""offset"", &res_offset, sizeof(res_offset))) { res_offset = RESISTANCE_OFFSET; write_param_file(""offset"", &res_offset, sizeof(res_offset)); displog.println(F(""Offset\\ndefault\\n\\ write"")); displog.printf("" %.1f\\n"", res_offset); } else { displog.println(F(""Offset\\n read"")); displog.printf("" %.1f\\n"", res_offset); } if (!read_param_file(""factor"", &res_factor, sizeof(res_factor))) { res_factor = RESISTANCE_FACTOR; write_param_file(""factor"", &res_factor, sizeof(res_factor)); displog.println(F(""\\nFactor\\ndefault\\n write"")); displog.printf("" %.4f\\n"", res_factor); } else { displog.println(F(""\\nFactor\\n read"")); displog.printf("" %.4f\\n"", res_factor); } delay(LOG_PAUSE); } /******************************************************************************** * Startup ********************************************************************************/ SoftwareTimer update_timer; void setup() { #if (USE_SERIAL) Serial.begin(115200); #endif // Start the OLED display display_setup(); // Set up the internal filesystem (LittleFS), read files, and where any files are missing write defaults setup_InternalFS(); init_cal(); // Set up Bluetooth Bluefruit.begin(); // Set power - needs only to work in pretty close range Bluefruit.setTxPower(BLE_TX_POWER); Bluefruit.setConnLedInterval(BLE_LED_INTERVAL); // Set the advertised device name (keep it short!) Bluefruit.setName(""KBikeBLE""); // Set the connect/disconnect callback handlers Bluefruit.Periph.setConnectCallback(connect_callback); Bluefruit.Periph.setDisconnectCallback(disconnect_callback); // Configure and Start the Device Information Service //Serial.println(""Configuring the Device Information Service""); bledis.setManufacturer(""Adafruit Industries""); bledis.setModel(""Bluefruit Feather52""); bledis.begin(); // Start the BLE Battery Service #if BLEBAS && HAVE_BATTERY blebas.begin(); #endif // Setup the FiTness Machine and Cycling Power services setupFTMS(); setupCPS(); // Start the BLEUart service #if (BLEUART) bleuart.begin(); #endif // Start the console #if defined(BLEUART) || defined(USE_SERIAL) console_init(); #endif // Setup the advertising packet(s) startAdv(); // Crank sensing. A falling edge (switch closure) triggers the interrupt. This counts as a crank event (rotation) // if it's been long enough since the last event. The rider could conceivably initiate faux rotations by holding // the crank right at a certain spot, but there are similar risks with any scheme. crank_event_time = xTaskGetTickCount(); // xTaskGetTickCountFromISR(); pinMode(CRANK_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(CRANK_PIN), crank_callback, FALLING); // Apply voltage to the resistance pot pinMode(RESISTANCE_TOP, OUTPUT); digitalWrite(RESISTANCE_TOP, HIGH); // Set up the analog input for resistance measurement ADC_setup(); // Set both notify characteristics to be active. Whichever the client responds to becomes the sole active characteristic ftm_active = true; cp_active = true; // With crank sensing handled by the interrupt, everything else - // - Bluetooth updates // - Display updates // - Battery check // - Power savings when pedaling stops // - Notifying the BLEUart console to check for input // is handled by the recurring update() task. update_timer.begin(TICK_INTERVAL, update); update_timer.start(); suspendLoop(); } /********************************************************************************************* * Suspend (power save) * - de-energizes the resistance sense pot * - If POWERSAVE == 1, powers the system down, with the crank switch configured as reset * - Otherwise, stops the scheduled update() task * See the notes in each section *********************************************************************************************/ #if (POWERSAVE > 0) #if (POWERSAVE == 1) /* Power down until reset. Reset will be caused by a selected level (not edge) on the crank switch GPIO pin. The crank switch closes at one point in the rotation and is likely to be open. We can't be certain, so we configure reset to occur when the crank switch changes to the opposite of its current state. Though the crank switch is usually open because the range of movement during which the magnet is nearby is small, it's possible for the pedals to be stopped with the switch closed. The stock systemOff() sets up a pullup if reset is to be active-low, or a pulldown if it's to be active-high. Here, with the non-GPIO side of the crank switch hard wired to ground, we're stuck with a pullup. Our copy of the stock systemOff() substitutes PULLUP for PULLDOWN when SENSE_HIGH is needed. The compromise made is in battery usage: the closed switch with the 22K pullup consumes 0.15 mA continuously. The prototype system uses about 1.0 mA when shut down due to power still being applied to the nRF52840 and OLED display boards, so the additional 0.15 mA isn't terrible. Alternatives include (1) active control over the non-GPIO side of the switch, which would affect the resistance measurements; (2) AC coupling of the switch (parallel RC - would consume) less, but not zero, current; (3) a very weak external pullup. */ void turnOff(uint32_t pin, uint8_t wake_logic) { // for(int i=0; i<8; i++) // { // NRF_POWER->RAM[i].POWERCLR = 0x03UL; // } pin = g_ADigitalPinMap[pin]; if (wake_logic) { //Original systemOff() uses NRF_GPIO_PIN_PULLDOWN here nrf_gpio_cfg_sense_input(pin, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH); } else { nrf_gpio_cfg_sense_input(pin, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW); } uint8_t sd_en; (void)sd_softdevice_is_enabled(&sd_en); // Enter System OFF state if (sd_en) { sd_power_system_off(); } else { NRF_POWER->SYSTEMOFF = 1; } } void suspend() { digitalWrite(RESISTANCE_TOP, LOW); // De-energize the resistance pot turnOff(CRANK_PIN, !digitalRead(CRANK_PIN)); // Shut down, with a change in the crank switch causing reset } #else /* Enter the power save state by stopping the update() task. If full = true, also de-energize the resistance sense pot. full = false is used Resume by re-starting it just as in Setup(). */ void suspend() { digitalWrite(RESISTANCE_TOP, LOW); // De-energize the resistance pot update_timer.stop(); suspended = true; } void resume() { digitalWrite(RESISTANCE_TOP, HIGH); analogCalibrateOffset(); update_timer.start(); suspended = false; } #endif #endif /********************************************************************************************** Main ""loop()"" We define these periodic tasks: * Checking the resistance measurement. It helps the user for this to be updated 2/sec. * Checking for crank event(s) that were handled by the crank ISR, recalculating power, and determine any need for power savings steps. * Updating BLE service data, if connected. Service specs call for this to be about 1/sec * Checking the battery. Every 30 sec seems like plenty. * Updating the display as needed. These are all handled by a single function, update(), which calls each individual function at the appropriate times. update() is scheduled as a recurring task, twice per second, in FreeRTOS (part of the Adafruit Arduino core for the nRF52840. In the extended absence of pedaling, one option for power savings is to simply un-schedule this task, leaving nothing to do until pedaling resumes, and allowing the system to default into a low-power state. The BLE console interface is handled by a low-priority process that sits idle until triggered (the FreeRTOS term is Notify). update() does this once per second. **********************************************************************************************/ #define BATT_TICKS 60 // Battery check every __ ticks #define DEFAULT_TICKS 2 // Default stuff every __ ticks uint16_t last_crank_count = 0; uint8_t crank_still_timer = 3; // No pedaling is defined as this many crank checks with no event uint16_t stop_time; #define BRAKE 100 // Edge of the valid range, less than the max reading #define LEVER_MASK 0b00001111 // Up to 8 1's --> up to 7 samples that reistance must be < BRAKE void lever_check() // Moving the gear lever to the top switches the resistance/gear display mode { lever_state = (lever_state << 1) & LEVER_MASK | (inst_resistance > BRAKE); if (lever_state == 0b00000001) { gear_display = !gear_display; rg_label = rg_labels[(int)!gear_display]; #ifdef LEVER_EXTRAS LEVER_EXTRAS #endif } } void update_resistance() { raw_resistance = analogRead(RESISTANCE_PIN); // ADC set to oversample inst_resistance = max((raw_resistance - res_offset) * res_factor, 0); resistance = (RESISTANCE_FILTER * resistance + 2 * inst_resistance) / (RESISTANCE_FILTER + 2); gear = gear_lookup(resistance); disp_resistance = (RESISTANCE_DISPLAY_FILTER * resistance + 2 * inst_resistance) / (RESISTANCE_DISPLAY_FILTER + 2); //resistance_sq = resistance * resistance; //gear = max(floor(GC + GB * resistance + GA * resistance_sq), 1) ; lever_check(); } #if HAVE_BATTERY void update_battery() { if (analog_reference != AR_INTERNAL) { analogReference(AR_INTERNAL); delay(1); } batt_mvolts = analogRead(BATTERY_PIN) * VBAT_MV_PER_LSB; #if WATCH_VDD Vdd_mvolts = analogReadVDD() * VDD_MV_PER_LSB; #endif if (analog_reference != AR_INTERNAL) { analogReference(analog_reference); delay(1); } if (batt_mvolts < 3300) // LiPo model... batt_pct = 0.0; // Dead at 3.3V else if (batt_mvolts < 3600) batt_pct = (batt_mvolts - 3300) * 0.03333; // Last 10% - linear from 3.3 - 3.6 V else batt_pct = min(10.0 + ((batt_mvolts - 3600) * 0.15F), 100.0); // 10-100% - linear from 3.6 - 4.2 V #if WATCH_VDD batt_low = (batt_pct < BATT_LOW) || (Vdd_mvolts < VDD_MIN); # else batt_low = batt_pct < BATT_LOW; #endif #ifdef BLEBAS blebas.write(batt_pct); #endif } #endif void process_crank_event() { if (new_crank_event) // On a new crank event (flag set by the crank event ISR), update { stop_time = 0; // Hold off power saving timeout if (display_state < 2) // Be sure the display is on { display.setPowerSave(0); display.setContrast(CONTRAST_FULL); display_state = 2; #if HAVE_BATTERY ticker = BATT_TICKS; // Force battery check after the display has been off #endif } crank_still_timer = 0b100; // Reset the shift register used to detect no pedaling // 3 shifts = 3 seconds without an event indicates no pedaling restartBLE(); // Be sure BLE is running (RestartBLE checks whether it already is. // there should possibly be a state flag. new_crank_event = false; // Reset the flag } // new_crank_event else // If no crank event, check timeouts { crank_still_timer = crank_still_timer >> 1; if (crank_still_timer == 0) { inst_cadence = 0; stop_time++; // Timeouts related to the display switch (display_state) { case 2: // Full brightness - see whether it's time to dim if (stop_time > DIM_TIME) { display.setContrast(CONTRAST_DIM); display_state = 1; } break; case 1: // Dimmed - see whether it's time to turn off if (stop_time > BLANK_TIME) { display.setPowerSave(1); display_state = 0; } break; } // Timeouts related to further power savings - different according to Bluetooth state if (Bluefruit.connected()) { if (stop_time >= BLE_PS_TIME) // Active BLE connection: { // At BLE_PS_TIME, stop BLE and optionally suspend stopBLE(); #if (POWERSAVE > 0) suspend(); #endif } } else // No active BLE connection: { // At NO_BLE_PS_TIME, optionally suspend #if (POWERSAVE > 0) if (stop_time >= NO_BLE_PS_TIME) { Bluefruit.Advertising.stop(); // Ensure that we don't shut down with the BLE LED lit suspend(); } #endif } } } // no new_crank_event } void updateBLE() { if (Bluefruit.connected()) { // Update data (with notify()) for the active characteristics. Both are active until the client responds to one of them. if (cp_active) { format_power_data(); char_cp_measurement.notify((uint8_t *)&power_data, 8); // The cast should not be needed } if (ftm_active) { bspeed = 20 * cadence / 60; // NOT A REAL CAL OF ANY KIND! format_bike_data(); char_bike_data.notify((uint8_t *)&bike_data, 10); } } } #if (BLEUART) || (USE_SERIAL) #define SBUF_LEN 40 char sbuffer[SBUF_LEN]; // Serial console input buffer char cmd[SBUF_LEN]; // Tokenized command char arg[SBUF_LEN]; // Tokenized argument uint8_t sbix; // Current index into input buffer bool cmd_rcvd; // Console state: command received bool new_input; // Console state: new input ready to process uint8_t cmd_number; // Current command (= position in the table) uint8_t awaiting_conf = AWAITING_NONE; // Console state: awaiting confirmation for this numbered command uint8_t awaiting_timer; // Timeout counter for confirmation float new_factor; float new_offset; TaskHandle_t console_task_handle; Stream * console = nullptr; inline void console_clear() // Clears the console for fresh input { sbix = 0; cmd_rcvd = false; cmd[0] = 0; arg[0] = 0; new_input = false; //bleuart.flush(); // clear the input to avoid typeahead } #define AWAITING_CONF() awaiting_conf != AWAITING_NONE inline void console_reset() { new_factor = res_factor; new_offset = res_offset; } inline void console_init() { #if (USE_SERIAL) // These shouldn't be needed console = &Serial; #endif #if (BLEUART) console = &bleuart; #endif bool result = xTaskCreate(console_check, ""ConsoleCheck"", SCHEDULER_STACK_SIZE_DFLT, ( void * ) 1, TASK_PRIO_LOW, &console_task_handle); console_clear(); console_reset(); } bool console_source_check() { bool avail = false; #if (USE_SERIAL) // If enabled, check Serial bool s = Serial.available(); if (s) { console = &Serial; avail = true; } #endif #if (BLEUART) // If enabled, check BLEUart bool b = bleuart.available(); if (b) { console = &bleuart; avail = true; #if (USE_SERIAL) if (s) // BLE has precedence, so dump any serial input while (Serial.available()) Serial.read(); #endif } #endif return avail; } void console_take_input() { while (console->available()) // Might need && !new_input and flush at the end to be sure to get only one line { uint8_t c = (uint8_t) console->read(); switch (c) { case 32: // delimeter if (sbix == 0) break; // Ignore leading spaces in both the command and the argument if (!cmd_rcvd) { memcpy(&cmd, &sbuffer, sbix); // Save the command and ready the buffer for an argument cmd[sbix] = 0; cmd_rcvd = true; sbix = 0; } else { if (sbix < SBUF_LEN - 1) sbuffer[sbix++] = c; // Keep embedded spaces in the argument } break; case 10: case 13: //if (new_input) break; if (sbix > 0) // Anything in the buffer? { if (!cmd_rcvd) { memcpy(&cmd, &sbuffer, sbix); // Save the command cmd[sbix] = 0; cmd_rcvd = true; } else { memcpy(&arg, &sbuffer, sbix); // ...or the argument arg[sbix] = 0; } } if (cmd_rcvd) new_input = true; break; default: if (sbix < SBUF_LEN - 1) sbuffer[sbix++] = tolower(c); // Add the character to the pending command or argument break; } } } #define PBLEN 128 char pbuffer[PBLEN]; #define CONSOLE_PRINT(string) console->write((uint8_t *) string, strlen(string)) //console_send(string) #define CONSOLE_PRINTF(format, args...) snprintf(pbuffer, PBLEN, format, args); \\ console->write((uint8_t *) pbuffer, strlen(pbuffer)) //console_send(pbuffer) void cmd_batt() { #if HAVE_BATTERY CONSOLE_PRINTF(""\\nBattery voltage %.2f \\n"", batt_mvolts/1000); CONSOLE_PRINTF("" %d%% charge\\n\\n"", batt_pct); #if WATCH_VDD CONSOLE_PRINTF(""Vdd %.2f \\n\\n"", Vdd_mvolts/1000); #endif #else CONSOLE_PRINT(""\\nNo battery.\\n\\n""); #endif } void cmd_res() { uint32_t sum_resistance = 0; uint8_t n_resistance = 0; uint8_t max_n = 10; // Default number of samples double mean = 0; double M2 = 0; double variance = 0; double delta = 0; if (arg[0] != 0) { max_n = min(0xFF, max(atoi(arg), 1)); } CONSOLE_PRINTF(""%d measurements (any input to stop)...\\n\\n"", max_n); for (uint8_t i = max_n; i > 0; i--) { sum_resistance += raw_resistance; n_resistance++; CONSOLE_PRINTF(""Raw ADC value %d\\n"", raw_resistance); CONSOLE_PRINTF(""Resistance %.1f%%\\n"", resistance); CONSOLE_PRINTF(""Keiser gear number %d\\n\\n"", gear); delta = raw_resistance - mean; // Welford’s algorithm for variance from a sample stream mean += delta / n_resistance; M2 += delta * (raw_resistance - mean); //variance = M2 / n_resistance; if (console->available()) { while (console->available()) console->read(); //NOTE: bleuart.flush() flushes input; Serial.flush() flushes output break; } delay(TICK_INTERVAL); } if (n_resistance > 0) { CONSOLE_PRINTF(""%d measurements.\\n"", n_resistance); CONSOLE_PRINTF(""Average ADC value %.1f\\n"", (float)sum_resistance / n_resistance); CONSOLE_PRINTF(""Estimated mean %.1f; SD %.1f . \\n\\n"", mean, sqrt(M2 / n_resistance)); } } void cmd_adcref() { float Vdd = readVdd(); if (analog_reference == AR_INTERNAL) { analog_reference = AR_VDD4; res_offset *= (3.6 / Vdd); // This should be the actual VDD res_factor /= (3.6 / Vdd); CONSOLE_PRINT(""ADC reference is now Vdd.\\n\\n""); } else { analog_reference = AR_INTERNAL; res_offset *= (Vdd / 3.6); res_factor /= (Vdd / 3.6); CONSOLE_PRINT(""ADC reference is now internal 3.6V.\\n""); CONSOLE_PRINT(""This will remain until changed or the system is reset.\\n\\n""); } analogReference(analog_reference); } void cmd_adccal() { CONSOLE_PRINT(""Doing ADC calibration...""); analogCalibrateOffset(); CONSOLE_PRINT(""Done.\\n\\n""); } void cmd_temp() { CONSOLE_PRINTF(""CPU temperature %.1f\\n\\n"", readCPUTemperature()); } void cmd_showcal() { CONSOLE_PRINTF(""Offset %.1f; factor %.4f\\n\\n"", res_offset, res_factor); } void cmd_factor() { if (arg[0] == 0) //Should check for numeric as well { CONSOLE_PRINT(""Factor command requires a numeric value.\\n\\n""); return; } new_factor = atof(arg); CONSOLE_PRINTF(""New factor will be %.4f .\\n"", new_factor); CONSOLE_PRINT(""Use activate to have the bike use the new value.\\n\\n""); } void cmd_offset() { if (arg[0] == 0) //Should check for numeric as well { CONSOLE_PRINT(""Offset command requires a numeric value.\\n\\n""); return; } new_offset = atof(arg); CONSOLE_PRINTF(""New offset will be %.1f .\\n"", new_offset); CONSOLE_PRINT(""Use activate to have the bike use the new value.\\n\\n""); } void cmd_defaults() { new_offset = RESISTANCE_OFFSET; new_factor = RESISTANCE_FACTOR; CONSOLE_PRINT(""Defaults...\\n""); CONSOLE_PRINTF(""New offset will be %.1f .\\n"", new_offset); CONSOLE_PRINTF(""New factor will be %.4f .\\n"", new_factor); CONSOLE_PRINT(""Use activate to have the bike use these values.\\n\\n""); } uint8_t i; uint32_t base; uint32_t reading; void delay_message(uint8_t steps, uint16_t time) { for (i = steps; i > 0; i--) { CONSOLE_PRINTF("" %d.."", i); delay(time); } } void cmd_cal() { #define SAMPLES 20 #define BETWEEN_SAMPLES 100 if (AWAITING_CONF()) { CONSOLE_PRINT(""\\n\\nPlace the calibration tool on the flywheel, then rotate the flywheel so that the calibration tool contacts the magnet assembly.\\n""); delay_message(5, 1000); //base = analogRead(RESISTANCE_PIN); // Baseline reading - should increase from here CONSOLE_PRINT(""\\nRotate the magnet assembly by hand so that the magnet settles into the pocket in the calibration tool.""); CONSOLE_PRINT(""\\nDo not use the lever!\\n""); CONSOLE_PRINT(""\\nHold while readings are taken...\\n""); delay_message(5, 1000); update_timer.stop(); // Suspend updates so that resistance updates don't interfere // TO DO - since we're taking a known number of measurements and have plenty of RAM, this should use a // straight stdev or some other measure (simple min/max?), rather than the stream-based SD estimate uint32_t sum_resistance = 0; uint8_t n_resistance = 0; float average; double mean = 0; double M2 = 0; double variance = 0; for (uint8_t i=1; i <= SAMPLES; i++) { raw_resistance = analogRead(RESISTANCE_PIN); sum_resistance += raw_resistance; CONSOLE_PRINTF("" %d\\n"", raw_resistance); n_resistance++; double delta = raw_resistance - mean; // Welford’s algorithm for variance from a sample stream mean += delta / i; M2 += delta * (raw_resistance - mean); //variance = M2 / i; delay(BETWEEN_SAMPLES); } update_timer.start(); // Resume updates. Note: Since update() enables the console to run, we wouldn't // be here if the timer were stopped. average = (float) sum_resistance / SAMPLES; float SD = sqrt(M2 / SAMPLES); CONSOLE_PRINT(""Done.""); CONSOLE_PRINTF(""Average ADC value was %.1f\\n"", average); CONSOLE_PRINTF(""Standard deviation was %.1f\\n"", SD); if (SD > 1.0F) CONSOLE_PRINT(""\\n*** For SD > 1, re-doing the calibration is suggested. ***\\n""); new_offset = average - CALTOOL_RES/res_factor; CONSOLE_PRINTF(""\\nThe new offset is %.1f.\\n"", new_offset); CONSOLE_PRINT(""\\nUse activate to have the bike use these values.""); CONSOLE_PRINT(""If the readings weren't consistent, you can try again.\\n\\n""); awaiting_conf = AWAITING_NONE; } else { CONSOLE_PRINT(""Enter the calibration procedure.\\n""); CONSOLE_PRINT(""This will set the offset to match the bike.\\n""); CONSOLE_PRINT(""If for any reason you need to change the factor, enter and activate it *before* proceeding.\\n""); CONSOLE_PRINT(""\\nBe sure that the resistance lever is at the bottom (lowest gear)""); CONSOLE_PRINT("" and have the calibration tool ready to place on the flywheel.\\n""); CONSOLE_PRINT(""Y to continue...""); awaiting_conf = cmd_number; awaiting_timer = CONFIRMATION_TIMEOUT ; } } void cmd_activate() { if (AWAITING_CONF()) { res_offset = new_offset; res_factor = new_factor; CONSOLE_PRINT(""\\nActivate factor and offset confirmed.\\n\\n""); CONSOLE_PRINTF(""Offset %.1f; factor %.4f\\n\\n"", res_offset, res_factor); awaiting_conf = AWAITING_NONE; } else { CONSOLE_PRINTF(""Factor will be %.4f and offset will be %.1f .\\n"", new_factor, new_offset); CONSOLE_PRINT(""Y to make these the active values...""); awaiting_conf = cmd_number; awaiting_timer = CONFIRMATION_TIMEOUT ; } } void cmd_write() { if (AWAITING_CONF()) { if (write_param_file(""offset"", &res_offset, sizeof(res_offset)) & write_param_file(""factor"", &res_factor, sizeof(res_factor)) ) { CONSOLE_PRINT(""\\nWrite confirmed.\\n\\n""); } else { CONSOLE_PRINT(""\\nFailed to write the files.\\n\\n""); } awaiting_conf = AWAITING_NONE; } else { CONSOLE_PRINT(""Currently active factor and offset are...\\n""); CONSOLE_PRINTF(""Offset %.1f; factor %.4f\\n"", res_offset, res_factor); CONSOLE_PRINT(""Y to write these to the file...""); awaiting_conf = cmd_number; awaiting_timer = CONFIRMATION_TIMEOUT ; } } void cmd_read() { if (read_param_file(""offset"", &new_offset, sizeof(new_offset)) & read_param_file(""factor"", &new_factor, sizeof(new_factor))) { CONSOLE_PRINT(""Read from the parameter files:\\n""); CONSOLE_PRINTF(""Offset %.1f; factor %.4f\\n\\n"", new_offset, new_factor); CONSOLE_PRINT(""Use activate to have the bike use these values.\\n\\n""); } } void cmd_comment() { CONSOLE_PRINTF(""%s\\n\\n"", arg); } void cmd_help() { CONSOLE_PRINT(""\\n""); for (int i = 0; i < n_cmds; i++) { CONSOLE_PRINTF(""%s - %s \\n"", cmd_table[i].cmd, cmd_table[i].help); } CONSOLE_PRINT(""\\n""); } void process_cmd() { if (AWAITING_CONF()) // Awaiting confirmation - look for a ""y"" and call the same handler, or cancel { if (!strcmp(cmd, ""y"")) { cmd_table[awaiting_conf].cmdHandler(); } else { CONSOLE_PRINT(""Canceled.\\n""); awaiting_conf = AWAITING_NONE; } return; } int i = n_cmds; while (i--) { if (!strcmp(cmd, cmd_table[i].cmd)) { cmd_number = i; cmd_table[i].cmdHandler(); return; } } CONSOLE_PRINT(""Not a valid command.""); cmd_help(); return; } void console_check(void *notUsed) { uint32_t puNotificationValue; while (1) { xTaskNotifyWait(0x00, portMAX_DELAY, &puNotificationValue, DELAY_FOREVER); // Just sit here, blocked, until update() notifies us console_take_input(); // Take in whatever's there if (new_input) { process_cmd(); console_clear(); //RESPOND("" ""); } else if (AWAITING_CONF()) { CONSOLE_PRINT("".""); if (--awaiting_timer == 0) { awaiting_conf = AWAITING_NONE; CONSOLE_PRINT(""Cancelled.\\n\\n""); console_clear(); } } } } #endif void LED_flash(int times, int ms) { for (int i = 0; i < times; i++) { digitalWrite(LED_RED, 1); delay(ms); digitalWrite(LED_RED, 0); if (i < times - 1) delay(ms); } } void loop() // We're using a FreeRTOS scheduled task, so this is empty. { }; void update(TimerHandle_t xTimerID) { // Things that happens on every tick ------------------------------------------------------------------------------------- update_resistance(); // Things happen at the default tick interval ---------------------------------------------------------------------------- if ((ticker % DEFAULT_TICKS) == 0) { process_crank_event(); cadence = inst_cadence; float inst_power = max(sinterp(gears, power90, slopes, gear, resistance) * (PC2 + PB2 * cadence + PA2 * cadence * cadence), 0); //float inst_power = max((PC1 + PB1 * resistance + PA1 * resistance_sq) * ( PC2 + PB2 * cadence + PA2 * cadence * cadence), 0); power = inst_power; updateBLE(); } #if defined(BLEUART) || defined(USE_SERIAL) // If there's console input, select the corresponding source and unblock the handler // Note the order of operations: Don't switch sources while awaiting confirmation. if (AWAITING_CONF() || console_source_check()) xTaskNotifyGive(console_task_handle); #endif // Things that happen on BATT_TICKS ------------------------------------------------------------------------------------ #if HAVE_BATTERY if ((ticker % BATT_TICKS) == 0) { update_battery(); } #endif // Final things, as needed, on every tick ------------------------------------------------------------------------------ if (display_state > 0) display_numbers(); ticker++; //delay(TICK_INTERVAL); // Not used when this routine is triggered by a timer. } ",12285,False,1955.0332570985058,median "############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"""",%progbits .text .p2align 4, 0x90 CONST_TABLE: _poly: .quad 0x1, 0xC200000000000000 _twoone: .quad 0x1, 0x100000000 _u128_str: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 _mask1: .quad 0xffffffffffffffff, 0x0 _mask2: .quad 0x0, 0xffffffffffffffff _inc1: .quad 1,0 .p2align 4, 0x90 .globl AesGcmPrecompute_avx .type AesGcmPrecompute_avx, @function AesGcmPrecompute_avx: push %ebp mov %esp, %ebp push %esi lea CONST_TABLE, %esi movl (8)(%ebp), %eax movdqu (%eax), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd ((_twoone-CONST_TABLE))(%esi), %xmm4 pand ((_poly-CONST_TABLE))(%esi), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 psllq $(1), %xmm3 pxor %xmm1, %xmm3 psllq $(5), %xmm3 pxor %xmm1, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 psllq $(1), %xmm3 pxor %xmm2, %xmm3 psllq $(5), %xmm3 pxor %xmm2, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movl (12)(%ebp), %eax movdqu %xmm0, (%eax) movdqu %xmm1, (16)(%eax) movdqu %xmm2, (32)(%eax) pop %esi pop %ebp ret .Lfe1: .size AesGcmPrecompute_avx, .Lfe1-(AesGcmPrecompute_avx) .p2align 4, 0x90 .globl AesGcmMulGcm_avx .type AesGcmMulGcm_avx, @function AesGcmMulGcm_avx: push %ebp mov %esp, %ebp push %esi push %edi lea CONST_TABLE, %esi movl (8)(%ebp), %edi movl (12)(%ebp), %eax movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .Lfe2: .size AesGcmMulGcm_avx, .Lfe2-(AesGcmMulGcm_avx) .p2align 4, 0x90 .globl AesGcmAuth_avx .type AesGcmAuth_avx, @function AesGcmAuth_avx: push %ebp mov %esp, %ebp push %esi push %edi lea CONST_TABLE, %esi movl (8)(%ebp), %edi movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movl (20)(%ebp), %eax movdqa (%eax), %xmm1 movl (12)(%ebp), %ecx movl (16)(%ebp), %edx .p2align 4, 0x90 .Lauth_loopgas_3: movdqu (%ecx), %xmm2 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm2 add $(16), %ecx pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %edx jnz .Lauth_loopgas_3 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .Lfe3: .size AesGcmAuth_avx, .Lfe3-(AesGcmAuth_avx) .p2align 4, 0x90 .globl AesGcmEnc_avx .type AesGcmEnc_avx, @function AesGcmEnc_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax lea CONST_TABLE, %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_4 .p2align 4, 0x90 .Lblks4_loopgas_4: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 4, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm1 pxor (48)(%ebx), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm2 pxor (64)(%ebx), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm3 pxor (80)(%ebx), %xmm3 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm7 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_4 pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 movdqa %xmm0, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm2, (64)(%ebx) movdqa %xmm3, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 movdqa (16)(%eax), %xmm7 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 movdqa (%eax), %xmm7 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%ebx) .Lsingle_block_procgas_4: cmpl $(0), (132)(%ebx) jz .Lquitgas_4 .p2align 4, 0x90 .Lblk_loopgas_4: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 4, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe4: .size AesGcmEnc_avx, .Lfe4-(AesGcmEnc_avx) .p2align 4, 0x90 .globl AesGcmDec_avx .type AesGcmDec_avx, @function AesGcmDec_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax lea CONST_TABLE, %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_5 .p2align 4, 0x90 .Lblks4_loopgas_5: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 4, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm4 pxor (32)(%ebx), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm5 pxor (48)(%ebx), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm6 pxor (64)(%ebx), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm7 pxor (80)(%ebx), %xmm7 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm0 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_5 pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 movdqa %xmm4, (32)(%ebx) movdqa %xmm5, (48)(%ebx) movdqa %xmm6, (64)(%ebx) movdqa %xmm7, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 movdqa (16)(%eax), %xmm0 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 movdqa (%eax), %xmm0 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%ebx) .Lsingle_block_procgas_5: cmpl $(0), (132)(%ebx) jz .Lquitgas_5 .p2align 4, 0x90 .Lblk_loopgas_5: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 4, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm1 pxor (32)(%ebx), %xmm1 movdqa (%eax), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 psllq $(1), %xmm2 pxor %xmm1, %xmm2 psllq $(5), %xmm2 pxor %xmm1, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe5: .size AesGcmDec_avx, .Lfe5-(AesGcmDec_avx) ",16282,True,4897.087181601459,median "/* The OpenTRV project licenses this file to you under the Apache Licence, Version 2.0 (the ""Licence""); you may not use this file except in compliance with the Licence. You may obtain a copy of the Licence at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence. Author(s) / Copyright (s): Damon Hart-Davis 2013--2014 Gary Gladman 2014 */ /* V0p2 (V0.2) core. DHD20130417: hardware setup on bare board. * 1MHz CPU clock (from 8MHz internal RC clock with /8 prescaler) ATmega328P running at 1.8V--5V (typically 2V--3.3V). * Fuse set for BOD-managed additional clock settle time, ie as fast a restart from sleep as possible. * All unused pins unconnected and nominally floating (though driven low as output where possible). * 32768Hz xtal between pins 9 and 10, async timer 2, for accurate timekeeping and low-power sleep. * All unused system modules turned off. Basic AVR power consumption ticking an (empty) control loop at ~0.5Hz should be ~1uA. */ // Arduino libraries imported here (even for use in other .cpp files). #include #include #include #include #include ""V0p2_Main.h"" #include ""V0p2_Generic_Config.h"" #include ""V0p2_Board_IO_Config.h"" // I/O pin allocation: include ahead of I/O module headers. #include ""Ambient_Light_Sensor.h"" #include ""Control.h"" #include ""EEPROM_Utils.h"" #include ""FHT8V_Wireless_Rad_Valve.h"" #include ""RTC_Support.h"" #include ""Power_Management.h"" #include ""PRNG.h"" #include ""RFM22_Radio.h"" #include ""Security.h"" #include ""Serial_IO.h"" #include ""Temperature_Sensor.h"" #include ""Temp_Pot.h"" #include ""UI_Minimal.h"" #include ""Unit_Tests.h"" // Controller's view of Least Significiant Digits of the current (local) time, in this case whole seconds. // See PICAXE V0.1/V0.09/DHD201302L0 code. #define TIME_LSD_IS_BINARY // TIME_LSD is in binary (cf BCD). #define TIME_CYCLE_S 60 // TIME_LSD ranges from 0 to TIME_CYCLE_S-1, also major cycle length. static uint_fast8_t TIME_LSD; // Controller's notion of seconds within major cycle. // Indicate that the system is broken in an obvious way (distress flashing the main LED). // DOES NOT RETURN. // Tries to turn off most stuff safely that will benefit from doing so, but nothing too complex. // Tries not to use lots of energy so as to keep distress beacon running for a while. void panic() { #ifdef USE_MODULE_RFM22RADIOSIMPLE // Reset radio and go into low-power mode. RFM22PowerOnInit(); #endif // Power down almost everything else... minimisePowerWithoutSleep(); #ifdef LED_HEATCALL pinMode(LED_HEATCALL, OUTPUT); #else pinMode(LED_HEATCALL_L, OUTPUT); #endif for( ; ; ) { LED_HEATCALL_ON(); tinyPause(); LED_HEATCALL_OFF(); bigPause(); } } // Panic with fixed message. void panic(const __FlashStringHelper *s) { serialPrintlnAndFlush(s); // May fail. panic(); } #ifdef DEBUG // Optional Power-On Self Test routines. // Aborts with a call to panic() if a test fails. static void optionalPOST() { } #endif // Compute a CRC of all of SRAM as a hash that should contain some entropy, especially after power-up. #if !defined(RAMSTART) #define RAMSTART (0x100) #endif static uint16_t sramCRC() { uint16_t result = ~0U; for(uint8_t *p = (uint8_t *)RAMSTART; p <= (uint8_t *)RAMEND; ++p) { result = _crc_ccitt_update(result, *p); } return(result); } // Compute a CRC of all of EEPROM as a hash that may contain some entropy, particularly across restarts. static uint16_t eeCRC() { uint16_t result = ~0U; for(uint8_t *p = (uint8_t *)0; p <= (uint8_t *)E2END; ++p) { const uint8_t v = eeprom_read_byte(p); result = _crc_ccitt_update(result, v); } return(result); } // Signal position in basic POST sequence (as a small positive integer. // Simple count of position in ON flashes. // LED is assumed to be ON upon entry, and is left ON at exit. // // See video which shows the boot sequence: http://gallery.hd.org/_c/energy-matters/_more2013/_more12/OpenTRV-V0p2-breadboard-POST-Power-On-Self-Test-LED-sequence-as-of-20131202-bootloader-then-five-sections-then-flicker-for-SPI-drive-of-RFM23-1-DHD.mov.html // * Two quick flashes from the Arduino bootloader then the LED comes on. // * Each of the 5 main sections of Power On Self Test is 1 second LED on, 0.5 second off, n short flashes separated by 0.25s off, then 0.5s off, then 1s on. // The value of n is 1, 2, 3, 4, 5. // * The LED should then go off except for optional faint flickers as the radio is being driven if set up to do so. #define PP_OFF_MS 250 static void posPOST(const uint8_t position, const __FlashStringHelper *s) { sleepLowPowerMs(1000); #ifdef DEBUG DEBUG_SERIAL_PRINT_FLASHSTRING(""posPOST: ""); // Can only be used once serial is set up. DEBUG_SERIAL_PRINT(position); DEBUG_SERIAL_PRINT_FLASHSTRING("": ""); DEBUG_SERIAL_PRINT(s); DEBUG_SERIAL_PRINTLN(); #else serialPrintlnAndFlush(s); #endif // pinMode(LED_HEATCALL, OUTPUT); LED_HEATCALL_OFF(); sleepLowPowerMs(2*PP_OFF_MS); // TODO: use this time to gather entropy. int i = position; while(--i >= 0) { LED_HEATCALL_ON(); tinyPause(); LED_HEATCALL_OFF(); sleepLowPowerMs(PP_OFF_MS); // TODO: use this time to gather entropy. } sleepLowPowerMs(PP_OFF_MS); // TODO: use this time to gather entropy. LED_HEATCALL_ON(); sleepLowPowerMs(1000); // TODO: use this time to gather entropy. } // Rearrange date into sensible most-significant-first order. (Would like it also to be fully numeric, but whatever...) // FIXME: would be better to have this in PROGMEM (Flash) rather than RAM. static const char _YYYYMmmDD[] = { __DATE__[7], __DATE__[8], __DATE__[9], __DATE__[10], '/', __DATE__[0], __DATE__[1], __DATE__[2], '/', __DATE__[4], __DATE__[5], '\\0' }; // Version (code/board) information printed as one line to serial (with line-end, and flushed); machine- and human- parseable. // Format: ""board VXXXX REVY; code YYYY/Mmm/DD HH:MM:SS"". void serialPrintlnBuildVersion() { serialPrintAndFlush(F(""board V0.2 REV"")); serialPrintAndFlush(V0p2_REV); serialPrintAndFlush(F(""; code "")); serialPrintAndFlush(_YYYYMmmDD); serialPrintAndFlush(F("" "" __TIME__)); serialPrintlnAndFlush(); } // Setup routine: runs once after reset. // Does some limited board self-test and will panic() if anything is obviously broken. void setup() { // Set appropriate low-power states, interrupts, etc, ASAP. powerSetup(); // Capture early sub-cycle time to help ensure that the 32768Hz async clock is actually running. const uint8_t earlySCT = getSubCycleTime(); IOSetup(); // Restore previous RTC state if available. RTC::restoreRTC(); // TODO: consider code to calibrate the internal RC oscillator against the xtal, eg to keep serial comms happy, eg http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=36237&start=0 serialPrintAndFlush(F(""\\r\\nOpenTRV booting: "")); // Leading CRLF to clear leading junk, eg from bootloader. serialPrintlnBuildVersion(); // Count resets to detect unexpected crashes/restarts. const uint8_t oldResetCount = eeprom_read_byte((uint8_t *)EE_START_RESET_COUNT); eeprom_write_byte((uint8_t *)EE_START_RESET_COUNT, 1 + oldResetCount); #ifdef DEBUG DEBUG_SERIAL_PRINTLN_FLASHSTRING(""DEBUG mode with serial logging""); #endif #ifdef DEBUG DEBUG_SERIAL_PRINT_FLASHSTRING(""Resets: ""); DEBUG_SERIAL_PRINT(oldResetCount); DEBUG_SERIAL_PRINTLN(); const uint8_t overruns = (~eeprom_read_byte((uint8_t *)EE_START_OVERRUN_COUNTER)) & 0xff; if(0 != overruns) { DEBUG_SERIAL_PRINT_FLASHSTRING(""Overruns: ""); DEBUG_SERIAL_PRINT(overruns); DEBUG_SERIAL_PRINTLN(); } // Compute approx free RAM: see http://jeelabs.org/2011/05/22/atmega-memory-use/ DEBUG_SERIAL_PRINT_FLASHSTRING(""Free RAM: ""); extern int __heap_start, *__brkval; int x; DEBUG_SERIAL_PRINT((int) &x - (__brkval == 0 ? (int) &__heap_start : (int) __brkval)); DEBUG_SERIAL_PRINTLN(); #ifdef UNIT_TESTS DEBUG_SERIAL_PRINTLN_FLASHSTRING(""UNIT TESTS WILL BE RUN...""); #endif #endif posPOST(1, F(""about to test RFM23"")); #ifdef USE_MODULE_RFM22RADIOSIMPLE #if !defined(RFM22_IS_ACTUALLY_RFM23) && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""(Using RFM22.)""); #endif // Initialise the radio, if configured, ASAP because it can suck a lot of power until properly initialised. RFM22PowerOnInit(); // Check that the radio is correctly connected; panic if not... if(!RFM22CheckConnected()) { panic(); } // Configure the radio. RFM22RegisterBlockSetup(FHT8V_RFM22_Reg_Values); // Put the radio in low-power standby mode. RFM22ModeStandbyAndClearState(); #endif posPOST(2, F(""RFM23 OK"")); #ifdef DEBUG // Do additional POST. optionalPOST(); #endif // Get current power supply voltage. const uint16_t Vcc = readBatterymV(); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""Vcc: ""); DEBUG_SERIAL_PRINT(Vcc); DEBUG_SERIAL_PRINTLN_FLASHSTRING(""mV""); #endif // Get internal temperature measurement. const int intTempC16 = readInternalTemperatureC16(); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""Int temp: ""); DEBUG_SERIAL_PRINT((intTempC16 + 8) >> 4); DEBUG_SERIAL_PRINT_FLASHSTRING(""C / ""); DEBUG_SERIAL_PRINT(intTempC16); DEBUG_SERIAL_PRINTLN(); #endif posPOST(3, F(""internal sensors OK, next light/temp/other"")); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Gathering initial inputs and computing target/demand...""); #endif // Collect full set of environmental values before entering loop(). // This should also help ensure that sensors are properly initialised. const lightLevel_t light = Light::readAmbientLight(); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""light: ""); DEBUG_SERIAL_PRINT(light); DEBUG_SERIAL_PRINTLN(); #endif // // Assume 0 or full-scale values unlikely. // if((0 == light) || (light >= 1023)) { panic(F(""LDR fault"")); } const tempC16_t heat = Temp::readTemperatureC16(); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""temp: ""); DEBUG_SERIAL_PRINT(heat); DEBUG_SERIAL_PRINTLN(); #endif #if defined(TEMP_POT_AVAILABLE) const int tempPot = readTempPot(); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""temp pot: ""); DEBUG_SERIAL_PRINT(tempPot); DEBUG_SERIAL_PRINTLN(); #endif #endif // Check buttons not stuck enabled. if(fastDigitalRead(BUTTON_MODE_L) == LOW) { panic(F(""M stuck"")); } #if defined(BUTTON_LEARN_L) if(fastDigitalRead(BUTTON_LEARN_L) == LOW) { panic(F(""L stuck"")); } #endif #if defined(BUTTON_LEARN2_L) if(fastDigitalRead(BUTTON_LEARN2_L) == LOW) { panic(F(""L2 stuck"")); } #endif posPOST(4, F(""light/temp OK"")); #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Gathering initial inputs and computing target/demand...""); #endif // Update targets, output to TRV and boiler, etc, to be sensible before main loop starts. computeCallForHeat(); #if defined(USE_MODULE_FHT8VSIMPLE) #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Creating initial FHT8V frame...""); #endif // Unconditionally ensure that a valid FHT8V TRV command frame has been computed and stored // in case this unit is actually controlling a local valve. FHT8VCreateValveSetCmdFrame(); #endif // Seed PRNG(s) with available environmental values and clock time/jitter for some entropy. // Also sweeps over SRAM and EEPROM (see RAMEND and E2END), especially for non-volatile state and uninitialised areas of SRAM. // TODO: add better PRNG with entropy pool (eg for crypto). // TODO: add RFM22B WUT clock jitter, RSSI, temperature and battery voltage measures. #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Starting seed computation...""); #endif const uint16_t srseed = sramCRC(); const uint16_t eeseed = eeCRC(); // Check that the 32768Hz async clock is actually running having done significant CPU-intensive work. const uint8_t laterSCT = getSubCycleTime(); if(laterSCT == earlySCT) { #if defined(WAKEUP_32768HZ_XTAL) // Allow (an extra) 1s+ for 32768Hz crystal to start reliably, see: http://www.atmel.com/Images/doc1259.pdf #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Sleeping to let async 32768Hz clock start...""); #endif // Time spent here should not be a whole multiple of basic cycle time to avoid spuriously stationary async clock reading! for(int i = 20; (--i >= 0) && (earlySCT == getSubCycleTime()); ) { sleepLowPowerMs(691); captureEntropy1(); } #endif const uint8_t latestSCT = getSubCycleTime(); if(latestSCT == earlySCT) { #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Async 32768Hz clock may not be running!""); #endif panic(F(""XTAL dead"")); // Async clock not running. } } posPOST(5, F(""slow RTC clock OK"")); // DHD20130430: maybe as much as 16 bits of entropy on each reset in seed1, concentrated in the least-significant bits. const uint16_t s16 = (__DATE__[5]) ^ ((RTC::getMinutesSinceMidnightLT() << 5) ^ (((int)getSubCycleTime()) << 7) ^ (heat << 2) ^ (light << 6) ^ Vcc ^ intTempC16); /* This fits in an int (16 bits). */ //const long seed1 = ((((long) clockJitterRTC()) << 13) ^ (((long)clockJitterWDT()) << 21) ^ (((long)(srseed^eeseed)) << 16)) + s16; // Seed simple/fast/small built-in PRNG. (Smaller and faster than srandom()/random().) const uint8_t nar1 = noisyADCRead(); seedRNG8(nar1 ^ (uint8_t) s16, oldResetCount - (uint8_t)((s16+eeseed) >> 8), clockJitterWDT() ^ (uint8_t)srseed); #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""nar ""); DEBUG_SERIAL_PRINTFMT(nar1, BIN); DEBUG_SERIAL_PRINTLN(); #endif // TODO: seed other/better PRNGs. // Feed in mainly persistent/nonvolatile state explicitly. addEntropyToPool(oldResetCount ^ eeseed, 0); addEntropyToPool((uint8_t)(eeseed >> 8) + nar1, 0); addEntropyToPool((uint8_t)s16 ^ (uint8_t)(s16 >> 8) , 0); for(uint8_t i = 0; i < EE_LEN_SEED; ++i) { addEntropyToPool(eeprom_read_byte((uint8_t *)(EE_START_SEED + i)), 0); } addEntropyToPool(noisyADCRead(), 4); // Conservative first push of noise into pool. // Carry a few bits of entropy over a reset by picking one of the four designated EEPROM bytes at random; // if zero, erase to 0xff, else AND in part of the seed including some of the previous EEPROM hash (and write). // This amounts to about a quarter of an erase/write cycle per reset/restart per byte, or 400k restarts endurance! // These 4 bytes should be picked up as part of the hash/CRC of EEPROM above, next time, // essentially forming a longish-cycle (poor) PRNG even with little new real entropy each time. seedRNG8(nar1 ^ (uint8_t) s16, oldResetCount - (uint8_t)((s16+eeseed) >> 8), clockJitterWDT() ^ (uint8_t)srseed); uint8_t *const erp = (uint8_t *)(EE_START_SEED + (3&((s16)^((eeseed>>8)+(__TIME__[7]))))); // Use some new and some eeseed bits to choose which byte to updated. const uint8_t erv = eeprom_read_byte(erp); if(0 == erv) { eeprom_smart_erase_byte(erp); } else { eeprom_smart_clear_bits(erp, clockJitterEntropyByte() + ((uint8_t)eeseed)); } // Nominally include disjoint set of eeseed bits in choice of which to clear. #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""srseed ""); DEBUG_SERIAL_PRINTFMT(srseed, BIN); DEBUG_SERIAL_PRINTLN(); DEBUG_SERIAL_PRINT_FLASHSTRING(""eeseed ""); DEBUG_SERIAL_PRINTFMT(eeseed, BIN); DEBUG_SERIAL_PRINTLN(); DEBUG_SERIAL_PRINT_FLASHSTRING(""RNG8 ""); DEBUG_SERIAL_PRINTFMT(randRNG8(), BIN); DEBUG_SERIAL_PRINTLN(); DEBUG_SERIAL_PRINT_FLASHSTRING(""erv ""); DEBUG_SERIAL_PRINTFMT(erv, BIN); DEBUG_SERIAL_PRINTLN(); #endif // Initialised: turn heatcall UI LED off. // pinMode(LED_HEATCALL, OUTPUT); LED_HEATCALL_OFF(); #if defined(SUPPORT_CLI) // Help user get to CLI. serialPrintlnAndFlush(F(""? at CLI prompt for help"")); #endif // Ensure ID set up (mainly on first use). // Have one attempt (don't want to bang already failign EEPROM) to force-reset if not good, then panic. if(!ensureIDCreated()) { if(!ensureIDCreated(true)) // Force reset. { panic(F(""Invalid ID and cannot reset, sorry."")); } } // Report initial status. serialStatusReport(); // Set appropriate loop() values just before entering it. TIME_LSD = RTC::getSecondsLT(); } // Call this to do an I/O poll if needed; returns true if something useful happened. // This call should typically take << 1ms at 1MHz CPU. // Does not change CPU clock speeds, mess with interrupts (other than possible brief blocking), or sleep. // Limits actual poll rate to something like once every 32ms, unless force is true. // * force if true then force full poll on every call (ie do not internally rate-limit) bool pollIO(const bool force) { #if defined(ENABLE_BOILER_HUB) && defined(USE_MODULE_FHT8VSIMPLE) if(inHubMode()) { static volatile uint8_t _pO_lastPoll; // Poll RX at most about every ~32ms to help approx match spil rate when called in loop with 30ms nap. const uint8_t sct = getSubCycleTime(); if(force || ((0 == (sct & 3)) && (sct != _pO_lastPoll))) { _pO_lastPoll = sct; if(FHT8VCallForHeatPoll()) // Check if call-for-heat has been overheard. { return(true); } } } #endif return(false); } //======================================== // MAIN LOOP //======================================== #ifdef UNIT_TESTS // Run unit tests *instead* of normal loop() code. void loop() { unitTestLoop(); } #else // 'Elapsed minutes' count of minute/major cycles; cheaper than accessing RTC and not tied to real time. static uint8_t minuteCount; #if defined(ENABLE_BOILER_HUB) // Ticks until locally-controlled boiler should be turned off; boiler should be on while this is positive. // Ticks are the mail loop time, 1s or 2s. // Used in hub mode only. static uint16_t boilerCountdownTicks; // Minutes since boiler last on as result of remote call for heat. // Reducing listening if quiet for a while helps reduce self-heating temperature error // (~2C as of 2013/12/24 at 100% RX, ~100mW heat dissipation in V0.2 REV1 box) and saves some energy. // Time thresholds could be affected by eco/comfort switch. #define RX_REDUCE_MIN_M 20 // Minimum minutes quiet before considering reducing RX duty cycle listening for call for heat; [1--255], 10--60 typical. // IF DEFINED then give backoff threshold to minimise duty cycle. // #define RX_REDUCE_MAX_M 240 // Minutes quiet before considering maximally reducing RX duty cycle; ]RX_REDUCE_MIN_M--255], 30--240 typical. static uint8_t boilerNoCallM; #endif // The main control loop routine runs forever. // Note: exiting loop() and re-entering can take a little while, handling Arduino background tasks such as serial. void loop() { #if 0 && defined(DEBUG) // Indicate loop start. DEBUG_SERIAL_PRINT('L'); DEBUG_SERIAL_PRINT(TIME_LSD); DEBUG_SERIAL_PRINTLN(); #endif // Set up some variables before sleeping to minimise delay/jitter after the RTC tick. bool showStatus = false; // Show status at end of loop? // Use the zeroth second in each minute to force extra deep device sleeps/resets, etc. const bool second0 = (0 == TIME_LSD); if(second0) { // Tick minute. RTC::tickMinuteRTC(); } // Sensor readings are taken late in each minute (where they are taken) // and if possible noise and heat and light should be minimised in this part of each minute to improve readings. // const bool sensorReading30s = (TIME_LSD >= 30); // Sensor readings and (stats transmissions) are nominally on a 4-minute cycle. const uint8_t minuteFrom4 = (minuteCount & 3); // The 0th minute in each group of four is always used for measuring where possible (possibly amongst others) // and where possible locally-generated noise and heat and light should be minimised in this minute to give the best possible readings. // This is the first (0th) minute in each group of four. const bool minute0From4ForSensors = (0 == minuteFrom4); // True the minute after all sensors should have been sampled. const bool minute1From4AfterSensors = (1 == minuteFrom4); // Note last-measured battery status. const bool batteryLow = isBatteryLow(); // Run some tasks less often when not demanding heat (at the valve or boiler), so as to conserve battery/energy. const bool conserveBattery = (batteryLow || !inWarmModeDebounced()) && // Don't spare the batteries unless low, or in FROST mode (which should be most of the time). #if defined(ENABLE_BOILER_HUB) (0 == boilerCountdownTicks) && // Unless the boiler is off, stay responsive. #endif (!isControlledValveOpen()) && // Run at full speed until the FHT8V valve should actually have shut and the boiler gone off. (0 == getTRVPercentOpen()); // Run at full speed until not nominally demanding heat, eg even during FROST mode or pre-heating. // Try if very near to end of cycle and thus causing an overrun. // Conversely, if not true, should have time to savely log outputs, etc. const uint8_t nearOverrunThreshold = GSCT_MAX - 8; // ~64ms/~32 serial TX chars of grace time... bool tooNearOverrun = false; // Set flag that can be checked later. // Is this unit currently in central hub listener mode? const bool hubMode = inHubMode(); // Check (early) for any remote stats arriving to dump. // This is designed to be easy to pick up by reading the serial output. // The output is terse to avoid taking too long and possibly delaying other stuff too far. // Avoid doing this at all if too near the end of the cycle and risking overrun, // leaving any message queued, hoping it does not get overwritten. if(getSubCycleTime() >= nearOverrunThreshold) { tooNearOverrun = true; } else { FullStatsMessageCore_t stats; getLastCoreStats(&stats); if(stats.containsID) { // Dump (remote) stats field '@;TnnCh[P;]' // where the T field shows temperature in C with a hex digit after the binary point indicated by C // and the optional P field indicates low power. serialPrintAndFlush(LINE_START_CHAR_RSTATS); serialPrintAndFlush((((uint16_t)stats.id0) << 8) | stats.id1, HEX); if(stats.containsTempAndPower) { serialPrintAndFlush(F("";T"")); serialPrintAndFlush(stats.tempAndPower.tempC16 >> 4, DEC); serialPrintAndFlush('C'); serialPrintAndFlush(stats.tempAndPower.tempC16 & 0xf, HEX); if(stats.tempAndPower.powerLow) { serialPrintAndFlush(F("";P"")); } // Insert power-low field if needed. } if(stats.containsAmbL) { serialPrintAndFlush(F("";L"")); serialPrintAndFlush((uint16_t) (stats.ambL << 2)); // revert to light scaling } if(0 != stats.occ) { serialPrintAndFlush(F("";O"")); serialPrintAndFlush(stats.occ); } serialPrintlnAndFlush(); } } // IF IN CENTRAL HUB MODE: listen out for OpenTRV units calling for heat. // Power optimisation 1: when >> 1 TX cycle (of ~2mins) need not listen, ie can avoid enabling receiver. // Power optimisation 2: TODO: when (say) >>30m since last call for heat then only sample listen for (say) 3 minute in 10 (not at a TX cycle multiple). // TODO: These optimisation are more important when hub unit is running a local valve // to avoid temperature over-estimates from self-heating, // and could be disabled if no local valve is being run to provide better response to remote nodes. bool hubModeBoilerOn = false; // If true then remote call for heat is in progress. #if defined(USE_MODULE_FHT8VSIMPLE) bool needsToEavesdrop = false; // By default assume no need to eavesdrop. #endif if(hubMode) { #if defined(USE_MODULE_FHT8VSIMPLE) // Final poll to to cover up to end of previous minor loop. // Keep time from here to following SetupToEavesdropOnFHT8V() as short as possible to avoid missing remote calls. FHT8VCallForHeatPoll(); // Fetch and clear current pending sample house code calling for heat. const uint16_t hcRequest = FHT8VCallForHeatHeardGetAndClear(); const bool heardIt = (hcRequest != ((uint16_t)~0)); // Don't log call for hear if near overrun, // and leave any error queued for next time. if(getSubCycleTime() >= nearOverrunThreshold) { tooNearOverrun = true; } else { if(heardIt) { DEBUG_SERIAL_TIMESTAMP(); DEBUG_SERIAL_PRINT(' '); serialPrintAndFlush(F(""CfH "")); // Call for heat from serialPrintAndFlush((hcRequest >> 8) & 0xff); serialPrintAndFlush(' '); serialPrintAndFlush(hcRequest & 0xff); serialPrintlnAndFlush(); } else { // Check for error if nothing received. const uint8_t err = FHT8VLastRXErrGetAndClear(); if(0 != err) { serialPrintAndFlush(F(""!RXerr F"")); serialPrintAndFlush(err); serialPrintlnAndFlush(); } } } // Record call for heat, both to start boiler-on cycle and to defer need to listen again. // Optimisation: may be able to stop RX if boiler is on for local demand (can measure local temp better: less self-heating). if(heardIt) { if(0 == boilerCountdownTicks) { if(getSubCycleTime() >= nearOverrunThreshold) { tooNearOverrun = true; } else { serialPrintlnAndFlush(F(""RCfH1"")); } // Remote call for heat on. } boilerCountdownTicks = getMinBoilerOnMinutes() * (60/MAIN_TICK_S); boilerNoCallM = 0; // No time has passed since the last call. } // Else count down towards boiler off. else if(boilerCountdownTicks > 0) { if(0 == --boilerCountdownTicks) { if(getSubCycleTime() >= nearOverrunThreshold) { tooNearOverrun = true; } else { serialPrintlnAndFlush(F(""RCfH0"")); } // Remote call for heat off } } // Else already off so count up quiet minutes... else if(second0 && (boilerNoCallM < (uint8_t)~0)) { ++boilerNoCallM; } // Turn boiler output on or off in response to calls for heat. hubModeBoilerOn = (boilerCountdownTicks > 0); // If not running a local TRV, and this without local temperature measurement problems from self-heating, // then just listen all the time for maximum simplicity and responsiveness at some cost in extra power consumption. // (At least as long as power is not running low for some reasons.) if(!localFHT8VTRVEnabled() && !batteryLow) { needsToEavesdrop = true; } // Try to avoid listening in the 'quiet' sensor minute in order to minimise noise and power consumption and self-heating. // Optimisation: if just heard a call need not listen on this next cycle. // Optimisation: if boiler timeout is a long time away (>> one FHT8V TX cycle, ~2 minutes excl quiet minute), then can avoid listening for now. // Longish period without any RX listening may allow hub unit to cool and get better sample of local temperature if marginal. // Aim to listen in one stretch for greater than full FHT8V TX cycle of ~2m to avoid missing a call for heat. // MUST listen for all of final 2 mins of boiler-on to avoid missing TX (without forcing boiler over-run). else if((boilerCountdownTicks <= ((MAX_FHT8V_TX_CYCLE_HS+1)/(2*MAIN_TICK_S))) && // Don't miss a final TX that would keep the boiler on... (boilerCountdownTicks != 0)) // But don't force unit to listen/RX all the time if no recent call for heat. { needsToEavesdrop = true; } else if((!heardIt) && (!minute0From4ForSensors) && (boilerCountdownTicks <= (RX_REDUCE_MIN_M*(60/MAIN_TICK_S)))) // Listen eagerly for fresh calls for heat for last few minutes before turning boiler off. { #if defined(RX_REDUCE_MAX_M) && defined(LOCAL_TRV) // Skip the minute before the 'quiet' minute also in very quiet mode to improve local temp measurement. // (Should still catch at least one TX per 4 minutes at worst.) needsToEavesdrop = ((boilerNoCallM <= RX_REDUCE_MAX_M) || (3 != (minuteCount & 3))); #else needsToEavesdrop = true; #endif } #endif } #if defined(USE_MODULE_FHT8VSIMPLE) // Act on eavesdropping need, setting up or clearing down hooks as required. if(needsToEavesdrop) { // Ensure radio is in RX mode rather than standby, and possibly hook up interrupts if available (REV1 board). SetupToEavesdropOnFHT8V(second0); // Start listening (if not already so). #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""hub listen, on/cd ""); DEBUG_SERIAL_PRINT(boilerCountdownTicks); DEBUG_SERIAL_PRINT_FLASHSTRING(""t quiet ""); DEBUG_SERIAL_PRINT(boilerNoCallM); DEBUG_SERIAL_PRINTLN_FLASHSTRING(""m""); #endif } else { // Power down and clear radio state (if currently eavesdropping). StopEavesdropOnFHT8V(second0); // Clear any RX state so that nothing stale is carried forward. FHT8VCallForHeatHeardGetAndClear(); } #endif // Set BOILER_OUT as appropriate for local and/or remote calls for heat. // FIXME: local valve-driven boiler on does not obey normal on/off run-time rules. fastDigitalWrite(OUT_HEATCALL, ((hubModeBoilerOn || isControlledValveOpen()) ? HIGH : LOW)); // Sleep in low-power mode (waiting for interrupts) until seconds roll. // NOTE: sleep at the top of the loop to minimise timing jitter/delay from Arduino background activity after loop() returns. // DHD20130425: waking up from sleep and getting to start processing below this block may take >10ms. #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""*E""); // End-of-cycle sleep. #endif powerDownSerial(); // Ensure that serial I/O is off. // Power down most stuff (except radio for hub RX). minimisePowerWithoutSleep(); uint_fast8_t newTLSD; while(TIME_LSD == (newTLSD = RTC::getSecondsLT())) { #if defined(ENABLE_BOILER_HUB) && defined(USE_MODULE_FHT8VSIMPLE) // Deal with FHT8V eavesdropping if needed. // Poll for RX of remote calls-for-heat if needed. if(needsToEavesdrop) { nap30AndPoll(); continue; } #endif #if defined(USE_MODULE_RFM22RADIOSIMPLE) // Force radio to power-saving standby state if appropriate. // Force radio to known-low-power state from time to time (not every time to avoid unnecessary SPI work, LED flicker, etc.) if(batteryLow || second0) { RFM22ModeStandbyAndClearState(); } #endif sleepUntilInt(); // Normal long minimal-power sleep until wake-up interrupt. } TIME_LSD = newTLSD; #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""*S""); // Start-of-cycle wake. #endif #if defined(ENABLE_BOILER_HUB) && defined(USE_MODULE_FHT8VSIMPLE) // Deal with FHT8V eavesdropping if needed. // Check RSSI... if(needsToEavesdrop) { const uint8_t rssi = RFM22RSSI(); static uint8_t lastRSSI; if((rssi > 0) && (lastRSSI != rssi)) { lastRSSI = rssi; addEntropyToPool(rssi, 0); // Probably some real entropy but don't assume it. #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""RSSI=""); DEBUG_SERIAL_PRINT(rssi); DEBUG_SERIAL_PRINTLN(); #endif } } #endif #if 0 && defined(DEBUG) // Show CPU cycles. DEBUG_SERIAL_PRINT('C'); DEBUG_SERIAL_PRINT(cycleCountCPU()); DEBUG_SERIAL_PRINTLN(); #endif // START LOOP BODY // =============== // Warn if too near overrun before. if(tooNearOverrun) { serialPrintlnAndFlush(F(""?near overrun"")); } // Get current power supply voltage. #if 0 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""Vcc: ""); DEBUG_SERIAL_PRINT(readBatterymV()); DEBUG_SERIAL_PRINTLN_FLASHSTRING(""mV""); #endif #if defined(USE_MODULE_FHT8VSIMPLE) // FHT8V is highest priority and runs first. // ---------- HALF SECOND #0 ----------- bool useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_First(!conserveBattery); // Time for extra TX before UI. // if(useExtraFHT8VTXSlots) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""ES@0""); } #endif // High-priority UI handing, every other/even second. // Show status if the user changed something significant. // Must take ~300ms or less so as not to run over into next half second if two TXs are done. bool recompute = false; // Set true an extra recompute of target temperature should be done. #if !defined(TWO_S_TICK_RTC_SUPPORT) if(0 == (TIME_LSD & 1)) #endif { if(tickUI(TIME_LSD)) { showStatus = true; recompute = true; } } if(recompute || recentUIControlUse()) { computeTargetTemperature(); // Force recompute of temperature for (UI) responsiveness. } #if defined(USE_MODULE_FHT8VSIMPLE) if(useExtraFHT8VTXSlots) { // Time for extra TX before other actions, but don't bother if minimising power in frost mode. // ---------- HALF SECOND #1 ----------- useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(!conserveBattery); // if(useExtraFHT8VTXSlots) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""ES@1""); } } #endif // While debugging switchover to phototransistor... // DEBUG_SERIAL_PRINT('L'); // DEBUG_SERIAL_PRINT(Light::readAmbientLight()); // DEBUG_SERIAL_PRINTLN(); // DO SCHEDULING // Once-per-minute tasks: all must take << 0.3s. // Run tasks spread throughout the minute to be as kind to batteries (etc) as possible. // Only when runAll is true run less-critical tasks that be skipped sometimes when particularly conserving energy. // TODO: coordinate temperature reading with time when radio and other heat-generating items are off for more accurate readings. // TODO: ensure only take ambient light reading at times when all LEDs are off. const bool runAll = (!conserveBattery) || minute0From4ForSensors; switch(TIME_LSD) // With TWO_S_TICK_RTC_SUPPORT only even seconds are available. { case 0: { // Tasks that must be run every minute. ++minuteCount; checkUserSchedule(); // Force to user's programmed settings, if any, at the correct time. // Ensure that the RTC has been persisted promptly when necessary. RTC::persistRTC(); break; } // Churn/reseed PRNG(s) a little to improve unpredictability in use: should be lightweight. case 2: { if(runAll) { seedRNG8(minuteCount ^ cycleCountCPU() ^ (uint8_t)getBatterymV(), getSubCycleTime() ^ (uint8_t)Light::getAmbientLight(), (uint8_t)Temp::getTemperatureC16()); } break; } // Force read of battery voltage; measure and recompute status less often when already thought to be low, eg when conserving. case 4: { if(runAll) { readBatterymV(); } break; } #if defined(USE_MODULE_FHT8VSIMPLE) && defined(FHT8V_ALLOW_EXTRA_TXES) // Re-transmit slot for additional comms with boiler hub, eg when valve wide open, to help ensure reliable/fast call for heat. // This is entirely optional, and just improves odds of an urgent call for heat being acted on quickly, // so it can be cancelled with any reasonable excuse to save some energy and bandwidth. // This should always be safe, ie not done unless valve actually open, etc, // though it may cause the boiler to overrun a little into a closing valve under some circumstances. case 8: { if((!hubMode) && // Hub doesn't need to send extra TXes to itself! (!batteryLow) && // Don't send if battery is low. (!useExtraFHT8VTXSlots) && // Don't send if there's an immediately pending TX. inWarmModeDebounced() && // Only do extra TX if still in a warming mode, ie don't TX if mode just changed to FROST. (isControlledValveOpen()) && // Valve should be open already so we won't hurt the pump/boiler with call for heat. ((getTRVPercentOpen() >= 75) || inBakeModeDebounced())) // Valve fairly wide open, eg for BAKE or because boiler not hearing us reliably. { #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Extra FTH8V TX""); #endif pollIO(); // Deal with any pending I/O. sleepLowPowerLessThanMs(1 | (randRNG8() & 0x7f)); // Sleep randomly up to 127ms to spread transmissions and help avoid collisions. pollIO(); // Deal with any pending I/O. FHT8VDoSafeExtraTXToHub(); // Takes up to ~80ms. } break; } #endif // Regular transmission of stats if NOT driving a local valve and not a hub, ie needing to stay in RX mode. case 10: { if(hubMode) { break; } // Hub can't allow random switch to TX mode. if(!enableTrailingMinimalStatsPayload()) { break; } // Not allowed to send stuff like this. #if defined(USE_MODULE_FHT8VSIMPLE) if(localFHT8VTRVEnabled()) { break; } // Do only piggy-back stats TXes if driving an FHT8V to save bandwidth/conflicts. #endif // Generally only attempt stats TX in the minute after all sensors should have been polled (so that readings are fresh). if(minute1From4AfterSensors || (!batteryLow && (0 == (0x24 & randRNG8())))) // Occasional additional TX when not conserving power. { // Gather core stats. FullStatsMessageCore_t content; populateCoreStats(&content); // Create (insecure) message. uint8_t buf[RFM22_PREAMBLE_BYTES + RFM22_SYNC_MIN_BYTES + FullStatsMessageCore_MAX_BYTES_ON_WIRE + 1]; uint8_t *bptr = buf; // Start with RFM23-friendly preamble which ends with with the aacccccc sync word. memset(bptr, RFM22_PREAMBLE_BYTE, RFM22_PREAMBLE_BYTES); bptr += RFM22_PREAMBLE_BYTES; memset(bptr, RFM22_SYNC_BYTE, RFM22_SYNC_MIN_BYTES); bptr += RFM22_SYNC_MIN_BYTES; const uint8_t *msg1 = encodeFullStatsMessageCore(bptr, sizeof(buf) - (bptr-buf), getStatsTXLevel(), false, &content); if(NULL == msg1) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Msg gen err!""); break; } pollIO(); // Deal with any pending I/O. sleepLowPowerLessThanMs(1 | (randRNG8() & 0x7f)); // Sleep randomly up to 127ms to spread transmissions and help avoid collisions. pollIO(); // Deal with any pending I/O. // TODO: put in listen before TX to reduce collisions (CSMA) // Send message! // Assume RFM22/23 support for now. RFM22QueueCmdToFF(buf); RFM22TXFIFO(); // Send it! Approx 1.6ms/byte. RFM22ModeStandbyAndClearState(); // Go to standby to conserve energy. DEBUG_SERIAL_PRINTLN_FLASHSTRING(""Bare stats TX""); } break; } // Read all environmental inputs, late in the cycle. #ifdef TEMP_POT_AVAILABLE // Sample the user-selected WARM temperature target. case 50: { if(runAll) { readTempPot(); } break; } #endif // Sample ambient light levels. case 52: { if(runAll) { Light::readAmbientLight(); } break; } // At a hub, sample temperature as late as possible in (and only in the 'quiet') minute, to reduce valve hunting from self-heating. case 54: { if(hubMode ? minute0From4ForSensors : runAll) { Temp::readTemperatureC16(); } break; } // Compute targets and heat demand based on environmental inputs. // Note: ensure that valve-shut message is always conveyed quickly to valve even in slow/'conserve' mode. // Also drives OUT_HEATCALL to control local boiler if in central hub mode. case 56: { static bool boilerOn; // Internal record of current boiler-out state. // Recompute target, valve position and call for heat, etc. // Should be called once per minute to work correctly. if(computeCallForHeat() || (minute1From4AfterSensors && enableTrailingMinimalStatsPayload())) { // If there was a change in target valve position, // or periodically in a minute after all sensors should have been read, // precompute some or all of any outgoing frames/stats/etc ready for transmission. #if defined(USE_MODULE_FHT8VSIMPLE) // Recompute FHT8V command to send if target valve setting has changed... if(localFHT8VTRVEnabled()) { FHT8VCreateValveSetCmdFrame(); } #endif } #if defined(ENABLE_BOILER_HUB) // Track how long since remote call for heat last heard. if(hubMode) { if(boilerCountdownTicks != 0) { #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""Boiler on, s left: ""); DEBUG_SERIAL_PRINT(boilerCountdownTicks * MAIN_TICK_S); DEBUG_SERIAL_PRINTLN(); #endif } } #endif // Show current status if appropriate. if(runAll) { showStatus = true; } break; } // Stats samples; should never be missed. case 58: { // Take full stats sample as near the end of the hour as reasonably possible (without danger of overrun), // and with other optional non-full samples evenly spaced throughout the hour (if not low on battery). if(minute0From4ForSensors) // Hope to take lowest-noise samples on the special minute out of each 4. { const uint_least8_t mm = RTC::getMinutesLT(); switch(mm) { case 16: case 17: case 18: case 19: case 36: case 37: case 38: case 39: { if(!batteryLow) { sampleStats(false); } break; } // Skip sub-samples if short of juice. case 56: case 57: case 58: case 59: { sampleStats(true); break; } // Always take the full sample at end of hour. } } break; } } #if defined(USE_MODULE_FHT8VSIMPLE) && defined(TWO_S_TICK_RTC_SUPPORT) if(useExtraFHT8VTXSlots) { // Time for extra TX before other actions, but don't bother if minimising power in frost mode. // ---------- HALF SECOND #2 ----------- useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(!conserveBattery); // if(useExtraFHT8VTXSlots) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""ES@2""); } } #endif // Generate periodic status reports. if(showStatus) { serialStatusReport(); } #if defined(USE_MODULE_FHT8VSIMPLE) && defined(TWO_S_TICK_RTC_SUPPORT) if(useExtraFHT8VTXSlots) { // ---------- HALF SECOND #3 ----------- useExtraFHT8VTXSlots = localFHT8VTRVEnabled() && FHT8VPollSyncAndTX_Next(!conserveBattery); // if(useExtraFHT8VTXSlots) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""ES@3""); } } #endif // Command-Line Interface (CLI) polling. // If a reasonable chunk of the minor cycle remains after all other work is done // AND the CLI is / should be active OR a status line has just been output // then poll/prompt the user for input // using a timeout which should safely avoid missing the next basic tick // and which should also allow some energy-saving sleep. #if 1 && defined(SUPPORT_CLI) const bool humanCLIUse = isCLIActive(); // Keeping CLI active for human interaction rather than for automated interaction. if(showStatus || humanCLIUse) { const uint8_t sct = getSubCycleTime(); const uint8_t listenTime = max(GSCT_MAX/16, CLI_POLL_MIN_SCT); if(sct < (GSCT_MAX - 2*listenTime)) // Don't listen beyond the last 16th of the cycle, // or a minimal time if only prodding for interaction with automated front-end, // as listening for UART RX uses lots of power. { pollCLI(humanCLIUse ? (GSCT_MAX-listenTime) : (sct+CLI_POLL_MIN_SCT)); } } #endif #if 0 && defined(DEBUG) const int tDone = getSubCycleTime(); if(tDone > 1) // Ignore for trivial 1-click time. { DEBUG_SERIAL_PRINT_FLASHSTRING(""done in ""); // Indicates what fraction of available loop time was used / 256. DEBUG_SERIAL_PRINT(tDone); DEBUG_SERIAL_PRINT_FLASHSTRING("" @ ""); DEBUG_SERIAL_TIMESTAMP(); DEBUG_SERIAL_PRINTLN(); } #endif // Detect and handle (actual or near) overrun, if it happens, though it should not. if(TIME_LSD != RTC::getSecondsLT()) { // Increment the overrun counter (stored inverted, so 0xff initialised => 0 overruns). const uint8_t orc = 1 + ~eeprom_read_byte((uint8_t *)EE_START_OVERRUN_COUNTER); eeprom_smart_update_byte((uint8_t *)EE_START_OVERRUN_COUNTER, ~orc); #if 1 && defined(DEBUG) DEBUG_SERIAL_PRINT_FLASHSTRING(""!ERROR: loop overrun ""); DEBUG_SERIAL_PRINT(orc); DEBUG_SERIAL_PRINTLN(); #endif #if defined(USE_MODULE_FHT8VSIMPLE) FHT8VSyncAndTXReset(); // Assume that sync with valve may have been lost, so re-sync. #endif TIME_LSD = RTC::getSecondsLT(); // Prepare to sleep until start of next full minor cycle. } #if 0 && defined(DEBUG) // Expect to pick up near overrun at start of next loop. else if(getSubCycleTime() >= nearOverrunThreshold) { DEBUG_SERIAL_PRINTLN_FLASHSTRING(""?O""); // Near overrun. Note 2ms/char to send... } #endif } #endif // defined(UNIT_TESTS) ",12157,False,2358.5436592297633,median "/* StringLineU8x8.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include /* Preconditions: Uno with DOGS102 Shield */ // Please UNCOMMENT one of the contructor lines below // U8x8 Contructor List // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing //U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 6, /* dc=*/ 4, /* reset=*/ 12); // Arduboy (DevKit) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy 10 (Production, Kickstarter Edition) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_HW_SPI u8x8(/* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); // Digispark ATTiny85 //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display //U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SSD1306_128X64_ALT0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SH1106_128X64_WINSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8X8_SH1106_128X32_VISIONOX_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X32_VISIONOX_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_72X40_WISE_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_64X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_PIMORONI_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_SEEED_128X128_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_128X128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1108_160X160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_128X32_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_64X48_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8X8_SSD1306_48X64_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_1F_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_96X16_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" //U8X8_SSD1306_72X40_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" //U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1317_96X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1317_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1318_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1318_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1326_ER_256X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8X8_SSD1327_SEEED_96X96_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_SEEED_96X96_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_EA_W128128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_EA_W128128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ A4, /* dc=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather 32u4 Basic Proto //U8X8_SSD1305_128X32_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_HD44102_100X64 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_T7932_150X32 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCD8544_84X48_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCF8812_96X65_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_PCF8812_96X65_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_HX1230_96X68_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_HX1230_96X68_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_EA_DOGM132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_ZOLEN_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ZOLEN_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LM6059_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_LM6059_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_KS0713_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_KS0713_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_LX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_ALT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_ERC12864_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_PI_132X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_PI_132X64_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_64X32_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7567_HEM6432_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7571_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX25664_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C //U8X8_ST75320_JLX320240_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75320_JLX320240_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7588_JLX12864_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8X8_ST7588_JLX12864_HW_I2C u8x8(/* reset=*/ 5); //U8X8_IST3020_ERC19264_6800 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8X8_IST3020_ERC19264_8080 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8X8_IST3020_ERC19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_IST7920_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_IST7920_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_UC1601_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1601_128X32_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_UC1601_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_ERC24064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_DEM240064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_ERC240120_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_240X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1610_EA_DOGXL160_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1610_EA_DOGXL160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1611_EA_DOGM240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_IDS4073_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_IDS4073_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_SW_I2C u8x8(/* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); // u8g2 test board: I2C clock/data is same as SPI, I2C default address is 0x78 //U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8X8_SSD1607_GS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8X8_SSD1607_WS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8X8_IL3820_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT //U8X8_IL3820_V2_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, optimized (lesser screen flicker) //U8X8_ST7511_AVD_320X240_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Connect RD pin with 3.3V/5V //U8X8_S1D15721_240X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_S1D15721_240X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // End of constructor list void setup(void) { // DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102) //u8x8.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_home_pin= */ 3); // DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield u8x8.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_home_pin= */ 8); u8x8.setFont(u8x8_font_chroma48medium8_r); } const char *string_list = ""\\tAltocumulus\\n"" ""\\tAltostratus\\n"" ""\\tCirrocumulus\\n"" ""\\tCirrostratus\\n"" ""\\tCirrus\\n"" ""\\tCumulonimbus\\n"" ""\\tCumulus\\n"" ""\\tNimbostratus\\n"" ""\\tStratocumulus\\n"" ""\\tStratus""; uint8_t current_selection = 0; void loop(void) { current_selection = u8x8_UserInterfaceSelectionList( u8x8.getU8x8(), ""\\tCloud Types\\n\\t-----------"", current_selection, string_list); u8x8_UserInterfaceMessage( u8x8.getU8x8(), ""\\tSelection:"", u8x8_GetStringLineStart(current_selection, string_list ), """", "" ok \\n cancel ""); } ",12355,True,3715.4349465769465,median "/* StringLineU8x8.ino Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include /* Preconditions: Uno with DOGS102 Shield */ // Please UNCOMMENT one of the contructor lines below // U8x8 Contructor List // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing //U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 6, /* dc=*/ 4, /* reset=*/ 12); // Arduboy (DevKit) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy 10 (Production, Kickstarter Edition) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_HW_SPI u8x8(/* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); // Digispark ATTiny85 //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display //U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SSD1306_128X64_ALT0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SH1106_128X64_WINSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8X8_SH1106_128X32_VISIONOX_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X32_VISIONOX_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_72X40_WISE_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_64X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_PIMORONI_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_SEEED_128X128_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_128X128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1108_160X160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_128X32_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_64X48_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8X8_SSD1306_48X64_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_1F_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_96X16_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" //U8X8_SSD1306_72X40_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" //U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1317_96X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1317_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1318_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1318_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1326_ER_256X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8X8_SSD1327_SEEED_96X96_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_SEEED_96X96_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_EA_W128128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_EA_W128128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ A4, /* dc=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather 32u4 Basic Proto //U8X8_SSD1305_128X32_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCD8544_84X48_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCF8812_96X65_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_PCF8812_96X65_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_HX1230_96X68_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_HX1230_96X68_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_EA_DOGM132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_ZOLEN_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ZOLEN_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LM6059_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_LM6059_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_KS0713_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_KS0713_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_LX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_ALT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_ERC12864_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_PI_132X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_PI_132X64_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_64X32_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7567_HEM6432_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7571_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX25664_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C //U8X8_ST75320_JLX320240_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75320_JLX320240_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7588_JLX12864_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8X8_ST7588_JLX12864_HW_I2C u8x8(/* reset=*/ 5); //U8X8_IST3020_ERC19264_6800 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8X8_IST3020_ERC19264_8080 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8X8_IST3020_ERC19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_IST7920_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_IST7920_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_UC1601_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1601_128X32_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_UC1601_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_ERC24064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_DEM240064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_ERC240120_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_240X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1610_EA_DOGXL160_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1610_EA_DOGXL160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1611_EA_DOGM240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_IDS4073_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_IDS4073_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_SW_I2C u8x8(/* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); // u8g2 test board: I2C clock/data is same as SPI, I2C default address is 0x78 //U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8X8_SSD1607_GS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8X8_SSD1607_WS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8X8_IL3820_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT //U8X8_IL3820_V2_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, optimized (lesser screen flicker) //U8X8_ST7511_AVD_320X240_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Connect RD pin with 3.3V/5V //U8X8_S1D15721_240X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_S1D15721_240X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // End of constructor list void setup(void) { // DOGS102 Shield (http://shieldlist.org/controlconnection/dogs102) //u8x8.begin(/* menu_select_pin= */ 5, /* menu_next_pin= */ 4, /* menu_prev_pin= */ 2, /* menu_home_pin= */ 3); // DOGM128 Shield (http://shieldlist.org/schmelle2/dogm128) + DOGXL160 Shield u8x8.begin(/* menu_select_pin= */ 2, /* menu_next_pin= */ 3, /* menu_prev_pin= */ 7, /* menu_home_pin= */ 8); u8x8.setFont(u8x8_font_chroma48medium8_r); } uint8_t current_value = 0; void loop(void) { u8x8_UserInterfaceInputValue( u8x8.getU8x8(), ""\\tEnter Distance:"", ""\\t"", ¤t_value, 3, 20, 3, "" cm""); u8x8_UserInterfaceMessage( u8x8.getU8x8(), ""\\tValue:"", u8x8_u8toa(current_value, 2), """", "" ok \\n cancel ""); } ",12067,True,3715.740433564304,median "/* HelloWorld.ino ""Hello World"" version for U8x8 API Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif // Please UNCOMMENT one of the contructor lines below // U8x8 Contructor List // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8x8setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8X8_NULL u8x8; // null device, a 8x8 pixel display which does nothing //U8X8_SSD1306_128X64_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 6, /* dc=*/ 4, /* reset=*/ 12); // Arduboy (DevKit) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy 10 (Production, Kickstarter Edition) //U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_3W_HW_SPI u8x8(/* cs=*/ 10, /* reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 2, /* data=*/ 0, /* reset=*/ U8X8_PIN_NONE); // Digispark ATTiny85 //U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display //U8X8_SSD1306_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SSD1306_128X64_ALT0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8X8_SH1106_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X64_VCOMH0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8X8_SH1106_128X64_WINSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8X8_SH1106_128X32_VISIONOX_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1106_128X32_VISIONOX_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1106_72X40_WISE_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_64X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1107_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_PIMORONI_128X128_HW_I2C u8x8(/* reset=*/ 8); //U8X8_SH1107_SEEED_128X128_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_128X128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SH1107_SEEED_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SH1108_160X160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_SW_I2C u8x8(/* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8X8_SSD1306_128X32_UNIVISION_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_128X32_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8X8_SSD1306_64X48_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8X8_SSD1306_48X64_WINSTAR_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_64X32_1F_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_SSD1306_96X16_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" //U8X8_SSD1306_72X40_ER_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // EastRising 0.42"" //U8X8_SSD1306_128X64_NONAME_6800 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1306_128X64_NONAME_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME0_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1309_128X64_NONAME2_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1316_128X32_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1317_96X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1317_96X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // not tested, not confirmed //U8X8_SSD1318_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1318_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1320_160X132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_256X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1322_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1325_NHD_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD0323_OS128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1326_ER_256X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8X8_SSD1327_SEEED_96X96_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_SEEED_96X96_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8X8_SSD1327_EA_W128128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_EA_W128128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_MIDAS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_WS_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1327_VISIONOX_128X96_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_128X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1329_96X96_NONAME_4W_HW_SPI u8x8(/* cs=*/ A4, /* dc=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather 32u4 Basic Proto //U8X8_SSD1305_128X32_NONAME_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_NONAME_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X32_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_ADAFRUIT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_SSD1305_128X64_RAYSTAR_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_KS0108_128X64 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_KS0108_ERM19264 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_HD44102_100X64 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_T7932_150X32 u8x8(4, 5, 6, 7, 8, 9, 10, 11, /*enable=*/ 2, /*dc=*/ 3, /*cs0=*/ A0, /*cs1=*/ A1, /*cs2=*/ A2, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8X8_UC1701_EA_DOGS102_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1701_EA_DOGS102_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_PCD8544_84X48_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCD8544_84X48_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8X8_PCF8812_96X65_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_PCF8812_96X65_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8X8_HX1230_96X68_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_HX1230_96X68_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7528_ERC16064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_64128N_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_EA_DOGM132_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_EA_DOGM132_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8X8_ST7565_ZOLEN_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ZOLEN_128X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LM6059_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_LM6059_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8X8_ST7565_KS0713_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_KS0713_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // KS0713 controller //U8X8_ST7565_LX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_LX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_ERC12864_ALT_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_ERC12864_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // contrast improved version for ERC12864 //U8X8_ST7565_NHD_C12832_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12832_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_NHD_C12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7565_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_PI_132X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_PI_132X64_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8X8_ST7567_JLX12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_JLX12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_OS12864_4W_HW_SPI u8x8(/* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_ENH_DG128064I_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7567_64X32_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7567_HEM6432_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE); //U8X8_ST7571_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7571_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX172104_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX19296_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_WO256X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160M_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX256160_ALT_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX240160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75256_JLX25664_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C //U8X8_ST75320_JLX320240_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST75320_JLX320240_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_NT7534_TG12864R_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_ST7588_JLX12864_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8X8_ST7588_JLX12864_HW_I2C u8x8(/* reset=*/ 5); //U8X8_IST3020_ERC19264_6800 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8X8_IST3020_ERC19264_8080 u8x8(44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8X8_IST3020_ERC19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_IST7920_128X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_IST7920_128X128_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Round display //U8X8_UC1601_128X32_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1601_128X32_3W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8X8_UC1601_128X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1604_JLX19264_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_ERC24064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_DEM240064_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Due, SW SPI, ERC24064-1 Test Board //U8X8_UC1608_ERC240120_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1608_240X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1610_EA_DOGXL160_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1610_EA_DOGXL160_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8X8_UC1611_EA_DOGM240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8X8_UC1611_EA_DOGM240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_2ND_HW_I2C u8x8(/* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8X8_UC1611_EA_DOGXL240_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8X8_UC1611_IDS4073_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_IDS4073_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1611_EW50850_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8X8_UC1611_CG160160_8080 u8x8(8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 17); // Connect WR1 and CD1 pin with 3.3V, connect CS0 with cs, WR0 with enable, CD with dc //U8X8_UC1617_JLX128128_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1617_JLX128128_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_SW_SPI u8x8( /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_4W_HW_SPI u8x8( /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_UC1638_192X96_SW_I2C u8x8(/* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); // u8g2 test board: I2C clock/data is same as SPI, I2C default address is 0x78 //U8X8_SSD1606_172X72_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8X8_SSD1607_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8X8_SSD1607_GS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8X8_SSD1607_WS_200X200_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Waveshare //U8X8_IL3820_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT //U8X8_IL3820_V2_296X128_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, optimized (lesser screen flicker) //U8X8_ST7511_AVD_320X240_8080 u8x8(13, 11, 2, 3, 4, 5, 6, A4, /*enable/WR=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); // Connect RD pin with 3.3V/5V //U8X8_S1D15721_240X64_4W_SW_SPI u8x8(/* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8X8_S1D15721_240X64_4W_HW_SPI u8x8(/* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // End of constructor list void setup(void) { /* U8g2 Project: SSD1306 Test Board */ //pinMode(10, OUTPUT); //pinMode(9, OUTPUT); //digitalWrite(10, 0); //digitalWrite(9, 0); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); u8x8.setI2CAddress(0x07e); u8x8.begin(); u8x8.setPowerSave(0); } uint16_t y = 0; void loop(void) { u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.clear(); u8x8.setCursor(0, y); u8x8.print(""Line ""); u8x8.print(y); y++; if ( y >= u8x8.getRows() ) y = 0; u8x8.refreshDisplay(); // for SSD1606/7 delay(1000); } ",12243,True,3708.5367082440657,median "// Uncomment this to enable Arduino OTA //#define UseOTA #include #include #include #include #include #include #ifdef UseOTA #include #include #include #endif #include ""config.h"" // Neopixel Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int ledArray[NUMPIXELS][3]; // Custom array to allow us to buffer changes before sending them // Wifi WiFiClient espClient; // MQTT PubSubClient client(espClient); const uint8_t bufferSize = 20; char buffer[bufferSize]; // Reconnect Variables unsigned long reconnectStart = 0; unsigned long lastReconnectMessage = 0; unsigned long messageInterval = 1000; int currentReconnectStep = 0; boolean offlineMode = true; boolean recovered = false; // Device specific variables (currently only used for animations specific to my stair LEDs, leave false if you are not me) boolean stairs = false; int stairPixelArray[13]; int stairPixelArrayLength = 13; // Sun Position const char* sunPositionTopic = ""sunPosition""; // This will be sent as a retained message so will be updated upon boot int sunPosition = 0; // Other unsigned long availabilityPublishTimer = 0; int availabilityPublishInterval = 30000; #pragma region Global Animation Variables const int numModes = 13; // This is the total number of modes int currentMode; // 0 int brightness = 255; int rgbValueOne[3]; // 1 int rgbValueTwo[3]; // 2 unsigned long colourDelay; // 3 int colourJump; // 4 unsigned long pixelDelay; // 5 int pixelJump; // 6 boolean randomise; // 7 unsigned long loopDelay; // 8 float highPixelDelay; // 9 float multiplier; // 10 int chance; // 11 int trailLength; // 12 unsigned long previousMillis; boolean flipFlop; int currentStep; int currentPixel; int currentColor; unsigned long colourDelaySeed; int colourJumpSeed; unsigned long pixelDelaySeed; unsigned long loopDelaySeed; float highPixelDelaySeed; float multiplierSeed; #pragma endregion void resetGlobalAnimationVariables() { currentMode = 0; for (int colour = 0;colour < 3;colour ++) { rgbValueOne[colour] = 0; rgbValueTwo[colour] = 255; } colourDelay = 0; colourJump = 1; pixelDelay = 0; pixelJump = 1; randomise = false; loopDelay = 0; highPixelDelay = 0; multiplier = 1; previousMillis = 0; flipFlop = 0; currentStep = 0; currentPixel = 0; trailLength = 0; colourDelaySeed = 0; colourJumpSeed = 1; pixelDelaySeed = 0; loopDelaySeed = 0; highPixelDelaySeed = 0; multiplierSeed = 0; chance = 100; } void setModeDefaults(int mode) { // All Off // No additional defaults // All On if (mode == 1) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; colourDelay = 2; } // Fade To Colour else if (mode == 2) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 255; colourDelay = 20; } // Strobe else if (mode == 3) { colourDelay = 40; } // Fire else if (mode == 4) { colourDelay = 20; } // Colour Phase else if (mode == 5) { colourDelay = 30; } // Sparkle else if (mode == 6) { rgbValueTwo[0] = 150; rgbValueTwo[1] = 150; rgbValueTwo[2] = 150; colourJump = 5; } // Shoot else if (mode == 7) { rgbValueTwo[0] = 50; rgbValueTwo[1] = 50; rgbValueTwo[2] = 255; colourJump = 20; loopDelay = 10000; highPixelDelay = 5; multiplier = 1.15; randomise = true; trailLength = 7; } // Mode 8 else if (mode == 8) { rgbValueTwo[0] = 100; rgbValueTwo[1] = 100; rgbValueTwo[2] = 255; colourDelay = 4; chance = 15000; } // Stairs On else if (mode == 9) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; } // Stair Shutdown else if (mode == 10) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; } // Stair Startup else if (mode == 11) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 147; rgbValueTwo[2] = 41; } // Rainbow else if (mode == 12 || mode == 13) { colourDelay = 50; currentColor = 0; previousMillis = millis(); } } void reconnect() { // IF statements used to complete process in single loop if possible // 0 - Turn the LED on and log the reconnect start time if (currentReconnectStep == 0) { //digitalWrite(LED_BUILTIN, LOW); reconnectStart = millis(); currentReconnectStep++; // If the ESP is reconnecting after a connection failure then wait a second before starting the reconnect routine if (offlineMode == false) { delay(1000); } } // If we've previously had a connection and have been trying to connect for more than 2 minutes then restart the ESP. // We don't do this if we've never had a connection as that means the issue isn't temporary and we don't want the relay // to turn off every 2 minutes. if (offlineMode == false && ((millis() - reconnectStart) > 120000)) { Serial.println(""Restarting!""); ESP.restart(); } // 1 - Check WiFi Connection if (currentReconnectStep == 1) { if (WiFi.status() != WL_CONNECTED) { if ((millis() - lastReconnectMessage) > messageInterval) { Serial.print(""Awaiting WiFi Connection (""); Serial.print((millis() - reconnectStart) / 1000); Serial.println(""s)""); lastReconnectMessage = millis(); } } else { Serial.println(""WiFi connected!""); Serial.print(""SSID: ""); Serial.print(WiFi.SSID()); Serial.println(""""); Serial.print(""IP address: ""); Serial.println(WiFi.localIP()); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 2; } } // 2 - Check MQTT Connection if (currentReconnectStep == 2) { if (!client.connected()) { if ((millis() - lastReconnectMessage) > messageInterval) { Serial.print(""Awaiting MQTT Connection (""); Serial.print((millis() - reconnectStart) / 1000); Serial.println(""s)""); lastReconnectMessage = millis(); String clientId = ""ESP8266Client-""; clientId += String(random(0xffff), HEX); client.connect(clientId.c_str(), mqttUser, mqttPass, availabilityTopic, 0, true, ""0""); } // Check the MQTT again and go forward if necessary if (client.connected()) { Serial.println(""MQTT connected!""); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 3; } // Check the WiFi again and go back if necessary else if (WiFi.status() != WL_CONNECTED) { currentReconnectStep = 1; } } else { Serial.println(""MQTT connected!""); Serial.println(""""); lastReconnectMessage = 0; currentReconnectStep = 3; } } // 3 - All connected, turn the LED back on and then subscribe to the MQTT topics if (currentReconnectStep == 3) { //digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off publishAvailability(); // MQTT Subscriptions client.subscribe(sunPositionTopic); client.subscribe(rgbCommandTopic); client.subscribe(commandlTopic); client.subscribe(recoveryTopic); if (offlineMode == true) { offlineMode = false; Serial.println(""Offline Mode Deactivated""); Serial.println(""""); } currentReconnectStep = 0; // Reset } } #pragma region MiscFunctions int* randomColour() { // Not yet used but could be useful static int aRandomColour[3]; aRandomColour[0] = random(255); aRandomColour[1] = random(255); aRandomColour[2] = random(255); return aRandomColour; } void updateLedArray_singleColour(int targetColour[3]) { for (int i = 0; i < NUMPIXELS; i++) { ledArray[i][0] = targetColour[0]; ledArray[i][1] = targetColour[1]; ledArray[i][2] = targetColour[2]; } } void updateStripFromLedArray() { for (int i = 0; i < NUMPIXELS; i++) { pixels.setPixelColor(i, pixels.Color(ledArray[i][0], ledArray[i][1], ledArray[i][2])); } pixels.show(); } void publishState() { if (currentMode == 0) { client.publish(stateTopic, ""0"", true); } else { client.publish(stateTopic, ""1"", true); } } void publishColour() { snprintf(buffer, bufferSize, ""%d,%d,%d"", rgbValueTwo[0], rgbValueTwo[1], rgbValueTwo[2]); client.publish(rgbStateTopic, buffer); } void publishAvailability() { client.publish(availabilityTopic, ""1"", true); } void publishRecovery() { DynamicJsonDocument doc(1024); //DynamicJsonBuffer jsonBuffer; // Reserve memory space (https://bblanchon.github.io/ArduinoJson/) serializeJson(doc, Serial); //JsonObject& doc = jsonBuffer.createObject(); // Create the JSON object // Always publish the mode so that there is a current retained message doc[""0""] = currentMode; // Only publish the other variables if they are non-default if (rgbValueOne[0] != 0 | rgbValueOne[1] != 0 | rgbValueOne[2] != 0) { JsonArray rgbValueOneArray = doc.createNestedArray(""1""); rgbValueOneArray.add(rgbValueOne[0]); rgbValueOneArray.add(rgbValueOne[1]); rgbValueOneArray.add(rgbValueOne[2]); } if (rgbValueTwo[0] != 255 | rgbValueTwo[1] != 255 | rgbValueTwo[2] != 255) { JsonArray rgbValueTwoArray = doc.createNestedArray(""2""); rgbValueTwoArray.add(rgbValueTwo[0]); rgbValueTwoArray.add(rgbValueTwo[1]); rgbValueTwoArray.add(rgbValueTwo[2]); } if (colourDelay != 0) { doc[""3""] = colourDelay; } if (colourJump != 1) { doc[""4""] = colourJump; } if (pixelDelay != 0) { doc[""5""] = pixelDelay; } if (pixelJump != 1) { doc[""6""] = pixelJump; } if (randomise != false) { doc[""7""] = randomise; } if (loopDelay != 0) { doc[""8""] = loopDelay; } if (highPixelDelay != 0) { doc[""9""] = highPixelDelay; } if (multiplier != 1) { doc[""10""] = multiplier; } if (chance != 100) { doc[""11""] = chance; } if (trailLength != 0) { doc[""12""] = trailLength; } char buffer[256]; //doc.printTo(buffer, sizeof(buffer)); serializeJson(doc, buffer, sizeof(buffer)); client.publish(recoveryTopic, buffer, true); } void publishAll() { publishColour(); publishState(); publishRecovery(); publishAvailability(); } #pragma endregion #pragma region Modes void allRgbValueOne() { if (flipFlop == 0) { // This is used updateLedArray_singleColour(rgbValueOne); updateStripFromLedArray(); flipFlop = 1; } } void allRgbValueTwo() { if (flipFlop == 0) { // This is used updateLedArray_singleColour(rgbValueTwo); updateStripFromLedArray(); flipFlop = 1; } } void stairsOn() { if (flipFlop == 0) { // This isn't used updateLedArray_singleColour(rgbValueOne); for (int i = 0; i < 3; i++) { ledArray[3][i] = rgbValueTwo[i]; ledArray[12][i] = rgbValueTwo[i]; ledArray[21][i] = rgbValueTwo[i]; ledArray[30][i] = rgbValueTwo[i]; ledArray[40][i] = rgbValueTwo[i]; ledArray[49][i] = rgbValueTwo[i]; ledArray[58][i] = rgbValueTwo[i]; ledArray[68][i] = rgbValueTwo[i]; ledArray[77][i] = rgbValueTwo[i]; ledArray[86][i] = rgbValueTwo[i]; ledArray[96][i] = rgbValueTwo[i]; ledArray[105][i] = rgbValueTwo[i]; ledArray[111][i] = rgbValueTwo[i]; } updateStripFromLedArray(); } } void stairsOff() { if (flipFlop == 0) { // This isn't used updateLedArray_singleColour(rgbValueOne); if (sunPosition == 0) { rgbValueTwo[0] = 2; rgbValueTwo[1] = 1; rgbValueTwo[2] = 0; } else if (sunPosition == 1) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; } for (int i = 0; i < 3; i++) { ledArray[0][i] = rgbValueTwo[i]; ledArray[9][i] = rgbValueTwo[i]; ledArray[18][i] = rgbValueTwo[i]; ledArray[27][i] = rgbValueTwo[i]; ledArray[37][i] = rgbValueTwo[i]; ledArray[46][i] = rgbValueTwo[i]; ledArray[55][i] = rgbValueTwo[i]; ledArray[65][i] = rgbValueTwo[i]; ledArray[74][i] = rgbValueTwo[i]; ledArray[83][i] = rgbValueTwo[i]; ledArray[93][i] = rgbValueTwo[i]; ledArray[102][i] = rgbValueTwo[i]; ledArray[111][i] = rgbValueTwo[i]; } updateStripFromLedArray(); } } void fadeToColour(bool useFlipFlop /*= false*/) { if (flipFlop == 0) { // This is used unsigned long currentMillis = millis(); if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { int count = 0; // Reset the count for (int pixel = 0;pixel < NUMPIXELS;pixel ++){ // For every pixel if (ledArray[pixel][0] != rgbValueTwo[0] | ledArray[pixel][1] != rgbValueTwo[1] | ledArray[pixel][2] != rgbValueTwo[2]) { for (int colour = 0;colour < 3;colour++) { // For each colour if (ledArray[pixel][colour] < rgbValueTwo[colour]) { // If the colour value is less that it should be ledArray[pixel][colour] += 1; // Add 1 } else if (ledArray[pixel][colour] > rgbValueTwo[colour]) { // If the colour value is more that it should be ledArray[pixel][colour] -= 1; // Subtract 1 } } pixels.setPixelColor(pixel, pixels.Color(ledArray[pixel][0], ledArray[pixel][1], ledArray[pixel][2])); } else { count ++; } } pixels.show(); if (count == NUMPIXELS && useFlipFlop == true) { flipFlop = 1; } previousMillis = currentMillis; } } } void fadePixelToTargetColour(int pixelNo) { if (millis() - previousMillis >= colourDelay) { if (ledArray[pixelNo][0] != rgbValueTwo[0] | ledArray[pixelNo][1] != rgbValueTwo[1] | ledArray[pixelNo][2] != rgbValueTwo[2]) { for (int colour = 0; colour < 3; colour++) { // For each colour if (ledArray[pixelNo][colour] < rgbValueTwo[colour]) { // If the colour value is less that it should be ledArray[pixelNo][colour] += colourJump; // Add the colour jump if (ledArray[pixelNo][colour] > rgbValueTwo[colour]) { // Jump back if we've jumped over it ledArray[pixelNo][colour] = rgbValueTwo[colour]; } } else if (ledArray[pixelNo][colour] > rgbValueTwo[colour]) { // If the colour value is more that it should be ledArray[pixelNo][colour] -= colourJump; // Subtract the colour jump if (ledArray[pixelNo][colour] < rgbValueTwo[colour]) { // Jump back if we've jumped under it ledArray[pixelNo][colour] = rgbValueTwo[colour]; } } } pixels.setPixelColor(pixelNo, pixels.Color(ledArray[pixelNo][0], ledArray[pixelNo][1], ledArray[pixelNo][2])); pixels.show(); } else { currentStep++; } previousMillis = millis(); } } void fadePixelToBaseColour(int pixelNo) { if (millis() - previousMillis >= colourDelay) { if (ledArray[pixelNo][0] != rgbValueOne[0] | ledArray[pixelNo][1] != rgbValueOne[1] | ledArray[pixelNo][2] != rgbValueOne[2]) { for (int colour = 0; colour < 3; colour++) { // For each colour if (ledArray[pixelNo][colour] < rgbValueOne[colour]) { // If the colour value is less that it should be ledArray[pixelNo][colour] += colourJump; // Add the colour jump if (ledArray[pixelNo][colour] > rgbValueOne[colour]) { // Jump back if we've jumped over it ledArray[pixelNo][colour] = rgbValueOne[colour]; } } else if (ledArray[pixelNo][colour] > rgbValueOne[colour]) { // If the colour value is more that it should be ledArray[pixelNo][colour] -= colourJump; // Subtract the colour jump if (ledArray[pixelNo][colour] < rgbValueOne[colour]) { // Jump back if we've jumped under it ledArray[pixelNo][colour] = rgbValueOne[colour]; } } } pixels.setPixelColor(pixelNo, pixels.Color(ledArray[pixelNo][0], ledArray[pixelNo][1], ledArray[pixelNo][2])); pixels.show(); } else { currentStep++; } previousMillis = millis(); } } void strobe() { unsigned long currentMillis = millis(); if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { if (flipFlop == 1) { updateLedArray_singleColour(rgbValueTwo); updateStripFromLedArray(); flipFlop = !flipFlop; } else if (flipFlop == 0) { updateLedArray_singleColour(rgbValueOne); updateStripFromLedArray(); flipFlop = !flipFlop; } previousMillis = currentMillis; } } void fire(int Cooling, int Sparking, int SpeedDelay) { // Need to tailor variables and update LED array static byte heat[NUMPIXELS]; int cooldown; // Step 1. Cool down every cell a little for( int i = 0; i < NUMPIXELS; i++) { cooldown = random(0, ((Cooling * 10) / NUMPIXELS) + 2); if(cooldown>heat[i]) { heat[i]=0; } else { heat[i]=heat[i]-cooldown; } } // Step 2. Heat from each cell drifts 'up' and diffuses a little for( int k= NUMPIXELS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3; } // Step 3. Randomly ignite new 'sparks' near the bottom if( random(255) < Sparking ) { int y = random(7); heat[y] = heat[y] + random(160,255); //heat[y] = random(160,255); } // Step 4. Convert heat to LED colors for( int j = 0; j < NUMPIXELS; j++) { setPixelHeatColor(j, heat[j] ); } pixels.show(); delay(SpeedDelay); } void setPixelHeatColor (int Pixel, byte temperature) { // Scale 'heat' down from 0-255 to 0-191 byte t192 = round((temperature/255.0)*191); // calculate ramp up from byte heatramp = t192 & 0x3F; // 0..63 heatramp <<= 2; // scale up to 0..252 // figure out which third of the spectrum we're in: if( t192 > 0x80) { // hottest pixels.setPixelColor(Pixel, 255, 255, heatramp); } else if( t192 > 0x40 ) { // middle pixels.setPixelColor(Pixel, 255, heatramp, 0); } else { // coolest pixels.setPixelColor(Pixel, heatramp, 0, 0); } } // Fire Source: https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#fire void colourPhase() { if (flipFlop == 1) { // fadeToColour will set flipFlop to 1 when complete so we use this to update the current step then reset the flipFlop currentStep++; flipFlop = 0; if (currentStep > 5) { // If the current step is greater than the number of steps we reset currentStep = 0; } } if (currentStep == 0) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 0; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 1) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 255; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 2) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 255; rgbValueTwo[2] = 0; fadeToColour(true); } else if (currentStep == 3) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 255; rgbValueTwo[2] = 255; fadeToColour(true); } else if (currentStep == 4) { rgbValueTwo[0] = 0; rgbValueTwo[1] = 0; rgbValueTwo[2] = 255; fadeToColour(true); } else if (currentStep == 5) { rgbValueTwo[0] = 255; rgbValueTwo[1] = 255; rgbValueTwo[2] = 255; fadeToColour(true); } } void sparkle() { unsigned long currentMillis = millis(); // Initiator if (currentStep == 0) { allRgbValueOne(); // Sets all LEDs to rgbValueOne colourDelaySeed = colourDelay; colourJumpSeed = colourJump; pixelDelaySeed = pixelDelay; currentStep ++; } // Pixel Delay if (currentStep == 1) { if (previousMillis > currentMillis || currentMillis - previousMillis >= pixelDelay) { if (randomise == true) { pixelDelay = random(pixelDelaySeed); colourDelay = random(colourDelaySeed); // Only change between pixels so the light doesn't waver colourJump = random(1,colourJumpSeed); // Min of 1 otherwise there's a chance the loop will stop } previousMillis = currentMillis; currentStep ++; } } // Roll Up if (currentStep == 2 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay )) { if (ledArray[currentPixel][0] != rgbValueTwo[0] | ledArray[currentPixel][1] != rgbValueTwo[1] | ledArray[currentPixel][2] != rgbValueTwo[2]) { // If the pixel hasn't reached peak for (int i = 1;!(i > colourJump);i++) { for (int col = 0;col < 3;col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueTwo[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueTwo[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep ++; } previousMillis = currentMillis; } // Roll Down if (currentStep == 3 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay )) { if (ledArray[currentPixel][0] != rgbValueOne[0] | ledArray[currentPixel][1] != rgbValueOne[1] | ledArray[currentPixel][2] != rgbValueOne[2]) { // If the pixel hasn't reached base for (int i = 1;!(i > colourJump);i++) { for (int col = 0;col < 3;col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueOne[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueOne[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep = 1; // Go back to the mid pixel wait currentPixel = random(NUMPIXELS); } previousMillis = currentMillis; } } void rain() { unsigned long currentMillis = millis(); if (random(chance) == 1) { int randomPixel = random(NUMPIXELS); ledArray[randomPixel][0] = rgbValueTwo[0]; ledArray[randomPixel][1] = rgbValueTwo[1]; ledArray[randomPixel][2] = rgbValueTwo[2]; updateStripFromLedArray(); } if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { for (int pixel = 0;pixel < NUMPIXELS;pixel ++){ // For every pixel for (int i = 1;!(i > colourJump);i++) { if (ledArray[pixel][0] != rgbValueOne[0] | ledArray[pixel][1] != rgbValueOne[1] | ledArray[pixel][2] != rgbValueOne[2]) { for (int colour = 0;colour < 3;colour++) { // For each colour if (ledArray[pixel][colour] < rgbValueOne[colour]) { // If the colour value is less that it should be ledArray[pixel][colour] += 1; // Add 1 } else if (ledArray[pixel][colour] > rgbValueOne[colour]) { // If the colour value is more that it should be ledArray[pixel][colour] -= 1; // Subtract 1 } } pixels.setPixelColor(pixel, pixels.Color(ledArray[pixel][0],ledArray[pixel][1],ledArray[pixel][2])); } } } updateStripFromLedArray(); previousMillis = currentMillis; } } void shoot() { unsigned long currentMillis = millis(); // Initiator if (currentStep == 0) { allRgbValueOne(); // Sets all LEDs to rgbValueOne loopDelaySeed = loopDelay; colourJumpSeed = colourJump; multiplierSeed = multiplier; highPixelDelaySeed = highPixelDelay; // Seeded because it's multiplied not because it's randomised currentStep++; } // Loop Delay if (currentStep == 1) { if (previousMillis > currentMillis || currentMillis - previousMillis >= loopDelay) { if (randomise == true) { loopDelay = random(loopDelaySeed); colourJump = random(1, colourJumpSeed); float multiplierSeedX = (multiplier * 100.00); multiplier = (random(multiplierSeedX * 0.95, multiplierSeedX * 1.05)) / 100.00; // +-5% - Best at 1.25 } highPixelDelay = highPixelDelaySeed; previousMillis = currentMillis; currentStep++; } } // Pixel Delay if (currentStep == 2) { if (previousMillis > currentMillis || currentMillis - previousMillis >= pixelDelay) { previousMillis = currentMillis; currentStep++; } } // Roll Up if (currentPixel > (NUMPIXELS - 1)) { // Skip the roll up if we're after the last pixel (trail) currentStep = 4; } if (currentStep == 3 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay)) { if (ledArray[currentPixel][0] != rgbValueTwo[0] | ledArray[currentPixel][1] != rgbValueTwo[1] | ledArray[currentPixel][2] != rgbValueTwo[2]) { // If the pixel hasn't reached peak for (int i = 1; !(i > colourJump); i++) { for (int col = 0; col < 3; col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueTwo[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueTwo[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { currentStep++; } previousMillis = currentMillis; } // High Pixel Delay if (currentStep == 4) { if (previousMillis > currentMillis || currentMillis - previousMillis >= highPixelDelay) { previousMillis = currentMillis; highPixelDelay = (highPixelDelay * multiplier); currentStep++; } } // Roll Down if (currentStep == 5 && (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay)) { if (trailLength == 0) { if (ledArray[currentPixel][0] != rgbValueOne[0] | ledArray[currentPixel][1] != rgbValueOne[1] | ledArray[currentPixel][2] != rgbValueOne[2]) { // If the pixel hasn't reached base for (int i = 1; !(i > colourJump); i++) { for (int col = 0; col < 3; col++) { // For each colour if (ledArray[currentPixel][col] < rgbValueOne[col]) { // If the colour value is less that it should be ledArray[currentPixel][col] += 1; // Add 1 } else if (ledArray[currentPixel][col] > rgbValueOne[col]) { // If the colour value is more that it should be ledArray[currentPixel][col] -= 1; // Subtract 1 } } } updateStripFromLedArray(); } else { if (currentPixel == (NUMPIXELS - 1)) { currentPixel = 0; currentStep = 1; } else { currentPixel++; currentStep = 2; } } } else { Serial.println(""---""); Serial.print(""currentPixel = ""); Serial.println(currentPixel); int currentTrailPixel = currentPixel; // Start with the current pixel as we're about to put the next one up while (currentTrailPixel >= (currentPixel - (trailLength + 1))) { if (currentTrailPixel >= 0 && currentTrailPixel < NUMPIXELS) { Serial.print(""trailPixelToUpdate = ""); Serial.println(currentTrailPixel); if (currentTrailPixel > (currentPixel - trailLength)) { // This is the trail int trailDifference = (currentPixel - currentTrailPixel); float trailPercentage = ((1.0 / trailLength) * (trailLength - trailDifference)); Serial.print(""trailPercentage = ""); Serial.println(trailPercentage); ledArray[currentTrailPixel][0] = (rgbValueTwo[0] * trailPercentage); ledArray[currentTrailPixel][1] = (rgbValueTwo[1] * trailPercentage); ledArray[currentTrailPixel][2] = (rgbValueTwo[2] * trailPercentage); } else { // Clear the trail ledArray[currentTrailPixel][0] = rgbValueOne[0]; ledArray[currentTrailPixel][1] = rgbValueOne[1]; ledArray[currentTrailPixel][2] = rgbValueOne[2]; } } currentTrailPixel = (currentTrailPixel - 1); } updateStripFromLedArray(); if (currentPixel == ((NUMPIXELS - 1) + trailLength)) { currentPixel = 0; currentStep = 1; } else { currentPixel++; currentStep = 2; } } previousMillis = currentMillis; } } void stairStartup() { if (currentStep == 0) { allRgbValueOne(); // Turn all the lights off first currentPixel = 12; // Start at the end currentStep++; } else if (currentStep == 1) { fadePixelToTargetColour(stairPixelArray[currentPixel]); } else if (currentStep == 2) { if ((currentPixel - 1) <= -1) { // If we've done all the pixels currentStep = 4; } else if (millis() - previousMillis >= pixelDelay) { currentPixel--; currentStep = 1; } } else if (currentStep == 4) { currentMode = 9; // stairsOn setModeDefaults(currentMode); // No need to publish state as mode 10 is considered on anyway and so has already been published publishColour(); publishRecovery(); } } void stairShutdown() { // This step fades the top LED to red to indicate shutdown if (currentStep == 0) { fadePixelToTargetColour(111); } else if (currentStep == 1) { fadePixelToBaseColour(stairPixelArray[currentPixel]); } else if (currentStep == 2) { if ((currentPixel + 1) >= stairPixelArrayLength) { // If we've done all the pixels currentStep = 3; } else if (millis() - previousMillis >= pixelDelay) { currentPixel++; currentStep = 1; } } else if (currentStep == 3) { currentMode = 0; // Off setModeDefaults(currentMode); publishAll(); } } void rainbow(int rainbowMode) { static int colorVals[3]; unsigned long currentMillis = millis(); byte WheelPos; if (previousMillis > currentMillis || currentMillis - previousMillis >= colourDelay) { for(int i=0; i MQTT Received""); #pragma region commandlTopic if (String(commandlTopic).equals(topic)) { Serial.println(""topic:""); Serial.println(topic); if (length == 1) { Serial.println(""Message is numerical input:""); byte valprint = (char)payload[0]; Serial.write(valprint); Serial.println(); // Off if ((char)payload[0] == '0') { resetGlobalAnimationVariables(); currentMode = 0; // Not required as 0 is set by the reset, left in for clarity setModeDefaults(currentMode); publishState(); publishRecovery(); } // On else if ((char)payload[0] == '1') { // Only turn on if currentMode is 0 if (currentMode == 0) { resetGlobalAnimationVariables(); currentMode = 1; setModeDefaults(currentMode); publishAll(); // State + Colour + Recovery } } // Toggle - Using a re-publish ensures any changes to the On / Off routines are used for the toggle as well else if ((char)payload[0] == '2') { if (currentMode == 0) { client.publish(commandlTopic, ""1""); } else { client.publish(commandlTopic, ""0""); } } // Cycle Modes else if ((char)payload[0] == '9') { int lastMode = currentMode; resetGlobalAnimationVariables(); currentMode = ++lastMode; if (currentMode > numModes) { currentMode = 0; } setModeDefaults(currentMode); publishAll(); } } else if ((char)payload[0] == '{') { // It's a JSON Serial.println(""Message is numerical JSON input:""); char message_buff[256]; // Max of 256 characters for (int i = 0; i < length; i++) { message_buff[i] = payload[i]; if (i == (length - 1)) { // If we're at the last character message_buff[i + 1] = '\\0'; // Add a string terminator to the next character } } DynamicJsonDocument doc(1024); //ArduinoJson 6 equivalent of next line. //DynamicJsonBuffer jsonBuffer; // Step 1: Reserve memory space (https://bblanchon.github.io/ArduinoJson/) deserializeJson(doc, message_buff); //JsonObject& doc = jsonBuffer.parseObject(message_buff); // Step 2: Deserialize the JSON string if (doc.isNull()) { Serial.println(""parseObject() failed""); } else if (!doc.isNull()) { if (doc.containsKey(""0"")) { resetGlobalAnimationVariables(); // Only do this if the mode changes currentMode = doc[""0""]; setModeDefaults(currentMode); // Only do this if the mode changes // We don't publish the recovery message here as other variables might have changed without the mode changing and so we wait until later publishState(); publishColour(); } if (currentMode > numModes) { // If mode is greater than is possible, set to 0 currentMode = 0; } if (doc.containsKey(""1"")) { rgbValueOne[0] = doc[""1""][0]; rgbValueOne[1] = doc[""1""][1]; rgbValueOne[2] = doc[""1""][2]; flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. } if (doc.containsKey(""2"")) { rgbValueTwo[0] = doc[""2""][0]; rgbValueTwo[1] = doc[""2""][1]; rgbValueTwo[2] = doc[""2""][2]; flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. publishColour(); } if (doc.containsKey(""3"")) { colourDelay = doc[""3""]; } if (doc.containsKey(""4"")) { colourJump = doc[""4""]; } if (doc.containsKey(""5"")) { pixelDelay = doc[""5""]; } if (doc.containsKey(""6"")) { pixelJump = doc[""6""]; } if (doc.containsKey(""7"")) { randomise = doc[""7""]; } if (doc.containsKey(""8"")) { loopDelay = doc[""8""]; } if (doc.containsKey(""9"")) { highPixelDelay = doc[""9""]; } if (doc.containsKey(""10"")) { multiplier = doc[""10""]; } if (doc.containsKey(""11"")) { chance = doc[""11""]; } if (doc.containsKey(""12"")) { trailLength = doc[""12""]; } } publishRecovery(); } } #pragma endregion #pragma region rgbCommandTopic else if (String(rgbCommandTopic).equals(topic)) { String payloadString; for (uint8_t i = 0; i < length; i++) { payloadString.concat((char)payload[i]); } uint8_t firstIndex = payloadString.indexOf(','); uint8_t lastIndex = payloadString.lastIndexOf(','); uint8_t rgb_red = payloadString.substring(0, firstIndex).toInt(); if (rgb_red < 0 || rgb_red > 255) { return; } else { rgbValueTwo[0] = rgb_red; } uint8_t rgb_green = payloadString.substring(firstIndex + 1, lastIndex).toInt(); if (rgb_green < 0 || rgb_green > 255) { return; } else { rgbValueTwo[1] = rgb_green; } uint8_t rgb_blue = payloadString.substring(lastIndex + 1).toInt(); if (rgb_blue < 0 || rgb_blue > 255) { return; } else { rgbValueTwo[2] = rgb_blue; } flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again now the colour has changed. // No need to publish the state, it can't have changed. publishColour(); publishRecovery(); } #pragma endregion #pragma region sunPositionTopic else if (String(sunPositionTopic).equals(topic)) { if ((char)payload[0] == '0') { sunPosition = 0; } else if ((char)payload[0] == '1') { sunPosition = 1; } } #pragma endregion #pragma region recoveryTopic else if (String(recoveryTopic).equals(topic) && recovered == false) { char message_buff[256]; for (int i = 0; i < length; i++) { message_buff[i] = payload[i]; if (i == (length - 1)) { // If we're at the last character message_buff[i + 1] = '\\0'; // Add a string terminator to the next character } } StaticJsonDocument<300> doc; //StaticJsonBuffer<300> jsonBuffer; // Reserve memory space (https://bblanchon.github.io/ArduinoJson/) deserializeJson(doc, message_buff); //deserialize in arduinoJson 6. Same as below line //JsonObject& doc = jsonBuffer.parseObject(message_buff); // Step 2: Deserialize the JSON string if (doc.isNull()) { Serial.println(""parseObject() failed""); } else if (!doc.isNull()) { if (doc.containsKey(""0"")) { currentMode = doc[""0""]; setModeDefaults(currentMode); // Only do this if the mode changes } if (currentMode > numModes) { // If mode is greater than is possible, set to 0 currentMode = 0; } if (doc.containsKey(""1"")) { rgbValueOne[0] = doc[""1""][0]; rgbValueOne[1] = doc[""1""][1]; rgbValueOne[2] = doc[""1""][2]; } if (doc.containsKey(""2"")) { rgbValueTwo[0] = doc[""2""][0]; rgbValueTwo[1] = doc[""2""][1]; rgbValueTwo[2] = doc[""2""][2]; publishColour(); } if (doc.containsKey(""3"")) { colourDelay = doc[""3""]; } if (doc.containsKey(""4"")) { colourJump = doc[""4""]; } if (doc.containsKey(""5"")) { pixelDelay = doc[""5""]; } if (doc.containsKey(""6"")) { pixelJump = doc[""6""]; } if (doc.containsKey(""7"")) { randomise = doc[""7""]; } if (doc.containsKey(""8"")) { loopDelay = doc[""8""]; } if (doc.containsKey(""9"")) { highPixelDelay = doc[""9""]; } if (doc.containsKey(""10"")) { multiplier = doc[""10""]; } if (doc.containsKey(""11"")) { chance = doc[""11""]; } if (doc.containsKey(""12"")) { trailLength = doc[""12""]; } // No need to publish recovery message as it would match the current settings anyway publishState(); publishColour(); flipFlop = 0; // When displaying a static colour this is set to 1 once the LED strip has been updated, resetting this to 0 is needed to trigger the strip update again. } recovered = true; } #pragma endregion } void loop() { if (!client.connected()) { reconnect(); } else { client.loop(); } if (currentMode == 0) { if (stairs == true) { // Special Off Mode for Stairs stairsOff(); } else { allRgbValueOne(); // Normal } } else if (currentMode == 1) { fadeToColour(true); } else if (currentMode == 2) { fadeToColour(true); } else if (currentMode == 3) { strobe(); } else if (currentMode == 4) { fire(55,120,colourDelay); } else if (currentMode == 5) { colourPhase(); } else if (currentMode == 6) { sparkle(); } else if (currentMode == 7) { shoot(); } else if (currentMode == 8) { rain(); } else if (currentMode == 9) { stairsOn(); } else if (currentMode == 10) { stairShutdown(); } else if (currentMode == 11) { stairStartup(); } else if (currentMode == 12) { rainbow(1); } else if (currentMode == 13) { rainbow(2); } if ((millis() - availabilityPublishInterval) >= availabilityPublishTimer) { publishAvailability(); availabilityPublishTimer = millis(); } #ifdef UseOTA ArduinoOTA.handle(); #endif yield(); } ",12517,False,2435.929462852267,median "/* Wather.ino Show weather icons from open-iconic set. Plus demo for text scrolling. This example requires display height >= 64. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif /* U8glib Example Overview: Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only. This is a page buffer example. */ // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! // End of constructor list #define SUN 0 #define SUN_CLOUD 1 #define CLOUD 2 #define RAIN 3 #define THUNDER 4 void drawWeatherSymbol(u8g2_uint_t x, u8g2_uint_t y, uint8_t symbol) { // fonts used: // u8g2_font_open_iconic_embedded_6x_t // u8g2_font_open_iconic_weather_6x_t // encoding values, see: https://github.com/olikraus/u8g2/wiki/fntgrpiconic switch(symbol) { case SUN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 69); break; case SUN_CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 65); break; case CLOUD: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 64); break; case RAIN: u8g2.setFont(u8g2_font_open_iconic_weather_6x_t); u8g2.drawGlyph(x, y, 67); break; case THUNDER: u8g2.setFont(u8g2_font_open_iconic_embedded_6x_t); u8g2.drawGlyph(x, y, 67); break; } } void drawWeather(uint8_t symbol, int degree) { drawWeatherSymbol(0, 48, symbol); u8g2.setFont(u8g2_font_logisoso32_tf); u8g2.setCursor(48+3, 42); u8g2.print(degree); u8g2.print(""°C""); // requires enableUTF8Print() } /* Draw a string with specified pixel offset. The offset can be negative. Limitation: The monochrome font with 8 pixel per glyph */ void drawScrollString(int16_t offset, const char *s) { static char buf[36]; // should for screen with up to 256 pixel width size_t len; size_t char_offset = 0; u8g2_uint_t dx = 0; size_t visible = 0; len = strlen(s); if ( offset < 0 ) { char_offset = (-offset)/8; dx = offset + char_offset*8; if ( char_offset >= u8g2.getDisplayWidth()/8 ) return; visible = u8g2.getDisplayWidth()/8-char_offset+1; strncpy(buf, s, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(char_offset*8-dx, 62, buf); } else { char_offset = offset / 8; if ( char_offset >= len ) return; // nothing visible dx = offset - char_offset*8; visible = len - char_offset; if ( visible > u8g2.getDisplayWidth()/8+1 ) visible = u8g2.getDisplayWidth()/8+1; strncpy(buf, s+char_offset, visible); buf[visible] = '\\0'; u8g2.setFont(u8g2_font_8x13_mf); u8g2.drawStr(-dx, 62, buf); } } void draw(const char *s, uint8_t symbol, int degree) { int16_t offset = -(int16_t)u8g2.getDisplayWidth(); int16_t len = strlen(s); for(;;) { u8g2.firstPage(); do { drawWeather(symbol, degree); drawScrollString(offset, s); } while ( u8g2.nextPage() ); delay(20); offset+=2; if ( offset > len*8+1 ) break; } } void setup(void) { /* U8g2 Project: SSD1306 Test Board */ pinMode(10, OUTPUT); pinMode(9, OUTPUT); digitalWrite(10, 0); digitalWrite(9, 0); /* U8g2 Project: T6963 Test Board */ //pinMode(18, OUTPUT); //digitalWrite(18, 1); /* U8g2 Project: KS0108 Test Board */ //pinMode(16, OUTPUT); //digitalWrite(16, 0); /* U8g2 Project: LC7981 Test Board, connect RW to GND */ //pinMode(17, OUTPUT); //digitalWrite(17, 0); /* U8g2 Project: Pax Instruments Shield: Enable Backlight */ //pinMode(6, OUTPUT); //digitalWrite(6, 0); u8g2.begin(); u8g2.enableUTF8Print(); } void loop(void) { draw(""What a beautiful day!"", SUN, 27); draw(""The sun's come out!"", SUN_CLOUD, 19); draw(""It's raining cats and dogs."", RAIN, 8); draw(""That sounds like thunder."", THUNDER, 12); draw(""It's stopped raining"", CLOUD, 15); } ",12303,True,3363.849312682075,median " float arr[1000] = {-194.7293734,-228.7205774,-241.1012313,-274.3287909,-258.4301079,-244.645154,-267.9013166,-246.6050094,-242.4746091,-262.6250468,-238.1975294,-221.7994023,-235.1426569,-242.8932457,-247.5878307,-218.1253556,-237.4591843,-229.5916635,-223.2165116,-205.5867448,-237.778965,-201.5138842,-197.2634399,-218.4651907,-226.9375835,-199.6628832,-240.0012574,-222.3782983,-204.4144371,-223.0221878,-215.5507942,-204.6482212,-222.0696607,-221.5406628,-233.7575657,-207.3931737,-213.1469816,-256.4251654,-248.644363,-238.4953193,-243.4652311,-206.2320692,-236.7459641,-259.4415915,-262.9389297,-203.4735393,-189.4905604,-150.4684017,-144.7423112,-108.8224312,-50.3437065,-42.48394314,-9.313541237,2.282074465,60.61253926,58.58308399,43.99462444,45.23633906,5.781279205,12.42652926,-6.064931748,-37.43559123,-73.84242875,-54.06086811,-103.7524177,-137.3311552,-154.8714495,-145.8669742,-163.164842,-213.1969349,-188.3772464,-180.3718886,-190.6680207,-182.8992434,-208.5555581,-227.0501279,-223.9086697,-203.6115081,-225.0068371,-249.7099086,-270.430942,-247.9083576,-221.4759624,-271.2626802,-256.0717227,-240.2203343,-211.4446914,-201.1415653,-198.7572259,-207.5827723,-233.1128712,-178.8934831,-190.8283584,-189.2946002,-194.2929802,-194.1054383,-198.4310706,-188.7845077,-210.9275443,-197.1196525,-185.5335141,-233.2417639,-222.0488999,-223.1010373,-237.2142258,-227.1844383,-224.8237316,-227.1231129,-225.6844486,-188.4712173,-212.9535228,-238.0921159,-246.9258376,-229.913049,-268.1904491,-257.5908872,-235.2382047,-196.0882206,-174.4861493,-144.3613337,-121.5747288,-89.66203045,-65.1663977,-40.2986104,24.53192862,53.25129558,69.48466659,46.26462118,54.09895211,16.29032903,5.228029817,-20.74642039,-40.2574299,-80.06059097,-85.14764361,-101.1609156,-130.8264169,-110.7740027,-172.6491102,-190.6556797,-150.7838331,-178.8338841,-209.2648121,-206.1178525,-210.4814517,-214.1269824,-222.1505692,-230.3364431,-229.1243872,-251.8032432,-250.9595267,-235.0004413,-232.6200981,-235.0745491,-204.5328354,-212.59826,-211.1507703,-207.7587466,-234.7991683,-192.0878764,-222.6905045,-202.4615363,-204.2220413,-225.1243183,-216.3029391,-191.6984828,-185.4856592,-182.9473139,-177.8998202,-183.2392524,-208.2415824,-212.0286206,-169.3541698,-210.5412575,-231.0118891,-249.5577641,-208.3705454,-204.5434279,-214.5228903,-228.7358685,-241.2009769,-235.1017173,-218.3852069,-213.7527006,-227.4889893,-223.6288157,-228.9916498,-207.5219466,-190.493554,-154.5865093,-116.0024558,-63.17772296,-51.8002069,-7.546116619,-14.39880211,32.98183203,63.20752025,64.41857886,59.71544681,32.10101235,-17.70912436,-7.631012085,-51.8776306,-55.95033776,-69.06182035,-111.8571389,-104.4989893,-126.9390643,-163.5667602,-151.7080535,-187.5999,-219.4481594,-206.2992725,-207.0990868,-222.7266564,-222.5792183,-210.542429,-238.9541618,-240.7254286,-243.3493466,-258.2009352,-241.234409,-225.2101582,-243.213891,-246.0856964,-238.4527187,-219.1768319,-227.3266325,-213.8079106,-225.8201055,-222.0041483,-210.3261814,-205.7475302,-206.0668604,-222.6182256,-200.8885429,-206.1334318,-218.22569,-186.0937162,-226.4895114,-221.4281832,-191.3548204,-200.6006756,-211.0800005,-213.9486458,-203.0680747,-190.9419471,-221.7923004,-201.7018474,-215.4770913,-246.7618175,-228.9328285,-232.0936364,-240.3352165,-230.6981949,-224.9568539,-199.9779163,-212.2616482,-173.7521828,-176.9408848,-119.7392093,-103.6798485,-89.81041289,-67.57551054,-10.67998311,9.749239444,32.13123786,16.27966092,34.40986469,15.91874671,13.97345217,3.402896188,5.590464863,-45.38323666,-65.65860722,-95.44303348,-98.91854576,-98.15341909,-131.3000653,-135.7003976,-192.0801184,-189.0861504,-164.4095092,-156.1325791,-193.5525884,-184.7028529,-229.651036,-223.1013635,-187.5059762,-190.6580371,-168.5168179,-171.8102238,-214.0656828,-206.2208193,-183.5450934,-190.8589567,-182.7666905,-178.6198467,-180.509724,-175.642094,-172.8580103,-167.8244064,-196.979952,-186.2138905,-168.0834867,-167.8570434,-169.5713098,-203.7577476,-173.624489,-189.6457655,-186.161929,-178.6140261,-186.2081834,-203.8580852,-174.0582505,-218.2507178,-214.4790238,-204.6601377,-193.1434548,-234.4722219,-246.5686757,-185.7564607,-217.201683,-225.3845411,-179.1924198,-162.6436219,-164.680583,-145.8246757,-131.3135381,-107.2424073,-96.60282967,-66.09455088,-39.12388801,-10.4655626,18.43708564,25.39622555,19.70363064,29.50104014,24.65377861,9.065353235,7.800289078,-9.481016435,-32.44722798,-8.425000643,-42.09591755,-84.85431968,-65.23416939,-83.26647469,-88.61872226,-94.31984595,-135.5122422,-96.24493259,-130.6101087,-164.2159095,-163.8014595,-161.2911478,-146.1628098,-143.8038188,-165.9456815,-162.9975622,-186.5376742,-163.928964,-208.4947079,-163.6350835,-143.1139405,-179.8374228,-161.6782426,-170.9720761,-153.9010512,-159.7300558,-169.2543883,-125.3209033,-166.0480624,-190.0647723,-164.8502403,-176.244536,-176.7593197,-141.0916485,-191.6808102,-175.8716194,-179.0655926,-213.334729,-157.4868359,-146.8128336,-176.2284353,-192.1630524,-171.753249,-184.7194487,-190.6521523,-176.2414561,-225.7463566,-181.2578951,-170.1268263,-168.2026363,-136.5319892,-137.8841734,-97.44384241,-96.24254779,-62.94615628,-3.930067195,8.360604156,30.9113395,57.224556,60.38299552,71.4775984,37.93360244,30.25482625,-10.96794785,43.9548974,8.275507057,-5.505276016,-42.18418284,-41.53852257,-38.19401138,-9.988135433,-73.23986505,-82.37523151,-92.49459774,-119.2384522,-117.1943554,-142.7418834,-134.5810715,-155.6807706,-170.4483921,-162.0791537,-121.3606511,-135.2956761,-158.4504113,-177.587806,-191.5341681,-170.2470434,-164.0494494,-169.9082233,-152.4201734,-138.1347796,-151.0786031,-145.2001118,-153.4814199,-183.4935886,-153.946237,-152.2658373,-185.4743658,-160.4133792,-149.8470445,-199.958043,-173.5824841,-170.6156591,-165.6102076,-151.9477062,-183.3851466,-189.1947611,-190.5126042,-178.451038,-232.1975489,-209.617863,-181.0558565,-195.2786295,-195.4491857,-191.063771,-209.1130301,-241.5632851,-171.2830079,-205.2558494,-199.4252494,-171.0996064,-135.2528671,-120.0398883,-86.35313349,-58.75543608,-31.63496181,15.61749277,21.53029518,52.80680223,37.94167304,38.60237186,39.1940536,41.07783215,29.45936977,20.05054327,-8.013389731,16.79412285,-7.969302978,-59.9582873,-64.72356939,-88.95088436,-76.4041469,-98.53033607,-99.11610762,-67.75720734,-95.97143121,-96.68185726,-126.6121091,-105.5375604,-102.3703775,-133.2714074,-131.1305721,-131.4514406,-111.0579924,-136.3332306,-117.5234052,-120.694585,-82.60431528,-108.3972289,-101.9762479,-132.7979261,-94.75065491,-124.2930794,-110.4378804,-138.6506348,-123.5289038,-131.5299734,-132.8438586,-122.8304073,-120.7581867,-100.7386637,-149.5780713,-161.4928199,-157.7717813,-152.1336241,-145.7094938,-159.1026831,-102.0334835,-160.1400191,-153.7176046,-171.7580939,-157.3400312,-166.8574939,-194.2379129,-177.1002617,-134.1092309,-161.9593411,-141.7789387,-142.6961662,-161.7180284,-108.7803143,-101.1193168,-118.6115166,-91.42120803,-70.22670377,-62.88077846,-31.97668856,-6.215203813,-5.233143328,-44.56281787,-21.68037513,-45.79143414,8.989530097,-33.15079614,-21.48894064,-33.49492773,-29.2493369,-41.52894652,-75.47306377,-68.38486974,-74.77386162,-115.0927022,-70.91988867,-114.6172291,-102.9498024,-106.6596287,-125.8687341,-130.0565056,-112.7060226,-114.066016,-144.0590352,-139.9082732,-79.15096988,-122.8808231,-123.1155945,-106.5493839,-95.2442839,-84.61336782,-91.78075471,-81.91146491,-86.01301159,-74.34770941,-57.81595852,-105.2189274,-89.36945358,-78.90219237,-86.36036927,-87.60490458,-82.61198278,-90.23936768,-111.8892024,-119.0173669,-99.10710747,-72.20035121,-105.0562126,-97.31112661,-108.4746315,-124.6542035,-85.76581803,-92.86040155,-109.1004347,-121.3621172,-100.9174347,-142.4731285,-130.0011933,-119.4201213,-139.370153,-121.6220649,-87.52025165,-60.4602173,-39.90009249,-14.47723731,28.08235515,47.0560563,120.2148031,107.0469654,115.7527706,136.7052646,118.2185203,121.9294065,84.74510753,96.10309817,64.47610982,38.05916544,13.27418373,-32.23912655,-36.78391247,-25.11066914,-61.15777398,-98.29203929,-68.59806904,-99.0657737,-87.29964824,-102.3767133,-125.4705793,-135.8394233,-148.0103686,-121.5531103,-140.2008691,-127.8816079,-142.15461,-130.3117346,-142.8451429,-136.1119731,-128.1150761,-181.7599915,-135.3870371,-129.2560956,-137.0686169,-112.1668674,-118.3244947,-88.19945937,-115.5759744,-137.0163441,-85.11711793,-121.9576238,-140.4228662,-144.3353992,-127.470473,-121.8499143,-155.2375142,-141.0241809,-137.4376575,-116.4224465,-156.3159578,-159.9703768,-153.0455255,-116.8784562,-158.7746494,-159.2404272,-146.5092559,-145.9024473,-135.9718693,-149.2638179,-136.4628664,-153.8788251,-138.2996744,-129.7350719,-122.8989196,-69.96569523,-42.6188645,-26.6727897,42.75270977,80.38748068,85.15990593,144.2246011,114.0285993,135.0663365,118.77368,108.4004485,79.29920395,53.47504442,51.4568911,15.51504004,2.820147023,-17.76931482,-29.5342018,-76.86515899,-93.52672611,-92.36201603,-106.8546262,-99.42868777,-128.2335362,-141.4652213,-149.7667769,-173.7089838,-162.7297406,-153.9823947,-157.7649799,-169.7695429,-136.117979,-190.0099192,-171.0138731,-153.8969602,-131.3825889,-132.4775054,-144.8328747,-119.4553937,-118.461819,-152.2870008,-123.99986,-109.9679708,-107.7218485,-134.425985,-108.5528276,-122.931492,-144.3043608,-123.9151892,-136.0427895,-138.2686626,-125.487269,-132.3539958,-138.2329971,-139.939367,-171.8562663,-119.2203833,-148.7311304,-130.8654556,-132.1708188,-140.651656,-146.8004431,-161.7175614,-141.8975887,-204.1681909,-181.4347946,-169.794193,-181.3817571,-163.1939391,-181.9440958,-141.4159902,-161.3779616,-142.8835639,-92.83279682,-87.82929402,-67.63583459,-45.72687899,-18.59988298,-23.8363,3.608611204,1.818248803,-8.739289403,-21.57494524,-41.33157434,-29.03713358,-20.99940689,-50.0813837,-21.99804201,-74.39428105,-76.39698718,-78.44490173,-98.33019493,-107.645843,-99.10440428,-124.3985889,-130.8573096,-163.2159422,-142.4553406,-159.944714,-148.9434037,-160.8869971,-184.5980749,-155.1405424,-146.5041614,-156.7679863,-182.9961263,-180.3384162,-141.9037962,-143.0601834,-164.0363091,-146.9603389,-152.7834731,-164.5475811,-127.676256,-157.8642206,-151.1628084,-166.7477876,-167.5465739,-154.2128082,-171.8941133,-168.0392262,-121.3123974,-145.018166,-204.3435584,-182.2026828,-149.4854941,-183.9677767,-183.512187,-166.1788482,-167.4555169,-173.1731897,-180.8263172,-170.8577042,-177.8208421,-180.3912373,-180.5553552,-195.928325,-196.1781535,-190.0243037,-184.3042068,-191.4410315,-151.0294216,-149.9720078,-127.1330296,-90.14556331,-34.01657424,-24.09053284,-19.20488983,10.32673427,26.05205325,15.75123511,41.96615392,14.59800579,-13.62332522,-21.03076268,-30.02105683,-41.17833452,-77.18028379,-96.99706135,-127.306131,-132.4580054,-134.9024561,-152.8904973,-176.0369535,-161.986251,-138.455779,-201.3283425,-208.3465867,-200.7438402,-205.9870668,-219.1445998,-192.2587361,-176.9577506,-210.0107858,-208.2073254,-174.0554183,-189.1968548,-168.2189224,-154.2706031,-126.5548643,-135.7245765,-173.113575,-139.4801769,-150.9201739,-157.1746172,-125.409453,-152.7137791,-170.3718494,-157.5132698,-166.5706996,-203.1650381,-182.003685,-160.8451871,-150.3803736,-156.9948784,-172.4977517,-201.7729783,-169.2198307,-186.9477502,-174.2955725,-174.2682879,-193.5521213,-164.0675421,-193.5597176,-180.4292896,-190.882491,-229.4133228,-207.9229962,-210.5044907,-176.0909394,-216.6674227,-143.3847579,-135.8177249,-94.8520075,-55.29308187,-8.596819711,7.964483205,28.48459718,44.78772264,17.27301549,25.115108,0.829013092,4.966635828,-32.97422792,-55.44387968,-38.01791022,-66.97019754,-80.10909905,-133.6043384,-122.9867923,-158.0198585,-168.7119192,-162.1761282,-193.2111663,-202.4715106,-215.1658819,-205.3750362,-182.2905731,-219.30705,-200.7479717,-204.8469231,-209.0812153,-211.6547947,-204.1270669,-226.8917176,-192.2647367,-192.0937077,-149.1202258,-178.2079718,-153.9820205,-160.0980568,-143.4038851,-160.9962075,-152.194965,-144.7864218,-152.6499076,-161.0921342,-146.3687844,-133.3138354,-157.2481451,-168.1529119,-177.2414936,-175.869606,-163.9159113,-167.8363622,-171.5562753,-176.8878957,-184.8272099,-173.231631,-189.1954342,-186.7880633,-198.419782,-198.4993576,-205.7931514,-225.0244529,-217.432668,-225.6304254,-208.4727153,-196.0858998,-179.7989551,-180.135508,-107.6521441,-84.49460718,-57.79385363,-5.432363826,-7.905866213,7.415821868,38.71482905,49.74463987,38.91135793,38.58460628,16.72865935,-6.29901565,-32.45669955,-70.16222148,-105.1041477,-100.6433214,-130.2641923,-128.9636693,-174.105794,-178.0473545,-205.6339688,-235.4556809,-201.4454861,-241.9226402,-217.5838268,-244.6654605,-264.975986,-235.3203644,-194.1459558,-224.5232334,-192.4564951,-196.1291018,-186.0265871,-162.9354431,-185.5400986,-178.1149615,-150.0574549,-160.1466649,-154.5837003,-137.2761693,-141.4914396,-123.2661691,-148.2682616,-144.4504403,-139.3705715,-155.2151228}; float y = 0; int num_of_data = 1000; void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: for (int i = 0; i< 1000; i++) { y = 0; // First Order Difference if (i == 0) { y = 0; } else { y = arr[i] - arr[i-1]; } Serial.print(arr[i]); Serial.print(','); Serial.println(y); } } ",12051,True,3705.033977651439,median "; Contains multiplayer menu, and all menus derived from it [list -] %include ""swos.inc"" %include ""swsmenu.inc"" %include ""mplayer.inc"" [list +] extern GetPreviousMenu, ReturnToMenu, SetMenuToReturnToAfterTheGame extern GetSkipFrames, SetSkipFrames extern GetNumSubstitutes, SetNumSubstitutes, GetMaxSubstitutes, SetMaxSubstitutes extern strupr, GetDirectGameName bits 32 section .data ; ; multiplayer menu ; extern GetPlayerNick, SetPlayerNick, GetGameName, SetGameName, SetTeam, ShowMPOptions global multiplayerMenu StartMenu multiplayerMenu, InitMultiplayerMenu, MPMenuAfterDraw, 0, 4 ; [0] ""nickname"" StartEntry 53, 45, 60, 11 EntryColor 9 EntryString 0, ""NICKNAME"" EndEntry ; [1] enter name StartEntry 115, 45, 136, 11, playerNick NextEntries -1, -1, -1, 3 EntryColor 13 EntryString 0, -1 OnSelect MPMenuSetPlayerNick EndEntry ; [2] ""game name"" StartEntry 53, 60, 60, 11 EntryColor 9 EntryString 0, ""GAME NAME"" EndEntry ; [3] enter game name StartEntry 115, 60, 136, 11, gameName NextEntries -1, -1, 1, 4 EntryColor 13 EntryString 0, -1 OnSelect MPMenuSetGameName EndEntry ; [4] create game StartEntry 92, 80, 120, 15 NextEntries -1, -1, 3, 5 EntryColor 14 EntryString 0, ""CREATE GAME"" OnSelect ShowGameLobbyMenu EndEntry ; [5] join game StartEntry 92, 105, 120, 15 NextEntries -1, -1, 4, 6 EntryColor 14 EntryString 0, aJoinGame OnSelect ShowJoinGameMenu EndEntry ; [6] options StartEntry 92, 130, 120, 15 NextEntries -1, -1, 5, 7 EntryColor 14 EntryString 0, ""OPTIONS"" OnSelect ShowMPOptions EndEntry ; [7] exit StartEntry 102, 185, 100, 15 NextEntries -1, -1, 6, -1 EntryColor 12 EntryString 0, aExit OnSelect ExitMultiplayerMenu EndEntry ; [8] title StartEntry 92, 0, 120, 15 EntryColor 0x17 EntryString 0, ""MULTIPLAYER"" EndEntry EndMenu section .text ; functions from Multiplayer menu extern ShutDownNetwork, InitPlayerNick, InitGameName, extern InitMultiplayer, FinishMultiplayer InitMultiplayerMenu: call InitMultiplayer ; forbid entering this menu if multiplayer isn't working for some reason test eax, eax jnz .err_exit call PatchMenu jmp MPMenuAfterDraw .err_exit: call strupr ; it'll tell us what the error was mov dword [A0], eax ShowErrorMenuAndExit: calla ShowErrorMenu jmpa SetExitMenuFlag ; SetEntryString ; ; in: ; eax -> source string that will be put to menu entry ; A5 -> menu ordinal of which to set string ; ; Set specific menu entry text to given string. ; extern strcpy SetEntryString: mov ecx, eax calla CalcMenuEntryAddress mov edx, ecx mov esi, [A0] mov eax, [esi + MenuEntry.string] jmpa strcpy ; Fill game name and player nickname and prevent them appearing as ""STDMENUTEXT"". MPMenuAfterDraw: push byte multiplayerMenu_playerNick call GetPlayerNick pop dword [D0] call SetEntryString push byte multiplayerMenu_gameName call GetGameName pop dword [D0] jmp SetEntryString ExitMultiplayerMenu: call UnpatchMenu call FinishMultiplayer jmpa SetExitMenuFlag ; InputStringToEntryAndSave ; ; in: ; A5 -> menu entry whose string buffer will be used for input ; ebx - buffer max length (limit for string input) ; ecx -> store function, expects pointer to string that received the input in eax ; InputStringToEntryAndSave: mov esi, [A5] mov eax, [esi + MenuEntry.string] mov [A0], eax mov dword [D0], ebx push eax ; save string buffer and pointer to function push ecx calla InputText pop ecx pop eax jnz .out call ecx .out: retn MPMenuSetGameName: push byte GAME_NAME_LENGTH mov ecx, SetGameName pop ebx jmp InputStringToEntryAndSave global MPMenuSetPlayerNick MPMenuSetPlayerNick: push byte NICKNAME_LEN mov ecx, SetPlayerNick pop ebx jmp InputStringToEntryAndSave ShowGameLobbyMenu: call GetPlayerNick mov al, [eax] ; don't let them in without a nickname test al, al jz .nick_error call GetGameName mov al, [eax] ; don't let them in without game name either test al, al jz .game_name_error mov byte [weAreTheServer], 1 mov dword [A6], gameLobbyMenu jmpa ShowMenu .game_name_error: movstr dword [A0], ""PLEASE ENTER GAME NAME"" jmp short .out .nick_error: movstr dword [A0], ""PLEASE ENTER NICKNAME"" .out: jmpa ShowErrorMenu ; ReturnToMPMenuAfterTheGame [called from C++] ; ; Make sure we are returning to multiplayer menu, in case choose teams menu was open. ; ReturnToMPMenuAfterTheGame: pushad xor ebx, ebx xor eax, eax mov al, [weAreTheServer] cmp ebx, eax sbb eax, eax not eax neg eax lea edx, [eax + 4] mov eax, multiplayerMenu call SetMenuToReturnToAfterTheGame mov byte [choosingTeam], 0 calla ExitChooseTeams calla SetExitMenuFlag popad retn UnpatchSWOSProc: mov byte [SWOS + 0x24b], 0 jmpa RestorePreviousMenu ; ReturnToGameLobbyAfterTheGame [called from C++] ; ReturnToGameLobbyAfterTheGame: pushad mov eax, gameLobbyMenu cmp [currentMenuPtr], eax jz .out mov edx, [gameLobbySelectedEntry] call SetMenuToReturnToAfterTheGame mov byte [choosingTeam], 0 calla ExitChooseTeams ; will exit menu, and luckily we know it can be _max_ one menu :P call UnpatchAfterSettingTeams mov eax, [currentMenuPtr] cmp eax, continueAbortMenu jz .out calla ExitPlayMatch mov eax, gameLobbyMenu xor edx, edx call ReturnToMenu mov byte [SWOS + 0x24b], 1 ; SWOS disallows returning back from menu that called game lea eax, [UnpatchSWOSProc - 5] ; choose teams is toughie lea ebx, [SWOS + 0x259] sub eax, ebx mov dword [SWOS + 0x25a], eax .out: popad retn ; SetGameLobbyMenuServerMode ; ; in: ; al - boolean, server mode true or false ; ; Control behaviour of game lobby menu, are we showing it in server or client mode. ; global SetGameLobbyMenuServerMode SetGameLobbyMenuServerMode: mov [weAreTheServer], al retn section .data ; ; join game menu ; StartMenu joinGameMenu, InitJoinGameMenu, 0, 0, 13 ; [0] menu title StartEntry 92, 0, 120, 15 EntryColor 0x17 EntryString 0, aJoinGame EndEntry ; [1] game list title %assign x 92 %assign width 120 StartEntry x, 20, width, 15 EntryColor 9 EntryString 0, ""CURRENT GAMES:"" EndEntry ; games template entry StartTemplateEntry StartEntry EntryColor 13 EntryString 0, 0 InvisibleEntry OnSelect OnJoinGame EndEntry MarkNextEntryOrdinal mpGamesStartIndex ; [2-11] found games 10 entries %assign y 41 %assign prev -1 %assign index 2 %rep 10 %assign next index + 1 StartEntry x - width / 2, y, 2 * width, 11 NextEntries -1, -1, prev, next EndEntry %assign y y + 12 %assign prev index %assign index index + 1 %endrep RestoreTemplateEntry MarkNextEntryOrdinal mpGamesEndIndex ; [12] refresh StartEntry x, 200 - 2 * 15 - 4, width, 15, Refresh EntryString 0, aRefresh EntryColor 14 OnSelect RequestListRefresh NextEntries -1, -1, prev, index + 1 EndEntry ; [13] exit StartEntry 102, 200 - 15, 100, 15, Exit EntryString 0, aExit EntryColor 4 OnSelect ExitJoinGameMenu NextEntries -1, -1, prev + 1, -1 EndEntry EndMenu aRefresh: db ""REFRESH"", 0 aSearching: db ""SEARCHING..."", 0 section .text ShowJoinGameMenu: mov dword [A6], joinGameMenu jmpa ShowMenu extern EnterWaitingToJoinState InitJoinGameMenu: mov eax, RefreshWaitingGames xor edx, edx call EnterWaitingToJoinState retn extern LeaveWaitingToJoinState ExitJoinGameMenu: call LeaveWaitingToJoinState jmpa SetExitMenuFlag ; Refresh button is pressed. extern RefreshList RequestListRefresh: call RefreshList mov word [prevRefreshDisabled], 0 retn ; ToggleRefreshing ; ; in: ; eax - true if currently refreshing ; ; Toggle refresh button between ""REFRESH"" and ""SEARCHING"" labels. While it's ; refreshing disable it, and switch to exit button. ; ToggleRefreshing: push eax mov [D0], word joinGameMenu_Refresh calla CalcMenuEntryAddress mov esi, [A0] mov [esi + MenuEntry.string], dword aRefresh ; assume not searching mov [esi + MenuEntry.backAndFrameColor], word 14 pop eax mov [esi + MenuEntry.isDisabled], ax test eax, eax jz .out mov [esi + MenuEntry.string], dword aSearching mov [esi + MenuEntry.backAndFrameColor], word 9 mov eax, [g_currentMenu] ; check if there are any games listed xor ecx, ecx xor ebx, ebx mov cx, mpGamesStartIndex .nextEntry: mov [D0], cx push ebx calla CalcMenuEntryAddress pop ebx mov esi, [A0] cmp word [esi + MenuEntry.isInvisible], 0 jnz .continue mov ebx, ecx .continue: inc ecx add esi, MenuEntry_size cmp ecx, joinGameMenu_Refresh jb .nextEntry test ebx, ebx jz .out cmp word [prevRefreshDisabled], 0 jnz .out mov [D0], word joinGameMenu_Exit calla SetCurrentEntry add word [prevRefreshDisabled], 1 .out: retn ; EnterGameLobby [called from C++] ; ; We have been granted the privilege by the gaming gods. ; EnterGameLobby: pushad mov byte [weAreTheServer], 0 mov dword [A6], gameLobbyMenu calla ShowMenu popad retn ; RefreshWaitingGames [called from C++] ; ; in: ; eax -> pointer to state info structure, see below for details ; ; Refresh graphical state of the waiting to join games menu. We get called from ; network loop, which sends us complete state in an array with the following ; structure: ; 0 dword, boolean: true if we're still refreshing ; 4 dword, pointer to string: name of n-th game (note: there may be 0 games!) ; ... ... ; x dword, value -1: terminator for the string array ; RefreshWaitingGames: pushad push eax add eax, 4 mov [D0], dword mpGamesStartIndex push eax calla CalcMenuEntryAddress pop eax mov esi, [A0] ; esi -> current entry mov [D0], dword mpGamesEndIndex push eax calla CalcMenuEntryAddress pop eax mov edi, [A0] ; edi -> sentry entry .next_ptr: cmp [eax], dword -1 jz .clear_games_loop mov [esi + MenuEntry.isInvisible], word 0 mov ebx, [eax] mov [esi + MenuEntry.string], ebx add eax, 4 add esi, MenuEntry_size jmp .next_ptr .clear_games_loop: ; make any remaining entries invisible cmp esi, edi jge .toggle_refresh mov [esi + MenuEntry.isInvisible], word 1 add esi, MenuEntry_size jmp .clear_games_loop .toggle_refresh: pop eax mov eax, [eax] call ToggleRefreshing popad retn ; JoinRemoteGame ; ; in: ; eax - joining game ordinal ; ; Display modal ""connecting"" dialog while trying to connect to the selected game. ; extern JoinGame, InitModalDialog global JoinRemoteGame JoinRemoteGame: push eax mov eax, modalDialogInitData mov dword [modalDialogStrTable], connectingPleaseWaitStrTable call InitModalDialog pop eax mov edx, JoinGameModalDialogProc mov ecx, EnterGameLobby push PlayMatchMenuTimeout push SyncModalDialogProc push ReturnToGameLobbyAfterTheGame push ReturnToMPMenuAfterTheGame push ShowPlayMatchMenu push SyncModalDialogProc push DisconnectedFromLobby call JoinGame ; has stack frame, do not ""optimize"" retn OnJoinGame: mov esi, [A5] mov eax, [esi + MenuEntry.ordinal] sub eax, mpGamesStartIndex call JoinRemoteGame mov word [D0], joinGameMenu_Exit jmpa SetCurrentEntry ; ExitSWOS ; ; Switch back to previous screen resolution and close SWOS gracefully. ; extern EndProgram, SwitchToPrevVideoMode ExitSWOS: call SwitchToPrevVideoMode xor eax, eax jmp EndProgram ; ExitIfInDirectMode ; ; Exit SWOS if we are in direct connect mode. ; ExitIfInDirectMode: call GetDirectGameName mov al, [eax] test al, al jz .out call DisbandGame jmp ExitSWOS .out: retn ; DisconnectedFromLobby [called from C++] ; ; Called when we get disconnected from the lobby. Show error message and go ; back to trying to find some games, unless in direct connect mode -- in that ; case exit SWOS. ; DisconnectedFromLobby: pushad movstr dword [A0], ""DISCONNECTED FROM THE SERVER"" calla ShowErrorMenu call ExitIfInDirectMode call InitJoinGameMenu mov eax, joinGameMenu xor edx, edx call ReturnToMenu ; make sure we land where we're supposed to mov byte [choosingTeam], 0 calla ExitChooseTeams ; in case we interrupt choose team menu popad retn ; MiniMenuLoop ; ; Essential parts of menu loop - menu loop in a nutshell. ; MiniMenuLoop: call DrawModalDialog calla FlipInMenu mov ax, 4 ; try to set a longer delay if faster memory to video copy cmp word [videoSpeedIndex], 50 jg short .pause mov ax, 2 .pause: cmp [menuCycleTimer], ax jl short .pause mov word [menuCycleTimer], 0 calla SWOS_ReadGamePort calla CheckControls calla WaitRetrace movzx ecx, word [PIT_countdown] mov al, 110110b jmpa ProgramPIT ; JoinGameModalDialogProc [called from C++] ; ; in: ; al - status code: ; -1 = done, error ; 0 = not done ; 1 = done, ok ; edx -> error string (if error status) ; ; out: ; al - true - user requesting dispensing of dialog ; false - stay blocked ; ; While a blocking operation is being done, draw corresponding modal dialog ; based on status code. Re-initialize dialog on code changes. Return true if ; requesting dismissal. If error, stay in error state until dismissal. ; extern DrawModalDialog, disabledInputCycles JoinGameModalDialogProc: pushad mov bl, [lastModalState] mov [lastModalState], al cmp al, 1 jz .out ; also return true since we're done cmp al, bl jz .draw_modal cmp bl, -1 jnz .reinitialize mov byte [lastModalState], -1 ; make sure we stay in error state jmp .draw_modal .reinitialize: test edx, edx ; set which string we're showing mov byte [disabledInputCycles], 15 mov dword [errorModalDialogInitData + 10], failedToConnectStrTable jz .set_init_data mov esi, eax mov dword [errorModalDialogInitData + 10], serverErrorMessageStrTable mov ebx, serverErrorMessageLen - 1 mov eax, serverErrorMessage mov edi, eax calla swos_libc_strncpy_, ecx mov byte [eax], 0 mov eax, edi call strupr mov eax, esi .set_init_data: test al, al mov eax, errorModalDialogInitData jnz .init_dialog mov eax, modalDialogInitData .init_dialog: call InitModalDialog .draw_modal: call MiniMenuLoop xor eax, eax mov al, [lastModalState] test al, al jz .out mov ax, word [fire] ; check fire only if we're showing error dialog mov word [fire], 0 ; prevent from exiting menu test ax, ax jz .out mov al, [disabledInputCycles] test al, al jnz .out mov byte [lastModalState], 0 ; reset this so we don't remain in error state forever ;) call ExitIfInDirectMode ; if we failed to connect while in direct connect mode, exit SWOS mov al, 1 .out: mov [esp + 28], eax popad retn section .data ; ; game lobby menu ; StartMenu gameLobbyMenu, InitGameLobbyMenu, SaveCurrentGLEntry, GameLobbyBeforeDraw, 22 ; [0] title StartEntry 87, 0, 130, 15 EntryColor 0x17 EntryString 0, ""MULTIPLAYER GAME SETUP"" EndEntry ; [1] cancel game StartEntry 164, 190, 74, 10, cancelGame NextEntries 40, 2, 21, -1 EntryColor 12 EntryString 0, ""CANCEL GAME"" OnSelect ExitGameLobbyMenu EndEntry ; [2] start game StartEntry 238, 190, 74, 10, startGame NextEntries gameLobbyMenu_cancelGame, -1, 52, -1 EntryColor 9 EntryString 0, ""START GAME"" OnSelect OnStartGame DownSkip 1, 0 ; go left EndEntry ; [3] ""connected players:"" %assign player_entry_width 130 %assign start_y 16 StartEntry 1, start_y, player_entry_width, 12 EntryColor 9 EntryString 0, ""CONNECTED PLAYERS:"" EndEntry ; [4] ""teams:"" StartEntry 10 + player_entry_width, start_y, player_entry_width, 12 EntryColor 9 EntryString 0, ""TEAMS:"" EndEntry ; [5] ""go:"" StartEntry 19 + 2 * player_entry_width, start_y, 25, 12 EntryColor 9 EntryString 0, ""GO:"" EndEntry ; template for player names StartTemplateEntry StartEntry 1, start_y + 13, player_entry_width, 8 EntryString 0, 0 EntryColor 13 EndEntry MarkNextEntryOrdinal glPlayerNamesStart ; [6-13] joined player names %assign y start_y + 13 %assign index glPlayerNamesStart %assign prev -1 %rep MAX_PLAYERS %assign next index + 1 %if index >= glPlayerNamesStart + MAX_PLAYERS - 1 %assign next 40 %endif StartEntry 1, y, player_entry_width, 8 NextEntries -1, index + MAX_PLAYERS, prev, next EndEntry %assign y y + 9 %assign prev index %assign index index + 1 %endrep RestoreTemplateEntry MarkNextEntryOrdinal glPlayerNamesEnd ; template for player teams StartTemplateEntry StartEntry 10 + player_entry_width, start_y + 22, player_entry_width, 8 EntryColor 12 EntryString 0, 0 OnSelect 0 EndEntry MarkNextEntryOrdinal glPlayerTeamNamesStart ; [14-21] joined player teams %assign y start_y + 13 %assign index glPlayerTeamNamesStart %assign prev -1 %assign right glPlayerTeamNamesStart + MAX_PLAYERS %rep MAX_PLAYERS %assign next index + 1 %if index >= glPlayerTeamNamesStart + MAX_PLAYERS - 1 %assign next 42 %endif StartEntry 10 + player_entry_width, y, player_entry_width, 8 NextEntries index - glPlayerTeamNamesStart + glPlayerNamesStart, right, prev, next EndEntry %assign prev index %assign index index + 1 %assign y y + 9 %endrep RestoreTemplateEntry MarkNextEntryOrdinal glPlayerTeamNamesEnd ; joined players go checkbox template StartTemplateEntry StartEntry 19 + 2 * player_entry_width, start_y + 13, 25, 8 EntrySprite2 209 EntryColor 10 OnSelect 0 EndEntry MarkNextEntryOrdinal glPlayerGoCheckboxesStart ; [22-29] joined players go checkboxes %assign y start_y + 13 %assign index glPlayerGoCheckboxesStart %rep MAX_PLAYERS StartEntry 19 + 2 * player_entry_width, y, 25, 8 %if index == glPlayerGoCheckboxesStart OnSelect ToggleReadyState BeforeDraw UpdateReadyState NextEntries glPlayerTeamNamesStart, -1, -1, 42 %endif EndEntry %assign index index + 1 %assign y y + 9 %endrep RestoreTemplateEntry MarkNextEntryOrdinal glPlayerGoCheckboxesEnd ; [30] ""chat:"" %assign chat_x 1 %assign chat_y 100 %assign chat_width 161 StartEntry chat_x, chat_y, chat_width, 8 EntryString 0, ""CHAT:"" EntryColor 14 EndEntry ; chat lines template StartTemplateEntry StartEntry EntryString 1 << 15, 0 InvisibleEntry EndEntry MarkNextEntryOrdinal glChatLines ; [31-39] chat lines %assign y chat_y + 9 %rep 9 StartEntry chat_x, y, chat_width, 8 EndEntry %assign y y + 9 %endrep RestoreTemplateEntry ; [40] chat input StartEntry chat_x, y, chat_width, 10, chatInput EntryColor 13 EntryString 1 << 15, -1 OnSelect ChatLineInput NextEntries -1, gameLobbyMenu_cancelGame, glPlayerNamesEnd - 1, -1 EndEntry ; options ; [41] join as text StartEntry 164, chat_y, 82, 11 EntryColor 9 EntryString 0, ""JOIN AS"" EndEntry MarkNextEntryOrdinal glOptionsStart ; [42] player/watcher StartEntry 251, chat_y, 54, 11, playerWatcher EntryColor 13 StringTable 0, playerWatcherStrTable OnSelect ChangePlayerWatcher NextEntries -1, -1, glPlayerGoCheckboxesStart, 44 EndEntry ; [43] game length text StartEntry 164, chat_y + 13, 82, 11 EntryColor 9 EntryString 0, aGameLength EndEntry ; [44] game length StartEntry 251, chat_y + 13, 54, 11, optGameLength EntryColor 13 StringTable 0, gameLengthStrTable OnSelect ChangeGameLengthAndNotify NextEntries -1, -1, gameLobbyMenu_playerWatcher, 46 EndEntry ; [45] pitch type text StartEntry 164, chat_y + 2 * 13, 82, 11 EntryColor 9 EntryString 0, aPitchType EndEntry ; [46] pitch type StartEntry 251, chat_y + 2 * 13, 54, 11, optPitchType EntryColor 13 StringTable 0, pitch_type_str_table OnSelect ChangePitchTypeAndNotify NextEntries -1, -1, gameLobbyMenu_optGameLength, 48 EndEntry ; [47] substitutes text StartEntry 164, chat_y + 3 * 13, 82, 11 EntryColor 9 EntryString 0, aSubstitutes EndEntry ; [48] number of substitutes StartEntry 251, chat_y + 3 * 13, 11, 11, optNumSubstitutes EntryColor 13 EntryString 0, -1 OnSelect ChangeNumSubstitutesAndNotify NextEntries -1, 50, gameLobbyMenu_optPitchType, 52 EndEntry ; [49] substitutes from text StartEntry 263, chat_y + 3 * 13, 30, 11 EntryColor 9 EntryString 0, aFrom EndEntry ; [50] max substitutes StartEntry 294, chat_y + 3 * 13, 11, 11, optMaxSubstitutes EntryColor 13 EntryString 0, -1 NextEntries gameLobbyMenu_optNumSubstitutes, -1, \\ gameLobbyMenu_optPitchType, 52 OnSelect ChangeMaxSubstitutesAndNotify EndEntry ; [51] auto save replays text StartEntry 164, chat_y + 4 * 13, 82, 11 EntryColor 9 EntryString 0, ""SAVE REPLAYS"" EndEntry ; [52] auto save replays on/off StartEntry 251, chat_y + 4 * 13, 54, 11, optAutoSaveReplays EntryColor 13 OnSelect ToggleSaveAutoReplays StringTable 0, autoSaveReplaysTable NextEntries -1, -1, gameLobbyMenu_optNumSubstitutes, 54 EndEntry ; [53] skip frames text StartEntry 164, chat_y + 5 * 13, 82, 11 EntryColor 9 EntryString 0, ""SKIP FRAMES"" EndEntry ; [54] decrease skip frames button StartEntry 251, chat_y + 5 * 13, 16, 11, optDecreaseFrameSkip EntryColor 13 EntryString 0, aMinus OnSelect DecreaseSkipFramesAndNotify NextEntries -1, 56, gameLobbyMenu_optAutoSaveReplays, gameLobbyMenu_startGame EndEntry ; [55] skip frames StartEntry 268, chat_y + 5 * 13, 20, 11, optSkipFrames EntryColor 9 EntryNumber 0, 0 EndEntry ; [56] increase skip frames button StartEntry 289, chat_y + 5 * 13, 16, 11, optIncreaseFrameSkip EntryColor 13 EntryString 0, aPlus OnSelect IncreaseSkipFramesAndNotify NextEntries gameLobbyMenu_optDecreaseFrameSkip, -1, \\ gameLobbyMenu_optAutoSaveReplays, gameLobbyMenu_startGame EndEntry EndMenu ; entries that have to be permanently disabled when we're entering this menu as clients entriesToDisable: db gameLobbyMenu_optGameLength db gameLobbyMenu_optPitchType db gameLobbyMenu_optNumSubstitutes db gameLobbyMenu_optMaxSubstitutes db gameLobbyMenu_startGame db gameLobbyMenu_optDecreaseFrameSkip db gameLobbyMenu_optIncreaseFrameSkip db -1 section .text ; GetGameLobbyMenu ; ; External accessor for game lobby menu. ; global GetGameLobbyMenu GetGameLobbyMenu: mov eax, gameLobbyMenu retn ; DisplayErrorAndExit ; ; Unpatch everything and make a switch from game to menu display. ; Then show error menu and wait for player to press exit. ; Only called in direct connect mode. ; extern ShowErrorAndQuit, FinishMultiplayerGame DisplayErrorAndExit: calla FadeOutToBlack calla LoadFillAndSwtitle mov eax, [linAdr384k] mov [vsPtr], eax mov word [screenWidth], 320 mov word [cameraX], 0 mov word [cameraY], 0 call UnpatchAfterSettingTeams ; required to regain user input call FinishMultiplayerGame movstr eax, ""GAME INTERRUPTED"" jmp ShowErrorAndQuit ; InitGameLobbyMenu ; ; Game lobby menu OnInit function. ; extern CreateNewGame, CanGameStart, GetFreshMPOptions InitGameLobbyMenu: call GetDirectGameName mov al, [eax] mov edi, ReturnToMPMenuAfterTheGame test al, al jz .not_direct_mode mov edi, DisplayErrorAndExit .not_direct_mode: mov byte [syncDialogInitialized], 0 push byte gameLobbyMenu_chatInput pop dword [D0] calla CalcMenuEntryAddress mov esi, [A0] mov esi, [esi + MenuEntry.string] mov [esi], byte 0 sub esp, MP_Options_size mov eax, esp call GetFreshMPOptions mov edx, UpdateGameLobby movzx ecx, byte [weAreTheServer] push ecx push ReturnToGameLobbyAfterTheGame mov ecx, edi call CreateNewGame add esp, MP_Options_size mov byte [isReady], 0 ; not ready by default %ifdef DEBUG call ToggleReadyState ; except in debug version %endif mov word [playerOrWatcher], 0 ; player (not watcher) by default call SetNumSubstitutesText mov dword [D0], gameLobbyMenu_optAutoSaveReplays ; disable auto-save replays for now calla CalcMenuEntryAddress mov esi, [A0] mov word [esi + MenuEntry.isDisabled], 1 mov word [esi + MenuEntry.backAndFrameColor], 9 call DisableServerOnlyEntries .out: retn SaveCurrentGLEntry: mov eax, [g_currentMenu + Menu.currentEntry] test eax, eax jz .out mov eax, [eax + MenuEntry.ordinal] mov [gameLobbySelectedEntry], eax .out: retn ; DisableServerOnlyEntries ; ; Disable certain menu entries that only host is allowed to change (game options). ; Must be called from init and after draw functions. ; DisableServerOnlyEntries: push byte gameLobbyMenu_optAutoSaveReplays ; disable auto-save replays for now pop dword [D0] calla CalcMenuEntryAddress mov eax, [A0] mov word [eax + MenuEntry.isDisabled], 1 mov dword [eax + MenuEntry.backAndFrameColor], 9 mov al, [weAreTheServer] test al, al jnz InitGameLobbyMenu.out mov esi, entriesToDisable ; if not server disable option entries .disable_next_entry: lodsb cmp al, -1 jz InitGameLobbyMenu.out cbw mov [D0], ax calla CalcMenuEntryAddress mov eax, [A0] mov word [eax + MenuEntry.isDisabled], 1 mov dword [eax + MenuEntry.backAndFrameColor], 9 jmp .disable_next_entry ; FixSelectedEntry ; ; After refreshing player list check if currently selected player may have been ; disconnected or left on their own. If so, move cursor to entry above. ; Must not modify edi. ; FixSelectedEntry: mov ecx, g_currentMenu mov esi, [ecx + Menu.currentEntry] test esi, esi jz short .out cmp word [esi + MenuEntry.isInvisible], 0 jz short .out movsx eax, byte [esi + MenuEntry.upEntry] test eax, eax ; this should never happen, as there should always be js short .out ; at least 1 player above - us, but let's be safe lea ebx, [8 * eax - Menu_size] shl eax, 6 sub eax, ebx ; eax = entry index * 56 (MenuEntry size) + Menu header size add eax, ecx ; eax -> up entry mov dword [ecx + Menu.currentEntry], eax .out: retn ; UpdateGameLobby [called from C++] ; ; in: ; eax -> LobbyState structure (described in mplayer.h) ; ; Update entire game lobby screen based on informations received from the ; network module. Called each frame. ; extern GetCurrentTeamId, ApplyMPOptions UpdateGameLobby: pushad cmp byte [choosingTeam], 0 jnz .out mov edi, eax ; edi will point to passed infos mov ecx, [edi + LobbyState.numPlayers] ; ecx - number of players push byte glPlayerNamesStart pop edx mov [D0], edx ; edx - current player entry number push edx calla CalcMenuEntryAddress pop edx mov ebp, [A0] ; ebp -> current player name entry lea esi, [ebp + (glPlayerTeamNamesStart - glPlayerNamesStart) * MenuEntry_size] push esi ; esi -> current player team name entry lea ebx, [ebp + (glPlayerGoCheckboxesStart - glPlayerNamesStart) * MenuEntry_size] ; ebx -> current player ready icon entry ; set each player's name, team and ready icon .players_loop: xor eax, eax dec ecx mov [ebp + MenuEntry.string], dword 0 ; assume no player mov [esi + MenuEntry.string], dword 0 mov [esi + MenuEntry.onSelect], dword 0 mov [ebp + MenuEntry.isInvisible], dword -1 ; set both invisible and disabled mov [ebx + MenuEntry.isInvisible], dword -1 mov [esi + MenuEntry.isInvisible], dword -1 mov [ebx + MenuEntry.sprite2], word 209 ; assume not ready mov [ebx + MenuEntry.backAndFrameColor], word 10 ; red js .next mov eax, [edi + LobbyState.playerNames + 4 * (edx - glPlayerNamesStart)] mov [ebp + MenuEntry.isInvisible], dword 0 ; make it visible and enable it mov [esi + MenuEntry.isInvisible], dword 0 mov [ebx + MenuEntry.isInvisible], dword 0 mov [ebp + MenuEntry.string], eax ; set the name string mov eax, [edi + LobbyState.playerFlags + 4 * (edx - glPlayerNamesStart)] push eax and eax, 2 shr eax, 1 sub [ebx + MenuEntry.sprite2], ax ; 208 = ready, 209 = not ready shl eax, 2 add [ebx + MenuEntry.backAndFrameColor], ax ; 14 for green if ready pop eax and eax, 1 lea eax, [eax * 2 + 11] ; color = 11 for player, 13 for watcher mov [ebp + MenuEntry.backAndFrameColor], ax mov eax, [edi + LobbyState.playerTeamsNames + 4 * (edx - glPlayerNamesStart)] mov [esi + MenuEntry.string], eax ; set the team name string test eax, eax jz .team_not_chosen mov al, [eax] test al, al jnz .next .team_not_chosen: mov dword [esi + MenuEntry.string], aTeamNotChosen .next: inc edx add ebp, MenuEntry_size add esi, MenuEntry_size add ebx, MenuEntry_size cmp edx, byte glPlayerNamesEnd jb .players_loop call FixSelectedEntry mov word [D0], glPlayerGoCheckboxesStart ; fix our player, they're always at index 0 calla CalcMenuEntryAddress mov esi, [A0] mov dword [esi + MenuEntry.onSelect], ToggleReadyState pop esi mov dword [esi + MenuEntry.onSelect], ChooseTeam ; enable our player to select team call GetCurrentTeamId cmp eax, -1 jz .set_choose_team mov eax, [esi + MenuEntry.string] test eax, eax jz .set_choose_team mov al, [eax] test al, al jnz .apply_options .set_choose_team: mov dword [esi + MenuEntry.string], aChooseTeam ; ""choose team"" if not chosen already mov word [esi + MenuEntry.backAndFrameColor], 10 ; mark the entry as red .apply_options: mov ebp, edi lea eax, [edi + LobbyState.MP_Options] call ApplyMPOptions xor ecx, ecx ; set the chat lines push byte glChatLines pop eax mov [D0], eax calla CalcMenuEntryAddress mov esi, [A0] ; fill chat lines .next_line: mov dword [esi + MenuEntry.isInvisible], -1 ; assume no chat line mov byte [esi + MenuEntry.stringFlags], 0 mov eax, [ebp + 4 * ecx + LobbyState.chatLines] test eax, eax jz .skip_line mov bl, [eax] test bl, bl jz .skip_line mov dword [esi + MenuEntry.isInvisible], 0 ; we got the line mov [esi + MenuEntry.string], eax mov al, [ebp + ecx + LobbyState.chatLineColors] mov [esi + MenuEntry.stringFlags], al .skip_line: inc ecx add esi, MenuEntry_size cmp ecx, MAX_CHAT_LINES jb .next_line .out: popad retn extern UpdateMPOptions ChangeGameLengthAndNotify: calla ChangeGameLength NotifyOptionsChange: sub esp, MP_Options_size mov eax, esp call GetFreshMPOptions mov eax, esp call UpdateMPOptions add esp, MP_Options_size retn IncDecSkipFramesAndNotify: call GetSkipFrames .opByte: dec eax jns .set_frames inc eax .set_frames: call SetSkipFrames push byte gameLobbyMenu_optSkipFrames pop dword [D0] calla CalcMenuEntryAddress call GetSkipFrames mov esi, [A0] mov [esi + MenuEntry.number], eax jmp NotifyOptionsChange DecreaseSkipFramesAndNotify: mov byte [IncDecSkipFramesAndNotify.opByte], 0x48 jmp IncDecSkipFramesAndNotify IncreaseSkipFramesAndNotify: mov byte [IncDecSkipFramesAndNotify.opByte], 0x40 jmp IncDecSkipFramesAndNotify ChangePitchTypeAndNotify: calla ChangePitchType jmp NotifyOptionsChange extern AddChatLine ChatLineInput: mov word [D0], MAX_CHAT_LINE_LENGTH + 1 mov esi, [A5] mov ebx, [esi + MenuEntry.string] push ebx mov dword [A0], ebx mov word [inputingTextOk], 0 calla InputText pop ebx mov eax, [D0] test ax, ax jnz .out mov eax, ebx call AddChatLine .out: mov eax, ebx mov [eax], byte 0 retn EnterInputTextHook: cmp dword [A0], ChatLineInput ; is this our entry? jnz .out cmp [lastKey], word 0x1c ; yes! check if enter was pressed jnz .out or eax, -1 ; bingo! set eax to -1 as if fire was pressed retn .out: mov ax, [shortFire] or ax, ax retn InputTextOnEnterPatch: calla EnterInputTextHook nop nop InputTextOnEnterPatchSize equ $ - InputTextOnEnterPatch ; in: ; esi -> data to patch with ; PatchMenuProc: mov edi, MenuProc + 0x114 push byte InputTextOnEnterPatchSize pop ecx cld rep movsb retn EnableInputTextOnEnter: mov esi, InputTextOnEnterPatch jmp PatchMenuProc DisableInputTextOnEnter: mov esi, EnterInputTextHook.out jmp PatchMenuProc ; choose this players team for a multiplayer game global ChooseTeam ChooseTeam: xor eax, eax mov [A1], eax ; no need for on select function inc eax mov [D2], eax ; show club teams mov [D3], eax ; show national teams mov [D4], eax ; show original custom teams movstr dword [A0], ""CHOOSE MULTIPLAYER GAME TEAM"" mov byte [choosingTeam], 1 calla ChooseTeamsDialog mov byte [choosingTeam], 0 mov eax, [A0] mov edx, [D0] ; selected team country number or -1 if aborted cmp dx, -1 jz .out mov edx, [eax] ; selected team unique number call SetTeam .out: retn ; fire triggered on num. substitutes ChangeNumSubstitutesAndNotify: call GetMaxSubstitutes test eax, eax jz .out mov ebx, eax ; ebx = max substitutes call GetNumSubstitutes inc eax cmp ebx, eax jnb .in_range mov eax, 1 ; num. substitutes = 1 if it's bigger than max .in_range: call SetNumSubstitutes call SetNumSubstitutesText calla DrawMenuItem .out: jmp NotifyOptionsChange ; fire triggered on max substitutes ChangeMaxSubstitutesAndNotify: call GetMaxSubstitutes inc eax cmp eax, 5 jbe .in_range xor eax, eax call SetMaxSubstitutes .in_range: cmp eax, 1 ja .skip_fixing_subs call SetNumSubstitutes .skip_fixing_subs: call SetMaxSubstitutes call SetNumSubstitutesText calla DrawMenuItem mov dword [D0], gameLobbyMenu_optNumSubstitutes calla CalcMenuEntryAddress mov eax, [A0] mov [A5], eax calla DrawMenuItem jmp NotifyOptionsChange SetSkipFramesText: push byte gameLobbyMenu_optSkipFrames pop dword [D0] calla CalcMenuEntryAddress mov esi, [A0] call GetSkipFrames mov [esi + MenuEntry.number], eax retn SetNumSubstitutesText: push byte gameLobbyMenu_optNumSubstitutes pop dword [D0] calla CalcMenuEntryAddress mov esi, [A0] mov eax, [esi + MenuEntry.string] mov dword [A1], eax call GetNumSubstitutes mov [D0], eax calla Int2Ascii push byte gameLobbyMenu_optMaxSubstitutes pop dword [D0] calla CalcMenuEntryAddress mov esi, [A0] mov eax, [esi + MenuEntry.string] mov dword [A1], eax call GetMaxSubstitutes mov [D0], eax jmpa Int2Ascii ToggleSaveAutoReplays: xor word [autoSaveReplays], 1 jmpa DrawMenuItem ; called before creating Multiplayer menu extern GetMPOptions, EnableAdditionalInputKeys, DisableAdditionalInputKeys PatchMenu: call EnableInputTextOnEnter call EnableAdditionalInputKeys mov byte [ChangePitchType + 0x19], 0xff ; eliminate seasonal retn ; deinitialization of Multiplayer menu UnpatchMenu: call DisableInputTextOnEnter call DisableAdditionalInputKeys mov byte [ChangePitchType + 0x19], 0xfe ; restore pitch type table retn ; see if we can enable start game button GameLobbyBeforeDraw: call SaveCurrentGLEntry call SetNumSubstitutesText call SetSkipFramesText call CanGameStart neg eax sbb eax, eax push eax and eax, 5 lea ecx, [eax + 9] and eax, 1 shl eax, 13 mov edi, eax mov word [D0], gameLobbyMenu_startGame calla CalcMenuEntryAddress mov esi, [A0] pop eax not eax mov word [esi + MenuEntry.isDisabled], ax ; disable/enable start game button mov [esi + MenuEntry.backAndFrameColor], cx mov [esi + MenuEntry.stringFlags], di test eax, eax jz .fix_chat_input_line mov edi, [A6] ; check if start game is selected while we disable it mov eax, [edi + Menu.currentEntry] cmp eax, esi jnz .fix_chat_input_line push byte gameLobbyMenu_cancelGame ; move focus to cancel game button pop dword [D0] calla SetCurrentEntry .fix_chat_input_line: cmp word [inputingTextOk], 0 jnz .chat_input_ok push byte gameLobbyMenu_chatInput pop dword [D0] calla CalcMenuEntryAddress mov esi, [A0] mov eax, [esi + MenuEntry.string] mov [eax], byte 0 ; prevent ""STDMENUTEXT"" from showing up after choose team menu .chat_input_ok: call DisableServerOnlyEntries retn UpdateReadyState: mov esi, [A5] mov [esi + MenuEntry.sprite2], word 208 ; assume ready mov [esi + MenuEntry.backAndFrameColor], word 14 ; check, background color = green xor eax, eax mov al, [isReady] test eax, eax jnz .out inc word [esi + MenuEntry.sprite2] ; uncheck, background color = red mov [esi + MenuEntry.backAndFrameColor], word 10 .out: retn extern SetPlayerReadyState ToggleReadyState: xor byte [isReady], 1 movzx eax, byte [isReady] call SetPlayerReadyState jmp UpdateReadyState ; ExitGameLobbyMenu ; ; Show confirmation dialog when leaving multiplayer game. If we're called from direct mode ; exit SWOS if player chooses so, otherwise go back to previous menu. ; extern DisbandGame ExitGameLobbyMenu: call GetDirectGameName mov al, [eax] test al, al movstr dword [A0], ""EXIT GAME"" mov dword [A1], exitGamePrompt push eax jnz .show_prompt cmp byte [weAreTheServer], 0 movstr dword [A0], ""DISBAND MULTIPLAYER ROOM"" mov dword [A1], disbandGamePrompt jnz .show_prompt movstr dword [A0], ""LEAVE MULTIPLAYER GAME"" mov dword [A1], leaveGamePrompt .show_prompt: mov dword [A2], aContinue mov dword [A3], aAbort calla DoContinueAbortMenu pop ebx jnz .out call DisbandGame ; user is leaving the game, disband in any case test bl, bl jz .back_to_prev_menu call ExitSWOS ; it's direct connect mode, exit SWOS .back_to_prev_menu: calla SetExitMenuFlag ; not direct mode, return to previous menu cmp byte [weAreTheServer], 0 jnz .out call InitJoinGameMenu .out: retn extern SetPlayerOrWatcher ChangePlayerWatcher: xor eax, eax mov ax, [playerOrWatcher] inc eax cmp eax, 2 jb .out xor eax, eax .out: mov [playerOrWatcher], ax call SetPlayerOrWatcher retn ; OnStartGame ; ; Play match was selected in game lobby. Show play match menu for players to ; set up their teams. ; extern SetupTeams OnStartGame: WriteToLog ""Play match selected... going to synchronization..."" mov word [showingCpuTeams], 0 ; just in case mov eax, SyncModalDialogProc mov edx, ShowPlayMatchMenu mov ecx, eax push PlayMatchMenuTimeout call SetupTeams ; let's rock'n'roll retn ; SyncModalDialogProc [called from C++] ; ; Draw modal dialog while player team synchronization is being done. ; SyncModalDialogProc: pushad cmp byte [syncDialogInitialized], 0 jnz .menu_loop mov dword [modalDialogStrTable], syncingPleaseWaitStrTable mov eax, modalDialogInitData call InitModalDialog mov byte [syncDialogInitialized], 1 .menu_loop: call MiniMenuLoop popad retn ; HookFindTeamInCache ; ; in: ; ecx -> get current team function ; ; Patch FindTeamsInCache since it blindly returns team from selectedTeams based on team id. ; That causes horrible problems when both players are using same team. Make it return team of ; player that's currently in control -- callback function will provide us with that. ; Make sure esi is not touched. ; HookFindTeamInCache: mov dword [ReturnCurrentTeam + 1], ecx mov al, [FindTeamInCache] mov [savedFindTeamInCacheBytes], al mov eax, [FindTeamInCache + 1] mov [savedFindTeamInCacheBytes + 1], eax mov byte [FindTeamInCache], 0xe9 mov eax, ReturnCurrentTeam - 5 mov ebx, FindTeamInCache sub eax, ebx mov [FindTeamInCache + 1], eax retn ; UnhookFindTeamInCache ; ; Return FindTeamInCache to its original state (since it won't work like this ; during the menus). ; UnhookFindTeamInCache: mov al, [savedFindTeamInCacheBytes] mov [FindTeamInCache], al mov eax, [savedFindTeamInCacheBytes + 1] mov [FindTeamInCache + 1], eax retn ; ReturnCurrentTeam ; ; Run in place of FindTeamInCache, and always return team of the controlling player ; with a help of a patched in callback. ; ReturnCurrentTeam: db 0xb8, 0x90, 0x90, 0x90, 0x90 call eax ; it will only ever return 0 or 1 mov word [D0], ax neg eax and eax, TEAM_SIZE lea eax, [eax + g_selectedTeams] mov [A0], eax mov word [D1], 0 xor eax, eax retn ; ShowPlayMatchMenu [called from C++] ; ; in: ; eax -> team1 ; edx -> team2 ; ecx -> get current team function ; ; Called when we're entering menu for players to set up their teams after successful ; synchronization. Do all the necessary patching of play match menu for multiplayer to work. ; extern lastFireState ShowPlayMatchMenu: pushad mov byte [lastFireState], 0 mov byte [disabledInputCycles], -1 ; signal to ask keys from network mov word [player2ClearFlag], -1 ; block player2 input mov word [player1ClearFlag], 0 ; just in case mov esi, playMatchMenu mov dword [esi + Menu.afterDraw], FixPlayMatchMenuAfterDraw mov dword [esi + Menu.onDraw], FixPlayMatchMenu mov dword [esi + 0x134], HookPlayMatchSelected mov dword [esi + 0x10a], HookExitPlayMatch mov byte [eax + 4], 2 mov byte [edx + 4], 2 ; hopefully ""COACH"" won't show up anymore mov [A1], eax mov [A2], edx %ifdef DEBUG lea eax, [eax + 5] lea edx, [edx + 5] WriteToLog ""Left team is %s, right team is %s"", eax, edx %endif call HookFindTeamInCache movzx eax, byte [g_joyKbdWord] push byte 1 cmp al, convertControlsTableLen pop ebx jae .set_controls mov ebx, eax .set_controls: mov al, [g_joyKbdWord] ; we used to save g_joyKbdWord by push/pop but in case of network mov [savedJoyKbdWord], al ; error stack might get chopped off, so this is safer xchg al, [convertControlsTable + ebx] mov [g_joyKbdWord], al WriteToLog ""g_joyKbdWord set to %d for menus."", eax mov byte [syncDialogInitialized], 0 ; we'll need this later calla InitAndPlayGame call UnpatchAfterSettingTeams .out: popad retn ; UnpatchAfterSettingTeams ; ; Clean up after returning from play match menu. ; global UnpatchAfterSettingTeams UnpatchAfterSettingTeams: mov esi, playMatchMenu mov dword [esi + 0x10a], ExitPlayMatch mov dword [esi + 0x134], PlayMatchSelected mov dword [esi + Menu.afterDraw], PlayMatchAfterDraw mov dword [esi + Menu.onDraw], 0 mov byte [disabledInputCycles], 0 mov word [player2ClearFlag], 0 mov word [keyCount], 0 mov al, [savedJoyKbdWord] mov [g_joyKbdWord], al jmp UnhookFindTeamInCache disabledPlayMatchMenuEntries: db 6, 7, 10, -1 ; player, view opponent, edit tactics ; FixPlayMatchMenuAfterDraw/FixPlayMatchMenu ; ; Make necessary changes on play match menu to accommodate multiplayer mode. ; Executing as on draw menu proc, and also on after draw to negate changes done ; by SWOS. ; FixPlayMatchMenuAfterDraw: calla PlayMatchAfterDraw ; let it do it's thing first FixPlayMatchMenu: mov dword [player1ClearFlag], 0xffff0000 ; keep player 1 clear player 2 set mov esi, disabledPlayMatchMenuEntries .next: xor eax, eax lodsb cmp al, -1 jz .out mov word [D0], ax calla CalcMenuEntryAddress mov edi, [A0] mov word [edi + MenuEntry.isDisabled], 1 mov word [edi + MenuEntry.backAndFrameColor], 9 jmp .next .out: retn ; PlayMatchMenuTimeout [called from C++] ; ; in: ; eax - if true, player that timed out is the server ; ; Called when a timeout occurs while players are setting up their teams (we're in ; play match menu). Depending if timed out player is the server we have two options: ; - if the server is down, go to multiplayer menu, try finding some new games to join ; - if the server is still up, try going back to lobby ; PlayMatchMenuTimeout: pushad push eax call UnpatchAfterSettingTeams ; must unpatch first since GetCurrentPlayerTeamIndex() might get called movstr dword [A0], ""A PLAYER DROPPED"" calla ShowErrorMenu call ExitIfInDirectMode pop eax test eax, eax jz .back_to_lobby mov eax, joinGameMenu xor edx, edx call ReturnToMenu call InitJoinGameMenu calla ExitPlayMatch jmp short .out .back_to_lobby: call ReturnToGameLobbyAfterTheGame .out: popad retn ; HookPlayMatchSelected ; ; Called when player finishes setting up team and presses play match button. ; Notifies network to go to next state. Relies on SwitchToNextControllingState to ; patch main loop and control status procs to call our hooks. ; extern SwitchToNextControllingState HookPlayMatchSelected: mov byte [lastFireState], 0 mov word [g_joy1Status], 0 mov eax, StartTheGameCallback call SwitchToNextControllingState ; returns zero if we can't start the game yet test eax, eax jnz .continue retn .continue: cmp eax, 1 mov byte [pl1Fire], 1 ; must set these, as they will be used to determine mov byte [pl2Fire], 0 ; player numbers in teams later jz StartTheGameCallback.out StartTheGameCallback: mov byte [pl1Fire], 0 mov byte [pl2Fire], 1 .out: jmpa PlayMatchSelected ; HookExitPlayMatch ; ; Patched in place of on exit play match menu function. Clean up everything then ; proceed as normal. ; extern GoBackToLobby HookExitPlayMatch: call ReturnToGameLobbyMenu jmpa ExitPlayMatch ; ReturnToGameLobbyMenu ; ; Notifies the network that we're leaving play match menu, so it can go back to lobby state. ; Unpatches main loop and control status procs. ; ReturnToGameLobbyMenu: mov ebx, gameLobbyMenu call GoBackToLobby call GetPreviousMenu cmp eax, ebx jz .out mov eax, ebx ; we are called from something that isn't game lobby menu xor edx, edx call ReturnToMenu ; make sure we return to game lobby mov word [menuFade], 0 mov word [contAbortResult], 1 ; abort the possible prompt mov byte [choosingTeam], 0 call UnpatchAfterSettingTeams ; stack will be chopped off, we gotta run this manually .out: jmpa ExitChooseTeams section .data aJoinGame: db ""JOIN GAME"", 0 disbandGamePrompt: db 2 db ""CREATED MULTIPLAYER GAME"", 0 db ""IS ABOUT TO BE DISBANDED"", 0 leaveGamePrompt: db 2 db ""YOU ARE ABOUT TO LEAVE"", 0 db ""MULTIPLAYER GAME"", 0 exitGamePrompt: db 2 db ""YOU ARE ABOUT TO CLOSE"", 0 db ""SWOS AND GO BACK TO OS"", 0 aConnectionRefused: db ""CONNECTION REFUSED:"", 0 align 4 playerWatcherStrTable: dd playerOrWatcher dw 0 dd aPlayer_0 dd watcherStr watcherStr: db ""WATCHER"", 0 align 4 autoSaveReplaysTable: dd autoSaveReplays dw 0 dd aOff dd aOn modalDialogInitData: db 12 ; show OK button: OFF, show sprite(0), animations: ON, loop: ON db 6 ; animation delay dw 113 ; start sprite dw 122 ; end sprite dw 32 ; sprite width dw 8 ; sprite height modalDialogStrTable: dd connectingPleaseWaitStrTable errorModalDialogInitData: db 7 ; show OK button ON, show bitmap(1), animations: ON, loop: OFF db 70 ; animation delay dd playerIconErrorAnimTable dw 11 ; sprite width dw 14 ; sprite height dd failedToConnectStrTable serverErrorMessageStrTable: dd 2 dd aConnectionRefused dd serverErrorMessage aPleaseWait: db ""PLEASE WAIT"", 0 align 4 connectingPleaseWaitStrTable: dd 2 declareStr ""CONNECTING..."" dd aPleaseWait syncingPleaseWaitStrTable: dd 2 declareStr ""SYNCHRONIZING..."" dd aPleaseWait failedToConnectStrTable: db 1 db ""FAILED TO CONNECT"", 0 align 4 playerIconErrorAnimTable: dd playerIconError1 dd playerIconError2 dd 0 aChooseTeam: db ""CHOOSE TEAM..."", 0 global aTeamNotChosen aTeamNotChosen: db ""(TEAM NOT CHOSEN)"", 0 ; convert g_joyKbdWord values to only keyboard/joypad to enforce Player1StatusProc to read ; joypad too in case of mixed controls (Player2StatusProc won't be called and it's task is ; to read values for player on joypad in case of mixed controls) align 4 convertControlsTable: db 1, 1, 2, 2, 1, 2 convertControlsTableLen equ $ - convertControlsTable playerIconError1: incbin ""../bitmap/spr0415.bp"" playerIconError2: incbin ""../bitmap/spr0416.bp"" section .bss align 4, resb 1 gameLobbySelectedEntry: resb 4 playerOrWatcher: resb 2 isReady: resb 1 lastModalState: resb 1 autoSaveReplays: resb 2 prevRefreshDisabled: resb 2 weAreTheServer: resb 1 choosingTeam: resb 1 serverErrorMessage: resb 32 serverErrorMessageLen equ $ - serverErrorMessage options: resb MP_Options_size syncDialogInitialized: resb 1 mainLoopRan: resb 1 savedJoyKbdWord: resb 1 savedFindTeamInCacheBytes: resb 5 ",16249,True,3206.6016662711563,median " _hello: file format elf32-i386 Disassembly of section .text: 00000000
: #include ""types.h"" #include ""user.h"" int main(){ 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp printf(1, ""Hello World \\n""); 11: 83 ec 08 sub $0x8,%esp 14: 68 84 07 00 00 push $0x784 19: 6a 01 push $0x1 1b: e8 b8 03 00 00 call 3d8 20: 83 c4 10 add $0x10,%esp exit(); 23: e8 3e 02 00 00 call 266 00000028 : 28: 55 push %ebp 29: 89 e5 mov %esp,%ebp 2b: 57 push %edi 2c: 53 push %ebx 2d: 8b 4d 08 mov 0x8(%ebp),%ecx 30: 8b 55 10 mov 0x10(%ebp),%edx 33: 8b 45 0c mov 0xc(%ebp),%eax 36: 89 cb mov %ecx,%ebx 38: 89 df mov %ebx,%edi 3a: 89 d1 mov %edx,%ecx 3c: fc cld 3d: f3 aa rep stos %al,%es:(%edi) 3f: 89 ca mov %ecx,%edx 41: 89 fb mov %edi,%ebx 43: 89 5d 08 mov %ebx,0x8(%ebp) 46: 89 55 10 mov %edx,0x10(%ebp) 49: 5b pop %ebx 4a: 5f pop %edi 4b: 5d pop %ebp 4c: c3 ret 0000004d : 4d: 55 push %ebp 4e: 89 e5 mov %esp,%ebp 50: 83 ec 10 sub $0x10,%esp 53: 8b 45 08 mov 0x8(%ebp),%eax 56: 89 45 fc mov %eax,-0x4(%ebp) 59: 90 nop 5a: 8b 45 08 mov 0x8(%ebp),%eax 5d: 8d 50 01 lea 0x1(%eax),%edx 60: 89 55 08 mov %edx,0x8(%ebp) 63: 8b 55 0c mov 0xc(%ebp),%edx 66: 8d 4a 01 lea 0x1(%edx),%ecx 69: 89 4d 0c mov %ecx,0xc(%ebp) 6c: 8a 12 mov (%edx),%dl 6e: 88 10 mov %dl,(%eax) 70: 8a 00 mov (%eax),%al 72: 84 c0 test %al,%al 74: 75 e4 jne 5a 76: 8b 45 fc mov -0x4(%ebp),%eax 79: c9 leave 7a: c3 ret 0000007b : 7b: 55 push %ebp 7c: 89 e5 mov %esp,%ebp 7e: eb 06 jmp 86 80: ff 45 08 incl 0x8(%ebp) 83: ff 45 0c incl 0xc(%ebp) 86: 8b 45 08 mov 0x8(%ebp),%eax 89: 8a 00 mov (%eax),%al 8b: 84 c0 test %al,%al 8d: 74 0e je 9d 8f: 8b 45 08 mov 0x8(%ebp),%eax 92: 8a 10 mov (%eax),%dl 94: 8b 45 0c mov 0xc(%ebp),%eax 97: 8a 00 mov (%eax),%al 99: 38 c2 cmp %al,%dl 9b: 74 e3 je 80 9d: 8b 45 08 mov 0x8(%ebp),%eax a0: 8a 00 mov (%eax),%al a2: 0f b6 d0 movzbl %al,%edx a5: 8b 45 0c mov 0xc(%ebp),%eax a8: 8a 00 mov (%eax),%al aa: 0f b6 c0 movzbl %al,%eax ad: 29 c2 sub %eax,%edx af: 89 d0 mov %edx,%eax b1: 5d pop %ebp b2: c3 ret 000000b3 : b3: 55 push %ebp b4: 89 e5 mov %esp,%ebp b6: 83 ec 10 sub $0x10,%esp b9: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) c0: eb 03 jmp c5 c2: ff 45 fc incl -0x4(%ebp) c5: 8b 55 fc mov -0x4(%ebp),%edx c8: 8b 45 08 mov 0x8(%ebp),%eax cb: 01 d0 add %edx,%eax cd: 8a 00 mov (%eax),%al cf: 84 c0 test %al,%al d1: 75 ef jne c2 d3: 8b 45 fc mov -0x4(%ebp),%eax d6: c9 leave d7: c3 ret 000000d8 : d8: 55 push %ebp d9: 89 e5 mov %esp,%ebp db: 8b 45 10 mov 0x10(%ebp),%eax de: 50 push %eax df: ff 75 0c pushl 0xc(%ebp) e2: ff 75 08 pushl 0x8(%ebp) e5: e8 3e ff ff ff call 28 ea: 83 c4 0c add $0xc,%esp ed: 8b 45 08 mov 0x8(%ebp),%eax f0: c9 leave f1: c3 ret 000000f2 : f2: 55 push %ebp f3: 89 e5 mov %esp,%ebp f5: 83 ec 04 sub $0x4,%esp f8: 8b 45 0c mov 0xc(%ebp),%eax fb: 88 45 fc mov %al,-0x4(%ebp) fe: eb 12 jmp 112 100: 8b 45 08 mov 0x8(%ebp),%eax 103: 8a 00 mov (%eax),%al 105: 3a 45 fc cmp -0x4(%ebp),%al 108: 75 05 jne 10f 10a: 8b 45 08 mov 0x8(%ebp),%eax 10d: eb 11 jmp 120 10f: ff 45 08 incl 0x8(%ebp) 112: 8b 45 08 mov 0x8(%ebp),%eax 115: 8a 00 mov (%eax),%al 117: 84 c0 test %al,%al 119: 75 e5 jne 100 11b: b8 00 00 00 00 mov $0x0,%eax 120: c9 leave 121: c3 ret 00000122 : 122: 55 push %ebp 123: 89 e5 mov %esp,%ebp 125: 83 ec 18 sub $0x18,%esp 128: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 12f: eb 41 jmp 172 131: 83 ec 04 sub $0x4,%esp 134: 6a 01 push $0x1 136: 8d 45 ef lea -0x11(%ebp),%eax 139: 50 push %eax 13a: 6a 00 push $0x0 13c: e8 3d 01 00 00 call 27e 141: 83 c4 10 add $0x10,%esp 144: 89 45 f0 mov %eax,-0x10(%ebp) 147: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 14b: 7f 02 jg 14f 14d: eb 2c jmp 17b 14f: 8b 45 f4 mov -0xc(%ebp),%eax 152: 8d 50 01 lea 0x1(%eax),%edx 155: 89 55 f4 mov %edx,-0xc(%ebp) 158: 89 c2 mov %eax,%edx 15a: 8b 45 08 mov 0x8(%ebp),%eax 15d: 01 c2 add %eax,%edx 15f: 8a 45 ef mov -0x11(%ebp),%al 162: 88 02 mov %al,(%edx) 164: 8a 45 ef mov -0x11(%ebp),%al 167: 3c 0a cmp $0xa,%al 169: 74 10 je 17b 16b: 8a 45 ef mov -0x11(%ebp),%al 16e: 3c 0d cmp $0xd,%al 170: 74 09 je 17b 172: 8b 45 f4 mov -0xc(%ebp),%eax 175: 40 inc %eax 176: 3b 45 0c cmp 0xc(%ebp),%eax 179: 7c b6 jl 131 17b: 8b 55 f4 mov -0xc(%ebp),%edx 17e: 8b 45 08 mov 0x8(%ebp),%eax 181: 01 d0 add %edx,%eax 183: c6 00 00 movb $0x0,(%eax) 186: 8b 45 08 mov 0x8(%ebp),%eax 189: c9 leave 18a: c3 ret 0000018b : 18b: 55 push %ebp 18c: 89 e5 mov %esp,%ebp 18e: 83 ec 18 sub $0x18,%esp 191: 83 ec 08 sub $0x8,%esp 194: 6a 00 push $0x0 196: ff 75 08 pushl 0x8(%ebp) 199: e8 08 01 00 00 call 2a6 19e: 83 c4 10 add $0x10,%esp 1a1: 89 45 f4 mov %eax,-0xc(%ebp) 1a4: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 1a8: 79 07 jns 1b1 1aa: b8 ff ff ff ff mov $0xffffffff,%eax 1af: eb 25 jmp 1d6 1b1: 83 ec 08 sub $0x8,%esp 1b4: ff 75 0c pushl 0xc(%ebp) 1b7: ff 75 f4 pushl -0xc(%ebp) 1ba: e8 ff 00 00 00 call 2be 1bf: 83 c4 10 add $0x10,%esp 1c2: 89 45 f0 mov %eax,-0x10(%ebp) 1c5: 83 ec 0c sub $0xc,%esp 1c8: ff 75 f4 pushl -0xc(%ebp) 1cb: e8 be 00 00 00 call 28e 1d0: 83 c4 10 add $0x10,%esp 1d3: 8b 45 f0 mov -0x10(%ebp),%eax 1d6: c9 leave 1d7: c3 ret 000001d8 : 1d8: 55 push %ebp 1d9: 89 e5 mov %esp,%ebp 1db: 83 ec 10 sub $0x10,%esp 1de: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 1e5: eb 24 jmp 20b 1e7: 8b 55 fc mov -0x4(%ebp),%edx 1ea: 89 d0 mov %edx,%eax 1ec: c1 e0 02 shl $0x2,%eax 1ef: 01 d0 add %edx,%eax 1f1: 01 c0 add %eax,%eax 1f3: 89 c1 mov %eax,%ecx 1f5: 8b 45 08 mov 0x8(%ebp),%eax 1f8: 8d 50 01 lea 0x1(%eax),%edx 1fb: 89 55 08 mov %edx,0x8(%ebp) 1fe: 8a 00 mov (%eax),%al 200: 0f be c0 movsbl %al,%eax 203: 01 c8 add %ecx,%eax 205: 83 e8 30 sub $0x30,%eax 208: 89 45 fc mov %eax,-0x4(%ebp) 20b: 8b 45 08 mov 0x8(%ebp),%eax 20e: 8a 00 mov (%eax),%al 210: 3c 2f cmp $0x2f,%al 212: 7e 09 jle 21d 214: 8b 45 08 mov 0x8(%ebp),%eax 217: 8a 00 mov (%eax),%al 219: 3c 39 cmp $0x39,%al 21b: 7e ca jle 1e7 21d: 8b 45 fc mov -0x4(%ebp),%eax 220: c9 leave 221: c3 ret 00000222 : 222: 55 push %ebp 223: 89 e5 mov %esp,%ebp 225: 83 ec 10 sub $0x10,%esp 228: 8b 45 08 mov 0x8(%ebp),%eax 22b: 89 45 fc mov %eax,-0x4(%ebp) 22e: 8b 45 0c mov 0xc(%ebp),%eax 231: 89 45 f8 mov %eax,-0x8(%ebp) 234: eb 16 jmp 24c 236: 8b 45 fc mov -0x4(%ebp),%eax 239: 8d 50 01 lea 0x1(%eax),%edx 23c: 89 55 fc mov %edx,-0x4(%ebp) 23f: 8b 55 f8 mov -0x8(%ebp),%edx 242: 8d 4a 01 lea 0x1(%edx),%ecx 245: 89 4d f8 mov %ecx,-0x8(%ebp) 248: 8a 12 mov (%edx),%dl 24a: 88 10 mov %dl,(%eax) 24c: 8b 45 10 mov 0x10(%ebp),%eax 24f: 8d 50 ff lea -0x1(%eax),%edx 252: 89 55 10 mov %edx,0x10(%ebp) 255: 85 c0 test %eax,%eax 257: 7f dd jg 236 259: 8b 45 08 mov 0x8(%ebp),%eax 25c: c9 leave 25d: c3 ret 0000025e : 25e: b8 01 00 00 00 mov $0x1,%eax 263: cd 40 int $0x40 265: c3 ret 00000266 : 266: b8 02 00 00 00 mov $0x2,%eax 26b: cd 40 int $0x40 26d: c3 ret 0000026e : 26e: b8 03 00 00 00 mov $0x3,%eax 273: cd 40 int $0x40 275: c3 ret 00000276 : 276: b8 04 00 00 00 mov $0x4,%eax 27b: cd 40 int $0x40 27d: c3 ret 0000027e : 27e: b8 05 00 00 00 mov $0x5,%eax 283: cd 40 int $0x40 285: c3 ret 00000286 : 286: b8 10 00 00 00 mov $0x10,%eax 28b: cd 40 int $0x40 28d: c3 ret 0000028e : 28e: b8 15 00 00 00 mov $0x15,%eax 293: cd 40 int $0x40 295: c3 ret 00000296 : 296: b8 06 00 00 00 mov $0x6,%eax 29b: cd 40 int $0x40 29d: c3 ret 0000029e : 29e: b8 07 00 00 00 mov $0x7,%eax 2a3: cd 40 int $0x40 2a5: c3 ret 000002a6 : 2a6: b8 0f 00 00 00 mov $0xf,%eax 2ab: cd 40 int $0x40 2ad: c3 ret 000002ae : 2ae: b8 11 00 00 00 mov $0x11,%eax 2b3: cd 40 int $0x40 2b5: c3 ret 000002b6 : 2b6: b8 12 00 00 00 mov $0x12,%eax 2bb: cd 40 int $0x40 2bd: c3 ret 000002be : 2be: b8 08 00 00 00 mov $0x8,%eax 2c3: cd 40 int $0x40 2c5: c3 ret 000002c6 : 2c6: b8 13 00 00 00 mov $0x13,%eax 2cb: cd 40 int $0x40 2cd: c3 ret 000002ce : 2ce: b8 14 00 00 00 mov $0x14,%eax 2d3: cd 40 int $0x40 2d5: c3 ret 000002d6 : 2d6: b8 09 00 00 00 mov $0x9,%eax 2db: cd 40 int $0x40 2dd: c3 ret 000002de : 2de: b8 0a 00 00 00 mov $0xa,%eax 2e3: cd 40 int $0x40 2e5: c3 ret 000002e6 : 2e6: b8 0b 00 00 00 mov $0xb,%eax 2eb: cd 40 int $0x40 2ed: c3 ret 000002ee : 2ee: b8 0c 00 00 00 mov $0xc,%eax 2f3: cd 40 int $0x40 2f5: c3 ret 000002f6 : 2f6: b8 0d 00 00 00 mov $0xd,%eax 2fb: cd 40 int $0x40 2fd: c3 ret 000002fe : 2fe: b8 0e 00 00 00 mov $0xe,%eax 303: cd 40 int $0x40 305: c3 ret 00000306 : 306: 55 push %ebp 307: 89 e5 mov %esp,%ebp 309: 83 ec 18 sub $0x18,%esp 30c: 8b 45 0c mov 0xc(%ebp),%eax 30f: 88 45 f4 mov %al,-0xc(%ebp) 312: 83 ec 04 sub $0x4,%esp 315: 6a 01 push $0x1 317: 8d 45 f4 lea -0xc(%ebp),%eax 31a: 50 push %eax 31b: ff 75 08 pushl 0x8(%ebp) 31e: e8 63 ff ff ff call 286 323: 83 c4 10 add $0x10,%esp 326: c9 leave 327: c3 ret 00000328 : 328: 55 push %ebp 329: 89 e5 mov %esp,%ebp 32b: 53 push %ebx 32c: 83 ec 24 sub $0x24,%esp 32f: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 336: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 33a: 74 17 je 353 33c: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 340: 79 11 jns 353 342: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) 349: 8b 45 0c mov 0xc(%ebp),%eax 34c: f7 d8 neg %eax 34e: 89 45 ec mov %eax,-0x14(%ebp) 351: eb 06 jmp 359 353: 8b 45 0c mov 0xc(%ebp),%eax 356: 89 45 ec mov %eax,-0x14(%ebp) 359: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 360: 8b 4d f4 mov -0xc(%ebp),%ecx 363: 8d 41 01 lea 0x1(%ecx),%eax 366: 89 45 f4 mov %eax,-0xc(%ebp) 369: 8b 5d 10 mov 0x10(%ebp),%ebx 36c: 8b 45 ec mov -0x14(%ebp),%eax 36f: ba 00 00 00 00 mov $0x0,%edx 374: f7 f3 div %ebx 376: 89 d0 mov %edx,%eax 378: 8a 80 e4 09 00 00 mov 0x9e4(%eax),%al 37e: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) 382: 8b 5d 10 mov 0x10(%ebp),%ebx 385: 8b 45 ec mov -0x14(%ebp),%eax 388: ba 00 00 00 00 mov $0x0,%edx 38d: f7 f3 div %ebx 38f: 89 45 ec mov %eax,-0x14(%ebp) 392: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 396: 75 c8 jne 360 398: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 39c: 74 0e je 3ac 39e: 8b 45 f4 mov -0xc(%ebp),%eax 3a1: 8d 50 01 lea 0x1(%eax),%edx 3a4: 89 55 f4 mov %edx,-0xc(%ebp) 3a7: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) 3ac: eb 1c jmp 3ca 3ae: 8d 55 dc lea -0x24(%ebp),%edx 3b1: 8b 45 f4 mov -0xc(%ebp),%eax 3b4: 01 d0 add %edx,%eax 3b6: 8a 00 mov (%eax),%al 3b8: 0f be c0 movsbl %al,%eax 3bb: 83 ec 08 sub $0x8,%esp 3be: 50 push %eax 3bf: ff 75 08 pushl 0x8(%ebp) 3c2: e8 3f ff ff ff call 306 3c7: 83 c4 10 add $0x10,%esp 3ca: ff 4d f4 decl -0xc(%ebp) 3cd: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 3d1: 79 db jns 3ae 3d3: 8b 5d fc mov -0x4(%ebp),%ebx 3d6: c9 leave 3d7: c3 ret 000003d8 : 3d8: 55 push %ebp 3d9: 89 e5 mov %esp,%ebp 3db: 83 ec 28 sub $0x28,%esp 3de: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 3e5: 8d 45 0c lea 0xc(%ebp),%eax 3e8: 83 c0 04 add $0x4,%eax 3eb: 89 45 e8 mov %eax,-0x18(%ebp) 3ee: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 3f5: e9 54 01 00 00 jmp 54e 3fa: 8b 55 0c mov 0xc(%ebp),%edx 3fd: 8b 45 f0 mov -0x10(%ebp),%eax 400: 01 d0 add %edx,%eax 402: 8a 00 mov (%eax),%al 404: 0f be c0 movsbl %al,%eax 407: 25 ff 00 00 00 and $0xff,%eax 40c: 89 45 e4 mov %eax,-0x1c(%ebp) 40f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 413: 75 2c jne 441 415: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 419: 75 0c jne 427 41b: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 422: e9 24 01 00 00 jmp 54b 427: 8b 45 e4 mov -0x1c(%ebp),%eax 42a: 0f be c0 movsbl %al,%eax 42d: 83 ec 08 sub $0x8,%esp 430: 50 push %eax 431: ff 75 08 pushl 0x8(%ebp) 434: e8 cd fe ff ff call 306 439: 83 c4 10 add $0x10,%esp 43c: e9 0a 01 00 00 jmp 54b 441: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 445: 0f 85 00 01 00 00 jne 54b 44b: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 44f: 75 1e jne 46f 451: 8b 45 e8 mov -0x18(%ebp),%eax 454: 8b 00 mov (%eax),%eax 456: 6a 01 push $0x1 458: 6a 0a push $0xa 45a: 50 push %eax 45b: ff 75 08 pushl 0x8(%ebp) 45e: e8 c5 fe ff ff call 328 463: 83 c4 10 add $0x10,%esp 466: 83 45 e8 04 addl $0x4,-0x18(%ebp) 46a: e9 d5 00 00 00 jmp 544 46f: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 473: 74 06 je 47b 475: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 479: 75 1e jne 499 47b: 8b 45 e8 mov -0x18(%ebp),%eax 47e: 8b 00 mov (%eax),%eax 480: 6a 00 push $0x0 482: 6a 10 push $0x10 484: 50 push %eax 485: ff 75 08 pushl 0x8(%ebp) 488: e8 9b fe ff ff call 328 48d: 83 c4 10 add $0x10,%esp 490: 83 45 e8 04 addl $0x4,-0x18(%ebp) 494: e9 ab 00 00 00 jmp 544 499: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 49d: 75 40 jne 4df 49f: 8b 45 e8 mov -0x18(%ebp),%eax 4a2: 8b 00 mov (%eax),%eax 4a4: 89 45 f4 mov %eax,-0xc(%ebp) 4a7: 83 45 e8 04 addl $0x4,-0x18(%ebp) 4ab: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 4af: 75 07 jne 4b8 4b1: c7 45 f4 92 07 00 00 movl $0x792,-0xc(%ebp) 4b8: eb 1a jmp 4d4 4ba: 8b 45 f4 mov -0xc(%ebp),%eax 4bd: 8a 00 mov (%eax),%al 4bf: 0f be c0 movsbl %al,%eax 4c2: 83 ec 08 sub $0x8,%esp 4c5: 50 push %eax 4c6: ff 75 08 pushl 0x8(%ebp) 4c9: e8 38 fe ff ff call 306 4ce: 83 c4 10 add $0x10,%esp 4d1: ff 45 f4 incl -0xc(%ebp) 4d4: 8b 45 f4 mov -0xc(%ebp),%eax 4d7: 8a 00 mov (%eax),%al 4d9: 84 c0 test %al,%al 4db: 75 dd jne 4ba 4dd: eb 65 jmp 544 4df: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 4e3: 75 1d jne 502 4e5: 8b 45 e8 mov -0x18(%ebp),%eax 4e8: 8b 00 mov (%eax),%eax 4ea: 0f be c0 movsbl %al,%eax 4ed: 83 ec 08 sub $0x8,%esp 4f0: 50 push %eax 4f1: ff 75 08 pushl 0x8(%ebp) 4f4: e8 0d fe ff ff call 306 4f9: 83 c4 10 add $0x10,%esp 4fc: 83 45 e8 04 addl $0x4,-0x18(%ebp) 500: eb 42 jmp 544 502: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 506: 75 17 jne 51f 508: 8b 45 e4 mov -0x1c(%ebp),%eax 50b: 0f be c0 movsbl %al,%eax 50e: 83 ec 08 sub $0x8,%esp 511: 50 push %eax 512: ff 75 08 pushl 0x8(%ebp) 515: e8 ec fd ff ff call 306 51a: 83 c4 10 add $0x10,%esp 51d: eb 25 jmp 544 51f: 83 ec 08 sub $0x8,%esp 522: 6a 25 push $0x25 524: ff 75 08 pushl 0x8(%ebp) 527: e8 da fd ff ff call 306 52c: 83 c4 10 add $0x10,%esp 52f: 8b 45 e4 mov -0x1c(%ebp),%eax 532: 0f be c0 movsbl %al,%eax 535: 83 ec 08 sub $0x8,%esp 538: 50 push %eax 539: ff 75 08 pushl 0x8(%ebp) 53c: e8 c5 fd ff ff call 306 541: 83 c4 10 add $0x10,%esp 544: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) 54b: ff 45 f0 incl -0x10(%ebp) 54e: 8b 55 0c mov 0xc(%ebp),%edx 551: 8b 45 f0 mov -0x10(%ebp),%eax 554: 01 d0 add %edx,%eax 556: 8a 00 mov (%eax),%al 558: 84 c0 test %al,%al 55a: 0f 85 9a fe ff ff jne 3fa 560: c9 leave 561: c3 ret 00000562 : 562: 55 push %ebp 563: 89 e5 mov %esp,%ebp 565: 83 ec 10 sub $0x10,%esp 568: 8b 45 08 mov 0x8(%ebp),%eax 56b: 83 e8 08 sub $0x8,%eax 56e: 89 45 f8 mov %eax,-0x8(%ebp) 571: a1 00 0a 00 00 mov 0xa00,%eax 576: 89 45 fc mov %eax,-0x4(%ebp) 579: eb 24 jmp 59f 57b: 8b 45 fc mov -0x4(%ebp),%eax 57e: 8b 00 mov (%eax),%eax 580: 3b 45 fc cmp -0x4(%ebp),%eax 583: 77 12 ja 597 585: 8b 45 f8 mov -0x8(%ebp),%eax 588: 3b 45 fc cmp -0x4(%ebp),%eax 58b: 77 24 ja 5b1 58d: 8b 45 fc mov -0x4(%ebp),%eax 590: 8b 00 mov (%eax),%eax 592: 3b 45 f8 cmp -0x8(%ebp),%eax 595: 77 1a ja 5b1 597: 8b 45 fc mov -0x4(%ebp),%eax 59a: 8b 00 mov (%eax),%eax 59c: 89 45 fc mov %eax,-0x4(%ebp) 59f: 8b 45 f8 mov -0x8(%ebp),%eax 5a2: 3b 45 fc cmp -0x4(%ebp),%eax 5a5: 76 d4 jbe 57b 5a7: 8b 45 fc mov -0x4(%ebp),%eax 5aa: 8b 00 mov (%eax),%eax 5ac: 3b 45 f8 cmp -0x8(%ebp),%eax 5af: 76 ca jbe 57b 5b1: 8b 45 f8 mov -0x8(%ebp),%eax 5b4: 8b 40 04 mov 0x4(%eax),%eax 5b7: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 5be: 8b 45 f8 mov -0x8(%ebp),%eax 5c1: 01 c2 add %eax,%edx 5c3: 8b 45 fc mov -0x4(%ebp),%eax 5c6: 8b 00 mov (%eax),%eax 5c8: 39 c2 cmp %eax,%edx 5ca: 75 24 jne 5f0 5cc: 8b 45 f8 mov -0x8(%ebp),%eax 5cf: 8b 50 04 mov 0x4(%eax),%edx 5d2: 8b 45 fc mov -0x4(%ebp),%eax 5d5: 8b 00 mov (%eax),%eax 5d7: 8b 40 04 mov 0x4(%eax),%eax 5da: 01 c2 add %eax,%edx 5dc: 8b 45 f8 mov -0x8(%ebp),%eax 5df: 89 50 04 mov %edx,0x4(%eax) 5e2: 8b 45 fc mov -0x4(%ebp),%eax 5e5: 8b 00 mov (%eax),%eax 5e7: 8b 10 mov (%eax),%edx 5e9: 8b 45 f8 mov -0x8(%ebp),%eax 5ec: 89 10 mov %edx,(%eax) 5ee: eb 0a jmp 5fa 5f0: 8b 45 fc mov -0x4(%ebp),%eax 5f3: 8b 10 mov (%eax),%edx 5f5: 8b 45 f8 mov -0x8(%ebp),%eax 5f8: 89 10 mov %edx,(%eax) 5fa: 8b 45 fc mov -0x4(%ebp),%eax 5fd: 8b 40 04 mov 0x4(%eax),%eax 600: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 607: 8b 45 fc mov -0x4(%ebp),%eax 60a: 01 d0 add %edx,%eax 60c: 3b 45 f8 cmp -0x8(%ebp),%eax 60f: 75 20 jne 631 611: 8b 45 fc mov -0x4(%ebp),%eax 614: 8b 50 04 mov 0x4(%eax),%edx 617: 8b 45 f8 mov -0x8(%ebp),%eax 61a: 8b 40 04 mov 0x4(%eax),%eax 61d: 01 c2 add %eax,%edx 61f: 8b 45 fc mov -0x4(%ebp),%eax 622: 89 50 04 mov %edx,0x4(%eax) 625: 8b 45 f8 mov -0x8(%ebp),%eax 628: 8b 10 mov (%eax),%edx 62a: 8b 45 fc mov -0x4(%ebp),%eax 62d: 89 10 mov %edx,(%eax) 62f: eb 08 jmp 639 631: 8b 45 fc mov -0x4(%ebp),%eax 634: 8b 55 f8 mov -0x8(%ebp),%edx 637: 89 10 mov %edx,(%eax) 639: 8b 45 fc mov -0x4(%ebp),%eax 63c: a3 00 0a 00 00 mov %eax,0xa00 641: c9 leave 642: c3 ret 00000643 : 643: 55 push %ebp 644: 89 e5 mov %esp,%ebp 646: 83 ec 18 sub $0x18,%esp 649: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 650: 77 07 ja 659 652: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) 659: 8b 45 08 mov 0x8(%ebp),%eax 65c: c1 e0 03 shl $0x3,%eax 65f: 83 ec 0c sub $0xc,%esp 662: 50 push %eax 663: e8 86 fc ff ff call 2ee 668: 83 c4 10 add $0x10,%esp 66b: 89 45 f4 mov %eax,-0xc(%ebp) 66e: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 672: 75 07 jne 67b 674: b8 00 00 00 00 mov $0x0,%eax 679: eb 26 jmp 6a1 67b: 8b 45 f4 mov -0xc(%ebp),%eax 67e: 89 45 f0 mov %eax,-0x10(%ebp) 681: 8b 45 f0 mov -0x10(%ebp),%eax 684: 8b 55 08 mov 0x8(%ebp),%edx 687: 89 50 04 mov %edx,0x4(%eax) 68a: 8b 45 f0 mov -0x10(%ebp),%eax 68d: 83 c0 08 add $0x8,%eax 690: 83 ec 0c sub $0xc,%esp 693: 50 push %eax 694: e8 c9 fe ff ff call 562 699: 83 c4 10 add $0x10,%esp 69c: a1 00 0a 00 00 mov 0xa00,%eax 6a1: c9 leave 6a2: c3 ret 000006a3 : 6a3: 55 push %ebp 6a4: 89 e5 mov %esp,%ebp 6a6: 83 ec 18 sub $0x18,%esp 6a9: 8b 45 08 mov 0x8(%ebp),%eax 6ac: 83 c0 07 add $0x7,%eax 6af: c1 e8 03 shr $0x3,%eax 6b2: 40 inc %eax 6b3: 89 45 ec mov %eax,-0x14(%ebp) 6b6: a1 00 0a 00 00 mov 0xa00,%eax 6bb: 89 45 f0 mov %eax,-0x10(%ebp) 6be: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 6c2: 75 23 jne 6e7 6c4: c7 45 f0 f8 09 00 00 movl $0x9f8,-0x10(%ebp) 6cb: 8b 45 f0 mov -0x10(%ebp),%eax 6ce: a3 00 0a 00 00 mov %eax,0xa00 6d3: a1 00 0a 00 00 mov 0xa00,%eax 6d8: a3 f8 09 00 00 mov %eax,0x9f8 6dd: c7 05 fc 09 00 00 00 movl $0x0,0x9fc 6e4: 00 00 00 6e7: 8b 45 f0 mov -0x10(%ebp),%eax 6ea: 8b 00 mov (%eax),%eax 6ec: 89 45 f4 mov %eax,-0xc(%ebp) 6ef: 8b 45 f4 mov -0xc(%ebp),%eax 6f2: 8b 40 04 mov 0x4(%eax),%eax 6f5: 3b 45 ec cmp -0x14(%ebp),%eax 6f8: 72 4d jb 747 6fa: 8b 45 f4 mov -0xc(%ebp),%eax 6fd: 8b 40 04 mov 0x4(%eax),%eax 700: 3b 45 ec cmp -0x14(%ebp),%eax 703: 75 0c jne 711 705: 8b 45 f4 mov -0xc(%ebp),%eax 708: 8b 10 mov (%eax),%edx 70a: 8b 45 f0 mov -0x10(%ebp),%eax 70d: 89 10 mov %edx,(%eax) 70f: eb 26 jmp 737 711: 8b 45 f4 mov -0xc(%ebp),%eax 714: 8b 40 04 mov 0x4(%eax),%eax 717: 2b 45 ec sub -0x14(%ebp),%eax 71a: 89 c2 mov %eax,%edx 71c: 8b 45 f4 mov -0xc(%ebp),%eax 71f: 89 50 04 mov %edx,0x4(%eax) 722: 8b 45 f4 mov -0xc(%ebp),%eax 725: 8b 40 04 mov 0x4(%eax),%eax 728: c1 e0 03 shl $0x3,%eax 72b: 01 45 f4 add %eax,-0xc(%ebp) 72e: 8b 45 f4 mov -0xc(%ebp),%eax 731: 8b 55 ec mov -0x14(%ebp),%edx 734: 89 50 04 mov %edx,0x4(%eax) 737: 8b 45 f0 mov -0x10(%ebp),%eax 73a: a3 00 0a 00 00 mov %eax,0xa00 73f: 8b 45 f4 mov -0xc(%ebp),%eax 742: 83 c0 08 add $0x8,%eax 745: eb 3b jmp 782 747: a1 00 0a 00 00 mov 0xa00,%eax 74c: 39 45 f4 cmp %eax,-0xc(%ebp) 74f: 75 1e jne 76f 751: 83 ec 0c sub $0xc,%esp 754: ff 75 ec pushl -0x14(%ebp) 757: e8 e7 fe ff ff call 643 75c: 83 c4 10 add $0x10,%esp 75f: 89 45 f4 mov %eax,-0xc(%ebp) 762: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 766: 75 07 jne 76f 768: b8 00 00 00 00 mov $0x0,%eax 76d: eb 13 jmp 782 76f: 8b 45 f4 mov -0xc(%ebp),%eax 772: 89 45 f0 mov %eax,-0x10(%ebp) 775: 8b 45 f4 mov -0xc(%ebp),%eax 778: 8b 00 mov (%eax),%eax 77a: 89 45 f4 mov %eax,-0xc(%ebp) 77d: e9 6d ff ff ff jmp 6ef 782: c9 leave 783: c3 ret ",16285,True,4353.330149079199,median "#include #include #include #include #include #include #include #include #include #include ""esp_pm.h"" #include ""fft.h"" #include ""DHT12.h"" #include ""WiFi.h"" extern const unsigned char Logodata[25600]; extern const unsigned char error_48[4608]; extern const unsigned char warning_48[4608]; extern const unsigned char icon_ir[4608]; extern const unsigned char icon_ble[4608]; extern const unsigned char icon_wifi[4608]; extern const unsigned char icon_ble_disconnect[4608]; extern const unsigned char ImageData[768]; extern const unsigned char stick1[12960]; extern const unsigned char stick2[12960]; extern const unsigned char stick3[12960]; extern const unsigned char stick4[12960]; extern const unsigned char stick5[12960]; extern const unsigned char stick6[12960]; extern const unsigned char stick7[12960]; extern const unsigned char stick8[12960]; extern const unsigned char stick9[12960]; extern const unsigned char stick10[12960]; extern const unsigned char stick11[12960]; extern const unsigned char stick12[12960]; extern const unsigned char stick13[12960]; extern const unsigned char stick14[12960]; extern const unsigned char stick15[12960]; extern const unsigned char stick16[12960]; extern const unsigned char stick17[12960]; extern const unsigned char stick18[12960]; const unsigned char* Animationptr[18] = { stick1,stick2,stick3,stick4,stick5, stick6,stick7,stick8,stick9,stick10, stick11,stick12,stick13,stick14,stick15, stick16,stick17,stick18 }; typedef struct { double x; double y; double z; } point_3d_t; typedef struct { point_3d_t start_point; point_3d_t end_point; } line_3d_t; typedef struct { double x; double y; } point_2d_t; double r_rand = PI / 180; double r_alpha = 19.47 * PI / 180; double r_gamma = 20.7 * PI / 180; double sin_alpha = sin(19.47 * PI / 180); double cos_alpha = cos(19.47 * PI / 180); double sin_gamma = sin(20.7 * PI / 180); double cos_gamma = cos(20.7 * PI / 180); //#define NUM_LEDS 3 //#define DATA_PIN 32 //CRGB leds[NUM_LEDS]; hw_timer_t *timer = NULL; volatile SemaphoreHandle_t timerSemaphore; portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED; volatile uint8_t TimerCount = 0; bool TestMode = false; TFT_eSprite Disbuff = TFT_eSprite(&M5.Lcd); void IRAM_ATTR onTimer() { portENTER_CRITICAL_ISR(&timerMux); digitalWrite(10, TimerCount % 100 ); TimerCount++; portEXIT_CRITICAL_ISR(&timerMux); } void checkAXPPress() { if( M5.Axp.GetBtnPress()) { ESP.restart(); } } void ErrorMeg(uint8_t code, const char *str, int iconNum, bool modal) { Disbuff.fillRect(0, 0, 160, 80, BLACK); switch(iconNum) { case 0: Disbuff.pushImage(0, 16, 48, 48, (uint16_t *)error_48); Disbuff.drawString(""ERROR"", 55, 10, 2); break; case 1: Disbuff.pushImage(0, 16, 48, 48, (uint16_t *)warning_48); Disbuff.drawString(""WARNING"", 55, 10, 2); break; } Disbuff.setCursor(120, 10); Disbuff.setTextFont(2); Disbuff.printf(""%02X"", code); Disbuff.drawString(""-----------------"", 55, 30, 1); Disbuff.drawString(str, 55, 45, 1); Disbuff.drawString(""check Hardware "", 55, 60, 1); Disbuff.pushSprite(0, 0); if( modal ) { while (1) { M5.update(); delay(10); if( M5.BtnA.wasPressed()||M5.BtnB.wasPressed())break; } } } void ErrorMeg(uint8_t code, const char *str1, const char *str2, int iconNum, bool modal) { Disbuff.fillRect(0, 0, 160, 80, BLACK); switch(iconNum) { case 0: Disbuff.pushImage(0, 16, 48, 48, (uint16_t *)error_48); Disbuff.drawString(""ERROR"", 55, 10, 2); break; case 1: Disbuff.pushImage(0, 16, 48, 48, (uint16_t *)warning_48); Disbuff.drawString(""WARNING"", 55, 10, 2); break; } Disbuff.setCursor(120, 10); Disbuff.setTextFont(2); Disbuff.printf(""%02X"", code); Disbuff.drawString(""-----------------"", 55, 30, 1); Disbuff.drawString(str1, 55, 45, 1); Disbuff.drawString(str2, 55, 60, 1); Disbuff.pushSprite(0, 0); if( modal ) { while (1) { M5.update(); delay(10); if( M5.BtnA.wasPressed()||M5.BtnB.wasPressed())break; } } } #define PIN_CLK 0 #define PIN_DATA 34 bool InitI2SMicroPhone() { esp_err_t err = ESP_OK; i2s_config_t i2s_config = { .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_PDM), .sample_rate = 44100, .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB .channel_format = I2S_CHANNEL_FMT_ALL_RIGHT, .communication_format = I2S_COMM_FORMAT_I2S, .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, .dma_buf_count = 2, .dma_buf_len = 128, }; i2s_pin_config_t pin_config; pin_config.bck_io_num = I2S_PIN_NO_CHANGE; pin_config.ws_io_num = PIN_CLK; pin_config.data_out_num = I2S_PIN_NO_CHANGE; pin_config.data_in_num = PIN_DATA; err += i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); err += i2s_set_pin(I2S_NUM_0, &pin_config); err += i2s_set_clk(I2S_NUM_0, 44100, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_MONO); //i2s_set_clk(0) if (err != ESP_OK) { return false; } else { return true; } } static esp_pm_lock_handle_t rmt_freq_lock; #define RMT_TX_CHANNEL RMT_CHANNEL_0 #define RMT_TX_GPIO_NUM GPIO_NUM_9 #define RMT_CLK_DIV (1) // 80000000 / 1(HZ) rmt_item32_t *tx_buffer = NULL; void ir_tx_callback(rmt_channel_t channel, void *arg) { //static BaseType_t xHigherPriorityTaskWoken = false; if (channel == RMT_TX_CHANNEL) { esp_pm_lock_release(rmt_freq_lock); //xHigherPriorityTaskWoken = pdFALSE; //xSemaphoreGiveFromISR( irTxSem, &xHigherPriorityTaskWoken ); free(tx_buffer); } } bool InitIRTx() { /* rmt_config_t rmt_tx; rmt_tx.rmt_mode = RMT_MODE_TX; rmt_tx.channel = RMT_TX_CHANNEL; rmt_tx.gpio_num = RMT_TX_GPIO_NUM; rmt_tx.mem_block_num = 1; rmt_tx.clk_div = RMT_CLK_DIV; rmt_tx.tx_config.loop_en = false; rmt_tx.tx_config.carrier_duty_percent = 50; rmt_tx.tx_config.carrier_freq_hz = 38000; rmt_tx.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; rmt_tx.tx_config.carrier_en = true; rmt_tx.tx_config.idle_level = RMT_IDLE_LEVEL_HIGH; rmt_tx.tx_config.idle_output_en = true; rmt_config(&rmt_tx); rmt_driver_install(rmt_tx.channel, 0, 0); */ ledcSetup(15,38000,8); ledcAttachPin(9,15); ledcWrite(15,0); return true; } bool ir_uart_tx(const uint8_t *src, uint8_t len, bool wait_tx_done) { /* if(src == NULL || recvFlag == true) { return false; } if (src == NULL) { return false; } #if BAUD == 4800 const rmt_item32_t bit0 = {{{8421, 1, 8421, 1}}}; //Logical 0 const rmt_item32_t bit1 = {{{8421, 0, 8421, 0}}}; //Logical 1 #else const rmt_item32_t bit0 = {{{16842, 1, 16842, 1}}}; //Logical 0 const rmt_item32_t bit1 = {{{16842, 0, 16842, 0}}}; //Logical 1 #endif uint8_t *psrc = (uint8_t *)src; //xSemaphoreTake(irTxSem, portMAX_DELAY); tx_buffer = (rmt_item32_t *)malloc(sizeof(rmt_item32_t) * 10 * len); if (tx_buffer == NULL) { return false; } rmt_item32_t *pdest = tx_buffer; for (uint8_t ptr = 0; ptr < len; ptr++) { pdest->val = bit0.val; pdest++; for (int i = 0; i < 8; i++) { if (*psrc & (0x1 << i)) { pdest->val = bit1.val; } else { pdest->val = bit0.val; } pdest++; } pdest->val = bit1.val; pdest++; psrc++; } esp_pm_lock_acquire(rmt_freq_lock); rmt_write_items(RMT_TX_CHANNEL, tx_buffer, 10 * len, true); free(tx_buffer); */ ledcWrite(15,50); return true; } #define SERVICE_UUID ""1bc68b2a-f3e3-11e9-81b4-2a2ae2dbcce4"" #define CHARACTERISTIC_RX_UUID ""1bc68da0-f3e3-11e9-81b4-2a2ae2dbcce4"" #define CHARACTERISTIC_TX_UUID ""1bc68efe-f3e3-11e9-81b4-2a2ae2dbcce4"" BLEServer *pServer = NULL; BLEService *pService = NULL; BLECharacteristic * pTxCharacteristic; bool deviceConnected = false; bool oldDeviceConnected = false; class MyServerCallbacks: public BLEServerCallbacks { void onConnect(BLEServer* pServer) { deviceConnected = true; }; void onDisconnect(BLEServer* pServer) { deviceConnected = false; } }; uint8_t* data = new uint8_t[128]; class MyCallbacks: public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { data = pCharacteristic->getData(); } }; bool InitBLEServer() { uint64_t chipid = ESP.getEfuseMac(); String blename = ""M5-"" + String((uint32_t)(chipid >> 32), HEX); BLEDevice::init(blename.c_str()); //BLEDevice::setPower(ESP_PWR_LVL_N12); pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); pService = pServer->createService(SERVICE_UUID); pTxCharacteristic = pService->createCharacteristic( CHARACTERISTIC_RX_UUID, BLECharacteristic::PROPERTY_NOTIFY ); pTxCharacteristic->addDescriptor(new BLE2902()); BLECharacteristic * pRxCharacteristic = pService->createCharacteristic( CHARACTERISTIC_TX_UUID, BLECharacteristic::PROPERTY_WRITE ); pRxCharacteristic->setCallbacks(new MyCallbacks()); return true; } void Displaybuff() { if (TestMode) { Disbuff.setTextSize(1); Disbuff.setTextColor(RED); Disbuff.drawString(""Test Mode"", 0, 0, 1); Disbuff.setTextColor(WHITE); } Disbuff.pushSprite(0, 0); } bool checkAXP192() { float temp = M5.Axp.GetTempInAXP192(); if ((temp < 5) || (temp > 90)) { ErrorMeg(0x21, ""AXP find error"",0,true); return false; } float VBat = M5.Axp.GetBatVoltage(); if ((VBat < 3.1) || (VBat > 4.4)) { ErrorMeg(0x22, ""Low Battery"",""please charge!"",1,false); char strbuff[64]; while(1) { VBat = M5.Axp.GetBatVoltage(); sprintf(strbuff,""charging %.2fV"",VBat); ErrorMeg(0x22, ""Low Battery"",""please charge!"",1,false); if (VBat > 3.2) break; delay(10); } return false; } return true; } bool checkMPU6886() { return true; } bool checkBM8563() { uint8_t i = 0; M5.Rtc.GetBm8563Time(); RTC_TimeTypeDef time; M5.Rtc.GetTime(&time); uint8_t sec = time.Seconds; while (1) { M5.Rtc.GetTime(&time); delay(10); i++; if (i > 200) { ErrorMeg(0x41, ""RTC error "", 0, true); } if (sec != time.Seconds) { break; } } return true; } bool checkOUTIO() { uint32_t sumadc1 = 0, sumadc2 = 0; pinMode(26,INPUT); for (int i = 0; i < 50; i++) { sumadc2 += analogRead(36); delay(50); } sumadc1 = sumadc1 / 50; sumadc2 = sumadc2 / 50; sumadc1 = sumadc1 * 3300 / 4095 * 2; sumadc2 = sumadc2 * 3300 / 4095 * 2; printf(""%d,%d\\n"", sumadc1, sumadc2); if ( sumadc1 < 3000 ) { ErrorMeg(0x61, ""5V or 26 error"",0 ,true); } if ( sumadc2 < 2500 ) { ErrorMeg(0x62, ""3V3 or 36 error"",0 ,true); } return true; } DHT12 dht12; bool CheckGrove() { float tmp = dht12.readTemperature(); float hum = dht12.readHumidity(); uint8_t count = 0; for (int i = 0; i < 10; i++) { tmp = dht12.readTemperature(); hum = dht12.readHumidity(); if(( tmp > 50 )||( tmp < -20 )||( hum > 100 )||( hum == 0 )) { count ++; if( count > 5 ) { ErrorMeg(0x91, ""Grove error"",0 ,true); return false; } } } return true; } void ColorBar() { float color_r, color_g, color_b; color_r = 0; color_g = 0; color_b = 255; M5.Axp.ScreenBreath(12); for (int i = 0; i < 384; i=i+4) { if (i < 128) { color_r = i * 2; color_g = 0; color_b = 255 - (i * 2); } else if ((i >= 128) && (i < 256)) { color_r = 255 - ((i - 128) * 2); color_g = (i - 128) * 2; color_b = 0; } else if ((i >= 256) && (i < 384)) { color_r = 0; color_g = 255 - ((i - 256) * 2); ; color_b = (i - 256) * 2; ; } Disbuff.fillRect(0, 0, 160, 80, Disbuff.color565(color_r, color_g, color_b)); if (TestMode) { Disbuff.setTextColor(RED); Disbuff.drawString(""Test Mode"", 0, 0, 1); } Displaybuff(); } for (int i = 0; i < 4; i++) { switch (i) { case 0: color_r = 0; color_g = 0; color_b = 0; break; case 1: color_r = 255; color_g = 0; color_b = 0; break; case 2: color_r = 0; color_g = 255; color_b = 0; break; case 3: color_r = 0; color_g = 0; color_b = 255; break; } for (int n = 0; n < 160; n++) { color_r = (color_r < 255) ? color_r += 1.6 : 255U; color_g = (color_g < 255) ? color_g += 1.6 : 255U; color_b = (color_b < 255) ? color_b += 1.6 : 255U; Disbuff.drawLine(n, i * 20, n, (i + 1) * 20, Disbuff.color565(color_r, color_g, color_b)); } } if (TestMode) { Disbuff.setTextColor(RED); Disbuff.drawString(""Test Mode"", 0, 0, 1); } Displaybuff(); delay(2000); M5.Axp.ScreenBreath(12); for (int i = 0; i < 4; i++) { switch (i) { case 0: color_r = 255; color_g = 255; color_b = 255; break; case 1: color_r = 255; color_g = 0; color_b = 0; break; case 2: color_r = 0; color_g = 255; color_b = 0; break; case 3: color_r = 0; color_g = 0; color_b = 255; break; } for (int n = 0; n < 160; n++) { color_r = (color_r > 2) ? color_r -= 1.5 : 0U; color_g = (color_g > 2) ? color_g -= 1.5 : 0U; color_b = (color_b > 2) ? color_b -= 1.5 : 0U; Disbuff.drawLine(159 - n, i * 20, 159 - n, (i + 1) * 20, Disbuff.color565(color_r, color_g, color_b)); } } Displaybuff(); delay(2000); } bool point3Dto2D(point_3d_t *source, point_2d_t *point) { point->x = (source->x * cos_gamma) - (source->y * sin_gamma); point->y = -(source->x * sin_gamma * sin_alpha) - (source->y * cos_gamma * sin_alpha) + (source->z * cos_alpha); return true; } bool point2DToDisPoint(point_2d_t *point, uint8_t *x, uint8_t *y) { *x = point->x + 80; *y = 40 - point->y; return true; } bool printLine3D(TFT_eSprite *display, line_3d_t *line, uint32_t color) { uint8_t start_x, start_y, end_x, end_y; point_2d_t point; point3Dto2D(&line->start_point, &point); point2DToDisPoint(&point, &start_x, &start_y); point3Dto2D(&line->end_point, &point); point2DToDisPoint(&point, &end_x, &end_y); display->drawLine(start_x, start_y, end_x, end_y, color); return true; } void RotatePoint(point_3d_t *point, double x, double y, double z) { if (x != 0) { point->y = point->y * cos(x * r_rand) - point->z * sin(x * r_rand); point->z = point->y * sin(x * r_rand) + point->z * cos(x * r_rand); } if (y != 0) { point->x = point->z * sin(y * r_rand) + point->x * cos(y * r_rand); point->z = point->z * cos(y * r_rand) - point->x * sin(y * r_rand); } if (z != 0) { point->x = point->x * cos(z * r_rand) - point->y * sin(z * r_rand); point->y = point->x * sin(z * r_rand) + point->y * cos(z * r_rand); } } void RotatePoint(point_3d_t *point, point_3d_t *point_new, double x, double y, double z) { if (x != 0) { point_new->y = point->y * cos(x * r_rand) - point->z * sin(x * r_rand); point_new->z = point->y * sin(x * r_rand) + point->z * cos(x * r_rand); } if (y != 0) { point_new->x = point->z * sin(y * r_rand) + point->x * cos(y * r_rand); point_new->z = point->z * cos(y * r_rand) - point->x * sin(y * r_rand); } if (z != 0) { point_new->x = point->x * cos(z * r_rand) - point->y * sin(z * r_rand); point_new->y = point->x * sin(z * r_rand) + point->y * cos(z * r_rand); } } line_3d_t rect[12] = { {.start_point = {-1, -1, 1}, .end_point = {1, -1, 1}}, {.start_point = {1, -1, 1}, .end_point = {1, 1, 1}}, {.start_point = {1, 1, 1}, .end_point = {-1, 1, 1}}, {.start_point = {-1, 1, 1}, .end_point = {-1, -1, 1}}, { .start_point = {-1, -1, 1}, .end_point = {-1, -1, -1}, }, { .start_point = {1, -1, 1}, .end_point = {1, -1, -1}, }, { .start_point = {1, 1, 1}, .end_point = {1, 1, -1}, }, { .start_point = {-1, 1, 1}, .end_point = {-1, 1, -1}, }, {.start_point = {-1, -1, -1}, .end_point = {1, -1, -1}}, {.start_point = {1, -1, -1}, .end_point = {1, 1, -1}}, {.start_point = {1, 1, -1}, .end_point = {-1, 1, -1}}, {.start_point = {-1, 1, -1}, .end_point = {-1, -1, -1}}, }; void MPU6886Test() { float accX = 0; float accY = 0; float accZ = 0; double theta, last_theta = 0; double phi, last_phi = 0; double alpha = 0.2; line_3d_t x = { .start_point = {0, 0, 0}, .end_point = {0, 0, 0}}; line_3d_t y = { .start_point = {0, 0, 0}, .end_point = {0, 0, 0}}; line_3d_t z = { .start_point = {0, 0, 0}, .end_point = {0, 0, 30}}; line_3d_t rect_source[12]; line_3d_t rect_dis; for (int n = 0; n < 12; n++) { rect_source[n].start_point.x = rect[n].start_point.x * 15; rect_source[n].start_point.y = rect[n].start_point.y * 15; rect_source[n].start_point.z = rect[n].start_point.z * 15; rect_source[n].end_point.x = rect[n].end_point.x * 15; rect_source[n].end_point.y = rect[n].end_point.y * 15; rect_source[n].end_point.z = rect[n].end_point.z * 15; } while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { M5.Imu.getAccelData(&accX, &accY, &accZ); //M5.MPU6886.getAccelData(&accX, &accY, &accZ); if ((accX < 1) && (accX > -1)) { theta = asin(-accX) * 57.295; } if (accZ != 0) { phi = atan(accY / accZ) * 57.295; } theta = alpha * theta + (1 - alpha) * last_theta; phi = alpha * phi + (1 - alpha) * last_phi; Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.setTextSize(1); Disbuff.setCursor(10, 55); Disbuff.printf(""%.2f"", theta); Disbuff.setCursor(10, 65); Disbuff.printf(""%.2f"", phi); //Displaybuff(); delay(20); z.end_point.x = 0; z.end_point.y = 0; z.end_point.z = 30; RotatePoint(&z.end_point, theta, phi, 0); RotatePoint(&z.end_point, &x.end_point, -90, 0, 0); RotatePoint(&z.end_point, &y.end_point, 0, 90, 0); for (int n = 0; n < 12; n++) { RotatePoint(&rect_source[n].start_point, &rect_dis.start_point, theta, phi, (double)0); RotatePoint(&rect_source[n].end_point, &rect_dis.end_point, theta, phi, (double)0); printLine3D(&Disbuff, &rect_dis, WHITE); } //Disbuff.fillRect(0,0,160,80,BLACK); printLine3D(&Disbuff, &x, RED); printLine3D(&Disbuff, &y, GREEN); printLine3D(&Disbuff, &z, BLUE); //Disbuff Disbuff.setTextColor(WHITE); Disbuff.setTextSize(1); Disbuff.fillRect(0,0,52,18,Disbuff.color565(20,20,20)); Disbuff.drawString(""MPU6886"",5,5,1); Displaybuff(); last_theta = theta; last_phi = phi; M5.update(); checkAXPPress(); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); checkAXPPress(); delay(10); } } void DisplayI2CENV() { Disbuff.fillRect(0, 0, 160, 80, Disbuff.color565(0, 0, 0)); Displaybuff(); float tmp; float hum; while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { tmp = dht12.readTemperature(); hum = dht12.readHumidity(); Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.setTextSize(3); Disbuff.setCursor(5, 15); Disbuff.printf(""TMP:%2.1f"", tmp); Disbuff.setCursor(5, 45); Disbuff.printf(""HUM:%2.0f%%"", hum); Displaybuff(); M5.update(); delay(100); checkAXPPress(); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); checkAXPPress(); delay(10); } } SemaphoreHandle_t xSemaphore = NULL; SemaphoreHandle_t start_dis = NULL; SemaphoreHandle_t start_fft = NULL; int8_t i2s_readraw_buff[1024]; uint8_t fft_dis_buff[161][80] = {0}; uint16_t posData = 160; void MicRecordfft(void *arg) { int16_t *buffptr; size_t bytesread; uint16_t count_n = 0, count_i = 0, count_x = 0, count_y = 0; float adc_data; double data = 0; uint16_t ydata; while (1) { xSemaphoreTake(start_fft, portMAX_DELAY); xSemaphoreGive(start_fft); fft_config_t *real_fft_plan = fft_init(512, FFT_REAL, FFT_FORWARD, NULL, NULL); i2s_read(I2S_NUM_0, (char *)i2s_readraw_buff, 1024, &bytesread, (100 / portTICK_RATE_MS)); buffptr = (int16_t *)i2s_readraw_buff; for (count_n = 0; count_n < real_fft_plan->size; count_n++) { adc_data = (float)map(buffptr[count_n], INT16_MIN, INT16_MAX, -1000, 1000); real_fft_plan->input[count_n] = adc_data; } fft_execute(real_fft_plan); xSemaphoreTake(xSemaphore, 100 / portTICK_RATE_MS); for (count_n = 1; count_n < real_fft_plan->size / 4; count_n++) { data = sqrt(real_fft_plan->output[2 * count_n] * real_fft_plan->output[2 * count_n] + real_fft_plan->output[2 * count_n + 1] * real_fft_plan->output[2 * count_n + 1]); if ((count_n - 1) < 80) { ydata = map(data, 0, 2000, 0, 256); fft_dis_buff[posData][80 - count_n] = ydata; } } posData++; if (posData >= 161) { posData = 0; } xSemaphoreGive(xSemaphore); fft_destroy(real_fft_plan); } } void Drawdisplay(void *arg) { uint16_t count_n = 0, count_x = 0, count_y = 0; uint16_t ydata; uint16_t colorPos; while (1) { xSemaphoreTake(start_dis, portMAX_DELAY); xSemaphoreGive(start_dis); xSemaphoreTake(xSemaphore, 500 / portTICK_RATE_MS); for (count_y = 0; count_y < 80; count_y++) { for (count_x = 0; count_x < 160; count_x++) { if ((count_x + (posData % 160)) > 160) { colorPos = fft_dis_buff[count_x + (posData % 160) - 160][count_y]; } else { colorPos = fft_dis_buff[count_x + (posData % 160)][count_y]; } Disbuff.drawPixel(count_x, count_y, Disbuff.color565(ImageData[colorPos * 3 + 0], ImageData[colorPos * 3 + 1], ImageData[colorPos * 3 + 2])); /* disbuff[ count_y * 160 + count_x ].r = ImageData[ colorPos * 3 + 0 ]; disbuff[ count_y * 160 + count_x ].g = ImageData[ colorPos * 3 + 1 ]; disbuff[ count_y * 160 + count_x ].b = ImageData[ colorPos * 3 + 2 ]; */ } } xSemaphoreGive(xSemaphore); Disbuff.setTextColor(WHITE); Disbuff.setTextSize(1); Disbuff.fillRect(0,0,70,18,Disbuff.color565(20,20,20)); Disbuff.drawString(""MicroPhone"",5,5,1); Disbuff.pushSprite(0, 0); } } TaskHandle_t xhandle_display = NULL; TaskHandle_t xhandle_fft = NULL; void DisplayMicro() { Disbuff.fillRect(0, 0, 160, 80, Disbuff.color565(0, 0, 0)); Disbuff.pushSprite(0, 0); xSemaphoreGive(start_dis); xSemaphoreGive(start_fft); while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { xSemaphoreGive(start_dis); xSemaphoreGive(start_fft); M5.update(); //delay(100); xSemaphoreTake(start_dis, portMAX_DELAY); xSemaphoreTake(start_fft, portMAX_DELAY); //checkAXPPress(); } //xSemaphoreTake( start_dis , portMAX_DELAY ); //xSemaphoreTake( start_fft , portMAX_DELAY ); while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); delay(10); checkAXPPress(); } } void DisplayRTC() { Disbuff.fillRect(0, 0, 160, 80, Disbuff.color565(0, 0, 0)); Displaybuff(); M5.Rtc.GetBm8563Time(); RTC_TimeTypeDef time; M5.Rtc.GetTime(&time); Disbuff.setTextSize(3); Disbuff.setCursor(6, 25); Disbuff.setTextColor(WHITE); while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { Disbuff.fillRect(0, 0, 160, 80, Disbuff.color565(0, 0, 0)); M5.Rtc.GetTime(&time); Disbuff.setTextSize(3); Disbuff.setTextColor(WHITE); Disbuff.setCursor(6, 40); Disbuff.printf(""%02d:%02d:%02d"", time.Hours, time.Minutes, time.Seconds); Disbuff.fillRect(0,0,160,18,Disbuff.color565(20,20,20)); Disbuff.setTextSize(1); Disbuff.drawString(""BMP8563 RTC Time"",32,5,1); Displaybuff(); M5.update(); checkAXPPress(); delay(100); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { checkAXPPress(); M5.update(); delay(10); } } void DisplayIOPort() { i2s_pin_config_t pin_config; pin_config.bck_io_num = I2S_PIN_NO_CHANGE; pin_config.ws_io_num = 33; pin_config.data_out_num = I2S_PIN_NO_CHANGE; pin_config.data_in_num = PIN_DATA; i2s_set_pin(I2S_NUM_0,&pin_config); i2s_driver_uninstall(I2S_NUM_0); gpio_reset_pin(GPIO_NUM_0); gpio_reset_pin(GPIO_NUM_26); pinMode(26,OUTPUT); pinMode(0,OUTPUT); digitalWrite(0,1); digitalWrite(26,1); uint16_t pin36_adc = analogRead(36); Disbuff.setTextSize(2); Disbuff.setCursor(6, 25); Disbuff.setTextColor(WHITE); uint8_t count = 0; while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.setTextSize(2); digitalWrite(0,0); digitalWrite(26,0); count = 0; for( int i = 0 ; i< 10; i++ ) { digitalWrite( 0, i%2 ); delay(10); pin36_adc = analogRead(36); if(( pin36_adc > 1800 )&&( i%2 == 1 )) { count ++; } } Disbuff.setCursor(5, 5); if( count >= 5 ) { Disbuff.setTextColor(GREEN); Disbuff.printf(""%d G0 OK"", count); } else { Disbuff.setTextColor(RED); Disbuff.printf(""%d G0 faild"", count); } Disbuff.setTextColor(WHITE); digitalWrite(0,0); digitalWrite(26,0); count = 0; for( int i = 0 ; i< 10; i++ ) { digitalWrite( 26, i%2 ); delay(10); pin36_adc = analogRead(36); if(( pin36_adc > 1800 )&&( i%2 == 1 )) { count ++; } } Disbuff.setCursor(5, 20); if( count >= 5 ) { Disbuff.setTextColor(GREEN); Disbuff.printf(""%d G26 OK"", count); } else { Disbuff.setTextColor(RED); Disbuff.printf(""%d G26 faild"", count); } Disbuff.setTextColor(WHITE); digitalWrite(0,0); digitalWrite(26,0); delay(10); pin36_adc = analogRead(36); Disbuff.setCursor(5, 35); Disbuff.printf(""%.2f"", M5.Axp.GetVinVoltage()); if( M5.Axp.GetVinVoltage() > 4.2 ) { Disbuff.setTextColor(GREEN); Disbuff.printf("" 5V OK""); } else { Disbuff.setTextColor(RED); Disbuff.printf(""5V Err""); } Disbuff.setTextColor(WHITE); Disbuff.setCursor(5, 50); Disbuff.printf(""%d"", pin36_adc); //if( pin36_adc > 1100 ) { Disbuff.setTextColor(GREEN); Disbuff.printf(""3V3 OK""); } //else //{ // Disbuff.setTextColor(RED); // Disbuff.printf(""3V3 Err""); //} Disbuff.setTextColor(WHITE); Displaybuff(); /* pin36_adc = analogRead(36); Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.setTextSize(3); Disbuff.setCursor(5, 15); Disbuff.printf(""%.2f"", M5.Axp.GetVinVoltage()); Disbuff.setCursor(5, 45); Disbuff.printf(""%d"", pin36_adc); Displaybuff(); */ M5.update(); delay(100); checkAXPPress(); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); delay(10); checkAXPPress(); } InitI2SMicroPhone(); } void DisIRSend() { uint8_t senddata[20]={0}; memset(senddata,0x00,sizeof(uint8_t)*20); while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.pushImage(110, 16, 48, 48, (uint16_t *)icon_ir); Disbuff.setTextColor(Disbuff.color565(180,180,180)); Disbuff.setTextSize(2); Disbuff.setCursor(12, 20); Disbuff.printf(""IR Send ""); Disbuff.setCursor(12, 45); if( senddata[0] % 4 == 0 ) { Disbuff.printf(""0x%02X> "",senddata[0]); } else if( senddata[0] % 4 == 1 ) { Disbuff.printf(""0x%02X>>"",senddata[0]); } else if( senddata[0] % 4 == 2 ) { Disbuff.printf(""0x%02X >>"",senddata[0]); } else if( senddata[0] % 4 == 3 ) { Disbuff.printf(""0x%02X >"",senddata[0]); } Displaybuff(); senddata[1]++; if( senddata[1] > 3 ) { senddata[1] = 0; senddata[0]++; ir_uart_tx( senddata ,20, true); } checkAXPPress(); M5.update(); delay(100); ledcWrite(15,0); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); checkAXPPress(); delay(10); } ledcWrite(15,0); Disbuff.setTextColor(WHITE); } void DisPlayBLESend() { uint8_t senddata[2]={0}; pService->start(); pServer->getAdvertising()->start(); uint64_t chipid = ESP.getEfuseMac(); String blename = ""M5-"" + String((uint32_t)(chipid >> 32), HEX); while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { Disbuff.fillRect(0, 0, 160, 80, BLACK); if( deviceConnected ) { Disbuff.pushImage(110, 16, 48, 48, (uint16_t *)icon_ble); Disbuff.setTextColor(Disbuff.color565(180,180,180)); Disbuff.setTextSize(2); Disbuff.setCursor(12, 20); //Disbuff.printf(""BLE connect!\\n""); Disbuff.printf(""BLE Send\\n""); Disbuff.setCursor(12, 45); if( senddata[0] % 4 == 0 ) { Disbuff.printf(""0x%02X> "",senddata[0]); } else if( senddata[0] % 4 == 1 ) { Disbuff.printf(""0x%02X>>"",senddata[0]); } else if( senddata[0] % 4 == 2 ) { Disbuff.printf(""0x%02X >>"",senddata[0]); } else if( senddata[0] % 4 == 3 ) { Disbuff.printf(""0x%02X >"",senddata[0]); } senddata[1]++; if( senddata[1] > 3 ) { senddata[1] = 0; senddata[0]++; pTxCharacteristic->setValue( senddata, 1 ); pTxCharacteristic->notify(); } } else { Disbuff.setTextSize(1); Disbuff.setCursor(12, 20); Disbuff.setTextColor(RED); Disbuff.printf(""BLE disconnect\\n""); Disbuff.setCursor(12, 35); Disbuff.setTextColor(Disbuff.color565(18,150,219)); Disbuff.printf(String(""Name:""+blename+""\\n"").c_str()); Disbuff.setCursor(12, 50); Disbuff.printf(""UUID:1bc68b2a\\n""); Disbuff.pushImage(110, 16, 48, 48, (uint16_t *)icon_ble_disconnect); } Displaybuff(); M5.update(); delay(100); checkAXPPress(); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); delay(10); checkAXPPress(); } Disbuff.setTextColor(WHITE); pService->stop(); pServer->getAdvertising()->stop(); } void DisplayWIFI() { WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); int n = 0; while ((!M5.BtnA.isPressed()) && (!M5.BtnB.isPressed())) { Disbuff.fillRect(0, 0, 160, 80, BLACK); Disbuff.pushImage(110, 16, 48, 48, (uint16_t *)icon_wifi); n = WiFi.scanNetworks(); Disbuff.setTextColor(WHITE); Disbuff.setTextSize(1); if (n == 0) { Disbuff.setCursor(5, 20); Disbuff.setTextColor(RED); Disbuff.printf(""No WIFI found\\n""); Disbuff.setTextColor(WHITE); } else { Disbuff.setTextColor(WHITE); n = ( n > 4 )? 4 : n; for (int i = 0; i < n; ++i) { Disbuff.setCursor(5, 20); Disbuff.setTextColor(RED); if( WiFi.SSID(i).length() >= 10 ) { Disbuff.drawString(WiFi.SSID(i).substring(0,10),5,( 20 + i * 10)); } else { Disbuff.drawString(WiFi.SSID(i),5,( 20 + i * 10)); } } } Disbuff.fillRect(0,0,160,18,Disbuff.color565(20,20,20)); Disbuff.setTextSize(1); Disbuff.drawString(""Wifi Test"",32,5,1); Displaybuff(); M5.update(); delay(100); } while ((M5.BtnA.isPressed()) || (M5.BtnB.isPressed())) { M5.update(); delay(10); } } void setup() { M5.begin(); M5.update(); if (M5.BtnB.isPressed()) { TestMode = true; } Wire.begin(32,33,10000); M5.Lcd.setRotation(3); M5.Lcd.setSwapBytes(false); Disbuff.createSprite(160, 80); Disbuff.setSwapBytes(true); for (int n = 0; n < 12; n++) { Disbuff.pushImage(40, 0, 81, 80, (uint16_t *)Animationptr[n]); Displaybuff(); delay(30); } if (InitI2SMicroPhone() != true) { ErrorMeg(0x51, ""MicroPhone error"",0 ,true); } if (M5.Imu.Init() != 0) { ErrorMeg(0x31, ""MPU6886 error "",0 ,true); } if( InitIRTx() != true ) { ErrorMeg(0x72, ""RMT Init error"",0 ,true); } if( InitBLEServer() != true ) { ErrorMeg(0x81, ""BLE init error"",0 ,true); } checkAXP192(); checkBM8563(); uint16_t ellips[7] = { 70, 78, 86, 93, 100, 108, 116}; uint16_t* picptr = (uint16_t*)stick10; for (int n = 11; n < 18; n++) { Disbuff.fillEllipse(80,40,ellips[n-11]/2, ellips[n-11]/2, Disbuff.color565(43,43,43)); Disbuff.pushImage(40, 0, 81, 80, (uint16_t *)Animationptr[n]); Displaybuff(); delay(20); } int color_bk = 43; for (int n = 116; n < 180; n=n+8) { Disbuff.fillEllipse(80,40,n/2, n/2, Disbuff.color565(color_bk,color_bk,color_bk)); Displaybuff(); delay(20); color_bk -= 5; } Disbuff.fillRect(0,0,160,80,BLACK); Displaybuff(); if (TestMode) { ColorBar(); } pinMode(10, OUTPUT); timerSemaphore = xSemaphoreCreateBinary(); timer = timerBegin(0, 80, true); timerAttachInterrupt(timer, &onTimer, true); timerAlarmWrite(timer, 50000, true); timerAlarmEnable(timer); xSemaphore = xSemaphoreCreateMutex(); start_dis = xSemaphoreCreateMutex(); start_fft = xSemaphoreCreateMutex(); xSemaphoreTake(start_dis, portMAX_DELAY); xSemaphoreTake(start_fft, portMAX_DELAY); xTaskCreate(Drawdisplay, ""Drawdisplay"", 1024 * 2, (void *)0, 4, &xhandle_display); xTaskCreate(MicRecordfft, ""MicRecordfft"", 1024 * 2, (void *)0, 5, &xhandle_fft); } uint8_t xData, yData; void loop() { delay(100); MPU6886Test(); DisplayRTC(); DisplayMicro(); DisIRSend(); //DisplayWIFI(); if (TestMode) { DisplayI2CENV(); DisplayIOPort(); DisPlayBLESend(); } else { DisPlayBLESend(); } } ",12336,False,2275.052787656711,median "############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 CONST_TABLE: _poly: .quad 0x1, 0xC200000000000000 _twoone: .quad 0x1, 0x100000000 _u128_str: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 _mask1: .quad 0xffffffffffffffff, 0x0 _mask2: .quad 0x0, 0xffffffffffffffff _inc1: .quad 1,0 .p2align 5, 0x90 .globl _h9_AesGcmPrecompute_avx _h9_AesGcmPrecompute_avx: push %ebp mov %esp, %ebp push %esi call .L__0000gas_1 .L__0000gas_1: pop %esi sub $(.L__0000gas_1-CONST_TABLE), %esi movl (8)(%ebp), %eax movdqu (%eax), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm0 psrlq $(63), %xmm4 movdqa %xmm4, %xmm3 pslldq $(8), %xmm4 psrldq $(8), %xmm3 por %xmm4, %xmm0 pshufd $(36), %xmm3, %xmm4 pcmpeqd ((_twoone-CONST_TABLE))(%esi), %xmm4 pand ((_poly-CONST_TABLE))(%esi), %xmm4 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm1 pshufd $(78), %xmm1, %xmm5 pshufd $(78), %xmm0, %xmm3 pxor %xmm1, %xmm5 pxor %xmm0, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm1, %xmm4 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm0, %xmm4 pxor %xmm1, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm1 movdqa %xmm1, %xmm3 psllq $(1), %xmm3 pxor %xmm1, %xmm3 psllq $(5), %xmm3 pxor %xmm1, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm1 pxor %xmm3, %xmm4 movdqa %xmm1, %xmm5 psrlq $(5), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm1, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm1 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 pshufd $(78), %xmm2, %xmm5 pshufd $(78), %xmm1, %xmm3 pxor %xmm2, %xmm5 pxor %xmm1, %xmm3 pclmulqdq $(0), %xmm3, %xmm5 movdqa %xmm2, %xmm4 pclmulqdq $(0), %xmm1, %xmm2 pxor %xmm3, %xmm3 pclmulqdq $(17), %xmm1, %xmm4 pxor %xmm2, %xmm5 pxor %xmm4, %xmm5 palignr $(8), %xmm5, %xmm3 pslldq $(8), %xmm5 pxor %xmm3, %xmm4 pxor %xmm5, %xmm2 movdqa %xmm2, %xmm3 psllq $(1), %xmm3 pxor %xmm2, %xmm3 psllq $(5), %xmm3 pxor %xmm2, %xmm3 psllq $(57), %xmm3 movdqa %xmm3, %xmm5 pslldq $(8), %xmm5 psrldq $(8), %xmm3 pxor %xmm5, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm2, %xmm5 psrlq $(5), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm2, %xmm5 psrlq $(1), %xmm5 pxor %xmm5, %xmm2 pxor %xmm4, %xmm2 movl (12)(%ebp), %eax movdqu %xmm0, (%eax) movdqu %xmm1, (16)(%eax) movdqu %xmm2, (32)(%eax) pop %esi pop %ebp ret .p2align 5, 0x90 .globl _h9_AesGcmMulGcm_avx _h9_AesGcmMulGcm_avx: push %ebp mov %esp, %ebp push %esi push %edi call .L__0001gas_2 .L__0001gas_2: pop %esi sub $(.L__0001gas_2-CONST_TABLE), %esi movl (8)(%ebp), %edi movl (12)(%ebp), %eax movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .p2align 5, 0x90 .globl _h9_AesGcmAuth_avx _h9_AesGcmAuth_avx: push %ebp mov %esp, %ebp push %esi push %edi call .L__0002gas_3 .L__0002gas_3: pop %esi sub $(.L__0002gas_3-CONST_TABLE), %esi movl (8)(%ebp), %edi movdqa (%edi), %xmm0 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movl (20)(%ebp), %eax movdqa (%eax), %xmm1 movl (12)(%ebp), %ecx movl (16)(%ebp), %edx .p2align 5, 0x90 .Lauth_loopgas_3: movdqu (%ecx), %xmm2 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm2 add $(16), %ecx pxor %xmm2, %xmm0 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 sub $(16), %edx jnz .Lauth_loopgas_3 pshufb ((_u128_str-CONST_TABLE))(%esi), %xmm0 movdqa %xmm0, (%edi) pop %edi pop %esi pop %ebp ret .p2align 5, 0x90 .globl _h9_AesGcmEnc_avx _h9_AesGcmEnc_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax call .L__0003gas_4 .L__0003gas_4: pop %esi sub $(.L__0003gas_4-CONST_TABLE), %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_4 .p2align 5, 0x90 .Lblks4_loopgas_4: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher4_loopgas_4: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_4 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm1 pxor (48)(%ebx), %xmm1 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm2 pxor (64)(%ebx), %xmm2 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm3 pxor (80)(%ebx), %xmm3 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm7 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_4 pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 movdqa %xmm0, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm2, (64)(%ebx) movdqa %xmm3, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_4 .Lcombine_hashgas_4: pshufd $(78), %xmm0, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm0, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm0, %xmm5 pclmulqdq $(0), %xmm7, %xmm0 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm0, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm0 movdqa %xmm0, %xmm4 psllq $(1), %xmm4 pxor %xmm0, %xmm4 psllq $(5), %xmm4 pxor %xmm0, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm0 pxor %xmm4, %xmm5 movdqa %xmm0, %xmm6 psrlq $(5), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm0, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm0 pxor %xmm5, %xmm0 movdqa (16)(%eax), %xmm7 pshufd $(78), %xmm1, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm1, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm1, %xmm5 pclmulqdq $(0), %xmm7, %xmm1 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm1, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm1 movdqa %xmm1, %xmm4 psllq $(1), %xmm4 pxor %xmm1, %xmm4 psllq $(5), %xmm4 pxor %xmm1, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm1 pxor %xmm4, %xmm5 movdqa %xmm1, %xmm6 psrlq $(5), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm1, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm1 pxor %xmm5, %xmm1 movdqa (%eax), %xmm7 pshufd $(78), %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm2, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm2, %xmm5 pclmulqdq $(0), %xmm7, %xmm2 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm2, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm2 movdqa %xmm2, %xmm4 psllq $(1), %xmm4 pxor %xmm2, %xmm4 psllq $(5), %xmm4 pxor %xmm2, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm2 pxor %xmm4, %xmm5 movdqa %xmm2, %xmm6 psrlq $(5), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm2, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm2 pxor %xmm5, %xmm2 pxor %xmm1, %xmm3 pxor %xmm2, %xmm3 pshufd $(78), %xmm3, %xmm6 pshufd $(78), %xmm7, %xmm4 pxor %xmm3, %xmm6 pxor %xmm7, %xmm4 pclmulqdq $(0), %xmm4, %xmm6 movdqa %xmm3, %xmm5 pclmulqdq $(0), %xmm7, %xmm3 pxor %xmm4, %xmm4 pclmulqdq $(17), %xmm7, %xmm5 pxor %xmm3, %xmm6 pxor %xmm5, %xmm6 palignr $(8), %xmm6, %xmm4 pslldq $(8), %xmm6 pxor %xmm4, %xmm5 pxor %xmm6, %xmm3 movdqa %xmm3, %xmm4 psllq $(1), %xmm4 pxor %xmm3, %xmm4 psllq $(5), %xmm4 pxor %xmm3, %xmm4 psllq $(57), %xmm4 movdqa %xmm4, %xmm6 pslldq $(8), %xmm6 psrldq $(8), %xmm4 pxor %xmm6, %xmm3 pxor %xmm4, %xmm5 movdqa %xmm3, %xmm6 psrlq $(5), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm3, %xmm6 psrlq $(1), %xmm6 pxor %xmm6, %xmm3 pxor %xmm5, %xmm3 pxor %xmm0, %xmm3 movdqa %xmm3, (32)(%ebx) .Lsingle_block_procgas_4: cmpl $(0), (132)(%ebx) jz .Lquitgas_4 .p2align 5, 0x90 .Lblk_loopgas_4: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher_loopgas_4: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_4 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm0 pxor (32)(%ebx), %xmm0 movdqa (%eax), %xmm1 pshufd $(78), %xmm0, %xmm4 pshufd $(78), %xmm1, %xmm2 pxor %xmm0, %xmm4 pxor %xmm1, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm0, %xmm3 pclmulqdq $(0), %xmm1, %xmm0 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm1, %xmm3 pxor %xmm0, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm0 movdqa %xmm0, %xmm2 psllq $(1), %xmm2 pxor %xmm0, %xmm2 psllq $(5), %xmm2 pxor %xmm0, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm0 pxor %xmm2, %xmm3 movdqa %xmm0, %xmm4 psrlq $(5), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm0, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm0 pxor %xmm3, %xmm0 movdqa %xmm0, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_4 .Lquitgas_4: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret .p2align 5, 0x90 .globl _h9_AesGcmDec_avx _h9_AesGcmDec_avx: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(152), %esp lea (16)(%esp), %ebx and $(-16), %ebx movl (20)(%ebp), %eax call .L__0004gas_5 .L__0004gas_5: pop %esi sub $(.L__0004gas_5-CONST_TABLE), %esi movdqa ((_u128_str-CONST_TABLE))(%esi), %xmm4 movdqa ((_inc1-CONST_TABLE))(%esi), %xmm5 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx movdqu (%eax), %xmm0 movdqu (%ecx), %xmm1 movdqu (%edx), %xmm2 pshufb %xmm4, %xmm0 movdqa %xmm0, (%ebx) movdqa %xmm1, (16)(%ebx) pshufb %xmm4, %xmm2 pxor %xmm1, %xmm1 movdqa %xmm2, (32)(%ebx) movdqa %xmm1, (48)(%ebx) movdqa %xmm1, (64)(%ebx) movdqa %xmm1, (80)(%ebx) movdqa %xmm4, (96)(%ebx) movdqa %xmm5, (112)(%ebx) movl (28)(%ebp), %ecx movl (12)(%ebp), %esi movl (8)(%ebp), %edi movl (16)(%ebp), %eax mov $(63), %edx and %eax, %edx and $(-64), %eax movl %eax, (128)(%ebx) movl %edx, (132)(%ebx) jz .Lsingle_block_procgas_5 .p2align 5, 0x90 .Lblks4_loopgas_5: movdqa (112)(%ebx), %xmm5 movdqa %xmm0, %xmm1 paddd %xmm5, %xmm1 movdqa %xmm1, %xmm2 paddd %xmm5, %xmm2 movdqa %xmm2, %xmm3 paddd %xmm5, %xmm3 movdqa %xmm3, %xmm4 paddd %xmm5, %xmm4 movdqa %xmm4, (%ebx) movdqa (96)(%ebx), %xmm5 movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb %xmm5, %xmm1 pshufb %xmm5, %xmm2 pshufb %xmm5, %xmm3 pshufb %xmm5, %xmm4 pxor %xmm0, %xmm1 pxor %xmm0, %xmm2 pxor %xmm0, %xmm3 pxor %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher4_loopgas_5: aesenc %xmm0, %xmm1 aesenc %xmm0, %xmm2 aesenc %xmm0, %xmm3 aesenc %xmm0, %xmm4 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher4_loopgas_5 aesenclast %xmm0, %xmm1 aesenclast %xmm0, %xmm2 aesenclast %xmm0, %xmm3 aesenclast %xmm0, %xmm4 movdqa (16)(%ebx), %xmm0 movdqa %xmm4, (16)(%ebx) movdqu (%esi), %xmm4 movdqu (16)(%esi), %xmm5 movdqu (32)(%esi), %xmm6 movdqu (48)(%esi), %xmm7 add $(64), %esi pxor %xmm4, %xmm0 movdqu %xmm0, (%edi) pshufb (96)(%ebx), %xmm4 pxor (32)(%ebx), %xmm4 pxor %xmm5, %xmm1 movdqu %xmm1, (16)(%edi) pshufb (96)(%ebx), %xmm5 pxor (48)(%ebx), %xmm5 pxor %xmm6, %xmm2 movdqu %xmm2, (32)(%edi) pshufb (96)(%ebx), %xmm6 pxor (64)(%ebx), %xmm6 pxor %xmm7, %xmm3 movdqu %xmm3, (48)(%edi) pshufb (96)(%ebx), %xmm7 pxor (80)(%ebx), %xmm7 add $(64), %edi movl (44)(%ebp), %eax movdqa (32)(%eax), %xmm0 cmpl $(64), (128)(%ebx) je .Lcombine_hashgas_5 pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 movdqa %xmm4, (32)(%ebx) movdqa %xmm5, (48)(%ebx) movdqa %xmm6, (64)(%ebx) movdqa %xmm7, (80)(%ebx) movdqa (%ebx), %xmm0 subl $(64), (128)(%ebx) jge .Lblks4_loopgas_5 .Lcombine_hashgas_5: pshufd $(78), %xmm4, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm4, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm4, %xmm2 pclmulqdq $(0), %xmm0, %xmm4 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm4, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm4 movdqa %xmm4, %xmm1 psllq $(1), %xmm1 pxor %xmm4, %xmm1 psllq $(5), %xmm1 pxor %xmm4, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm4 pxor %xmm1, %xmm2 movdqa %xmm4, %xmm3 psrlq $(5), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm4, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm4 pxor %xmm2, %xmm4 movdqa (16)(%eax), %xmm0 pshufd $(78), %xmm5, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm5, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm5, %xmm2 pclmulqdq $(0), %xmm0, %xmm5 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm5, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm5 movdqa %xmm5, %xmm1 psllq $(1), %xmm1 pxor %xmm5, %xmm1 psllq $(5), %xmm1 pxor %xmm5, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm5 pxor %xmm1, %xmm2 movdqa %xmm5, %xmm3 psrlq $(5), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm5, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm5 pxor %xmm2, %xmm5 movdqa (%eax), %xmm0 pshufd $(78), %xmm6, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm6, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm6, %xmm2 pclmulqdq $(0), %xmm0, %xmm6 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm6, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm6 movdqa %xmm6, %xmm1 psllq $(1), %xmm1 pxor %xmm6, %xmm1 psllq $(5), %xmm1 pxor %xmm6, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm6 pxor %xmm1, %xmm2 movdqa %xmm6, %xmm3 psrlq $(5), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm6, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm6 pxor %xmm2, %xmm6 pxor %xmm5, %xmm7 pxor %xmm6, %xmm7 pshufd $(78), %xmm7, %xmm3 pshufd $(78), %xmm0, %xmm1 pxor %xmm7, %xmm3 pxor %xmm0, %xmm1 pclmulqdq $(0), %xmm1, %xmm3 movdqa %xmm7, %xmm2 pclmulqdq $(0), %xmm0, %xmm7 pxor %xmm1, %xmm1 pclmulqdq $(17), %xmm0, %xmm2 pxor %xmm7, %xmm3 pxor %xmm2, %xmm3 palignr $(8), %xmm3, %xmm1 pslldq $(8), %xmm3 pxor %xmm1, %xmm2 pxor %xmm3, %xmm7 movdqa %xmm7, %xmm1 psllq $(1), %xmm1 pxor %xmm7, %xmm1 psllq $(5), %xmm1 pxor %xmm7, %xmm1 psllq $(57), %xmm1 movdqa %xmm1, %xmm3 pslldq $(8), %xmm3 psrldq $(8), %xmm1 pxor %xmm3, %xmm7 pxor %xmm1, %xmm2 movdqa %xmm7, %xmm3 psrlq $(5), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm7, %xmm3 psrlq $(1), %xmm3 pxor %xmm3, %xmm7 pxor %xmm2, %xmm7 pxor %xmm4, %xmm7 movdqa %xmm7, (32)(%ebx) .Lsingle_block_procgas_5: cmpl $(0), (132)(%ebx) jz .Lquitgas_5 .p2align 5, 0x90 .Lblk_loopgas_5: movdqa (%ebx), %xmm0 movdqa %xmm0, %xmm1 paddd (112)(%ebx), %xmm1 movdqa %xmm1, (%ebx) movdqa (%ecx), %xmm0 lea (16)(%ecx), %eax pshufb (96)(%ebx), %xmm1 pxor %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax movl (24)(%ebp), %edx sub $(1), %edx .p2align 5, 0x90 .Lcipher_loopgas_5: aesenc %xmm0, %xmm1 movdqa (%eax), %xmm0 add $(16), %eax dec %edx jnz .Lcipher_loopgas_5 aesenclast %xmm0, %xmm1 movdqa (16)(%ebx), %xmm0 movdqa %xmm1, (16)(%ebx) movdqu (%esi), %xmm1 add $(16), %esi pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %edi movl (44)(%ebp), %eax pshufb (96)(%ebx), %xmm1 pxor (32)(%ebx), %xmm1 movdqa (%eax), %xmm0 pshufd $(78), %xmm1, %xmm4 pshufd $(78), %xmm0, %xmm2 pxor %xmm1, %xmm4 pxor %xmm0, %xmm2 pclmulqdq $(0), %xmm2, %xmm4 movdqa %xmm1, %xmm3 pclmulqdq $(0), %xmm0, %xmm1 pxor %xmm2, %xmm2 pclmulqdq $(17), %xmm0, %xmm3 pxor %xmm1, %xmm4 pxor %xmm3, %xmm4 palignr $(8), %xmm4, %xmm2 pslldq $(8), %xmm4 pxor %xmm2, %xmm3 pxor %xmm4, %xmm1 movdqa %xmm1, %xmm2 psllq $(1), %xmm2 pxor %xmm1, %xmm2 psllq $(5), %xmm2 pxor %xmm1, %xmm2 psllq $(57), %xmm2 movdqa %xmm2, %xmm4 pslldq $(8), %xmm4 psrldq $(8), %xmm2 pxor %xmm4, %xmm1 pxor %xmm2, %xmm3 movdqa %xmm1, %xmm4 psrlq $(5), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm1, %xmm4 psrlq $(1), %xmm4 pxor %xmm4, %xmm1 pxor %xmm3, %xmm1 movdqa %xmm1, (32)(%ebx) subl $(16), (132)(%ebx) jg .Lblk_loopgas_5 .Lquitgas_5: movdqa (96)(%ebx), %xmm4 movdqa (%ebx), %xmm0 movdqa (16)(%ebx), %xmm1 movdqa (32)(%ebx), %xmm2 movl (36)(%ebp), %eax movl (40)(%ebp), %ecx movl (32)(%ebp), %edx pshufb %xmm4, %xmm0 movdqu %xmm0, (%eax) movdqu %xmm1, (%ecx) pshufb %xmm4, %xmm2 movdqu %xmm2, (%edx) add $(152), %esp pop %edi pop %esi pop %ebx pop %ebp ret ",16303,True,4931.017353222788,median "; Copyright © 2020, VideoLAN and dav1d authors ; Copyright © 2020, Two Orioles, LLC ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %include ""config.asm"" %include ""ext/x86/x86inc.asm"" %if HAVE_AVX512ICL && ARCH_X86_64 %macro DUP4 1-* %rep %0 times 4 db %1 %rotate 1 %endrep %endmacro %macro DIRS 16 ; cdef_directions[] %rep 4 + 16 + 4 ; 6 7 0 1 2 3 4 5 6 7 0 1 ; masking away unused bits allows us to use a single vpaddd {1to16} ; instruction instead of having to do vpbroadcastd + paddb db %13 & 0x3f, -%13 & 0x3f %rotate 1 %endrep %endmacro SECTION_RODATA 64 lut_perm_4x4: db 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 db 16, 17, 0, 1, 2, 3, 4, 5, 18, 19, 8, 9, 10, 11, 12, 13 db 20, 21, 80, 81, 82, 83, 84, 85, 22, 23, 32, 33, 34, 35, 36, 37 db 98, 99,100,101,102,103,104,105, 50, 51, 52, 53, 54, 55, 56, 57 lut_perm_4x8a: db 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 db 96, 97, 0, 1, 2, 3, 4, 5, 98, 99, 8, 9, 10, 11, 12, 13 lut_perm_4x8b:db 100,101, 16, 17, 18, 19, 20, 21,102,103, 24, 25, 26, 27, 28, 29 db 104,105, 32, 33, 34, 35, 36, 37,106,107, 40, 41, 42, 43, 44, 45 db 108,109, 48, 49, 50, 51, 52, 53,110,111, 56, 57, 58, 59, 60, 61 db 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 pd_01234567: dd 0, 1, 2, 3, 4, 5, 6, 7 lut_perm_8x8a: db 0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23 db -1, -1, 34, 35, 36, 37, 38, 39, -1, -1, 50, 51, 52, 53, 54, 55 db -1, -1, 66, 67, 68, 69, 70, 71, -1, -1, 82, 83, 84, 85, 86, 87 db 96, 97, 98, 99,100,101,102,103,112,113,114,115,116,117,118,119 lut_perm_8x8b: db 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 22, 23, 24, 25, 26, 27 db 36, 37, 38, 39, 40, 41, 42, 43, 52, 53, 54, 55, 56, 57, 58, 59 db 68, 69, 70, 71, 72, 73, 74, 75, 84, 85, 86, 87, 88, 89, 90, 91 db 100,101,102,103,104,105,106,107,116,117,118,119,120,121,122,123 edge_mask: dq 0x00003c3c3c3c0000, 0x00003f3f3f3f0000 ; 0000, 0001 dq 0x0000fcfcfcfc0000, 0x0000ffffffff0000 ; 0010, 0011 dq 0x00003c3c3c3c3c3c, 0x00003f3f3f3f3f3f ; 0100, 0101 dq 0x0000fcfcfcfcfcfc, 0x0000ffffffffffff ; 0110, 0111 dq 0x3c3c3c3c3c3c0000, 0x3f3f3f3f3f3f0000 ; 1000, 1001 dq 0xfcfcfcfcfcfc0000, 0xffffffffffff0000 ; 1010, 1011 dq 0x3c3c3c3c3c3c3c3c, 0x3f3f3f3f3f3f3f3f ; 1100, 1101 dq 0xfcfcfcfcfcfcfcfc, 0xffffffffffffffff ; 1110, 1111 px_idx: DUP4 18, 19, 20, 21, 26, 27, 28, 29, 34, 35, 36, 37, 42, 43, 44, 45 cdef_dirs: DIRS -7,-14, 1, -6, 1, 2, 1, 10, 9, 18, 8, 17, 8, 16, 8, 15 gf_shr: dq 0x0102040810204080, 0x0102040810204080 ; >> 0, >> 0 dq 0x0204081020408000, 0x0408102040800000 ; >> 1, >> 2 dq 0x0810204080000000, 0x1020408000000000 ; >> 3, >> 4 dq 0x2040800000000000, 0x4080000000000000 ; >> 5, >> 6 times 16 db 0 ; realign (introduced by cdef_dirs) end_perm_w8clip:db 0, 4, 8, 12, 2, 6, 10, 14, 16, 20, 24, 28, 18, 22, 26, 30 db 32, 36, 40, 44, 34, 38, 42, 46, 48, 52, 56, 60, 50, 54, 58, 62 db 1, 5, 9, 13, 3, 7, 11, 15, 17, 21, 25, 29, 19, 23, 27, 31 db 33, 37, 41, 45, 35, 39, 43, 47, 49, 53, 57, 61, 51, 55, 59, 63 end_perm: db 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61 db 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63 pri_tap: db 64, 64, 32, 32, 48, 48, 48, 48 ; left-shifted by 4 sec_tap: db 32, 32, 16, 16 pd_268435568: dd 268435568 SECTION .text %if WIN64 DECLARE_REG_TMP 5, 6 %else DECLARE_REG_TMP 8, 5 %endif ; lut: ; t0 t1 t2 t3 t4 t5 t6 t7 ; T0 T1 T2 T3 T4 T5 T6 T7 ; L0 L1 00 01 02 03 04 05 ; L2 L3 10 11 12 13 14 15 ; L4 L5 20 21 22 23 24 25 ; L6 L7 30 31 32 33 34 35 ; 4e 4f 40 41 42 43 44 45 ; 5e 5f 50 51 52 53 54 55 INIT_ZMM avx512icl cglobal cdef_filter_4x4, 4, 8, 13, dst, stride, left, top, pri, sec, dir, damping, edge %define base r7-edge_mask movq xmm0, [dstq+strideq*0] movhps xmm0, [dstq+strideq*1] lea r7, [edge_mask] movq xmm1, [topq+strideq*0-2] movhps xmm1, [topq+strideq*1-2] mov r6d, edgem vinserti32x4 ym0, ymm0, [leftq], 1 lea r2, [strideq*3] vinserti32x4 ym1, ymm1, [dstq+strideq*2], 1 mova m5, [base+lut_perm_4x4] vinserti32x4 m0, [dstq+r2], 2 test r6b, 0x08 ; avoid buffer overread jz .main lea r3, [dstq+strideq*4-4] vinserti32x4 m1, [r3+strideq*0], 2 vinserti32x4 m0, [r3+strideq*1], 3 .main: movifnidn prid, prim mov t0d, dirm mova m3, [base+px_idx] mov r3d, dampingm vpermi2b m5, m0, m1 ; lut vpbroadcastd m0, [base+pd_268435568] ; (1 << 28) + (7 << 4) pxor m7, m7 lea r3, [r7+r3*8] ; gf_shr + (damping - 30) * 8 vpermb m6, m3, m5 ; px cmp r6d, 0x0f jne .mask_edges ; mask edges only if required test prid, prid jz .sec_only vpaddd m1, m3, [base+cdef_dirs+(t0+2)*4] {1to16} ; dir vpermb m1, m1, m5 ; k0p0 k0p1 k1p0 k1p1 %macro CDEF_FILTER_4x4_PRI 0 vpcmpub k1, m6, m1, 6 ; px > pN psubb m2, m1, m6 lzcnt r6d, prid vpsubb m2{k1}, m6, m1 ; abs(diff) vpbroadcastb m4, prid and prid, 1 vgf2p8affineqb m9, m2, [r3+r6*8] {1to8}, 0 ; abs(diff) >> shift movifnidn t1d, secm vpbroadcastd m10, [base+pri_tap+priq*4] vpsubb m10{k1}, m7, m10 ; apply_sign(pri_tap) psubusb m4, m9 ; imax(0, pri_strength - (abs(diff) >> shift))) pminub m2, m4 vpdpbusd m0, m2, m10 ; sum %endmacro CDEF_FILTER_4x4_PRI test t1d, t1d ; sec jz .end_no_clip call .sec .end_clip: pminub m4, m6, m1 pmaxub m1, m6 pminub m5, m2, m3 pmaxub m2, m3 pminub m4, m5 pmaxub m2, m1 psrldq m1, m4, 2 psrldq m3, m2, 2 pminub m1, m4 vpcmpw k1, m0, m7, 1 vpshldd m6, m0, 8 pmaxub m2, m3 pslldq m3, m1, 1 psubw m7, m0 paddusw m0, m6 ; clip >0xff vpsubusw m0{k1}, m6, m7 ; clip <0x00 pslldq m4, m2, 1 pminub m1, m3 pmaxub m2, m4 pmaxub m0, m1 pminub m0, m2 jmp .end .sec_only: movifnidn t1d, secm call .sec .end_no_clip: vpshldd m6, m0, 8 ; (px << 8) + ((sum > -8) << 4) paddw m0, m6 ; (px << 8) + ((sum + (sum > -8) + 7) << 4) .end: mova xm1, [base+end_perm] vpermb m0, m1, m0 ; output in bits 8-15 of each dword movd [dstq+strideq*0], xm0 pextrd [dstq+strideq*1], xm0, 1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r2 ], xm0, 3 RET .mask_edges_sec_only: movifnidn t1d, secm call .mask_edges_sec jmp .end_no_clip ALIGN function_align .mask_edges: vpbroadcastq m8, [base+edge_mask+r6*8] test prid, prid jz .mask_edges_sec_only vpaddd m2, m3, [base+cdef_dirs+(t0+2)*4] {1to16} vpshufbitqmb k1, m8, m2 ; index in-range mova m1, m6 vpermb m1{k1}, m2, m5 CDEF_FILTER_4x4_PRI test t1d, t1d jz .end_no_clip call .mask_edges_sec jmp .end_clip .mask_edges_sec: vpaddd m4, m3, [base+cdef_dirs+(t0+4)*4] {1to16} vpaddd m9, m3, [base+cdef_dirs+(t0+0)*4] {1to16} vpshufbitqmb k1, m8, m4 mova m2, m6 vpermb m2{k1}, m4, m5 vpshufbitqmb k1, m8, m9 mova m3, m6 vpermb m3{k1}, m9, m5 jmp .sec_main ALIGN function_align .sec: vpaddd m2, m3, [base+cdef_dirs+(t0+4)*4] {1to16} ; dir + 2 vpaddd m3, [base+cdef_dirs+(t0+0)*4] {1to16} ; dir - 2 vpermb m2, m2, m5 ; k0s0 k0s1 k1s0 k1s1 vpermb m3, m3, m5 ; k0s2 k0s3 k1s2 k1s3 .sec_main: vpbroadcastd m8, [base+sec_tap] vpcmpub k1, m6, m2, 6 psubb m4, m2, m6 vpbroadcastb m12, t1d lzcnt t1d, t1d vpsubb m4{k1}, m6, m2 vpcmpub k2, m6, m3, 6 vpbroadcastq m11, [r3+t1*8] gf2p8affineqb m10, m4, m11, 0 psubb m5, m3, m6 mova m9, m8 vpsubb m8{k1}, m7, m8 psubusb m10, m12, m10 vpsubb m5{k2}, m6, m3 pminub m4, m10 vpdpbusd m0, m4, m8 gf2p8affineqb m11, m5, m11, 0 vpsubb m9{k2}, m7, m9 psubusb m12, m11 pminub m5, m12 vpdpbusd m0, m5, m9 ret DECLARE_REG_TMP 2, 7 ; lut top lut bottom ; t0 t1 t2 t3 t4 t5 t6 t7 L4 L5 20 21 22 23 24 25 ; T0 T1 T2 T3 T4 T5 T6 T7 L6 L7 30 31 32 33 34 35 ; L0 L1 00 01 02 03 04 05 L8 L9 40 41 42 43 44 45 ; L2 L3 10 11 12 13 14 15 La Lb 50 51 52 53 54 55 ; L4 L5 20 21 22 23 24 25 Lc Ld 60 61 62 63 64 65 ; L6 L7 30 31 32 33 34 35 Le Lf 70 71 72 73 74 75 ; L8 L9 40 41 42 43 44 45 8e 8f 80 81 82 83 84 85 ; La Lb 50 51 52 53 54 55 9e 9f 90 91 92 93 94 95 cglobal cdef_filter_4x8, 4, 9, 22, dst, stride, left, top, \\ pri, sec, dir, damping, edge %define base r8-edge_mask vpbroadcastd ym21, strided mov r6d, edgem lea r8, [edge_mask] movq xm1, [topq+strideq*0-2] pmulld ym21, [base+pd_01234567] kxnorb k1, k1, k1 movq xm2, [topq+strideq*1-2] vpgatherdq m0{k1}, [dstq+ym21] ; +0+1 +2+3 +4+5 +6+7 mova m14, [base+lut_perm_4x8a] movu m15, [base+lut_perm_4x8b] test r6b, 0x08 ; avoid buffer overread jz .main lea r7, [dstq+strideq*8-2] vinserti32x4 ym1, [r7+strideq*0], 1 vinserti32x4 ym2, [r7+strideq*1], 1 .main: punpcklqdq ym1, ym2 vinserti32x4 m1, [leftq], 2 ; -2-1 +8+9 left ____ movifnidn prid, prim mov t0d, dirm mova m16, [base+px_idx] mov r3d, dampingm vpermi2b m14, m0, m1 ; lut top vpermi2b m15, m0, m1 ; lut bottom vpbroadcastd m0, [base+pd_268435568] ; (1 << 28) + (7 << 4) pxor m20, m20 lea r3, [r8+r3*8] ; gf_shr + (damping - 30) * 8 vpermb m2, m16, m14 ; pxt vpermb m3, m16, m15 ; pxb mova m1, m0 cmp r6b, 0x0f jne .mask_edges ; mask edges only if required test prid, prid jz .sec_only vpaddd m6, m16, [base+cdef_dirs+(t0+2)*4] {1to16} ; dir vpermb m4, m6, m14 ; pNt k0p0 k0p1 k1p0 k1p1 vpermb m5, m6, m15 ; pNb %macro CDEF_FILTER_4x8_PRI 0 vpcmpub k1, m2, m4, 6 ; pxt > pNt vpcmpub k2, m3, m5, 6 ; pxb > pNb psubb m6, m4, m2 psubb m7, m5, m3 lzcnt r6d, prid vpsubb m6{k1}, m2, m4 ; abs(diff_top) vpsubb m7{k2}, m3, m5 ; abs(diff_bottom) vpbroadcastb m13, prid vpbroadcastq m9, [r3+r6*8] and prid, 1 vpbroadcastd m11, [base+pri_tap+priq*4] vgf2p8affineqb m8, m6, m9, 0 ; abs(dt) >> shift vgf2p8affineqb m9, m7, m9, 0 ; abs(db) >> shift mova m10, m11 movifnidn t1d, secm vpsubb m10{k1}, m20, m11 ; apply_sign(pri_tap_top) vpsubb m11{k2}, m20, m11 ; apply_sign(pri_tap_bottom) psubusb m12, m13, m8 ; imax(0, pri_strength - (abs(dt) >> shift))) psubusb m13, m13, m9 ; imax(0, pri_strength - (abs(db) >> shift))) pminub m6, m12 pminub m7, m13 vpdpbusd m0, m6, m10 ; sum top vpdpbusd m1, m7, m11 ; sum bottom %endmacro CDEF_FILTER_4x8_PRI test t1d, t1d ; sec jz .end_no_clip call .sec .end_clip: pminub m10, m4, m2 pminub m12, m6, m8 pminub m11, m5, m3 pminub m13, m7, m9 pmaxub m4, m2 pmaxub m6, m8 pmaxub m5, m3 pmaxub m7, m9 pminub m10, m12 pminub m11, m13 pmaxub m4, m6 pmaxub m5, m7 mov r2d, 0xAAAAAAAA kmovd k1, r2d kxnorb k2, k2, k2 ; hw lw vpshrdd m12, m0, m1, 16 ; m1lw m0hw vpshrdd m6, m10, m11, 16 ; m11lw m10hw vpshrdd m8, m4, m5, 16 ; m5lw m4hw vpblendmw m7{k1}, m10, m11 ; m11hw m10lw vpblendmw m9{k1}, m4, m5 ; m5hw m4lw vpblendmw m4{k1}, m0, m12 ; m1lw m0lw vpblendmw m5{k1}, m12, m1 ; m1hw m0hw vpshrdd m2, m3, 16 pminub m6, m7 pmaxub m8, m9 mova ym14, [base+end_perm] vpcmpw k1, m4, m20, 1 vpshldw m2, m5, 8 pslldq m7, m6, 1 pslldq m9, m8, 1 psubw m5, m20, m4 paddusw m0, m4, m2 ; clip >0xff pminub m6, m7 pmaxub m8, m9 psubusw m0{k1}, m2, m5 ; clip <0x00 pmaxub m0, m6 pminub m0, m8 vpermb m0, m14, m0 vpscatterdd [dstq+ym21]{k2}, ym0 RET .sec_only: movifnidn t1d, secm call .sec .end_no_clip: mova ym4, [base+end_perm] kxnorb k1, k1, k1 vpshldd m2, m0, 8 ; (px << 8) + ((sum > -8) << 4) vpshldd m3, m1, 8 paddw m0, m2 ; (px << 8) + ((sum + (sum > -8) + 7) << 4) paddw m1, m3 pslld m0, 16 vpshrdd m0, m1, 16 vpermb m0, m4, m0 ; output in bits 8-15 of each word vpscatterdd [dstq+ym21]{k1}, ym0 RET .mask_edges_sec_only: movifnidn t1d, secm call .mask_edges_sec jmp .end_no_clip ALIGN function_align .mask_edges: mov t1d, r6d or r6d, 8 ; top 4x4 has bottom or t1d, 4 ; bottom 4x4 has top vpbroadcastq m17, [base+edge_mask+r6*8] vpbroadcastq m18, [base+edge_mask+t1*8] test prid, prid jz .mask_edges_sec_only vpaddd m6, m16, [base+cdef_dirs+(t0+2)*4] {1to16} vpshufbitqmb k1, m17, m6 ; index in-range vpshufbitqmb k2, m18, m6 mova m4, m2 mova m5, m3 vpermb m4{k1}, m6, m14 vpermb m5{k2}, m6, m15 CDEF_FILTER_4x8_PRI test t1d, t1d jz .end_no_clip call .mask_edges_sec jmp .end_clip .mask_edges_sec: vpaddd m10, m16, [base+cdef_dirs+(t0+4)*4] {1to16} vpaddd m11, m16, [base+cdef_dirs+(t0+0)*4] {1to16} vpshufbitqmb k1, m17, m10 vpshufbitqmb k2, m18, m10 vpshufbitqmb k3, m17, m11 vpshufbitqmb k4, m18, m11 mova m6, m2 mova m7, m3 mova m8, m2 mova m9, m3 vpermb m6{k1}, m10, m14 vpermb m7{k2}, m10, m15 vpermb m8{k3}, m11, m14 vpermb m9{k4}, m11, m15 jmp .sec_main ALIGN function_align .sec: vpaddd m8, m16, [base+cdef_dirs+(t0+4)*4] {1to16} ; dir + 2 vpaddd m9, m16, [base+cdef_dirs+(t0+0)*4] {1to16} ; dir - 2 vpermb m6, m8, m14 ; pNt k0s0 k0s1 k1s0 k1s1 vpermb m7, m8, m15 ; pNb vpermb m8, m9, m14 ; pNt k0s2 k0s3 k1s2 k1s3 vpermb m9, m9, m15 ; pNb .sec_main: vpbroadcastb m18, t1d lzcnt t1d, t1d vpcmpub k1, m2, m6, 6 vpcmpub k2, m3, m7, 6 vpcmpub k3, m2, m8, 6 vpcmpub k4, m3, m9, 6 vpbroadcastq m17, [r3+t1*8] psubb m10, m6, m2 psubb m11, m7, m3 psubb m12, m8, m2 psubb m13, m9, m3 vpsubb m10{k1}, m2, m6 ; abs(dt0) vpsubb m11{k2}, m3, m7 ; abs(db0) vpsubb m12{k3}, m2, m8 ; abs(dt1) vpsubb m13{k4}, m3, m9 ; abs(db1) vpbroadcastd m19, [base+sec_tap] gf2p8affineqb m14, m10, m17, 0 ; abs(dt0) >> shift gf2p8affineqb m15, m11, m17, 0 ; abs(db0) >> shift gf2p8affineqb m16, m12, m17, 0 ; abs(dt1) >> shift gf2p8affineqb m17, m13, m17, 0 ; abs(db1) >> shift psubusb m14, m18, m14 ; imax(0, sec_strength - (abs(dt0) >> shift))) psubusb m15, m18, m15 ; imax(0, sec_strength - (abs(db0) >> shift))) psubusb m16, m18, m16 ; imax(0, sec_strength - (abs(dt1) >> shift))) psubusb m17, m18, m17 ; imax(0, sec_strength - (abs(db1) >> shift))) pminub m10, m14 pminub m11, m15 pminub m12, m16 pminub m13, m17 mova m14, m19 mova m15, m19 mova m16, m19 vpsubb m14{k1}, m20, m19 ; apply_sign(sec_tap_top_0) vpsubb m15{k2}, m20, m19 ; apply_sign(sec_tap_bottom_0) vpsubb m16{k3}, m20, m19 ; apply_sign(sec_tap_top_1) vpsubb m19{k4}, m20, m19 ; apply_sign(sec_tap_bottom_1) vpdpbusd m0, m10, m14 vpdpbusd m1, m11, m15 vpdpbusd m0, m12, m16 vpdpbusd m1, m13, m19 ret ; lut tl lut tr ; t0 t1 t2 t3 t4 t5 t6 t7 t6 t7 t8 t9 ta tb tc td ; T0 T1 T2 T3 T4 T5 T6 T7 T6 T7 T8 T9 TA TB TC TD ; L0 L1 00 01 02 03 04 05 04 05 06 07 08 09 0a 0b ; L2 L3 10 11 12 13 14 15 14 15 16 17 18 19 1a 1b ; L4 L5 20 21 22 23 24 25 24 25 26 27 28 29 2a 2b ; L6 L7 30 31 32 33 34 35 34 35 36 37 38 39 3a 3b ; L8 L9 40 41 42 43 44 45 44 45 46 47 48 49 4a 4b ; La Lb 50 51 52 53 54 55 54 55 56 57 58 59 5a 5b ; lut bl lut br ; L4 L5 20 21 22 23 24 25 24 25 26 27 28 29 2a 2b ; L6 L7 30 31 32 33 34 35 34 35 36 37 38 39 3a 3b ; L8 L9 40 41 42 43 44 45 44 45 46 47 48 49 4a 4b ; La Lb 50 51 52 53 54 55 54 55 56 57 58 59 5a 5b ; Lc Ld 60 61 62 63 64 65 64 65 66 67 68 69 6a 6b ; Le Lf 70 71 72 73 74 75 74 75 76 77 78 79 7a 7b ; 8e 8f 80 81 82 83 84 85 84 85 86 87 88 89 8a 8b ; 9e 9f 90 91 92 93 94 95 94 95 96 97 98 99 9a 9b cglobal cdef_filter_8x8, 4, 11, 32, 4*64, dst, stride, left, top, \\ pri, sec, dir, damping, edge %define base r8-edge_mask mov r6d, edgem lea r10, [dstq+strideq*4-2] movu xmm0, [topq+strideq*0-2] movu xmm1, [dstq+strideq*2-2] movu xmm2, [r10 +strideq*2 ] lea r8, [edge_mask] lea r9, [strideq*3] pmovzxwq m10, [leftq-4] vinserti32x4 ym0, ymm0, [topq+strideq*1-2], 1 vinserti32x4 ym1, ymm1, [dstq+r9 -2], 1 vinserti32x4 ym2, ymm2, [r10 +r9 ], 1 lea r7, [r10 +strideq*4 ] pmovzxwq m11, [leftq+4] vinserti32x4 m0, [dstq+strideq*0-2], 2 vinserti32x4 m1, [r10 +strideq*0 ], 2 mova m12, [base+lut_perm_8x8a] movu m13, [base+lut_perm_8x8b] vinserti32x4 m0, [dstq+strideq*1-2], 3 vinserti32x4 m1, [r10 +strideq*1 ], 3 test r6b, 0x08 ; avoid buffer overread jz .main vinserti32x4 m2, [r7 +strideq*0], 2 vinserti32x4 m2, [r7 +strideq*1], 3 .main: mov t1d, 0x11111100 mova m14, m12 mova m15, m13 kmovd k1, t1d kshiftrd k2, k1, 8 movifnidn prid, prim mov t0d, dirm mova m30, [base+px_idx] mov r3d, dampingm vpermi2b m12, m0, m1 ; lut tl vpermi2b m14, m1, m2 ; lut bl vpermi2b m13, m0, m1 ; lut tr vpermi2b m15, m1, m2 ; lut br vpblendmw m12{k1}, m12, m10 vpblendmw m14{k2}, m14, m11 vpbroadcastd m0, [base+pd_268435568] ; (1 << 28) + (7 << 4) pxor m31, m31 lea r3, [r8+r3*8] ; gf_shr + (damping - 30) * 8 vpermb m4, m30, m12 ; pxtl vpermb m5, m30, m13 ; pxtr vpermb m6, m30, m14 ; pxbl vpermb m7, m30, m15 ; pxbr mova m1, m0 mova m2, m0 mova m3, m0 cmp r6b, 0x0f jne .mask_edges ; mask edges only if required test prid, prid jz .sec_only vpaddd m11, m30, [base+cdef_dirs+(t0+2)*4] {1to16} ; dir vpermb m8, m11, m12 ; pNtl k0p0 k0p1 k1p0 k1p1 vpermb m9, m11, m13 ; pNtr vpermb m10, m11, m14 ; pNbl vpermb m11, m11, m15 ; pNbr %macro CDEF_FILTER_8x8_PRI 0 vpcmpub k1, m4, m8, 6 ; pxtl > pNtl vpcmpub k2, m5, m9, 6 ; pxtr > pNtr vpcmpub k3, m6, m10, 6 ; pxbl > pNbl vpcmpub k4, m7, m11, 6 ; pxbr > pNbr psubb m16, m8, m4 psubb m17, m9, m5 psubb m18, m10, m6 psubb m19, m11, m7 lzcnt r6d, prid vpsubb m16{k1}, m4, m8 ; abs(diff_tl) vpsubb m17{k2}, m5, m9 ; abs(diff_tr) vpsubb m18{k3}, m6, m10 ; abs(diff_bl) vpsubb m19{k4}, m7, m11 ; abs(diff_br) vpbroadcastq m28, [r3+r6*8] vpbroadcastb m29, prid and prid, 1 vpbroadcastd m27, [base+pri_tap+priq*4] vgf2p8affineqb m20, m16, m28, 0 ; abs(dtl) >> shift vgf2p8affineqb m21, m17, m28, 0 ; abs(dtr) >> shift vgf2p8affineqb m22, m18, m28, 0 ; abs(dbl) >> shift vgf2p8affineqb m23, m19, m28, 0 ; abs(dbl) >> shift mova m24, m27 mova m25, m27 mova m26, m27 movifnidn t1d, secm vpsubb m24{k1}, m31, m27 ; apply_sign(pri_tap_tl) vpsubb m25{k2}, m31, m27 ; apply_sign(pri_tap_tr) vpsubb m26{k3}, m31, m27 ; apply_sign(pri_tap_tl) vpsubb m27{k4}, m31, m27 ; apply_sign(pri_tap_tr) psubusb m20, m29, m20 ; imax(0, pri_strength - (abs(dtl) >> shift))) psubusb m21, m29, m21 ; imax(0, pri_strength - (abs(dtr) >> shift))) psubusb m22, m29, m22 ; imax(0, pri_strength - (abs(dbl) >> shift))) psubusb m23, m29, m23 ; imax(0, pri_strength - (abs(dbr) >> shift))) pminub m16, m20 pminub m17, m21 pminub m18, m22 pminub m19, m23 vpdpbusd m0, m16, m24 ; sum tl vpdpbusd m1, m17, m25 ; sum tr vpdpbusd m2, m18, m26 ; sum bl vpdpbusd m3, m19, m27 ; sum br %endmacro CDEF_FILTER_8x8_PRI test t1d, t1d ; sec jz .end_no_clip call .sec .end_clip: pminub m20, m8, m4 pminub m24, m12, m16 pminub m21, m9, m5 pminub m25, m13, m17 pminub m22, m10, m6 pminub m26, m14, m18 pminub m23, m11, m7 pminub m27, m15, m19 pmaxub m8, m4 pmaxub m12, m16 pmaxub m9, m5 pmaxub m13, m17 pmaxub m10, m6 pmaxub m14, m18 pmaxub m11, m7 pmaxub m15, m19 pminub m20, m24 pminub m21, m25 pminub m22, m26 pminub m23, m27 pmaxub m8, m12 pmaxub m9, m13 pmaxub m10, m14 pmaxub m11, m15 mov r2d, 0xAAAAAAAA kmovd k1, r2d vpshrdd m24, m0, m1, 16 vpshrdd m25, m2, m3, 16 vpshrdd m12, m20, m21, 16 vpshrdd m14, m22, m23, 16 vpshrdd m16, m8, m9, 16 vpshrdd m18, m10, m11, 16 vpblendmw m13{k1}, m20, m21 vpblendmw m15{k1}, m22, m23 vpblendmw m17{k1}, m8, m9 vpblendmw m19{k1}, m10, m11 vpblendmw m20{k1}, m0, m24 vpblendmw m21{k1}, m24, m1 vpblendmw m22{k1}, m2, m25 vpblendmw m23{k1}, m25, m3 vpshrdd m4, m5, 16 vpshrdd m6, m7, 16 pminub m12, m13 pminub m14, m15 pmaxub m16, m17 pmaxub m18, m19 mova m8, [base+end_perm_w8clip] vpcmpw k2, m20, m31, 1 vpcmpw k3, m22, m31, 1 vpshldw m4, m21, 8 vpshldw m6, m23, 8 kunpckdq k1, k1, k1 kxnorb k4, k4, k4 vpshrdw m11, m12, m14, 8 vpshrdw m15, m16, m18, 8 vpblendmb m13{k1}, m12, m14 vpblendmb m17{k1}, m16, m18 psubw m21, m31, m20 psubw m23, m31, m22 paddusw m0, m20, m4 ; clip >0xff paddusw m1, m22, m6 pminub m11, m13 pmaxub m15, m17 psubusw m0{k2}, m4, m21 ; clip <0x00 psubusw m1{k3}, m6, m23 psrlw m0, 8 vmovdqu8 m0{k1}, m1 pmaxub m0, m11 pminub m0, m15 vpermb m0, m8, m0 add r10, 2 vextracti32x4 xm1, m0, 1 vextracti32x4 xm2, m0, 2 vextracti32x4 xm3, m0, 3 movq [dstq+strideq*0], xm0 movq [dstq+strideq*2], xm1 movq [r10 +strideq*0], xm2 movq [r10 +strideq*2], xm3 movhps [dstq+strideq*1], xm0 movhps [dstq+r9 ], xm1 movhps [r10 +strideq*1], xm2 movhps [r10 +r9 ], xm3 RET .sec_only: movifnidn t1d, secm call .sec .end_no_clip: mova xm8, [base+end_perm] kxnorb k1, k1, k1 vpshldd m4, m0, 8 ; (px << 8) + ((sum > -8) << 4) vpshldd m5, m1, 8 vpshldd m6, m2, 8 vpshldd m7, m3, 8 paddw m0, m4 ; (px << 8) + ((sum + (sum > -8) + 7) << 4) paddw m1, m5 paddw m2, m6 paddw m3, m7 vpermb m0, m8, m0 vpermb m1, m8, m1 vpermb m2, m8, m2 vpermb m3, m8, m3 add r10, 2 punpckldq m4, m0, m1 punpckhdq m0, m1 punpckldq m5, m2, m3 punpckhdq m2, m3 movq [dstq+strideq*0], xm4 movq [dstq+strideq*2], xm0 movq [r10 +strideq*0], xm5 movq [r10 +strideq*2], xm2 movhps [dstq+strideq*1], xm4 movhps [dstq+r9 ], xm0 movhps [r10 +strideq*1], xm5 movhps [r10 +r9 ], xm2 RET .mask_edges_sec_only: movifnidn t1d, secm call .mask_edges_sec jmp .end_no_clip ALIGN function_align .mask_edges: mov t0d, r6d mov t1d, r6d or t0d, 0xA ; top-left 4x4 has bottom and right or t1d, 0x9 ; top-right 4x4 has bottom and left vpbroadcastq m26, [base+edge_mask+t0*8] vpbroadcastq m27, [base+edge_mask+t1*8] mov t1d, r6d or r6d, 0x6 ; bottom-left 4x4 has top and right or t1d, 0x5 ; bottom-right 4x4 has top and left vpbroadcastq m28, [base+edge_mask+r6*8] vpbroadcastq m29, [base+edge_mask+t1*8] mov t0d, dirm test prid, prid jz .mask_edges_sec_only vpaddd m20, m30, [base+cdef_dirs+(t0+2)*4] {1to16} vpshufbitqmb k1, m26, m20 ; index in-range vpshufbitqmb k2, m27, m20 vpshufbitqmb k3, m28, m20 vpshufbitqmb k4, m29, m20 mova m8, m4 mova m9, m5 mova m10, m6 mova m11, m7 vpermb m8{k1}, m20, m12 vpermb m9{k2}, m20, m13 vpermb m10{k3}, m20, m14 vpermb m11{k4}, m20, m15 mova [rsp+0x00], m26 mova [rsp+0x40], m27 mova [rsp+0x80], m28 mova [rsp+0xC0], m29 CDEF_FILTER_8x8_PRI test t1d, t1d jz .end_no_clip mova m26, [rsp+0x00] mova m27, [rsp+0x40] mova m28, [rsp+0x80] mova m29, [rsp+0xC0] call .mask_edges_sec jmp .end_clip .mask_edges_sec: vpaddd m20, m30, [base+cdef_dirs+(t0+4)*4] {1to16} vpaddd m21, m30, [base+cdef_dirs+(t0+0)*4] {1to16} vpshufbitqmb k1, m26, m20 vpshufbitqmb k2, m27, m20 vpshufbitqmb k3, m28, m20 vpshufbitqmb k4, m29, m20 mova m16, m4 mova m17, m5 mova m18, m6 mova m19, m7 vpermb m16{k1}, m20, m12 vpermb m17{k2}, m20, m13 vpermb m18{k3}, m20, m14 vpermb m19{k4}, m20, m15 vpshufbitqmb k1, m26, m21 vpshufbitqmb k2, m27, m21 vpshufbitqmb k3, m28, m21 vpshufbitqmb k4, m29, m21 vpermb m12, m21, m12 vpermb m13, m21, m13 vpermb m14, m21, m14 vpermb m15, m21, m15 vpblendmb m12{k1}, m4, m12 vpblendmb m13{k2}, m5, m13 vpblendmb m14{k3}, m6, m14 vpblendmb m15{k4}, m7, m15 jmp .sec_main ALIGN function_align .sec: vpaddd m20, m30, [base+cdef_dirs+(t0+4)*4] {1to16} ; dir + 2 vpaddd m21, m30, [base+cdef_dirs+(t0+0)*4] {1to16} ; dir - 2 vpermb m16, m20, m12 ; pNtl k0s0 k0s1 k1s0 k1s1 vpermb m17, m20, m13 ; pNtr vpermb m18, m20, m14 ; pNbl vpermb m19, m20, m15 ; pNbr vpermb m12, m21, m12 ; pNtl k0s2 k0s3 k1s2 k1s3 vpermb m13, m21, m13 ; pNtr vpermb m14, m21, m14 ; pNbl vpermb m15, m21, m15 ; pNbr .sec_main: %macro CDEF_FILTER_8x8_SEC 4-5 0 ; load constants vpcmpub k1, m4, %1, 6 vpcmpub k2, m5, %2, 6 vpcmpub k3, m6, %3, 6 vpcmpub k4, m7, %4, 6 psubb m20, %1, m4 psubb m21, %2, m5 psubb m22, %3, m6 psubb m23, %4, m7 %if %5 vpbroadcastb m28, t1d lzcnt t1d, t1d vpbroadcastq m29, [r3+t1*8] %endif vpsubb m20{k1}, m4, %1 vpsubb m21{k2}, m5, %2 vpsubb m22{k3}, m6, %3 vpsubb m23{k4}, m7, %4 gf2p8affineqb m24, m20, m29, 0 gf2p8affineqb m25, m21, m29, 0 gf2p8affineqb m26, m22, m29, 0 gf2p8affineqb m27, m23, m29, 0 %if %5 vpbroadcastd m30, [base+sec_tap] %endif psubusb m24, m28, m24 psubusb m25, m28, m25 psubusb m26, m28, m26 psubusb m27, m28, m27 pminub m20, m24 pminub m21, m25 pminub m22, m26 pminub m23, m27 mova m24, m30 mova m25, m30 mova m26, m30 mova m27, m30 vpsubb m24{k1}, m31, m30 vpsubb m25{k2}, m31, m30 vpsubb m26{k3}, m31, m30 vpsubb m27{k4}, m31, m30 vpdpbusd m0, m20, m24 vpdpbusd m1, m21, m25 vpdpbusd m2, m22, m26 vpdpbusd m3, m23, m27 %endmacro CDEF_FILTER_8x8_SEC m16, m17, m18, m19, 1 CDEF_FILTER_8x8_SEC m12, m13, m14, m15 ret %endif ; HAVE_AVX512ICL && ARCH_X86_64 ",16303,True,3538.414835812025,median "/* PowerSaveTest.ino This test will turn on and off your display for two seconds. If the text ""power off"" is visible on your display, then power save mode does not work with your display. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/) Copyright (c) 2016, olikraus@gmail.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C #include #endif // Please UNCOMMENT one of the contructor lines below // U8g2 Contructor List (Picture Loop Page Buffer) // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected //U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition) //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_128X64_ALT0_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display //U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 17, /* reset=*/ U8X8_PIN_NONE); // ESP32 Thing, pure SW emulated I2C //U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 16, /* data=*/ 17); // ESP32 Thing, HW I2C with pin remapping //U8G2_SSD1306_128X64_NONAME_1_6800 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_NONAME_1_8080 u8g2(U8G2_R0, 13, 11, 2, 3, 4, 5, 6, A4, /*enable=*/ 7, /*cs=*/ 10, /*dc=*/ 9, /*reset=*/ 8); //U8G2_SSD1306_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SSD1306_128X64_ALT0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but may solve the ""every 2nd line skipped"" problem //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SH1106_128X64_VCOMH0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but maximizes setContrast() range //U8G2_SH1106_128X64_WINSTAR_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // same as the NONAME variant, but uses updated SH1106 init sequence //U8G2_SH1106_72X40_WISE_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_64X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1107_128X128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); //U8G2_SH1107_SEEED_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1108_160X160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SH1122_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 21, /* data=*/ 20, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather M0 Basic Proto + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED //U8G2_SSD1306_128X32_UNIVISION_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ SCL, /* data=*/ SDA); // pin remapping with ESP8266 HW I2C //U8G2_SSD1306_64X48_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.66"" OLED breakout board, Uno: A4=SDA, A5=SCL, 5V powered //U8G2_SSD1306_48X64_WINSTAR_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_64X32_1F_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1306_96X16_ER_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // EastRising 0.69"" OLED //U8G2_SSD1322_NHD_256X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_256X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Enable U8G2_16BIT in u8g2.h //U8G2_SSD1322_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1322_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1325_NHD_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD0323_OS128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1326_ER_256X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // experimental driver for ER-OLED018-1 //U8G2_SSD1327_SEEED_96X96_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_SEEED_96X96_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Seeedstudio Grove OLED 96x96 //U8G2_SSD1327_EA_W128128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_EA_W128128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ 5, /* data=*/ 4, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_EA_W128128_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_SSD1327_MIDAS_128X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1327_MIDAS_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1329_128X96_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X32_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1305_128X64_ADAFRUIT_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME0_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1309_128X64_NONAME2_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_SSD1317_96X96_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LD7032_60X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* cs=*/ 9, /* dc=*/ 10, /* reset=*/ 8); // SW SPI Nano Board //U8G2_LD7032_60X32_1_4W_SW_I2C u8g2(U8G2_R0, /* clock=*/ 11, /* data=*/ 12, /* reset=*/ U8X8_PIN_NONE); // NOT TESTED! //U8G2_UC1701_EA_DOGS102_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1701_EA_DOGS102_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCD8544_84X48_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Nokia 5110 Display //U8G2_PCF8812_96X65_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_PCF8812_96X65_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Could be also PCF8814 //U8G2_HX1230_96X68_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_HX1230_96X68_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_KS0108_128X64_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ U8X8_PIN_NONE, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_KS0108_ERM19264_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*dc=*/ 17, /*cs0=*/ 14, /*cs1=*/ 15, /*cs2=*/ 16, /* reset=*/ U8X8_PIN_NONE); // Set R/W to low! //U8G2_ST7920_192X32_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ U8X8_PIN_NONE, /*dc=*/ 17, /*reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_192X32_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18 /* A4 */, /*cs=*/ U8X8_PIN_NONE, /*dc/rs=*/ 17 /* A3 */, /*reset=*/ 15 /* A1 */); // Remember to set R/W to 0 //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 18 /* A4 */ , /* data=*/ 16 /* A2 */, /* CS=*/ 17 /* A3 */, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_64128N_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_EA_DOGM132_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_EA_DOGM132_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); // DOGM132 Shield //U8G2_ST7565_ZOLEN_128X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ZOLEN_128X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LM6059_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LM6059_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Adafruit ST7565 GLCD //U8G2_ST7565_LX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_LX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_ERC12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12832_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_NHD_C12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7565_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_PI_132X64_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_PI_132X64_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); // Pax Instruments Shield, LCD_BL=6 //U8G2_ST7567_JLX12864_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_JLX12864_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_ENH_DG128064I_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7567_64X32_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); //U8G2_ST75256_JLX172104_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX172104_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 9, /* data=*/ 8, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 7, /* dc=*/ 6, /* reset=*/ 5); // MKR Zero, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX256160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Uno, Enable U8g2 16 bit mode for this display //U8G2_ST75256_JLX240160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX240160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST75256_JLX25664_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, enable U8g2 16 bit mode for this display //U8G2_NT7534_TG12864R_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_NT7534_TG12864R_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_ST7588_JLX12864_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ 5); //U8G2_ST7588_JLX12864_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ 5); //U8G2_IST3020_ERC19264_1_6800 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 28, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect WR pin with GND //U8G2_IST3020_ERC19264_1_8080 u8g2(U8G2_R0, 44, 43, 42, 41, 40, 39, 38, 37, /*enable=*/ 29, /*cs=*/ 32, /*dc=*/ 30, /*reset=*/ 31); // Connect RD pin with 3.3V //U8G2_IST3020_ERC19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_LC7981_160X80_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_160X160_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_LC7981_240X64_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RW with GND //U8G2_SED1520_122X32_1 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*dc=*/ A0, /*e1=*/ A3, /*e2=*/ A2, /* reset=*/ A4); // Set R/W to low! //U8G2_T6963_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_256X64_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_T6963_160X80_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect RD with +5V, FS0 and FS1 with GND //U8G2_SED1330_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_SED1330_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_RA8835_NHD_240X128_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // Connect /RD = E with +5V, enable is /WR = RW, FG with GND, 14=Uno Pin A0 //U8G2_RA8835_NHD_240X128_1_6800 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 17, /*cs=*/ 14, /*dc=*/ 15, /*reset=*/ 16); // A0 is dc pin, /WR = RW = GND, enable is /RD = E //U8G2_UC1601_128X32_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1601_128X32_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1604_JLX19264_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_ERC24064_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1608_ERC240120_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); //U8G2_UC1608_240X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due ERC24064-1 Test Setup //U8G2_UC1610_EA_DOGXL160_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1610_EA_DOGXL160_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ U8X8_PIN_NONE); //U8G2_UC1611_EA_DOGM240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGM240 Test Board //U8G2_UC1611_EA_DOGM240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_2ND_HW_I2C u8g2(U8G2_R0, /* reset=*/ 8); // Due, 2nd I2C, DOGXL240 Test Board //U8G2_UC1611_EA_DOGXL240_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // SW SPI, Due DOGXL240 Test Board //U8G2_UC1611_EW50850_1_8080 u8g2(U8G2_R0, 8, 9, 10, 11, 4, 5, 6, 7, /*enable=*/ 18, /*cs=*/ 3, /*dc=*/ 16, /*reset=*/ 16); // 240x160, Connect RD/WR1 pin with 3.3V, CS is aktive high //U8G2_UC1638_160X128_1_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 2, /* dc=*/ 3, /* reset=*/ 4); // Not tested //U8G2_SSD1606_172X72_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display //U8G2_SSD1607_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // eInk/ePaper Display, original LUT from embedded artists //U8G2_SSD1607_GD_200X200_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // Good Display //U8G2_IL3820_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // WaveShare 2.9 inch eInk/ePaper Display, enable 16 bit mode for this display! //U8G2_IL3820_V2_296X128_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8); // ePaper Display, lesser flickering and faster speed, enable 16 bit mode for this display! //U8G2_LS013B7DH03_128X128_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display //U8G2_LS027B7DH01_400X240_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ U8X8_PIN_NONE, /* reset=*/ 8); // there is no DC line for this display // End of constructor list void setup(void) { u8g2.begin(); u8g2.setFont(u8g2_font_6x10_tr); } void draw(const char *s) { u8g2.firstPage(); do { u8g2.drawStr(2,15,""PowerSaveTest""); u8g2.drawStr(2,30,s); u8g2.drawFrame(0,0,u8g2.getDisplayWidth(),u8g2.getDisplayHeight() ); } while ( u8g2.nextPage() ); delay(2000); } void loop(void) { u8g2.setPowerSave(0); draw(""power on / x""); u8g2.setPowerSave(1); draw(""power off / x""); u8g2.setPowerSave(0); draw(""power on / +""); u8g2.setPowerSave(1); draw(""power off / +""); } ",12512,True,3777.166590743267,median "/* ESPrinkler2 -- Web Server Enabled Sprinkler Controller https://github.com/n0bel/ESPrinkler2 Original Base code is https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser.ino Base Code Copyright (c) 2015 Hristo Gochkov. All rights reserved. LGPL This Code Copyright (c) 2017 Kevin Uhlir. All rights reserved. LGPL This is a rewrite of ESPrinkler https://github.com/n0bel/ESPrinkler but based on the Arduino toolchain instead of ExperssIF. This should make the project more accessable to people. */ /* Requirements: Arduino-1.8.3 ESP8266/Arduino :Additional Boards Manager URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json Time 1.5.0 https://github.com/PaulStoffregen/Time SimpleTimer https://github.com/jfturcot/SimpleTimer (http://playground.arduino.cc/Code/SimpleTimer) NtpClientLib 2.0.5 https://github.com/gmag11/NtpClient ArduinoJson 5.6.7 https://github.com/bblanchon/ArduinoJson (https://bblanchon.github.io/ArduinoJson/) U8G2Lib 2.13.5 https://github.com/olikraus/u8g2 orbitalair-arduino-rtc-pcf8563 https://bitbucket.org/orbitalair/arduino_rtc_pcf8563/downloads/ (https://playground.arduino.cc/Main/RTC-PCF8563) Don't forget to restart the Arduino IDE after installing these things. Set your esp settings.. the board, program method, flash size and spiffs size. This uses the SPIFFS file system. So we need to load that in your esp-xx first. Upload the contents of the data folder with MkSPIFFS Tool (""ESP8266 Sketch Data Upload"" in Tools menu in Arduino IDE) Then compile and upload the .ino. */ // Configurable Options // Include code for PCF8563 RTC #define INCLUDE_PCF8563 // Include code for DS1307 RTC #define INCLUDE_DS1307 // Where Do you want to send debug output? #define DBG_OUTPUT_PORT Serial // Uncommment if you'd like even more debug information // #define EXTRA_DEBUG // End of Config #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define EEPROM_SIZE 512 #ifdef INCLUDE_PCF8563 #include #endif #ifdef INCLUDE_DS1307 #include #endif #include ""./version.h"" U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R2, U8X8_PIN_NONE); #ifdef INCLUDE_PCF8563 Rtc_Pcf8563 Rtc_Pcf8563; #endif #ifdef INCLUDE_DS1307 RtcDS1307 Rtc_Ds1307(Wire); #endif const char* configFile = ""/config.json""; // The config file name const char* schedFile = ""/sched.json""; // The sched file name const char* buttonsFile = ""/buttons.json""; // The buttons file name // Note that these are the default values if no /config.json exists, // or items are missing from it. char ssid[31] = { """" }; // This is the access point to connect to #define EEPROM_SSID 0 // where the ssid is kept in EEPROM char password[31] = { """" }; // And its password #define EEPROM_PASSWORD 32 // where the password is kept in EEPROM char host[31] = { ""*"" }; // The host name .local (mdns) hostname #define EEPROM_HOST 64 // where the host is kept in EEPROM char assid[31] = { """" }; // This is the access point to connect to char apassword[31] = { """" }; // And its password int offsetGMT = 0; // Local timezone offset in seconds char offsetGMTstring[10] = { ""-1"" }; // String version of it #define EEPROM_OFFSET_GMT 96 // where the host is kept in EEPROM int relayState = 0; // The current state of the relayState bool apMode = false; // Are we in Acess Point mode? bool dnsStarted = false; // Did we start dns? #ifdef INCLUDE_PCF8563 bool hasPcf8563 = false; // we found a PCF8563 #endif #ifdef INCLUDE_DS1307 bool hasDs1307 = false; // we found a PCF8563 #endif bool hasRtc = false; // do we have an rtc bool rtcValid = false; // does it have a valid time time_t bootTime = 0; String bootTimeString; char timeServer[31] = { ""pool.ntp.org"" }; // the NTP timeServer to use #define MAX_SCHED 30 struct _sched { int zone; // 1-8 and 100 for reset int days; // day bits 0-6 = sunday-saturday and 8 and 9 are even and odd time_t start; // seconds like 02:00 am is 120 * 3600 int duration; // minutes time_t begin; // begin date time_t end; // end date time_t next; // next time this should turn on a relay time_t stop; // when the relay should turn off } sched[MAX_SCHED] = { 0 }; // DNS server const byte DNS_PORT = 53; DNSServer dnsServer; ESP8266WebServer server(80); // The Web Server File fsUploadFile; // holds the current upload when files are // uploaded (see edit.htm) SimpleTimer timer; int priorPct = -1; int fullSize = -1; // format bytes String formatBytes(size_t bytes) { if (bytes < 1024) { return String(bytes)+""B""; } else if (bytes < (1024 * 1024)) { return String(bytes/1024.0)+""KB""; } else if (bytes < (1024 * 1024 * 1024)) { return String(bytes/1024.0/1024.0)+""MB""; } else { return String(bytes/1024.0/1024.0/1024.0)+""GB""; } } String getContentType(String filename) { if (server.hasArg(""download"")) return ""application/octet-stream""; else if (filename.endsWith("".htm"")) return ""text/html""; else if (filename.endsWith("".html"")) return ""text/html""; else if (filename.endsWith("".css"")) return ""text/css""; else if (filename.endsWith("".js"")) return ""application/javascript""; else if (filename.endsWith("".json"")) return ""text/json""; else if (filename.endsWith("".png"")) return ""image/png""; else if (filename.endsWith("".gif"")) return ""image/gif""; else if (filename.endsWith("".jpg"")) return ""image/jpeg""; else if (filename.endsWith("".ico"")) return ""image/x-icon""; else if (filename.endsWith("".xml"")) return ""text/xml""; else if (filename.endsWith("".pdf"")) return ""application/x-pdf""; else if (filename.endsWith("".zip"")) return ""application/x-zip""; else if (filename.endsWith("".gz"")) return ""application/x-gzip""; return ""text/plain""; } bool handleFileRead(String path) { DBG_OUTPUT_PORT.printf("" handleFileRead: %s\\n"", path.c_str()); displayStatus(2, ""served %s"", path.c_str()); if (path.endsWith(""/"")) path += ""index.html""; String ims = server.header(""If-Modified-Since""); String contentType = getContentType(path); String pathWithGz = path + "".gz""; if (SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)) { if (bootTimeString != """" && bootTimeString == ims) { server.send(304, contentType, ""Not Modified""); return true; } if (SPIFFS.exists(pathWithGz)) path += "".gz""; File file = SPIFFS.open(path, ""r""); if (path.indexOf("".json"") < 0 || path.indexOf(""-schema.json"") > -1) { server.sendHeader(""Cache-Control"", ""public, max-age=3600""); if (bootTime > 0) { server.sendHeader(""Last-Modified"", bootTimeString); } } else { server.sendHeader(""Cache-Control"", ""public, max-age=0""); } size_t sent = server.streamFile(file, contentType); file.close(); return true; } DBG_OUTPUT_PORT.printf(""%s not found\\n"", path.c_str()); return false; } void handleFileUpdate() { HTTPUpload& update = server.upload(); if (update.status == UPLOAD_FILE_START) { String filename = update.filename; fullSize = atoi(server.header(""Content-Length"").c_str()); priorPct = 0; DBG_OUTPUT_PORT.printf(""handleFileUpdate Name: %s %d\\n"", filename.c_str(), fullSize); displayStatus(1, ""HTTP Update start""); if (server.uri() == ""/spiffsupdate"") { if (!Update.begin(fullSize, U_SPIFFS)) { Update.printError(DBG_OUTPUT_PORT); } } else { uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; if (!Update.begin(maxSketchSpace)) { Update.printError(DBG_OUTPUT_PORT); } } } else if (update.status == UPLOAD_FILE_WRITE) { int p = update.totalSize / (fullSize / 100); if ((p - priorPct) >= 5) { priorPct = p; DBG_OUTPUT_PORT.printf(""Update: %u%%\\n"", p); displayStatus(1, ""HTTP Update %u%"", p); } if (Update.write(update.buf, update.currentSize) != update.currentSize) { Update.printError(DBG_OUTPUT_PORT); displayStatus(1, ""HTTP Update Failed""); } } else if (update.status == UPLOAD_FILE_END) { if (Update.end(true)) { DBG_OUTPUT_PORT.printf(""Update Success: %u\\nRebooting...\\n"", update.totalSize); displayStatus(1, ""HTTP Update End""); } else { Update.printError(DBG_OUTPUT_PORT); } } else if (update.status == UPLOAD_FILE_ABORTED) { Update.end(); DBG_OUTPUT_PORT.printf(""Update aborted.\\n""); displayStatus(1, ""HTTP Update aborted""); } } void afterFileUpdate() { server.sendHeader(""Location"", String(Update.hasError() ? ""/updatefailed.html"" : ""/updatesuccessful.html""), true); server.send(301, ""text/html"", """"); doRestart(); } void handleFileUpload() { if (server.uri() != ""/edit"") return; HTTPUpload& upload = server.upload(); if (upload.status == UPLOAD_FILE_START) { String filename = upload.filename; if (!filename.startsWith(""/"")) filename = ""/""+filename; displayStatus(2, ""upload %s"", filename.c_str()); DBG_OUTPUT_PORT.printf(""handleFileUpload Name: %s\\n"", filename.c_str()); fsUploadFile = SPIFFS.open(filename, ""w""); filename = String(); } else if (upload.status == UPLOAD_FILE_WRITE) { // DBG_OUTPUT_PORT.printf(""handleFileUpload Data: %s\\n"",upload.currentSize); if (fsUploadFile) fsUploadFile.write(upload.buf, upload.currentSize); } else if (upload.status == UPLOAD_FILE_END) { if (fsUploadFile) fsUploadFile.close(); DBG_OUTPUT_PORT.printf(""handleFileUpload Size: %d\\n"", upload.totalSize); if (upload.filename == configFile) { loadConfig(); } if (upload.filename == schedFile) { loadSched(); } } } void handleFileDelete() { if (server.args() == 0) return server.send(500, ""text/plain"", ""BAD ARGS""); String path = server.arg(0); DBG_OUTPUT_PORT.printf(""handleFileDelete: %s\\n"", path.c_str()); displayStatus(2, ""deleted %s"", path.c_str()); if (path == ""/"") return server.send(500, ""text/plain"", ""BAD PATH""); if (!SPIFFS.exists(path)) return server.send(404, ""text/plain"", ""FileNotFound""); SPIFFS.remove(path); server.send(200, ""text/plain"", """"); path = String(); } void handleFileCreate() { if (server.args() == 0) return server.send(500, ""text/plain"", ""BAD ARGS""); String path = server.arg(0); DBG_OUTPUT_PORT.printf(""handleFileCreate: %s\\n"", path.c_str()); displayStatus(2, ""created %s"", path.c_str()); if (path == ""/"") return server.send(500, ""text/plain"", ""BAD PATH""); if (SPIFFS.exists(path)) return server.send(500, ""text/plain"", ""FILE EXISTS""); File file = SPIFFS.open(path, ""w""); if (file) file.close(); else return server.send(500, ""text/plain"", ""CREATE FAILED""); server.send(200, ""text/plain"", """"); path = String(); } void handleFileList() { if (!server.hasArg(""dir"")) { server.send(500, ""text/plain"", ""BAD ARGS""); return; } String path = server.arg(""dir""); DBG_OUTPUT_PORT.printf("" handleFileList: %s\\n"", path.c_str()); displayStatus(2, ""list %s"", path.c_str()); Dir dir = SPIFFS.openDir(path); path = String(); String output = ""[""; while (dir.next()) { File entry = dir.openFile(""r""); if (output != ""["") output += ','; bool isDir = false; output += ""{\\""type\\"":\\""""; output += (isDir)?""dir"":""file""; output += ""\\"",\\""name\\"":\\""""; output += String(entry.name()).substring(1); output += ""\\""}""; entry.close(); } output += ""]""; server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/json"", output); } void eeSave(); // forward ref void loadConfig() { if (SPIFFS.exists(configFile)) { File file = SPIFFS.open(configFile, ""r""); char json[500]; memset(json, 0, sizeof(json)); file.readBytes(json, sizeof(json)); file.close(); StaticJsonBuffer<500> jsonBuffer; JsonObject& root = jsonBuffer.parseObject(json); if (!root.success()) { DBG_OUTPUT_PORT.printf(""json parse of configFile failed.\\n""); } else { const char *t; t = root[""ssid""]; if (t && t[0] != '*') { strncpy(ssid, t, 30); t = root[""password""]; if (t) { strncpy(password, t, 30); } } t = root[""assid""]; if (t) { strncpy(assid, t, 30); } t = root[""apassword""]; if (t) { strncpy(apassword, t, 30); } t = root[""host""]; if (t) { strncpy(host, t, 30); } t = root[""timeServer""]; if (t) { strncpy(timeServer, t, 30); } t = root[""offsetGMT""]; if (t) { strncpy(offsetGMTstring, t, 10); } int g = atoi(offsetGMTstring); if (g != -1) { offsetGMT = g; } setHostName(); displayStatus(2, host); eeSave(); DBG_OUTPUT_PORT.printf(""Config: host: %s ssid: %s assid: %s\\n"", host, ssid, assid); DBG_OUTPUT_PORT.printf("" timeServer: %s offsetGMT:%d\\n"", timeServer, offsetGMT); } } else { DBG_OUTPUT_PORT.printf(""config file: %s not found\\n"", configFile); } } int computeDayFromTm(tmElements_t *tm) { // bits 0-6 = day of week // bits 8 == even Day // bit 9 == odd Day return (1 << (tm->Wday - 1)) | ( 1 << ((tm->Day & 1) + 8)); } #ifdef EXTRA_DEBUG void dumpSched(const char *m, struct _sched *s) { DBG_OUTPUT_PORT.printf( ""%s: %08x z:%d s:%d d:%02x b:%d e:%d n:%d o:%d d:%d\\n"", m, s, s->zone, s->start, s->days, s->begin, s->end, s->next, s->stop, s->duration); DBG_OUTPUT_PORT.printf(""%s: next:%s"", m, timeStr(s->next+offsetGMT)); DBG_OUTPUT_PORT.printf("" stop:%s\\n"", timeStr(s->stop+offsetGMT)); } #endif void xxdoRestart() { ESP.restart(); } void doRestart() { displayStatus(0, ""Restarting.....""); DBG_OUTPUT_PORT.printf(""Restart in 5 seconds.\\n""); timer.setTimeout(5000, []() { ESP.restart(); }); } void computeNext(struct _sched *s) { if (now() < 10000000) { s->next = s->stop = 0; return; } time_t midnightLocal = (now() + offsetGMT) / 86400; if (s->begin > 10000000 && s->begin > now()) midnightLocal = s->begin / 86400; midnightLocal = midnightLocal * 86400; time_t midnightLocalAsGmt = midnightLocal - offsetGMT; int day = 0xffff; s->next = midnightLocalAsGmt + s->start - 86400; do { s->next += 86400; tmElements_t tm; breakTime(s->next + offsetGMT, tm); day = computeDayFromTm(&tm); if (s->next > s->end) { s->next = 0; break; } #ifdef EXTRA_DEBUG dumpSched(""computeNext"", s); DBG_OUTPUT_PORT.printf(""computeNext: day=%02x tm.Day=%d tm.Wday=%d\\n"", day, tm.Day, tm.Wday); #endif } while (now() >= s->next || (day & (s->days)) == 0); if (s->stop == 0 && s->next > 0) { s->stop = s->next + s->duration; } } void checkSched() { time_t timeNow = now(); for (int i = 0; i < MAX_SCHED; i++) { if (sched[i].zone > 0) { #ifdef EXTRA_DEBUG dumpSched(""checkSched"", &sched[i]); #endif if (sched[i].stop > 0 && timeNow >= sched[i].stop) { sched[i].stop = 0; if (sched[i].next > 0) { sched[i].stop = sched[i].next + sched[i].duration; } if (sched[i].zone < 9) { relayState &= ~(1 << (sched[i].zone - 1)); setRelays(); } } if (sched[i].next > 0 && timeNow >= sched[i].next) { if (sched[i].zone == 100) { doRestart(); } else { relayState |= (1 << (sched[i].zone - 1)); setRelays(); } computeNext(&sched[i]); } } } } void recalcSched() { for (int i = 0; i < MAX_SCHED; i++) { if (sched[i].zone > 0) { computeNext(&sched[i]); } } } void loadSched() { if (SPIFFS.exists(schedFile)) { File file = SPIFFS.open(schedFile, ""r""); char json[1000]; memset(json, 0, sizeof(json)); file.readBytes(json, sizeof(json)); file.close(); StaticJsonBuffer<1000> jsonBuffer; JsonArray& root = jsonBuffer.parseArray(json); if (!root.success()) { DBG_OUTPUT_PORT.printf(""json parse of schedFile failed.\\n""); } else { tmElements_t tm; relayState = 0; setRelays(); for (int i = 0; i < MAX_SCHED; i++) { const char *zoneString = root[i][""zone""]; const char *startTime = root[i][""startTime""]; sched[i].zone = 0; sched[i].next = 0; sched[i].duration = 0; sched[i].stop = 0; if (zoneString && zoneString[0] != '\\0' && startTime && startTime[0] != '\\0') { // if (strstr(zoneString, ""Zone "") == zoneString) { sched[i].zone = zoneString[5] - '0'; } if (strstr(zoneString, ""Restart"") == zoneString) { sched[i].zone = 100; } sched[i].start = atoi(startTime) * 3600 + atoi(startTime + 3) * 60; const char *beginDate = root[i][""begin""]; if (!beginDate || beginDate[0] == '\\0') { sched[i].begin = 10000000; // more or less beginning of time } else { tm.Second = tm.Hour = tm.Minute = tm.Wday = 0; tm.Year = atoi(beginDate) - 1970; tm.Month = atoi(beginDate+5); tm.Day = atoi(beginDate+8); sched[i].begin = makeTime(tm) - offsetGMT; } const char *endDate = root[i][""end""]; if (!endDate || endDate[0] == '\\0') { sched[i].end = 0x7fffffff; // more or less end of time } else { tm.Second = tm.Hour = tm.Minute = tm.Wday = 0; tm.Year = atoi(endDate) - 1970; tm.Month = atoi(endDate+5); tm.Day = atoi(endDate+8); sched[i].end = makeTime(tm) - offsetGMT; } const char *duration = root[i][""duration""]; if (!duration || duration[0] == '\\0') { sched[i].duration = 15 * 60; // default = 15 minutes } else { sched[i].duration = atoi(duration) * 60; } sched[i].days = 0; for (int j = 0; j < 10; j++) { const char *dayString = root[i][""days""][j]; if (!dayString) break; if (strstr(dayString, ""Sunday"") == dayString ) sched[i].days |= 1 << 0; if (strstr(dayString, ""Monday"") == dayString ) sched[i].days |= 1 << 1; if (strstr(dayString, ""Tuesday"") == dayString ) sched[i].days |= 1 << 2; if (strstr(dayString, ""Wednesday"") == dayString ) sched[i].days |= 1 << 3; if (strstr(dayString, ""Thursday"") == dayString ) sched[i].days |= 1 << 4; if (strstr(dayString, ""Friday"") == dayString ) sched[i].days |= 1 << 5; if (strstr(dayString, ""Saturday"") == dayString ) sched[i].days |= 1 << 6; if (strstr(dayString, ""Even"") == dayString ) sched[i].days |= 1 << 8; if (strstr(dayString, ""Odd"") == dayString ) sched[i].days |= 1 << 9; } if (sched[i].days == 0) sched[i].days = 0xffff; computeNext(&sched[i]); #ifdef EXTRA_DEBUG dumpSched(""schedlist"", &sched[i]); #endif DBG_OUTPUT_PORT.printf(""schedule %d loaded next: %s duration %d\\n"", i, timeStr(sched[i].next + offsetGMT), sched[i].duration); } } } } else { DBG_OUTPUT_PORT.printf(""sched file: %s not found\\n"", schedFile); } } void setRelays() { DBG_OUTPUT_PORT.printf(""set relays=%02x\\n"", relayState); SPI.transfer(relayState); u8g2.setDrawColor(0); u8g2.drawBox(0, 64 - 12, 128, 12); for (int i = 0; i < 8; i++) { if (relayState & (1 << i)) { u8g2.setDrawColor(1); u8g2.drawBox(i * 16 + 2, 64 - 12, 12, 12); u8g2.setDrawColor(0); u8g2.drawGlyph(i * 16 + 6, 64 - 11, i + '1'); } else { u8g2.setDrawColor(0); u8g2.drawBox(i * 16 + 2, 64 - 12, 12, 12); u8g2.setDrawColor(1); u8g2.drawGlyph(i * 16 + 6, 64 - 11, i + '1'); } } u8g2.sendBuffer(); } void displayStatus(int line, const char *fmt, ...) { int count; char *buffer; va_list Arglist; count = 0; buffer = reinterpret_cast(malloc(128)); if (buffer == NULL) return; va_start(Arglist, fmt); vsnprintf(buffer, 128, fmt, Arglist); // NOLINT u8g2.setDrawColor(0); u8g2.drawBox(0, line * 12, 128, 12); u8g2.setDrawColor(1); u8g2.drawStr(0, line * 12, buffer); u8g2.sendBuffer(); free(buffer); } void clearTimedFunc(int *id, const char *name) { DBG_OUTPUT_PORT.printf(""clearTimedFunc %s\\n"", name); if (*id > -1) { DBG_OUTPUT_PORT.printf(""clearingTimer id=%d\\n"", *id); timer.disable(*id); timer.deleteTimer(*id); } *id = -1; } int setTimedFunc(bool repeat, int *id, sint32_t t, void (*func)(), const char *name) { if (*id > -1) { #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""clearingTimer id=%d\\n"", *id); #endif timer.disable(*id); timer.deleteTimer(*id); } *id = -1; if (t > 0) { if (repeat) { *id = timer.setInterval(t, func); } else { *id = timer.setTimeout(t, func); } } #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""setTimedFunc %d %d %s %08x id=%d\\n"", repeat, t, name, func, *id); for (int i = 0; i < timer.MAX_TIMERS; i++) { if (timer.callbacks[i]) { DBG_OUTPUT_PORT.printf(""%d cb:%08x num:%d numMax:%d\\n"", i, timer.callbacks[i], timer.numRuns[i], timer.maxNumRuns[i]); } } #endif return(*id); } // LED CONTROL int blinkerTimerId = -1; #define setBlinker(t) setTimedFunc(true, &blinkerTimerId, t, blinker, ""blinker"") void blinker() { static bool onoff = false; onoff = !onoff; digitalWrite(BUILTIN_LED, onoff?HIGH:LOW); } // mdns bool mdnsStarted = false; void startMDNS() { if (mdnsStarted) return; mdnsStarted = true; MDNS.begin(host); DBG_OUTPUT_PORT.printf(""MDNS Starting\\nOpen http://%s.local or http://%s/\\n"", host, apMode ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()); displayStatus(2, host); } // NTP void setRtc() { #ifdef INCLUDE_PCF8563 if (hasPcf8563) { Rtc_Pcf8563.setDate(day(), weekday() - 1, month(), year() < 2000 ? 1 : 0, year()%100); Rtc_Pcf8563.setTime(hour(), minute(), second()); DBG_OUTPUT_PORT.printf(""Setting PCF8563 time.\\n""); } #endif #ifdef INCLUDE_DS1307 if (hasDs1307) { RtcDateTime dt = RtcDateTime( year(), month(), day(), hour(), minute(), second()); Rtc_Ds1307.SetDateTime(dt); DBG_OUTPUT_PORT.printf(""Setting DS1307 time.\\n""); } #endif } bool ntpStarted = false; void startNTP() { if (timeServer[0] == '\\0') return; if (rtcValid) return; if (ntpStarted) return; ntpStarted = true; DBG_OUTPUT_PORT.printf(""Starting NTP %s\\n"", timeServer); NTP.begin(timeServer, 0, false); } void stopNTP() { NTP.stop(); ntpStarted = false; } void recalcSched(); // forward ref void handleNtpSync(NTPSyncEvent_t event) { if (event) { DBG_OUTPUT_PORT.printf(""NTP Error %d\\n"", event); } else { DBG_OUTPUT_PORT.printf(""NTP Successfull\\n""); timer.setTimeout(1000, recalcSched); if (hasRtc && !rtcValid) { timer.setTimeout(1000, setRtc); stopNTP(); } } } const char *timeStr(time_t t) { static char tmbuf[20]; if (t < 10000000) { strncpy(tmbuf, ""Not Set"", sizeof(tmbuf)); return tmbuf; } tmElements_t tm; breakTime(t, tm); snprintf(tmbuf, sizeof(tmbuf), ""%02d:%02d:%02d %04d/%02d/%02d"", tm.Hour, tm.Minute, tm.Second, tm.Year + 1970, tm.Month, tm.Day); return tmbuf; } const char *timeStrStd(time_t t) { static char tmbuf[40]; static char *wdays[7] = { ""Sun"", ""Mon"", ""Tue"", ""Wed"", ""Thu"", ""Fri"", ""Sat"" }; static char *mons[12] = { ""Jan"", ""Feb"", ""Mar"", ""Apr"", ""May"", ""Jun"", ""Jul"", ""Aug"", ""Sep"", ""Oct"", ""Nov"", ""Dec"" }; tmElements_t tm; breakTime(t, tm); snprintf(tmbuf, sizeof(tmbuf), ""%s, %02d %s %04d %02d:%02d:%02d GMT"", wdays[tm.Wday - 1], tm.Day, mons[tm.Month - 1], tm.Year + 1970, tm.Hour, tm.Minute, tm.Second); return tmbuf; } int tickId = -1; void checkSched(); // forward ref void tick() { const char *tx = timeStr(now() > 100000000 ? now()+offsetGMT : 0); #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""now(): %d %s\\n"", now(), tx); #endif displayStatus(1, ""time %s\\n"", tx); if (bootTime == 0 && now() > 100000000) { bootTime = now(); bootTimeString = String(timeStrStd(bootTime)); DBG_OUTPUT_PORT.printf(""boot time: %s\\n"", bootTimeString.c_str()); } checkSched(); } // WIFI STATUS CHANGES void setHostName() { if (host[0] == '*' && host[1] == '\\0') { uint8_t mac[6]; WiFi.softAPmacAddress(mac); snprintf(host, sizeof(host), ""ESPrinkler2_%02x%02x%02x"", mac[3], mac[4], mac[5]); } } int apModeTimerId = -1; int staModeTimerId = -1; #define setApModeTimeout(t) \\ setTimedFunc(false, &apModeTimerId, t, apModeTimeout, ""apModeTimeout"") #define setStaModeTimeout(t) \\ setTimedFunc(false, &staModeTimerId, t, staModeTimeout, ""staModeTimeout"") void apModeTimeout() { DBG_OUTPUT_PORT.printf(""apModeTimeout\\n""); apModeTimerId = -1; setApMode(true); setBlinker(100); if (ssid[0] != '\\0') { // if no ssid setStaModeTimeout(600000); } } void staModeTimeout() { DBG_OUTPUT_PORT.printf(""staModeTimeout\\n""); staModeTimerId = -1; setApMode(false); setBlinker(50); setApModeTimeout(60000); } void setApMode(bool mode) { if (apMode == mode) return; apMode = mode; if (apMode) { DBG_OUTPUT_PORT.printf(""going to AP mode\\n""); WiFi.disconnect(); delay(500); WiFi.mode(WIFI_AP); apMode = true; uint8_t mac[6]; delay(500); WiFi.softAPmacAddress(mac); delay(500); if (assid[0] == '\\0') { strncpy(assid, host, sizeof(assid)); } DBG_OUTPUT_PORT.printf(""SoftAP ssid:%s\\n"", assid); if (strlen(apassword) >= 8) { // softAP doesn't work if password < 8 WiFi.softAP(assid, apassword); } else { WiFi.softAP(assid); } DBG_OUTPUT_PORT.printf(""AP mode. IP address: %s\\n"", WiFi.softAPIP().toString().c_str()); /* Setup the DNS server redirecting all the domains to the apIP */ dnsServer.setErrorReplyCode(DNSReplyCode::NoError); dnsServer.start(DNS_PORT, ""*"", WiFi.softAPIP()); dnsStarted = true; #ifdef EXTRA_DEBUG WiFi.printDiag(DBG_OUTPUT_PORT); #endif displayStatus(0, ""AP:%s %s"", WiFi.softAPIP().toString().c_str(), assid); } else { if (dnsStarted) dnsServer.stop(); dnsStarted = false; DBG_OUTPUT_PORT.printf(""going to STA mode %s\\n"", ssid); displayStatus(0, ""Try: %s"", ssid); WiFi.mode(WIFI_STA); delay(500); if (password[0] == '\\0') { WiFi.begin(ssid); } else { WiFi.begin(ssid, password); } } } WiFiEventHandler onSTAGotIPHandler; void onSTAGotIP(WiFiEventStationModeGotIP ipInfo) { if (apMode) return; DBG_OUTPUT_PORT.printf(""Got IP: %s\\n"", ipInfo.ip.toString().c_str()); displayStatus(0, ""STA:%s %s %d"", WiFi.localIP().toString().c_str(), ssid, WiFi.RSSI()); setApModeTimeout(0); setBlinker(500); timer.setTimeout(1000, startMDNS); timer.setTimeout(5000, startNTP); } WiFiEventHandler onSTADisconnectedHandler; void onSTADisconnected(WiFiEventStationModeDisconnected event_info) { if (apMode) return; Serial.printf(""Disconnected from SSID: %s Reason: %d\\n"", event_info.ssid.c_str(), event_info.reason); displayStatus(0, ""DIS:%s %d"", event_info.ssid.c_str(), event_info.reason); setBlinker(50); if (apModeTimerId < 0) setApModeTimeout(600000); timer.setTimeout(20, stopNTP); } bool eeIsValid() { uint8_t csum = 0x35; #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""eeIsValid?""); #endif for (int addr = 0; addr < EEPROM_SIZE; addr++) { #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf("" %02x"", EEPROM.read(addr)); #endif csum += EEPROM.read(addr); } #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""eeIsValid CSUM=%02x\\n"", csum); #endif if (csum != 0) return false; return true; } bool eeMakeValid() { uint8_t csum = 0x35; for (int addr = 0; addr < (EEPROM_SIZE-1); addr++) { csum += EEPROM.read(addr); } #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.printf(""eeMakeValid last=%02x\\n"", 256 - csum); #endif EEPROM.write(EEPROM_SIZE-1, 256 - csum); EEPROM.commit(); } void eeReadChar(char *data, int addr, int size) { while (size--) { *data = static_cast(EEPROM.read(addr)); addr++; data++; } } void eeWriteChar(char *data, int addr, int size) { while (size--) { EEPROM.write(addr, (uint8_t)*data); addr++; data++; } } void eeClear() { for (int addr = 0; addr < (EEPROM_SIZE-1); addr++) { EEPROM.write(addr, 0); } eeMakeValid(); } void eeLoad() { eeReadChar(ssid, EEPROM_SSID, sizeof(ssid)); eeReadChar(password, EEPROM_PASSWORD, sizeof(password)); char t[sizeof(host)]; eeReadChar(t, EEPROM_HOST, sizeof(host)); if (strlen(t) > 0) strncpy(host, t, sizeof(host)); setHostName(); displayStatus(2, host); eeReadChar(offsetGMTstring, EEPROM_OFFSET_GMT, sizeof(offsetGMTstring)); offsetGMT = atoi(offsetGMTstring); } void eeSave() { if (ssid[0] != '\\0' && ssid[0] != '*') { eeWriteChar(ssid, EEPROM_SSID, sizeof(ssid)); eeWriteChar(password, EEPROM_PASSWORD, sizeof(password)); } eeWriteChar(host, EEPROM_HOST, sizeof(host)); snprintf(offsetGMTstring, sizeof(offsetGMTstring), ""%d"", offsetGMT); eeWriteChar(offsetGMTstring, EEPROM_OFFSET_GMT, sizeof(offsetGMTstring)); eeMakeValid(); } void setup(void) { pinMode(BUILTIN_LED, OUTPUT); setBlinker(50); SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); SPI.setClockDivider(SPI_CLOCK_DIV16); SPI.setHwCs(true); SPI.begin(); SPI.transfer(relayState); delay(500); DBG_OUTPUT_PORT.begin(74880); DBG_OUTPUT_PORT.setDebugOutput(false); #ifdef EXTRA_DEBUG DBG_OUTPUT_PORT.setDebugOutput(true); #endif DBG_OUTPUT_PORT.printf(""\\n\\nESPrinkler2 %s compiled %s %s\\n"", VERSION, __DATE__, __TIME__); DBG_OUTPUT_PORT.setTimeout(1000); u8g2.begin(); u8g2.setFont(u8g2_font_helvR08_tf); u8g2.setFontRefHeightExtendedText(); u8g2.setDrawColor(1); u8g2.setFontPosTop(); u8g2.setFontDirection(0); u8g2.clearBuffer(); displayStatus(0, ""Start %s"", VERSION); displayStatus(1, ""cmp: %s %s"", __DATE__, __TIME__); setHostName(); displayStatus(2, host); delay(2000); EEPROM.begin(EEPROM_SIZE); if (eeIsValid()) { eeLoad(); } else { eeClear(); eeSave(); } SPIFFS.begin(); { Dir dir = SPIFFS.openDir(""/""); while (dir.next()) { String fileName = dir.fileName(); size_t fileSize = dir.fileSize(); DBG_OUTPUT_PORT.printf(""FS File: %s, size: %s\\n"", fileName.c_str(), formatBytes(fileSize).c_str()); } DBG_OUTPUT_PORT.printf(""\\n""); } loadConfig(); #ifdef EXTRA_DEBUG for (int address = 1; address < 127; address++) { // The i2c_scanner uses the return value of // the Write.endTransmisstion to see if // a device did acknowledge to the address. Wire.beginTransmission(address); int error = Wire.endTransmission(); if (error == 0) { DBG_OUTPUT_PORT.printf(""I2C device found at address 0x%02x\\n"", address); } else { if (error == 4) { DBG_OUTPUT_PORT.printf(""Unknown error at address 0x%02x\\n"", address); } } } #endif // DS1307 #ifdef INCLUDE_DS1307 Wire.beginTransmission(DS1307_ADDRESS); if (Wire.endTransmission() == 0) { hasRtc = true; hasDs1307 = true; DBG_OUTPUT_PORT.printf(""RTC DS1307 Found @ %02x\\n"", DS1307_ADDRESS); displayStatus(0, ""RTC found""); if (Rtc_Ds1307.GetIsRunning()) { if (Rtc_Ds1307.IsDateTimeValid()) rtcValid = true; } else { DBG_OUTPUT_PORT.printf(""RTC DS1307 is not running.\\n""); Rtc_Ds1307.SetIsRunning(true); DBG_OUTPUT_PORT.printf(""Set RTC DS1307 to running.\\n""); } RtcDateTime dt = Rtc_Ds1307.GetDateTime(); DBG_OUTPUT_PORT.printf( ""RTC DS1307 time is %svalid: %02d:%02d:%02d %04d/%02d/%02d\\n"", rtcValid ? """" : ""not "", dt.Hour(), dt.Minute(), dt.Second(), dt.Year(), dt.Month(), dt.Day()); if (rtcValid) { setTime(dt.Hour(), dt.Minute(), dt.Second(), dt.Day(), dt.Month(), dt.Year()); } } #endif // pcf8563 #ifdef INCLUDE_PCF8563 Wire.beginTransmission(RTCC_R>>1); if (Wire.endTransmission() == 0) { hasRtc = true; hasPcf8563 = true; DBG_OUTPUT_PORT.printf(""RTC PCF8563 Found @ %02x\\n"", RTCC_R>>1); displayStatus(0, ""RTC found""); Wire.beginTransmission(RTCC_R>>1); Wire.write(RTCC_STAT1_ADDR); Wire.endTransmission(); Wire.requestFrom(RTCC_R >> 1, 3); // request 3 bytes byte stat1 = Wire.read(); byte stat2 = Wire.read(); byte stat3 = Wire.read(); DBG_OUTPUT_PORT.printf(""RTC PCF8563 status %02x %02x %02x\\n"", stat1, stat2, stat3); // we'll init the control values 1 and 2 Wire.beginTransmission(RTCC_R>>1); Wire.write(RTCC_STAT1_ADDR); Wire.write(0); Wire.write(0); Wire.endTransmission(); if ((stat1 & (1 << 7 | 1 << 5)) == 0) { // if clock is running if ((stat3 & 0x80) == 0) rtcValid = true; } if (!rtcValid) { displayStatus(0, ""RTC not valid""); } DBG_OUTPUT_PORT.printf(""RTC PCF8563 time is %svalid: %s %s\\n"", rtcValid ? """" : ""not "", Rtc_Pcf8563.formatDate(RTCC_DATE_ASIA), Rtc_Pcf8563.formatTime(RTCC_TIME_HMS)); if (rtcValid) { setTime(Rtc_Pcf8563.getHour(), Rtc_Pcf8563.getMinute(), Rtc_Pcf8563.getSecond(), Rtc_Pcf8563.getDay(), Rtc_Pcf8563.getMonth(), 2000 + Rtc_Pcf8563.getYear()); } } #endif loadSched(); setRelays(); // WIFI INIT onSTAGotIPHandler = WiFi.onStationModeGotIP(onSTAGotIP); onSTADisconnectedHandler = WiFi.onStationModeDisconnected(onSTADisconnected); NTP.onNTPSyncEvent(handleNtpSync); WiFi.persistent(false); if (ssid[0] == '\\0') { // no ssid, therefore go to apmode apMode = false; // forced mode change setApMode(true); } else { setApModeTimeout(60000); apMode = true; // forced mode change setApMode(false); } setTimedFunc(true, &tickId, 1000, tick, ""tick""); // SERVER INIT // list directory server.on(""/list"", HTTP_GET, handleFileList); // load editor server.on(""/edit"", HTTP_GET, []() { if (!handleFileRead(""/edit.html"")) { server.send(404, ""text/plain"", ""FileNotFound""); } }); // create file server.on(""/edit"", HTTP_PUT, handleFileCreate); // delete file server.on(""/edit"", HTTP_DELETE, handleFileDelete); // first callback is called after the request has // ended with all parsed arguments // second callback handles file uploads at that location server.on(""/edit"", HTTP_POST, []() { server.send(200, ""text/plain"", """"); }, handleFileUpload); server.on(""/update"", HTTP_POST, afterFileUpdate, handleFileUpdate); server.on(""/spiffsupdate"", HTTP_POST, afterFileUpdate, handleFileUpdate); server.on(""/status"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); String json = ""{""; for (int i = 0; i < 8; i++) { json += String(""\\""zone"") + String(i) + String(relayState&(1 << i) ? ""\\"":\\""on\\"","" : ""\\"":\\""off\\"",""); } json += String(""\\""time\\"":"")+String(now())+"",""; json += String(""\\""offsetGMT\\"":"")+String(offsetGMT)+"",""; json += String(""\\""host\\"":\\"""")+String(host)+""\\""""; json += ""}""; server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/json"", json); DBG_OUTPUT_PORT.printf(""status %s\\n"", json.c_str()); json = String(); }); server.on(""/toggle"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); int i = 0; if (server.args() > 0) i = atoi(server.arg(""zone"").c_str()); relayState ^= (1 << i); server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/text"", ""OK""); DBG_OUTPUT_PORT.printf(""toggle %d = %s\\n"", i, relayState&(1 << i) ? ""on"" : ""off""); setRelays(); }); server.on(""/clear"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); relayState = 0; server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/text"", ""OK""); setRelays(); }); server.on(""/clean"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); eeClear(); SPIFFS.remove(configFile); SPIFFS.remove(schedFile); SPIFFS.remove(buttonsFile); server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/text"", ""Persistant Storage has been cleaned.""); }); server.on(""/settime"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); int i = 0; i = atoi(server.arg(""time"").c_str()); setTime(i); i = atoi(server.arg(""offset"").c_str()); offsetGMT = i; if (hasRtc) { setRtc(); } eeSave(); server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/text"", ""OK""); DBG_OUTPUT_PORT.printf(""settime %d\\n"", i); setRelays(); }); server.on(""/restart"", HTTP_GET, []() { displayStatus(2, ""%s"", server.uri().c_str()); server.sendHeader(""Cache-Control"", ""public, max-age=0""); server.send(200, ""text/text"", ""Restarting.... Wait a minute or so and then refresh.""); relayState = 0; setRelays(); doRestart(); }); // called when the url is not defined here // use it to load content from SPIFFS server.onNotFound([]() { if (!handleFileRead(server.uri())) { displayStatus(2, ""not found %s"", server.uri().c_str()); server.send(404, ""text/plain"", ""FileNotFound""); } }); const char * headerkeys[] = {""If-Modified-Since"", ""Content-Length""}; server.collectHeaders(headerkeys, 2); server.begin(); DBG_OUTPUT_PORT.printf(""HTTP server started\\n""); // OTA init ArduinoOTA.onStart([]() { priorPct = 0; DBG_OUTPUT_PORT.printf(""OTA Start\\n""); displayStatus(1, ""OTA Update Start.""); }); ArduinoOTA.onEnd([]() { DBG_OUTPUT_PORT.printf(""OTA End\\n""); displayStatus(1, ""OTA done.""); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { int p = progress / (total / 100); if ((p - priorPct) < 5) return; priorPct = p; DBG_OUTPUT_PORT.printf(""OTA Update: %u%%\\r\\n"", p); displayStatus(1, ""OTA Update: %u%%"", p); }); ArduinoOTA.onError([](ota_error_t error) { DBG_OUTPUT_PORT.printf(""Error[%u]: "", error); if (error == OTA_AUTH_ERROR) DBG_OUTPUT_PORT.printf(""Auth Failed\\n""); else if (error == OTA_BEGIN_ERROR) DBG_OUTPUT_PORT.printf(""Begin Failed\\n""); else if (error == OTA_CONNECT_ERROR) DBG_OUTPUT_PORT.printf(""Connect Failed\\n""); else if (error == OTA_RECEIVE_ERROR) DBG_OUTPUT_PORT.printf(""Receive Failed\\n""); else if (error == OTA_END_ERROR) DBG_OUTPUT_PORT.printf(""End Failed\\n""); displayStatus(1, ""OTA Error[%u]"", error); }); ArduinoOTA.begin(); } void loop(void) { // deal with timer (SimpleTimer) timer.run(); // deal with http server. server.handleClient(); ArduinoOTA.handle(); if (dnsStarted) dnsServer.processNextRequest(); if (DBG_OUTPUT_PORT.available()) { String line = DBG_OUTPUT_PORT.readStringUntil('\\r'); DBG_OUTPUT_PORT.printf(""%s\\n"", line.c_str()); char buf[100]; line.toCharArray(buf, sizeof(buf)); char *p = buf; char *str; char *args[10]; int argc = 0; while ((str = strtok_r(p, "" "", &p)) != NULL && argc < 10) { args[argc++] = str; } if (argc >= 3 && strcmp(args[0], ""ap"") == 0) { strncpy(ssid, args[1], sizeof(ssid)); strncpy(password, args[2], sizeof(password)); eeSave(); doRestart(); } } } ",12388,False,2174.7146854727575,median " .ORG $8000 #define db .byte #define dw .word ;4-channel music generator ZX-10 ;Original code JDeak (c)1989 Bytepack Bratislava ;Modified 1tracker version by Shiru 04'12 begin: ld hl,musicData call play ret play: di ld a,(hl) inc hl ld (speed+1),a dec a ld (speedCnt),a xor a ld e,(hl) inc hl ld d,(hl) inc hl ld (ch1order),de ld (de),a ld (sc1+3),a ld e,(hl) inc hl ld d,(hl) inc hl ld (ch2order),de ld (de),a ld (sc2+3),a ld e,(hl) inc hl ld d,(hl) inc hl ld (ch3order),de ld (de),a ld (sc3+3),a ld e,(hl) inc hl ld d,(hl) ld (ch4order),de ld (de),a ld (sc4+3),a ld hl,adst ld de,sx ld bc,$0400 init0: ld (hl),c inc hl ld (hl),e inc hl ld (hl),d inc hl djnz init0 playRow: ld ix,sc1 ld hl,adst ld de,8 ld b,4 decay0: ld a,(hl) or a jr z,decay1 dec (hl) sla (ix+3) set 4,(ix+3) decay1: add ix,de inc hl inc hl inc hl djnz decay0 ld a,(speedCnt) inc a speed: cp 0 jr nz,noNextRow ld ix,sc1 ld hl,adst ld b,4 nextRow0: push hl inc hl ld e,(hl) inc hl ld d,(hl) ld a,(de) inc de ld (hl),d dec hl ld (hl),e cp $e0 jp nz,noNextOrder ld de,12 add hl,de ld c,(hl) inc hl ld a,(hl) or a sbc hl,de push hl ld l,c ld h,a ld a,(hl) inc hl cp (hl) dec hl jr nz,porder1 ;xor a ;loop channel ;ld (hl),a ;jr porder2 pop hl ;exit at end of the song pop hl jp keyPressed porder1: inc (hl) porder2: inc a ex de,hl ld l,a ld h,0 add hl,hl add hl,de ld e,(hl) inc hl ld d,(hl) pop hl ld a,(de) inc de ld (hl),d dec hl ld (hl),e noNextOrder: ld c,a and 31 cp 2 jr nc,nextRow2 or a jr nz,nextRow1 pop hl jr nextRow4 nextRow1: set 4,(ix+2) jr nextRow3 nextRow2: res 4,(ix+2) nextRow3: ld e,a ld d,0 ld hl,frq ;note add hl,de ld a,(hl) ld (ix+1),a ld a,c ;duration rlca rlca rlca rlca and 14 inc a pop hl ld (hl),a ld (ix+3),$1f nextRow4: ld de,8 add ix,de inc hl inc hl inc hl djnz nextRow0 xor a noNextRow: ld (speedCnt),a xor a ld a,%10111111 ;+ new keyhandler out (1),a in a,(1) ;read keyboard cpl bit 6,a // jp nz,keyPressed ld hl,256 sc: exx sc0: dec c jp nz,s1 sc1: ld c,0 ld l,0 l1: dec b jp nz,s2 sc2: ld b,0 ld l,0 l2: dec e jp nz,s3 sc3: ld e,0 ld l,0 l3: dec d jp nz,s4 sc4: ld d,0 ld l,0 l4: ;sound loop ld a,l and $10 sla l push af bit 4,a jr z,$+$04 ld a,$3c xor 33 ld (30779), a ld (30779), a ld (30779), a ld (30779), a ld (30779), a nop nop pop af exx dec hl ld a,h or l exx jp nz,sc0 push af bit 4,a jr z,$+$04 ld a,$3c xor 33 ld (30779), a ld (30779), a ld (30779), a ld (30779), a ld (30779), a nop nop pop af exx jp playRow s1: nop jp l1 s2: nop jp l2 s3: nop jp l3 s4: nop jp l4 keyPressed: exx ei ret frq: db 0,255,241,227,214,202,191,180 db 170,161,152,143,135,127,120,114 db 107,101, 95, 90, 85, 80, 76, 71 db 67, 63, 60, 57, 53, 50, 47, 45 sx: db $e0 adst: db 0 dw 0 db 0 dw 0 db 0 dw 0 db 0 dw 0 db 0 ch1order: dw 0 db 0 ch2order: dw 0 db 0 ch3order: dw 0 db 0 ch4order: dw 0 speedCnt: db 0 musicData: db $06 dw order0 dw order1 dw order2 dw order3 order0: dw $e100 dw pattern0 dw pattern1 dw pattern0 dw pattern2 dw pattern3 dw pattern1 dw pattern1 dw pattern4 dw pattern0 dw pattern1 dw pattern0 dw pattern2 dw pattern3 dw pattern1 dw pattern1 dw pattern5 dw pattern6 dw pattern1 dw pattern6 dw pattern7 dw pattern8 dw pattern1 dw pattern1 dw pattern9 dw pattern6 dw pattern1 dw pattern6 dw pattern7 dw pattern8 dw pattern1 dw pattern1 dw pattern10 dw pattern2 dw pattern1 dw pattern2 dw pattern11 dw pattern12 dw pattern1 dw pattern1 dw pattern13 dw pattern2 dw pattern1 dw pattern2 dw pattern11 dw pattern14 dw pattern1 dw pattern1 dw pattern15 dw pattern7 dw pattern1 dw pattern7 dw pattern16 dw pattern17 dw pattern1 dw pattern1 dw pattern18 dw pattern7 dw pattern1 dw pattern7 dw pattern16 dw pattern19 dw pattern1 dw pattern1 dw pattern20 dw pattern21 dw pattern1 dw pattern21 dw pattern22 dw pattern12 dw pattern1 dw pattern1 dw pattern23 dw pattern21 dw pattern1 dw pattern21 dw pattern22 dw pattern24 dw pattern1 dw pattern1 dw pattern25 dw pattern21 dw pattern1 dw pattern21 dw pattern22 dw pattern12 dw pattern1 dw pattern1 dw pattern23 dw pattern0 dw pattern1 dw pattern0 dw pattern26 dw pattern27 dw pattern1 dw pattern1 dw pattern28 dw pattern29 dw pattern30 dw pattern31 dw pattern1 dw pattern32 dw pattern33 dw pattern34 dw pattern35 dw pattern36 dw pattern37 dw pattern1 dw pattern38 dw pattern39 dw pattern1 dw pattern1 dw pattern1 dw pattern40 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern41 dw pattern1 dw pattern1 dw pattern42 dw pattern39 dw pattern1 dw pattern1 dw pattern1 dw pattern43 dw pattern44 dw pattern45 dw pattern46 dw pattern47 dw pattern48 dw pattern33 dw pattern8 dw pattern49 dw pattern50 dw pattern51 dw pattern52 dw pattern53 dw pattern54 dw pattern55 dw pattern56 dw pattern43 dw pattern44 dw pattern45 dw pattern46 dw pattern57 dw pattern58 dw pattern33 dw pattern8 dw pattern49 dw pattern50 dw pattern51 dw pattern52 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern12 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern17 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern60 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern61 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern60 dw pattern17 dw pattern12 dw pattern1 dw pattern1 dw pattern1 dw pattern62 dw pattern1 dw pattern1 dw pattern1 dw pattern17 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern63 dw pattern64 dw pattern65 dw pattern1 dw pattern1 dw pattern1 dw pattern66 dw pattern1 dw pattern1 dw pattern1 dw pattern61 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern60 dw pattern17 dw pattern59 order1: dw $e100 dw pattern67 dw pattern68 dw pattern69 dw pattern70 dw pattern71 dw pattern1 dw pattern1 dw pattern72 dw pattern67 dw pattern68 dw pattern69 dw pattern70 dw pattern71 dw pattern1 dw pattern1 dw pattern73 dw pattern74 dw pattern3 dw pattern75 dw pattern76 dw pattern77 dw pattern1 dw pattern1 dw pattern78 dw pattern74 dw pattern3 dw pattern75 dw pattern76 dw pattern77 dw pattern1 dw pattern1 dw pattern79 dw pattern80 dw pattern81 dw pattern82 dw pattern83 dw pattern84 dw pattern1 dw pattern1 dw pattern85 dw pattern86 dw pattern48 dw pattern87 dw pattern83 dw pattern84 dw pattern1 dw pattern1 dw pattern88 dw pattern89 dw pattern90 dw pattern91 dw pattern92 dw pattern93 dw pattern1 dw pattern1 dw pattern94 dw pattern95 dw pattern96 dw pattern97 dw pattern92 dw pattern93 dw pattern1 dw pattern1 dw pattern98 dw pattern99 dw pattern100 dw pattern101 dw pattern102 dw pattern103 dw pattern1 dw pattern1 dw pattern104 dw pattern105 dw pattern93 dw pattern106 dw pattern102 dw pattern103 dw pattern1 dw pattern1 dw pattern107 dw pattern99 dw pattern100 dw pattern101 dw pattern102 dw pattern103 dw pattern1 dw pattern1 dw pattern104 dw pattern67 dw pattern68 dw pattern69 dw pattern70 dw pattern71 dw pattern1 dw pattern1 dw pattern108 dw pattern109 dw pattern109 dw pattern109 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern110 dw pattern111 dw pattern111 dw pattern1 dw pattern17 dw pattern1 dw pattern1 dw pattern1 dw pattern112 dw pattern109 dw pattern109 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern110 dw pattern111 dw pattern111 dw pattern1 dw pattern17 dw pattern1 dw pattern1 dw pattern1 dw pattern113 dw pattern114 dw pattern115 dw pattern116 dw pattern117 dw pattern118 dw pattern119 dw pattern117 dw pattern120 dw pattern61 dw pattern60 dw pattern121 dw pattern122 dw pattern63 dw pattern123 dw pattern124 dw pattern113 dw pattern114 dw pattern115 dw pattern116 dw pattern125 dw pattern126 dw pattern127 dw pattern63 dw pattern120 dw pattern61 dw pattern60 dw pattern121 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern128 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern128 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern128 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern129 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern128 dw pattern130 dw pattern131 dw pattern132 dw pattern133 dw pattern1 dw pattern134 dw pattern1 dw pattern135 dw pattern1 dw pattern136 dw pattern1 dw pattern1 dw pattern1 dw pattern137 dw pattern1 dw pattern1 dw pattern1 dw pattern138 dw pattern138 dw pattern138 dw pattern138 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern129 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern128 dw pattern130 dw pattern59 order2: dw $e100 dw pattern140 dw pattern141 dw pattern31 dw pattern1 dw pattern142 dw pattern143 dw pattern144 dw pattern145 dw pattern146 dw pattern141 dw pattern31 dw pattern1 dw pattern147 dw pattern143 dw pattern144 dw pattern148 dw pattern149 dw pattern150 dw pattern151 dw pattern1 dw pattern152 dw pattern153 dw pattern154 dw pattern155 dw pattern156 dw pattern150 dw pattern151 dw pattern1 dw pattern157 dw pattern153 dw pattern154 dw pattern158 dw pattern159 dw pattern160 dw pattern161 dw pattern12 dw pattern162 dw pattern163 dw pattern164 dw pattern165 dw pattern166 dw pattern160 dw pattern161 dw pattern1 dw pattern162 dw pattern163 dw pattern164 dw pattern167 dw pattern168 dw pattern169 dw pattern170 dw pattern17 dw pattern171 dw pattern163 dw pattern172 dw pattern173 dw pattern174 dw pattern169 dw pattern170 dw pattern1 dw pattern171 dw pattern163 dw pattern172 dw pattern175 dw pattern176 dw pattern177 dw pattern178 dw pattern12 dw pattern179 dw pattern130 dw pattern128 dw pattern180 dw pattern181 dw pattern177 dw pattern178 dw pattern1 dw pattern179 dw pattern130 dw pattern128 dw pattern182 dw pattern183 dw pattern177 dw pattern178 dw pattern12 dw pattern179 dw pattern130 dw pattern128 dw pattern180 dw pattern184 dw pattern185 dw pattern186 dw pattern1 dw pattern187 dw pattern188 dw pattern144 dw pattern189 dw pattern190 dw pattern191 dw pattern191 dw pattern192 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern193 dw pattern194 dw pattern194 dw pattern195 dw pattern1 dw pattern1 dw pattern196 dw pattern1 dw pattern190 dw pattern191 dw pattern191 dw pattern192 dw pattern1 dw pattern1 dw pattern1 dw pattern1 dw pattern193 dw pattern194 dw pattern194 dw pattern195 dw pattern1 dw pattern1 dw pattern196 dw pattern1 dw pattern197 dw pattern198 dw pattern199 dw pattern200 dw pattern200 dw pattern198 dw pattern199 dw pattern200 dw pattern201 dw pattern202 dw pattern203 dw pattern201 dw pattern201 dw pattern202 dw pattern203 dw pattern201 dw pattern197 dw pattern198 dw pattern199 dw pattern200 dw pattern200 dw pattern198 dw pattern199 dw pattern200 dw pattern201 dw pattern202 dw pattern203 dw pattern201 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern129 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern204 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern164 dw pattern1 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern1 dw pattern172 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern164 dw pattern204 dw pattern205 dw pattern206 dw pattern206 dw pattern207 dw pattern208 dw pattern209 dw pattern209 dw pattern209 dw pattern210 dw pattern211 dw pattern212 dw pattern212 dw pattern213 dw pattern213 dw pattern213 dw pattern213 dw pattern214 dw pattern1 dw pattern1 dw pattern1 dw pattern77 dw pattern1 dw pattern1 dw pattern1 dw pattern172 dw pattern1 dw pattern1 dw pattern59 dw pattern1 dw pattern1 dw pattern164 dw pattern204 dw pattern59 order3: dw $e100 dw pattern187 dw pattern143 dw pattern215 dw pattern216 dw pattern153 dw pattern129 dw pattern217 dw pattern218 dw pattern187 dw pattern143 dw pattern215 dw pattern216 dw pattern153 dw pattern129 dw pattern217 dw pattern219 dw pattern220 dw pattern153 dw pattern221 dw pattern222 dw pattern223 dw pattern204 dw pattern224 dw pattern225 dw pattern220 dw pattern153 dw pattern221 dw pattern222 dw pattern223 dw pattern226 dw pattern224 dw pattern227 dw pattern162 dw pattern163 dw pattern228 dw pattern229 dw pattern163 dw pattern130 dw pattern230 dw pattern231 dw pattern162 dw pattern163 dw pattern228 dw pattern229 dw pattern163 dw pattern130 dw pattern230 dw pattern232 dw pattern171 dw pattern163 dw pattern233 dw pattern234 dw pattern163 dw pattern235 dw pattern236 dw pattern237 dw pattern171 dw pattern163 dw pattern233 dw pattern234 dw pattern163 dw pattern235 dw pattern236 dw pattern238 dw pattern179 dw pattern130 dw pattern239 dw pattern240 dw pattern130 dw pattern241 dw pattern242 dw pattern243 dw pattern179 dw pattern130 dw pattern239 dw pattern240 dw pattern130 dw pattern241 dw pattern242 dw pattern244 dw pattern179 dw pattern130 dw pattern239 dw pattern240 dw pattern130 dw pattern241 dw pattern242 dw pattern243 dw pattern245 dw pattern188 dw pattern215 dw pattern246 dw pattern247 dw pattern248 dw pattern249 dw pattern219 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern250 dw pattern251 dw pattern252 dw pattern250 dw pattern253 dw pattern254 dw pattern255 dw pattern253 dw pattern253 dw pattern254 dw pattern256 dw pattern257 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern258 dw pattern258 dw pattern259 dw pattern259 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern259 dw pattern259 dw pattern258 dw pattern258 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern259 dw pattern259 dw pattern259 dw pattern259 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern260 dw pattern260 dw pattern260 dw pattern260 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern139 dw pattern59 pattern0: db $47,$00,$4a,$00,$4e,$00,$51,$00,$e0 pattern1: db $00,$00,$00,$00,$00,$00,$00,$00,$e0 pattern2: db $4e,$00,$51,$00,$55,$00,$58,$00,$e0 pattern3: db $53,$00,$00,$00,$00,$00,$00,$00,$e0 pattern4: db $4c,$4e,$4c,$00,$5a,$5b,$5d,$00,$e0 pattern5: db $58,$56,$55,$00,$58,$56,$55,$53,$e0 pattern6: db $49,$00,$4c,$00,$50,$00,$53,$00,$e0 pattern7: db $50,$00,$53,$00,$57,$00,$5a,$00,$e0 pattern8: db $55,$00,$00,$00,$00,$00,$00,$00,$e0 pattern9: db $4e,$50,$4e,$00,$5c,$5d,$5f,$00,$e0 pattern10: db $5a,$58,$57,$00,$5a,$58,$57,$55,$e0 pattern11: db $55,$00,$58,$00,$5c,$00,$5f,$00,$e0 pattern12: db $02,$00,$00,$00,$00,$00,$00,$00,$e0 pattern13: db $13,$15,$13,$00,$1f,$1f,$1f,$00,$e0 pattern14: db $5a,$00,$02,$00,$00,$00,$00,$00,$e0 pattern15: db $1f,$1d,$1c,$00,$1f,$1d,$1c,$1a,$e0 pattern16: db $57,$00,$5a,$00,$5e,$00,$5f,$00,$e0 pattern17: db $04,$00,$00,$00,$00,$00,$00,$00,$e0 pattern18: db $15,$17,$15,$00,$1f,$1f,$1f,$00,$e0 pattern19: db $5c,$00,$04,$00,$00,$00,$00,$00,$e0 pattern20: db $1f,$1f,$1e,$00,$1f,$1f,$1e,$00,$e0 pattern21: db $46,$00,$49,$00,$4d,$00,$50,$00,$e0 pattern22: db $4d,$00,$50,$00,$54,$00,$55,$00,$e0 pattern23: db $0b,$0d,$0b,$00,$15,$15,$15,$00,$e0 pattern24: db $52,$00,$06,$00,$00,$00,$00,$00,$e0 pattern25: db $15,$15,$14,$00,$15,$15,$14,$00,$e0 pattern26: db $4e,$00,$51,$00,$55,$00,$56,$00,$e0 pattern27: db $53,$00,$07,$00,$00,$00,$00,$00,$e0 pattern28: db $16,$16,$15,$00,$16,$16,$15,$00,$e0 pattern29: db $42,$42,$00,$00,$47,$00,$4c,$00,$e0 pattern30: db $55,$00,$56,$00,$00,$00,$56,$56,$e0 pattern31: db $56,$00,$53,$00,$51,$00,$53,$00,$e0 pattern32: db $53,$00,$53,$00,$53,$00,$53,$00,$e0 pattern33: db $56,$00,$00,$00,$00,$00,$00,$00,$e0 pattern34: db $4a,$00,$00,$00,$00,$00,$00,$00,$e0 pattern35: db $56,$56,$56,$00,$56,$56,$56,$55,$e0 pattern36: db $57,$37,$00,$00,$2e,$2e,$00,$00,$e0 pattern37: db $30,$04,$00,$00,$00,$00,$00,$00,$e0 pattern38: db $03,$04,$05,$06,$07,$08,$09,$0a,$e0 pattern39: db $2b,$00,$00,$00,$00,$00,$00,$00,$e0 pattern40: db $42,$42,$00,$00,$00,$00,$00,$00,$e0 pattern41: db $44,$24,$00,$00,$00,$00,$00,$00,$e0 pattern42: db $23,$24,$25,$26,$27,$28,$29,$2a,$e0 pattern43: db $29,$29,$09,$00,$09,$0a,$0b,$0c,$e0 pattern44: db $2c,$2c,$0c,$00,$00,$00,$00,$4c,$e0 pattern45: db $0a,$00,$00,$00,$00,$00,$00,$4a,$e0 pattern46: db $49,$00,$00,$00,$00,$00,$00,$49,$e0 pattern47: db $35,$35,$15,$00,$00,$00,$00,$55,$e0 pattern48: db $58,$00,$00,$00,$00,$00,$00,$00,$e0 pattern49: db $00,$2b,$2b,$0b,$00,$00,$0b,$0c,$e0 pattern50: db $0d,$2e,$2e,$0e,$00,$2e,$2e,$00,$e0 pattern51: db $4e,$0c,$00,$00,$00,$00,$00,$00,$e0 pattern52: db $4c,$0b,$00,$00,$00,$00,$00,$4b,$e0 pattern53: db $0b,$00,$00,$00,$00,$00,$00,$4b,$e0 pattern54: db $0e,$00,$00,$00,$00,$00,$00,$4e,$e0 pattern55: db $0c,$00,$00,$00,$00,$00,$00,$4c,$e0 pattern56: db $0b,$00,$00,$00,$00,$00,$00,$00,$e0 pattern57: db $35,$33,$15,$00,$00,$00,$00,$55,$e0 pattern58: db $5d,$00,$00,$00,$00,$00,$5f,$5d,$e0 pattern59: db $01,$00,$00,$00,$00,$00,$00,$00,$e0 pattern60: db $05,$00,$00,$00,$00,$00,$00,$00,$e0 pattern61: db $07,$00,$00,$00,$00,$00,$00,$00,$e0 pattern62: db $5d,$00,$00,$00,$00,$00,$00,$00,$e0 pattern63: db $15,$00,$00,$00,$00,$00,$00,$00,$e0 pattern64: db $00,$00,$00,$00,$11,$10,$0f,$0c,$e0 pattern65: db $0b,$0a,$07,$06,$05,$00,$00,$00,$e0 pattern66: db $10,$00,$00,$00,$01,$00,$00,$00,$e0 pattern67: db $00,$00,$47,$00,$4a,$00,$4e,$00,$e0 pattern68: db $51,$00,$00,$00,$00,$00,$00,$00,$e0 pattern69: db $00,$00,$47,$00,$4e,$00,$4f,$00,$e0 pattern70: db $4e,$00,$4c,$00,$4a,$00,$4c,$00,$e0 pattern71: db $47,$00,$00,$00,$00,$00,$00,$00,$e0 pattern72: db $51,$53,$55,$00,$53,$55,$56,$00,$e0 pattern73: db $55,$56,$55,$00,$55,$53,$55,$53,$e0 pattern74: db $00,$00,$49,$00,$4c,$00,$50,$00,$e0 pattern75: db $00,$00,$49,$00,$50,$00,$51,$00,$e0 pattern76: db $50,$00,$4e,$00,$4c,$00,$4e,$00,$e0 pattern77: db $49,$00,$00,$00,$00,$00,$00,$00,$e0 pattern78: db $53,$55,$57,$00,$55,$57,$58,$00,$e0 pattern79: db $57,$58,$57,$00,$57,$55,$57,$55,$e0 pattern80: db $02,$00,$0e,$00,$11,$00,$15,$00,$e0 pattern81: db $18,$00,$02,$00,$00,$00,$00,$00,$e0 pattern82: db $00,$00,$0e,$00,$15,$00,$16,$00,$e0 pattern83: db $55,$00,$53,$00,$51,$00,$53,$00,$e0 pattern84: db $4e,$00,$00,$00,$00,$00,$00,$00,$e0 pattern85: db $58,$5a,$5c,$00,$5a,$5c,$5d,$00,$e0 pattern86: db $00,$00,$4e,$00,$51,$00,$55,$00,$e0 pattern87: db $00,$00,$4e,$00,$55,$00,$56,$00,$e0 pattern88: db $5c,$5d,$5c,$00,$5c,$5a,$5c,$5a,$e0 pattern89: db $04,$00,$10,$00,$13,$00,$17,$00,$e0 pattern90: db $1a,$00,$04,$00,$00,$00,$00,$00,$e0 pattern91: db $00,$00,$10,$00,$17,$00,$18,$00,$e0 pattern92: db $57,$00,$55,$00,$53,$00,$55,$00,$e0 pattern93: db $50,$00,$00,$00,$00,$00,$00,$00,$e0 pattern94: db $5a,$5c,$5e,$00,$5c,$5e,$5f,$00,$e0 pattern95: db $00,$00,$50,$00,$53,$00,$57,$00,$e0 pattern96: db $5a,$00,$00,$00,$00,$00,$00,$00,$e0 pattern97: db $00,$00,$50,$00,$57,$00,$58,$00,$e0 pattern98: db $5e,$5f,$5e,$00,$5e,$5c,$5e,$00,$e0 pattern99: db $02,$00,$06,$00,$09,$00,$0d,$00,$e0 pattern100: db $10,$00,$02,$00,$00,$00,$00,$00,$e0 pattern101: db $00,$00,$06,$00,$0d,$00,$0e,$00,$e0 pattern102: db $4d,$00,$4b,$00,$49,$00,$4b,$00,$e0 pattern103: db $46,$00,$00,$00,$00,$00,$00,$00,$e0 pattern104: db $50,$52,$54,$00,$52,$54,$55,$00,$e0 pattern105: db $00,$00,$46,$00,$49,$00,$4d,$00,$e0 pattern106: db $00,$00,$46,$00,$4d,$00,$4e,$00,$e0 pattern107: db $54,$55,$54,$00,$54,$52,$54,$00,$e0 pattern108: db $55,$56,$55,$00,$55,$53,$55,$00,$e0 pattern109: db $02,$00,$00,$00,$0e,$00,$00,$00,$e0 pattern110: db $04,$00,$00,$00,$0e,$00,$00,$00,$e0 pattern111: db $04,$00,$00,$00,$10,$00,$00,$00,$e0 pattern112: db $13,$00,$11,$00,$0e,$00,$00,$00,$e0 pattern113: db $02,$00,$00,$00,$03,$04,$05,$06,$e0 pattern114: db $05,$00,$00,$00,$00,$00,$00,$01,$e0 pattern115: db $03,$00,$00,$00,$00,$00,$00,$01,$e0 pattern116: db $02,$00,$00,$00,$00,$00,$00,$01,$e0 pattern117: db $0e,$00,$00,$00,$00,$00,$00,$00,$e0 pattern118: db $11,$00,$00,$00,$00,$00,$00,$00,$e0 pattern119: db $0f,$00,$00,$00,$00,$00,$00,$00,$e0 pattern120: db $04,$00,$00,$00,$00,$00,$05,$06,$e0 pattern121: db $04,$00,$00,$00,$00,$00,$15,$16,$e0 pattern122: db $17,$00,$00,$00,$00,$00,$18,$17,$e0 pattern123: db $0f,$11,$00,$00,$00,$00,$13,$11,$e0 pattern124: db $04,$00,$00,$00,$00,$00,$00,$01,$e0 pattern125: db $0e,$0c,$0e,$00,$00,$00,$16,$17,$e0 pattern126: db $18,$00,$00,$00,$00,$00,$1a,$18,$e0 pattern127: db $16,$00,$00,$00,$00,$00,$18,$16,$e0 pattern128: db $29,$00,$00,$00,$00,$00,$00,$00,$e0 pattern129: db $2e,$00,$00,$00,$00,$00,$00,$00,$e0 pattern130: db $35,$00,$00,$00,$00,$00,$00,$00,$e0 pattern131: db $15,$09,$00,$00,$35,$09,$00,$00,$e0 pattern132: db $15,$09,$00,$00,$15,$09,$00,$00,$e0 pattern133: db $00,$09,$00,$00,$15,$09,$00,$00,$e0 pattern134: db $3a,$00,$3c,$00,$00,$00,$00,$00,$e0 pattern135: db $3c,$00,$3d,$00,$00,$00,$00,$00,$e0 pattern136: db $09,$00,$00,$00,$00,$00,$00,$00,$e0 pattern137: db $1c,$00,$00,$00,$00,$00,$00,$00,$e0 pattern138: db $55,$49,$00,$00,$55,$49,$00,$00,$e0 pattern139: db $15,$13,$10,$11,$15,$13,$10,$11,$e0 pattern140: db $00,$00,$47,$00,$00,$00,$4c,$00,$e0 pattern141: db $55,$00,$58,$00,$00,$00,$5a,$58,$e0 pattern142: db $33,$00,$00,$00,$00,$00,$33,$00,$e0 pattern143: db $38,$00,$00,$00,$00,$00,$00,$00,$e0 pattern144: db $2a,$00,$00,$00,$00,$00,$00,$00,$e0 pattern145: db $35,$36,$38,$00,$38,$3a,$3b,$00,$e0 pattern146: db $47,$00,$00,$00,$47,$00,$4c,$00,$e0 pattern147: db $33,$00,$00,$00,$33,$00,$33,$33,$e0 pattern148: db $3a,$38,$3a,$00,$3a,$38,$36,$35,$e0 pattern149: db $00,$00,$00,$00,$49,$00,$4e,$00,$e0 pattern150: db $57,$00,$5a,$00,$00,$00,$5c,$5a,$e0 pattern151: db $58,$00,$55,$00,$53,$00,$55,$00,$e0 pattern152: db $35,$00,$35,$00,$00,$00,$35,$00,$e0 pattern153: db $3a,$00,$00,$00,$00,$00,$00,$00,$e0 pattern154: db $2c,$00,$00,$00,$00,$00,$00,$00,$e0 pattern155: db $37,$38,$3a,$00,$3a,$3c,$3d,$00,$e0 pattern156: db $49,$00,$00,$00,$49,$00,$4e,$00,$e0 pattern157: db $35,$38,$3c,$3f,$33,$37,$3a,$3d,$e0 pattern158: db $3c,$3a,$3c,$00,$3c,$3a,$38,$37,$e0 pattern159: db $00,$00,$00,$00,$4e,$00,$53,$00,$e0 pattern160: db $5c,$00,$5f,$00,$00,$00,$5f,$5f,$e0 pattern161: db $5d,$00,$5a,$00,$58,$00,$5a,$00,$e0 pattern162: db $3a,$00,$3a,$00,$3a,$00,$3a,$00,$e0 pattern163: db $3f,$00,$00,$00,$00,$00,$00,$00,$e0 pattern164: db $31,$00,$00,$00,$00,$00,$00,$00,$e0 pattern165: db $3c,$3d,$3f,$00,$3f,$3f,$3f,$00,$e0 pattern166: db $4e,$00,$00,$00,$4e,$00,$53,$00,$e0 pattern167: db $3f,$3f,$3f,$00,$3f,$3f,$3d,$3c,$e0 pattern168: db $00,$00,$00,$00,$50,$00,$55,$00,$e0 pattern169: db $5e,$00,$5f,$00,$00,$00,$5f,$5f,$e0 pattern170: db $5f,$00,$5c,$00,$5a,$00,$5c,$00,$e0 pattern171: db $3c,$00,$3c,$00,$3c,$00,$3c,$00,$e0 pattern172: db $33,$00,$00,$00,$00,$00,$00,$00,$e0 pattern173: db $3e,$3f,$3f,$00,$3f,$3f,$3f,$00,$e0 pattern174: db $50,$00,$00,$00,$50,$00,$55,$00,$e0 pattern175: db $3f,$3f,$3f,$00,$3f,$3f,$3f,$3e,$e0 pattern176: db $51,$00,$00,$00,$46,$00,$4b,$00,$e0 pattern177: db $54,$00,$55,$00,$00,$00,$55,$55,$e0 pattern178: db $55,$00,$52,$00,$50,$00,$52,$00,$e0 pattern179: db $32,$00,$32,$00,$32,$00,$32,$00,$e0 pattern180: db $34,$35,$35,$00,$35,$35,$35,$00,$e0 pattern181: db $46,$00,$00,$00,$46,$00,$4b,$00,$e0 pattern182 db $35,$35,$35,$00,$35,$35,$35,$34,$e0 pattern183: db $00,$00,$00,$00,$46,$00,$4b,$00,$e0 pattern184: db $07,$00,$00,$00,$07,$00,$0c,$00,$e0 pattern185: db $15,$00,$16,$00,$00,$00,$16,$16,$e0 pattern186: db $16,$00,$13,$00,$11,$00,$13,$00,$e0 pattern187: db $33,$00,$33,$00,$33,$00,$33,$00,$e0 pattern188: db $36,$00,$00,$00,$00,$00,$00,$00,$e0 pattern189: db $36,$36,$36,$00,$36,$36,$36,$35,$e0 pattern190: db $0e,$01,$0e,$01,$0e,$00,$02,$00,$e0 pattern191: db $0e,$00,$02,$00,$0e,$00,$02,$00,$e0 pattern192: db $02,$00,$0e,$00,$02,$00,$0e,$00,$e0 pattern193: db $10,$01,$10,$01,$10,$00,$04,$00,$e0 pattern194: db $10,$00,$04,$00,$10,$00,$04,$00,$e0 pattern195: db $04,$00,$10,$00,$04,$00,$10,$00,$e0 pattern196: db $00,$00,$00,$00,$3a,$00,$30,$00,$e0 pattern197: db $22,$00,$2e,$00,$22,$2e,$00,$38,$e0 pattern198: db $25,$31,$00,$3d,$25,$31,$00,$3b,$e0 pattern199: db $23,$2f,$00,$3b,$23,$2f,$00,$39,$e0 pattern200: db $22,$2e,$00,$3a,$22,$2e,$00,$38,$e0 pattern201: db $24,$30,$3c,$30,$24,$30,$3a,$30,$e0 pattern202: db $27,$33,$3f,$33,$27,$33,$3d,$33,$e0 pattern203: db $25,$31,$3d,$31,$25,$31,$3b,$31,$e0 pattern204: db $30,$00,$00,$00,$00,$00,$00,$00,$e0 pattern205: db $35,$3f,$3c,$3d,$15,$3f,$3c,$3d,$e0 pattern206: db $35,$3f,$3c,$3d,$35,$3f,$3c,$3d,$e0 pattern207: db $00,$00,$00,$00,$00,$39,$38,$37,$e0 pattern208: db $36,$35,$33,$30,$31,$35,$33,$30,$e0 pattern209: db $31,$35,$33,$30,$31,$35,$33,$30,$e0 pattern210: db $15,$1f,$1c,$1d,$15,$1f,$1c,$1d,$e0 pattern211: db $15,$1f,$1c,$00,$1c,$1f,$1c,$1d,$e0 pattern212: db $1c,$1f,$1c,$1d,$1c,$1f,$1c,$1d,$e0 pattern213: db $35,$3f,$3c,$31,$35,$3f,$3c,$31,$e0 pattern214: db $15,$13,$11,$00,$00,$00,$00,$00,$e0 pattern215: db $27,$00,$27,$00,$27,$00,$27,$00,$e0 pattern216: db $3d,$38,$33,$38,$3d,$38,$33,$38,$e0 pattern217: db $2f,$00,$00,$00,$2e,$00,$2c,$00,$e0 pattern218: db $29,$2a,$2c,$00,$2c,$2e,$2f,$00,$e0 pattern219: db $2e,$2c,$2e,$00,$2e,$2c,$2a,$29,$e0 pattern220: db $35,$00,$35,$00,$35,$00,$35,$00,$e0 pattern221: db $29,$00,$29,$00,$29,$00,$29,$00,$e0 pattern222: db $3f,$3a,$35,$3a,$3f,$3a,$35,$3a,$e0 pattern223: db $3c,$00,$00,$00,$00,$00,$00,$00,$e0 pattern224: db $31,$00,$00,$00,$30,$00,$2e,$00,$e0 pattern225: db $2b,$2c,$2e,$00,$2e,$30,$31,$00,$e0 pattern226: db $2e,$31,$35,$38,$2e,$31,$35,$38,$e0 pattern227: db $30,$2e,$30,$00,$30,$2e,$2c,$2b,$e0 pattern228: db $2e,$00,$2e,$00,$2e,$00,$2e,$00,$e0 pattern229: db $3f,$3f,$3a,$3f,$3f,$3f,$3a,$3f,$e0 pattern230: db $36,$00,$00,$00,$35,$00,$33,$00,$e0 pattern231: db $30,$31,$33,$00,$33,$35,$36,$00,$e0 pattern232: db $35,$33,$35,$00,$35,$33,$31,$30,$e0 pattern233: db $30,$00,$30,$00,$30,$00,$30,$00,$e0 pattern234: db $3f,$3f,$3c,$3f,$3f,$3f,$3c,$3f,$e0 pattern235: db $37,$00,$00,$00,$00,$00,$00,$00,$e0 pattern236: db $38,$00,$00,$00,$37,$00,$35,$00,$e0 pattern237: db $32,$33,$35,$00,$35,$37,$38,$00,$e0 pattern238: db $37,$35,$37,$00,$37,$35,$33,$32,$e0 pattern239: db $26,$00,$26,$00,$26,$00,$26,$00,$e0 pattern240: db $35,$35,$32,$35,$35,$35,$32,$35,$e0 pattern241: db $2d,$00,$00,$00,$00,$00,$00,$00,$e0 pattern242: db $2e,$00,$00,$00,$2d,$00,$2b,$00,$e0 pattern243: db $28,$29,$2b,$00,$2b,$2d,$2e,$00,$e0 pattern244: db $2d,$2b,$2d,$00,$2d,$2b,$29,$28,$e0 pattern245: db $3f,$00,$3a,$00,$36,$00,$33,$00,$e0 pattern246: db $36,$36,$33,$36,$36,$36,$33,$36,$e0 pattern247: db $5f,$00,$5a,$00,$58,$00,$56,$00,$e0 pattern248: db $5d,$00,$5a,$00,$56,$00,$53,$00,$e0 pattern249: db $5a,$00,$56,$00,$53,$00,$4e,$00,$e0 pattern250: db $3a,$00,$35,$00,$31,$00,$35,$00,$e0 pattern251: db $3d,$00,$35,$00,$31,$00,$35,$00,$e0 pattern252: db $3b,$00,$35,$00,$31,$00,$35,$00,$e0 pattern253: db $3c,$00,$37,$00,$33,$00,$37,$00,$e0 pattern254: db $3f,$00,$37,$00,$33,$00,$37,$00,$e0 pattern255: db $3d,$00,$37,$00,$33,$00,$37,$00,$e0 pattern256: db $3d,$01,$37,$01,$33,$01,$37,$01,$e0 pattern257: db $3c,$01,$37,$01,$53,$53,$57,$57,$e0 pattern258: db $55,$53,$50,$51,$55,$53,$50,$51,$e0 pattern259: db $35,$33,$30,$31,$35,$33,$30,$31,$e0 pattern260: db $1a,$18,$15,$16,$1a,$18,$15,$16,$e0 .DB ""ZX10 TI 0.1"", 0 .END ",16283,True,4597.85554484619,median "*&---------------------------------------------------------------------* *& Report ZANGRY_BIRDS *& Just for fun *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zangry_birds. DATA: lo_excel TYPE REF TO zcl_excel, lo_excel_writer TYPE REF TO zif_excel_writer, lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_border_light TYPE REF TO zcl_excel_style_border, lo_style_color0 TYPE REF TO zcl_excel_style, lo_style_color1 TYPE REF TO zcl_excel_style, lo_style_color2 TYPE REF TO zcl_excel_style, lo_style_color3 TYPE REF TO zcl_excel_style, lo_style_color4 TYPE REF TO zcl_excel_style, lo_style_color5 TYPE REF TO zcl_excel_style, lo_style_color6 TYPE REF TO zcl_excel_style, lo_style_color7 TYPE REF TO zcl_excel_style, lo_style_credit TYPE REF TO zcl_excel_style, lo_style_link TYPE REF TO zcl_excel_style, lo_column TYPE REF TO zcl_excel_column, lo_row TYPE REF TO zcl_excel_row, lo_hyperlink TYPE REF TO zcl_excel_hyperlink. DATA: lv_style_color0_guid TYPE zexcel_cell_style, lv_style_color1_guid TYPE zexcel_cell_style, lv_style_color2_guid TYPE zexcel_cell_style, lv_style_color3_guid TYPE zexcel_cell_style, lv_style_color4_guid TYPE zexcel_cell_style, lv_style_color5_guid TYPE zexcel_cell_style, lv_style_color6_guid TYPE zexcel_cell_style, lv_style_color7_guid TYPE zexcel_cell_style, lv_style_credit_guid TYPE zexcel_cell_style, lv_style_link_guid TYPE zexcel_cell_style. DATA: lv_col_str TYPE zexcel_cell_column_alpha, lv_row TYPE i, lv_col TYPE i, lt_mapper TYPE TABLE OF zexcel_cell_style, ls_mapper TYPE zexcel_cell_style. DATA: lv_file TYPE xstring, lv_bytecount TYPE i, lt_file_tab TYPE solix_tab. DATA: lv_full_path TYPE string, lv_workdir TYPE string, lv_file_separator TYPE c. CONSTANTS: lv_default_file_name TYPE string VALUE 'angry_birds.xlsx'. PARAMETERS: p_path TYPE zexcel_export_dir. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path. lv_workdir = p_path. cl_gui_frontend_services=>directory_browse( EXPORTING initial_folder = lv_workdir CHANGING selected_folder = lv_workdir ). p_path = lv_workdir. INITIALIZATION. cl_gui_frontend_services=>get_sapgui_workdir( CHANGING sapworkdir = lv_workdir ). cl_gui_cfw=>flush( ). p_path = lv_workdir. START-OF-SELECTION. IF p_path IS INITIAL. p_path = lv_workdir. ENDIF. cl_gui_frontend_services=>get_file_separator( CHANGING file_separator = lv_file_separator ). CONCATENATE p_path lv_file_separator lv_default_file_name INTO lv_full_path. "" Creates active sheet CREATE OBJECT lo_excel. CREATE OBJECT lo_border_light. lo_border_light->border_color-rgb = zcl_excel_style_color=>c_white. lo_border_light->border_style = zcl_excel_style_border=>c_border_thin. "" Create color white lo_style_color0 = lo_excel->add_new_style( ). lo_style_color0->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color0->fill->fgcolor-rgb = 'FFFFFFFF'. lo_style_color0->borders->allborders = lo_border_light. lv_style_color0_guid = lo_style_color0->get_guid( ). "" Create color black lo_style_color1 = lo_excel->add_new_style( ). lo_style_color1->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color1->fill->fgcolor-rgb = 'FF252525'. lo_style_color1->borders->allborders = lo_border_light. lv_style_color1_guid = lo_style_color1->get_guid( ). "" Create color dark green lo_style_color2 = lo_excel->add_new_style( ). lo_style_color2->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color2->fill->fgcolor-rgb = 'FF75913A'. lo_style_color2->borders->allborders = lo_border_light. lv_style_color2_guid = lo_style_color2->get_guid( ). "" Create color light green lo_style_color3 = lo_excel->add_new_style( ). lo_style_color3->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color3->fill->fgcolor-rgb = 'FF9DFB73'. lo_style_color3->borders->allborders = lo_border_light. lv_style_color3_guid = lo_style_color3->get_guid( ). "" Create color green lo_style_color4 = lo_excel->add_new_style( ). lo_style_color4->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color4->fill->fgcolor-rgb = 'FF92CF56'. lo_style_color4->borders->allborders = lo_border_light. lv_style_color4_guid = lo_style_color4->get_guid( ). "" Create color 2dark green lo_style_color5 = lo_excel->add_new_style( ). lo_style_color5->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color5->fill->fgcolor-rgb = 'FF506228'. lo_style_color5->borders->allborders = lo_border_light. lv_style_color5_guid = lo_style_color5->get_guid( ). "" Create color yellow lo_style_color6 = lo_excel->add_new_style( ). lo_style_color6->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color6->fill->fgcolor-rgb = 'FFC3E224'. lo_style_color6->borders->allborders = lo_border_light. lv_style_color6_guid = lo_style_color6->get_guid( ). "" Create color yellow lo_style_color7 = lo_excel->add_new_style( ). lo_style_color7->fill->filltype = zcl_excel_style_fill=>c_fill_solid. lo_style_color7->fill->fgcolor-rgb = 'FFB3C14F'. lo_style_color7->borders->allborders = lo_border_light. lv_style_color7_guid = lo_style_color7->get_guid( ). "" Credits lo_style_credit = lo_excel->add_new_style( ). lo_style_credit->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. lo_style_credit->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. lo_style_credit->font->size = 20. lv_style_credit_guid = lo_style_credit->get_guid( ). "" Link lo_style_link = lo_excel->add_new_style( ). lo_style_link->alignment->horizontal = zcl_excel_style_alignment=>c_horizontal_center. lo_style_link->alignment->vertical = zcl_excel_style_alignment=>c_vertical_center. * lo_style_link->font->size = 20. lv_style_link_guid = lo_style_link->get_guid( ). "" Create image map "" line 2 DO 30 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 3 DO 28 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 4 DO 27 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 5 DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 15 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 6 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 7 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 8 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 9 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 10 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 11 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 12 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 13 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 14 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 12 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 15 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 16 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 17 DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 18 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 19 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 27 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 20 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 23 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 21 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 19 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 22 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 23 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 24 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 25 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 26 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 27 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 28 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color6_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 29 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 30 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 31 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color4_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 32 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color5_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 33 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 34 DO 3 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 35 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 36 DO 4 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 37 DO 5 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color7_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 38 DO 6 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 10 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 11 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 39 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 22 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 1 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 40 DO 7 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 17 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 41 DO 8 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 3 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 15 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 42 DO 9 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 9 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 2 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 43 DO 11 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 5 TIMES. APPEND lv_style_color3_guid TO lt_mapper. ENDDO. DO 7 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 44 DO 13 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 6 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. DO 4 TIMES. APPEND lv_style_color2_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 45 DO 16 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 13 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" line 46 DO 18 TIMES. APPEND lv_style_color0_guid TO lt_mapper. ENDDO. DO 8 TIMES. APPEND lv_style_color1_guid TO lt_mapper. ENDDO. APPEND INITIAL LINE TO lt_mapper. "" escape "" Get active sheet lo_worksheet = lo_excel->get_active_worksheet( ). lo_worksheet->set_title( ip_title = 'Angry Birds' ). lv_row = 1. lv_col = 1. LOOP AT lt_mapper INTO ls_mapper. lv_col_str = zcl_excel_common=>convert_column2alpha( lv_col ). IF ls_mapper IS INITIAL. lo_row = lo_worksheet->get_row( ip_row = lv_row ). lo_row->set_row_height( ip_row_height = 8 ). lv_col = 1. lv_row = lv_row + 1. CONTINUE. ENDIF. lo_worksheet->set_cell( ip_column = lv_col_str ip_row = lv_row ip_value = space ip_style = ls_mapper ). lv_col = lv_col + 1. lo_column = lo_worksheet->get_column( ip_column = lv_col_str ). lo_column->set_width( ip_width = 2 ). ENDLOOP. lo_worksheet->set_show_gridlines( i_show_gridlines = abap_false ). lo_worksheet->set_cell( ip_column = 'AP' ip_row = 15 ip_value = 'Created with abap2xlsx' ip_style = lv_style_credit_guid ). lo_hyperlink = zcl_excel_hyperlink=>create_external_link( iv_url = 'http://www.plinky.it/abap/abap2xlsx.php' ). lo_worksheet->set_cell( ip_column = 'AP' ip_row = 24 ip_value = 'http://www.plinky.it/abap/abap2xlsx.php' ip_style = lv_style_link_guid ip_hyperlink = lo_hyperlink ). lo_column = lo_worksheet->get_column( ip_column = 'AP' ). lo_column->set_auto_size( ip_auto_size = abap_true ). lo_worksheet->set_merge( ip_row = 15 ip_column_start = 'AP' ip_row_to = 22 ip_column_end = 'AR' ). lo_worksheet->set_merge( ip_row = 24 ip_column_start = 'AP' ip_row_to = 26 ip_column_end = 'AR' ). CREATE OBJECT lo_excel_writer TYPE zcl_excel_writer_2007. lv_file = lo_excel_writer->write_file( lo_excel ). "" Convert to binary CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING buffer = lv_file IMPORTING output_length = lv_bytecount TABLES binary_tab = lt_file_tab. * "" This method is only available on AS ABAP > 6.40 * lt_file_tab = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_file ). * lv_bytecount = xstrlen( lv_file ). "" Save the file cl_gui_frontend_services=>gui_download( EXPORTING bin_filesize = lv_bytecount filename = lv_full_path filetype = 'BIN' CHANGING data_tab = lt_file_tab ). ",13101,True,4580.386071962828,median "COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: GeoCalc FILE: spreadsheetMethodStyle.asm AUTHOR: Gene Anderson, Mar 2, 1991 ROUTINES: Name Description ---- ----------- MSG_VIS_TEXT_SET_FONT Set the font for the current selection MSG_VIS_TEXT_SET_STYLE Set the style for the current selection MSG_VIS_TEXT_SET_POINT_SIZE Set the pointsize for the selection MSG_VIS_TEXT_SET_SMALLER_POINT_SIZE Set the next smaller pointsize MSG_VIS_TEXT_SET_LARGER_POINT_SIZE Set the next larger pointsize MSG_VIS_TEXT_SET_PARA_ATTRIBUTES Set the justification for the selection MSG_VIS_TEXT_SET_COLOR Set the text color MSG_VIS_TEXT_SET_GRAY_SCREEN Set the text hatch pattern MSG_VIS_TEXT_SET_CHAR_BG_COLOR Set the background color MSG_VIS_TEXT_SET_CHAR_BG_GRAY_SCREEN Set the background hatch pattern MSG_VIS_TEXT_SET_TRACK_KERNING Set track kerning MSG_VIS_TEXT_SET_FONT_WIDTH Set font width MSG_VIS_TEXT_SET_FONT_WEIGHT Set font weight MSG_SPREADSHEET_SET_NUM_FORMAT Set the numeric format for selection INT SetAttrsCommon Common attribute setting, part I INT SetAttrsFinish Common attribute setting, part II REVISION HISTORY: Name Date Description ---- ---- ----------- Gene 3/ 2/91 Initial revision DESCRIPTION: Method handlers for setting style/cell attributes. $Id: spreadsheetMethodStyle.asm,v 1.2 98/03/14 21:55:02 gene Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AttrCode segment resource ; ; NOTE: -1 for SAS_columnCallback or SAS_wholeCallback means that ; paritcular optimization cannot be used. ; NOTE: note that SAS_wholeCallback is just the offset of the routine; ; it must be a far routine, but in the AttrCode segment. ; SetAttrStruct struct SAS_cellCallback nptr.near ;callback for single cell SAS_columnCallback nptr.near ;callback for column SAS_wholeCallback nptr ;offset of callback for whole SAS_attrOff word ;offset in CellAttrs SAS_notifyRoutine nptr.near ;routine for notification SAS_notifyFlags SpreadsheetNotifyFlags ;flags for update SetAttrStruct ends COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetTrackKerning %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set track kerning for selected cells CALLED BY: MSG_VIS_TEXT_SET_TRACK_KERNING PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message ss:bp - VisTextSetTrackKerningParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/21/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetTrackKerning method dynamic SpreadsheetClass, MSG_VIS_TEXT_SET_TRACK_KERNING mov ax, {word}ss:[bp].VTSTKP_trackKerning mov bx, offset setTrackKernParams GOTO SetSpreadsheetAttrs setTrackKernParams SetAttrStruct < SetWordAttr, ;cell SetWordAttr, ;column offset ChangeWordAttrCallback, ;spreadsheet offset CA_trackKern, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetTrackKerning endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetFontWeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set font weight for selected cells CALLED BY: MSG_VIS_TEXT_SET_FONT_WEIGHT PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message ss:bp - VisTextSetFontWeightParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/21/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetFontWeight method dynamic SpreadsheetClass, MSG_VIS_TEXT_SET_FONT_WEIGHT mov al, ss:[bp].VTSFWP_fontWeight mov bx, offset setFontWeightParams GOTO SetSpreadsheetAttrs setFontWeightParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_fontWeight, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetFontWeight endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetFontWidth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set font width for selected cells CALLED BY: MSG_VIS_TEXT_SET_FONT_WIDTH PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message ss:bp - VisTextSetFontWidthParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/21/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetFontWidth method dynamic SpreadsheetClass, MSG_VIS_TEXT_SET_FONT_WIDTH mov al, ss:[bp].VTSFWIP_fontWidth mov bx, offset setFontWidthParams GOTO SetSpreadsheetAttrs setFontWidthParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_fontWidth, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetFontWidth endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetJustification %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set justification for current selection. CALLED BY: MSG_VIS_TEXT_SET_PARA_ATTRIBUTES PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetParaAttrAttributesParams VTSPAAP_bitsToSet - VisTextParaAttrAttributes VTSPAAP_bitsToClear - VisTextParaAttrAttributes RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/27/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetJustification method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_PARA_ATTRIBUTES mov ax, ss:[bp].VTSPAAP_bitsToSet andnf ax, mask VTPAA_JUSTIFICATION if (offset VTPAA_JUSTIFICATION ne 0) mov cl, offset VTPAA_JUSTIFICATION shr ax, cl ;al <- Justification endif mov bx, offset setJustificationParams GOTO SetSpreadsheetAttrs setJustificationParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_justification, AttrUpdateUIRedrawSelection, mask SNF_JUSTIFICATION > SpreadsheetSetJustification endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetTextColor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the text color for the selection CALLED BY: MSG_VIS_TEXT_SET_COLOR PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetColorParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetTextColor method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_COLOR mov ax, {word}ss:[bp].VTSCP_color.CQ_redOrIndex mov dx, {word}ss:[bp].VTSCP_color.CQ_green ;dl <- index/red dh <- ColorFlag ;al <- green ah <- blue mov bx, offset setTextColorParams GOTO SetSpreadsheetAttrs setTextColorParams SetAttrStruct < SetDWordAttr, ;cell SetDWordAttr, ;column offset ChangeDWordAttrCallback, ;spreadsheet offset CA_textAttrs.AI_color, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetTextColor endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetTextGrayScreen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the text color for the selection CALLED BY: MSG_VIS_TEXT_SET_GRAY_SCREEN PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetGrayScreenParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetTextGrayScreen method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_GRAY_SCREEN mov al, ss:[bp].VTSGSP_grayScreen ;al <- hatch pattern mov bx, offset setTextGrayScreenParams GOTO SetSpreadsheetAttrs setTextGrayScreenParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_textAttrs.AI_grayScreen, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetTextGrayScreen endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetBackgroundColor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the background color for the selection CALLED BY: MSG_VIS_TEXT_SET_CHAR_BG_COLOR PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetColorParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: this cannot be optimized the same as the other attribute setting routines because empty cells are not drawn, and a background color requires drawing even on an empty cell. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetBackgroundColor method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_CHAR_BG_COLOR mov ax, {word}ss:[bp].VTSCP_color.CQ_redOrIndex mov dx, {word}ss:[bp].VTSCP_color.CQ_green ;al <- index/red ah <- ColorFlag ;dl <- green dh <- blue mov bx, offset setBackgroundColorParams GOTO SetSpreadsheetAttrs setBackgroundColorParams SetAttrStruct < SetDWordAttr, ;cell -1, ;can't optimize columns -1, ;can't optimize whole ssheet offset CA_bgAttrs.AI_color, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetBackgroundColor endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetCharBGGrayScreen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the text color for the selection CALLED BY: MSG_VIS_TEXT_SET_CHAR_BG_GRAY_SCREEN PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetGrayScreenParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: unlike background color, this *can* be optimized in the standard fashion, because if a cell doesn't exist, it's background color is white, and therefore is unaffected by grayscreen. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/ 7/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetCharBGGrayScreen method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_CHAR_BG_GRAY_SCREEN mov al, ss:[bp].VTSGSP_grayScreen ;al <- hatch pattern mov bx, offset setBGGrayScreenParams GOTO SetSpreadsheetAttrs setBGGrayScreenParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_bgAttrs.AI_grayScreen, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetCharBGGrayScreen endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetNumFormat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the number format for the selected range CALLED BY: MSG_SPREADSHEET_SET_NUM_FORMAT PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method cx - format token RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- cheng 3/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetNumFormat method SpreadsheetClass, \\ MSG_SPREADSHEET_SET_NUM_FORMAT mov ax, cx ;pass format token to callback mov bx, offset setNumFormatParams GOTO SetSpreadsheetAttrs setNumFormatParams SetAttrStruct < SetWordAttr, ;cell SetWordAttr, ;column offset ChangeWordAttrCallback, ;spreadsheet offset CA_format, AttrUpdateUIRedrawSelection, mask SNF_FORMAT_CHANGE > SpreadsheetSetNumFormat endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetFont %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the font for the current selection CALLED BY: MSG_VIS_TEXT_SET_FONT_ID PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetFontIDParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetFont method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_FONT_ID mov ax, ss:[bp].VTSFIDP_fontID ;ax <- FontID mov bx, offset setFontParams GOTO SetSpreadsheetAttrs setFontParams SetAttrStruct < SetWordAttr, ;cell SetWordAttr, ;column offset ChangeWordAttrCallback, ;spreadsheet offset CA_font, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetFont endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the pointsize for the current selection CALLED BY: MSG_SPREADSHEET_SET_POINTSIZE PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetPointSizeParams RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: we cannot optimize setting the pointsize for column operations because empty cells in a column with a non-default pointsize need to exist as the new pointsize affects the row height. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetPointsize method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_POINT_SIZE mov ax, ss:[bp].VTSPSP_pointSize.WWF_int mov cx, ss:[bp].VTSPSP_pointSize.WWF_frac shlwbf axch shlwbf axch shlwbf axch ;ax <- pointsize * 8 mov bx, offset setPointsizeParams GOTO SetSpreadsheetAttrs setPointsizeParams SetAttrStruct < SetWordAttr, ;cell -1, ;can't optimize columns (yet) offset ChangeWordAttrCallback, ;spreadsheet offset CA_pointsize, SetPointsizeRecalc, mask SNF_CHAR_ATTR or mask SNF_CELL_WIDTH_HEIGHT > SpreadsheetSetPointsize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetPointsizeRecalc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Recalculate and redraw after setting the pointsize CALLED BY: SpreadsheetSet{,Smaller,Larger}Pointsize(), PASS: ds:si - ptr to spreadsheet instance RETURN: none DESTROYED: ax, bx, cx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 6/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetPointsizeRecalc proc near .enter ; ; Recalculate row heights ; call RecalcRowHeightsFar ; ; Recalcuate the document size for the view, update the UI, ; and redraw ; mov ax, mask SNF_CHAR_ATTR or mask SNF_CELL_WIDTH_HEIGHT call UpdateDocUIRedrawAll .leave ret SetPointsizeRecalc endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetSmallerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set next smaller pointsize for current selection CALLED BY: MSG_SPREADSHEET_SET_SMALLER_POINTSIZE PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: we cannot optimize setting the pointsize for column operations because empty cells in a column with a non-default pointsize need to exist as the new pointsize affects the row height. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 6/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ pointSizeTable word \\ 4*8, 6*8, 8*8, 9*8, 10*8, 12*8, 14*8, 18*8, 24*8, 36*8, \\ 54*8, 72*8, 144*8, 180*8, 216*8 MIN_TABLE_POINTSIZE equ 4*8 MAX_TABLE_POINTSIZE equ 216*8 TABLE_POINTSIZE_INC equ 72*8 SpreadsheetSetSmallerPointsize method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_SMALLER_POINT_SIZE mov bx, offset setPointsizeSmallerParams GOTO SetSpreadsheetAttrs setPointsizeSmallerParams SetAttrStruct < SetSmallerPointsize, ;cell -1, ;can't optimize columns (yet) offset ChangeSmallerPointsizeCallback, ;spreadsheet offset CA_pointsize, SetPointsizeRecalc, mask SNF_CHAR_ATTR or mask SNF_CELL_WIDTH_HEIGHT > SpreadsheetSetSmallerPointsize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeSmallerPointsizeCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change pointsize to smaller entry for all CellAttrs CALLED BY: SpreadsheetSetSmallerPointsize() via StyleTokenChangeAttr() PASS: ds:di - ptr to CellAttrs structure RETURN: carry - set to abort DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeSmallerPointsizeCallback proc far uses ax .enter EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > mov ax, ds:[di].CA_pointsize call FindSmallerPointsize mov ds:[di].CA_pointsize, ax EC clc ;carry <- don't abort .leave ret ChangeSmallerPointsizeCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetSmallerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set next smaller pointsize for a cell CALLED BY: SpreadsheetSetSmallerPointsize() via RangeEnum() PASS: ss:bp - inherited locals RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/27/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetSmallerPointsize proc near locals local CellLocals .enter inherit mov ax, ss:locals.CL_cellAttrs.CA_pointsize call FindSmallerPointsize mov ss:locals.CL_cellAttrs.CA_pointsize, ax .leave ret SetSmallerPointsize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindSmallerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the next smaller pointsize CALLED BY: SetSmallerPointsize() PASS: ax - current pointsize RETURN: ax - next smaller pointsize DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindSmallerPointsize proc near uses si .enter ; ; Before start of table? ; cmp ax, MIN_TABLE_POINTSIZE je setSize ; ; After end of table? ; cmp ax, MAX_TABLE_POINTSIZE ja bigPointsize clr si sizeLoop: cmp ax, cs:pointSizeTable[si] jbe foundSize add si, (size word) jmp sizeLoop bigPointsize: ; ; See if it is just past the end of the table ; cmp ax, MAX_TABLE_POINTSIZE + TABLE_POINTSIZE_INC jb useLast sub ax, (TABLE_POINTSIZE_INC) jmp setSize ; ; If just past the end of the table, use the last value ; useLast: mov ax, MAX_TABLE_POINTSIZE jmp setSize foundSize: mov ax, cs:pointSizeTable[si][-2] setSize: .leave ret FindSmallerPointsize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetLargerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set next larger pointsize for current selection CALLED BY: MSG_SPREADSHEET_SET_LARGER_POINTSIZE PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: we cannot optimize setting the pointsize for column operations because empty cells in a column with a non-default pointsize need to exist as the new pointsize affects the row height. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 6/ 2/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetLargerPointsize method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_LARGER_POINT_SIZE mov bx, offset setPointsizeLargerParams GOTO SetSpreadsheetAttrs setPointsizeLargerParams SetAttrStruct < SetLargerPointsize, ;cell -1, ;can't optimize columns (yet) offset ChangeLargerPointsizeCallback, ;spreadsheet offset CA_pointsize, SetPointsizeRecalc, mask SNF_CHAR_ATTR or mask SNF_CELL_WIDTH_HEIGHT > SpreadsheetSetLargerPointsize endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeLargerPointsizeCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change pointsize to larger entry for all CellAttrs CALLED BY: SpreadsheetSetLargerPointsize() via StyleTokenChangeAttr() PASS: ds:di - ptr to CellAttrs structure RETURN: carry - set to abort DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeLargerPointsizeCallback proc far uses ax .enter EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > mov ax, ds:[di].CA_pointsize call FindLargerPointsize mov ds:[di].CA_pointsize, ax EC clc ;carry <- don't abort .leave ret ChangeLargerPointsizeCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetLargerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set next larger pointsize for a cell CALLED BY: SetAttrs() PASS: ss:bp - inherited locals RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 5/27/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetLargerPointsize proc near locals local CellLocals .enter inherit mov ax, ss:locals.CL_cellAttrs.CA_pointsize call FindLargerPointsize mov ss:locals.CL_cellAttrs.CA_pointsize, ax .leave ret SetLargerPointsize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FindLargerPointsize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Find the next larger pointsize CALLED BY: SetLargerPointsize() PASS: ax - pointsize RETURN: ax - next larger pointsize DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FindLargerPointsize proc near uses si .enter ; ; After end of table? ; cmp ax, MAX_TABLE_POINTSIZE jae bigPointsize clr si sizeLoop: cmp ax, cs:pointSizeTable[si] jb foundSize add si, (size word) jmp sizeLoop bigPointsize: add ax, TABLE_POINTSIZE_INC cmp ax, MAX_POINT_SIZE*8 jbe setSize mov ax, MAX_POINT_SIZE*8 jmp setSize foundSize: mov ax, cs:pointSizeTable[si] setSize: .leave ret FindLargerPointsize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetTextStyle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the text style for the current selection CALLED BY: MSG_SPREADSHEET_SET_STYLE PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the method ss:bp - VisTextSetTextStyleParams VTSTSP_styleBitsToSet (TextStyle) VTSTSP_styleBitsToClear (TextStyle) dx - size (VisTextSetTextStyleParams) RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 4/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetTextStyle method dynamic SpreadsheetClass, \\ MSG_VIS_TEXT_SET_TEXT_STYLE mov ah, {byte}ss:[bp].VTSTSP_styleBitsToSet mov al, {byte}ss:[bp].VTSTSP_styleBitsToClear EC < tst {byte}ss:[bp].VTSTSP_styleBitsToSet.high > EC < ERROR_NZ UNUSED_STYLE_BITS_NON_ZERO > EC < tst {byte}ss:[bp].VTSTSP_styleBitsToClear.high > EC < ERROR_NZ UNUSED_STYLE_BITS_NON_ZERO > mov bx, offset setTextStyleParams GOTO SetSpreadsheetAttrs setTextStyleParams SetAttrStruct < SetTextStyle, ;cell SetTextStyle, ;column offset ChangeTextStyleCallback, ;spreadsheet offset CA_style, AttrUpdateUIRedrawSelection, mask SNF_CHAR_ATTR > SpreadsheetSetTextStyle endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeTextStyleCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change the TextStyle for all cells CALLED BY: SpreadsheetSetStyle() via StyleTokenChangeAttr() PASS: ds:di - ptr to CellAttrs ss:bp - inherited locals CL_data1.low - TextStyle to clear CL_data1.high - TextStyle to set RETURN: carry - set to abort DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeTextStyleCallback proc far locals local CellLocals .enter inherit EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > mov ax, ss:locals.CL_data1 ;al <- set, ah <- clear not al ;al <- bits to keep andnf ds:[di].CA_style, al ;clear other bits ornf ds:[di].CA_style, ah ;set specified bits EC clc ;carry <- don't abort .leave ret ChangeTextStyleCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetTextStyle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set/Clear style bits for a cell CALLED BY: CellSetAttrs() PASS: ss:bp - inherited locals CL_data1.low - TextStyle to clear CL_data1.high - TextStyle to set RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 4/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetTextStyle proc near locals local CellLocals .enter inherit mov ax, ss:locals.CL_data1 ;al, ah <- TextStyle not al ;al <- bits to keep andnf ss:locals.CL_cellAttrs.CA_style, al ornf ss:locals.CL_cellAttrs.CA_style, ah .leave ret SetTextStyle endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetAttrsCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common cell attribute setting CALLED BY: CellSetAttrs() PASS: ss:bp - ptr to CallRangeEnum() local variables ds:si - SpreadsheetInstance ptr (ax,cx) - cell coordinates (r,c) carry - set if cell has data *es:di - ptr to cell data, if any RETURN: *es:di - ptr to cell data ss:bp.CL_cellAttrs - current cell attributes carry - unchanged DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 4/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetAttrsCommon proc near uses ax, dx locals local CellLocals .enter inherit EC < call ECCheckInstancePtr ;> pushf ;preserve carry push es, di jnc noData ;branch if cell empty mov di, es:[di] ;es:di <- ptr to cell mov ax, es:[di].CC_attrs ;ax <- style token lea di, locals.CL_cellAttrs segmov es, ss ;es:di <- ptr to cellAttrs call StyleGetStyleByTokenFar ;get styles for cell call StyleDeleteStyleByToken ;one less reference to old done: pop es, di popf ;recover carry .leave ret ; ; The cell doesn't exist yet -- get the default attrs for it ; noData: call ColumnGetDefaultAttrs mov ax, dx ;ax <- new style token lea di, locals.CL_cellAttrs segmov es, ss ;es:di <- ptr to cellAttrs call StyleGetStyleByTokenFar jmp done SetAttrsCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetAttrsFinish %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Finish setting cell attributes -- may create cell CALLED BY: CellSetAttrs() PASS: ss:bp - ptr to CallRangeEnum() local variables CL_cellAttrs - set for cell ds:si - ptr to Spreadsheet instance data (ax,cx) - cell coordinates (r,c) carry - set if cell has data *es:di - ptr to cell data RETURN: *es:di - updated if cell created dl - RangeEnumFlags with: REF_ALLOCATED bit set if we've allocated a cell REF_FREED if we've freed a cell DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: assumes CL_cellAttrs is set REVISION HISTORY: Name Date Description ---- ---- ----------- eca 3/ 4/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetAttrsFinish proc near uses ax, bx class SpreadsheetClass locals local CellLocals .enter inherit EC < call ECCheckInstancePtr ;> jc hasData ;branch if cell exists ; ; The cell doesn't exist -- allocate one using the attributes ; we've got. ; lea bx, locals.CL_cellAttrs ;ss:bx <- use passed attrs call AllocEmptyCell SpreadsheetCellLock ;*es:di <- ptr to the cell mov dl, mask REF_CELL_ALLOCATED ;dl <- allocated a cell jmp done ; ; The cell does exist. Make sure it should bother... ; hasData: ; ; Get the token for the specified attributes. ; push es, di, ax lea di, locals.CL_cellAttrs segmov es, ss ;es:di <- ptr to cellAttrs call StyleGetTokenByStyleFar mov bx, ax ;bx <- new style token pop es, di, ax ; ; Is this cell around for a reason? ; push di mov di, es:[di] ;es:di <- ptr to cell cmp es:[di].CC_type, CT_EMPTY ;'empty' cell? jne setAttrs ;branch if not empry tst es:[di].CC_dependencies.high jnz setAttrs ;branch if dependencies tst es:[di].CC_notes.high jnz setAttrs ;branch if notes ; ; NOTE: this uses the default column attrs, not DEFAULT_STYLE_TOKEN ; because we want the cell to go away if it is empty except for ; attributes and those attributes are the default for the column. ; call ColumnGetDefaultAttrs cmp bx, dx ;default attributes? jne setAttrs ;branch if not defaults ; ; Delete one reference (to the default column attributes) ; push ax mov ax, bx ;ax <- attrs from cell call StyleDeleteStyleByToken pop ax ; ; The cell existed only to hold the style attributes, and we're ; about to set those to the default. Nuke the little bugger... ; SpreadsheetCellUnlock clr dx ;dx <- delete the cell SpreadsheetCellReplaceAll mov dl, mask REF_CELL_FREED ;dl <- freed the cell pop di jmp done ; ; The cell exists, has non-default attributes or something else to ; cause it to exist. Set the attributes. ; setAttrs: mov es:[di].CC_attrs, bx ;set new attrs SpreadsheetCellDirty ;mark cell as dirty pop di ;*es:di <- cell data clr dl ;dl <- no change in cells done: .leave ret SetAttrsFinish endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetCellBorders %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set cell borders for the selected cells CALLED BY: MSG_SPREADSHEET_SET_CELL_BORDERS PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message cl - CellBorderInfo to set RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: this cannot be optimized the same as the other attribute setting routines because empty cells are not drawn, and cell borders requires drawing even on an empty cell. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 7/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetCellBorders method dynamic SpreadsheetClass, \\ MSG_SPREADSHEET_SET_CELL_BORDERS mov al, cl ;al <- CellBorderInfo mov bx, offset setCellBorderParams GOTO SetSpreadsheetAttrs setCellBorderParams SetAttrStruct < SetBorders, ;cell -1, ;can't optimize columns -1, ;can't optimize whole ssheet offset CA_border, AttrUpdateUIRedrawSelection, mask SNF_CELL_ATTRS > SpreadsheetSetCellBorders endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetBorders %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set borders for a cell CALLED BY: SpreadsheetSetCellBorders() via RangeEnum() PASS: ss:bp - inherited locals CL_data1.low - CellBorderInfo RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 7/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetBorders proc near uses bx locals local CellLocals .enter inherit ; ; Are we doing outline? ; mov bl, {byte}ss:locals.CL_data1 test bl, mask CBI_OUTLINE jz noOutline ;branch if not outline ; ; We're doing outline -- add the appropriate sides ; clr bl ;bl <- CellBorderInfo cmp ax, ss:locals.CL_params.REP_bounds.R_top jne notTop ornf bl, mask CBI_TOP notTop: cmp ax, ss:locals.CL_params.REP_bounds.R_bottom jne notBottom ornf bl, mask CBI_BOTTOM notBottom: cmp cx, ss:locals.CL_params.REP_bounds.R_left jne notLeft ornf bl, mask CBI_LEFT notLeft: cmp cx, ss:locals.CL_params.REP_bounds.R_right jne notRight ornf bl, mask CBI_RIGHT notRight: ; ; Set the CellBorderInfo flags for the cell ; noOutline: mov ss:locals.CL_cellAttrs.CA_border, bl .leave ret SetBorders endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetBorderColor %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set border color for selected cells CALLED BY: MSG_SPREADSHEET_SET_BORDER_COLOR PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message ch - ColorFlag CF_INDEX: cl - Color CF_RGB: cl - red dl - green dh - blue RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: unlike cell borders, this routine *can* be optimized because if a cell doesn't exist, it has no cell borders which are therefore unaffected by color. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 7/30/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetBorderColor method dynamic SpreadsheetClass, MSG_SPREADSHEET_SET_CELL_BORDER_COLOR mov ax, cx ;al, ah <- Color, red mov bx, offset setBorderColorParams GOTO SetSpreadsheetAttrs setBorderColorParams SetAttrStruct < SetDWordAttr, ;cell SetDWordAttr, ;column offset ChangeDWordAttrCallback, ;spreadsheet offset CA_borderAttrs.AI_color, AttrUpdateUIRedrawSelection, mask SNF_CELL_ATTRS > SpreadsheetSetBorderColor endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetSetBorderGrayScreen %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set border gray screen for selected cells CALLED BY: MSG_SPREADSHEET_SET_BORDER_GRAY_SCREEN PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of SpreadsheetClass ax - the message cl - SystemDrawMask RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: NOTE: unlike cell borders, this routine *can* be optimized because if a cell doesn't exist, it has no cell borders which are therefore unaffected by gray screen. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 7/30/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetSetBorderGrayScreen method dynamic SpreadsheetClass, MSG_SPREADSHEET_SET_CELL_BORDER_GRAY_SCREEN mov al, cl ;al <- SystemDrawMask mov bx, offset setBorderGrayScreenParams GOTO SetSpreadsheetAttrs setBorderGrayScreenParams SetAttrStruct < SetByteAttr, ;cell SetByteAttr, ;column offset ChangeByteAttrCallback, ;spreadsheet offset CA_borderAttrs.AI_grayScreen, AttrUpdateUIRedrawSelection, mask SNF_CELL_ATTRS > SpreadsheetSetBorderGrayScreen endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckAllSelected %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: See if the entire spreadsheet is selected CALLED BY: UTILITY PASS: ds:si - ptr to SpreadsheetInstance RETURN: carry - set if entire spreadsheet selected z flag - set (jz) if entire column(s) selected DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 5/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckAllSelected proc near uses ax class SpreadsheetClass .enter ; ; See if there is an entire column selected ; tst ds:[si].SSI_selected.CR_start.CR_row jnz notAllNoColumn mov ax, ds:[si].SSI_selected.CR_end.CR_row cmp ax, ds:[si].SSI_maxRow jb notAllNoColumn ; ; See if there is an entire row selected ; tst ds:[si].SSI_selected.CR_start.CR_column jnz notAll mov ax, ds:[si].SSI_selected.CR_end.CR_column cmp ax, ds:[si].SSI_maxCol jb notAll ; ; The whole spreadsheet is selected (which means entire columns, too) ; clr ax ;z flag <- columns selected stc ;carry <- all selected jmp done ; ; The whole spreadsheet isn't selected, and no entire columns ; notAllNoColumn: or al, 1 ;clears carry, clears z flag jmp done ; ; The whole spreadsheet isn't selected, but entire columns are ; notAll: clr ax ;clears carry, sets z flag done: .leave ret CheckAllSelected endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetSpreadsheetAttrs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common code for setting spreadsheet attributes CALLED BY: UTILITY PASS: *ds:si - Spreadsheet object ax, dx - data to pass to callback cs:bx - ptr to SetAttrStruct RETURN: none DESTROYED: ax, bx, cx, dx, si, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/15/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetSpreadsheetAttrs proc far locals local CellLocals class SpreadsheetClass .enter call SpreadsheetMarkBusy ; ; Do common setup ; mov si, ds:[si] add si, ds:[si].Spreadsheet_offset mov ss:locals.CL_data1, ax ;pass data to callback mov ss:locals.CL_data2, dx ;pass data to callback mov ss:locals.CL_data3, bx ;pass offset of SetAttrStruct ; ; IMPORTANT: invalidate the attributes set in the cached GState. ; This is because while the token may remain the same, the ; attributes it represents no longer do. ; mov ds:[si].SSI_curAttrs, -1 ; ; Check for special cases ; call CheckAllSelected jc doAll ;branch if all selected jz doColumn ;branch if column(s) selected ; ; Call the callback routine for all cells in the selection ; doEnumAll: mov di, mask REF_ALL_CELLS ;di <- all cells callEnum: mov ss:locals.CL_params.REP_callback.offset, offset CellSetAttrs mov ss:locals.CL_params.REP_callback.segment, SEGMENT_CS call CallRangeEnumSelected doRedraw: ; ; Update the UI and redraw appropriatly ; call cs:[bx].SAS_notifyRoutine call SpreadsheetMarkNotBusy .leave ret ; ; The entire spreadsheet is selected -- set the attributes for ; everything in our ever-so-quick way if we can. ; doAll: mov ax, cs:[bx].SAS_wholeCallback ;ax <- callback cmp ax, -1 ;optimization allowed? je doEnumAll ;branch if no optimization mov dx, cs:[bx].SAS_attrOff ;dx <- offset of attribute push bx mov bx, cs mov di, ax ;bx:di <- callback call StyleTokenChangeAttr pop bx jmp doRedraw ; ; One or more columns are selected -- optimize if we can ; doColumn: mov ax, cs:[bx].SAS_columnCallback ;ax <- callback cmp ax, -1 ;optimization allowed? je doEnumAll ;branch if no optimization ; ; Set the default attributes for the columns ; call SetColumnAttrs ; ; Set the attributes for any existing cells ; clr di ;di <- only existing cells jmp callEnum SetSpreadsheetAttrs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetColumnAttrs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set default attributes for the selected columns CALLED BY: SetSpreadsheetAttrs() PASS: ds:si - ptr to Spreadsheet instance cs:bx - ptr to SetAttrStruct ss:bp - inherited locals RETURN: none DESTROYED: ax, cx, dx, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/18/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetColumnAttrs proc near uses es class SpreadsheetClass locals local CellLocals .enter inherit EC < call ECCheckInstancePtr ;> mov cx, ds:[si].SSI_selected.CR_start.CR_column segmov es, ss, di lea di, locals.CL_cellAttrs ;es:di <- ptr to CellAttrs columnLoop: ; ; Get the current attrs ; call ColumnGetDefaultAttrs mov ax, dx ;ax <- attr token for column call StyleGetStyleByTokenFar ;get associated styles call StyleDeleteStyleByToken ; ; Modify the attrs to include what's new ; call cs:[bx].SAS_columnCallback ; ; Set the new default attributes ; call StyleGetTokenByStyleFar ;ax <- new attr token call ColumnSetDefaultAttrs ; ; loop while more columns ; inc cx cmp cx, ds:[si].SSI_selected.CR_end.CR_column jbe columnLoop ;loop while more columns .leave ret SetColumnAttrs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% AttrUpdateUIRedrawSelection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: AttrCode version of UpdateUIRedrawSelection() CALLED BY: UTILITY PASS: ds:si - ptr to Spreadsheet instance cs:bx - ptr to SetAttrStruct RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ AttrUpdateUIRedrawSelection proc near .enter mov ax, cs:[bx].SAS_notifyFlags ;ax <- SpreadsheetNotifyFlags call UpdateUIRedrawSelection .leave ret AttrUpdateUIRedrawSelection endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CellSetAttrs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback routine to set attribute for a cell CALLED BY: SetSpreadsheetAttrs() via RangeEnum() PASS: ss:bp - ptr to CallRangeEnum() local variables ds:si - ptr to SpreadsheetInstance data (ax,cx) - cell coordinates (r,c) carry - set if cell has data *es:di - ptr to cell data, if any CL_data3 - offset of SetAttrStruct CL_data1, CL_data2 - data for callback RETURN: carry - set to abort enum dl - RangeEnumFlags with REF_ALLOCATED bit set if we've allocated a cell. DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: NOTE: this routine uses near callbacks and therefore must have any callback routines in the same segment. REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CellSetAttrs proc far uses bx, di locals local CellLocals .enter inherit call SetAttrsCommon pushf push ax mov bx, ss:locals.CL_data3 ;cs:bx <- ptr to SetAttrStruct call cs:[bx].SAS_cellCallback pop ax popf call SetAttrsFinish clc ;carry <- don't abort .leave ret CellSetAttrs endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetByteAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common code to set a byte attribute CALLED BY: CellSetAttrs() PASS: cs:bx - ptr to SetAttrStruct ss:bp - inherited locals CL_data1.low - attribute RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetByteAttr proc near uses si locals local CellLocals .enter inherit mov si, cs:[bx].SAS_attrOff mov al, {byte}ss:locals.CL_data1 mov {byte}ss:locals.CL_cellAttrs[si], al .leave ret SetByteAttr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetWordAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common code to set a word attribute CALLED BY: CellSetAttrs() PASS: cs:bx - ptr to SetAttrStruct ss:bp - inherited locals CL_data1 - attribute RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetWordAttr proc near uses si locals local CellLocals .enter inherit mov si, cs:[bx].SAS_attrOff mov ax, ss:locals.CL_data1 mov {word}ss:locals.CL_cellAttrs[si], ax .leave ret SetWordAttr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetDWordAttr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Common code to set a byte attribute CALLED BY: CellSetAttrs() PASS: cs:bx - ptr to SetAttrStruct ss:bp - inherited locals CL_data1, CL_data2 - attribute RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/16/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetDWordAttr proc near uses si locals local CellLocals .enter inherit mov si, cs:[bx].SAS_attrOff mov ax, ss:locals.CL_data1 mov {word}ss:locals.CL_cellAttrs[si][0], ax mov ax, ss:locals.CL_data2 mov {word}ss:locals.CL_cellAttrs[si][2], ax .leave ret SetDWordAttr endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeByteAttrCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback to change a byte in a CellAttrs entry CALLED BY: SetSpreadsheetAttrs() via StyleTokenChangeAttr() PASS: ds:di - CellAttrs ss:bp - inherited locals CL_data1.low - new byte to set dx - offset of data in CellAttrs RETURN: carry - set to abort DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 5/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeByteAttrCallback proc far uses di locals local CellLocals .enter inherit EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > EC < push es ;> EC < segmov es, ds ;es:di <- ptr to CellAttrs EC < call ECCheckCellAttrRefCount ;> EC < pop es ;> add di, dx ;ds:di <- ptr to data mov al, ss:locals.CL_data1.low mov ds:[di], al ;store new byte EC clc ;carry <- don't abort .leave ret ChangeByteAttrCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeWordAttrCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback to change a word in a CellAttrs entry CALLED BY: SetSpreadsheetAttrs() via StyleTokenChangeAttr() PASS: ds:di - CellAttrs ss:bp - inherited locals CL_data1 - new word to set dx - offset of data in CellAttrs RETURN: carry - set to abort DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 5/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeWordAttrCallback proc far uses di locals local CellLocals .enter inherit EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > EC < push es ;> EC < segmov es, ds ;es:di <- ptr to CellAttrs EC < call ECCheckCellAttrRefCount ;> EC < pop es ;> add di, dx ;ds:di <- ptr to data mov ax, ss:locals.CL_data1 ;ax <- new word mov ds:[di], ax ;store new word EC clc ;carry <- don't abort .leave ret ChangeWordAttrCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ChangeDWordAttrCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback to change a dword in a CellAttrs entry CALLED BY: SetSpreadsheetAttrs() via StyleTokenChangeAttr() PASS: ds:di - ptr to CellAttrs ss:bp - inherited locals CL_data1 - low word CL_data2 - high word dx - offset in CellAttrs of data RETURN: none DESTROYED: ax PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 10/ 6/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ChangeDWordAttrCallback proc far uses di locals local CellLocals .enter inherit EC < cmp ds:[di].CA_refCount.REH_refCount.WAAH_high, EA_FREE_ELEMENT > EC < je done ;skip empty entries > EC < push es ;> EC < segmov es, ds ;es:di <- ptr to CellAttrs EC < call ECCheckCellAttrRefCount ;> EC < pop es ;> add di, dx ;ds:di <- ptr to data mov ax, ss:locals.CL_data1 mov ds:[di].low, ax ;store new low word mov ax, ss:locals.CL_data2 mov ds:[di].high, ax ;store new high word EC clc ;carry <- don't abort .leave ret ChangeDWordAttrCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SpreadsheetModifyNumFormat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: modify number format for selected cells CALLED BY: MSG_SPREADSHEET_MODIFY_NUM_FORMAT PASS: *ds:si = SpreadsheetClass object ds:di = SpreadsheetClass instance data ds:bx = SpreadsheetClass object (same as *ds:si) es = segment of SpreadsheetClass ax = message # cx = FloatModifyFormatFlags RETURN: DESTROYED: SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 12/ 6/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SpreadsheetModifyNumFormat method dynamic SpreadsheetClass, MSG_SPREADSHEET_MODIFY_NUM_FORMAT locals local CellLocals .enter call SpreadsheetMarkBusy ; ; Do common setup ; mov si, ds:[si] add si, ds:[si].Spreadsheet_offset mov ss:locals.CL_data1, ax ;pass data to callback mov ss:locals.CL_data2, cx ;pass FloatModifyFormatFlags ; ; IMPORTANT: invalidate the attributes set in the cached GState. ; This is because while the token may remain the same, the ; attributes it represents no longer do. ; mov ds:[si].SSI_curAttrs, -1 ; ; initialize FormatInfoStruc ; push es mov ax, size FormatInfoStruc mov cx, ALLOC_DYNAMIC_NO_ERR_LOCK or (mask HAF_ZERO_INIT shl 8) call MemAlloc ; ax = segment mov es, ax mov es:[FIS_signature], FORMAT_INFO_STRUC_ID mov ax, ds:[si].SSI_cellParams.CFP_file mov es:[FIS_userDefFmtArrayFileHan], ax mov ax, ds:[si].SSI_formatArray mov es:[FIS_userDefFmtArrayBlkHan], ax call MemUnlock mov ss:locals.CL_data3, bx ; save handle pop es ; ; Check for special cases ; call CheckAllSelected jc doAllOrColumn ;branch if all selected jz doAllOrColumn ;branch if column(s) selected ; ; Call the callback routine for all cells in the selection ; mov di, mask REF_ALL_CELLS ;di <- all cells callEnum: mov ss:locals.CL_params.REP_callback.offset, offset ModifyCellNumFormat mov ss:locals.CL_params.REP_callback.segment, SEGMENT_CS call CallRangeEnumSelected ; ; Update the UI and redraw appropriatly ; mov ax, mask SNF_FORMAT_CHANGE call UpdateUIRedrawSelection call SpreadsheetMarkNotBusy .leave ret ; ; One or more columns are selected -- optimize if we can ; doAllOrColumn: ; ; Create token for modified attributes, starting from the default ; attributes for this column ; call ModifyColumnNumFormat ; ; Set the attributes for any existing cells ; clr di ;di <- only existing cells jmp callEnum SpreadsheetModifyNumFormat endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ModifyCellNumFormat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: modify number format for cell CALLED BY: INTERNAL SpreadsheetModifyNumFormat via CallRangeEnumSelected PASS: ss:bp = CallRangeEnumSelected locals ds:si = SpreadsheetInstance data (ax, cx) = cell coordinates (r, c) carry set if cell has data *es:di = cell data, if any CL_data2 = FloatModifyFormatFlags CL_data3 = FIS block RETURN: carry set to stop enum dl = RangeEnumFlags with REF_ALLOCATED bit set if we've allocated a cell DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 12/ 9/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ModifyCellNumFormat proc far uses ax, di locals local CellLocals .enter inherit push es, di ; save cell data ptr pushf ; save data flag push ax ; save row jnc noData mov di, es:[di] ; es:di = cell data mov ax, es:[di].CC_attrs ; ax = style token lea di, locals.CL_cellAttrs segmov es, ss ; es:di = cell attrs buffers call StyleGetStyleByTokenFar ; get styles call StyleDeleteStyleByToken ; delete one reference setNumFormat: mov ax, locals.CL_cellAttrs.CA_format ; ax = num format token call ModifyNumFormatFromToken ; ax = new num format token mov locals.CL_cellAttrs.CA_format, ax ; store new token pop ax ; ax = row popf ; restore data flag pop es, di ; restore cell data call SetAttrsFinish ; finish up clc ; continue enumeration .leave ret ; ; The cell doesn't exist yet -- get the default attrs for it ; noData: call ColumnGetDefaultAttrs mov ax, dx ;ax <- new style token lea di, locals.CL_cellAttrs segmov es, ss ;es:di <- ptr to cellAttrs call StyleGetStyleByTokenFar jmp setNumFormat ModifyCellNumFormat endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ModifyColumnNumFormat %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: modify default attributes for column CALLED BY: INTERNAL SpreadsheetModifyNumFormat PASS: ds:si = ptr to Spreadsheet instance ss:bp = inherited locals RETURN: nothing DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 12/ 6/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ModifyColumnNumFormat proc near uses ax, cx, dx, di, es class SpreadsheetClass locals local CellLocals .enter inherit EC < call ECCheckInstancePtr ;> mov cx, ds:[si].SSI_selected.CR_start.CR_column segmov es, ss, di lea di, locals.CL_cellAttrs ;es:di <- ptr to CellAttrs columnLoop: ; ; Get the current attrs ; call ColumnGetDefaultAttrs mov ax, dx ;ax <- attr token for column call StyleGetStyleByTokenFar ;get associated styles call StyleDeleteStyleByToken ; ; Modify the number format as desired ; es:di = CellAttrs ; mov ax, es:[di].CA_format ; ax = format token call ModifyNumFormatFromToken ; ax = new format token mov es:[di].CA_format, ax ; store new format token ; ; Set the new default attributes ; call StyleGetTokenByStyleFar ;ax <- new attr token call ColumnSetDefaultAttrs ; ; loop while more columns ; inc cx cmp cx, ds:[si].SSI_selected.CR_end.CR_column jbe columnLoop ;loop while more columns .leave ret ModifyColumnNumFormat endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ModifyNumFormatFromToken %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: modify existing format and return new format token CALLED BY: INTERNAL ModifyColumnNumFormat PASS: ax = format token ss:bp = inherited locals RETURN: ax = new format token DESTROYED: nothing SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- brianc 12/ 6/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ModifyNumFormatFromToken proc near uses bx, dx, es locals local CellLocals .enter inherit push ax ; save token mov bx, locals.CL_data3 ; FIS block call MemLock mov es, ax ; es = FormatInfoStruc pop es:[FIS_curToken] mov dx, locals.CL_data2 ; FloatModifyFormatFlags call FloatFormatGetModifiedFormat ; ax = token call MemUnlock .leave ret ModifyNumFormatFromToken endp AttrCode ends ",16290,True,3504.274877620951,median "############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material (""Material"") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # ""License""), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 6, 0x90 .globl _cpMontSqr1024_avx2 _cpMontSqr1024_avx2: push %rbx push %rbp push %r12 push %r13 push %r14 sub $(64), %rsp movslq %ecx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rcx,8) vmovdqu %ymm11, (%rdx,%rcx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) movq %rcx, (24)(%rsp) movq %r8, (32)(%rsp) mov $(40), %rcx mov %r9, %rdi movq %rdi, (48)(%rsp) lea (%rdi,%rcx,8), %rbx lea (%rbx,%rcx,8), %r9 movq %r9, (40)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_1 .p2align 6, 0x90 .Lsqr1024_loop4gas_1: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_1: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_1 movq (48)(%rsp), %rdi movq (16)(%rsp), %rcx movq (32)(%rsp), %r8 mov $(38), %r9 movq (%rdi), %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rdi), %ymm1 vmovdqu (64)(%rdi), %ymm2 vmovdqu (96)(%rdi), %ymm3 vmovdqu (128)(%rdi), %ymm4 vmovdqu (160)(%rdi), %ymm5 vmovdqu (192)(%rdi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rdi), %ymm7 vmovdqu (256)(%rdi), %ymm8 vmovdqu (288)(%rdi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_1: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_1 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rdi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rdi), %r11 movq (16)(%rdi), %r12 movq (24)(%rdi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rdi), %ymm14, %ymm9 add $(32), %rdi sub $(2), %r9 jnz .Lreduction_loopgas_1 .Lexit_reduction_loopgas_1: movq (%rsp), %rdi movq %r12, (%rdi) movq %r13, (8)(%rdi) vmovdqu %ymm1, (16)(%rdi) vmovdqu %ymm2, (48)(%rdi) vmovdqu %ymm3, (80)(%rdi) vmovdqu %ymm4, (112)(%rdi) vmovdqu %ymm5, (144)(%rdi) vmovdqu %ymm6, (176)(%rdi) vmovdqu %ymm7, (208)(%rdi) vmovdqu %ymm8, (240)(%rdi) vmovdqu %ymm9, (272)(%rdi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_1: addq (%rdi), %rax add $(8), %rdi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (-8)(%rdi) sub $(1), %r9 jg .Lnorm_loopgas_1 movq %rax, (%rdi) add $(64), %rsp vzeroupper pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .p2align 6, 0x90 .globl _cpSqr1024_avx2 _cpSqr1024_avx2: push %rbx sub $(48), %rsp movslq %edx, %rdx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rsi,%rdx,8) movq %rdi, (%rsp) movq %rsi, (8)(%rsp) movq %rdx, (16)(%rsp) mov $(40), %rdx mov %rcx, %rdi movq %rdi, (32)(%rsp) lea (%rdi,%rdx,8), %rbx lea (%rbx,%rdx,8), %r9 movq %r9, (24)(%rsp) mov %rsi, %rax mov $(4), %rcx vmovdqu (%rsi), %ymm0 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 vmovdqu %ymm0, (%r9) vpbroadcastq (%rax), %ymm10 vpaddq %ymm1, %ymm1, %ymm1 vmovdqu %ymm1, (32)(%r9) vpaddq %ymm2, %ymm2, %ymm2 vmovdqu %ymm2, (64)(%r9) vpaddq %ymm3, %ymm3, %ymm3 vmovdqu %ymm3, (96)(%r9) vpaddq %ymm4, %ymm4, %ymm4 vmovdqu %ymm4, (128)(%r9) vpaddq %ymm5, %ymm5, %ymm5 vmovdqu %ymm5, (160)(%r9) vpaddq %ymm6, %ymm6, %ymm6 vmovdqu %ymm6, (192)(%r9) vpaddq %ymm7, %ymm7, %ymm7 vmovdqu %ymm7, (224)(%r9) vpaddq %ymm8, %ymm8, %ymm8 vmovdqu %ymm8, (256)(%r9) vpaddq %ymm9, %ymm9, %ymm9 vmovdqu %ymm9, (288)(%r9) vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vmovdqu %ymm11, (%rbx) vpmuludq (32)(%r9), %ymm10, %ymm1 vmovdqu %ymm11, (32)(%rbx) vpmuludq (64)(%r9), %ymm10, %ymm2 vmovdqu %ymm11, (64)(%rbx) vpmuludq (96)(%r9), %ymm10, %ymm3 vmovdqu %ymm11, (96)(%rbx) vpmuludq (128)(%r9), %ymm10, %ymm4 vmovdqu %ymm11, (128)(%rbx) vpmuludq (160)(%r9), %ymm10, %ymm5 vmovdqu %ymm11, (160)(%rbx) vpmuludq (192)(%r9), %ymm10, %ymm6 vmovdqu %ymm11, (192)(%rbx) vpmuludq (224)(%r9), %ymm10, %ymm7 vmovdqu %ymm11, (224)(%rbx) vpmuludq (256)(%r9), %ymm10, %ymm8 vmovdqu %ymm11, (256)(%rbx) vpmuludq (288)(%r9), %ymm10, %ymm9 vmovdqu %ymm11, (288)(%rbx) jmp .Lsqr1024_epgas_2 .p2align 6, 0x90 .Lsqr1024_loop4gas_2: vpmuludq (%rsi), %ymm10, %ymm0 vpbroadcastq (32)(%rax), %ymm14 vpaddq (%rdi), %ymm0, %ymm0 vpmuludq (32)(%r9), %ymm10, %ymm1 vpaddq (32)(%rdi), %ymm1, %ymm1 vpmuludq (64)(%r9), %ymm10, %ymm2 vpaddq (64)(%rdi), %ymm2, %ymm2 vpmuludq (96)(%r9), %ymm10, %ymm3 vpaddq (96)(%rdi), %ymm3, %ymm3 vpmuludq (128)(%r9), %ymm10, %ymm4 vpaddq (128)(%rdi), %ymm4, %ymm4 vpmuludq (160)(%r9), %ymm10, %ymm5 vpaddq (160)(%rdi), %ymm5, %ymm5 vpmuludq (192)(%r9), %ymm10, %ymm6 vpaddq (192)(%rdi), %ymm6, %ymm6 vpmuludq (224)(%r9), %ymm10, %ymm7 vpaddq (224)(%rdi), %ymm7, %ymm7 vpmuludq (256)(%r9), %ymm10, %ymm8 vpaddq (256)(%rdi), %ymm8, %ymm8 vpmuludq (288)(%r9), %ymm10, %ymm9 vpaddq (288)(%rdi), %ymm9, %ymm9 .Lsqr1024_epgas_2: vmovdqu %ymm0, (%rdi) vmovdqu %ymm1, (32)(%rdi) vpmuludq (32)(%rsi), %ymm14, %ymm11 vpbroadcastq (64)(%rax), %ymm10 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (64)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (96)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (128)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm5, %ymm5 vpmuludq (160)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm6, %ymm6 vpmuludq (192)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm7, %ymm7 vpmuludq (224)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (288)(%r9), %ymm14, %ymm0 vpaddq (%rbx), %ymm0, %ymm0 vmovdqu %ymm2, (64)(%rdi) vmovdqu %ymm3, (96)(%rdi) vpmuludq (64)(%rsi), %ymm10, %ymm11 vpbroadcastq (96)(%rax), %ymm14 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (96)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (128)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm6, %ymm6 vpmuludq (160)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm7, %ymm7 vpmuludq (192)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm8, %ymm8 vpmuludq (224)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm9, %ymm9 vpmuludq (256)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (288)(%r9), %ymm10, %ymm1 vpaddq (32)(%rbx), %ymm1, %ymm1 vmovdqu %ymm4, (128)(%rdi) vmovdqu %ymm5, (160)(%rdi) vpmuludq (96)(%rsi), %ymm14, %ymm11 vpbroadcastq (128)(%rax), %ymm10 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (128)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm7, %ymm7 vpmuludq (160)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm8, %ymm8 vpmuludq (192)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm9, %ymm9 vpmuludq (224)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm0, %ymm0 vpmuludq (256)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm1, %ymm1 vpmuludq (288)(%r9), %ymm14, %ymm2 vpaddq (64)(%rbx), %ymm2, %ymm2 vmovdqu %ymm6, (192)(%rdi) vmovdqu %ymm7, (224)(%rdi) vpmuludq (128)(%rsi), %ymm10, %ymm11 vpbroadcastq (160)(%rax), %ymm14 vpaddq %ymm11, %ymm8, %ymm8 vpmuludq (160)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm9, %ymm9 vpmuludq (192)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm0, %ymm0 vpmuludq (224)(%r9), %ymm10, %ymm11 vpaddq %ymm11, %ymm1, %ymm1 vpmuludq (256)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm2, %ymm2 vpmuludq (288)(%r9), %ymm10, %ymm3 vpaddq (96)(%rbx), %ymm3, %ymm3 vmovdqu %ymm8, (256)(%rdi) vmovdqu %ymm9, (288)(%rdi) vpmuludq (160)(%rsi), %ymm14, %ymm11 vpbroadcastq (192)(%rax), %ymm10 vpaddq %ymm11, %ymm0, %ymm0 vpmuludq (192)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm1, %ymm1 vpmuludq (224)(%r9), %ymm14, %ymm13 vpaddq %ymm13, %ymm2, %ymm2 vpmuludq (256)(%r9), %ymm14, %ymm11 vpaddq %ymm11, %ymm3, %ymm3 vpmuludq (288)(%r9), %ymm14, %ymm4 vpaddq (128)(%rbx), %ymm4, %ymm4 vmovdqu %ymm0, (320)(%rdi) vmovdqu %ymm1, (352)(%rdi) vpmuludq (192)(%rsi), %ymm10, %ymm11 vpbroadcastq (224)(%rax), %ymm14 vpaddq %ymm11, %ymm2, %ymm2 vpmuludq (224)(%r9), %ymm10, %ymm12 vpaddq %ymm12, %ymm3, %ymm3 vpmuludq (256)(%r9), %ymm10, %ymm13 vpaddq %ymm13, %ymm4, %ymm4 vpmuludq (288)(%r9), %ymm10, %ymm5 vpaddq (160)(%rbx), %ymm5, %ymm5 vmovdqu %ymm2, (384)(%rdi) vmovdqu %ymm3, (416)(%rdi) vpmuludq (224)(%rsi), %ymm14, %ymm11 vpbroadcastq (256)(%rax), %ymm10 vpaddq %ymm11, %ymm4, %ymm4 vpmuludq (256)(%r9), %ymm14, %ymm12 vpaddq %ymm12, %ymm5, %ymm5 vpmuludq (288)(%r9), %ymm14, %ymm6 vpaddq (192)(%rbx), %ymm6, %ymm6 vmovdqu %ymm4, (448)(%rdi) vmovdqu %ymm5, (480)(%rdi) vpmuludq (256)(%rsi), %ymm10, %ymm11 vpbroadcastq (288)(%rax), %ymm14 vpaddq %ymm11, %ymm6, %ymm6 vpmuludq (288)(%r9), %ymm10, %ymm7 vpaddq (224)(%rbx), %ymm7, %ymm7 vpmuludq (288)(%rsi), %ymm14, %ymm8 vpbroadcastq (8)(%rax), %ymm10 vpaddq (256)(%rbx), %ymm8, %ymm8 vmovdqu %ymm6, (512)(%rdi) vmovdqu %ymm7, (544)(%rdi) vmovdqu %ymm8, (576)(%rdi) add $(8), %rdi add $(8), %rbx add $(8), %rax sub $(1), %rcx jnz .Lsqr1024_loop4gas_2 movq (32)(%rsp), %rsi movq (%rsp), %rdi mov $(76), %r9 xor %rax, %rax .Lnorm_loopgas_2: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_2 movq %rax, (%rdi) add $(48), %rsp vzeroupper pop %rbx ret .p2align 6, 0x90 .globl _cpMontRed1024_avx2 _cpMontRed1024_avx2: push %r12 push %r13 movslq %ecx, %r9 mov %rdx, %rcx vpxor %ymm11, %ymm11, %ymm11 vmovdqu %ymm11, (%rdx,%r9,8) movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 mov %r10, %rdx imul %r8d, %edx and $(134217727), %edx vmovd %edx, %xmm10 vmovdqu (32)(%rsi), %ymm1 vmovdqu (64)(%rsi), %ymm2 vmovdqu (96)(%rsi), %ymm3 vmovdqu (128)(%rsi), %ymm4 vmovdqu (160)(%rsi), %ymm5 vmovdqu (192)(%rsi), %ymm6 mov %rdx, %rax imulq (%rcx), %rax add %rax, %r10 vpbroadcastq %xmm10, %ymm10 vmovdqu (224)(%rsi), %ymm7 vmovdqu (256)(%rsi), %ymm8 vmovdqu (288)(%rsi), %ymm9 mov %rdx, %rax imulq (8)(%rcx), %rax add %rax, %r11 mov %rdx, %rax imulq (16)(%rcx), %rax add %rax, %r12 shr $(27), %r10 imulq (24)(%rcx), %rdx add %rdx, %r13 add %r10, %r11 mov %r11, %rdx imul %r8d, %edx and $(134217727), %rdx .p2align 6, 0x90 .Lreduction_loopgas_3: vmovd %edx, %xmm11 vpbroadcastq %xmm11, %ymm11 vpmuludq (32)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (64)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (96)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (128)(%rcx), %ymm10, %ymm14 add %rax, %r11 shr $(27), %r11 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (160)(%rcx), %ymm10, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm5 add %rax, %r12 vpmuludq (192)(%rcx), %ymm10, %ymm14 imulq (16)(%rcx), %rdx add %r11, %r12 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (224)(%rcx), %ymm10, %ymm14 mov %r12, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm7 vpmuludq (256)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 and $(134217727), %rdx vpmuludq (288)(%rcx), %ymm10, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovd %edx, %xmm12 vpbroadcastq %xmm12, %ymm12 vpmuludq (24)(%rcx), %ymm11, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (56)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 vpmuludq (88)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (120)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm4, %ymm4 add %r12, %rax shr $(27), %rax vpmuludq (152)(%rcx), %ymm11, %ymm14 imulq (8)(%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (184)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 vpmuludq (216)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 add %r13, %rdx add %rax, %rdx vpmuludq (248)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (280)(%rcx), %ymm11, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 sub $(2), %r9 jz .Lexit_reduction_loopgas_3 vpmuludq (16)(%rcx), %ymm12, %ymm14 mov %rdx, %r13 imul %r8d, %edx vpaddq %ymm14, %ymm1, %ymm1 vpmuludq (48)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm2, %ymm2 and $(134217727), %rdx vpmuludq (80)(%rcx), %ymm12, %ymm14 vmovd %edx, %xmm13 vpaddq %ymm14, %ymm3, %ymm3 vpmuludq (112)(%rcx), %ymm12, %ymm14 vpbroadcastq %xmm13, %ymm13 vpaddq %ymm14, %ymm4, %ymm4 vpmuludq (144)(%rcx), %ymm12, %ymm14 imulq (%rcx), %rdx vpaddq %ymm14, %ymm5, %ymm5 vpmuludq (176)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm6, %ymm6 add %rdx, %r13 vpmuludq (208)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm7, %ymm7 shr $(27), %r13 vmovq %r13, %xmm0 vpmuludq (8)(%rcx), %ymm13, %ymm14 vpaddq %ymm0, %ymm1, %ymm1 vpaddq %ymm14, %ymm1, %ymm1 vmovdqu %ymm1, (%rsi) vpmuludq (240)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm8, %ymm8 vpmuludq (272)(%rcx), %ymm12, %ymm14 vpaddq %ymm14, %ymm9, %ymm9 vmovq %xmm1, %rdx imul %r8d, %edx and $(134217727), %edx vmovq %xmm1, %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 vmovd %edx, %xmm10 vpbroadcastq %xmm10, %ymm10 vpmuludq (40)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (%rcx), %rax vpaddq %ymm14, %ymm2, %ymm1 vpmuludq (72)(%rcx), %ymm13, %ymm14 add %rax, %r10 vpaddq %ymm14, %ymm3, %ymm2 shr $(27), %r10 vpmuludq (104)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (8)(%rcx), %rax vpaddq %ymm14, %ymm4, %ymm3 add %rax, %r11 vpmuludq (136)(%rcx), %ymm13, %ymm14 mov %rdx, %rax imulq (16)(%rcx), %rax vpaddq %ymm14, %ymm5, %ymm4 add %rax, %r12 vpmuludq (168)(%rcx), %ymm13, %ymm14 imulq (24)(%rcx), %rdx vpaddq %ymm14, %ymm6, %ymm5 add %rdx, %r13 add %r10, %r11 vpmuludq (200)(%rcx), %ymm13, %ymm14 mov %r11, %rdx imul %r8d, %edx vpaddq %ymm14, %ymm7, %ymm6 and $(134217727), %rdx vpmuludq (232)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm8, %ymm7 vpmuludq (264)(%rcx), %ymm13, %ymm14 vpaddq %ymm14, %ymm9, %ymm8 vpmuludq (296)(%rcx), %ymm13, %ymm14 vpaddq (320)(%rsi), %ymm14, %ymm9 add $(32), %rsi sub $(2), %r9 jnz .Lreduction_loopgas_3 .Lexit_reduction_loopgas_3: movq (%rsp), %rsi movq %r12, (%rsi) movq %r13, (8)(%rsi) vmovdqu %ymm1, (16)(%rsi) vmovdqu %ymm2, (48)(%rsi) vmovdqu %ymm3, (80)(%rsi) vmovdqu %ymm4, (112)(%rsi) vmovdqu %ymm5, (144)(%rsi) vmovdqu %ymm6, (176)(%rsi) vmovdqu %ymm7, (208)(%rsi) vmovdqu %ymm8, (240)(%rsi) vmovdqu %ymm9, (272)(%rsi) mov $(38), %r9 xor %rax, %rax .Lnorm_loopgas_3: addq (%rsi), %rax add $(8), %rsi mov $(134217727), %rdx and %rax, %rdx shr $(27), %rax movq %rdx, (%rdi) add $(8), %rdi sub $(1), %r9 jg .Lnorm_loopgas_3 movq %rax, (%rdi) vzeroupper pop %r13 pop %r12 ret ",16355,True,4229.6179089483,median "*""* use this source file for the definition and implementation of *""* local helper classes, interface definitions and type *""* declarations TYPES: BEGIN OF ty_fields, len TYPE i, maxlen TYPE i, offset TYPE i, END OF ty_fields . CLASS lcl_convert DEFINITION DEFERRED. CLASS zcl_ntlm DEFINITION LOCAL FRIENDS lcl_convert. CLASS lcl_reader DEFINITION DEFERRED. CLASS zcl_ntlm DEFINITION LOCAL FRIENDS lcl_reader. CLASS lcl_writer DEFINITION DEFERRED. CLASS zcl_ntlm DEFINITION LOCAL FRIENDS lcl_writer. CLASS lcl_util DEFINITION DEFERRED. CLASS zcl_ntlm DEFINITION LOCAL FRIENDS lcl_util. *----------------------------------------------------------------------* * CLASS lcl_time DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_util DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS class_constructor. CLASS-METHODS since_epoc_hex RETURNING VALUE(rv_hex) TYPE zcl_ntlm=>ty_byte8 RAISING cx_static_check. CLASS-METHODS since_epoc IMPORTING iv_time TYPE t DEFAULT sy-uzeit iv_date TYPE d DEFAULT sy-datum RETURNING VALUE(rv_num) TYPE zntlm_dec_22. CLASS-METHODS hmac_md5 IMPORTING iv_key TYPE xsequence iv_data TYPE xsequence RETURNING VALUE(rv_hash) TYPE xstring RAISING cx_static_check. CLASS-METHODS random_nonce RETURNING VALUE(rv_data) TYPE zcl_ntlm=>ty_byte8. CLASS-METHODS md5 IMPORTING iv_data TYPE xstring RETURNING VALUE(rv_hash) TYPE zcl_ntlm=>ty_byte16. PRIVATE SECTION. CLASS-DATA: mo_random TYPE REF TO cl_abap_random. ENDCLASS. ""lcl_time DEFINITION *----------------------------------------------------------------------* * CLASS lcl_convert DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_convert DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS to_64bit IMPORTING iv_num TYPE zntlm_dec_22 RETURNING VALUE(rv_hex) TYPE zcl_ntlm=>ty_byte8. CLASS-METHODS fields_decode IMPORTING iv_byte8 TYPE zcl_ntlm=>ty_byte8 RETURNING VALUE(rs_fields) TYPE ty_fields. CLASS-METHODS fields_encode IMPORTING is_fields TYPE ty_fields RETURNING VALUE(rv_byte8) TYPE zcl_ntlm=>ty_byte8. CLASS-METHODS base64_decode IMPORTING iv_string TYPE string RETURNING VALUE(rv_xstring) TYPE xstring. CLASS-METHODS base64_encode IMPORTING iv_xstring TYPE xstring RETURNING VALUE(rv_string) TYPE string. CLASS-METHODS flags_decode IMPORTING iv_hex TYPE zcl_ntlm=>ty_byte4 RETURNING VALUE(rs_flags) TYPE zcl_ntlm=>ty_flags. CLASS-METHODS flags_encode IMPORTING is_flags TYPE zcl_ntlm=>ty_flags RETURNING VALUE(rv_hex) TYPE zcl_ntlm=>ty_byte4. CLASS-METHODS byte2_to_int IMPORTING iv_byte2 TYPE zcl_ntlm=>ty_byte2 RETURNING VALUE(rv_int) TYPE i. CLASS-METHODS byte4_to_int IMPORTING iv_byte4 TYPE zcl_ntlm=>ty_byte4 RETURNING VALUE(rv_int) TYPE i. CLASS-METHODS int_to_byte2 IMPORTING iv_int TYPE i RETURNING VALUE(rv_byte2) TYPE zcl_ntlm=>ty_byte2. CLASS-METHODS int_to_byte4 IMPORTING iv_int TYPE i RETURNING VALUE(rv_byte4) TYPE zcl_ntlm=>ty_byte4. CLASS-METHODS codepage_4103 IMPORTING iv_string TYPE clike RETURNING VALUE(rv_xstring) TYPE xstring. CLASS-METHODS codepage_utf_8 IMPORTING iv_string TYPE string RETURNING VALUE(rv_xstring) TYPE xstring. CLASS-METHODS codepage_4103_x IMPORTING iv_xstring TYPE xstring RETURNING VALUE(rv_string) TYPE string. CLASS-METHODS codepage_utf_8_x IMPORTING iv_xstring TYPE xstring RETURNING VALUE(rv_string) TYPE string. ENDCLASS. ""lcl_convert DEFINITION *----------------------------------------------------------------------* * CLASS lcl_time IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_util IMPLEMENTATION. METHOD class_constructor. mo_random = cl_abap_random=>create( cl_abap_random=>seed( ) ). ENDMETHOD. METHOD md5. DATA lv_empty TYPE xstring. DATA lv_hash TYPE xstring. TRY. cl_abap_hmac=>calculate_hmac_for_raw( EXPORTING if_algorithm = 'MD5' if_key = lv_empty if_data = iv_data IMPORTING ef_hmacxstring = lv_hash ). CATCH cx_abap_message_digest. ASSERT 1 = 2. ENDTRY. rv_hash = lv_hash. ENDMETHOD. METHOD random_nonce. rv_data+4 = mo_random->int( ). rv_data(4) = mo_random->int( ). ENDMETHOD. METHOD hmac_md5. DATA lv_key TYPE xstring. lv_key = iv_key. "" convert type cl_abap_hmac=>calculate_hmac_for_raw( EXPORTING if_algorithm = 'MD5' if_key = lv_key if_data = iv_data IMPORTING ef_hmacxstring = rv_hash ). ENDMETHOD. METHOD since_epoc. * tenths of a microsecond since 1 jan 1601, encoded as little endian signed 64 bit value DATA: lv_secs TYPE tzntstmpl, lv_tstmp1 TYPE p, lv_tstmp2 TYPE p. cl_abap_tstmp=>systemtstmp_syst2utc( EXPORTING syst_date = iv_date syst_time = iv_time IMPORTING utc_tstmp = lv_tstmp1 ). lv_tstmp2 = '16010101000000'. lv_secs = cl_abap_tstmp=>subtract( tstmp1 = lv_tstmp1 tstmp2 = lv_tstmp2 ). rv_num = lv_secs * ( 10 ** 7 ). ENDMETHOD. METHOD since_epoc_hex. DATA lv_lsec TYPE zntlm_dec_22. lv_lsec = since_epoc( ). rv_hex = lcl_convert=>to_64bit( lv_lsec ). ENDMETHOD. ENDCLASS. *----------------------------------------------------------------------* * CLASS lcl_convert IMPLMENTATION. *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_convert IMPLEMENTATION. METHOD to_64bit. DATA: lv_c TYPE c LENGTH 1, lv_xres TYPE x LENGTH 8, lv_index TYPE i, lv_num LIKE iv_num. lv_num = iv_num. * hmm, this is crazy, since there are no 64 bit types in ABAP * INT8 was introduced in 750 DO 64 TIMES. lv_index = 64 - sy-index + 1. lv_c = lv_num MOD 2. lv_num = lv_num DIV 2. SET BIT lv_index OF lv_xres TO lv_c. ENDDO. CONCATENATE lv_xres+7(1) lv_xres+6(1) lv_xres+5(1) lv_xres+4(1) lv_xres+3(1) lv_xres+2(1) lv_xres+1(1) lv_xres(1) INTO rv_hex IN BYTE MODE. ENDMETHOD. ""to_64bit METHOD codepage_4103_x. DATA: lo_obj TYPE REF TO cl_abap_conv_in_ce. lo_obj = cl_abap_conv_in_ce=>create( encoding = '4103' ). lo_obj->convert( EXPORTING input = iv_xstring IMPORTING data = rv_string ). ENDMETHOD. ""codepage_4103_x METHOD codepage_utf_8_x. DATA: lo_obj TYPE REF TO cl_abap_conv_in_ce. lo_obj = cl_abap_conv_in_ce=>create( encoding = 'UTF-8' ). lo_obj->convert( EXPORTING input = iv_xstring IMPORTING data = rv_string ). ENDMETHOD. ""codepage_utf_8_x METHOD codepage_utf_8. DATA: lo_obj TYPE REF TO cl_abap_conv_out_ce. lo_obj = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ). lo_obj->convert( EXPORTING data = iv_string IMPORTING buffer = rv_xstring ). ENDMETHOD. ""codepage_UTF_8 METHOD codepage_4103. DATA: lo_obj TYPE REF TO cl_abap_conv_out_ce. lo_obj = cl_abap_conv_out_ce=>create( encoding = '4103' ). lo_obj->convert( EXPORTING data = iv_string IMPORTING buffer = rv_xstring ). ENDMETHOD. ""codepage_4103 METHOD fields_decode. DATA: lv_byte2 TYPE zcl_ntlm=>ty_byte2, lv_byte4 TYPE zcl_ntlm=>ty_byte4. lv_byte2 = iv_byte8(2). rs_fields-len = byte2_to_int( lv_byte2 ). lv_byte2 = iv_byte8+2(2). rs_fields-maxlen = byte2_to_int( lv_byte2 ). lv_byte4 = iv_byte8+4(4). rs_fields-offset = byte4_to_int( lv_byte4 ). ENDMETHOD. ""fields_decode METHOD fields_encode. rv_byte8(2) = int_to_byte2( is_fields-len ). rv_byte8+2(2) = int_to_byte2( is_fields-maxlen ). rv_byte8+4(4) = int_to_byte4( is_fields-offset ). ENDMETHOD. ""fields_encode METHOD base64_decode. rv_xstring = cl_http_utility=>decode_x_base64( iv_string ). ENDMETHOD. METHOD base64_encode. rv_string = cl_http_utility=>encode_x_base64( iv_xstring ). ENDMETHOD. METHOD flags_decode. DATA: lv_c TYPE c LENGTH 1, lv_x TYPE x LENGTH 1. lv_x = iv_hex. GET BIT 8 OF lv_x INTO lv_c. rs_flags-negotiate_unicode = boolc( lv_c = '1' ). GET BIT 7 OF lv_x INTO lv_c. rs_flags-negotiate_oem = boolc( lv_c = '1' ). GET BIT 6 OF lv_x INTO lv_c. rs_flags-request_target = boolc( lv_c = '1' ). GET BIT 5 OF lv_x INTO lv_c. rs_flags-r10 = boolc( lv_c = '1' ). GET BIT 4 OF lv_x INTO lv_c. rs_flags-negotiate_sign = boolc( lv_c = '1' ). GET BIT 3 OF lv_x INTO lv_c. rs_flags-negotiate_seal = boolc( lv_c = '1' ). GET BIT 2 OF lv_x INTO lv_c. rs_flags-negotiate_datagram = boolc( lv_c = '1' ). GET BIT 1 OF lv_x INTO lv_c. rs_flags-negotiate_lm_key = boolc( lv_c = '1' ). lv_x = iv_hex+1. GET BIT 8 OF lv_x INTO lv_c. rs_flags-r9 = boolc( lv_c = '1' ). GET BIT 7 OF lv_x INTO lv_c. rs_flags-negotiate_ntlm = boolc( lv_c = '1' ). GET BIT 6 OF lv_x INTO lv_c. rs_flags-r8 = boolc( lv_c = '1' ). GET BIT 5 OF lv_x INTO lv_c. rs_flags-anonymous = boolc( lv_c = '1' ). GET BIT 4 OF lv_x INTO lv_c. rs_flags-negotiate_oem_domain_supplied = boolc( lv_c = '1' ). GET BIT 3 OF lv_x INTO lv_c. rs_flags-negotiate_oem_workstation_sup = boolc( lv_c = '1' ). GET BIT 2 OF lv_x INTO lv_c. rs_flags-r7 = boolc( lv_c = '1' ). GET BIT 1 OF lv_x INTO lv_c. rs_flags-negotiate_always_sign = boolc( lv_c = '1' ). lv_x = iv_hex+2. GET BIT 8 OF lv_x INTO lv_c. rs_flags-target_type_domain = boolc( lv_c = '1' ). GET BIT 7 OF lv_x INTO lv_c. rs_flags-target_type_server = boolc( lv_c = '1' ). GET BIT 6 OF lv_x INTO lv_c. rs_flags-r6 = boolc( lv_c = '1' ). GET BIT 5 OF lv_x INTO lv_c. rs_flags-negotiate_extended_session_sec = boolc( lv_c = '1' ). GET BIT 4 OF lv_x INTO lv_c. rs_flags-negotiate_identity = boolc( lv_c = '1' ). GET BIT 3 OF lv_x INTO lv_c. rs_flags-r5 = boolc( lv_c = '1' ). GET BIT 2 OF lv_x INTO lv_c. rs_flags-request_non_nt_session_key = boolc( lv_c = '1' ). GET BIT 1 OF lv_x INTO lv_c. rs_flags-negotiate_target_info = boolc( lv_c = '1' ). lv_x = iv_hex+3. GET BIT 1 OF lv_x INTO lv_c. rs_flags-r4 = boolc( lv_c = '1' ). GET BIT 2 OF lv_x INTO lv_c. rs_flags-negotiate_version = boolc( lv_c = '1' ). GET BIT 3 OF lv_x INTO lv_c. rs_flags-r3 = boolc( lv_c = '1' ). GET BIT 4 OF lv_x INTO lv_c. rs_flags-r2 = boolc( lv_c = '1' ). GET BIT 5 OF lv_x INTO lv_c. rs_flags-r1 = boolc( lv_c = '1' ). GET BIT 6 OF lv_x INTO lv_c. rs_flags-negotiate_128 = boolc( lv_c = '1' ). GET BIT 7 OF lv_x INTO lv_c. rs_flags-negotiate_key_exch = boolc( lv_c = '1' ). GET BIT 8 OF lv_x INTO lv_c. rs_flags-negotiate_56 = boolc( lv_c = '1' ). ENDMETHOD. ""flags_decode METHOD flags_encode. DATA lv_x TYPE x LENGTH 1. CLEAR lv_x. IF is_flags-negotiate_unicode = abap_true. SET BIT 8 OF lv_x. ENDIF. IF is_flags-negotiate_oem = abap_true. SET BIT 7 OF lv_x. ENDIF. IF is_flags-request_target = abap_true. SET BIT 6 OF lv_x. ENDIF. IF is_flags-r10 = abap_true. SET BIT 5 OF lv_x. ENDIF. IF is_flags-negotiate_sign = abap_true. SET BIT 4 OF lv_x. ENDIF. IF is_flags-negotiate_seal = abap_true. SET BIT 3 OF lv_x. ENDIF. IF is_flags-negotiate_datagram = abap_true. SET BIT 2 OF lv_x. ENDIF. IF is_flags-negotiate_lm_key = abap_true. SET BIT 1 OF lv_x. ENDIF. rv_hex(1) = lv_x. CLEAR lv_x. IF is_flags-r9 = abap_true. SET BIT 8 OF lv_x. ENDIF. IF is_flags-negotiate_ntlm = abap_true. SET BIT 7 OF lv_x. ENDIF. IF is_flags-r8 = abap_true. SET BIT 6 OF lv_x. ENDIF. IF is_flags-anonymous = abap_true. SET BIT 5 OF lv_x. ENDIF. IF is_flags-negotiate_oem_domain_supplied = abap_true. SET BIT 4 OF lv_x. ENDIF. IF is_flags-negotiate_oem_workstation_sup = abap_true. SET BIT 3 OF lv_x. ENDIF. IF is_flags-r7 = abap_true. SET BIT 2 OF lv_x. ENDIF. IF is_flags-negotiate_always_sign = abap_true. SET BIT 1 OF lv_x. ENDIF. rv_hex+1(1) = lv_x. CLEAR lv_x. IF is_flags-target_type_domain = abap_true. SET BIT 8 OF lv_x. ENDIF. IF is_flags-target_type_server = abap_true. SET BIT 7 OF lv_x. ENDIF. IF is_flags-r6 = abap_true. SET BIT 6 OF lv_x. ENDIF. IF is_flags-negotiate_extended_session_sec = abap_true. SET BIT 5 OF lv_x. ENDIF. IF is_flags-negotiate_identity = abap_true. SET BIT 4 OF lv_x. ENDIF. IF is_flags-r5 = abap_true. SET BIT 3 OF lv_x. ENDIF. IF is_flags-request_non_nt_session_key = abap_true. SET BIT 2 OF lv_x. ENDIF. IF is_flags-negotiate_target_info = abap_true. SET BIT 1 OF lv_x. ENDIF. rv_hex+2(1) = lv_x. CLEAR lv_x. IF is_flags-r4 = abap_true. SET BIT 1 OF lv_x. ENDIF. IF is_flags-negotiate_version = abap_true. SET BIT 2 OF lv_x. ENDIF. IF is_flags-r3 = abap_true. SET BIT 3 OF lv_x. ENDIF. IF is_flags-r2 = abap_true. SET BIT 4 OF lv_x. ENDIF. IF is_flags-r1 = abap_true. SET BIT 5 OF lv_x. ENDIF. IF is_flags-negotiate_128 = abap_true. SET BIT 6 OF lv_x. ENDIF. IF is_flags-negotiate_key_exch = abap_true. SET BIT 7 OF lv_x. ENDIF. IF is_flags-negotiate_56 = abap_true. SET BIT 8 OF lv_x. ENDIF. rv_hex+3(1) = lv_x. ENDMETHOD. ""flags_encode METHOD byte2_to_int. DATA: lv_rev TYPE zcl_ntlm=>ty_byte2. CONCATENATE iv_byte2+1(1) iv_byte2(1) INTO lv_rev IN BYTE MODE. rv_int = lv_rev. ENDMETHOD. ""byte2_to_int METHOD byte4_to_int. DATA: lv_rev TYPE zcl_ntlm=>ty_byte4. CONCATENATE iv_byte4+3(1) iv_byte4+2(1) iv_byte4+1(1) iv_byte4(1) INTO lv_rev IN BYTE MODE. rv_int = lv_rev. ENDMETHOD. ""byte4_to_int METHOD int_to_byte2. DATA: lv_rev TYPE zcl_ntlm=>ty_byte2. lv_rev = iv_int. rv_byte2(1) = lv_rev+1(1). rv_byte2+1(1) = lv_rev(1). ENDMETHOD. ""int_to_byte2 METHOD int_to_byte4. DATA: lv_rev TYPE zcl_ntlm=>ty_byte4. lv_rev = iv_int. rv_byte4(1) = lv_rev+3(1). rv_byte4+1(1) = lv_rev+2(1). rv_byte4+2(1) = lv_rev+1(1). rv_byte4+3(1) = lv_rev(1). ENDMETHOD. ""int_to_byte4 ENDCLASS. ""lcl_convert IMPLMENTATION. *----------------------------------------------------------------------* * CLASS lcl_read DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_reader DEFINITION FINAL. PUBLIC SECTION. METHODS constructor IMPORTING iv_value TYPE string iv_type TYPE xstring RAISING zcx_ntlm_protocol_error. METHODS flags RETURNING VALUE(rs_flags) TYPE zcl_ntlm=>ty_flags. METHODS data_raw RETURNING VALUE(rv_data) TYPE xstring RAISING zcx_ntlm_protocol_error. METHODS data_str IMPORTING iv_oem TYPE abap_bool RETURNING VALUE(rv_data) TYPE string RAISING zcx_ntlm_protocol_error. METHODS skip IMPORTING iv_bytes TYPE i. METHODS raw IMPORTING iv_bytes TYPE i RETURNING VALUE(rv_raw) TYPE xstring. PRIVATE SECTION. DATA: mv_original TYPE xstring, mv_current TYPE xstring. ENDCLASS. ""lcl_read DEFINITION *----------------------------------------------------------------------* * CLASS lcl_read IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_reader IMPLEMENTATION. METHOD raw. rv_raw = mv_current(iv_bytes). mv_current = mv_current+iv_bytes. ENDMETHOD. ""raw METHOD skip. mv_current = mv_current+iv_bytes. ENDMETHOD. ""skip METHOD constructor. mv_original = lcl_convert=>base64_decode( iv_value ). IF xstrlen( mv_original ) < 8 OR mv_original(8) <> zcl_ntlm=>c_signature. RAISE EXCEPTION TYPE zcx_ntlm_protocol_error. ENDIF. mv_current = mv_original+8. IF xstrlen( mv_current ) < 4 OR mv_current(4) <> iv_type. RAISE EXCEPTION TYPE zcx_ntlm_protocol_error. ENDIF. mv_current = mv_current+4. ENDMETHOD. ""constructor METHOD flags. DATA: lv_byte4 TYPE zcl_ntlm=>ty_byte4. lv_byte4 = mv_current(4). rs_flags = lcl_convert=>flags_decode( lv_byte4 ). mv_current = mv_current+4. ENDMETHOD. ""flags METHOD data_raw. DATA: lv_byte8 TYPE zcl_ntlm=>ty_byte8, ls_fields TYPE ty_fields. lv_byte8 = mv_current(8). ls_fields = lcl_convert=>fields_decode( lv_byte8 ). mv_current = mv_current+8. IF ls_fields-len = 0. RETURN. ENDIF. IF ls_fields-len <> ls_fields-maxlen. RAISE EXCEPTION TYPE zcx_ntlm_protocol_error. ENDIF. rv_data = mv_original+ls_fields-offset(ls_fields-len). ENDMETHOD. ""fields METHOD data_str. DATA: lv_raw TYPE xstring. lv_raw = data_raw( ). IF iv_oem = abap_true. rv_data = lcl_convert=>codepage_utf_8_x( lv_raw ). ELSE. rv_data = lcl_convert=>codepage_4103_x( lv_raw ). ENDIF. ENDMETHOD. ""data_str ENDCLASS. ""lcl_read IMPLEMENTATION *----------------------------------------------------------------------* * CLASS lcl_write DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_writer DEFINITION FINAL. PUBLIC SECTION. METHODS constructor IMPORTING iv_type TYPE xstring. METHODS flags IMPORTING is_flags TYPE zcl_ntlm=>ty_flags. METHODS data_raw IMPORTING iv_data TYPE xsequence. METHODS data_str IMPORTING iv_oem TYPE abap_bool DEFAULT abap_false iv_data TYPE clike. METHODS message RETURNING VALUE(rv_msg) TYPE string. METHODS raw IMPORTING iv_data TYPE xsequence. PRIVATE SECTION. TYPES: BEGIN OF ty_fix, fix TYPE i, offset TYPE i, length TYPE i, END OF ty_fix. DATA: mv_header TYPE xstring, mv_payload TYPE xstring, mt_fix TYPE TABLE OF ty_fix. ENDCLASS. ""lcl_write DEFINITION *----------------------------------------------------------------------* * CLASS lcl_write IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_writer IMPLEMENTATION. METHOD message. DATA: lv_xstr TYPE xstring, lv_fix TYPE i, lv_len TYPE i, lv_header TYPE x LENGTH 200, lv_offset TYPE i. FIELD-SYMBOLS: LIKE LINE OF mt_fix. lv_len = xstrlen( mv_header ). ASSERT lv_len <= 200. lv_header = mv_header. lv_offset = xstrlen( mv_header ). LOOP AT mt_fix ASSIGNING . lv_fix = -fix. lv_header+lv_fix(4) = lcl_convert=>int_to_byte4( lv_offset ). lv_offset = lv_offset + -length. ENDLOOP. mv_header = lv_header(lv_len). CONCATENATE mv_header mv_payload INTO lv_xstr IN BYTE MODE. rv_msg = lcl_convert=>base64_encode( lv_xstr ). ENDMETHOD. ""message METHOD constructor. CONCATENATE zcl_ntlm=>c_signature iv_type INTO mv_header IN BYTE MODE. ENDMETHOD. ""constructor METHOD flags. DATA: lv_byte4 TYPE zcl_ntlm=>ty_byte4. lv_byte4 = lcl_convert=>flags_encode( is_flags ). CONCATENATE mv_header lv_byte4 INTO mv_header IN BYTE MODE. ENDMETHOD. ""flags METHOD data_raw. DATA: ls_fields TYPE ty_fields, ls_fix LIKE LINE OF mt_fix, lv_byte8 TYPE zcl_ntlm=>ty_byte8. ls_fields-len = xstrlen( iv_data ). ls_fields-maxlen = xstrlen( iv_data ). ls_fix-fix = xstrlen( mv_header ) + 4. ls_fix-offset = xstrlen( mv_payload ). ls_fix-length = xstrlen( iv_data ). APPEND ls_fix TO mt_fix. lv_byte8 = lcl_convert=>fields_encode( ls_fields ). CONCATENATE mv_header lv_byte8 INTO mv_header IN BYTE MODE. CONCATENATE mv_payload iv_data INTO mv_payload IN BYTE MODE. ENDMETHOD. ""fields METHOD raw. CONCATENATE mv_header iv_data INTO mv_header IN BYTE MODE. ENDMETHOD. ""raw METHOD data_str. DATA: lv_raw TYPE xstring. IF iv_oem = abap_true. lv_raw = lcl_convert=>codepage_utf_8( iv_data ). ELSE. lv_raw = lcl_convert=>codepage_4103( iv_data ). ENDIF. data_raw( lv_raw ). ENDMETHOD. ""data_str ENDCLASS. ""lcl_write IMPLEMENTATION ",6274,False,1284.5780296281007,median "CLASS zcl_abapgit_repo_srv DEFINITION PUBLIC FINAL CREATE PRIVATE . PUBLIC SECTION. INTERFACES zif_abapgit_repo_srv . INTERFACES zif_abapgit_repo_listener . ALIASES get_repo_from_package FOR zif_abapgit_repo_srv~get_repo_from_package . ALIASES get_repo_from_url FOR zif_abapgit_repo_srv~get_repo_from_url . CLASS-METHODS get_instance RETURNING VALUE(ri_srv) TYPE REF TO zif_abapgit_repo_srv . PROTECTED SECTION. PRIVATE SECTION. ALIASES delete FOR zif_abapgit_repo_srv~delete . ALIASES get FOR zif_abapgit_repo_srv~get . ALIASES list FOR zif_abapgit_repo_srv~list . ALIASES validate_package FOR zif_abapgit_repo_srv~validate_package . ALIASES validate_url FOR zif_abapgit_repo_srv~validate_url . CLASS-DATA gi_ref TYPE REF TO zif_abapgit_repo_srv . DATA mv_init TYPE abap_bool. DATA mv_only_favorites TYPE abap_bool. DATA mt_list TYPE zif_abapgit_repo_srv=>ty_repo_list . METHODS determine_branch_name IMPORTING !iv_name TYPE string !iv_url TYPE string RETURNING VALUE(rv_name) TYPE string RAISING zcx_abapgit_exception . METHODS refresh_all RAISING zcx_abapgit_exception . METHODS refresh_favorites RAISING zcx_abapgit_exception . METHODS instantiate_and_add IMPORTING !is_repo_meta TYPE zif_abapgit_persistence=>ty_repo RETURNING VALUE(ro_repo) TYPE REF TO zcl_abapgit_repo RAISING zcx_abapgit_exception . METHODS add IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RAISING zcx_abapgit_exception . METHODS reinstantiate_repo IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !is_meta TYPE zif_abapgit_persistence=>ty_repo_xml RAISING zcx_abapgit_exception . METHODS validate_sub_super_packages IMPORTING !iv_package TYPE devclass !it_repos TYPE zif_abapgit_persistence=>ty_repos !iv_ign_subpkg TYPE abap_bool DEFAULT abap_false EXPORTING VALUE(eo_repo) TYPE REF TO zcl_abapgit_repo !ev_reason TYPE string RAISING zcx_abapgit_exception . ENDCLASS. CLASS zcl_abapgit_repo_srv IMPLEMENTATION. METHOD add. DATA: lo_repo LIKE LINE OF mt_list. LOOP AT mt_list INTO lo_repo. IF lo_repo->ms_data-key = io_repo->ms_data-key. IF lo_repo = io_repo. RETURN. ENDIF. zcx_abapgit_exception=>raise( 'identical keys' ). ENDIF. ENDLOOP. io_repo->bind_listener( me ). APPEND io_repo TO mt_list. ENDMETHOD. METHOD determine_branch_name. DATA lo_branch_list TYPE REF TO zcl_abapgit_git_branch_list. rv_name = iv_name. IF rv_name IS INITIAL. ASSERT NOT iv_url IS INITIAL. lo_branch_list = zcl_abapgit_git_transport=>branches( iv_url ). rv_name = lo_branch_list->get_head_symref( ). ELSEIF -1 = find( val = rv_name sub = zif_abapgit_definitions=>c_git_branch-heads_prefix ). "" Assume short branch name was received rv_name = zif_abapgit_definitions=>c_git_branch-heads_prefix && rv_name. ENDIF. ENDMETHOD. METHOD get_instance. IF gi_ref IS INITIAL. gi_ref = NEW zcl_abapgit_repo_srv( ). ENDIF. ri_srv = gi_ref. ENDMETHOD. METHOD instantiate_and_add. IF is_repo_meta-offline = abap_false. ro_repo = NEW zcl_abapgit_repo_online( is_data = is_repo_meta ). ELSE. ro_repo = NEW zcl_abapgit_repo_offline( is_data = is_repo_meta ). ENDIF. add( ro_repo ). ENDMETHOD. METHOD zif_abapgit_repo_srv~list_favorites. IF mv_init = abap_false OR mv_only_favorites = abap_false. refresh_favorites( ). ENDIF. rt_list = mt_list. ENDMETHOD. METHOD refresh_all. DATA: lt_list TYPE zif_abapgit_persistence=>ty_repos. FIELD-SYMBOLS: LIKE LINE OF lt_list. CLEAR mt_list. lt_list = zcl_abapgit_persist_factory=>get_repo( )->list( ). LOOP AT lt_list ASSIGNING . instantiate_and_add( ). ENDLOOP. mv_init = abap_true. mv_only_favorites = abap_false. ENDMETHOD. METHOD refresh_favorites. DATA: lt_list TYPE zif_abapgit_persistence=>ty_repos, lt_user_favorites TYPE zif_abapgit_persist_user=>ty_favorites. FIELD-SYMBOLS: LIKE LINE OF lt_list. CLEAR mt_list. lt_user_favorites = zcl_abapgit_persistence_user=>get_instance( )->get_favorites( ). lt_list = zcl_abapgit_persist_factory=>get_repo( )->list_favorites( lt_user_favorites ). LOOP AT lt_list ASSIGNING . instantiate_and_add( ). ENDLOOP. mv_init = abap_true. mv_only_favorites = abap_true. ENDMETHOD. METHOD reinstantiate_repo. DATA lo_repo TYPE REF TO zcl_abapgit_repo. DATA ls_full_meta TYPE zif_abapgit_persistence=>ty_repo. lo_repo = get( iv_key ). DELETE TABLE mt_list FROM lo_repo. ASSERT sy-subrc IS INITIAL. MOVE-CORRESPONDING is_meta TO ls_full_meta. ls_full_meta-key = iv_key. instantiate_and_add( ls_full_meta ). ENDMETHOD. METHOD validate_sub_super_packages. DATA: ls_repo LIKE LINE OF it_repos, li_package TYPE REF TO zif_abapgit_sap_package, lt_packages TYPE zif_abapgit_sap_package=>ty_devclass_tt, lo_repo TYPE REF TO zcl_abapgit_repo. LOOP AT it_repos INTO ls_repo. lo_repo = get( ls_repo-key ). li_package = zcl_abapgit_factory=>get_sap_package( ls_repo-package ). IF li_package->exists( ) = abap_false. "" Skip dangling repository CONTINUE. ENDIF. CLEAR lt_packages. IF lo_repo->get_local_settings( )-ignore_subpackages = abap_false. APPEND LINES OF li_package->list_subpackages( ) TO lt_packages. READ TABLE lt_packages TRANSPORTING NO FIELDS WITH KEY table_line = iv_package. IF sy-subrc = 0. eo_repo = lo_repo. ev_reason = |Repository { lo_repo->get_name( ) } already contains { iv_package } |. RETURN. ENDIF. ENDIF. IF iv_ign_subpkg = abap_false. APPEND LINES OF li_package->list_superpackages( ) TO lt_packages. READ TABLE lt_packages TRANSPORTING NO FIELDS WITH KEY table_line = iv_package. IF sy-subrc = 0. eo_repo = lo_repo. ev_reason = |Repository { lo_repo->get_name( ) } already contains subpackage of { iv_package } |. RETURN. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_repo_listener~on_meta_change. DATA li_persistence TYPE REF TO zif_abapgit_persist_repo. li_persistence = zcl_abapgit_persist_factory=>get_repo( ). li_persistence->update_metadata( iv_key = iv_key is_meta = is_meta is_change_mask = is_change_mask ). "" Recreate repo instance if type changed "" Instances in mt_list are of *_online and *_offline type "" If type is changed object should be recreated from the proper class "" TODO refactor, e.g. unify repo logic in one class IF is_change_mask-offline = abap_true. reinstantiate_repo( iv_key = iv_key is_meta = is_meta ). ENDIF. ENDMETHOD. METHOD zif_abapgit_repo_srv~delete. zcl_abapgit_persist_factory=>get_repo( )->delete( io_repo->get_key( ) ). "" If favorite, remove it IF zcl_abapgit_persistence_user=>get_instance( )->is_favorite_repo( io_repo->get_key( ) ) = abap_true. zcl_abapgit_persistence_user=>get_instance( )->toggle_favorite( io_repo->get_key( ) ). ENDIF. DELETE TABLE mt_list FROM io_repo. ASSERT sy-subrc = 0. ENDMETHOD. METHOD zif_abapgit_repo_srv~get. FIELD-SYMBOLS: LIKE LINE OF mt_list. IF mv_init = abap_false. refresh_all( ). ENDIF. DO 2 TIMES. "" Repo might have been created in another session. Try again after refresh IF sy-index = 2. refresh_all( ). ENDIF. LOOP AT mt_list ASSIGNING . IF ->ms_data-key = iv_key. ro_repo = . RETURN. ENDIF. ENDLOOP. ENDDO. zcx_abapgit_exception=>raise( 'repo not found, get' ). ENDMETHOD. METHOD zif_abapgit_repo_srv~get_repo_from_package. DATA: lt_repos TYPE zif_abapgit_persistence=>ty_repos, lv_name TYPE zif_abapgit_persistence=>ty_local_settings-display_name, lv_owner TYPE zif_abapgit_persistence=>ty_local_settings-display_name. FIELD-SYMBOLS: LIKE LINE OF lt_repos. "" check if package is already in use for a different repository lt_repos = zcl_abapgit_persist_factory=>get_repo( )->list( ). READ TABLE lt_repos WITH KEY package = iv_package ASSIGNING . IF sy-subrc = 0. eo_repo = get_instance( )->get( -key ). lv_name = eo_repo->get_name( ). lv_owner = -created_by. ev_reason = |Package { iv_package } already versioned as { lv_name } by { lv_owner }|. ELSE. "" check if package is include as sub-package in a different repo validate_sub_super_packages( EXPORTING iv_package = iv_package it_repos = lt_repos iv_ign_subpkg = iv_ign_subpkg IMPORTING eo_repo = eo_repo ev_reason = ev_reason ). ENDIF. ENDMETHOD. METHOD zif_abapgit_repo_srv~get_repo_from_url. DATA: lt_repos TYPE zif_abapgit_persistence=>ty_repos, lv_current_repo_address TYPE string, lv_check_repo_address TYPE string, lv_repo_path TYPE string, lv_name TYPE zif_abapgit_persistence=>ty_local_settings-display_name, lv_owner TYPE zif_abapgit_persistence=>ty_local_settings-display_name. FIELD-SYMBOLS: LIKE LINE OF lt_repos. CLEAR: eo_repo, ev_reason. lv_current_repo_address = zcl_abapgit_url=>url_address( iv_url ). "" check if url is already in use for a different package lt_repos = zcl_abapgit_persist_factory=>get_repo( )->list( ). LOOP AT lt_repos ASSIGNING WHERE offline = abap_false. lv_check_repo_address = zcl_abapgit_url=>url_address( -url ). IF lv_current_repo_address = lv_check_repo_address. eo_repo = get_instance( )->get( -key ). lv_repo_path = zcl_abapgit_url=>path_name( iv_url ). lv_name = eo_repo->get_name( ). lv_owner = -created_by. ev_reason = |Repository { lv_repo_path } already versioned as { lv_name } by { lv_owner }|. RETURN. ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_repo_srv~is_repo_installed. DATA: lt_repo TYPE zif_abapgit_repo_srv=>ty_repo_list, lo_repo TYPE REF TO zcl_abapgit_repo, lv_url TYPE string, lv_package TYPE devclass, lo_repo_online TYPE REF TO zcl_abapgit_repo_online, lv_err TYPE string. lt_repo = list( ). LOOP AT lt_repo INTO lo_repo. CHECK lo_repo->is_offline( ) = abap_false. lo_repo_online ?= lo_repo. lv_url = lo_repo_online->get_url( ). lv_package = lo_repo_online->get_package( ). CHECK to_upper( lv_url ) = to_upper( iv_url ). "" Validate bindings ""TODO refactor: move this message out of this method IF iv_target_package IS NOT INITIAL AND iv_target_package <> lv_package. lv_err = |Installation to package { lv_package } detected. | && |Cancelling installation|. zcx_abapgit_exception=>raise( lv_err ). ENDIF. rv_installed = abap_true. EXIT. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_repo_srv~list. IF mv_init = abap_false OR mv_only_favorites = abap_true. refresh_all( ). ENDIF. rt_list = mt_list. ENDMETHOD. METHOD zif_abapgit_repo_srv~new_offline. DATA: ls_repo TYPE zif_abapgit_persistence=>ty_repo, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, lo_dot_abapgit TYPE REF TO zcl_abapgit_dot_abapgit. IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-create_repo ) = abap_false. zcx_abapgit_exception=>raise( 'Not authorized' ). ENDIF. validate_package( iv_package ). IF iv_url IS INITIAL. zcx_abapgit_exception=>raise( 'Missing display name for repo' ). ENDIF. lo_dot_abapgit = zcl_abapgit_dot_abapgit=>build_default( ). lo_dot_abapgit->set_folder_logic( iv_folder_logic ). lv_key = zcl_abapgit_persist_factory=>get_repo( )->add( iv_url = iv_url iv_branch_name = '' iv_package = iv_package iv_offline = abap_true is_dot_abapgit = lo_dot_abapgit->get_data( ) ). TRY. ls_repo = zcl_abapgit_persist_factory=>get_repo( )->read( lv_key ). CATCH zcx_abapgit_not_found. zcx_abapgit_exception=>raise( 'new_offline not found' ). ENDTRY. ro_repo ?= instantiate_and_add( ls_repo ). ls_repo-local_settings-main_language_only = iv_main_lang_only. ro_repo->set_local_settings( ls_repo-local_settings ). ENDMETHOD. METHOD zif_abapgit_repo_srv~new_online. DATA: ls_repo TYPE zif_abapgit_persistence=>ty_repo, lv_branch_name LIKE iv_branch_name, lv_key TYPE zif_abapgit_persistence=>ty_repo-key, ls_dot_abapgit TYPE zif_abapgit_dot_abapgit=>ty_dot_abapgit, lv_url TYPE string. ASSERT NOT iv_url IS INITIAL AND NOT iv_package IS INITIAL. lv_url = condense( iv_url ). IF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-create_repo ) = abap_false. zcx_abapgit_exception=>raise( 'Not authorized' ). ENDIF. validate_package( iv_package = iv_package iv_ign_subpkg = iv_ign_subpkg ). validate_url( lv_url ). lv_branch_name = determine_branch_name( iv_name = iv_branch_name iv_url = lv_url ). ls_dot_abapgit = zcl_abapgit_dot_abapgit=>build_default( )->get_data( ). ls_dot_abapgit-folder_logic = iv_folder_logic. lv_key = zcl_abapgit_persist_factory=>get_repo( )->add( iv_url = lv_url iv_branch_name = lv_branch_name "" local ! iv_display_name = iv_display_name iv_package = iv_package iv_offline = abap_false is_dot_abapgit = ls_dot_abapgit ). TRY. ls_repo = zcl_abapgit_persist_factory=>get_repo( )->read( lv_key ). CATCH zcx_abapgit_not_found. zcx_abapgit_exception=>raise( 'new_online not found' ). ENDTRY. ro_repo ?= instantiate_and_add( ls_repo ). IF ls_repo-local_settings-ignore_subpackages <> iv_ign_subpkg. ls_repo-local_settings-ignore_subpackages = iv_ign_subpkg. ENDIF. ls_repo-local_settings-main_language_only = iv_main_lang_only. ro_repo->set_local_settings( ls_repo-local_settings ). ro_repo->refresh( ). ro_repo->find_remote_dot_abapgit( ). ro_repo->check_and_create_package( iv_package ). ENDMETHOD. METHOD zif_abapgit_repo_srv~purge. * uninstalls all objects, no UI or popups in this class * todo, this should be a method on the repo instead? DATA: lt_tadir TYPE zif_abapgit_definitions=>ty_tadir_tt. DATA: lx_error TYPE REF TO zcx_abapgit_exception. ri_log = io_repo->create_new_log( 'Uninstall Log' ). IF io_repo->get_local_settings( )-write_protected = abap_true. zcx_abapgit_exception=>raise( 'Cannot purge. Local code is write-protected by repo config' ). ELSEIF zcl_abapgit_auth=>is_allowed( zif_abapgit_auth=>c_authorization-uninstall ) = abap_false. zcx_abapgit_exception=>raise( 'Not authorized' ). ENDIF. lt_tadir = zcl_abapgit_factory=>get_tadir( )->read( io_repo->get_package( ) ). TRY. zcl_abapgit_objects=>delete( it_tadir = lt_tadir is_checks = is_checks ii_log = ri_log ). CATCH zcx_abapgit_exception INTO lx_error. "" If uninstall fails, repo needs a refresh to show which objects where deleted and which not io_repo->refresh( iv_drop_log = abap_false ). RAISE EXCEPTION lx_error. ENDTRY. delete( io_repo ). ENDMETHOD. METHOD zif_abapgit_repo_srv~validate_package. DATA: lv_as4user TYPE tdevc-as4user, lo_repo TYPE REF TO zcl_abapgit_repo, lv_reason TYPE string. IF iv_package IS INITIAL. zcx_abapgit_exception=>raise( 'add, package empty' ). ENDIF. IF iv_package = '$TMP'. zcx_abapgit_exception=>raise( 'not possible to use $TMP, create new (local) package' ). ENDIF. "" Check if package owned by SAP is allowed (new packages are ok, since they are created automatically) SELECT SINGLE as4user FROM tdevc INTO lv_as4user WHERE devclass = iv_package. ""#EC CI_GENBUFF IF sy-subrc = 0 AND lv_as4user = 'SAP' AND zcl_abapgit_factory=>get_environment( )->is_sap_object_allowed( ) = abap_false. zcx_abapgit_exception=>raise( |Package { iv_package } not allowed, responsible user = 'SAP'| ). ENDIF. "" Check if package is already used in another repo IF iv_chk_exists = abap_true. get_repo_from_package( EXPORTING iv_package = iv_package iv_ign_subpkg = iv_ign_subpkg IMPORTING eo_repo = lo_repo ev_reason = lv_reason ). IF lo_repo IS BOUND. zcx_abapgit_exception=>raise( lv_reason ). ENDIF. ENDIF. ENDMETHOD. METHOD zif_abapgit_repo_srv~validate_url. DATA: lo_repo TYPE REF TO zcl_abapgit_repo, lv_reason TYPE string. zcl_abapgit_url=>validate( iv_url ). IF iv_chk_exists = abap_true. get_repo_from_url( EXPORTING iv_url = iv_url IMPORTING eo_repo = lo_repo ev_reason = lv_reason ). IF lo_repo IS BOUND. zcx_abapgit_exception=>raise( lv_reason ). ENDIF. ENDIF. ENDMETHOD. ENDCLASS. ",4858,False,1166.3616654007433,median "#include #include //#include // Read in VEHICLE_NUMBER, which specifies which trike is being used. // Also provides definitions specific to that trike, under // VEHICLE_NUMBER conditionals. See README.txt for how to use and // modify Settings.h. #include // On Mega, TX must use d10-15, d50-53, or a8-a15 (62-69) const int softwareTx = 10; // to 7 segment LED display const int softwareRx = 7; // not used //SoftwareSerial s7s(softwareRx, softwareTx); #define s7s Serial3 #define LOOP_TIME_MS 400 #define ERROR_HISTORY 20 // Distance the wheel outer circumference moves during one phase cycle. const float WHEEL_PHASE_DISTANCE_MM = WHEEL_DIAMETER_MM * PI / MOTOR_POLE_PAIRS; // Conversion factor from 1 / (motor phase cycle time in microseconds) to speed // in km/h: // There are MOTOR_POLE_PAIRS phase cycles per wheel rotation, so the time for // one wheel rotation (based on a single phase cycle) is the duration of that // phase cycle times the number of pole pairs. Also, we want km / h rather // than mm / usec. Units conversion: // speed measured in km / hr // = (speed measured in mm / usec) * (km / 10^6 mm) * (3600 * 10^6 usec / hr) // = (speed in mm / usec) * 3600 // = (wheel phase distance in mm / motor feedback cycle time in usec) * 3600 // = (wheel phase distance in mm * 3600) / (motor feedback cycle time in usec) // The first part is a constant for a given motor and wheel diameter: const float HUB_PHASE_TO_KMPH = WHEEL_PHASE_DISTANCE_MM * 3600; // For a motor with 23 pole pairs and a 500 mm diameter drive wheel, this is // about 245863.8. /*================ReadTurnAngle ================*/ // Value measured at analog input A2 from right steering column when wheels pointed straight ahead. // An analog voltage can be 0 to 5V, which correspond to angles from 0 to 360 degrees. // Analog input reads this as a value form 0 to 1024. // We may want to mount the sensors so that straight is close to 500. // This number is not critical, since actual wheel turn range is much less than 360 int RightStraight_A2 = 750; // Original value 181 // Value measured at analog input A3 from left steering column when wheels pointed straight ahead. int LeftStraight_A3 = 914; // Original value 181 // Calibration constants // Aangle (degrees) = (Value - RightStraight_A2) * RIGHT_DEGx1000pCOUNT / 1000 #define RIGHT_DEGx1000pCOUNT 333 #define LEFT_DEGx1000pCOUNT 333 // A correct sensor will produce a reading between these values int Left_Min_Count = 850; // Real values are in setup(). int Left_Max_Count = 980; int Right_Min_Count = 698; int Right_Max_Count = 808; // Channel order differs for differernt vehicles // Indices for information stored in arrays RC_rise, RC_elapsed, local_results,... // Right joystick left/right to D21 #define RC_TURN 1 #define RC_AUTO 2 // Right joystick up/down to D19 #define RC_GO 3 // Red (Gear) Switch to D18 #define RC_ESTP 4 // Left joystick left/right to D20 #define RC_RDR 5 // Left joystick up/down to D2 #define RC_RVS 6 // There are six channels, but we are limited to five interrupts #define NUMBER_CHANNELS 6 // RC_rise contains the time value collected in the rising edge interrupts. // RC_elapsed contains the width of the pulse. The rise and fall interrupts // should alternate. #define ProcessFallOfINT(Index) RC_elapsed[Index]=(micros()-RC_rise[Index]) #define ProcessRiseOfINT(Index) RC_rise[Index]=micros() const int SelectCD = 49; // Select IC 3 DAC (channels C and D) const int SelectAB = 53; // Select IC 2 DAC (channels A and B) const unsigned long INVALID_DATA = 0; volatile int rc_index = 0; volatile unsigned long RC_rise[7]; volatile unsigned long RC_elapsed[7]; volatile boolean synced = false; volatile unsigned long last_fallingedge_time = 4294967295; // max long volatile int RC_Done[7] = {0,0,0,0,0,0,0}; // interrupt number handling a function depends on the RC controller. #ifdef RC_SPEKTRUM const int IRPT_RVS = 0; // D2 = Int 0 const int IRPT_TURN = 2; // D21 = Int 2 const int IRPT_GO = 3; // D20 = Int 3 const int IRPT_RDR = 5; // D18 = Int 5 // RDR (rudder) is not used. Instead, use this interrupt for the motor phase feedback, which gives speed. const int IRPT_ESTOP = 4; // D19 = Int 4 //RC input values - pulse widths in microseconds const int DEAD_ZONE = 75; const int MIDDLE = 1500; // was 1322; new stable value = 1510 // extremes of RC pulse width const int MIN_RC = 1090; // was 911; const int MAX_RC = 1930; // was 1730; #endif #ifdef RC_HITEC const int IRPT_RVS = 0; // D2 = Int 0 const int IRPT_TURN = 2; // D21 = Int 2 const int IRPT_GO = 3; // D20 = Int 3 // RDR (rudder) is not used. Instead, use this interrupt for the motor phase // feedback, which gives speed. const int IRPT_RDR = 5; // D18 = Int 5 const int IRPT_ESTOP = 4; // D19 = Int 4 //RC input values - pulse widths in microseconds const int DEAD_ZONE = 75; const int MIDDLE = 1380; // extremes of RC pulse width const int MIN_RC = 960; const int MAX_RC = 1800; #endif // D3 = Int 1 Wheel Click // Currently different interrupts are used for the motor phase feedback. #if (VEHICLE_NUMBER == 1) #define RC_MOTOR_FEEDBACK RC_RVS const int IRPT_MOTOR_FEEDBACK = IRPT_RVS; #endif #if (VEHICLE_NUMBER == 2) #define RC_MOTOR_FEEDBACK RC_RDR const int IRPT_MOTOR_FEEDBACK = IRPT_RDR; #endif long speed_errors[ERROR_HISTORY]; long old_turn_degx1000; unsigned long calibrationTime_ms; unsigned long stoppedTime_ms; unsigned long straightTime_ms; int throttle_control = MIN_ACC_OUT; int brake_control = MAX_BRAKE_OUT; int steer_control = STRAIGHT_TURN_OUT; float Odometer_m = 0; float HubSpeed_kmPh; const float HubSpeed2kmPh = 13000000; const unsigned long HubAtZero = 1159448; //========================================================================================== void ISR_TURN_rise() { noInterrupts(); ProcessRiseOfINT(RC_TURN); attachInterrupt(IRPT_TURN, ISR_TURN_fall, FALLING); interrupts(); } // RDR (rudder) is currently not used. void ISR_RDR_rise() { noInterrupts(); unsigned long old_phase_rise = RC_rise[RC_RDR]; ProcessRiseOfINT(RC_RDR); RC_elapsed[RC_RDR] = RC_rise[RC_RDR] - old_phase_rise; interrupts(); } void ISR_GO_rise() { noInterrupts(); ProcessRiseOfINT(RC_GO); attachInterrupt(IRPT_GO, ISR_GO_fall, FALLING); interrupts(); } void ISR_ESTOP_rise() { noInterrupts(); ProcessRiseOfINT(RC_ESTP); attachInterrupt(IRPT_ESTOP, ISR_ESTOP_fall, FALLING); interrupts(); } void ISR_RVS_rise() { noInterrupts(); ProcessRiseOfINT(RC_RVS); attachInterrupt(IRPT_RVS, ISR_RVS_fall, FALLING); interrupts(); } void ISR_TURN_fall() { noInterrupts(); ProcessFallOfINT(RC_TURN); RC_Done[RC_TURN] = 1; attachInterrupt(IRPT_TURN, ISR_TURN_rise, RISING); interrupts(); } void ISR_GO_fall() { noInterrupts(); ProcessFallOfINT(RC_GO); RC_Done[RC_GO] = 1; attachInterrupt(IRPT_GO, ISR_GO_rise, RISING); interrupts(); } void ISR_ESTOP_fall() { noInterrupts(); ProcessFallOfINT(RC_ESTP); RC_Done[RC_ESTP] = 1; // if (RC_elapsed[RC_ESTP] > MIDDLE) // E_Stop(); attachInterrupt(IRPT_ESTOP, ISR_ESTOP_rise, RISING); interrupts(); } void ISR_RVS_fall() { noInterrupts(); ProcessFallOfINT(RC_RVS); RC_Done[RC_RVS] = 1; attachInterrupt(IRPT_RVS, ISR_RVS_rise, RISING); interrupts(); } // An e-bike hub motor is powered by giving it 3 phase power. This is supplied // by the motor controller. The controller needs feeback from the hub. It // receives three feedback signals from the motor, one for each phase. These // are the *actual* phase rotation of the motor, not the phases supplied by the // controller, which differ from what the motor is currently doing whenever the // controller is attempting to speed up or slow down or change direction of the // motor. The motor phase feedback pulse rate is an integer multiple of wheel // rotation rate. The factor is the number of pole pairs in the motor. Note // that the controller has no idea how many pole pairs the motor has, so it // only controls the phase rate, not the actual rotation rate. It is ""someone // else's problem"" to limit the actual rotation rate or speed. The feedback // signals are 5V square waves. They have some noise -- spikes of several // volts, which exceeds the maximum voltage allowed for Arduino inputs, which // is 5.5V. The signal is cleaned up by an RC low pass filter with R = 1K, // C = 100 nF. void ISR_MOTOR_FEEDBACK_rise() { noInterrupts(); // This differs from the other interrupt routines since we need the *cycle* // duration, not the width of the high pulse. So here, we get the time from // the previous rising edge to the current rising edge. Q: Are we properly // ignoring the first value from all of these interval computations? unsigned long old_phase_rise = RC_rise[RC_MOTOR_FEEDBACK]; ProcessRiseOfINT(RC_MOTOR_FEEDBACK); RC_elapsed[RC_MOTOR_FEEDBACK] = RC_rise[RC_MOTOR_FEEDBACK] - old_phase_rise; interrupts(); } //---------------------------------------------------------------------------- void setup() { //Set up pins pinMode(BRAKE_OUT_PIN, OUTPUT); pinMode(STEER_OUT_PIN, OUTPUT); // SPI: set the slaveSelectPin as an output: pinMode (SelectAB, OUTPUT); pinMode (SelectCD, OUTPUT); pinMode (10, OUTPUT); SPI.setDataMode( SPI_MODE0); SPI.setBitOrder( MSBFIRST); // initialize SPI: // The following line should not be neccessary. It uses a system library. // Note PRR0 and PRR1 are defined for the Mega 2560 but smaller boards have just PRR. PRR0 &= ~4; // turn off PRR0.PRSPI bit so power isn't off SPI.begin(); for (int channel = 0; channel < 4; channel++) DAC_Write (channel, 0); // reset did not clear previous states // put vehicle in initial state steer(STRAIGHT_TURN_OUT); brake(MAX_BRAKE_OUT); moveVehicle(MIN_ACC_OUT); setup7seg(); // Initialize 7 segment display for speedometer delay(500); // let vehicle stabilize Serial.begin(9600); rc_index = 0; for (int i = 0; i < 8; i++) { RC_rise[i] = INVALID_DATA; RC_elapsed[i] = INVALID_DATA; } for (int i = 0; i < ERROR_HISTORY; i++) { speed_errors[i] = 0; } setupWheelRev(); // WheelRev4 addition CalibrateTurnAngle(32, 20); calibrationTime_ms = millis(); attachInterrupt(IRPT_TURN, ISR_TURN_rise, RISING); //attachInterrupt(IRPT_RDR, ISR_RDR_rise, RISING); attachInterrupt(IRPT_GO, ISR_GO_rise, RISING); attachInterrupt(IRPT_ESTOP, ISR_ESTOP_rise, RISING); //attachInterrupt(IRPT_RVS, ISR_RVS_rise, RISING); attachInterrupt(IRPT_MOTOR_FEEDBACK, ISR_MOTOR_FEEDBACK_rise, RISING); Print7headers(false); PrintHeaders(); } void loop() { SerialData Results; // Save start time for performance report. unsigned long startTime = micros(); // Get the next loop start time. unsigned long nextTime = startTime + LOOP_TIME_MS; startCapturingRCState(); unsigned long local_results[7]; // PrintDone(); // ToDo: Refactor this to not have a spinloop. // We get three signals from the RC controller in turn, one each for RC_ESTP, // RC_GO, and RC_TURN. The three signals are sent separately. We get triples of // new RC values at about 30Hz, which is faster than the loop runs. It doesn't // really matter if we are using exactly the latest value, as there isn't much // change between one an the next, except for ESTP, and if we wait til the next // loop pass for that, it should be ok. So just have the interrupt routines read // the RC information and store it, then the loop can use the latest values. // It should check that it has received any values, since the Arduino may be // started before the RC controller is turned on. while (micros() < nextTime && ~((RC_Done[RC_ESTP] == 1) && (RC_Done[RC_GO] == 1) && (RC_Done[RC_TURN] == 1) )) ; //wait // got data; for (int i = 0; i < 8; i++) local_results[i] = RC_elapsed[i]; Print7(false, local_results); processRC(local_results); // Print7( true, local_results); Results.Clear(); Results.kind = MSG_SENSOR; Results.angle_deg = TurnAngle_degx10() / 10; show_speed (&Results); // Report how long the loop took. unsigned long endTime = micros(); unsigned long elapsedTime = endTime - startTime; //Serial.print(""loop elapsed time = ""); //Serial.println(elapsedTime); LogData(local_results, &Results); // data for spreadsheet calibrationTime_ms += LOOP_TIME_MS; straightTime_ms = (steer_control == STRAIGHT_TURN_OUT)? straightTime_ms + LOOP_TIME_MS: 0; stoppedTime_ms = (throttle_control == MIN_ACC_OUT)? stoppedTime_ms + LOOP_TIME_MS: 0; if (calibrationTime_ms > 40000 && straightTime_ms > 3000 && stoppedTime_ms > 3000) { // int oldBrake = brake_control; // brake(MAX_BRAKE_OUT); // put on brakes CalibrateTurnAngle(16, 10); // WARNING: No response to controls while calibrating // brake(oldBrake); // restore brake state calibrationTime_ms = 0; } // Did we spend long enough in the loop that we should immediately // start the next pass? if (nextTime > endTime) { // No, pause til the next loop start time. delay(nextTime - endTime); } else { // Yes, we overran the expected loop interval. Extend the time. nextTime = endTime + 1000 * LOOP_TIME_MS; } } void PrintDone() { Serial.print(""RC_Done values: RC_ESTP ""); Serial.print(RC_Done[RC_ESTP]); Serial.print("" RC_GO ""); Serial.print(RC_Done[RC_GO]); Serial.print("" RC_TURN ""); Serial.print(RC_Done[RC_TURN]); //Serial.print("" RC_RVS ""); Serial.print(RC_Done[RC_RVS]); // Not currently using RC_RVS, and it is always zero. } void Print7headers (bool processed) { processed? Serial.print(""processed data \\t"") : Serial.print(""received data \\t""); #ifdef RC_SPEKTRUM Serial.print(""Time\\t""); Serial.print(""TURN\\t""); Serial.print(""AUTO\\t""); Serial.print(""GO\\t""); Serial.print(""Rudder\\t""); Serial.print(""E-Stop\\t""); Serial.println(""Reverse\\t""); #endif #ifdef RC_HITEC Serial.print(""Time\\t""); Serial.print(""TURN\\t""); Serial.print(""AUTO\\t""); Serial.print(""GO\\t""); Serial.print(""E-Stop\\t""); Serial.print(""Rudder\\t""); Serial.println(""Reverse\\t""); #endif } void Print7 (bool processed, unsigned long results[7]) { processed? Serial.print(""processed data \\t"") : Serial.print(""received data \\t""); Serial.print(results[0]); Serial.print(""\\t""); Serial.print(results[1]); Serial.print(""\\t""); Serial.print(results[2]); Serial.print(""\\t""); Serial.print(results[3]); Serial.print(""\\t""); Serial.print(results[4]); Serial.print(""\\t""); Serial.print(results[5]); Serial.print(""\\t""); Serial.println(results[6]); } void LogData(unsigned long commands[7], SerialData *sensors) // data for spreadsheet { Serial.print(millis()); Serial.print(""\\t""); Serial.print(sensors->speed_cmPs); Serial.print(""\\t""); Serial.print(sensors->speed_cmPs*36.0/1000.); Serial.print(""\\t""); // km/hr Serial.print(HubSpeed_kmPh); Serial.print(""\\t""); Serial.print(sensors->angle_deg); Serial.print(""\\t""); int right = analogRead(A2); int left = analogRead(A3); Serial.print(right); Serial.print(""\\t""); Serial.print(left); Serial.print(""\\t""); Serial.print(throttle_control); Serial.print(""\\t""); Serial.print(brake_control); Serial.print(""\\t""); Serial.print(steer_control); Serial.print(""\\t""); Serial.println(Odometer_m); // Print7 (true, commands); } void PrintHeaders (void) { Serial.print(""(ms) Time\\t""); Serial.print(""(cm/s) Speed\\t""); Serial.print(""(km/h) Speed\\t""); Serial.print(""(km/h) Hub Speed\\t""); Serial.print(""(deg) Angle\\t""); Serial.print(""Right\\t""); Serial.print(""Left\\t""); Serial.print(""Throttle\\t""); Serial.print(""Brake\\t""); Serial.print(""Steer\\t""); Serial.println(""(m) Distance""); } void startCapturingRCState() { for (int i = 1; i < 7; i++) { RC_Done[i] = 0; } } // processRC modified by TCF 9/17/15 void processRC (unsigned long *results) { // 1st pulse is aileron (position 5 on receiver; controlled by Right left/right joystick on transmitter) // used for Steering int aileron = results[RC_TURN]; // Serial.print(""\\tTurn input ""); Serial.print(aileron); results[RC_TURN] = convertTurn(aileron); // Serial.print(""\\tTurn Cmd ""); Serial.println(results[RC_TURN]); /* 2nd pulse is aux (position 1 on receiver; controlled by flap/gyro toggle on transmitter) will be used for selecting remote control or autonomous control. */ // Serial.print(""In processRC, received results[RC_AUTO] = ""); Serial.println(results[RC_AUTO]); if (NUMBER_CHANNELS > 5) results[RC_AUTO] = (results[RC_AUTO] > MIDDLE? HIGH: LOW); // Serial.print(""processed results[RC_AUTO] = ""); Serial.println(results[RC_AUTO]); /* 4th pulse is gear (position 2 on receiver; controlled by gear/mode toggle on transmitter) will be used for emergency stop. D38 */ results[RC_ESTP] = (results[RC_ESTP] > MIDDLE? HIGH: LOW); if (results[RC_ESTP] == HIGH) { E_Stop(); // already done at interrupt level if ((results[RC_AUTO] == LOW) && (NUMBER_CHANNELS > 5)) // under RC control steer(results[RC_TURN]); Serial.println(""Exiting processRC due to E-stop.""); return; } if ((results[RC_AUTO] == HIGH) && (NUMBER_CHANNELS > 5)) { Serial.println(""Exiting processRC as not under RC control.""); return; // not under RC control } else { // Serial.println(""Continuing processRC as under RC control.""); } /* 6th pulse is marked throttle (position 6 on receiver; controlled by Left up/down joystick on transmitter). It will be used for shifting from Drive to Reverse . D40 */ results[RC_RVS] = (results[RC_RVS] > MIDDLE? HIGH: LOW); // TO DO: Select Forward / reverse based on results[RC_RVS] /* 3rd pulse is elevator (position 4 on receiver; controlled by Right up/down. will be used for throttle/brake: RC_Throttle */ // Braking or Throttle if (liveBrake(results[RC_GO])) convertBrake (&(results[RC_GO])); //Accelerating else if(liveThrottle(results[RC_GO])) { results[RC_GO] = convertThrottle(results[RC_GO]); moveVehicle(results[RC_GO]); } else moveVehicle(MIN_ACC_OUT); steer(results[RC_TURN]); /* 5th pulse is rudder (position 3 on receiver; controlled by Left left/right joystick on transmitter) Not used */ // results[RC_RDR] = (results[RC_RDR] > MIDDLE? HIGH: LOW); // could be analog Serial.println(results[RC_MOTOR_FEEDBACK]); if (results[RC_MOTOR_FEEDBACK] >= HubAtZero) HubSpeed_kmPh = 0; else HubSpeed_kmPh = HubSpeed2kmPh / results[RC_MOTOR_FEEDBACK]; // Serial.println(""""); // New line } //Converts RC values to corresponding values for the PWM output int convertTurn(int input) { long int steerRange, rcRange; long output; int trueOut; // Serial.print(""\\tconvertTurn: input = \\t""); Serial.print(input); // Check if Input is in steer dead zone if ((input <= MIDDLE + DEAD_ZONE) && (input >= MIDDLE - DEAD_ZONE)) return STRAIGHT_TURN_OUT; // On SPEKTRUM, MIN_RC = 1 msec = stick right; MAX_RC = 2 msec = stick left // On HI_TEC, MIN_RC = 1 msec = stick left; MAX_RC = 2 msec = stick right // LEFT_TURN_OUT > RIGHT_TURN_OUT #ifdef RC_HITEC input = MAX_RC - (input - MIN_RC); #endif if (input > MIDDLE + DEAD_ZONE) { // left turn steerRange = LEFT_TURN_OUT - STRAIGHT_TURN_OUT; rcRange = MAX_RC - (MIDDLE + DEAD_ZONE); input = input - MIDDLE - DEAD_ZONE; // originally input = middle + dead_zone output = STRAIGHT_TURN_OUT + input * steerRange / rcRange; //set max and min values if out of range trueOut = (int)output; if(trueOut > LEFT_TURN_OUT) trueOut = LEFT_TURN_OUT; if(trueOut < STRAIGHT_TURN_OUT) trueOut = STRAIGHT_TURN_OUT; return trueOut; } if (input < MIDDLE - DEAD_ZONE) { // right turn steerRange = STRAIGHT_TURN_OUT - RIGHT_TURN_OUT; rcRange = MIDDLE - DEAD_ZONE - MIN_RC; input = input - DEAD_ZONE - MIDDLE; // input is negative output = STRAIGHT_TURN_OUT + input * steerRange / rcRange; //set max and min values if out of range trueOut = (int)output; if(trueOut < RIGHT_TURN_OUT) trueOut = RIGHT_TURN_OUT; if(trueOut > STRAIGHT_TURN_OUT) trueOut = STRAIGHT_TURN_OUT; return trueOut; } } int convertThrottle(int input) { //full throttle = 227, min = 40 const int dacRange = MAX_ACC_OUT - MIN_ACC_OUT; const int rcRange = MAX_RC - (MIDDLE + DEAD_ZONE); input -= (MIDDLE + DEAD_ZONE); double output = (double)input /(double)rcRange; output *= dacRange; output += MIN_ACC_OUT; //set max values if out of range int trueOut = (int)output; if(trueOut > MAX_ACC_OUT) trueOut = MAX_ACC_OUT; return trueOut; } //Tests for inputs // Input not in throttle dead zone boolean liveThrottle(int acc) { return (acc > MIDDLE + DEAD_ZONE); } // Input is not in brake dead zone boolean liveBrake(int brake) { return (brake < MIDDLE - DEAD_ZONE); } // Emergency stop void E_Stop() { brake(MAX_BRAKE_OUT); moveVehicle(MIN_ACC_OUT); delay (2000); // inhibit output // TO DO: disable 36V power } //Send values to output pin void steer(int pos) { analogWrite(STEER_OUT_PIN, pos); // Serial.print(""\\tSteering to: \\t""); Serial.print(pos); steer_control = pos; } void convertBrake(long unsigned *amount) { if (*amount < (MIDDLE + MIN_RC)/2) *amount = MAX_BRAKE_OUT; else *amount = MIN_BRAKE_OUT; brake (*amount); } void brake (int amount) { analogWrite(BRAKE_OUT_PIN, amount); // Serial.print(""\\tBraking to: \\t""); Serial.print(*amount); brake_control = amount; } /*---------------------------------------------------------------------------------------*/ /* DAC_Write applies value to address, producing an analog voltage. // address: 0 for chan A; 1 for chan B; 2 for chan C; 3 for chan D // value: digital value converted to analog voltage // Output goes to mcp 4802 Digital-Analog Converter Chip via SPI // There is no input back from the chip. */ void DAC_Write(int address, int value) /* REGISTER 5-3: WRITE COMMAND REGISTER FOR MCP4802 (8-BIT DAC) A/B — GA SHDN D7 D6 D5 D4 D3 D2 D1 D0 x x x x bit 15 bit 0 bit 15 A/B: DACA or DACB Selection bit 1 = Write to DACB 0 = Write to DACA bit 14 — Don’t Care bit 13 GA: Output Gain Selection bit 1 = 1x (VOUT = VREF * D/4096) 0 = 2x (VOUT = 2 * VREF * D/4096), where internal VREF = 2.048V. bit 12 SHDN: Output Shutdown Control bit 1 = Active mode operation. VOUT is available. 0 = Shutdown the selected DAC channel. Analog output is not available at the channel that was shut down. VOUT pin is connected to 500 k (typical) bit 11-0 D11:D0: DAC Input Data bits. Bit x is ignored. With 4.95 V on Vcc, observed output for 255 is 4.08V. This is as documented; with gain of 2, maximum output is 2 * Vref */ { int byte1 = ((value & 0xF0)>>4) | 0x10; // acitve mode, bits D7-D4 int byte2 = (value & 0x0F)<<4; // D3-D0 if (address < 2) { // take the SS pin low to select the chip: digitalWrite(SelectAB,LOW); if (address >= 0) { if (address == 1) byte1 |= 0x80; // second channnel SPI.transfer(byte1); SPI.transfer(byte2); } // take the SS pin high to de-select the chip: digitalWrite(SelectAB,HIGH); } else { // take the SS pin low to select the chip: digitalWrite(SelectCD,LOW); if (address <= 3) { if (address == 3) byte1 |= 0x80; // second channnel SPI.transfer(byte1); SPI.transfer(byte2); } // take the SS pin high to de-select the chip: digitalWrite(SelectCD,HIGH); } } void moveVehicle(int acc) { /* Observed behavior on ElCano #1 E-bike no load (May 10, 2013, TCF) 0.831 V at rest 52 counts 1.20 V: nothing 75 1.27 V: just starting 79 1.40 V: slow, steady 87 1.50 V: brisker 94 3.63 V: max 227 counts 255 counts = 4.08 V */ DAC_Write(DAC_CHANNEL, acc); throttle_control = acc; // post most recent throttle. } /*========================================================================/ *============================WheelRev4 code==============================/ *=======================================================================*/ /* Wheel Revolution Interrupt routine Ben Spencer 10/21/13 Modified by Tyler Folsom 3/16/14; 3/3/16 A cyclometer gives a click once per revolution. This routine computes the speed. */ #define SerialOdoOut Serial3 #define SerialMonitor Serial #define MEG 1000000 #define MAX_SPEED_KPH 50 #define MAX_SPEED_mmPs ((MAX_SPEED_KPH * MEG) / 3600) // MAX_SPEED_mmPs = 13,888 mm/s = 13.888 m/s unsigned long MinTickTime_ms; // ((WHEEL_DIAMETER_MM * 3142) / MAX_SPEED_mmPs) // MinTickTime_ms = 89 ms #define MIN_SPEED_mPh 3000 // A speed of less than 0.3 KPH is zero. unsigned long MaxTickTime_ms; // ((WHEEL_DIAMETER_MM * 3142) / MIN_SPEED_mmPs) // MinTickTime_ms = 9239 ms = 9 sec long SpeedCyclometer_mmPs = 0; // Speed in revolutions per second is independent of wheel size. float SpeedCyclometer_revPs = 0.0;//revolutions per sec #define IRQ_NONE 0 #define IRQ_FIRST 1 #define IRQ_SECOND 2 #define IRQ_RUNNING 3 #define NO_DATA 0x7FFFFFFF volatile byte InterruptState = IRQ_NONE; // Tells us if we have initialized. volatile byte ClickNumber = 0; // Used to distinguish old data from new. volatile unsigned long TickTime = 0; // Time from one wheel rotation to the next gives speed. volatile unsigned long OldTick = 0; static struct hist { long olderSpeed_mmPs; // older data unsigned long olderTime_ms; // time stamp of older speed long oldSpeed_mmPs; // last data from the interrupt byte oldClickNumber; unsigned long oldTime_ms; // time stamp of old speed byte nowClickNumber; // situation when we want to display the speed byte InterruptState; unsigned long nowTime_ms; unsigned long TickTime_ms; // Tick times are used to compute speeds unsigned long OldTick_ms; // Tick times may not match time stamps if we don't process // results of every interrupt } history; /*---------------------------------------------------------------------------------------*/ // WheelRev is called by an interrupt. void WheelRev() { static int flip = 0; unsigned long tick; noInterrupts(); tick = millis(); if (InterruptState != IRQ_RUNNING) // Need to process 1st two interrupts before results are meaningful. InterruptState++; if (tick - TickTime > MinTickTime_ms) { OldTick = TickTime; TickTime = tick; ++ClickNumber; } if (flip) digitalWrite(13, LOW); else digitalWrite(13, HIGH); flip =!flip; interrupts(); } /*---------------------------------------------------------------------------------------*/ void setupWheelRev() { SerialOdoOut.begin(115200); // C6 to C4 pinMode(13, OUTPUT); //led digitalWrite(13, LOW);//turn LED off pinMode(3, INPUT);//pulls input HIGH float MinTick = WHEEL_DIAMETER_MM * PI; // SerialMonitor.print ("" MinTick = ""); // SerialMonitor.println (MinTick); MinTick *= 1000.0; MinTick /= MAX_SPEED_mmPs; // SerialMonitor.print (MinTick); MinTickTime_ms = MinTick; SerialMonitor.print ("" MinTickTime_ms = ""); SerialMonitor.println (MinTickTime_ms); // SerialMonitor.print ("" MIN_SPEED_mPh = ""); // SerialMonitor.print (MIN_SPEED_mPh); float MIN_SPEED_mmPs = ((MIN_SPEED_mPh * 1000.0) / 3600.0); // MIN_SPEED_mmPs = 135 mm/s // SerialMonitor.print ("" MIN_SPEED_mmPs = ""); // SerialMonitor.print (MIN_SPEED_mmPs); float MaxTick = (WHEEL_DIAMETER_MM * PI * 1000.0) / MIN_SPEED_mmPs; // SerialMonitor.print ("" MaxTick = ""); // SerialMonitor.print (MaxTick); MaxTickTime_ms = MaxTick; // SerialMonitor.print ("" MaxTickTime = ""); // SerialMonitor.println (MaxTickTime_ms); TickTime = millis(); // OldTick will normally be less than TickTime. // When it is greater, TickTime - OldTick is a large positive number, // indicating that we have not moved. // TickTime would overflow after days of continuous operation, causing a glitch of // a display of zero speed. It is unlikely that we have enough battery power to ever see this. OldTick = TickTime; InterruptState = IRQ_NONE; ClickNumber = 0; history.oldSpeed_mmPs = history.olderSpeed_mmPs = NO_DATA; attachInterrupt (1, WheelRev, RISING);//pin 3 on Mega SerialMonitor.print(""TickTime: ""); SerialMonitor.print(TickTime); SerialMonitor.print("" OldTick: ""); SerialMonitor.println(OldTick); SerialMonitor.println(""WheelRev setup complete""); } /*---------------------------------------------------------------------------------------*/ void ComputeSpeed( struct hist *data) { if (data->InterruptState == IRQ_NONE || data->InterruptState == IRQ_FIRST) { // No data SpeedCyclometer_mmPs = 0; SpeedCyclometer_revPs = 0; return; } float Circum_mm = (WHEEL_DIAMETER_MM * PI); long WheelRev_ms = data->TickTime_ms - data->OldTick_ms; if (data->InterruptState >= IRQ_SECOND && data->oldSpeed_mmPs == NO_DATA && WheelRev_ms > 0) { // first computed speed SpeedCyclometer_revPs = 1000.0 / WheelRev_ms; SpeedCyclometer_mmPs = data->oldSpeed_mmPs = Circum_mm * SpeedCyclometer_revPs; data->oldTime_ms = data->TickTime_ms; // time stamp for oldSpeed_mmPs data->oldClickNumber = data->nowClickNumber; return; } if (data->InterruptState == IRQ_RUNNING && data->olderSpeed_mmPs == NO_DATA && WheelRev_ms > 0 && data->nowClickNumber != data->oldClickNumber) { // new data for second computed speed data->olderSpeed_mmPs = data->oldSpeed_mmPs; data->olderTime_ms = data->oldTime_ms; SpeedCyclometer_revPs = 1000.0 / WheelRev_ms; SpeedCyclometer_mmPs = data->oldSpeed_mmPs = Circum_mm * SpeedCyclometer_revPs; data->oldTime_ms = data->TickTime_ms; // time stamp for oldSpeed_mmPs data->oldClickNumber = data->nowClickNumber; return; } if (data->InterruptState == IRQ_RUNNING && data->olderSpeed_mmPs != NO_DATA && WheelRev_ms > 0) { // Normal situation after initialization if (data->nowClickNumber == data->oldClickNumber) { // No new information; extrapolate the speed if decelerating; else keep old speed if (data->olderSpeed_mmPs > data->oldSpeed_mmPs) { // decelerrating float deceleration = (float) (data->olderSpeed_mmPs - data->oldSpeed_mmPs) / (data->oldTime_ms - data->olderTime_ms); SpeedCyclometer_mmPs = data->oldSpeed_mmPs - deceleration * (data->nowTime_ms - data->oldTime_ms); if (SpeedCyclometer_mmPs < 0) SpeedCyclometer_mmPs = 0; SpeedCyclometer_revPs = SpeedCyclometer_mmPs / Circum_mm; } else { // accelerating; should get new data soon } if(data->nowTime_ms - data->oldTime_ms > MaxTickTime_ms) { // too long without getting a tick SpeedCyclometer_mmPs = 0; SpeedCyclometer_revPs = 0; if(data->nowTime_ms - data->oldTime_ms > 2 * MaxTickTime_ms) { InterruptState = IRQ_FIRST; // Invalidate old data data->oldSpeed_mmPs = NO_DATA; data->olderSpeed_mmPs = NO_DATA; } } } else { // moving; use new data to compute speed data->olderSpeed_mmPs = data->oldSpeed_mmPs; data->olderTime_ms = data->oldTime_ms; SpeedCyclometer_revPs = 1000.0 / WheelRev_ms; SpeedCyclometer_mmPs = data->oldSpeed_mmPs = Circum_mm * SpeedCyclometer_revPs; data->oldTime_ms = data->TickTime_ms; // time stamp for oldSpeed_mmPs data->oldClickNumber = data->nowClickNumber; } } if(data->nowTime_ms - data->TickTime_ms > WheelRev_ms) { // at this speed, should have already gotten a tick?; If so, we are slowing. float SpeedSlowing_revPs = 1000.0 / (data->nowTime_ms - data->TickTime_ms); long SpeedSlowing_mmPs = Circum_mm * SpeedCyclometer_revPs; SpeedCyclometer_revPs = min(SpeedCyclometer_revPs, SpeedSlowing_revPs); SpeedCyclometer_mmPs = min(SpeedCyclometer_mmPs, SpeedSlowing_mmPs); } return; } /*---------------------------------------------------------------------------------------*/ void PrintSpeed( struct hist *data) { Serial.print(SpeedCyclometer_mmPs); Serial.print(""\\t""); Serial.print(data->InterruptState); Serial.print(""\\t""); Serial.print(data->oldSpeed_mmPs); Serial.print(""\\t""); Serial.print(data->olderSpeed_mmPs); Serial.print(""\\t""); Serial.print(data->oldClickNumber); Serial.print(""\\t""); Serial.print(data->nowClickNumber); Serial.print(""\\t""); Serial.print(data->olderTime_ms); Serial.print(""\\t""); Serial.print(data->oldTime_ms); Serial.print(""\\t""); Serial.print(data->nowTime_ms); Serial.print(""\\t""); Serial.print(data->TickTime_ms); Serial.print(""\\t""); Serial.println(data->OldTick_ms); } /*---------------------------------------------------------------------------------------*/ void show_speed(SerialData *Results) { history.nowTime_ms = millis(); noInterrupts(); history.TickTime_ms = TickTime; history.OldTick_ms = OldTick; history.nowClickNumber = ClickNumber; history.InterruptState = InterruptState; interrupts(); ComputeSpeed (&history); // PrintSpeed(&history); Odometer_m += (float)(LOOP_TIME_MS * SpeedCyclometer_mmPs) / MEG; // Since Results have not been cleared, angle information will also be sent. Results->speed_cmPs = SpeedCyclometer_mmPs / 10; writeSerial(&Serial3, Results); // Send speed to C6 show7seg( SpeedCyclometer_mmPs); // Show speed on 7 segment LEDs } /*========================CalibrateTurnAngle======================*/ /* This routine should only be called when - Wheels are pointed straight ahead, and have been for a while. - Trike is not moving, and is stable. Calibration will block any response to controls; there will be no turning or movemnet during calibration. Angle sensors can drift, and should periodically be zeroed. */ void CalibrateTurnAngle(int count, int pause) { int totalRight = 0; int totalLeft = 0; int i, left, right; for (i = 0; i < count; i++) { totalRight += analogRead(A2); totalLeft += analogRead(A3); delay(pause); } right = totalRight / count; left = totalLeft / count; // Only recalibrate when instruments are reasonable // Do not make garbage readings the new normal. if(RIGHT_MIN_COUNT <= right && right <= RIGHT_MAX_COUNT) { RightStraight_A2 = right; Right_Min_Count = RightStraight_A2 - 60; // 60 counts is 20 degrees Right_Max_Count = RightStraight_A2 + 60; } else { RightStraight_A2 = RIGHT_MIN_COUNT + (RIGHT_MAX_COUNT - RIGHT_MIN_COUNT)/2 ; Right_Min_Count = RIGHT_MIN_COUNT; Right_Max_Count = RIGHT_MAX_COUNT; } if (LEFT_MIN_COUNT <= left && left <= LEFT_MAX_COUNT) { LeftStraight_A3 = left; Left_Min_Count = LeftStraight_A3 - 60; Left_Max_Count = LeftStraight_A3 + 60; } else { LeftStraight_A3 = LEFT_MIN_COUNT + (LEFT_MAX_COUNT - LEFT_MIN_COUNT)/2 ; Left_Min_Count = LEFT_MIN_COUNT; Left_Max_Count = LEFT_MAX_COUNT; } // Serial.print(""\\tCALIBRATE: Left Straight\\t""); Serial.print(LeftStraight_A3); // Serial.print(""\\tRight Straight\\t""); Serial.println(RightStraight_A2); old_turn_degx1000 = 0; // straight } /*======================ReadTurnAngle======================*/ int TurnAngle_degx10() { long new_turn_degx1000; long expected_turn_degx1000; int new_turn_degx10; long min_ang, max_ang; bool OK_right = false; bool OK_left = false; int right = analogRead(A2); int left = analogRead(A3); // Serial.print(""Left""); Serial.print(""\\t""); Serial.print(left); // Serial.print(""\\tRight""); Serial.print(""\\t""); Serial.print(right); // Serial.print(""LeftStraight_A3""); Serial.print(""\\t""); Serial.print(LeftStraight_A3); // Serial.print(""\\tRightStraight_A2""); Serial.print(""\\t""); Serial.print(RightStraight_A2); if ((Right_Min_Count <= right) && (right <= Right_Max_Count)) OK_right = true; if ((Left_Min_Count <= left) && (left <= Left_Max_Count)) OK_left = true; long right_degx1000 = (right - RightStraight_A2) * RIGHT_DEGx1000pCOUNT; long left_degx1000 = (left - LeftStraight_A3) * LEFT_DEGx1000pCOUNT; // Serial.print(""Left""); Serial.print(""\\t""); Serial.print(left_degx1000); // Serial.print(""\\tRight""); Serial.print(""\\t""); Serial.print(right_degx1000); expected_turn_degx1000 = old_turn_degx1000; if (OK_left && OK_right) { // use the median if (right_degx1000 < left_degx1000) { min_ang = right_degx1000; max_ang = left_degx1000; } else { min_ang = left_degx1000; max_ang = right_degx1000; } if (expected_turn_degx1000 < min_ang) new_turn_degx1000 = min_ang; else if (expected_turn_degx1000 > max_ang) new_turn_degx1000 = max_ang; else new_turn_degx1000 = expected_turn_degx1000; } else if (OK_left) { new_turn_degx1000 = (left_degx1000 + expected_turn_degx1000)/2; } else if (OK_right) { new_turn_degx1000 = (right_degx1000 + expected_turn_degx1000)/2; } else { // No sensors; use last valid measurement new_turn_degx1000 = old_turn_degx1000; } new_turn_degx10 = (int) (new_turn_degx1000 / 100); old_turn_degx1000 = new_turn_degx1000; // Serial.print(""\\tnew_turn_degx10""); Serial.print(""\\t""); Serial.println(new_turn_degx10); return new_turn_degx10; } /*---------------------------------------------------------------------------------------*/ void Throttle_PID(long error_speed_mmPs) /* Use throttle and brakes to keep vehicle at a desired speed. A PID controller uses the error in the set point to increase or decrease the juice. P = proportional; change based on present error I = integra; change based on recent sum of errors D = derivative: change based on how error is changing. The controller needs to avoid problems of being too sluggish or too skittery. A sluggish control (overdamped) takes too long to reach the set-point. A skitterish control (underdamped) can overshoot, then undershoot, producing oscillations and jerky motion. Getting the right control is a matter of tuning right parts of P, I, and D, which is something of a black art. For more information, search for: VanDoren Proportional Integral Derivative Control */ { static int throttle_control = MIN_ACC_OUT; static int brake_control = MAX_BRAKE_OUT; static int error_index = 0; int i; static long error_sum = 0; long mean_speed_error = 0; long extrapolated_error = 0; long PID_error; const float P_tune = 0.4; const float I_tune = 0.5; const float D_tune = 0.1; const long speed_tolerance_mmPs = 75; // about 0.2 mph // setting the max_error affacts control: anything bigger gets maximum response const long max_error_mmPs = 2500; // about 5.6 mph error_sum -= speed_errors[error_index]; speed_errors[error_index] = error_speed_mmPs; error_sum += error_speed_mmPs; mean_speed_error = error_sum / ERROR_HISTORY; i = (error_index -1) % ERROR_HISTORY; if (++error_index >= ERROR_HISTORY) error_index = 0; extrapolated_error = 2 * error_speed_mmPs - speed_errors[i]; PID_error = P_tune * error_speed_mmPs + I_tune * mean_speed_error + D_tune * extrapolated_error; if (PID_error > speed_tolerance_mmPs) { // too fast long throttle_decrease = (MAX_ACC_OUT - MIN_ACC_OUT) * PID_error / max_error_mmPs; throttle_control -= throttle_decrease; if (throttle_control < MIN_ACC_OUT) throttle_control = MIN_ACC_OUT; moveVehicle(throttle_control); long brake_increase = (MAX_BRAKE_OUT - MIN_BRAKE_OUT) * PID_error / max_error_mmPs; // MIN_BRAKE_OUT = 180; MAX_BRAKE_OUT = 250; brake_control -= brake_increase; if (brake_control > MAX_BRAKE_OUT) brake_control = MAX_BRAKE_OUT; brake(brake_control); } else if (PID_error < speed_tolerance_mmPs) { // too slow long throttle_increase = (MAX_ACC_OUT - MIN_ACC_OUT) * PID_error / max_error_mmPs; throttle_control += throttle_increase; if (throttle_control > MAX_ACC_OUT) throttle_control = MAX_ACC_OUT; moveVehicle(throttle_control); // release brakes long brake_decrease = (MAX_BRAKE_OUT - MIN_BRAKE_OUT) * PID_error / max_error_mmPs; // MIN_BRAKE_OUT = 180; MAX_BRAKE_OUT = 250; brake_control += brake_decrease; if (brake_control < MIN_BRAKE_OUT) brake_control = MIN_BRAKE_OUT; brake(brake_control); } // else maintain current speed Serial.print(""\\tThrottle Brake \\t""); // csv for spreadsheet Serial.print(throttle_control); Serial.print(""\\t""); Serial.print(brake_control); Serial.print(""\\t""); // Serial.print(drive_speed_mmPs); Serial.print(""\\t""); // Serial.println(sensor_speed_mmPs); } /*---------------------------------------------------------------------------------------*/ /* Serial 7-Segment Display Example Code Serial Mode Stopwatch by: Jim Lindblom SparkFun Electronics date: November 27, 2012 license: This code is public domain. This example code shows how you could use software serial Arduino library to interface with a Serial 7-Segment Display. There are example functions for setting the display's brightness, decimals and clearing the display. The print function is used with the SoftwareSerial library to send display data to the S7S. Circuit: Arduino -------------- Serial 7-Segment 3.3V -------------------- VCC GND -------------------- GND 10 -------------------- RX */ void setup7seg() { // Must begin s7s software serial at the correct baud rate. // The default of the s7s is 9600. s7s.begin(9600); // Clear the display, and then turn on all segments and decimals clearDisplay(); // Clears display, resets cursor setBrightness(127); // Medium brightness // setBrightness(255); // High brightness } void show7seg(int speed_mmPs) { char tempString[10]; // Will be used with sprintf to create strings // convert mm/s to km/h int speed_kmPhx10 = (speed_mmPs*.036); // Magical sprintf creates a string for us to send to the s7s. // The %4d option creates a 4-digit integer. sprintf(tempString, ""%4d"", speed_kmPhx10); // Serial.println(tempString); // This will output the tempString to the S7S s7s.print(tempString); setDecimals(0b00000100); // Sets digit 3 decimal on } // Send the clear display command (0x76) // This will clear the display and reset the cursor void clearDisplay() { s7s.write(0x76); // Clear display command } // Set the displays brightness. Should receive byte with the value // to set the brightness to // dimmest------------->brightest // 0--------127--------255 void setBrightness(byte value) { s7s.write(0x7A); // Set brightness command byte s7s.write(value); // brightness data byte } // Turn on any, none, or all of the decimals. // The six lowest bits in the decimals parameter sets a decimal // (or colon, or apostrophe) on or off. A 1 indicates on, 0 off. // [MSB] (X)(X)(Apos)(Colon)(Digit 4)(Digit 3)(Digit2)(Digit1) void setDecimals(byte decimals) { s7s.write(0x77); s7s.write(decimals); } ",12452,False,1735.2912266121032,median "/**************************************************************************************************************************** Async_ConfigOnSwitch.ino For ESP8266 / ESP32 boards ESPAsync_WiFiManager is a library for the ESP8266/Arduino platform, using (ESP)AsyncWebServer to enable easy configuration and reconfiguration of WiFi credentials using a Captive Portal. Modified from 1. Tzapu (https://github.com/tzapu/WiFiManager) 2. Ken Taylor (https://github.com/kentaylor) 3. Alan Steremberg (https://github.com/alanswx/ESPAsyncWiFiManager) 4. Khoi Hoang (https://github.com/khoih-prog/ESP_WiFiManager) Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager Licensed under MIT license *****************************************************************************************************************************/ /**************************************************************************************************************************** This example will open a configuration portal when no WiFi configuration has been previously entered or when a button is pushed. It is the easiest scenario for configuration but requires a pin and a button on the ESP8266 device. The Flash button is convenient for this on NodeMCU devices. Also in this example a password is required to connect to the configuration portal network. This is inconvenient but means that only those who know the password or those already connected to the target WiFi network can access the configuration portal and the WiFi network credentials will be sent from the browser over an encrypted connection and can not be read by observers. *****************************************************************************************************************************/ #if !( defined(ESP8266) || defined(ESP32) ) #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET ""ESPAsync_WiFiManager v1.10.0"" #define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 //For ESP32, To use ESP32 Dev Module, QIO, Flash 4MB/80MHz, Upload 921600 //Ported to ESP32 #ifdef ESP32 #include #include #include // From v1.1.1 #include WiFiMulti wifiMulti; // LittleFS has higher priority than SPIFFS #if ( ARDUINO_ESP32C3_DEV ) // Currently, ESP32-C3 only supporting SPIFFS and EEPROM. Will fix to support LittleFS #define USE_LITTLEFS false #define USE_SPIFFS true #else #define USE_LITTLEFS true #define USE_SPIFFS false #endif #if USE_LITTLEFS // Use LittleFS #include ""FS.h"" // Check cores/esp32/esp_arduino_version.h and cores/esp32/core_version.h //#if ( ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0) ) //(ESP_ARDUINO_VERSION_MAJOR >= 2) #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) #warning Using ESP32 Core 1.0.6 or 2.0.0+ // The library has been merged into esp32 core from release 1.0.6 #include FS* filesystem = &LittleFS; #define FileFS LittleFS #define FS_Name ""LittleFS"" #else #warning Using ESP32 Core 1.0.5-. You must install LITTLEFS library // The library has been merged into esp32 core from release 1.0.6 #include // https://github.com/lorol/LITTLEFS FS* filesystem = &LITTLEFS; #define FileFS LITTLEFS #define FS_Name ""LittleFS"" #endif #elif USE_SPIFFS #include FS* filesystem = &SPIFFS; #define FileFS SPIFFS #define FS_Name ""SPIFFS"" #else // Use FFat #include FS* filesystem = &FFat; #define FileFS FFat #define FS_Name ""FFat"" #endif ////// #define ESP_getChipId() ((uint32_t)ESP.getEfuseMac()) #define LED_BUILTIN 2 #define LED_ON HIGH #define LED_OFF LOW #else #include //https://github.com/esp8266/Arduino //needed for library #include // From v1.1.0 #include ESP8266WiFiMulti wifiMulti; #define USE_LITTLEFS true #if USE_LITTLEFS #include FS* filesystem = &LittleFS; #define FileFS LittleFS #define FS_Name ""LittleFS"" #else FS* filesystem = &SPIFFS; #define FileFS SPIFFS #define FS_Name ""SPIFFS"" #endif ////// #define ESP_getChipId() (ESP.getChipId()) #define LED_ON LOW #define LED_OFF HIGH #endif #ifdef ESP32 //See file .../hardware/espressif/esp32/variants/(esp32|doitESP32devkitV1)/pins_arduino.h #define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED #define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED #define PIN_D0 0 // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32 #define PIN_D1 1 // Pin D1 mapped to pin GPIO1/TX0 of ESP32 #define PIN_D2 2 // Pin D2 mapped to pin GPIO2/ADC12/TOUCH2 of ESP32 #define PIN_D3 3 // Pin D3 mapped to pin GPIO3/RX0 of ESP32 #define PIN_D4 4 // Pin D4 mapped to pin GPIO4/ADC10/TOUCH0 of ESP32 #define PIN_D5 5 // Pin D5 mapped to pin GPIO5/SPISS/VSPI_SS of ESP32 #define PIN_D6 6 // Pin D6 mapped to pin GPIO6/FLASH_SCK of ESP32 #define PIN_D7 7 // Pin D7 mapped to pin GPIO7/FLASH_D0 of ESP32 #define PIN_D8 8 // Pin D8 mapped to pin GPIO8/FLASH_D1 of ESP32 #define PIN_D9 9 // Pin D9 mapped to pin GPIO9/FLASH_D2 of ESP32 #define PIN_D10 10 // Pin D10 mapped to pin GPIO10/FLASH_D3 of ESP32 #define PIN_D11 11 // Pin D11 mapped to pin GPIO11/FLASH_CMD of ESP32 #define PIN_D12 12 // Pin D12 mapped to pin GPIO12/HSPI_MISO/ADC15/TOUCH5/TDI of ESP32 #define PIN_D13 13 // Pin D13 mapped to pin GPIO13/HSPI_MOSI/ADC14/TOUCH4/TCK of ESP32 #define PIN_D14 14 // Pin D14 mapped to pin GPIO14/HSPI_SCK/ADC16/TOUCH6/TMS of ESP32 #define PIN_D15 15 // Pin D15 mapped to pin GPIO15/HSPI_SS/ADC13/TOUCH3/TDO of ESP32 #define PIN_D16 16 // Pin D16 mapped to pin GPIO16/TX2 of ESP32 #define PIN_D17 17 // Pin D17 mapped to pin GPIO17/RX2 of ESP32 #define PIN_D18 18 // Pin D18 mapped to pin GPIO18/VSPI_SCK of ESP32 #define PIN_D19 19 // Pin D19 mapped to pin GPIO19/VSPI_MISO of ESP32 #define PIN_D21 21 // Pin D21 mapped to pin GPIO21/SDA of ESP32 #define PIN_D22 22 // Pin D22 mapped to pin GPIO22/SCL of ESP32 #define PIN_D23 23 // Pin D23 mapped to pin GPIO23/VSPI_MOSI of ESP32 #define PIN_D24 24 // Pin D24 mapped to pin GPIO24 of ESP32 #define PIN_D25 25 // Pin D25 mapped to pin GPIO25/ADC18/DAC1 of ESP32 #define PIN_D26 26 // Pin D26 mapped to pin GPIO26/ADC19/DAC2 of ESP32 #define PIN_D27 27 // Pin D27 mapped to pin GPIO27/ADC17/TOUCH7 of ESP32 #define PIN_D32 32 // Pin D32 mapped to pin GPIO32/ADC4/TOUCH9 of ESP32 #define PIN_D33 33 // Pin D33 mapped to pin GPIO33/ADC5/TOUCH8 of ESP32 #define PIN_D34 34 // Pin D34 mapped to pin GPIO34/ADC6 of ESP32 //Only GPIO pin < 34 can be used as output. Pins >= 34 can be only inputs //See .../cores/esp32/esp32-hal-gpio.h/c //#define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg) //#define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg) //#define digitalPinToRtcPin(pin) (((pin) < 40)?esp32_gpioMux[(pin)].rtc:-1) //#define digitalPinToAnalogChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].adc:-1) //#define digitalPinToTouchChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].touch:-1) //#define digitalPinToDacChannel(pin) (((pin) == 25)?0:((pin) == 26)?1:-1) #define PIN_D35 35 // Pin D35 mapped to pin GPIO35/ADC7 of ESP32 #define PIN_D36 36 // Pin D36 mapped to pin GPIO36/ADC0/SVP of ESP32 #define PIN_D39 39 // Pin D39 mapped to pin GPIO39/ADC3/SVN of ESP32 #define PIN_RX0 3 // Pin RX0 mapped to pin GPIO3/RX0 of ESP32 #define PIN_TX0 1 // Pin TX0 mapped to pin GPIO1/TX0 of ESP32 #define PIN_SCL 22 // Pin SCL mapped to pin GPIO22/SCL of ESP32 #define PIN_SDA 21 // Pin SDA mapped to pin GPIO21/SDA of ESP32 #else //PIN_D0 can't be used for PWM/I2C #define PIN_D0 16 // Pin D0 mapped to pin GPIO16/USER/WAKE of ESP8266. This pin is also used for Onboard-Blue LED. PIN_D0 = 0 => LED ON #define PIN_D1 5 // Pin D1 mapped to pin GPIO5 of ESP8266 #define PIN_D2 4 // Pin D2 mapped to pin GPIO4 of ESP8266 #define PIN_D3 0 // Pin D3 mapped to pin GPIO0/FLASH of ESP8266 #define PIN_D4 2 // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266 #define LED_BUILTIN 2 // Pin D4 mapped to pin GPIO2/TXD1 of ESP8266, NodeMCU and WeMoS, control on-board LED #define PIN_D5 14 // Pin D5 mapped to pin GPIO14/HSCLK of ESP8266 #define PIN_D6 12 // Pin D6 mapped to pin GPIO12/HMISO of ESP8266 #define PIN_D7 13 // Pin D7 mapped to pin GPIO13/RXD2/HMOSI of ESP8266 #define PIN_D8 15 // Pin D8 mapped to pin GPIO15/TXD2/HCS of ESP8266 //Don't use pins GPIO6 to GPIO11 as already connected to flash, etc. Use them can crash the program //GPIO9(D11/SD2) and GPIO11 can be used only if flash in DIO mode ( not the default QIO mode) #define PIN_D11 9 // Pin D11/SD2 mapped to pin GPIO9/SDD2 of ESP8266 #define PIN_D12 10 // Pin D12/SD3 mapped to pin GPIO10/SDD3 of ESP8266 #define PIN_SD2 9 // Pin SD2 mapped to pin GPIO9/SDD2 of ESP8266 #define PIN_SD3 10 // Pin SD3 mapped to pin GPIO10/SDD3 of ESP8266 #define PIN_D9 3 // Pin D9 /RX mapped to pin GPIO3/RXD0 of ESP8266 #define PIN_D10 1 // Pin D10/TX mapped to pin GPIO1/TXD0 of ESP8266 #define PIN_RX 3 // Pin RX mapped to pin GPIO3/RXD0 of ESP8266 #define PIN_TX 1 // Pin RX mapped to pin GPIO1/TXD0 of ESP8266 #define LED_PIN 16 // Pin D0 mapped to pin GPIO16 of ESP8266. This pin is also used for Onboard-Blue LED. PIN_D0 = 0 => LED ON #endif //USE_ESP32 #ifdef ESP32 /* Trigger for inititating config mode is Pin D3 and also flash button on NodeMCU Flash button is convenient to use but if it is pressed it will stuff up the serial port device driver until the computer is rebooted on windows machines. */ #if ( USING_ESP32_S2 || USING_ESP32_C3 ) const int TRIGGER_PIN = PIN_D3; // Pin D3 mapped to pin GPIO03/ADC1-2/TOUCH3 of ESP32-S2 /* Alternative trigger pin. Needs to be connected to a button to use this pin. It must be a momentary connection not connected permanently to ground. Either trigger pin will work. */ const int TRIGGER_PIN2 = PIN_D4; // Pin D4 mapped to pin GPIO04/ADC1_3/TOUCH4 of ESP32-S2 #else const int TRIGGER_PIN = PIN_D0; // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32 /* Alternative trigger pin. Needs to be connected to a button to use this pin. It must be a momentary connection not connected permanently to ground. Either trigger pin will work. */ const int TRIGGER_PIN2 = PIN_D25; // Pin D25 mapped to pin GPIO25/ADC18/DAC1 of ESP32 #endif #else /* Trigger for inititating config mode is Pin D3 and also flash button on NodeMCU Flash button is convenient to use but if it is pressed it will stuff up the serial port device driver until the computer is rebooted on windows machines. */ const int TRIGGER_PIN = PIN_D3; // D3 on NodeMCU and WeMos. /* Alternative trigger pin. Needs to be connected to a button to use this pin. It must be a momentary connection not connected permanently to ground. Either trigger pin will work. */ const int TRIGGER_PIN2 = PIN_D7; // D7 on NodeMCU and WeMos. #endif // SSID and PW for Config Portal String ssid = ""ESP_"" + String(ESP_getChipId(), HEX); String password; // SSID and PW for your Router String Router_SSID; String Router_Pass; // From v1.1.1 // You only need to format the filesystem once //#define FORMAT_FILESYSTEM true #define FORMAT_FILESYSTEM false #define MIN_AP_PASSWORD_SIZE 8 #define SSID_MAX_LEN 32 //From v1.0.10, WPA2 passwords can be up to 63 characters long. #define PASS_MAX_LEN 64 typedef struct { char wifi_ssid[SSID_MAX_LEN]; char wifi_pw [PASS_MAX_LEN]; } WiFi_Credentials; typedef struct { String wifi_ssid; String wifi_pw; } WiFi_Credentials_String; #define NUM_WIFI_CREDENTIALS 2 // Assuming max 49 chars #define TZNAME_MAX_LEN 50 #define TIMEZONE_MAX_LEN 50 typedef struct { WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS]; char TZ_Name[TZNAME_MAX_LEN]; // ""America/Toronto"" char TZ[TIMEZONE_MAX_LEN]; // ""EST5EDT,M3.2.0,M11.1.0"" uint16_t checksum; } WM_Config; WM_Config WM_config; #define CONFIG_FILENAME F(""/wifi_cred.dat"") ////// // Indicates whether ESP has WiFi credentials saved from previous session, or double reset detected bool initialConfig = false; // Use false if you don't like to display Available Pages in Information Page of Config Portal // Comment out or use true to display Available Pages in Information Page of Config Portal // Must be placed before #include #define USE_AVAILABLE_PAGES true // From v1.0.10 to permit disable/enable StaticIP configuration in Config Portal from sketch. Valid only if DHCP is used. // You'll loose the feature of dynamically changing from DHCP to static IP, or vice versa // You have to explicitly specify false to disable the feature. //#define USE_STATIC_IP_CONFIG_IN_CP false // Use false to disable NTP config. Advisable when using Cellphone, Tablet to access Config Portal. // See Issue 23: On Android phone ConfigPortal is unresponsive (https://github.com/khoih-prog/ESP_WiFiManager/issues/23) #define USE_ESP_WIFIMANAGER_NTP true // Just use enough to save memory. On ESP8266, can cause blank ConfigPortal screen // if using too much memory #define USING_AFRICA false #define USING_AMERICA true #define USING_ANTARCTICA false #define USING_ASIA false #define USING_ATLANTIC false #define USING_AUSTRALIA false #define USING_EUROPE false #define USING_INDIAN false #define USING_PACIFIC false #define USING_ETC_GMT false // Use true to enable CloudFlare NTP service. System can hang if you don't have Internet access while accessing CloudFlare // See Issue #21: CloudFlare link in the default portal (https://github.com/khoih-prog/ESP_WiFiManager/issues/21) #define USE_CLOUDFLARE_NTP false // New in v1.0.11 #define USING_CORS_FEATURE true ////// // Use USE_DHCP_IP == true for dynamic DHCP IP, false to use static IP which you have to change accordingly to your network #if (defined(USE_STATIC_IP_CONFIG_IN_CP) && !USE_STATIC_IP_CONFIG_IN_CP) // Force DHCP to be true #if defined(USE_DHCP_IP) #undef USE_DHCP_IP #endif #define USE_DHCP_IP true #else // You can select DHCP or Static IP here #define USE_DHCP_IP true //#define USE_DHCP_IP false #endif #if ( USE_DHCP_IP ) // Use DHCP #warning Using DHCP IP IPAddress stationIP = IPAddress(0, 0, 0, 0); IPAddress gatewayIP = IPAddress(192, 168, 2, 1); IPAddress netMask = IPAddress(255, 255, 255, 0); #else // Use static IP #warning Using static IP #ifdef ESP32 IPAddress stationIP = IPAddress(192, 168, 2, 232); #else IPAddress stationIP = IPAddress(192, 168, 2, 186); #endif IPAddress gatewayIP = IPAddress(192, 168, 2, 1); IPAddress netMask = IPAddress(255, 255, 255, 0); #endif #define USE_CONFIGURABLE_DNS true IPAddress dns1IP = gatewayIP; IPAddress dns2IP = IPAddress(8, 8, 8, 8); #define USE_CUSTOM_AP_IP false IPAddress APStaticIP = IPAddress(192, 168, 100, 1); IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager #include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 /////////////////////////////////////////// // New in v1.4.0 /****************************************** * // Defined in ESPAsync_WiFiManager.h typedef struct { IPAddress _ap_static_ip; IPAddress _ap_static_gw; IPAddress _ap_static_sn; } WiFi_AP_IPConfig; typedef struct { IPAddress _sta_static_ip; IPAddress _sta_static_gw; IPAddress _sta_static_sn; #if USE_CONFIGURABLE_DNS IPAddress _sta_static_dns1; IPAddress _sta_static_dns2; #endif } WiFi_STA_IPConfig; ******************************************/ WiFi_AP_IPConfig WM_AP_IPconfig; WiFi_STA_IPConfig WM_STA_IPconfig; void initAPIPConfigStruct(WiFi_AP_IPConfig &in_WM_AP_IPconfig) { in_WM_AP_IPconfig._ap_static_ip = APStaticIP; in_WM_AP_IPconfig._ap_static_gw = APStaticGW; in_WM_AP_IPconfig._ap_static_sn = APStaticSN; } void initSTAIPConfigStruct(WiFi_STA_IPConfig &in_WM_STA_IPconfig) { in_WM_STA_IPconfig._sta_static_ip = stationIP; in_WM_STA_IPconfig._sta_static_gw = gatewayIP; in_WM_STA_IPconfig._sta_static_sn = netMask; #if USE_CONFIGURABLE_DNS in_WM_STA_IPconfig._sta_static_dns1 = dns1IP; in_WM_STA_IPconfig._sta_static_dns2 = dns2IP; #endif } void displayIPConfigStruct(WiFi_STA_IPConfig in_WM_STA_IPconfig) { LOGERROR3(F(""stationIP =""), in_WM_STA_IPconfig._sta_static_ip, "", gatewayIP ="", in_WM_STA_IPconfig._sta_static_gw); LOGERROR1(F(""netMask =""), in_WM_STA_IPconfig._sta_static_sn); #if USE_CONFIGURABLE_DNS LOGERROR3(F(""dns1IP =""), in_WM_STA_IPconfig._sta_static_dns1, "", dns2IP ="", in_WM_STA_IPconfig._sta_static_dns2); #endif } void configWiFi(WiFi_STA_IPConfig in_WM_STA_IPconfig) { #if USE_CONFIGURABLE_DNS // Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5 WiFi.config(in_WM_STA_IPconfig._sta_static_ip, in_WM_STA_IPconfig._sta_static_gw, in_WM_STA_IPconfig._sta_static_sn, in_WM_STA_IPconfig._sta_static_dns1, in_WM_STA_IPconfig._sta_static_dns2); #else // Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2. WiFi.config(in_WM_STA_IPconfig._sta_static_ip, in_WM_STA_IPconfig._sta_static_gw, in_WM_STA_IPconfig._sta_static_sn); #endif } /////////////////////////////////////////// uint8_t connectMultiWiFi() { #if ESP32 // For ESP32, this better be 0 to shorten the connect time. // For ESP32-S2/C3, must be > 500 #if ( USING_ESP32_S2 || USING_ESP32_C3 ) #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 500L #else // For ESP32 core v1.0.6, must be >= 500 #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 800L #endif #else // For ESP8266, this better be 2200 to enable connect the 1st time #define WIFI_MULTI_1ST_CONNECT_WAITING_MS 2200L #endif #define WIFI_MULTI_CONNECT_WAITING_MS 500L uint8_t status; //WiFi.mode(WIFI_STA); LOGERROR(F(""ConnectMultiWiFi with :"")); if ( (Router_SSID != """") && (Router_Pass != """") ) { LOGERROR3(F(""* Flash-stored Router_SSID = ""), Router_SSID, F("", Router_Pass = ""), Router_Pass ); LOGERROR3(F(""* Add SSID = ""), Router_SSID, F("", PW = ""), Router_Pass ); wifiMulti.addAP(Router_SSID.c_str(), Router_Pass.c_str()); } for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) { // Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8) if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != """") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) ) { LOGERROR3(F(""* Additional SSID = ""), WM_config.WiFi_Creds[i].wifi_ssid, F("", PW = ""), WM_config.WiFi_Creds[i].wifi_pw ); } } LOGERROR(F(""Connecting MultiWifi..."")); //WiFi.mode(WIFI_STA); #if !USE_DHCP_IP // New in v1.4.0 configWiFi(WM_STA_IPconfig); ////// #endif int i = 0; status = wifiMulti.run(); delay(WIFI_MULTI_1ST_CONNECT_WAITING_MS); while ( ( i++ < 20 ) && ( status != WL_CONNECTED ) ) { status = WiFi.status(); if ( status == WL_CONNECTED ) break; else delay(WIFI_MULTI_CONNECT_WAITING_MS); } if ( status == WL_CONNECTED ) { LOGERROR1(F(""WiFi connected after time: ""), i); LOGERROR3(F(""SSID:""), WiFi.SSID(), F("",RSSI=""), WiFi.RSSI()); LOGERROR3(F(""Channel:""), WiFi.channel(), F("",IP address:""), WiFi.localIP() ); } else { LOGERROR(F(""WiFi not connected"")); #if ESP8266 ESP.reset(); #else ESP.restart(); #endif } return status; } void toggleLED() { //toggle state digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); } #if USE_ESP_WIFIMANAGER_NTP void printLocalTime() { #if ESP8266 static time_t now; now = time(nullptr); if ( now > 1451602800 ) { Serial.print(""Local Date/Time: ""); Serial.print(ctime(&now)); } #else struct tm timeinfo; getLocalTime( &timeinfo ); // Valid only if year > 2000. // You can get from timeinfo : tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec if (timeinfo.tm_year > 100 ) { Serial.print(""Local Date/Time: ""); Serial.print( asctime( &timeinfo ) ); } #endif } #endif void heartBeatPrint() { #if USE_ESP_WIFIMANAGER_NTP printLocalTime(); #else static int num = 1; if (WiFi.status() == WL_CONNECTED) Serial.print(F(""H"")); // H means connected to WiFi else Serial.print(F(""F"")); // F means not connected to WiFi if (num == 80) { Serial.println(); num = 1; } else if (num++ % 10 == 0) { Serial.print(F("" "")); } #endif } void check_WiFi() { if ( (WiFi.status() != WL_CONNECTED) ) { Serial.println(F(""\\nWiFi lost. Call connectMultiWiFi in loop"")); connectMultiWiFi(); } } void check_status() { static ulong checkstatus_timeout = 0; static ulong LEDstatus_timeout = 0; static ulong checkwifi_timeout = 0; static ulong current_millis; #define WIFICHECK_INTERVAL 1000L #if USE_ESP_WIFIMANAGER_NTP #define HEARTBEAT_INTERVAL 60000L #else #define HEARTBEAT_INTERVAL 10000L #endif #define LED_INTERVAL 2000L current_millis = millis(); // Check WiFi every WIFICHECK_INTERVAL (1) seconds. if ((current_millis > checkwifi_timeout) || (checkwifi_timeout == 0)) { check_WiFi(); checkwifi_timeout = current_millis + WIFICHECK_INTERVAL; } if ((current_millis > LEDstatus_timeout) || (LEDstatus_timeout == 0)) { // Toggle LED at LED_INTERVAL = 2s toggleLED(); LEDstatus_timeout = current_millis + LED_INTERVAL; } // Print hearbeat every HEARTBEAT_INTERVAL (10) seconds. if ((current_millis > checkstatus_timeout) || (checkstatus_timeout == 0)) { heartBeatPrint(); checkstatus_timeout = current_millis + HEARTBEAT_INTERVAL; } } int calcChecksum(uint8_t* address, uint16_t sizeToCalc) { uint16_t checkSum = 0; for (uint16_t index = 0; index < sizeToCalc; index++) { checkSum += * ( ( (byte*) address ) + index); } return checkSum; } bool loadConfigData() { File file = FileFS.open(CONFIG_FILENAME, ""r""); LOGERROR(F(""LoadWiFiCfgFile "")); memset((void *) &WM_config, 0, sizeof(WM_config)); // New in v1.4.0 memset((void *) &WM_STA_IPconfig, 0, sizeof(WM_STA_IPconfig)); ////// if (file) { file.readBytes((char *) &WM_config, sizeof(WM_config)); // New in v1.4.0 file.readBytes((char *) &WM_STA_IPconfig, sizeof(WM_STA_IPconfig)); ////// file.close(); LOGERROR(F(""OK"")); if ( WM_config.checksum != calcChecksum( (uint8_t*) &WM_config, sizeof(WM_config) - sizeof(WM_config.checksum) ) ) { LOGERROR(F(""WM_config checksum wrong"")); return false; } // New in v1.4.0 displayIPConfigStruct(WM_STA_IPconfig); ////// return true; } else { LOGERROR(F(""failed"")); return false; } } void saveConfigData() { File file = FileFS.open(CONFIG_FILENAME, ""w""); LOGERROR(F(""SaveWiFiCfgFile "")); if (file) { WM_config.checksum = calcChecksum( (uint8_t*) &WM_config, sizeof(WM_config) - sizeof(WM_config.checksum) ); file.write((uint8_t*) &WM_config, sizeof(WM_config)); displayIPConfigStruct(WM_STA_IPconfig); // New in v1.4.0 file.write((uint8_t*) &WM_STA_IPconfig, sizeof(WM_STA_IPconfig)); ////// file.close(); LOGERROR(F(""OK"")); } else { LOGERROR(F(""failed"")); } } void setup() { //set led pin as output pinMode(LED_BUILTIN, OUTPUT); pinMode(TRIGGER_PIN, INPUT_PULLUP); pinMode(TRIGGER_PIN2, INPUT_PULLUP); Serial.begin(115200); while (!Serial); delay(200); Serial.print(F(""\\nStarting Async_ConfigOnSwitch using "")); Serial.print(FS_Name); Serial.print(F("" on "")); Serial.println(ARDUINO_BOARD); Serial.println(ESP_ASYNC_WIFIMANAGER_VERSION); #if defined(ESP_ASYNC_WIFIMANAGER_VERSION_INT) if (ESP_ASYNC_WIFIMANAGER_VERSION_INT < ESP_ASYNC_WIFIMANAGER_VERSION_MIN) { Serial.print(""Warning. Must use this example on Version later than : ""); Serial.println(ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET); } #endif Serial.setDebugOutput(false); if (FORMAT_FILESYSTEM) FileFS.format(); // Format FileFS if not yet #ifdef ESP32 if (!FileFS.begin(true)) #else if (!FileFS.begin()) #endif { #ifdef ESP8266 FileFS.format(); #endif Serial.println(F(""SPIFFS/LittleFS failed! Already tried formatting."")); if (!FileFS.begin()) { // prevents debug info from the library to hide err message. delay(100); #if USE_LITTLEFS Serial.println(F(""LittleFS failed!. Please use SPIFFS or EEPROM. Stay forever"")); #else Serial.println(F(""SPIFFS failed!. Please use LittleFS or EEPROM. Stay forever"")); #endif while (true) { delay(1); } } } unsigned long startedAt = millis(); // New in v1.4.0 initAPIPConfigStruct(WM_AP_IPconfig); initSTAIPConfigStruct(WM_STA_IPconfig); ////// digitalWrite(LED_BUILTIN, LED_ON); // turn the LED on by making the voltage LOW to tell us we are in configuration mode. //Local intialization. Once its business is done, there is no need to keep it around // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX //ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer); // Use this to personalize DHCP hostname (RFC952 conformed) AsyncWebServer webServer(HTTP_PORT); #if ( USING_ESP32_S2 || USING_ESP32_C3 ) ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, ""AsyncConfigOnSwitch""); #else DNSServer dnsServer; ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, ""AsyncConfigOnSwitch""); #endif ESPAsync_wifiManager.setDebugOutput(true); // Use only to erase stored WiFi Credentials //resetSettings(); //ESPAsync_wifiManager.resetSettings(); #if USE_CUSTOM_AP_IP //set custom ip for portal // New in v1.4.0 ESPAsync_wifiManager.setAPStaticIPConfig(WM_AP_IPconfig); ////// #endif ESPAsync_wifiManager.setMinimumSignalQuality(-1); // From v1.0.10 only // Set config portal channel, default = 1. Use 0 => random channel from 1-13 ESPAsync_wifiManager.setConfigPortalChannel(0); ////// #if !USE_DHCP_IP // Set (static IP, Gateway, Subnetmask, DNS1 and DNS2) or (IP, Gateway, Subnetmask). New in v1.0.5 // New in v1.4.0 ESPAsync_wifiManager.setSTAStaticIPConfig(WM_STA_IPconfig); ////// #endif // New from v1.1.1 #if USING_CORS_FEATURE ESPAsync_wifiManager.setCORSHeader(""Your Access-Control-Allow-Origin""); #endif // We can't use WiFi.SSID() in ESP32as it's only valid after connected. // SSID and Password stored in ESP32 wifi_ap_record_t and wifi_config_t are also cleared in reboot // Have to create a new function to store in EEPROM/SPIFFS for this purpose Router_SSID = ESPAsync_wifiManager.WiFi_SSID(); Router_Pass = ESPAsync_wifiManager.WiFi_Pass(); //Remove this line if you do not want to see WiFi password printed Serial.println(""ESP Self-Stored: SSID = "" + Router_SSID + "", Pass = "" + Router_Pass); // SSID to uppercase ssid.toUpperCase(); password = ""My"" + ssid; bool configDataLoaded = false; // From v1.1.0, Don't permit NULL password if ( (Router_SSID != """") && (Router_Pass != """") ) { LOGERROR3(F(""* Add SSID = ""), Router_SSID, F("", PW = ""), Router_Pass); wifiMulti.addAP(Router_SSID.c_str(), Router_Pass.c_str()); ESPAsync_wifiManager.setConfigPortalTimeout(120); //If no access point name has been previously entered disable timeout. Serial.println(F(""Got ESP Self-Stored Credentials. Timeout 120s for Config Portal"")); } if (loadConfigData()) { configDataLoaded = true; ESPAsync_wifiManager.setConfigPortalTimeout(120); //If no access point name has been previously entered disable timeout. Serial.println(F(""Got stored Credentials. Timeout 120s for Config Portal"")); #if USE_ESP_WIFIMANAGER_NTP if ( strlen(WM_config.TZ_Name) > 0 ) { LOGERROR3(F(""Current TZ_Name =""), WM_config.TZ_Name, F("", TZ = ""), WM_config.TZ); #if ESP8266 configTime(WM_config.TZ, ""pool.ntp.org""); #else //configTzTime(WM_config.TZ, ""pool.ntp.org"" ); configTzTime(WM_config.TZ, ""time.nist.gov"", ""0.pool.ntp.org"", ""1.pool.ntp.org""); #endif } else { Serial.println(F(""Current Timezone is not set. Enter Config Portal to set."")); } #endif } else { // Enter CP only if no stored SSID on flash and file Serial.println(F(""Open Config Portal without Timeout: No stored Credentials."")); initialConfig = true; } if (initialConfig) { Serial.print(F(""Starting configuration portal @ "")); #if USE_CUSTOM_AP_IP Serial.print(APStaticIP); #else Serial.print(F(""192.168.4.1"")); #endif Serial.print(F("", SSID = "")); Serial.print(ssid); Serial.print(F("", PWD = "")); Serial.println(password); digitalWrite(LED_BUILTIN, LED_ON); // Turn led on as we are in configuration mode. //sets timeout in seconds until configuration portal gets turned off. //If not specified device will remain in configuration mode until //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F(""Not connected to WiFi but continuing anyway."")); else { Serial.println(F(""WiFi connected...yeey :)"")); } // Stored for later usage, from v1.1.0, but clear first memset(&WM_config, 0, sizeof(WM_config)); for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) { String tempSSID = ESPAsync_wifiManager.getSSID(i); String tempPW = ESPAsync_wifiManager.getPW(i); if (strlen(tempSSID.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1) strcpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str()); else strncpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1); if (strlen(tempPW.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1) strcpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str()); else strncpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1); // Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8) if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != """") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) ) { LOGERROR3(F(""* Add SSID = ""), WM_config.WiFi_Creds[i].wifi_ssid, F("", PW = ""), WM_config.WiFi_Creds[i].wifi_pw ); wifiMulti.addAP(WM_config.WiFi_Creds[i].wifi_ssid, WM_config.WiFi_Creds[i].wifi_pw); } } #if USE_ESP_WIFIMANAGER_NTP String tempTZ = ESPAsync_wifiManager.getTimezoneName(); if (strlen(tempTZ.c_str()) < sizeof(WM_config.TZ_Name) - 1) strcpy(WM_config.TZ_Name, tempTZ.c_str()); else strncpy(WM_config.TZ_Name, tempTZ.c_str(), sizeof(WM_config.TZ_Name) - 1); const char * TZ_Result = ESPAsync_wifiManager.getTZ(WM_config.TZ_Name); if (strlen(TZ_Result) < sizeof(WM_config.TZ) - 1) strcpy(WM_config.TZ, TZ_Result); else strncpy(WM_config.TZ, TZ_Result, sizeof(WM_config.TZ_Name) - 1); if ( strlen(WM_config.TZ_Name) > 0 ) { LOGERROR3(F(""Saving current TZ_Name =""), WM_config.TZ_Name, F("", TZ = ""), WM_config.TZ); #if ESP8266 configTime(WM_config.TZ, ""pool.ntp.org""); #else //configTzTime(WM_config.TZ, ""pool.ntp.org"" ); configTzTime(WM_config.TZ, ""time.nist.gov"", ""0.pool.ntp.org"", ""1.pool.ntp.org""); #endif } else { LOGERROR(F(""Current Timezone Name is not set. Enter Config Portal to set."")); } #endif // New in v1.4.0 ESPAsync_wifiManager.getSTAStaticIPConfig(WM_STA_IPconfig); ////// saveConfigData(); } digitalWrite(LED_BUILTIN, LED_OFF); // Turn led off as we are not in configuration mode. startedAt = millis(); if (!initialConfig) { // Load stored data, the addAP ready for MultiWiFi reconnection if (!configDataLoaded) loadConfigData(); for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) { // Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8) if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != """") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) ) { LOGERROR3(F(""* Add SSID = ""), WM_config.WiFi_Creds[i].wifi_ssid, F("", PW = ""), WM_config.WiFi_Creds[i].wifi_pw ); wifiMulti.addAP(WM_config.WiFi_Creds[i].wifi_ssid, WM_config.WiFi_Creds[i].wifi_pw); } } if ( WiFi.status() != WL_CONNECTED ) { Serial.println(F(""ConnectMultiWiFi in setup"")); connectMultiWiFi(); } } Serial.print(F(""After waiting "")); Serial.print((float) (millis() - startedAt) / 1000); Serial.print(F("" secs more in setup(), connection result is "")); if (WiFi.status() == WL_CONNECTED) { Serial.print(F(""connected. Local IP: "")); Serial.println(WiFi.localIP()); } else Serial.println(ESPAsync_wifiManager.getStatus(WiFi.status())); } void loop() { // is configuration portal requested? if ((digitalRead(TRIGGER_PIN) == LOW) || (digitalRead(TRIGGER_PIN2) == LOW)) { Serial.println(F(""\\nConfiguration portal requested."")); digitalWrite(LED_BUILTIN, LED_ON); // turn the LED on by making the voltage LOW to tell us we are in configuration mode. //Local intialization. Once its business is done, there is no need to keep it around // Use this to default DHCP hostname to ESP8266-XXXXXX or ESP32-XXXXXX //ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer); // Use this to personalize DHCP hostname (RFC952 conformed) AsyncWebServer webServer(HTTP_PORT); #if ( USING_ESP32_S2 || USING_ESP32_C3 ) ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, ""ConfigOnSwitch""); #else DNSServer dnsServer; ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, ""ConfigOnSwitch""); #endif ESPAsync_wifiManager.setMinimumSignalQuality(-1); // From v1.0.10 only // Set config portal channel, default = 1. Use 0 => random channel from 1-13 ESPAsync_wifiManager.setConfigPortalChannel(0); ////// //set custom ip for portal //ESPAsync_wifiManager.setAPStaticIPConfig(IPAddress(192, 168, 100, 1), IPAddress(192, 168, 100, 1), IPAddress(255, 255, 255, 0)); #if !USE_DHCP_IP #if USE_CONFIGURABLE_DNS // Set static IP, Gateway, Subnetmask, DNS1 and DNS2. New in v1.0.5 ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask, dns1IP, dns2IP); #else // Set static IP, Gateway, Subnetmask, Use auto DNS1 and DNS2. ESPAsync_wifiManager.setSTAStaticIPConfig(stationIP, gatewayIP, netMask); #endif #endif // New from v1.1.1 #if USING_CORS_FEATURE ESPAsync_wifiManager.setCORSHeader(""Your Access-Control-Allow-Origin""); #endif //Check if there is stored WiFi router/password credentials. //If not found, device will remain in configuration mode until switched off via webserver. Serial.println(F(""Opening configuration portal. "")); Router_SSID = ESPAsync_wifiManager.WiFi_SSID(); Router_Pass = ESPAsync_wifiManager.WiFi_Pass(); //Remove this line if you do not want to see WiFi password printed Serial.println(""ESP Self-Stored: SSID = "" + Router_SSID + "", Pass = "" + Router_Pass); // From v1.1.0, Don't permit NULL password if ( (Router_SSID != """") && (Router_Pass != """") ) { LOGERROR3(F(""* Add SSID = ""), Router_SSID, F("", PW = ""), Router_Pass); wifiMulti.addAP(Router_SSID.c_str(), Router_Pass.c_str()); ESPAsync_wifiManager.setConfigPortalTimeout(120); //If no access point name has been previously entered disable timeout. Serial.println(F(""Got ESP Self-Stored Credentials. Timeout 120s for Config Portal"")); } else if (loadConfigData()) { ESPAsync_wifiManager.setConfigPortalTimeout(120); //If no access point name has been previously entered disable timeout. Serial.println(F(""Got stored Credentials. Timeout 120s for Config Portal"")); } else { // Enter CP only if no stored SSID on flash and file Serial.println(F(""Open Config Portal without Timeout: No stored Credentials."")); initialConfig = true; } //Starts an access point //and goes into a blocking loop awaiting configuration if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) { Serial.println(F(""Not connected to WiFi but continuing anyway."")); } else { //if you get here you have connected to the WiFi Serial.println(F(""connected...yeey :)"")); Serial.print(F(""Local IP: "")); Serial.println(WiFi.localIP()); } // Only clear then save data if CP entered and with new valid Credentials // No CP => stored getSSID() = """" if ( String(ESPAsync_wifiManager.getSSID(0)) != """" && String(ESPAsync_wifiManager.getSSID(1)) != """" ) { // Stored for later usage, from v1.1.0, but clear first memset(&WM_config, 0, sizeof(WM_config)); for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) { String tempSSID = ESPAsync_wifiManager.getSSID(i); String tempPW = ESPAsync_wifiManager.getPW(i); if (strlen(tempSSID.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1) strcpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str()); else strncpy(WM_config.WiFi_Creds[i].wifi_ssid, tempSSID.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_ssid) - 1); if (strlen(tempPW.c_str()) < sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1) strcpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str()); else strncpy(WM_config.WiFi_Creds[i].wifi_pw, tempPW.c_str(), sizeof(WM_config.WiFi_Creds[i].wifi_pw) - 1); // Don't permit NULL SSID and password len < MIN_AP_PASSWORD_SIZE (8) if ( (String(WM_config.WiFi_Creds[i].wifi_ssid) != """") && (strlen(WM_config.WiFi_Creds[i].wifi_pw) >= MIN_AP_PASSWORD_SIZE) ) { LOGERROR3(F(""* Add SSID = ""), WM_config.WiFi_Creds[i].wifi_ssid, F("", PW = ""), WM_config.WiFi_Creds[i].wifi_pw ); wifiMulti.addAP(WM_config.WiFi_Creds[i].wifi_ssid, WM_config.WiFi_Creds[i].wifi_pw); } } #if USE_ESP_WIFIMANAGER_NTP String tempTZ = ESPAsync_wifiManager.getTimezoneName(); if (strlen(tempTZ.c_str()) < sizeof(WM_config.TZ_Name) - 1) strcpy(WM_config.TZ_Name, tempTZ.c_str()); else strncpy(WM_config.TZ_Name, tempTZ.c_str(), sizeof(WM_config.TZ_Name) - 1); const char * TZ_Result = ESPAsync_wifiManager.getTZ(WM_config.TZ_Name); if (strlen(TZ_Result) < sizeof(WM_config.TZ) - 1) strcpy(WM_config.TZ, TZ_Result); else strncpy(WM_config.TZ, TZ_Result, sizeof(WM_config.TZ_Name) - 1); if ( strlen(WM_config.TZ_Name) > 0 ) { LOGERROR3(F(""Saving current TZ_Name =""), WM_config.TZ_Name, F("", TZ = ""), WM_config.TZ); #if ESP8266 configTime(WM_config.TZ, ""pool.ntp.org""); #else //configTzTime(WM_config.TZ, ""pool.ntp.org"" ); configTzTime(WM_config.TZ, ""time.nist.gov"", ""0.pool.ntp.org"", ""1.pool.ntp.org""); #endif } else { LOGERROR(F(""Current Timezone Name is not set. Enter Config Portal to set."")); } #endif // New in v1.4.0 ESPAsync_wifiManager.getSTAStaticIPConfig(WM_STA_IPconfig); ////// saveConfigData(); } digitalWrite(LED_BUILTIN, LED_OFF); // Turn led off as we are not in configuration mode. } // put your main code here, to run repeatedly check_status(); } ",12466,False,2083.893589675662,median