id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,536,364
|
personal1.h
|
FlagBrew_PKSM-Core/source/personal/personal1.h
|
constexpr int personal1_size = 1368;
constexpr int personal1_entrysize = 9;
| 81
|
C++
|
.h
| 2
| 39.5
| 41
| 0.759494
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,365
|
g1text.hpp
|
FlagBrew_PKSM-Core/source/utils/g1text.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G1TEXT_HPP
#define G1TEXT_HPP
#include "utils/coretypes.h"
#include <unordered_map>
namespace pksm::internal
{
constexpr char16_t tradeOTChar =
u'ඞ'; // a character not expected to appear in native names, maybe it'll surprise a joker ;P
constexpr std::array<u8, 112> G1ENVals = {0x50, 0x5D, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85,
0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3,
0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2,
0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1,
0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0,
0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xE0, 0xE1, 0xE2, 0xE3, 0xE6, 0xE7, 0xE8, 0xEF, 0xF1, 0xF2,
0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF};
constexpr std::array<char16_t, 112> G1ENChars = {u'\0', tradeOTChar, u' ', u'A', u'B', u'C',
u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R',
u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u'(', u')', u':', u';', u'[', u']', u'a',
u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p',
u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'à', u'è', u'é', u'ù', u'À',
u'Á', u'Ä', u'Ö', u'Ü', u'ä', u'ö', u'ü', u'È', u'É', u'Ì', u'Í', u'Ñ', u'Ò', u'Ó', u'Ù',
u'Ú', u'á', u'ì', u'í', u'ñ', u'ò', u'ó', u'ú', u'’', u'\uE0A7', u'\uE0A8', u'-', u'?',
u'!', u'.', u'♂', u'×', u'.', u'/', u',', u'♀', u'0', u'1', u'2', u'3', u'4', u'5', u'6',
u'7', u'8', u'9'};
constexpr std::array<u8, 169> G1JPVals = {0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x19, 0x1A, 0x1B, 0x1C, 0x26, 0x27, 0x28, 0x29, 0x2A,
0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x50, 0x5D, 0x7F, 0x80, 0x81, 0x82,
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91,
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0,
0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD,
0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC,
0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE6, 0xE7, 0xE9, 0xEA, 0xEB, 0xEF, 0xF4, 0xF5,
0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF};
constexpr std::array<char16_t, 169> G1JPChars = {u'ガ', u'ギ', u'グ', u'ゲ', u'ゴ', u'ザ',
u'ジ', u'ズ', u'ゼ', u'ゾ', u'ダ', u'ヂ', u'ヅ', u'デ', u'ド', u'バ', u'ビ', u'ブ', u'ボ',
u'が', u'ぎ', u'ぐ', u'げ', u'ご', u'ざ', u'じ', u'ず', u'ぜ', u'ぞ', u'だ', u'ぢ', u'づ',
u'で', u'ど', u'ば', u'び', u'ぶ', u'ベ', u'ぼ', u'パ', u'ピ', u'プ', u'ポ', u'ぱ', u'ぴ',
u'ぷ', u'ペ', u'ぽ', u'\0', tradeOTChar, u' ', u'ア', u'イ', u'ウ', u'エ', u'オ', u'カ',
u'キ', u'ク', u'ケ', u'コ', u'サ', u'シ', u'ス', u'セ', u'ソ', u'タ', u'チ', u'ツ', u'テ',
u'ト', u'ナ', u'ニ', u'ヌ', u'ネ', u'ノ', u'ハ', u'ヒ', u'フ', u'ホ', u'マ', u'ミ', u'ム',
u'メ', u'モ', u'ヤ', u'ユ', u'ヨ', u'ラ', u'ル', u'レ', u'ロ', u'ワ', u'ヲ', u'ン', u'ッ',
u'ャ', u'ュ', u'ョ', u'ィ', u'あ', u'い', u'う', u'え', u'お', u'か', u'き', u'く', u'け',
u'こ', u'さ', u'し', u'す', u'せ', u'そ', u'た', u'ち', u'つ', u'て', u'と', u'な', u'に',
u'ぬ', u'ね', u'の', u'は', u'ひ', u'ふ', u'へ', u'ほ', u'ま', u'み', u'む', u'め', u'も',
u'や', u'ゆ', u'よ', u'ら', u'リ', u'る', u'れ', u'ろ', u'わ', u'を', u'ん', u'っ', u'ゃ',
u'ゅ', u'ょ', u'ー', u'?', u'!', u'ァ', u'ゥ', u'ェ', u'♂', u'ォ', u'♀', u'0', u'1',
u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9'};
}
#endif
| 5,821
|
C++
|
.h
| 78
| 64.179487
| 100
| 0.543948
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,366
|
g2text.hpp
|
FlagBrew_PKSM-Core/source/utils/g2text.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G2TEXT_HPP
#define G2TEXT_HPP
#include "utils/coretypes.h"
#include <unordered_map>
#include <vector>
namespace pksm::internal
{
constexpr std::array<char16_t, 2485> G2KORChars = {u'ㄱ', u'ㄴ', u'ㄷ', u'ㄹ', u'ㅁ', u'ㅂ',
u'ㅅ', u'ㅇ', u'ㅈ', u'ㅊ', u'ㅋ', u'ㅌ', u'ㅍ', u'ㅎ', u'ㄲ', u'ㄸ', u'ㅃ', u'ㅆ', u'ㅉ',
u'ㅏ', u'ㅑ', u'ㅓ', u'ㅕ', u'ㅗ', u'ㅛ', u'ㅜ', u'ㅠ', u'ㅡ', u'ㅣ', u'ㅐ', u'ㅒ', u'ㅔ',
u'ㅖ', u'ㅘ', u'ㅙ', u'ㅚ', u'ㅝ', u'ㅞ', u'ㅟ', u'ㅢ', u'_', u'—', u'「', u'」', u'『',
u'』', u'(', u')', u'!', u'?', u'-', u'~', u'…', u',', u'.', u'0', u'1', u'2', u'3',
u'4', u'5', u'6', u'7', u'8', u'9', u'\u3000', u'가', u'각', u'간', u'갇', u'갈',
u'갉', u'갊', u'감', u'갑', u'값', u'갓', u'갔', u'강', u'갖', u'갗', u'같', u'갚', u'갛',
u'개', u'객', u'갠', u'갤', u'갬', u'갭', u'갯', u'갰', u'갱', u'갸', u'갹', u'갼', u'걀',
u'걋', u'걍', u'걔', u'걘', u'걜', u'거', u'걱', u'건', u'걷', u'걸', u'걺', u'검', u'겁',
u'것', u'겄', u'겅', u'겆', u'겉', u'겊', u'겋', u'게', u'겐', u'겔', u'겜', u'겝', u'겟',
u'겠', u'겡', u'겨', u'격', u'겪', u'견', u'겯', u'결', u'겹', u'겸', u'겻', u'겼', u'경',
u'곁', u'계', u'곈', u'곌', u'곕', u'곗', u'고', u'곡', u'곤', u'곧', u'골', u'곪', u'곬',
u'곯', u'곰', u'곱', u'곳', u'공', u'곶', u'과', u'곽', u'관', u'괄', u'괆', u'괌', u'괍',
u'괏', u'광', u'괘', u'괜', u'괠', u'괩', u'괬', u'괭', u'괴', u'괵', u'괸', u'괼', u'괻',
u'굅', u'굇', u'굉', u'교', u'굔', u'굘', u'굡', u'굣', u'구', u'국', u'군', u'굳', u'굴',
u'굵', u'굶', u'굻', u'굼', u'굽', u'굿', u'궁', u'궂', u'궈', u'궉', u'권', u'궐', u'궜',
u'궝', u'궤', u'궷', u'귀', u'귁', u'귄', u'귈', u'귐', u'귑', u'귓', u'규', u'균', u'귤',
u'그', u'극', u'근', u'귿', u'글', u'긁', u'금', u'급', u'긋', u'긍', u'긔', u'기', u'긱',
u'긴', u'긷', u'길', u'긺', u'김', u'깁', u'깃', u'깅', u'깆', u'깊', u'까', u'깍', u'깎',
u'깐', u'깔', u'깖', u'깜', u'깝', u'깟', u'깠', u'깡', u'깥', u'깨', u'깩', u'깬', u'깰',
u'깸', u'깹', u'깻', u'깼', u'깽', u'꺄', u'꺅', u'꺌', u'꺼', u'꺽', u'꺾', u'껀', u'껄',
u'껌', u'껍', u'껏', u'껐', u'껑', u'께', u'껙', u'껜', u'껨', u'껫', u'껭', u'껴', u'껸',
u'껼', u'꼇', u'꼈', u'꼍', u'꼐', u'꼬', u'꼭', u'꼰', u'꼲', u'꼴', u'꼼', u'꼽', u'꼿',
u'꽁', u'꽂', u'꽃', u'꽈', u'꽉', u'꽐', u'꽜', u'꽝', u'꽤', u'꽥', u'꽹', u'꾀', u'꾄',
u'꾈', u'꾐', u'꾑', u'꾕', u'꾜', u'꾸', u'꾹', u'꾼', u'꿀', u'꿇', u'꿈', u'꿉', u'꿋',
u'꿍', u'꿎', u'꿔', u'꿜', u'꿨', u'꿩', u'꿰', u'꿱', u'꿴', u'꿸', u'뀀', u'뀁', u'뀄',
u'뀌', u'뀐', u'뀔', u'뀜', u'뀝', u'뀨', u'끄', u'끅', u'끈', u'끊', u'끌', u'끎', u'끓',
u'끔', u'끕', u'끗', u'끙', u'끝', u'끼', u'끽', u'낀', u'낄', u'낌', u'낍', u'낏', u'낑',
u'나', u'낙', u'낚', u'난', u'낟', u'날', u'낡', u'낢', u'남', u'납', u'낫', u'났', u'낭',
u'낮', u'낯', u'낱', u'낳', u'내', u'낵', u'낸', u'낼', u'냄', u'냅', u'냇', u'냈', u'냉',
u'냐', u'냑', u'냔', u'냘', u'냠', u'냥', u'너', u'넉', u'넋', u'넌', u'널', u'넒', u'넓',
u'넘', u'넙', u'넛', u'넜', u'넝', u'넣', u'네', u'넥', u'넨', u'넬', u'넴', u'넵', u'넷',
u'넸', u'넹', u'녀', u'녁', u'년', u'녈', u'념', u'녑', u'녔', u'녕', u'녘', u'녜', u'녠',
u'노', u'녹', u'논', u'놀', u'놂', u'놈', u'놉', u'놋', u'농', u'높', u'놓', u'놔', u'놘',
u'놜', u'놨', u'뇌', u'뇐', u'뇔', u'뇜', u'뇝', u'뇟', u'뇨', u'뇩', u'뇬', u'뇰', u'뇹',
u'뇻', u'뇽', u'누', u'눅', u'눈', u'눋', u'눌', u'눔', u'눕', u'눗', u'눙', u'눠', u'눴',
u'눼', u'뉘', u'뉜', u'뉠', u'뉨', u'뉩', u'뉴', u'뉵', u'뉼', u'늄', u'늅', u'늉', u'느',
u'늑', u'는', u'늘', u'늙', u'늚', u'늠', u'늡', u'늣', u'능', u'늦', u'늪', u'늬', u'늰',
u'늴', u'니', u'닉', u'닌', u'닐', u'닒', u'님', u'닙', u'닛', u'닝', u'닢', u'다', u'닥',
u'닦', u'단', u'닫', u'달', u'닭', u'닮', u'닯', u'닳', u'담', u'답', u'닷', u'닸', u'당',
u'닺', u'닻', u'닿', u'대', u'댁', u'댄', u'댈', u'댐', u'댑', u'댓', u'댔', u'댕', u'더',
u'덕', u'덖', u'던', u'덛', u'덜', u'덞', u'덟', u'덤', u'덥', u'덧', u'덩', u'덫', u'덮',
u'데', u'덱', u'덴', u'델', u'뎀', u'뎁', u'뎃', u'뎄', u'뎅', u'뎌', u'뎐', u'뎔', u'뎠',
u'뎡', u'뎨', u'뎬', u'도', u'독', u'돈', u'돋', u'돌', u'돎', u'돔', u'돕', u'돗', u'동',
u'돛', u'돝', u'돠', u'돤', u'돨', u'돼', u'됐', u'되', u'된', u'될', u'됨', u'됩', u'됫',
u'됴', u'두', u'둑', u'둔', u'둘', u'둠', u'둡', u'둣', u'둥', u'둬', u'뒀', u'뒈', u'뒝',
u'뒤', u'뒨', u'뒬', u'뒵', u'뒷', u'뒹', u'듀', u'듄', u'듈', u'듐', u'듕', u'드', u'득',
u'든', u'듣', u'들', u'듦', u'듬', u'듭', u'듯', u'등', u'듸', u'디', u'딕', u'딘', u'딛',
u'딜', u'딤', u'딥', u'딧', u'딨', u'딩', u'딪', u'따', u'딱', u'딴', u'딸', u'땀', u'땁',
u'땃', u'땄', u'땅', u'땋', u'때', u'땍', u'땐', u'땔', u'땜', u'땝', u'땟', u'땠', u'땡',
u'떠', u'떡', u'떤', u'떨', u'떪', u'떫', u'떰', u'떱', u'떳', u'떴', u'떵', u'떻', u'떼',
u'떽', u'뗀', u'뗄', u'뗌', u'뗍', u'뗏', u'뗐', u'뗑', u'뗘', u'뗬', u'또', u'똑', u'똔',
u'똘', u'똥', u'똬', u'똴', u'뙈', u'뙤', u'뙨', u'뚜', u'뚝', u'뚠', u'뚤', u'뚫', u'뚬',
u'뚱', u'뛔', u'뛰', u'뛴', u'뛸', u'뜀', u'뜁', u'뜅', u'뜨', u'뜩', u'뜬', u'뜯', u'뜰',
u'뜸', u'뜹', u'뜻', u'띄', u'띈', u'띌', u'띔', u'띕', u'띠', u'띤', u'띨', u'띰', u'띱',
u'띳', u'띵', u'라', u'락', u'란', u'랄', u'람', u'랍', u'랏', u'랐', u'랑', u'랒', u'랖',
u'랗', u'뢔', u'래', u'랙', u'랜', u'랠', u'램', u'랩', u'랫', u'랬', u'랭', u'랴', u'략',
u'랸', u'럇', u'량', u'러', u'럭', u'런', u'럴', u'럼', u'럽', u'럿', u'렀', u'렁', u'렇',
u'레', u'렉', u'렌', u'렐', u'렘', u'렙', u'렛', u'렝', u'려', u'력', u'련', u'렬', u'렴',
u'렵', u'렷', u'렸', u'령', u'례', u'롄', u'롑', u'롓', u'로', u'록', u'론', u'롤', u'롬',
u'롭', u'롯', u'롱', u'롸', u'롼', u'뢍', u'뢨', u'뢰', u'뢴', u'뢸', u'룀', u'룁', u'룃',
u'룅', u'료', u'룐', u'룔', u'룝', u'룟', u'룡', u'루', u'룩', u'룬', u'룰', u'룸', u'룹',
u'룻', u'룽', u'뤄', u'뤘', u'뤠', u'뤼', u'뤽', u'륀', u'륄', u'륌', u'륏', u'륑', u'류',
u'륙', u'륜', u'률', u'륨', u'륩', u'륫', u'륭', u'르', u'륵', u'른', u'를', u'름', u'릅',
u'릇', u'릉', u'릊', u'릍', u'릎', u'리', u'릭', u'린', u'릴', u'림', u'립', u'릿', u'링',
u'마', u'막', u'만', u'많', u'맏', u'말', u'맑', u'맒', u'맘', u'맙', u'맛', u'망', u'맞',
u'맡', u'맣', u'매', u'맥', u'맨', u'맬', u'맴', u'맵', u'맷', u'맸', u'맹', u'맺', u'먀',
u'먁', u'먈', u'먕', u'머', u'먹', u'먼', u'멀', u'멂', u'멈', u'멉', u'멋', u'멍', u'멎',
u'멓', u'메', u'멕', u'멘', u'멜', u'멤', u'멥', u'멧', u'멨', u'멩', u'며', u'멱', u'면',
u'멸', u'몃', u'몄', u'명', u'몇', u'몌', u'모', u'목', u'몫', u'몬', u'몰', u'몲', u'몸',
u'몹', u'못', u'몽', u'뫄', u'뫈', u'뫘', u'뫙', u'뫼', u'묀', u'묄', u'묍', u'묏', u'묑',
u'묘', u'묜', u'묠', u'묩', u'묫', u'무', u'묵', u'묶', u'문', u'묻', u'물', u'묽', u'묾',
u'뭄', u'뭅', u'뭇', u'뭉', u'뭍', u'뭏', u'뭐', u'뭔', u'뭘', u'뭡', u'뭣', u'뭬', u'뮈',
u'뮌', u'뮐', u'뮤', u'뮨', u'뮬', u'뮴', u'뮷', u'므', u'믄', u'믈', u'믐', u'믓', u'미',
u'믹', u'민', u'믿', u'밀', u'밂', u'밈', u'밉', u'밋', u'밌', u'밍', u'및', u'밑', u'바',
u'박', u'밖', u'밗', u'반', u'받', u'발', u'밝', u'밞', u'밟', u'밤', u'밥', u'밧', u'방',
u'밭', u'배', u'백', u'밴', u'밸', u'뱀', u'뱁', u'뱃', u'뱄', u'뱅', u'뱉', u'뱌', u'뱍',
u'뱐', u'뱝', u'버', u'벅', u'번', u'벋', u'벌', u'벎', u'범', u'법', u'벗', u'벙', u'벚',
u'베', u'벡', u'벤', u'벧', u'벨', u'벰', u'벱', u'벳', u'벴', u'벵', u'벼', u'벽', u'변',
u'별', u'볍', u'볏', u'볐', u'병', u'볕', u'볘', u'볜', u'보', u'복', u'볶', u'본', u'볼',
u'봄', u'봅', u'봇', u'봉', u'봐', u'봔', u'봤', u'봬', u'뵀', u'뵈', u'뵉', u'뵌', u'뵐',
u'뵘', u'뵙', u'뵤', u'뵨', u'부', u'북', u'분', u'붇', u'불', u'붉', u'붊', u'붐', u'붑',
u'붓', u'붕', u'붙', u'붚', u'붜', u'붤', u'붰', u'붸', u'뷔', u'뷕', u'뷘', u'뷜', u'뷩',
u'뷰', u'뷴', u'뷸', u'븀', u'븃', u'븅', u'브', u'븍', u'븐', u'블', u'븜', u'븝', u'븟',
u'비', u'빅', u'빈', u'빌', u'빎', u'빔', u'빕', u'빗', u'빙', u'빚', u'빛', u'빠', u'빡',
u'빤', u'빨', u'빪', u'빰', u'빱', u'빳', u'빴', u'빵', u'빻', u'빼', u'빽', u'뺀', u'뺄',
u'뺌', u'뺍', u'뺏', u'뺐', u'뺑', u'뺘', u'뺙', u'뺨', u'뻐', u'뻑', u'뻔', u'뻗', u'뻘',
u'뻠', u'뻣', u'뻤', u'뻥', u'뻬', u'뼁', u'뼈', u'뼉', u'뼘', u'뼙', u'뼛', u'뼜', u'뼝',
u'뽀', u'뽁', u'뽄', u'뽈', u'뽐', u'뽑', u'뽕', u'뾔', u'뾰', u'뿅', u'뿌', u'뿍', u'뿐',
u'뿔', u'뿜', u'뿟', u'뿡', u'쀼', u'쁑', u'쁘', u'쁜', u'쁠', u'쁨', u'쁩', u'삐', u'삑',
u'삔', u'삘', u'삠', u'삡', u'삣', u'삥', u'사', u'삭', u'삯', u'산', u'삳', u'살', u'삵',
u'삶', u'삼', u'삽', u'삿', u'샀', u'상', u'샅', u'새', u'색', u'샌', u'샐', u'샘', u'샙',
u'샛', u'샜', u'생', u'샤', u'샥', u'샨', u'샬', u'샴', u'샵', u'샷', u'샹', u'섀', u'섄',
u'섈', u'섐', u'섕', u'서', u'석', u'섞', u'섟', u'선', u'섣', u'설', u'섦', u'섧', u'섬',
u'섭', u'섯', u'섰', u'성', u'섶', u'세', u'섹', u'센', u'셀', u'셈', u'셉', u'셋', u'셌',
u'셍', u'셔', u'셕', u'션', u'셜', u'셤', u'셥', u'셧', u'셨', u'셩', u'셰', u'셴', u'셸',
u'솅', u'소', u'속', u'솎', u'손', u'솔', u'솖', u'솜', u'솝', u'솟', u'송', u'솥', u'솨',
u'솩', u'솬', u'솰', u'솽', u'쇄', u'쇈', u'쇌', u'쇔', u'쇗', u'쇘', u'쇠', u'쇤', u'쇨',
u'쇰', u'쇱', u'쇳', u'쇼', u'쇽', u'숀', u'숄', u'숌', u'숍', u'숏', u'숑', u'수', u'숙',
u'순', u'숟', u'술', u'숨', u'숩', u'숫', u'숭', u'쌰', u'쎼', u'숯', u'숱', u'숲', u'숴',
u'쉈', u'쉐', u'쉑', u'쉔', u'쉘', u'쉠', u'쉥', u'쉬', u'쉭', u'쉰', u'쉴', u'쉼', u'쉽',
u'쉿', u'슁', u'슈', u'슉', u'슐', u'슘', u'슛', u'슝', u'스', u'슥', u'슨', u'슬', u'슭',
u'슴', u'습', u'슷', u'승', u'시', u'식', u'신', u'싣', u'실', u'싫', u'심', u'십', u'싯',
u'싱', u'싶', u'싸', u'싹', u'싻', u'싼', u'쌀', u'쌈', u'쌉', u'쌌', u'쌍', u'쌓', u'쌔',
u'쌕', u'쌘', u'쌜', u'쌤', u'쌥', u'쌨', u'쌩', u'썅', u'써', u'썩', u'썬', u'썰', u'썲',
u'썸', u'썹', u'썼', u'썽', u'쎄', u'쎈', u'쎌', u'쏀', u'쏘', u'쏙', u'쏜', u'쏟', u'쏠',
u'쏢', u'쏨', u'쏩', u'쏭', u'쏴', u'쏵', u'쏸', u'쐈', u'쐐', u'쐤', u'쐬', u'쐰', u'쓔',
u'쐴', u'쐼', u'쐽', u'쑈', u'쑤', u'쑥', u'쑨', u'쑬', u'쑴', u'쑵', u'쑹', u'쒀', u'쒔',
u'쒜', u'쒸', u'쒼', u'쓩', u'쓰', u'쓱', u'쓴', u'쓸', u'쓺', u'쓿', u'씀', u'씁', u'씌',
u'씐', u'씔', u'씜', u'씨', u'씩', u'씬', u'씰', u'씸', u'씹', u'씻', u'씽', u'아', u'악',
u'안', u'앉', u'않', u'알', u'앍', u'앎', u'앓', u'암', u'압', u'앗', u'았', u'앙', u'앝',
u'앞', u'애', u'액', u'앤', u'앨', u'앰', u'앱', u'앳', u'앴', u'앵', u'야', u'약', u'얀',
u'얄', u'얇', u'얌', u'얍', u'얏', u'양', u'얕', u'얗', u'얘', u'얜', u'얠', u'얩', u'어',
u'억', u'언', u'얹', u'얻', u'얼', u'얽', u'얾', u'엄', u'업', u'없', u'엇', u'었', u'엉',
u'엊', u'엌', u'엎', u'에', u'엑', u'엔', u'엘', u'엠', u'엡', u'엣', u'엥', u'여', u'역',
u'엮', u'연', u'열', u'엶', u'엷', u'염', u'엽', u'엾', u'엿', u'였', u'영', u'옅', u'옆',
u'옇', u'예', u'옌', u'옐', u'옘', u'옙', u'옛', u'옜', u'오', u'옥', u'온', u'올', u'옭',
u'옮', u'옰', u'옳', u'옴', u'옵', u'옷', u'옹', u'옻', u'와', u'왁', u'완', u'왈', u'왐',
u'왑', u'왓', u'왔', u'왕', u'왜', u'왝', u'왠', u'왬', u'왯', u'왱', u'외', u'왹', u'왼',
u'욀', u'욈', u'욉', u'욋', u'욍', u'요', u'욕', u'욘', u'욜', u'욤', u'욥', u'욧', u'용',
u'우', u'욱', u'운', u'울', u'욹', u'욺', u'움', u'웁', u'웃', u'웅', u'워', u'웍', u'원',
u'월', u'웜', u'웝', u'웠', u'웡', u'웨', u'웩', u'웬', u'웰', u'웸', u'웹', u'웽', u'위',
u'윅', u'윈', u'윌', u'윔', u'윕', u'윗', u'윙', u'유', u'육', u'윤', u'율', u'윰', u'윱',
u'윳', u'융', u'윷', u'으', u'윽', u'은', u'을', u'읆', u'음', u'읍', u'읏', u'응', u'읒',
u'읓', u'읔', u'읕', u'읖', u'읗', u'의', u'읜', u'읠', u'읨', u'읫', u'이', u'익', u'인',
u'일', u'읽', u'읾', u'잃', u'임', u'입', u'잇', u'있', u'잉', u'잊', u'잎', u'자', u'작',
u'잔', u'잖', u'잗', u'잘', u'잚', u'잠', u'잡', u'잣', u'잤', u'장', u'잦', u'재', u'잭',
u'잰', u'잴', u'잼', u'잽', u'잿', u'쟀', u'쟁', u'쟈', u'쟉', u'쟌', u'쟎', u'쟐', u'쟘',
u'쟝', u'쟤', u'쟨', u'쟬', u'저', u'적', u'전', u'절', u'젊', u'점', u'접', u'젓', u'정',
u'젖', u'제', u'젝', u'젠', u'젤', u'젬', u'젭', u'젯', u'젱', u'져', u'젼', u'졀', u'졈',
u'졉', u'졌', u'졍', u'졔', u'조', u'족', u'존', u'졸', u'졺', u'좀', u'좁', u'좃', u'종',
u'좆', u'좇', u'좋', u'좌', u'좍', u'좔', u'좝', u'좟', u'좡', u'좨', u'좼', u'좽', u'죄',
u'죈', u'죌', u'죔', u'죕', u'죗', u'죙', u'죠', u'죡', u'죤', u'죵', u'주', u'죽', u'준',
u'줄', u'줅', u'줆', u'줌', u'줍', u'줏', u'중', u'줘', u'줬', u'줴', u'쥐', u'쥑', u'쥔',
u'쥘', u'쥠', u'쥡', u'쥣', u'쥬', u'쥰', u'쥴', u'쥼', u'즈', u'즉', u'즌', u'즐', u'즘',
u'즙', u'즛', u'증', u'지', u'직', u'진', u'짇', u'질', u'짊', u'짐', u'집', u'짓', u'쬬',
u'징', u'짖', u'짙', u'짚', u'짜', u'짝', u'짠', u'짢', u'짤', u'짧', u'짬', u'짭', u'짯',
u'짰', u'짱', u'째', u'짹', u'짼', u'쨀', u'쨈', u'쨉', u'쨋', u'쨌', u'쨍', u'쨔', u'쨘',
u'쨩', u'쩌', u'쩍', u'쩐', u'쩔', u'쩜', u'쩝', u'쩟', u'쩠', u'쩡', u'쩨', u'쩽', u'쪄',
u'쪘', u'쪼', u'쪽', u'쫀', u'쫄', u'쫌', u'쫍', u'쫏', u'쫑', u'쫓', u'쫘', u'쫙', u'쫠',
u'쫬', u'쫴', u'쬈', u'쬐', u'쬔', u'쬘', u'쬠', u'쬡', u'쭁', u'쭈', u'쭉', u'쭌', u'쭐',
u'쭘', u'쭙', u'쭝', u'쭤', u'쭸', u'쭹', u'쮜', u'쮸', u'쯔', u'쯤', u'쯧', u'쯩', u'찌',
u'찍', u'찐', u'찔', u'찜', u'찝', u'찡', u'찢', u'찧', u'차', u'착', u'찬', u'찮', u'찰',
u'참', u'찹', u'찻', u'찼', u'창', u'찾', u'채', u'책', u'챈', u'챌', u'챔', u'챕', u'챗',
u'챘', u'챙', u'챠', u'챤', u'챦', u'챨', u'챰', u'챵', u'처', u'척', u'천', u'철', u'첨',
u'첩', u'첫', u'첬', u'청', u'체', u'첵', u'첸', u'첼', u'쳄', u'쳅', u'쳇', u'쳉', u'쳐',
u'쳔', u'쳤', u'쳬', u'쳰', u'촁', u'초', u'촉', u'촌', u'촐', u'촘', u'촙', u'촛', u'총',
u'촤', u'촨', u'촬', u'촹', u'최', u'쵠', u'쵤', u'쵬', u'쵭', u'쵯', u'쵱', u'쵸', u'춈',
u'추', u'축', u'춘', u'출', u'춤', u'춥', u'춧', u'충', u'춰', u'췄', u'췌', u'췐', u'취',
u'췬', u'췰', u'췸', u'췹', u'췻', u'췽', u'츄', u'츈', u'츌', u'츔', u'츙', u'츠', u'측',
u'츤', u'츨', u'츰', u'츱', u'츳', u'층', u'치', u'칙', u'친', u'칟', u'칠', u'칡', u'침',
u'칩', u'칫', u'칭', u'카', u'칵', u'칸', u'칼', u'캄', u'캅', u'캇', u'캉', u'캐', u'캑',
u'캔', u'캘', u'캠', u'캡', u'캣', u'캤', u'캥', u'캬', u'캭', u'컁', u'커', u'컥', u'컨',
u'컫', u'컬', u'컴', u'컵', u'컷', u'컸', u'컹', u'케', u'켁', u'켄', u'켈', u'켐', u'켑',
u'켓', u'켕', u'켜', u'켠', u'켤', u'켬', u'켭', u'켯', u'켰', u'켱', u'켸', u'코', u'콕',
u'콘', u'콜', u'콤', u'콥', u'콧', u'콩', u'콰', u'콱', u'콴', u'콸', u'쾀', u'쾅', u'쾌',
u'쾡', u'쾨', u'쾰', u'쿄', u'쿠', u'쿡', u'쿤', u'쿨', u'쿰', u'쿱', u'쿳', u'쿵', u'쿼',
u'퀀', u'퀄', u'퀑', u'퀘', u'퀭', u'퀴', u'퀵', u'퀸', u'퀼', u'큄', u'큅', u'큇', u'큉',
u'큐', u'큔', u'큘', u'큠', u'크', u'큭', u'큰', u'클', u'큼', u'큽', u'킁', u'키', u'킥',
u'킨', u'킬', u'킴', u'킵', u'킷', u'킹', u'타', u'탁', u'탄', u'탈', u'탉', u'탐', u'탑',
u'탓', u'탔', u'탕', u'태', u'택', u'탠', u'탤', u'탬', u'탭', u'탯', u'탰', u'탱', u'탸',
u'턍', u'터', u'턱', u'턴', u'털', u'턺', u'텀', u'텁', u'텃', u'텄', u'텅', u'테', u'텍',
u'텐', u'텔', u'템', u'텝', u'텟', u'텡', u'텨', u'텬', u'텼', u'톄', u'톈', u'토', u'톡',
u'톤', u'톨', u'톰', u'톱', u'톳', u'통', u'톺', u'톼', u'퇀', u'퇘', u'퇴', u'퇸', u'툇',
u'툉', u'툐', u'투', u'툭', u'툰', u'툴', u'툼', u'툽', u'툿', u'퉁', u'퉈', u'퉜', u'퉤',
u'튀', u'튁', u'튄', u'튈', u'튐', u'튑', u'튕', u'튜', u'튠', u'튤', u'튬', u'튱', u'트',
u'특', u'튼', u'튿', u'틀', u'틂', u'틈', u'틉', u'틋', u'틔', u'틘', u'틜', u'틤', u'틥',
u'티', u'틱', u'틴', u'틸', u'팀', u'팁', u'팃', u'팅', u'파', u'팍', u'팎', u'판', u'팔',
u'팖', u'팜', u'팝', u'팟', u'팠', u'팡', u'팥', u'패', u'팩', u'팬', u'팰', u'팸', u'팹',
u'팻', u'팼', u'팽', u'퍄', u'퍅', u'퍼', u'퍽', u'펀', u'펄', u'펌', u'펍', u'펏', u'펐',
u'펑', u'페', u'펙', u'펜', u'펠', u'펨', u'펩', u'펫', u'펭', u'펴', u'편', u'펼', u'폄',
u'폅', u'폈', u'평', u'폐', u'폘', u'폡', u'폣', u'포', u'폭', u'폰', u'폴', u'폼', u'폽',
u'폿', u'퐁', u'퐈', u'퐝', u'푀', u'푄', u'표', u'푠', u'푤', u'푭', u'푯', u'푸', u'푹',
u'푼', u'푿', u'풀', u'풂', u'품', u'풉', u'풋', u'풍', u'풔', u'풩', u'퓌', u'퓐', u'퓔',
u'퓜', u'퓟', u'퓨', u'퓬', u'퓰', u'퓸', u'퓻', u'퓽', u'프', u'픈', u'플', u'픔', u'픕',
u'픗', u'피', u'픽', u'핀', u'필', u'핌', u'핍', u'핏', u'핑', u'하', u'학', u'한', u'할',
u'핥', u'함', u'합', u'핫', u'항', u'해', u'핵', u'핸', u'핼', u'햄', u'햅', u'햇', u'했',
u'행', u'햐', u'향', u'허', u'헉', u'헌', u'헐', u'헒', u'험', u'헙', u'헛', u'헝', u'헤',
u'헥', u'헨', u'헬', u'헴', u'헵', u'헷', u'헹', u'혀', u'혁', u'현', u'혈', u'혐', u'협',
u'혓', u'혔', u'형', u'혜', u'혠', u'혤', u'혭', u'호', u'혹', u'혼', u'홀', u'홅', u'홈',
u'홉', u'홋', u'홍', u'홑', u'화', u'확', u'환', u'활', u'홧', u'황', u'홰', u'홱', u'홴',
u'횃', u'횅', u'회', u'획', u'횐', u'횔', u'횝', u'횟', u'횡', u'효', u'횬', u'횰', u'횹',
u'횻', u'후', u'훅', u'훈', u'훌', u'훑', u'훔', u'훗', u'훙', u'훠', u'훤', u'훨', u'훰',
u'훵', u'훼', u'훽', u'휀', u'휄', u'휑', u'휘', u'휙', u'휜', u'휠', u'휨', u'휩', u'휫',
u'휭', u'휴', u'휵', u'휸', u'휼', u'흄', u'흇', u'흉', u'흐', u'흑', u'흔', u'흖', u'흗',
u'흘', u'흙', u'흠', u'흡', u'흣', u'흥', u'흩', u'희', u'흰', u'흴', u'흼', u'흽', u'힁',
u'히', u'힉', u'힌', u'힐', u'힘', u'힙', u'힛', u'힝', u'ㄱ', u'ㄴ', u'ㄷ', u'ㄹ', u'ㅁ',
u'ㅂ', u'ㅅ', u'ㅇ', u'ㅈ', u'ㅊ', u'ㅋ', u'ㅌ', u'ㅍ', u'ㅎ', u'ㄲ', u'ㄸ', u'ㅃ', u'ㅆ',
u'ㅉ', u'ㅏ', u'ㅑ', u'ㅓ', u'ㅕ', u'ㅗ', u'ㅛ', u'ㅜ', u'ㅠ', u'ㅡ', u'ㅣ', u'ㅐ', u'ㅒ',
u'ㅔ', u'ㅖ', u'ㅘ', u'ㅙ', u'ㅚ', u'ㅝ', u'ㅞ', u'ㅟ', u'ㅢ', u'_', u'—', u'「', u'」',
u'『', u'』', u'(', u')', u'!', u'?', u'-', u'~', u'…', u',', u'.', u'0', u'1', u'2',
u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'\u3000'};
constexpr std::array<u16, 2485> G2KORVals = {0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006,
0x007, 0x008, 0x009, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x010, 0x011, 0x012, 0x020,
0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x02D,
0x02E, 0x02F, 0x030, 0x031, 0x032, 0x033, 0x034, 0x03E, 0x03F, 0x060, 0x061, 0x062, 0x063,
0x064, 0x065, 0x066, 0x067, 0x068, 0x069, 0x06A, 0x06B, 0x06C, 0x0F0, 0x0F1, 0x0F2, 0x0F3,
0x0F4, 0x0F5, 0x0F6, 0x0F7, 0x0F8, 0x0F9, 0x0FF, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106,
0x107, 0x108, 0x109, 0x10A, 0x10B, 0x10C, 0x10D, 0x10E, 0x10F, 0x110, 0x111, 0x112, 0x113,
0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120,
0x121, 0x122, 0x123, 0x124, 0x125, 0x126, 0x127, 0x128, 0x129, 0x12A, 0x12B, 0x12C, 0x12D,
0x12E, 0x12F, 0x130, 0x131, 0x132, 0x133, 0x134, 0x135, 0x136, 0x137, 0x138, 0x139, 0x13A,
0x13B, 0x13C, 0x13D, 0x13E, 0x13F, 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147,
0x148, 0x149, 0x14A, 0x14B, 0x14C, 0x14D, 0x14E, 0x14F, 0x160, 0x161, 0x162, 0x163, 0x164,
0x165, 0x166, 0x167, 0x168, 0x169, 0x16A, 0x16B, 0x16C, 0x16D, 0x16E, 0x171, 0x172, 0x173,
0x174, 0x175, 0x176, 0x177, 0x178, 0x179, 0x17A, 0x17B, 0x17C, 0x17D, 0x17E, 0x17F, 0x180,
0x181, 0x182, 0x183, 0x184, 0x185, 0x186, 0x187, 0x188, 0x189, 0x18A, 0x18B, 0x18C, 0x18D,
0x18E, 0x18F, 0x190, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A,
0x19B, 0x19C, 0x19D, 0x19E, 0x19F, 0x1A0, 0x1A1, 0x1A2, 0x1A3, 0x1A4, 0x1A5, 0x1A6, 0x1A7,
0x1A8, 0x1A9, 0x1AA, 0x1AB, 0x1AC, 0x1AD, 0x1AE, 0x1AF, 0x1B0, 0x1B1, 0x1B2, 0x1B3, 0x1B4,
0x1B5, 0x1B6, 0x1B7, 0x1B8, 0x1B9, 0x1BA, 0x1BB, 0x1BC, 0x1BD, 0x1BE, 0x1BF, 0x1C0, 0x1C1,
0x1C2, 0x1C3, 0x1C4, 0x1C5, 0x1C6, 0x1C7, 0x1C8, 0x1C9, 0x1CA, 0x1CB, 0x1CC, 0x1CD, 0x1CE,
0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD,
0x1DE, 0x1DF, 0x1E0, 0x1E1, 0x1E2, 0x1E3, 0x1E4, 0x1E5, 0x1E6, 0x1E7, 0x1E8, 0x1E9, 0x1EA,
0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7,
0x1F8, 0x1F9, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE, 0x1FF, 0x200, 0x201, 0x202, 0x203, 0x204,
0x205, 0x206, 0x207, 0x208, 0x209, 0x20A, 0x20B, 0x20C, 0x20D, 0x20E, 0x20F, 0x210, 0x211,
0x212, 0x213, 0x214, 0x215, 0x216, 0x217, 0x218, 0x219, 0x21A, 0x21B, 0x21C, 0x21D, 0x21E,
0x21F, 0x220, 0x221, 0x222, 0x223, 0x224, 0x225, 0x226, 0x227, 0x228, 0x229, 0x22A, 0x22B,
0x22C, 0x22D, 0x22E, 0x231, 0x232, 0x233, 0x234, 0x235, 0x236, 0x237, 0x238, 0x239, 0x23A,
0x23B, 0x23C, 0x23D, 0x23E, 0x23F, 0x240, 0x241, 0x242, 0x243, 0x244, 0x245, 0x246, 0x247,
0x248, 0x249, 0x24A, 0x24B, 0x24C, 0x24D, 0x24E, 0x24F, 0x260, 0x261, 0x262, 0x263, 0x264,
0x265, 0x266, 0x267, 0x268, 0x269, 0x26A, 0x26B, 0x26C, 0x26D, 0x26E, 0x26F, 0x270, 0x271,
0x272, 0x273, 0x274, 0x275, 0x276, 0x277, 0x278, 0x279, 0x27A, 0x27B, 0x27C, 0x27D, 0x27E,
0x27F, 0x280, 0x281, 0x282, 0x283, 0x284, 0x285, 0x286, 0x287, 0x288, 0x289, 0x28A, 0x28B,
0x28C, 0x28D, 0x28E, 0x28F, 0x290, 0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0x297, 0x298,
0x299, 0x29A, 0x29B, 0x29C, 0x29D, 0x29E, 0x2A1, 0x2A2, 0x2A3, 0x2A4, 0x2A5, 0x2A6, 0x2A7,
0x2A8, 0x2A9, 0x2AA, 0x2AB, 0x2AC, 0x2AD, 0x2AE, 0x2AF, 0x2B0, 0x2B1, 0x2B2, 0x2B3, 0x2B4,
0x2B5, 0x2B6, 0x2B7, 0x2B8, 0x2B9, 0x2BA, 0x2BB, 0x2BC, 0x2BD, 0x2BE, 0x2BF, 0x2C0, 0x2C1,
0x2C2, 0x2C3, 0x2C4, 0x2C5, 0x2C6, 0x2C7, 0x2C8, 0x2C9, 0x2CA, 0x2CB, 0x2CC, 0x2CD, 0x2CE,
0x2CF, 0x2D0, 0x2D1, 0x2D2, 0x2D3, 0x2D4, 0x2D5, 0x2D6, 0x2D7, 0x2D8, 0x2D9, 0x2DA, 0x2DB,
0x2DC, 0x2DD, 0x2DE, 0x2DF, 0x2E0, 0x2E1, 0x2E2, 0x2E3, 0x2E4, 0x2E5, 0x2E6, 0x2E7, 0x2E8,
0x2E9, 0x2EA, 0x2EB, 0x2EC, 0x2ED, 0x2EE, 0x2EF, 0x2F0, 0x2F1, 0x2F2, 0x2F3, 0x2F5, 0x2F6,
0x2F7, 0x2F8, 0x2F9, 0x2FA, 0x2FB, 0x2FC, 0x2FD, 0x2FE, 0x301, 0x302, 0x303, 0x304, 0x305,
0x306, 0x307, 0x308, 0x309, 0x30A, 0x30B, 0x30C, 0x30D, 0x30E, 0x30F, 0x310, 0x311, 0x312,
0x313, 0x314, 0x315, 0x316, 0x317, 0x318, 0x319, 0x31A, 0x31C, 0x31D, 0x31E, 0x31F, 0x320,
0x321, 0x322, 0x323, 0x324, 0x325, 0x326, 0x327, 0x328, 0x329, 0x32A, 0x32B, 0x32C, 0x32D,
0x32E, 0x32F, 0x330, 0x331, 0x332, 0x333, 0x334, 0x335, 0x336, 0x337, 0x338, 0x339, 0x33A,
0x33B, 0x33C, 0x33D, 0x33E, 0x33F, 0x340, 0x341, 0x342, 0x343, 0x344, 0x345, 0x346, 0x347,
0x348, 0x349, 0x34A, 0x34B, 0x34C, 0x34D, 0x34E, 0x34F, 0x360, 0x361, 0x362, 0x363, 0x364,
0x365, 0x366, 0x367, 0x368, 0x369, 0x36A, 0x36B, 0x36C, 0x36D, 0x36E, 0x371, 0x372, 0x373,
0x374, 0x375, 0x376, 0x377, 0x378, 0x379, 0x37A, 0x37B, 0x37C, 0x37D, 0x37E, 0x37F, 0x380,
0x381, 0x382, 0x383, 0x384, 0x385, 0x386, 0x387, 0x388, 0x389, 0x38A, 0x38B, 0x38C, 0x38D,
0x38E, 0x38F, 0x390, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A,
0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A2, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7,
0x3A8, 0x3A9, 0x3AA, 0x3AB, 0x3AC, 0x3AD, 0x3AE, 0x3AF, 0x3B0, 0x3B1, 0x3B2, 0x3B3, 0x3B4,
0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1,
0x3C2, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x3CB, 0x3CC, 0x3CD, 0x3CE,
0x3D0, 0x3D1, 0x3D2, 0x3D3, 0x3D4, 0x3D5, 0x3D6, 0x3D7, 0x3D8, 0x3D9, 0x3DA, 0x3DB, 0x3DC,
0x3DD, 0x3DE, 0x3DF, 0x3E0, 0x3E1, 0x3E2, 0x3E3, 0x3E4, 0x3E5, 0x3E6, 0x3E7, 0x3E8, 0x3E9,
0x3EA, 0x3EB, 0x3EC, 0x3ED, 0x3EE, 0x3EF, 0x3F0, 0x3F1, 0x3F2, 0x3F3, 0x3F4, 0x3F5, 0x3F6,
0x3F7, 0x3F8, 0x3F9, 0x3FA, 0x3FB, 0x3FC, 0x3FD, 0x3FE, 0x3FF, 0x400, 0x401, 0x402, 0x403,
0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40D, 0x40E, 0x40F, 0x410,
0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D,
0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A,
0x42B, 0x42C, 0x42D, 0x42E, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439,
0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446,
0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x460, 0x461, 0x462, 0x463,
0x464, 0x465, 0x466, 0x467, 0x468, 0x469, 0x46A, 0x46B, 0x46C, 0x46D, 0x46E, 0x46F, 0x470,
0x471, 0x472, 0x473, 0x474, 0x475, 0x476, 0x477, 0x478, 0x479, 0x47A, 0x47B, 0x47C, 0x47D,
0x47E, 0x47F, 0x480, 0x481, 0x482, 0x483, 0x484, 0x485, 0x486, 0x487, 0x488, 0x489, 0x48A,
0x48B, 0x48C, 0x48D, 0x48E, 0x48F, 0x490, 0x491, 0x492, 0x493, 0x494, 0x495, 0x496, 0x497,
0x498, 0x499, 0x49A, 0x49B, 0x49C, 0x49D, 0x49E, 0x4A1, 0x4A2, 0x4A3, 0x4A4, 0x4A5, 0x4A6,
0x4A7, 0x4A8, 0x4A9, 0x4AA, 0x4AB, 0x4AC, 0x4AD, 0x4AE, 0x4AF, 0x4B0, 0x4B1, 0x4B2, 0x4B3,
0x4B4, 0x4B5, 0x4B6, 0x4B7, 0x4B8, 0x4B9, 0x4BA, 0x4BB, 0x4BC, 0x4BD, 0x4BE, 0x4BF, 0x4C0,
0x4C1, 0x4C2, 0x4C3, 0x4C4, 0x4C5, 0x4C6, 0x4C7, 0x4C8, 0x4C9, 0x4CA, 0x4CB, 0x4CC, 0x4CD,
0x4CE, 0x4CF, 0x4D0, 0x4D1, 0x4D2, 0x4D3, 0x4D4, 0x4D5, 0x4D6, 0x4D7, 0x4D8, 0x4D9, 0x4DA,
0x4DB, 0x4DC, 0x4DD, 0x4DE, 0x4DF, 0x4E0, 0x4E1, 0x4E2, 0x4E3, 0x4E4, 0x4E5, 0x4E6, 0x4E7,
0x4E8, 0x4E9, 0x4EA, 0x4EB, 0x4EC, 0x4ED, 0x4EE, 0x4EF, 0x4F0, 0x4F1, 0x4F2, 0x4F3, 0x4F4,
0x4F5, 0x4F6, 0x4F7, 0x4F8, 0x4F9, 0x4FA, 0x4FB, 0x4FC, 0x4FD, 0x4FE, 0x501, 0x502, 0x503,
0x504, 0x505, 0x506, 0x507, 0x508, 0x509, 0x50A, 0x50B, 0x50C, 0x50D, 0x50E, 0x50F, 0x510,
0x511, 0x512, 0x513, 0x514, 0x515, 0x516, 0x517, 0x518, 0x519, 0x51A, 0x51B, 0x51C, 0x51D,
0x51E, 0x51F, 0x520, 0x521, 0x522, 0x523, 0x524, 0x525, 0x526, 0x527, 0x528, 0x529, 0x52A,
0x52B, 0x52C, 0x52D, 0x52E, 0x52F, 0x530, 0x531, 0x532, 0x533, 0x534, 0x535, 0x536, 0x537,
0x538, 0x539, 0x53A, 0x53B, 0x53C, 0x53D, 0x53E, 0x53F, 0x540, 0x541, 0x542, 0x543, 0x544,
0x545, 0x546, 0x547, 0x548, 0x549, 0x54A, 0x54B, 0x54C, 0x54D, 0x54E, 0x54F, 0x560, 0x561,
0x562, 0x563, 0x564, 0x565, 0x566, 0x567, 0x568, 0x569, 0x56A, 0x56B, 0x56C, 0x56D, 0x56E,
0x571, 0x572, 0x573, 0x574, 0x575, 0x576, 0x577, 0x578, 0x579, 0x57A, 0x57B, 0x57C, 0x57D,
0x57E, 0x57F, 0x580, 0x581, 0x582, 0x583, 0x584, 0x585, 0x586, 0x587, 0x588, 0x589, 0x58A,
0x58B, 0x58C, 0x58D, 0x58E, 0x58F, 0x590, 0x591, 0x592, 0x593, 0x594, 0x595, 0x596, 0x597,
0x598, 0x599, 0x59A, 0x59B, 0x59C, 0x59D, 0x59E, 0x59F, 0x5A0, 0x5A1, 0x5A2, 0x5A3, 0x5A4,
0x5A5, 0x5A6, 0x5A7, 0x5A8, 0x5A9, 0x5AA, 0x5AB, 0x5AC, 0x5AD, 0x5AE, 0x5AF, 0x5B0, 0x5B1,
0x5B2, 0x5B3, 0x5B4, 0x5B5, 0x5B6, 0x5B7, 0x5B8, 0x5B9, 0x5BA, 0x5BB, 0x5BC, 0x5BD, 0x5BE,
0x5BF, 0x5C0, 0x5C1, 0x5C2, 0x5C3, 0x5C4, 0x5C5, 0x5C6, 0x5C7, 0x5C8, 0x5C9, 0x5CA, 0x5CB,
0x5CC, 0x5CD, 0x5CE, 0x5D1, 0x5D2, 0x5D3, 0x5D4, 0x5D5, 0x5D6, 0x5D7, 0x5D8, 0x5D9, 0x5DA,
0x5DB, 0x5DC, 0x5DD, 0x5DE, 0x5DF, 0x5E0, 0x5E1, 0x5E2, 0x5E3, 0x5E4, 0x5E5, 0x5E6, 0x5E7,
0x5E8, 0x5E9, 0x5EA, 0x5EB, 0x5EC, 0x5ED, 0x5EE, 0x5EF, 0x5F0, 0x5F1, 0x5F2, 0x5F3, 0x5F4,
0x5F5, 0x5F6, 0x5F7, 0x5F8, 0x5F9, 0x5FA, 0x5FB, 0x5FC, 0x5FD, 0x5FE, 0x5FF, 0x600, 0x601,
0x602, 0x603, 0x604, 0x605, 0x606, 0x607, 0x608, 0x609, 0x60A, 0x60B, 0x60C, 0x60D, 0x60E,
0x60F, 0x610, 0x611, 0x612, 0x613, 0x614, 0x615, 0x616, 0x617, 0x618, 0x619, 0x61A, 0x61B,
0x61C, 0x61D, 0x61E, 0x61F, 0x620, 0x621, 0x622, 0x623, 0x624, 0x625, 0x626, 0x627, 0x628,
0x629, 0x62A, 0x62B, 0x62C, 0x62D, 0x62E, 0x62F, 0x630, 0x631, 0x632, 0x633, 0x634, 0x635,
0x636, 0x637, 0x638, 0x639, 0x63A, 0x63B, 0x63C, 0x63D, 0x63E, 0x63F, 0x640, 0x641, 0x642,
0x643, 0x644, 0x645, 0x646, 0x647, 0x648, 0x649, 0x64A, 0x64B, 0x64C, 0x64D, 0x64E, 0x64F,
0x660, 0x661, 0x662, 0x663, 0x664, 0x665, 0x666, 0x667, 0x668, 0x669, 0x66A, 0x66B, 0x66C,
0x66D, 0x66E, 0x66F, 0x670, 0x671, 0x672, 0x673, 0x674, 0x675, 0x676, 0x677, 0x678, 0x679,
0x67A, 0x67B, 0x67C, 0x67D, 0x67E, 0x67F, 0x680, 0x681, 0x682, 0x683, 0x684, 0x685, 0x686,
0x687, 0x688, 0x689, 0x68A, 0x68B, 0x68C, 0x68D, 0x68E, 0x68F, 0x690, 0x691, 0x692, 0x693,
0x694, 0x695, 0x696, 0x697, 0x698, 0x699, 0x69A, 0x69B, 0x69C, 0x69D, 0x69E, 0x6A0, 0x6A1,
0x6A2, 0x6A3, 0x6A4, 0x6A5, 0x6A6, 0x6A7, 0x6A8, 0x6A9, 0x6AA, 0x6AB, 0x6AC, 0x6AD, 0x6AE,
0x6AF, 0x6B0, 0x6B1, 0x6B2, 0x6B3, 0x6B4, 0x6B5, 0x6B6, 0x6B7, 0x6B8, 0x6B9, 0x6BA, 0x6BB,
0x6BC, 0x6BD, 0x6BE, 0x6BF, 0x6C0, 0x6C1, 0x6C2, 0x6C3, 0x6C4, 0x6C5, 0x6C6, 0x6C7, 0x6C8,
0x6C9, 0x6CA, 0x6CB, 0x6CC, 0x6CD, 0x6CE, 0x6CF, 0x6D0, 0x6D1, 0x6D2, 0x6D3, 0x6D4, 0x6D5,
0x6D6, 0x6D7, 0x6D8, 0x6D9, 0x6DA, 0x6DB, 0x6DC, 0x6DD, 0x6DE, 0x6DF, 0x6E0, 0x6E1, 0x6E2,
0x6E3, 0x6E4, 0x6E5, 0x6E6, 0x6E7, 0x6E8, 0x6E9, 0x6EA, 0x6EB, 0x6EC, 0x6ED, 0x6EE, 0x6EF,
0x6F0, 0x6F1, 0x6F2, 0x6F3, 0x6F4, 0x6F5, 0x6F6, 0x6F7, 0x6F8, 0x6F9, 0x6FA, 0x6FB, 0x6FC,
0x6FD, 0x6FE, 0x701, 0x702, 0x703, 0x704, 0x705, 0x706, 0x707, 0x708, 0x709, 0x70A, 0x70B,
0x70C, 0x70D, 0x70E, 0x70F, 0x710, 0x711, 0x712, 0x713, 0x714, 0x715, 0x716, 0x717, 0x718,
0x719, 0x71A, 0x71B, 0x71C, 0x71D, 0x71E, 0x71F, 0x720, 0x721, 0x722, 0x723, 0x724, 0x725,
0x726, 0x727, 0x728, 0x729, 0x72A, 0x72B, 0x72C, 0x72D, 0x72E, 0x72F, 0x730, 0x731, 0x732,
0x733, 0x734, 0x735, 0x736, 0x737, 0x738, 0x739, 0x73A, 0x73B, 0x73C, 0x73D, 0x73E, 0x73F,
0x740, 0x741, 0x742, 0x743, 0x744, 0x745, 0x746, 0x747, 0x748, 0x749, 0x74A, 0x74B, 0x74C,
0x74D, 0x74E, 0x74F, 0x760, 0x761, 0x762, 0x763, 0x764, 0x765, 0x766, 0x767, 0x768, 0x769,
0x76A, 0x76B, 0x76C, 0x76D, 0x76E, 0x771, 0x772, 0x773, 0x774, 0x775, 0x776, 0x777, 0x778,
0x779, 0x77A, 0x77B, 0x77C, 0x77D, 0x77E, 0x77F, 0x780, 0x781, 0x782, 0x783, 0x784, 0x785,
0x786, 0x787, 0x788, 0x789, 0x78A, 0x78B, 0x78C, 0x78D, 0x78E, 0x78F, 0x790, 0x791, 0x792,
0x793, 0x794, 0x795, 0x796, 0x797, 0x798, 0x799, 0x79A, 0x79B, 0x79C, 0x79D, 0x79E, 0x79F,
0x7A0, 0x7A1, 0x7A2, 0x7A3, 0x7A4, 0x7A5, 0x7A6, 0x7A7, 0x7A8, 0x7A9, 0x7AA, 0x7AB, 0x7AC,
0x7AD, 0x7AE, 0x7AF, 0x7B0, 0x7B1, 0x7B2, 0x7B3, 0x7B4, 0x7B5, 0x7B6, 0x7B7, 0x7B8, 0x7B9,
0x7BA, 0x7BB, 0x7BC, 0x7BD, 0x7BE, 0x7BF, 0x7C0, 0x7C1, 0x7C2, 0x7C3, 0x7C4, 0x7C5, 0x7C6,
0x7C7, 0x7C8, 0x7C9, 0x7CA, 0x7CB, 0x7CC, 0x7CD, 0x7CE, 0x7D1, 0x7D2, 0x7D3, 0x7D4, 0x7D5,
0x7D6, 0x7D7, 0x7D8, 0x7D9, 0x7DA, 0x7DB, 0x7DC, 0x7DD, 0x7DE, 0x7DF, 0x7E0, 0x7E1, 0x7E2,
0x7E3, 0x7E4, 0x7E5, 0x7E6, 0x7E7, 0x7E8, 0x7E9, 0x7EA, 0x7EB, 0x7EC, 0x7ED, 0x7EE, 0x7EF,
0x7F0, 0x7F1, 0x7F2, 0x7F3, 0x7F4, 0x7F5, 0x7F6, 0x7F7, 0x7F8, 0x7F9, 0x7FA, 0x7FB, 0x7FC,
0x7FD, 0x7FE, 0x7FF, 0x800, 0x801, 0x802, 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809,
0x80A, 0x80B, 0x80C, 0x80D, 0x80E, 0x80F, 0x810, 0x811, 0x812, 0x813, 0x814, 0x815, 0x816,
0x817, 0x818, 0x819, 0x81A, 0x81B, 0x81C, 0x81D, 0x81E, 0x81F, 0x820, 0x821, 0x822, 0x823,
0x824, 0x825, 0x826, 0x827, 0x828, 0x829, 0x82A, 0x82B, 0x82C, 0x82D, 0x82E, 0x830, 0x831,
0x832, 0x833, 0x834, 0x835, 0x836, 0x837, 0x838, 0x839, 0x83A, 0x83B, 0x83C, 0x83D, 0x83E,
0x83F, 0x840, 0x841, 0x842, 0x843, 0x844, 0x845, 0x846, 0x847, 0x848, 0x849, 0x84A, 0x84B,
0x84C, 0x84D, 0x84E, 0x84F, 0x860, 0x861, 0x862, 0x863, 0x864, 0x865, 0x866, 0x867, 0x868,
0x869, 0x86A, 0x86B, 0x86C, 0x86D, 0x86E, 0x86F, 0x870, 0x871, 0x872, 0x873, 0x874, 0x875,
0x876, 0x877, 0x878, 0x879, 0x87A, 0x87B, 0x87C, 0x87D, 0x87E, 0x87F, 0x880, 0x881, 0x882,
0x883, 0x884, 0x885, 0x886, 0x887, 0x888, 0x889, 0x88A, 0x88B, 0x88C, 0x88D, 0x88E, 0x88F,
0x890, 0x891, 0x892, 0x893, 0x894, 0x895, 0x896, 0x897, 0x898, 0x899, 0x89A, 0x89B, 0x89C,
0x89D, 0x89E, 0x8A1, 0x8A2, 0x8A3, 0x8A4, 0x8A5, 0x8A6, 0x8A7, 0x8A8, 0x8A9, 0x8AA, 0x8AB,
0x8AC, 0x8AD, 0x8AE, 0x8AF, 0x8B0, 0x8B1, 0x8B2, 0x8B3, 0x8B4, 0x8B5, 0x8B6, 0x8B7, 0x8B8,
0x8B9, 0x8BA, 0x8BB, 0x8BC, 0x8BD, 0x8BE, 0x8BF, 0x8C0, 0x8C1, 0x8C2, 0x8C3, 0x8C4, 0x8C5,
0x8C6, 0x8C7, 0x8C8, 0x8C9, 0x8CA, 0x8CB, 0x8CC, 0x8CD, 0x8CE, 0x8CF, 0x8D0, 0x8D1, 0x8D2,
0x8D3, 0x8D4, 0x8D5, 0x8D6, 0x8D7, 0x8D8, 0x8D9, 0x8DA, 0x8DB, 0x8DC, 0x8DD, 0x8DE, 0x8DF,
0x8E0, 0x8E1, 0x8E2, 0x8E3, 0x8E4, 0x8E5, 0x8E6, 0x8E7, 0x8E8, 0x8E9, 0x8EA, 0x8EB, 0x8EC,
0x8ED, 0x8EE, 0x8EF, 0x8F0, 0x8F1, 0x8F2, 0x8F3, 0x8F4, 0x8F5, 0x8F6, 0x8F7, 0x8F8, 0x8F9,
0x8FA, 0x8FB, 0x8FC, 0x8FD, 0x8FE, 0x901, 0x902, 0x903, 0x904, 0x905, 0x906, 0x907, 0x908,
0x909, 0x90A, 0x90B, 0x90C, 0x90D, 0x90E, 0x90F, 0x910, 0x911, 0x912, 0x913, 0x914, 0x915,
0x916, 0x917, 0x918, 0x919, 0x91A, 0x91B, 0x91C, 0x91D, 0x91E, 0x91F, 0x920, 0x921, 0x922,
0x923, 0x924, 0x925, 0x926, 0x927, 0x928, 0x929, 0x92A, 0x92B, 0x92C, 0x92D, 0x92E, 0x92F,
0x930, 0x931, 0x932, 0x933, 0x934, 0x935, 0x936, 0x937, 0x938, 0x939, 0x93A, 0x93B, 0x93C,
0x93D, 0x93E, 0x93F, 0x940, 0x941, 0x942, 0x943, 0x944, 0x945, 0x946, 0x947, 0x948, 0x949,
0x94A, 0x94B, 0x94C, 0x94D, 0x94E, 0x94F, 0x960, 0x961, 0x962, 0x963, 0x964, 0x965, 0x966,
0x967, 0x968, 0x969, 0x96A, 0x96B, 0x96C, 0x96D, 0x96E, 0x971, 0x972, 0x973, 0x974, 0x975,
0x976, 0x977, 0x978, 0x979, 0x97A, 0x97B, 0x97C, 0x97D, 0x97E, 0x97F, 0x980, 0x981, 0x982,
0x983, 0x984, 0x985, 0x986, 0x987, 0x988, 0x989, 0x98A, 0x98B, 0x98C, 0x98D, 0x98E, 0x98F,
0x990, 0x991, 0x992, 0x993, 0x994, 0x995, 0x996, 0x997, 0x998, 0x999, 0x99A, 0x99B, 0x99C,
0x99D, 0x99E, 0x99F, 0x9A0, 0x9A1, 0x9A2, 0x9A3, 0x9A4, 0x9A5, 0x9A6, 0x9A7, 0x9A8, 0x9A9,
0x9AA, 0x9AB, 0x9AC, 0x9AD, 0x9AE, 0x9AF, 0x9B0, 0x9B1, 0x9B2, 0x9B3, 0x9B4, 0x9B5, 0x9B6,
0x9B7, 0x9B8, 0x9B9, 0x9BA, 0x9BB, 0x9BC, 0x9BD, 0x9BE, 0x9BF, 0x9C0, 0x9C1, 0x9C2, 0x9C3,
0x9C4, 0x9C5, 0x9C6, 0x9C7, 0x9C8, 0x9C9, 0x9CA, 0x9CB, 0x9CC, 0x9CD, 0x9CE, 0x9D1, 0x9D2,
0x9D3, 0x9D4, 0x9D5, 0x9D6, 0x9D7, 0x9D8, 0x9D9, 0x9DA, 0x9DB, 0x9DC, 0x9DD, 0x9DE, 0x9DF,
0x9E0, 0x9E1, 0x9E2, 0x9E3, 0x9E4, 0x9E5, 0x9E6, 0x9E7, 0x9E8, 0x9E9, 0x9EA, 0x9EB, 0x9EC,
0x9ED, 0x9EE, 0x9EF, 0x9F0, 0x9F1, 0x9F2, 0x9F3, 0x9F4, 0x9F5, 0x9F6, 0x9F7, 0x9F8, 0x9F9,
0x9FA, 0x9FB, 0x9FC, 0x9FD, 0x9FE, 0x9FF, 0xA00, 0xA01, 0xA02, 0xA03, 0xA04, 0xA05, 0xA06,
0xA07, 0xA08, 0xA09, 0xA0A, 0xA0B, 0xA0C, 0xA0D, 0xA0E, 0xA0F, 0xA10, 0xA11, 0xA12, 0xA13,
0xA14, 0xA15, 0xA16, 0xA17, 0xA18, 0xA19, 0xA1A, 0xA1B, 0xA1C, 0xA1D, 0xA1E, 0xA1F, 0xA20,
0xA21, 0xA22, 0xA23, 0xA24, 0xA25, 0xA26, 0xA27, 0xA28, 0xA29, 0xA2A, 0xA2B, 0xA2C, 0xA2D,
0xA2E, 0xA31, 0xA32, 0xA33, 0xA34, 0xA35, 0xA36, 0xA37, 0xA38, 0xA39, 0xA3A, 0xA3B, 0xA3C,
0xA3D, 0xA3E, 0xA3F, 0xA40, 0xA41, 0xA42, 0xA43, 0xA44, 0xA45, 0xA46, 0xA47, 0xA48, 0xA49,
0xA4A, 0xA4B, 0xA4C, 0xA4D, 0xA4E, 0xA4F, 0xA60, 0xA61, 0xA62, 0xA63, 0xA64, 0xA65, 0xA66,
0xA67, 0xA68, 0xA69, 0xA6A, 0xA6B, 0xA6C, 0xA6D, 0xA6E, 0xA6F, 0xA70, 0xA71, 0xA72, 0xA73,
0xA74, 0xA75, 0xA76, 0xA77, 0xA78, 0xA79, 0xA7A, 0xA7B, 0xA7C, 0xA7D, 0xA7E, 0xA7F, 0xA80,
0xA81, 0xA82, 0xA83, 0xA84, 0xA85, 0xA86, 0xA87, 0xA88, 0xA89, 0xA8A, 0xA8B, 0xA8C, 0xA8D,
0xA8E, 0xA8F, 0xA90, 0xA91, 0xA92, 0xA93, 0xA94, 0xA95, 0xA96, 0xA97, 0xA98, 0xA99, 0xA9A,
0xA9B, 0xA9C, 0xA9D, 0xA9E, 0xAA1, 0xAA2, 0xAA3, 0xAA4, 0xAA5, 0xAA6, 0xAA7, 0xAA8, 0xAA9,
0xAAA, 0xAAB, 0xAAC, 0xAAD, 0xAAE, 0xAAF, 0xAB0, 0xAB1, 0xAB2, 0xAB3, 0xAB4, 0xAB5, 0xAB6,
0xAB7, 0xAB8, 0xAB9, 0xABA, 0xABB, 0xABC, 0xABD, 0xABE, 0xABF, 0xAC0, 0xAC1, 0xAC2, 0xAC3,
0xAC4, 0xAC5, 0xAC6, 0xAC7, 0xAC8, 0xAC9, 0xACA, 0xACB, 0xACC, 0xACD, 0xACE, 0xACF, 0xAD0,
0xAD1, 0xAD2, 0xAD3, 0xAD4, 0xAD5, 0xAD6, 0xAD7, 0xAD8, 0xAD9, 0xADA, 0xADB, 0xADC, 0xADD,
0xADE, 0xADF, 0xAE0, 0xAE1, 0xAE2, 0xAE3, 0xAE4, 0xAE5, 0xAE6, 0xAE7, 0xAE8, 0xAE9, 0xAEA,
0xAEB, 0xAEC, 0xAED, 0xAEE, 0xAEF, 0xAF0, 0xAF1, 0xAF2, 0xAF3, 0xAF4, 0xAF5, 0xAF6, 0xAF7,
0xAF8, 0xAF9, 0xAFA, 0xAFB, 0xAFC, 0xAFD, 0xAFE, 0xB00, 0xB01, 0xB02, 0xB03, 0xB04, 0xB05,
0xB06, 0xB07, 0xB08, 0xB09, 0xB0A, 0xB0B, 0xB0C, 0xB0D, 0xB0E, 0xB0F, 0xB10, 0xB11, 0xB12,
0xB20, 0xB21, 0xB22, 0xB23, 0xB24, 0xB25, 0xB26, 0xB27, 0xB28, 0xB29, 0xB2A, 0xB2B, 0xB2C,
0xB2D, 0xB2E, 0xB2F, 0xB30, 0xB31, 0xB32, 0xB33, 0xB34, 0xB3E, 0xB3F, 0xB60, 0xB61, 0xB62,
0xB63, 0xB64, 0xB65, 0xB66, 0xB67, 0xB68, 0xB69, 0xB6A, 0xB6B, 0xB6C, 0xBF0, 0xBF1, 0xBF2,
0xBF3, 0xBF4, 0xBF5, 0xBF6, 0xBF7, 0xBF8, 0xBF9, 0xBFF};
}
#endif
| 41,828
|
C++
|
.h
| 418
| 79.873206
| 98
| 0.506155
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,367
|
g3values.hpp
|
FlagBrew_PKSM-Core/source/utils/g3values.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G3VALUES_H
#define G3VALUES_H
#include "utils/coretypes.h"
#include <array>
namespace pksm::internal
{
// Index = species, value = g3 species
constexpr std::array<u16, 387> speciesToG3 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248,
249, 250, 251, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
292, 293, 294, 295, 296, 297, 298, 299, 300, 304, 305, 309, 310, 392, 393, 394, 311, 312,
306, 307, 364, 365, 366, 301, 302, 303, 370, 371, 372, 335, 336, 350, 320, 315, 316, 322,
355, 382, 383, 384, 356, 357, 337, 338, 353, 354, 386, 387, 363, 367, 368, 330, 331, 313,
314, 339, 340, 321, 351, 352, 308, 332, 333, 334, 344, 345, 358, 359, 380, 379, 348, 349,
323, 324, 326, 327, 318, 319, 388, 389, 390, 391, 328, 329, 385, 317, 377, 378, 361, 362,
369, 411, 376, 360, 346, 347, 341, 342, 343, 373, 374, 375, 381, 325, 395, 396, 397, 398,
399, 400, 401, 402, 403, 407, 408, 404, 405, 406, 409, 410};
// Index = g3 species, value = species
constexpr std::array<u16, 412> g3ToSpecies = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248,
249, 250, 251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269,
270, 271, 272, 273, 274, 275, 290, 291, 292, 276, 277, 285, 286, 327, 278, 279, 283, 284,
320, 321, 300, 301, 352, 343, 344, 299, 324, 302, 339, 340, 370, 341, 342, 349, 350, 318,
319, 328, 329, 330, 296, 297, 309, 310, 322, 323, 363, 364, 365, 331, 332, 361, 362, 337,
338, 298, 325, 326, 311, 312, 303, 307, 308, 333, 334, 360, 355, 356, 315, 287, 288, 289,
316, 317, 357, 293, 294, 295, 366, 367, 368, 359, 353, 354, 336, 335, 369, 304, 305, 306,
351, 313, 314, 345, 346, 347, 348, 280, 281, 282, 371, 372, 373, 374, 375, 376, 377, 378,
379, 382, 383, 384, 380, 381, 385, 386, 358};
// Index = g3 item, value = item
constexpr std::array<u16, 339> g3ToItem = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
65, 66, 67, 68, 69, 43, 44, 70, 71, 72, 73, 74, 75, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 45, 46, 47, 48, 49, 50, 51, 52, 53, 128, 55, 56, 57, 58, 59, 60, 61, 63, 64,
128, 76, 77, 78, 79, 128, 128, 128, 128, 128, 128, 80, 81, 82, 83, 84, 85, 128, 128, 128,
128, 86, 87, 128, 88, 89, 90, 91, 92, 93, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 149, 150, 151, 152, 153, 154, 155,
156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 201, 202, 203, 204, 205, 206, 207, 208,
128, 128, 128, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 260, 261, 262, 263, 264, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340,
341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358,
359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
377};
}
#endif
| 7,463
|
C++
|
.h
| 98
| 69.785714
| 100
| 0.572768
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,368
|
ppCount.hpp
|
FlagBrew_PKSM-Core/source/utils/ppCount.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Pk11
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef PP_COUNT_HPP
#define PP_COUNT_HPP
#include "enums/Move.hpp"
#include "utils/coretypes.h"
#include <array>
#include <utility>
namespace pksm::internal
{
constexpr std::array<u8, 827> PP_G8 = {
0, // None
35, // Pound
25, // KarateChop
10, // DoubleSlap
15, // CometPunch
20, // MegaPunch
20, // PayDay
15, // FirePunch
15, // IcePunch
15, // ThunderPunch
35, // Scratch
30, // ViseGrip
5, // Guillotine
10, // RazorWind
20, // SwordsDance
30, // Cut
35, // Gust
35, // WingAttack
20, // Whirlwind
15, // Fly
20, // Bind
20, // Slam
25, // VineWhip
20, // Stomp
30, // DoubleKick
5, // MegaKick
10, // JumpKick
15, // RollingKick
15, // SandAttack
15, // Headbutt
25, // HornAttack
20, // FuryAttack
5, // HornDrill
35, // Tackle
15, // BodySlam
20, // Wrap
20, // TakeDown
10, // Thrash
15, // DoubleEdge
30, // TailWhip
35, // PoisonSting
20, // Twineedle
20, // PinMissile
30, // Leer
25, // Bite
40, // Growl
20, // Roar
15, // Sing
20, // Supersonic
20, // SonicBoom
20, // Disable
30, // Acid
25, // Ember
15, // Flamethrower
30, // Mist
25, // WaterGun
5, // HydroPump
15, // Surf
10, // IceBeam
5, // Blizzard
20, // Psybeam
20, // BubbleBeam
20, // AuroraBeam
5, // HyperBeam
35, // Peck
20, // DrillPeck
20, // Submission
20, // LowKick
20, // Counter
20, // SeismicToss
15, // Strength
25, // Absorb
15, // MegaDrain
10, // LeechSeed
20, // Growth
25, // RazorLeaf
10, // SolarBeam
35, // PoisonPowder
30, // StunSpore
15, // SleepPowder
10, // PetalDance
40, // StringShot
10, // DragonRage
15, // FireSpin
30, // ThunderShock
15, // Thunderbolt
20, // ThunderWave
10, // Thunder
15, // RockThrow
10, // Earthquake
5, // Fissure
10, // Dig
10, // Toxic
25, // Confusion
10, // Psychic
20, // Hypnosis
40, // Meditate
30, // Agility
30, // QuickAttack
20, // Rage
20, // Teleport
15, // NightShade
10, // Mimic
40, // Screech
15, // DoubleTeam
10, // Recover
30, // Harden
10, // Minimize
20, // Smokescreen
10, // ConfuseRay
40, // Withdraw
40, // DefenseCurl
20, // Barrier
30, // LightScreen
30, // Haze
20, // Reflect
30, // FocusEnergy
10, // Bide
10, // Metronome
20, // MirrorMove
5, // SelfDestruct
10, // EggBomb
30, // Lick
20, // Smog
20, // Sludge
20, // BoneClub
5, // FireBlast
15, // Waterfall
15, // Clamp
20, // Swift
10, // SkullBash
15, // SpikeCannon
35, // Constrict
20, // Amnesia
15, // Kinesis
10, // SoftBoiled
10, // HighJumpKick
30, // Glare
15, // DreamEater
40, // PoisonGas
20, // Barrage
10, // LeechLife
10, // LovelyKiss
5, // SkyAttack
10, // Transform
30, // Bubble
10, // DizzyPunch
15, // Spore
20, // Flash
15, // Psywave
40, // Splash
20, // AcidArmor
10, // Crabhammer
5, // Explosion
15, // FurySwipes
10, // Bonemerang
10, // Rest
10, // RockSlide
15, // HyperFang
30, // Sharpen
30, // Conversion
10, // TriAttack
10, // SuperFang
20, // Slash
10, // Substitute
1, // Struggle
1, // Sketch
10, // TripleKick
25, // Thief
10, // SpiderWeb
5, // MindReader
15, // Nightmare
25, // FlameWheel
15, // Snore
10, // Curse
15, // Flail
30, // Conversion2
5, // Aeroblast
40, // CottonSpore
15, // Reversal
10, // Spite
25, // PowderSnow
10, // Protect
30, // MachPunch
10, // ScaryFace
20, // FeintAttack
10, // SweetKiss
10, // BellyDrum
10, // SludgeBomb
10, // MudSlap
10, // Octazooka
20, // Spikes
5, // ZapCannon
40, // Foresight
5, // DestinyBond
5, // PerishSong
15, // IcyWind
5, // Detect
10, // BoneRush
5, // LockOn
10, // Outrage
10, // Sandstorm
10, // GigaDrain
10, // Endure
20, // Charm
20, // Rollout
40, // FalseSwipe
15, // Swagger
10, // MilkDrink
20, // Spark
20, // FuryCutter
25, // SteelWing
5, // MeanLook
15, // Attract
10, // SleepTalk
5, // HealBell
20, // Return
15, // Present
20, // Frustration
25, // Safeguard
20, // PainSplit
5, // SacredFire
30, // Magnitude
5, // DynamicPunch
10, // Megahorn
20, // DragonBreath
40, // BatonPass
5, // Encore
20, // Pursuit
40, // RapidSpin
20, // SweetScent
15, // IronTail
35, // MetalClaw
10, // VitalThrow
5, // MorningSun
5, // Synthesis
5, // Moonlight
15, // HiddenPower
5, // CrossChop
20, // Twister
5, // RainDance
5, // SunnyDay
15, // Crunch
20, // MirrorCoat
10, // PsychUp
5, // ExtremeSpeed
5, // AncientPower
15, // ShadowBall
10, // FutureSight
15, // RockSmash
15, // Whirlpool
10, // BeatUp
10, // FakeOut
10, // Uproar
20, // Stockpile
10, // SpitUp
10, // Swallow
10, // HeatWave
10, // Hail
15, // Torment
15, // Flatter
15, // WillOWisp
10, // Memento
20, // Facade
20, // FocusPunch
10, // SmellingSalts
20, // FollowMe
20, // NaturePower
20, // Charge
20, // Taunt
20, // HelpingHand
10, // Trick
10, // RolePlay
10, // Wish
20, // Assist
20, // Ingrain
5, // Superpower
15, // MagicCoat
10, // Recycle
10, // Revenge
15, // BrickBreak
10, // Yawn
20, // KnockOff
5, // Endeavor
5, // Eruption
10, // SkillSwap
10, // Imprison
20, // Refresh
5, // Grudge
10, // Snatch
20, // SecretPower
10, // Dive
20, // ArmThrust
20, // Camouflage
20, // TailGlow
5, // LusterPurge
5, // MistBall
15, // FeatherDance
20, // TeeterDance
10, // BlazeKick
15, // MudSport
20, // IceBall
15, // NeedleArm
10, // SlackOff
10, // HyperVoice
15, // PoisonFang
10, // CrushClaw
5, // BlastBurn
5, // HydroCannon
10, // MeteorMash
15, // Astonish
10, // WeatherBall
5, // Aromatherapy
20, // FakeTears
25, // AirCutter
5, // Overheat
40, // OdorSleuth
15, // RockTomb
5, // SilverWind
40, // MetalSound
15, // GrassWhistle
20, // Tickle
20, // CosmicPower
5, // WaterSpout
15, // SignalBeam
20, // ShadowPunch
20, // Extrasensory
15, // SkyUppercut
15, // SandTomb
5, // SheerCold
10, // MuddyWater
30, // BulletSeed
20, // AerialAce
30, // IcicleSpear
15, // IronDefense
5, // Block
40, // Howl
15, // DragonClaw
5, // FrenzyPlant
20, // BulkUp
5, // Bounce
15, // MudShot
25, // PoisonTail
25, // Covet
15, // VoltTackle
20, // MagicalLeaf
15, // WaterSport
20, // CalmMind
15, // LeafBlade
20, // DragonDance
10, // RockBlast
20, // ShockWave
20, // WaterPulse
5, // DoomDesire
5, // PsychoBoost
10, // Roost
5, // Gravity
40, // MiracleEye
10, // WakeUpSlap
10, // HammerArm
5, // GyroBall
10, // HealingWish
10, // Brine
15, // NaturalGift
10, // Feint
20, // Pluck
15, // Tailwind
30, // Acupressure
10, // MetalBurst
20, // Uturn
5, // CloseCombat
10, // Payback
10, // Assurance
15, // Embargo
10, // Fling
10, // PsychoShift
5, // TrumpCard
15, // HealBlock
5, // WringOut
10, // PowerTrick
10, // GastroAcid
30, // LuckyChant
20, // MeFirst
20, // Copycat
10, // PowerSwap
10, // GuardSwap
5, // Punishment
5, // LastResort
10, // WorrySeed
5, // SuckerPunch
20, // ToxicSpikes
10, // HeartSwap
20, // AquaRing
10, // MagnetRise
15, // FlareBlitz
10, // ForcePalm
20, // AuraSphere
20, // RockPolish
20, // PoisonJab
15, // DarkPulse
15, // NightSlash
10, // AquaTail
15, // SeedBomb
15, // AirSlash
15, // XScissor
10, // BugBuzz
10, // DragonPulse
10, // DragonRush
20, // PowerGem
10, // DrainPunch
30, // VacuumWave
5, // FocusBlast
10, // EnergyBall
15, // BraveBird
10, // EarthPower
10, // Switcheroo
5, // GigaImpact
20, // NastyPlot
30, // BulletPunch
10, // Avalanche
30, // IceShard
15, // ShadowClaw
15, // ThunderFang
15, // IceFang
15, // FireFang
30, // ShadowSneak
10, // MudBomb
20, // PsychoCut
15, // ZenHeadbutt
10, // MirrorShot
10, // FlashCannon
20, // RockClimb
15, // Defog
5, // TrickRoom
5, // DracoMeteor
15, // Discharge
15, // LavaPlume
5, // LeafStorm
10, // PowerWhip
5, // RockWrecker
20, // CrossPoison
5, // GunkShot
15, // IronHead
20, // MagnetBomb
5, // StoneEdge
20, // Captivate
20, // StealthRock
20, // GrassKnot
20, // Chatter
10, // Judgment
20, // BugBite
10, // ChargeBeam
15, // WoodHammer
20, // AquaJet
15, // AttackOrder
10, // DefendOrder
10, // HealOrder
5, // HeadSmash
10, // DoubleHit
5, // RoarofTime
5, // SpacialRend
10, // LunarDance
5, // CrushGrip
5, // MagmaStorm
10, // DarkVoid
5, // SeedFlare
5, // OminousWind
5, // ShadowForce
15, // HoneClaws
10, // WideGuard
10, // GuardSplit
10, // PowerSplit
10, // WonderRoom
10, // Psyshock
10, // Venoshock
15, // Autotomize
20, // RagePowder
15, // Telekinesis
10, // MagicRoom
15, // SmackDown
10, // StormThrow
15, // FlameBurst
10, // SludgeWave
20, // QuiverDance
10, // HeavySlam
10, // Synchronoise
10, // ElectroBall
20, // Soak
20, // FlameCharge
20, // Coil
20, // LowSweep
20, // AcidSpray
15, // FoulPlay
15, // SimpleBeam
15, // Entrainment
15, // AfterYou
15, // Round
15, // EchoedVoice
20, // ChipAway
15, // ClearSmog
10, // StoredPower
15, // QuickGuard
15, // AllySwitch
15, // Scald
15, // ShellSmash
10, // HealPulse
10, // Hex
10, // SkyDrop
10, // ShiftGear
10, // CircleThrow
15, // Incinerate
15, // Quash
15, // Acrobatics
15, // ReflectType
5, // Retaliate
5, // FinalGambit
15, // Bestow
5, // Inferno
10, // WaterPledge
10, // FirePledge
10, // GrassPledge
20, // VoltSwitch
20, // StruggleBug
20, // Bulldoze
10, // FrostBreath
10, // DragonTail
30, // WorkUp
15, // Electroweb
15, // WildCharge
10, // DrillRun
15, // DualChop
25, // HeartStamp
10, // HornLeech
15, // SacredSword
10, // RazorShell
10, // HeatCrash
10, // LeafTornado
20, // Steamroller
10, // CottonGuard
10, // NightDaze
10, // Psystrike
10, // TailSlap
10, // Hurricane
15, // HeadCharge
15, // GearGrind
5, // SearingShot
5, // TechnoBlast
10, // RelicSong
10, // SecretSword
10, // Glaciate
5, // BoltStrike
5, // BlueFlare
10, // FieryDance
5, // FreezeShock
5, // IceBurn
15, // Snarl
10, // IcicleCrash
5, // Vcreate
5, // FusionFlare
5, // FusionBolt
10, // FlyingPress
10, // MatBlock
10, // Belch
10, // Rototiller
20, // StickyWeb
25, // FellStinger
10, // PhantomForce
20, // TrickorTreat
30, // NobleRoar
25, // IonDeluge
20, // ParabolicCharge
20, // ForestsCurse
15, // PetalBlizzard
20, // FreezeDry
15, // DisarmingVoice
20, // PartingShot
20, // TopsyTurvy
10, // DrainingKiss
10, // CraftyShield
10, // FlowerShield
10, // GrassyTerrain
10, // MistyTerrain
20, // Electrify
10, // PlayRough
30, // FairyWind
15, // Moonblast
10, // Boomburst
10, // FairyLock
10, // KingsShield
20, // PlayNice
20, // Confide
5, // DiamondStorm
5, // SteamEruption
5, // HyperspaceHole
20, // WaterShuriken
10, // MysticalFire
10, // SpikyShield
20, // AromaticMist
15, // EerieImpulse
20, // VenomDrench
20, // Powder
10, // Geomancy
20, // MagneticFlux
30, // HappyHour
10, // ElectricTerrain
10, // DazzlingGleam
40, // Celebrate
40, // HoldHands
30, // BabyDollEyes
20, // Nuzzle
40, // HoldBack
20, // Infestation
20, // PowerUpPunch
10, // OblivionWing
10, // ThousandArrows
10, // ThousandWaves
10, // LandsWrath
5, // LightofRuin
10, // OriginPulse
10, // PrecipiceBlades
5, // DragonAscent
5, // HyperspaceFury
1, // BreakneckBlitz
1, // BreakneckBlitz
1, // AllOutPummeling
1, // AllOutPummeling
1, // SupersonicSkystrike
1, // SupersonicSkystrike
1, // AcidDownpour
1, // AcidDownpour
1, // TectonicRage
1, // TectonicRage
1, // ContinentalCrush
1, // ContinentalCrush
1, // SavageSpinOut
1, // SavageSpinOut
1, // NeverEndingNightmare
1, // NeverEndingNightmare
1, // CorkscrewCrash
1, // CorkscrewCrash
1, // InfernoOverdrive
1, // InfernoOverdrive
1, // HydroVortex
1, // HydroVortex
1, // BloomDoom
1, // BloomDoom
1, // GigavoltHavoc
1, // GigavoltHavoc
1, // ShatteredPsyche
1, // ShatteredPsyche
1, // SubzeroSlammer
1, // SubzeroSlammer
1, // DevastatingDrake
1, // DevastatingDrake
1, // BlackHoleEclipse
1, // BlackHoleEclipse
1, // TwinkleTackle
1, // TwinkleTackle
1, // Catastropika
10, // ShoreUp
10, // FirstImpression
10, // BanefulBunker
10, // SpiritShackle
10, // DarkestLariat
10, // SparklingAria
10, // IceHammer
10, // FloralHealing
10, // HighHorsepower
10, // StrengthSap
10, // SolarBlade
40, // Leafage
15, // Spotlight
20, // ToxicThread
30, // LaserFocus
20, // GearUp
15, // ThroatChop
15, // PollenPuff
20, // AnchorShot
10, // PsychicTerrain
15, // Lunge
15, // FireLash
10, // PowerTrip
5, // BurnUp
10, // SpeedSwap
10, // SmartStrike
20, // Purify
15, // RevelationDance
10, // CoreEnforcer
15, // TropKick
15, // Instruct
15, // BeakBlast
5, // ClangingScales
15, // DragonHammer
20, // BrutalSwing
20, // AuroraVeil
1, // SinisterArrowRaid
1, // MaliciousMoonsault
1, // OceanicOperetta
1, // GuardianofAlola
1, // SoulStealing7StarStrike
1, // StokedSparksurfer
1, // PulverizingPancake
1, // ExtremeEvoboost
1, // GenesisSupernova
5, // ShellTrap
5, // FleurCannon
10, // PsychicFangs
10, // StompingTantrum
10, // ShadowBone
20, // Accelerock
10, // Liquidation
10, // PrismaticLaser
10, // SpectralThief
5, // SunsteelStrike
5, // MoongeistBeam
20, // TearfulLook
10, // ZingZap
10, // NaturesMadness
10, // MultiAttack
1, // TenMillionVoltThunderbolt
5, // MindBlown
15, // PlasmaFists
5, // PhotonGeyser
1, // LightThatBurnstheSky
1, // SearingSunrazeSmash
1, // MenacingMoonrazeMaelstrom
1, // LetsSnuggleForever
1, // SplinteredStormshards
1, // ClangorousSoulblaze
10, // ZippyZap
15, // SplishySplash
15, // FloatyFall
20, // PikaPapow
20, // BouncyBubble
20, // BuzzyBuzz
20, // SizzlySlide
15, // GlitzyGlow
15, // BaddyBad
10, // SappySeed
10, // FreezyFrost
5, // SparklySwirl
20, // VeeveeVolley
5, // DoubleIronBash
10, // MaxGuard
5, // DynamaxCannon
15, // SnipeShot
10, // JawLock
10, // StuffCheeks
5, // NoRetreat
15, // TarShot
20, // MagicPowder
10, // DragonDarts
10, // Teatime
15, // Octolock
10, // BoltBeak
10, // FishiousRend
10, // CourtChange
10, // MaxFlare
10, // MaxFlutterby
10, // MaxLightning
10, // MaxStrike
10, // MaxKnuckle
10, // MaxPhantasm
10, // MaxHailstorm
10, // MaxOoze
10, // MaxGeyser
10, // MaxAirstream
10, // MaxStarfall
10, // MaxWyrmwind
10, // MaxMindstorm
10, // MaxRockfall
10, // MaxQuake
10, // MaxDarkness
10, // MaxOvergrowth
10, // MaxSteelspike
5, // ClangorousSoul
10, // BodyPress
15, // Decorate
10, // DrumBeating
15, // SnapTrap
5, // PyroBall
5, // BehemothBlade
5, // BehemothBash
10, // AuraWheel
15, // BreakingSwipe
40, // BranchPoke
10, // Overdrive
10, // AppleAcid
10, // GravApple
15, // SpiritBreak
10, // StrangeSteam
10, // LifeDew
10, // Obstruct
10, // FalseSurrender
5, // MeteorAssault
5, // Eternabeam
5, // SteelBeam
10, // ExpandingForce
5, // SteelRoller
20, // ScaleShot
10, // MeteorBeam
10, // ShellSideArm
5, // MistyExplosion
20, // GrassyGlide
20, // RisingVoltage
10, // TerrainPulse
10, // SkitterSmack
5, // BurningJealousy
5, // LashOut
5, // Poltergeist
40, // CorrosiveGas
10, // Coaching
20, // FlipTurn
10, // TripleAxel
10, // DualWingbeat
10, // ScorchingSands
10, // JungleHealing
5, // WickedBlow
5, // SurgingStrikes
15, // ThunderCage
5, // DragonEnergy
10, // FreezingGlare
10, // FieryWrath
10, // ThunderousKick
5, // GlacialLance
5, // AstralBarrage
5, // EerieSpell
};
constexpr std::array<std::pair<pksm::Move, u8>, 9> PPDiff_LGPE = {
{{pksm::Move::Absorb, 15}, {pksm::Move::MegaDrain, 10}, {pksm::Move::ZippyZap, 15},
{pksm::Move::BouncyBubble, 15}, {pksm::Move::BuzzyBuzz, 15},
{pksm::Move::SizzlySlide, 15}, {pksm::Move::SappySeed, 15},
{pksm::Move::FreezyFrost, 15}, {pksm::Move::SparklySwirl, 15}}
};
// No differences between SM and SWSH
constexpr std::array<std::pair<pksm::Move, u8>, 3> PPDiff_G6 = {
{{pksm::Move::Submission, 25}, {pksm::Move::LeechLife, 15},
{pksm::Move::Synchronoise, 15}}
};
constexpr std::array<std::pair<pksm::Move, u8>, 18> PPDiff_G5 = {
{{pksm::Move::SwordsDance, 30}, {pksm::Move::VineWhip, 15}, {pksm::Move::JumpKick, 25},
{pksm::Move::Submission, 25}, {pksm::Move::Growth, 40}, {pksm::Move::Minimize, 20},
{pksm::Move::Barrier, 30}, {pksm::Move::SkullBash, 15}, {pksm::Move::LeechLife, 15},
{pksm::Move::AcidArmor, 40}, {pksm::Move::Thief, 10}, {pksm::Move::RockTomb, 10},
{pksm::Move::Extrasensory, 30}, {pksm::Move::Covet, 40}, {pksm::Move::Tailwind, 30},
{pksm::Move::AirSlash, 20}, {pksm::Move::Synchronoise, 15},
{pksm::Move::SacredSword, 20}}
};
constexpr std::array<std::pair<pksm::Move, u8>, 23> PPDiff_G4 = {
{{pksm::Move::SwordsDance, 30}, {pksm::Move::VineWhip, 15}, {pksm::Move::JumpKick, 25},
{pksm::Move::Thrash, 20}, {pksm::Move::Submission, 25}, {pksm::Move::Growth, 40},
{pksm::Move::PetalDance, 20}, {pksm::Move::Minimize, 20}, {pksm::Move::Barrier, 30},
{pksm::Move::Clamp, 10}, {pksm::Move::SkullBash, 15}, {pksm::Move::HighJumpKick, 20},
{pksm::Move::LeechLife, 15}, {pksm::Move::AcidArmor, 40}, {pksm::Move::Thief, 10},
{pksm::Move::Outrage, 15}, {pksm::Move::FutureSight, 15}, {pksm::Move::RockTomb, 10},
{pksm::Move::Extrasensory, 30}, {pksm::Move::Covet, 40}, {pksm::Move::Tailwind, 30},
{pksm::Move::AirSlash, 20}, {pksm::Move::DrainPunch, 5}}
};
// no pp difference in Gen I and II moves until Gen IV
constexpr std::array<std::pair<pksm::Move, u8>, 25> PPDiff_G123 = {
{{pksm::Move::SwordsDance, 30}, {pksm::Move::VineWhip, 15}, {pksm::Move::JumpKick, 25},
{pksm::Move::Thrash, 20}, {pksm::Move::Submission, 25}, {pksm::Move::Absorb, 20},
{pksm::Move::MegaDrain, 10}, {pksm::Move::Growth, 40}, {pksm::Move::PetalDance, 20},
{pksm::Move::Recover, 20}, {pksm::Move::Minimize, 20}, {pksm::Move::Barrier, 30},
{pksm::Move::Clamp, 10}, {pksm::Move::SkullBash, 15}, {pksm::Move::HighJumpKick, 20},
{pksm::Move::LeechLife, 15}, {pksm::Move::AcidArmor, 40}, {pksm::Move::Thief, 10},
{pksm::Move::Outrage, 15}, {pksm::Move::GigaDrain, 5}, {pksm::Move::FutureSight, 15},
{pksm::Move::Stockpile, 10}, {pksm::Move::RockTomb, 10}, {pksm::Move::Extrasensory, 30},
{pksm::Move::Covet, 40}}
};
}
#endif
| 25,660
|
C++
|
.h
| 906
| 19.628035
| 97
| 0.493655
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,369
|
g2values.hpp
|
FlagBrew_PKSM-Core/source/utils/g2values.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G2VALUES_HPP
#define G2VALUES_HPP
#include "utils/coretypes.h"
#include <array>
namespace pksm::internal
{
// index is Gen II item, value is modern item
// unlabeled gaps are Teru-sama, a dummy item
constexpr std::array<u16, 256> g2ToItem = {0, 1, 2, 213, 3, 4, 128, 450, 81, 18, 19, 20, 21, 22,
23, 24, 25, 26, 17, 78, 79, 41, 82, 83, 84, 128, 45, 46, 47, 48, 256, 49, 50, 60, 85, 257,
92, 63, 27, 28, 29, 55, 76, 77, 56, 128, 30, 31, 32, 57, 128, 58, 59, 61, 444, 128, 128,
216, 445, 446, 891, 447, 51, 38, 39, 40, 478, 464, 456, 484, 474, 482, 33, 217, 151, 890,
237, 244, 149, 153, 152, 245, 221, 156, 150, 485, 86, 87, 222, 487, 128, 223, 486, 488, 224,
243, 248, 490, 241, 491, 128, 489, 240, 473, 128 /*Pink Bow*/, 259, 228, 246, 242, 157, 88,
89, 229, 247, 504, 128 /*GS Ball*/, 472, 239, 258, 230, 128, 34, 35, 36, 37, 238, 231, 475,
481, 128 /*Egg Ticket*/, 479, 90, 91, 476, 480, 128, 128, 128, 249, 43, 232, 128, 128, 233,
250, 128, 234, 128, 128, 128, 154, 235, 128 /*Berserk Gene*/, 128, 128, 128, 44, 495,
128 /*Flower Mail*/, 493, 494, 492, 128, 236, 497, 498, 496, 128 /*Normal Box*/,
128 /*Gorgeous Box*/, 80, 128 /*Polkadot Bow*/, 128, 252, 155, 158, 477, 128, 500, 483, 128,
128 /*Brick Piece*/, 128 /*Surf Mail*/, 128 /*Litebluemail*/, 128 /*Portraitmail*/,
128 /*Lovely Mail*/, 128 /*Eon Mail*/, 128 /*Morph Mail*/, 128 /*Bluesky Mail*/,
128 /*Music Mail*/, 128 /*Mirage Mail*/, 128, 328, 329, 330, 331, 331, 332, 333, 334, 335,
336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353,
354, 355, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370,
371, 372, 373, 374, 375, 376, 377, 420, 421, 422, 423, 424, 425, 426, 427, 128 /*HM09*/,
128 /*HM10*/, 128 /*HM11*/, 128 /*HM12*/, 128 /*Cancel*/};
}
#endif
| 3,218
|
C++
|
.h
| 53
| 56.396226
| 100
| 0.630497
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,370
|
g3text.hpp
|
FlagBrew_PKSM-Core/source/utils/g3text.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G3TEXT_HPP
#define G3TEXT_HPP
#include <array>
namespace pksm::internal
{
constexpr std::array<char16_t, 247> G3_EN = {u' ', u'À', u'Á', u'Â', u'Ç', u'È', u'É', u'Ê',
u'Ë', u'Ì', u'こ', u'Î', u'Ï', u'Ò', u'Ó', u'Ô', u'Œ', u'Ù', u'Ú', u'Û', u'Ñ', u'ß', u'à',
u'á', u'ね', u'Ç', u'È', u'é', u'ê', u'ë', u'ì', u'í', u'î', u'ï', u'ò', u'ó', u'ô', u'œ',
u'ù', u'ú', u'û', u'ñ', u'º', u'ª', u'⒅', u'&', u'+', u'あ', u'ぃ', u'ぅ', u'ぇ', u'ぉ',
u'ゃ', u'=', u'ょ', u'が', u'ぎ', u'ぐ', u'げ', u'ご', u'ざ', u'じ', u'ず', u'ぜ', u'ぞ',
u'だ', u'ぢ', u'づ', u'で', u'ど', u'ば', u'び', u'ぶ', u'べ', u'ぼ', u'ぱ', u'ぴ', u'ぷ',
u'ぺ', u'ぽ', u'っ', u'¿', u'¡', u'⒆', u'⒇', u'オ', u'カ', u'キ', u'ク', u'ケ', u'Í', u'コ',
u'サ', u'ス', u'セ', u'ソ', u'タ', u'チ', u'ツ', u'テ', u'ト', u'ナ', u'ニ', u'ヌ', u'â',
u'ノ', u'ハ', u'ヒ', u'フ', u'ヘ', u'ホ', u'í', u'ミ', u'ム', u'メ', u'モ', u'ヤ', u'ユ',
u'ヨ', u'ラ', u'リ', u'ル', u'レ', u'ロ', u'ワ', u'ヲ', u'ン', u'ァ', u'ィ', u'ゥ', u'ェ',
u'ォ', u'ャ', u'ュ', u'ョ', u'ガ', u'ギ', u'グ', u'ゲ', u'ゴ', u'ザ', u'ジ', u'ズ', u'ゼ',
u'ゾ', u'ダ', u'ヂ', u'ヅ', u'デ', u'ド', u'バ', u'ビ', u'ブ', u'ベ', u'ボ', u'パ', u'ピ',
u'プ', u'ペ', u'ポ', u'ッ', u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9',
u'!', u'?', u'.', u'-', u'・', u'⑬', u'“', u'”', u'‘', u'’', u'♂', u'♀', u'$', u',', u'⑧',
u'/', u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N',
u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u'a', u'b', u'c',
u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r',
u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', u':', u'Ä', u'Ö', u'Ü', u'ä', u'ö',
u'ü'};
constexpr std::array<char16_t, 247> G3_JP = {u' ', u'あ', u'い', u'う', u'え', u'お', u'か',
u'き', u'く', u'け', u'こ', u'さ', u'し', u'す', u'せ', u'そ', u'た', u'ち', u'つ', u'て',
u'と', u'な', u'に', u'ぬ', u'ね', u'の', u'は', u'ひ', u'ふ', u'へ', u'ほ', u'ま', u'み',
u'む', u'め', u'も', u'や', u'ゆ', u'よ', u'ら', u'り', u'る', u'れ', u'ろ', u'わ', u'を',
u'ん', u'ぁ', u'ぃ', u'ぅ', u'ぇ', u'ぉ', u'ゃ', u'ゅ', u'ょ', u'が', u'ぎ', u'ぐ', u'げ',
u'ご', u'ざ', u'じ', u'ず', u'ぜ', u'ぞ', u'だ', u'ぢ', u'づ', u'で', u'ど', u'ば', u'び',
u'ぶ', u'べ', u'ぼ', u'ぱ', u'ぴ', u'ぷ', u'ぺ', u'ぽ', u'っ', u'ア', u'イ', u'ウ', u'エ',
u'オ', u'カ', u'キ', u'ク', u'ケ', u'コ', u'サ', u'シ', u'ス', u'セ', u'ソ', u'タ', u'チ',
u'ツ', u'テ', u'ト', u'ナ', u'ニ', u'ヌ', u'ネ', u'ノ', u'ハ', u'ヒ', u'フ', u'ヘ', u'ホ',
u'マ', u'ミ', u'ム', u'メ', u'モ', u'ヤ', u'ユ', u'ヨ', u'ラ', u'リ', u'ル', u'レ', u'ロ',
u'ワ', u'ヲ', u'ン', u'ァ', u'ィ', u'ゥ', u'ェ', u'ォ', u'ャ', u'ュ', u'ョ', u'ガ', u'ギ',
u'グ', u'ゲ', u'ゴ', u'ザ', u'ジ', u'ズ', u'ゼ', u'ゾ', u'ダ', u'ヂ', u'ヅ', u'デ', u'ド',
u'バ', u'ビ', u'ブ', u'ベ', u'ボ', u'パ', u'ピ', u'プ', u'ペ', u'ポ', u'ッ', u'0', u'1',
u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'!', u'?', u'。', u'ー', u'・',
u'⋯', u'『', u'』', u'「', u'」', u'♂', u'♀', u'$', u'.', u'⑧', u'/', u'A', u'B',
u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O',
u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u'a', u'b',
u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o',
u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', u':',
u'Ä', u'Ö', u'Ü', u'ä', u'ö', u'ü'};
}
#endif
| 5,502
|
C++
|
.h
| 71
| 60.873239
| 97
| 0.427742
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,371
|
g1values.hpp
|
FlagBrew_PKSM-Core/source/utils/g1values.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G1VALUES_HPP
#define G1VALUES_HPP
#include "utils/coretypes.h"
#include <array>
namespace pksm::internal
{
// index is Pokedex species (= modern species), value is internal species
constexpr std::array<u8, 152> speciesToG1 = {0, 153, 9, 154, 176, 178, 180, 177, 179, 28, 123,
124, 125, 112, 113, 114, 36, 150, 151, 165, 166, 5, 35, 108, 45, 84, 85, 96, 97, 15, 168,
16, 3, 167, 7, 4, 142, 82, 83, 100, 101, 107, 130, 185, 186, 187, 109, 46, 65, 119, 59, 118,
77, 144, 47, 128, 57, 117, 33, 20, 71, 110, 111, 148, 38, 149, 106, 41, 126, 188, 189, 190,
24, 155, 169, 39, 49, 163, 164, 37, 8, 173, 54, 64, 70, 116, 58, 120, 13, 136, 23, 139, 25,
147, 14, 34, 48, 129, 78, 138, 6, 141, 12, 10, 17, 145, 43, 44, 11, 55, 143, 18, 1, 40, 30,
2, 92, 93, 157, 158, 27, 152, 42, 26, 72, 53, 51, 29, 60, 133, 22, 19, 76, 102, 105, 104,
103, 170, 98, 99, 90, 91, 171, 132, 74, 75, 73, 88, 89, 66, 131, 21};
// index is internal species, value is Pokedex species (= modern species)
constexpr std::array<u8, 191> g1ToSpecies = {0, 112, 115, 32, 35, 21, 100, 34, 80, 2, 103, 108,
102, 88, 94, 29, 31, 104, 111, 131, 59, 151, 130, 90, 72, 92, 123, 120, 9, 127, 114, 0, 0,
58, 95, 22, 16, 79, 64, 75, 113, 67, 122, 106, 107, 24, 47, 54, 96, 76, 0, 126, 0, 125, 82,
109, 0, 56, 86, 50, 128, 0, 0, 0, 83, 48, 149, 0, 0, 0, 84, 60, 124, 146, 144, 145, 132, 52,
98, 0, 0, 0, 37, 38, 25, 26, 0, 0, 147, 148, 140, 141, 116, 117, 0, 0, 27, 28, 138, 139, 39,
40, 133, 136, 135, 134, 66, 41, 23, 46, 61, 62, 13, 14, 15, 0, 85, 57, 51, 49, 87, 0, 0, 10,
11, 12, 68, 0, 55, 97, 42, 150, 143, 129, 0, 0, 89, 0, 99, 91, 0, 101, 36, 110, 53, 105, 0,
93, 63, 65, 17, 18, 121, 1, 3, 73, 0, 118, 119, 0, 0, 0, 0, 77, 78, 19, 20, 33, 30, 74, 137,
142, 0, 81, 0, 0, 4, 7, 5, 8, 6, 0, 0, 0, 0, 43, 44, 45, 69, 70, 71};
// index is Gen I item, value is modern item
constexpr std::array<u16, 256> g1ToItem = {0, 1, 2, 3, 4, 442, 450, 128, 5, 128 /*Pokedex*/, 81,
18, 19, 20, 21, 22, 23, 24, 25, 26, 17, 128, 128, 128, 128, 128, 128, 128, 128 /*badges*/,
78, 79, 103, 82, 83, 84, 45, 46, 47, 48, 49, 50, 102, 101, 872, 128,
128 /*Bicycle Voucher*/, 60, 85, 876, 92, 128 /*dysfunctional "PP Up"*/, 63, 27, 28, 29, 55,
76, 77, 56, 128 /*Coin*/, 30, 31, 32, 873, 877, 57, 58, 59, 61 /*X Special*/, 444, 875,
471 /*Itemfinder*/, 874, 651, 878, 216 /*Exp. All*/, 445, 446, 447, 51, 38, 39, 40, 41, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128 /*gap*/, 420, 421, 422, 423, 424, 328, 329, 330, 331, 332, 333, 334, 335, 336,
337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378, 379, 380, 381, 382};
}
#endif
| 4,779
|
C++
|
.h
| 69
| 64
| 100
| 0.590561
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,372
|
g4text.hpp
|
FlagBrew_PKSM-Core/source/utils/g4text.hpp
|
/*
* This file is part of PKSM-Core
* Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef G4TEXT_H
#define G4TEXT_H
#include "utils/coretypes.h"
#include <array>
namespace pksm::internal
{
inline constexpr std::array<u16, 2872> G4Values = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158,
159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212,
213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 225, 226, 227, 228, 229, 230, 231,
232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267,
268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285,
286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321,
322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339,
340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357,
358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375,
376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411,
412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429,
430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447,
448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465,
466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 488, 489,
490, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038,
1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053,
1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068,
1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083,
1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098,
1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113,
1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128,
1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143,
1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158,
1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173,
1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188,
1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203,
1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218,
1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233,
1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248,
1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263,
1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278,
1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293,
1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308,
1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323,
1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338,
1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353,
1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368,
1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383,
1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398,
1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413,
1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428,
1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443,
1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458,
1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473,
1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488,
1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503,
1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518,
1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533,
1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548,
1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563,
1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578,
1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593,
1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608,
1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623,
1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638,
1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653,
1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668,
1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683,
1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698,
1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713,
1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728,
1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743,
1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758,
1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773,
1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788,
1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803,
1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818,
1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833,
1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848,
1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863,
1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878,
1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893,
1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908,
1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923,
1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938,
1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953,
1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968,
1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983,
1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028,
2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043,
2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058,
2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073,
2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088,
2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103,
2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118,
2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133,
2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148,
2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, 2160, 2161, 2162, 2163,
2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, 2172, 2173, 2174, 2175, 2176, 2177, 2178,
2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193,
2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208,
2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223,
2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238,
2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253,
2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268,
2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283,
2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298,
2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313,
2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328,
2329, 2330, 2331, 2332, 2333, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2342, 2343,
2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 2352, 2353, 2354, 2355, 2356, 2357, 2358,
2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, 2373,
2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388,
2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403,
2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418,
2419, 2420, 2421, 2422, 2423, 2424, 2425, 2426, 2427, 2428, 2429, 2430, 2431, 2432, 2433,
2434, 2435, 2436, 2437, 2438, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2446, 2447, 2448,
2449, 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463,
2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478,
2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493,
2494, 2495, 2496, 2497, 2498, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508,
2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2522, 2523,
2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538,
2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547, 2548, 2549, 2550, 2551, 2552, 2553,
2554, 2555, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567, 2568,
2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2580, 2581, 2582, 2583,
2584, 2585, 2586, 2587, 2588, 2589, 2590, 2591, 2592, 2593, 2594, 2595, 2596, 2597, 2598,
2599, 2600, 2601, 2602, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2612, 2613,
2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628,
2629, 2630, 2631, 2632, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643,
2644, 2645, 2646, 2647, 2648, 2649, 2650, 2651, 2652, 2653, 2654, 2655, 2656, 2657, 2658,
2659, 2660, 2661, 2662, 2663, 2664, 2665, 2666, 2667, 2668, 2669, 2670, 2671, 2672, 2673,
2674, 2675, 2676, 2677, 2678, 2679, 2680, 2681, 2682, 2683, 2684, 2685, 2686, 2687, 2688,
2689, 2690, 2691, 2692, 2693, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703,
2704, 2705, 2706, 2707, 2708, 2709, 2710, 2711, 2712, 2713, 2714, 2715, 2716, 2717, 2718,
2719, 2720, 2721, 2722, 2723, 2724, 2725, 2726, 2727, 2728, 2729, 2730, 2731, 2732, 2733,
2734, 2735, 2736, 2737, 2738, 2739, 2740, 2741, 2742, 2743, 2744, 2745, 2746, 2747, 2748,
2749, 2750, 2751, 2752, 2753, 2754, 2755, 2756, 2757, 2758, 2759, 2760, 2761, 2762, 2763,
2764, 2765, 2766, 2767, 2768, 2769, 2770, 2771, 2772, 2773, 2774, 2775, 2776, 2777, 2778,
2779, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2789, 2790, 2791, 2792, 2793,
2794, 2795, 2796, 2797, 2798, 2799, 2800, 2801, 2802, 2803, 2804, 2805, 2806, 2807, 2808,
2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 2821, 2822, 2823,
2824, 2825, 2826, 2827, 2828, 2829, 2830, 2831, 2832, 2833, 2834, 2835, 2836, 2837, 2838,
2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853,
2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868,
2869, 2870, 2871, 2872, 2873, 2874, 2875, 2876, 2877, 2878, 2879, 2880, 2881, 2882, 2883,
2884, 2885, 2886, 2887, 2888, 2889, 2890, 2891, 2892, 2893, 2894, 2895, 2896, 2897, 2898,
2899, 2900, 2901, 2902, 2903, 2904, 2905, 2906, 2907, 2908, 2909, 2910, 2911, 2912, 2913,
2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2922, 2923, 2924, 2925, 2926, 2927, 2928,
2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2943,
2944, 2945, 2946, 2947, 2948, 2949, 2950, 2951, 2952, 2953, 2954, 2955, 2956, 2957, 2958,
2959, 2960, 2961, 2962, 2963, 2964, 2965, 2966, 2967, 2968, 2969, 2970, 2971, 2972, 2973,
2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985, 2986, 2987, 2988,
2989, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 2999, 3000, 3001, 3002, 3003,
3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
3019, 3020, 3021, 3022, 3023, 3024, 3025, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033,
3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, 3044, 3045, 3046, 3047, 3048,
3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 3057, 3058, 3059, 3060, 3061, 3062, 3063,
3064, 3065, 3066, 3067, 3068, 3069, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078,
3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093,
3094, 3095, 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, 3108,
3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123,
3124, 3125, 3126, 3127, 3128, 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3138,
3139, 3140, 3141, 3142, 3143, 3144, 3145, 3146, 3147, 3148, 3149, 3150, 3151, 3152, 3153,
3154, 3155, 3156, 3157, 3158, 3159, 3160, 3161, 3162, 3163, 3164, 3165, 3166, 3167, 3168,
3169, 3170, 3171, 3172, 3173, 3174, 3175, 3176, 3177, 3178, 3179, 3180, 3181, 3182, 3183,
3184, 3185, 3186, 3187, 3188, 3189, 3190, 3191, 3192, 3193, 3194, 3195, 3196, 3197, 3198,
3199, 3200, 3201, 3202, 3203, 3204, 3205, 3206, 3207, 3208, 3209, 3210, 3211, 3212, 3213,
3214, 3215, 3216, 3217, 3218, 3219, 3220, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228,
3229, 3230, 3231, 3232, 3233, 3234, 3235, 3236, 3237, 3238, 3239, 3240, 3241, 3242, 3243,
3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258,
3259, 3260, 3261, 3262, 3263, 3264, 3265, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273,
3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288,
3289, 3290, 3291, 3292, 3293, 3294, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303,
3304, 3305, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318,
3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333,
3334, 3335, 3336, 3337, 3338, 3339, 3340, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348,
3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3363,
3364, 3365, 3366, 3367, 3368, 3369, 3370, 3371, 3372, 3373, 3374, 3377, 3378, 3379, 3380,
3381, 3382, 3383, 3384, 3385, 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395,
3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, 3408, 3409, 3425,
3426, 3427, 3428, 3429, 65535};
inline constexpr std::array<u16, 2872> G4Chars = {12288, 12353, 12354, 12355, 12356, 12357,
12358, 12359, 12360, 12361, 12362, 12363, 12364, 12365, 12366, 12367, 12368, 12369, 12370,
12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383,
12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396,
12397, 12398, 12399, 12400, 12401, 12402, 12403, 12404, 12405, 12406, 12407, 12408, 12409,
12410, 12411, 12412, 12413, 12414, 12415, 12416, 12417, 12418, 12419, 12420, 12421, 12422,
12423, 12424, 12425, 12426, 12427, 12428, 12429, 12431, 12434, 12435, 12449, 12450, 12451,
12452, 12453, 12454, 12455, 12456, 12457, 12458, 12459, 12460, 12461, 12462, 12463, 12464,
12465, 12466, 12467, 12468, 12469, 12470, 12471, 12472, 12473, 12474, 12475, 12476, 12477,
12478, 12479, 12480, 12481, 12482, 12483, 12484, 12485, 12486, 12487, 12488, 12489, 12490,
12491, 12492, 12493, 12494, 12495, 12496, 12497, 12498, 12499, 12500, 12501, 12502, 12503,
12504, 12505, 12506, 12507, 12508, 12509, 12510, 12511, 12512, 12513, 12514, 12515, 12516,
12517, 12518, 12519, 12520, 12521, 12522, 12523, 12524, 12525, 12527, 12530, 12531, 65296,
65297, 65298, 65299, 65300, 65301, 65302, 65303, 65304, 65305, 65313, 65314, 65315, 65316,
65317, 65318, 65319, 65320, 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329,
65330, 65331, 65332, 65333, 65334, 65335, 65336, 65337, 65338, 65345, 65346, 65347, 65348,
65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, 65361,
65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65281, 65311, 12289, 12290,
8943, 12539, 65295, 12300, 12301, 12302, 12303, 65288, 65289, 9325, 9326, 65291, 12540,
9319, 9320, 65309, 65370, 65306, 65307, 65294, 65292, 9327, 9328, 9329, 9330, 9331, 9332,
9333, 9334, 9335, 9336, 65312, 9337, 65285, 9338, 9339, 9341, 10052, 9739, 9812, 9813, 9738,
8663, 8664, 9790, 165, 9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 8592, 8593, 8595,
8594, 8227, 65286, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 338, 339, 350, 351,
170, 186, 185, 178, 179, 36, 161, 191, 33, 63, 44, 46, 9324, 65381, 47, 8216, 8217, 8220,
8221, 8222, 12298, 12299, 40, 41, 9794, 9792, 43, 45, 42, 35, 61, 38, 126, 58, 59, 9327,
9328, 9329, 9330, 9331, 9332, 9333, 9334, 9335, 9336, 64, 9337, 37, 9338, 9339, 9340, 9341,
9342, 9343, 9344, 9345, 9346, 9347, 9348, 32, 9349, 9350, 9351, 176, 95, 65343, 44032,
44033, 44036, 44039, 44040, 44041, 44042, 44048, 44049, 44050, 44051, 44052, 44053, 44054,
44055, 44057, 44058, 44059, 44060, 44061, 44064, 44068, 44076, 44077, 44079, 44080, 44081,
44088, 44089, 44092, 44096, 44107, 44109, 44116, 44120, 44124, 44144, 44145, 44148, 44151,
44152, 44154, 44160, 44161, 44163, 44164, 44165, 44166, 44169, 44170, 44171, 44172, 44176,
44180, 44188, 44189, 44191, 44192, 44193, 44200, 44201, 44202, 44204, 44207, 44208, 44216,
44217, 44219, 44220, 44221, 44225, 44228, 44232, 44236, 44245, 44247, 44256, 44257, 44260,
44263, 44264, 44266, 44268, 44271, 44272, 44273, 44275, 44277, 44278, 44284, 44285, 44288,
44292, 44294, 44300, 44301, 44303, 44305, 44312, 44316, 44320, 44329, 44332, 44333, 44340,
44341, 44344, 44348, 44356, 44357, 44359, 44361, 44368, 44372, 44376, 44385, 44387, 44396,
44397, 44400, 44403, 44404, 44405, 44406, 44411, 44412, 44413, 44415, 44417, 44418, 44424,
44425, 44428, 44432, 44444, 44445, 44452, 44471, 44480, 44481, 44484, 44488, 44496, 44497,
44499, 44508, 44512, 44516, 44536, 44537, 44540, 44543, 44544, 44545, 44552, 44553, 44555,
44557, 44564, 44592, 44593, 44596, 44599, 44600, 44602, 44608, 44609, 44611, 44613, 44614,
44618, 44620, 44621, 44622, 44624, 44628, 44630, 44636, 44637, 44639, 44640, 44641, 44645,
44648, 44649, 44652, 44656, 44664, 44665, 44667, 44668, 44669, 44676, 44677, 44684, 44732,
44733, 44734, 44736, 44740, 44748, 44749, 44751, 44752, 44753, 44760, 44761, 44764, 44776,
44779, 44781, 44788, 44792, 44796, 44807, 44808, 44813, 44816, 44844, 44845, 44848, 44850,
44852, 44860, 44861, 44863, 44865, 44866, 44867, 44872, 44873, 44880, 44892, 44893, 44900,
44901, 44921, 44928, 44932, 44936, 44944, 44945, 44949, 44956, 44984, 44985, 44988, 44992,
44999, 45000, 45001, 45003, 45005, 45006, 45012, 45020, 45032, 45033, 45040, 45041, 45044,
45048, 45056, 45057, 45060, 45068, 45072, 45076, 45084, 45085, 45096, 45124, 45125, 45128,
45130, 45132, 45134, 45139, 45140, 45141, 45143, 45145, 45149, 45180, 45181, 45184, 45188,
45196, 45197, 45199, 45201, 45208, 45209, 45210, 45212, 45215, 45216, 45217, 45218, 45224,
45225, 45227, 45228, 45229, 45230, 45231, 45233, 45235, 45236, 45237, 45240, 45244, 45252,
45253, 45255, 45256, 45257, 45264, 45265, 45268, 45272, 45280, 45285, 45320, 45321, 45323,
45324, 45328, 45330, 45331, 45336, 45337, 45339, 45340, 45341, 45347, 45348, 45349, 45352,
45356, 45364, 45365, 45367, 45368, 45369, 45376, 45377, 45380, 45384, 45392, 45393, 45396,
45397, 45400, 45404, 45408, 45432, 45433, 45436, 45440, 45442, 45448, 45449, 45451, 45453,
45458, 45459, 45460, 45464, 45468, 45480, 45516, 45520, 45524, 45532, 45533, 45535, 45544,
45545, 45548, 45552, 45561, 45563, 45565, 45572, 45573, 45576, 45579, 45580, 45588, 45589,
45591, 45593, 45600, 45620, 45628, 45656, 45660, 45664, 45672, 45673, 45684, 45685, 45692,
45700, 45701, 45705, 45712, 45713, 45716, 45720, 45721, 45722, 45728, 45729, 45731, 45733,
45734, 45738, 45740, 45744, 45748, 45768, 45769, 45772, 45776, 45778, 45784, 45785, 45787,
45789, 45794, 45796, 45797, 45798, 45800, 45803, 45804, 45805, 45806, 45807, 45811, 45812,
45813, 45815, 45816, 45817, 45818, 45819, 45823, 45824, 45825, 45828, 45832, 45840, 45841,
45843, 45844, 45845, 45852, 45908, 45909, 45910, 45912, 45915, 45916, 45918, 45919, 45924,
45925, 45927, 45929, 45931, 45934, 45936, 45937, 45940, 45944, 45952, 45953, 45955, 45956,
45957, 45964, 45968, 45972, 45984, 45985, 45992, 45996, 46020, 46021, 46024, 46027, 46028,
46030, 46032, 46036, 46037, 46039, 46041, 46043, 46045, 46048, 46052, 46056, 46076, 46096,
46104, 46108, 46112, 46120, 46121, 46123, 46132, 46160, 46161, 46164, 46168, 46176, 46177,
46179, 46181, 46188, 46208, 46216, 46237, 46244, 46248, 46252, 46261, 46263, 46265, 46272,
46276, 46280, 46288, 46293, 46300, 46301, 46304, 46307, 46308, 46310, 46316, 46317, 46319,
46321, 46328, 46356, 46357, 46360, 46363, 46364, 46372, 46373, 46375, 46376, 46377, 46378,
46384, 46385, 46388, 46392, 46400, 46401, 46403, 46404, 46405, 46411, 46412, 46413, 46416,
46420, 46428, 46429, 46431, 46432, 46433, 46496, 46497, 46500, 46504, 46506, 46507, 46512,
46513, 46515, 46516, 46517, 46523, 46524, 46525, 46528, 46532, 46540, 46541, 46543, 46544,
46545, 46552, 46572, 46608, 46609, 46612, 46616, 46629, 46636, 46644, 46664, 46692, 46696,
46748, 46749, 46752, 46756, 46763, 46764, 46769, 46804, 46832, 46836, 46840, 46848, 46849,
46853, 46888, 46889, 46892, 46895, 46896, 46904, 46905, 46907, 46916, 46920, 46924, 46932,
46933, 46944, 46948, 46952, 46960, 46961, 46963, 46965, 46972, 46973, 46976, 46980, 46988,
46989, 46991, 46992, 46993, 46994, 46998, 46999, 47000, 47001, 47004, 47008, 47016, 47017,
47019, 47020, 47021, 47028, 47029, 47032, 47047, 47049, 47084, 47085, 47088, 47092, 47100,
47101, 47103, 47104, 47105, 47111, 47112, 47113, 47116, 47120, 47128, 47129, 47131, 47133,
47140, 47141, 47144, 47148, 47156, 47157, 47159, 47160, 47161, 47168, 47172, 47185, 47187,
47196, 47197, 47200, 47204, 47212, 47213, 47215, 47217, 47224, 47228, 47245, 47272, 47280,
47284, 47288, 47296, 47297, 47299, 47301, 47308, 47312, 47316, 47325, 47327, 47329, 47336,
47337, 47340, 47344, 47352, 47353, 47355, 47357, 47364, 47384, 47392, 47420, 47421, 47424,
47428, 47436, 47439, 47441, 47448, 47449, 47452, 47456, 47464, 47465, 47467, 47469, 47476,
47477, 47480, 47484, 47492, 47493, 47495, 47497, 47498, 47501, 47502, 47532, 47533, 47536,
47540, 47548, 47549, 47551, 47553, 47560, 47561, 47564, 47566, 47567, 47568, 47569, 47570,
47576, 47577, 47579, 47581, 47582, 47585, 47587, 47588, 47589, 47592, 47596, 47604, 47605,
47607, 47608, 47609, 47610, 47616, 47617, 47624, 47637, 47672, 47673, 47676, 47680, 47682,
47688, 47689, 47691, 47693, 47694, 47699, 47700, 47701, 47704, 47708, 47716, 47717, 47719,
47720, 47721, 47728, 47729, 47732, 47736, 47747, 47748, 47749, 47751, 47756, 47784, 47785,
47787, 47788, 47792, 47794, 47800, 47801, 47803, 47805, 47812, 47816, 47832, 47833, 47868,
47872, 47876, 47885, 47887, 47889, 47896, 47900, 47904, 47913, 47915, 47924, 47925, 47926,
47928, 47931, 47932, 47933, 47934, 47940, 47941, 47943, 47945, 47949, 47951, 47952, 47956,
47960, 47969, 47971, 47980, 48008, 48012, 48016, 48036, 48040, 48044, 48052, 48055, 48064,
48068, 48072, 48080, 48083, 48120, 48121, 48124, 48127, 48128, 48130, 48136, 48137, 48139,
48140, 48141, 48143, 48145, 48148, 48149, 48150, 48151, 48152, 48155, 48156, 48157, 48158,
48159, 48164, 48165, 48167, 48169, 48173, 48176, 48177, 48180, 48184, 48192, 48193, 48195,
48196, 48197, 48201, 48204, 48205, 48208, 48221, 48260, 48261, 48264, 48267, 48268, 48270,
48276, 48277, 48279, 48281, 48282, 48288, 48289, 48292, 48295, 48296, 48304, 48305, 48307,
48308, 48309, 48316, 48317, 48320, 48324, 48333, 48335, 48336, 48337, 48341, 48344, 48348,
48372, 48373, 48374, 48376, 48380, 48388, 48389, 48391, 48393, 48400, 48404, 48420, 48428,
48448, 48456, 48457, 48460, 48464, 48472, 48473, 48484, 48488, 48512, 48513, 48516, 48519,
48520, 48521, 48522, 48528, 48529, 48531, 48533, 48537, 48538, 48540, 48548, 48560, 48568,
48596, 48597, 48600, 48604, 48617, 48624, 48628, 48632, 48640, 48643, 48645, 48652, 48653,
48656, 48660, 48668, 48669, 48671, 48708, 48709, 48712, 48716, 48718, 48724, 48725, 48727,
48729, 48730, 48731, 48736, 48737, 48740, 48744, 48746, 48752, 48753, 48755, 48756, 48757,
48763, 48764, 48765, 48768, 48772, 48780, 48781, 48783, 48784, 48785, 48792, 48793, 48808,
48848, 48849, 48852, 48855, 48856, 48864, 48867, 48868, 48869, 48876, 48897, 48904, 48905,
48920, 48921, 48923, 48924, 48925, 48960, 48961, 48964, 48968, 48976, 48977, 48981, 49044,
49072, 49093, 49100, 49101, 49104, 49108, 49116, 49119, 49121, 49212, 49233, 49240, 49244,
49248, 49256, 49257, 49296, 49297, 49300, 49304, 49312, 49313, 49315, 49317, 49324, 49325,
49327, 49328, 49331, 49332, 49333, 49334, 49340, 49341, 49343, 49344, 49345, 49349, 49352,
49353, 49356, 49360, 49368, 49369, 49371, 49372, 49373, 49380, 49381, 49384, 49388, 49396,
49397, 49399, 49401, 49408, 49412, 49416, 49424, 49429, 49436, 49437, 49438, 49439, 49440,
49443, 49444, 49446, 49447, 49452, 49453, 49455, 49456, 49457, 49462, 49464, 49465, 49468,
49472, 49480, 49481, 49483, 49484, 49485, 49492, 49493, 49496, 49500, 49508, 49509, 49511,
49512, 49513, 49520, 49524, 49528, 49541, 49548, 49549, 49550, 49552, 49556, 49558, 49564,
49565, 49567, 49569, 49573, 49576, 49577, 49580, 49584, 49597, 49604, 49608, 49612, 49620,
49623, 49624, 49632, 49636, 49640, 49648, 49649, 49651, 49660, 49661, 49664, 49668, 49676,
49677, 49679, 49681, 49688, 49689, 49692, 49695, 49696, 49704, 49705, 49707, 49709, 49711,
49713, 49714, 49716, 49736, 49744, 49745, 49748, 49752, 49760, 49765, 49772, 49773, 49776,
49780, 49788, 49789, 49791, 49793, 49800, 49801, 49808, 49816, 49819, 49821, 49828, 49829,
49832, 49836, 49837, 49844, 49845, 49847, 49849, 49884, 49885, 49888, 49891, 49892, 49899,
49900, 49901, 49903, 49905, 49910, 49912, 49913, 49915, 49916, 49920, 49928, 49929, 49932,
49933, 49939, 49940, 49941, 49944, 49948, 49956, 49957, 49960, 49961, 49989, 50024, 50025,
50028, 50032, 50034, 50040, 50041, 50044, 50045, 50052, 50056, 50060, 50112, 50136, 50137,
50140, 50143, 50144, 50146, 50152, 50153, 50157, 50164, 50165, 50168, 50184, 50192, 50212,
50220, 50224, 50228, 50236, 50237, 50248, 50276, 50277, 50280, 50284, 50292, 50293, 50297,
50304, 50324, 50332, 50360, 50364, 50409, 50416, 50417, 50420, 50424, 50426, 50431, 50432,
50433, 50444, 50448, 50452, 50460, 50472, 50473, 50476, 50480, 50488, 50489, 50491, 50493,
50500, 50501, 50504, 50505, 50506, 50508, 50509, 50510, 50515, 50516, 50517, 50519, 50520,
50521, 50525, 50526, 50528, 50529, 50532, 50536, 50544, 50545, 50547, 50548, 50549, 50556,
50557, 50560, 50564, 50567, 50572, 50573, 50575, 50577, 50581, 50583, 50584, 50588, 50592,
50601, 50612, 50613, 50616, 50617, 50619, 50620, 50621, 50622, 50628, 50629, 50630, 50631,
50632, 50633, 50634, 50636, 50638, 50640, 50641, 50644, 50648, 50656, 50657, 50659, 50661,
50668, 50669, 50670, 50672, 50676, 50678, 50679, 50684, 50685, 50686, 50687, 50688, 50689,
50693, 50694, 50695, 50696, 50700, 50704, 50712, 50713, 50715, 50716, 50724, 50725, 50728,
50732, 50733, 50734, 50736, 50739, 50740, 50741, 50743, 50745, 50747, 50752, 50753, 50756,
50760, 50768, 50769, 50771, 50772, 50773, 50780, 50781, 50784, 50796, 50799, 50801, 50808,
50809, 50812, 50816, 50824, 50825, 50827, 50829, 50836, 50837, 50840, 50844, 50852, 50853,
50855, 50857, 50864, 50865, 50868, 50872, 50873, 50874, 50880, 50881, 50883, 50885, 50892,
50893, 50896, 50900, 50908, 50909, 50912, 50913, 50920, 50921, 50924, 50928, 50936, 50937,
50941, 50948, 50949, 50952, 50956, 50964, 50965, 50967, 50969, 50976, 50977, 50980, 50984,
50992, 50993, 50995, 50997, 50999, 51004, 51005, 51008, 51012, 51018, 51020, 51021, 51023,
51025, 51026, 51027, 51028, 51029, 51030, 51031, 51032, 51036, 51040, 51048, 51051, 51060,
51061, 51064, 51068, 51069, 51070, 51075, 51076, 51077, 51079, 51080, 51081, 51082, 51086,
51088, 51089, 51092, 51094, 51095, 51096, 51098, 51104, 51105, 51107, 51108, 51109, 51110,
51116, 51117, 51120, 51124, 51132, 51133, 51135, 51136, 51137, 51144, 51145, 51148, 51150,
51152, 51160, 51165, 51172, 51176, 51180, 51200, 51201, 51204, 51208, 51210, 51216, 51217,
51219, 51221, 51222, 51228, 51229, 51232, 51236, 51244, 51245, 51247, 51249, 51256, 51260,
51264, 51272, 51273, 51276, 51277, 51284, 51312, 51313, 51316, 51320, 51322, 51328, 51329,
51331, 51333, 51334, 51335, 51339, 51340, 51341, 51348, 51357, 51359, 51361, 51368, 51388,
51389, 51396, 51400, 51404, 51412, 51413, 51415, 51417, 51424, 51425, 51428, 51445, 51452,
51453, 51456, 51460, 51461, 51462, 51468, 51469, 51471, 51473, 51480, 51500, 51508, 51536,
51537, 51540, 51544, 51552, 51553, 51555, 51564, 51568, 51572, 51580, 51592, 51593, 51596,
51600, 51608, 51609, 51611, 51613, 51648, 51649, 51652, 51655, 51656, 51658, 51664, 51665,
51667, 51669, 51670, 51673, 51674, 51676, 51677, 51680, 51682, 51684, 51687, 51692, 51693,
51695, 51696, 51697, 51704, 51705, 51708, 51712, 51720, 51721, 51723, 51724, 51725, 51732,
51736, 51753, 51788, 51789, 51792, 51796, 51804, 51805, 51807, 51808, 51809, 51816, 51837,
51844, 51864, 51900, 51901, 51904, 51908, 51916, 51917, 51919, 51921, 51923, 51928, 51929,
51936, 51948, 51956, 51976, 51984, 51988, 51992, 52000, 52001, 52033, 52040, 52041, 52044,
52048, 52056, 52057, 52061, 52068, 52088, 52089, 52124, 52152, 52180, 52196, 52199, 52201,
52236, 52237, 52240, 52244, 52252, 52253, 52257, 52258, 52263, 52264, 52265, 52268, 52270,
52272, 52280, 52281, 52283, 52284, 52285, 52286, 52292, 52293, 52296, 52300, 52308, 52309,
52311, 52312, 52313, 52320, 52324, 52326, 52328, 52336, 52341, 52376, 52377, 52380, 52384,
52392, 52393, 52395, 52396, 52397, 52404, 52405, 52408, 52412, 52420, 52421, 52423, 52425,
52432, 52436, 52452, 52460, 52464, 52481, 52488, 52489, 52492, 52496, 52504, 52505, 52507,
52509, 52516, 52520, 52524, 52537, 52572, 52576, 52580, 52588, 52589, 52591, 52593, 52600,
52616, 52628, 52629, 52632, 52636, 52644, 52645, 52647, 52649, 52656, 52676, 52684, 52688,
52712, 52716, 52720, 52728, 52729, 52731, 52733, 52740, 52744, 52748, 52756, 52761, 52768,
52769, 52772, 52776, 52784, 52785, 52787, 52789, 52824, 52825, 52828, 52831, 52832, 52833,
52840, 52841, 52843, 52845, 52852, 52853, 52856, 52860, 52868, 52869, 52871, 52873, 52880,
52881, 52884, 52888, 52896, 52897, 52899, 52900, 52901, 52908, 52909, 52929, 52964, 52965,
52968, 52971, 52972, 52980, 52981, 52983, 52984, 52985, 52992, 52993, 52996, 53000, 53008,
53009, 53011, 53013, 53020, 53024, 53028, 53036, 53037, 53039, 53040, 53041, 53048, 53076,
53077, 53080, 53084, 53092, 53093, 53095, 53097, 53104, 53105, 53108, 53112, 53120, 53125,
53132, 53153, 53160, 53168, 53188, 53216, 53217, 53220, 53224, 53232, 53233, 53235, 53237,
53244, 53248, 53252, 53265, 53272, 53293, 53300, 53301, 53304, 53308, 53316, 53317, 53319,
53321, 53328, 53332, 53336, 53344, 53356, 53357, 53360, 53364, 53372, 53373, 53377, 53412,
53413, 53416, 53420, 53428, 53429, 53431, 53433, 53440, 53441, 53444, 53448, 53449, 53456,
53457, 53459, 53460, 53461, 53468, 53469, 53472, 53476, 53484, 53485, 53487, 53488, 53489,
53496, 53517, 53552, 53553, 53556, 53560, 53562, 53568, 53569, 53571, 53572, 53573, 53580,
53581, 53584, 53588, 53596, 53597, 53599, 53601, 53608, 53612, 53628, 53636, 53640, 53664,
53665, 53668, 53672, 53680, 53681, 53683, 53685, 53690, 53692, 53696, 53720, 53748, 53752,
53767, 53769, 53776, 53804, 53805, 53808, 53812, 53820, 53821, 53823, 53825, 53832, 53852,
53860, 53888, 53889, 53892, 53896, 53904, 53905, 53909, 53916, 53920, 53924, 53932, 53937,
53944, 53945, 53948, 53951, 53952, 53954, 53960, 53961, 53963, 53972, 53976, 53980, 53988,
53989, 54000, 54001, 54004, 54008, 54016, 54017, 54019, 54021, 54028, 54029, 54030, 54032,
54036, 54038, 54044, 54045, 54047, 54048, 54049, 54053, 54056, 54057, 54060, 54064, 54072,
54073, 54075, 54076, 54077, 54084, 54085, 54140, 54141, 54144, 54148, 54156, 54157, 54159,
54160, 54161, 54168, 54169, 54172, 54176, 54184, 54185, 54187, 54189, 54196, 54200, 54204,
54212, 54213, 54216, 54217, 54224, 54232, 54241, 54243, 54252, 54253, 54256, 54260, 54268,
54269, 54271, 54273, 54280, 54301, 54336, 54340, 54364, 54368, 54372, 54381, 54383, 54392,
54393, 54396, 54399, 54400, 54402, 54408, 54409, 54411, 54413, 54420, 54441, 54476, 54480,
54484, 54492, 54495, 54504, 54508, 54512, 54520, 54523, 54525, 54532, 54536, 54540, 54548,
54549, 54551, 54588, 54589, 54592, 54596, 54604, 54605, 54607, 54609, 54616, 54617, 54620,
54624, 54629, 54632, 54633, 54635, 54637, 54644, 54645, 54648, 54652, 54660, 54661, 54663,
54664, 54665, 54672, 54693, 54728, 54729, 54732, 54736, 54738, 54744, 54745, 54747, 54749,
54756, 54757, 54760, 54764, 54772, 54773, 54775, 54777, 54784, 54785, 54788, 54792, 54800,
54801, 54803, 54804, 54805, 54812, 54816, 54820, 54829, 54840, 54841, 54844, 54848, 54853,
54856, 54857, 54859, 54861, 54865, 54868, 54869, 54872, 54876, 54887, 54889, 54896, 54897,
54900, 54915, 54917, 54924, 54925, 54928, 54932, 54941, 54943, 54945, 54952, 54956, 54960,
54969, 54971, 54980, 54981, 54984, 54988, 54993, 54996, 54999, 55001, 55008, 55012, 55016,
55024, 55029, 55036, 55037, 55040, 55044, 55057, 55064, 55065, 55068, 55072, 55080, 55081,
55083, 55085, 55092, 55093, 55096, 55100, 55108, 55111, 55113, 55120, 55121, 55124, 55126,
55127, 55128, 55129, 55136, 55137, 55139, 55141, 55145, 55148, 55152, 55156, 55164, 55165,
55169, 55176, 55177, 55180, 55184, 55192, 55193, 55195, 55197, 4352, 4353, 4354, 4355, 4356,
4357, 4358, 4359, 4360, 4361, 4362, 4363, 4364, 4365, 4366, 4367, 4368, 4369, 4370, 4449,
4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4461, 4462, 4466, 4467, 4469, 47252, 49968,
50108, 50388, 52012, 65535};
}
#endif
| 40,972
|
C++
|
.h
| 436
| 85.529817
| 100
| 0.637611
|
FlagBrew/PKSM-Core
| 35
| 9
| 2
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,373
|
BJumblrGUI.cpp
|
sjaehn_BJumblr/src/BJumblrGUI.cpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "BJumblrGUI.hpp"
#include "BUtilities/to_string.hpp"
#include "BUtilities/Path.hpp"
#include "BUtilities/vsystem.hpp"
#include "MessageDefinitions.hpp"
#include "MidiDefs.hpp"
inline double floorfrac (const double value) {return value - floor (value);}
inline double floormod (const double numer, const double denom) {return numer - floor(numer / denom) * denom;}
BJumblrGUI::BJumblrGUI (const char *bundle_path, const LV2_Feature *const *features, PuglNativeView parentWindow) :
Window (1020, 620, "B.Jumblr", parentWindow, true, PUGL_MODULE, 0),
controller (NULL), write_function (NULL),
pluginPath (bundle_path ? std::string (bundle_path) : std::string ("")),
sz (1.0), bgImageSurface (nullptr),
uris (), forge (), editMode (0),
patternFlipped (false),
clipBoard (),
cursor (0), wheelScrolled (false), padPressed (false), deleteMode (false),
samplePath ("."), sampleStart (0), sampleEnd (0), sampleLoop (false),
actPage (0), nrPages (1), pageOffset (0),
mContainer (0, 0, 1020, 620, "main"),
messageLabel (400, 45, 600, 20, "ctlabel", ""),
pageWidget (18, 86, 504, 30, "widget", 0.0),
pageBackSymbol (0, 0, 10, 30, "tab", LEFTSYMBOL),
pageForwardSymbol (482, 0, 10, 30, "tab", RIGHTSYMBOL),
sourceLabel (510, 95, 60, 10, "ylabel", BJUMBLR_LABEL_SOURCE),
calibrationLabel (405, 577, 80, 10, "ylabel", BJUMBLR_LABEL_CALIBRATION),
stepEditModeLabel (535, 577, 80, 10, "ylabel", BJUMBLR_LABEL_STEP_EDIT_MODE),
stepSizeLabel (690, 577, 80, 10, "ylabel", BJUMBLR_LABEL_STEP_SIZE),
patternSizeLabel (850, 577, 80, 10, "ylabel", BJUMBLR_LABEL_PATTERN_SIZE),
padLevelLabel (950, 120, 60, 10, "ylabel", BJUMBLR_LABEL_PAD_LEVEL),
playbackLabel (950, 350, 60, 10, "ylabel", BJUMBLR_LABEL_PLAYBACK),
speedLabel (950, 515, 60, 10, "ylabel", BJUMBLR_LABEL_SPEED),
midiBox (18, 118, 510, 120, "screen", 0),
midiText (20, 10, 450, 20, "tlabel", BJUMBLR_LABEL_MIDI_PAGE " #1"),
midiStatusLabel (10, 30, 130, 20, "ylabel", BJUMBLR_LABEL_MIDI_STATUS),
midiStatusListBox
(
10, 50, 130, 20, 0, 20, 130, 100, "menu",
BItems::ItemList ({{0, BJUMBLR_LABEL_NONE}, {9, BJUMBLR_LABEL_NOTE_ON}, {8, BJUMBLR_LABEL_NOTE_OFF}, {11, BJUMBLR_LABEL_CC}}),
0
),
midiChannelLabel (150, 30, 50, 20, "ylabel", BJUMBLR_LABEL_CHANNEL),
midiChannelListBox
(
150, 50, 50, 20, 0, 20, 50, 360, "menu",
BItems::ItemList
({
{0, BJUMBLR_LABEL_ALL}, {1, "1"}, {2, "2"}, {3, "3"},
{4, "4"}, {5, "5"}, {6, "6"}, {7, "7"},
{8, "8"}, {9, "9"}, {10, "10"}, {11, "11"},
{12, "12"}, {13, "13"}, {14, "14"}, {15, "15"}, {16, "16"}
}),
0
),
midiNoteLabel (210, 30, 160, 20, "ylabel", BJUMBLR_LABEL_NOTE),
midiNoteListBox (210, 50, 160, 20, 0, 20, 160, 360, "menu", BItems::ItemList ({NOTELIST}), 128),
midiValueLabel (380, 30, 50, 20, "ylabel", BJUMBLR_LABEL_VALUE),
midiValueListBox (380, 50, 50, 20, 0, 20, 50, 360, "menu", BItems::ItemList ({VALLIST}), 128),
midiLearnButton (440, 50, 60, 20, "menu/button", BJUMBLR_LABEL_LEARN),
midiCancelButton (170, 90, 60, 20, "menu/button", BJUMBLR_LABEL_CANCEL),
midiOkButton (280, 90, 60, 20, "menu/button", BJUMBLR_LABEL_OK),
flipButton (940, 120, 10, 10, "widget"),
padSurface (18, 128, 924, 434, "box"),
markerFwd (0, 130 + 15.5 * (430.0 / 16.0) - 10, 20, 20, "widget", MARKER_RIGHT),
markerRev (940, 130 + 15.5 * (430.0 / 16.0) - 10, 20, 20, "widget", MARKER_LEFT),
monitorWidget (20, 130, 920, 430, "monitor"),
sourceListBox (570, 90, 120, 20, 120, 60, "menu", BItems::ItemList ({{0, BJUMBLR_LABEL_AUDIO_STREAM}, {1, BJUMBLR_LABEL_SAMPLE}}), 0),
loadButton (710, 90, 20, 20, "menu/button"),
sampleNameLabel (740, 90, 160, 20, "boxlabel", ""),
sampleAmpDial (918, 88, 24, 24, "dial", 1.0, 0.0, 1.0, 0.0),
playButton (18, 588, 24, 24, "widget", BJUMBLR_LABEL_PLAY),
bypassButton (48, 588, 24, 24, "widget", BJUMBLR_LABEL_BYPASS),
stopButton (78, 588, 24, 24, "widget", BJUMBLR_LABEL_STOP),
syncWidget (400, 590, 95, 20, "widget", 0),
zeroStepOffsetButton (0, 0, 20, 20, "menu/button"),
decStepOffsetButton (25, 0, 20, 20, "menu/button"),
hostSyncButton (50, 0, 20, 20, "menu/button"),
incStepOffsetButton (75, 0, 20, 20, "menu/button"),
editModeListBox (530, 590, 90, 20, 0, -60, 90, 60, "menu",
BItems::ItemList ({{0, BJUMBLR_LABEL_ADD}, {1, BJUMBLR_LABEL_REPLACE}}), 0),
stepSizeListBox (650, 590, 70, 20, 0, -280, 70, 280, "menu",
BItems::ItemList ({{0.0625, "1/16"}, {0.83333333, "1/12"}, {0.125, "1/8"}, {0.1666667, "1/6"},
{0.25, "1/4"}, {0.3333333, "1/3"}, {0.5, "1/2"}, {0.666666667, "2/3"}, {0.75, "3/4"},
{1, "1"}, {2, "2"}, {2, "3"}, {4, "4"}}), 1),
stepBaseListBox (730, 590, 90, 20, 0, -80, 90, 80, "menu", BItems::ItemList ({{0, BJUMBLR_LABEL_SECONDS}, {1, BJUMBLR_LABEL_BEATS}, {2, BJUMBLR_LABEL_BARS}}), 1),
padSizeListBox (850, 590, 90, 20, 0, -240, 100, 240, "menu",
BItems::ItemList ({{2, "2 " BJUMBLR_LABEL_STEPS}, {3, "3 " BJUMBLR_LABEL_STEPS}, {4, "4 " BJUMBLR_LABEL_STEPS},
{6, "6 " BJUMBLR_LABEL_STEPS}, {8, "8 " BJUMBLR_LABEL_STEPS}, {9, "9 " BJUMBLR_LABEL_STEPS},
{12, "12 " BJUMBLR_LABEL_STEPS}, {16, "16 " BJUMBLR_LABEL_STEPS}, {18, "18 " BJUMBLR_LABEL_STEPS},
{24, "24 " BJUMBLR_LABEL_STEPS}, {32, "32 " BJUMBLR_LABEL_STEPS}}), 16),
levelDial (960, 290, 40, 48, "dial", 1.0, 0.0, 1.0, 0.01, "%1.2f"),
delayDisplayLabel (958, 370, 44, 20, "smboxlabel", ""),
manualProgressionDelayWidget (0, 0, 0, 0, "widget", 0.0, -32.0, 32.0, 0.0),
resetDelayButton (958, 398, 44, 22, "widget", BJUMBLR_LABEL_RESET_DELAY),
increaseDelayButton (958, 428, 44, 22, "widget", BJUMBLR_LABEL_INCREASE_DELAY),
decreaseDelayButton (958, 488, 44, 22, "widget", BJUMBLR_LABEL_DECREASE_DELAY),
setStartDelayButton (958, 458, 44, 22, "widget", BJUMBLR_LABEL_DELAY_TO_START),
speedDial (960, 530, 40, 48, "dial", 1.0, 0.0, 4.0, 0.25, "%1.2f"),
helpButton (958, 588, 24, 24, "widget", BJUMBLR_LABEL_HELP),
ytButton (988, 588, 24, 24, "widget", BJUMBLR_LABEL_TUTORIAL),
fileChooser (nullptr)
{
// Init tabs
for (int i = 0; i < MAXPAGES; ++i)
{
tabs[i].container = BWidgets::Widget (i * 80, 0, 78, 30, "tab");
tabs[i].icon = BWidgets::ImageIcon (0, 8, 40, 20, "widget", pluginPath + "inc/page" + std::to_string (i + 1) + ".png");
tabs[i].playSymbol = SymbolWidget (40, 12, 20, 12, "symbol", PLAYSYMBOL);
tabs[i].midiSymbol = SymbolWidget (60, 12, 20, 12, "symbol", MIDISYMBOL);
for (int j = 0; j < 4; ++j) tabs[i].symbols[j] = SymbolWidget (68 - j * 10, 2, 8, 8, "symbol", SWSymbol(j));
for (int j = 0; j < 4; ++j) tabs[i].midiWidgets[j] = BWidgets::ValueWidget (0, 0, 0, 0, "widget", 0);
}
// Init editButtons
for (int i = 0; i < EDIT_RESET; ++i) edit1Buttons[i] = HaloToggleButton (128 + i * 30, 588, 24, 24, "widget", editLabels[i]);
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i) edit2Buttons[i] = HaloButton (298 + i * 30, 588, 24, 24, "widget", editLabels[i + EDIT_RESET]);
for (int i = 0; i < 5; ++i) levelButtons[i] = HaloToggleButton (958, 138 + i * 30, 44, 22, "widget", BUtilities::to_string (1.0 - 0.25 * double(i), "%1.2f"));
levelButtons[0].setValue (1.0);
// Link controllerWidgets
controllerWidgets[SOURCE] = (BWidgets::ValueWidget*) &sourceListBox;
controllerWidgets[PLAY] = (BWidgets::ValueWidget*) &playButton;
controllerWidgets[NR_OF_STEPS] = (BWidgets::ValueWidget*) &padSizeListBox;
controllerWidgets[STEP_SIZE] = (BWidgets::ValueWidget*) &stepSizeListBox;
controllerWidgets[STEP_BASE] = (BWidgets::ValueWidget*) &stepBaseListBox;
controllerWidgets[STEP_OFFSET] = (BWidgets::ValueWidget*) &syncWidget;
controllerWidgets[MANUAL_PROGRSSION_DELAY] = (BWidgets::ValueWidget*) &manualProgressionDelayWidget;
controllerWidgets[SPEED] = (BWidgets::ValueWidget*) &speedDial;
controllerWidgets[PAGE] = (BWidgets::ValueWidget*) &pageWidget;
for (int i = 0; i < MAXPAGES; ++i)
{
for (int j = 0; j < 4; ++j) controllerWidgets[MIDI + i * 4 + j] = (BWidgets::ValueWidget*) &tabs[i].midiWidgets[j];
}
// Init controller values
for (int i = 0; i < MAXCONTROLLERS; ++i) controllers[i] = controllerWidgets[i]->getValue ();
// Set callback functions
for (int i = 0; i < MAXCONTROLLERS; ++i) controllerWidgets[i]->setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
bypassButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
stopButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
syncWidget.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
zeroStepOffsetButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, syncButtonClickedCallback);
decStepOffsetButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, syncButtonClickedCallback);
hostSyncButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, syncButtonClickedCallback);
incStepOffsetButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, syncButtonClickedCallback);
editModeListBox.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
for (int i = 0; i < EDIT_RESET; ++i) edit1Buttons[i].setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, edit1ChangedCallback);
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i) edit2Buttons[i].setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, edit2ChangedCallback);
for (int i = 0; i < 5; ++i) levelButtons[i].setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, levelChangedCallback);
levelDial.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, levelChangedCallback);
resetDelayButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, delayButtonsClickedCallback);
increaseDelayButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, delayButtonsClickedCallback);
decreaseDelayButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, delayButtonsClickedCallback);
setStartDelayButton.setCallbackFunction (BEvents::VALUE_CHANGED_EVENT, delayButtonsClickedCallback);
helpButton.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, helpButtonClickedCallback);
ytButton.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, ytButtonClickedCallback);
loadButton.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, loadButtonClickedCallback);
sampleNameLabel.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, loadButtonClickedCallback);
sampleAmpDial.setCallbackFunction(BEvents::VALUE_CHANGED_EVENT, valueChangedCallback);
pageBackSymbol.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, pageScrollClickedCallback);
pageForwardSymbol.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, pageScrollClickedCallback);
for (Tab& t : tabs)
{
t.container.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, pageClickedCallback);
t.playSymbol.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, pagePlayClickedCallback);
t.midiSymbol.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, midiSymbolClickedCallback);
for (SymbolWidget& s : t.symbols) s.setCallbackFunction(BEvents::BUTTON_PRESS_EVENT, pageSymbolClickedCallback);
}
midiLearnButton.setCallbackFunction(BEvents::VALUE_CHANGED_EVENT, midiButtonClickedCallback);
midiCancelButton.setCallbackFunction(BEvents::VALUE_CHANGED_EVENT, midiButtonClickedCallback);
midiOkButton.setCallbackFunction(BEvents::VALUE_CHANGED_EVENT, midiButtonClickedCallback);
midiStatusListBox.setCallbackFunction(BEvents::VALUE_CHANGED_EVENT, midiStatusChangedCallback);
padSurface.setDraggable (true);
padSurface.setCallbackFunction (BEvents::BUTTON_PRESS_EVENT, padsPressedCallback);
padSurface.setCallbackFunction (BEvents::BUTTON_RELEASE_EVENT, padsPressedCallback);
padSurface.setCallbackFunction (BEvents::POINTER_DRAG_EVENT, padsPressedCallback);
padSurface.setScrollable (true);
padSurface.setCallbackFunction (BEvents::WHEEL_SCROLL_EVENT, padsScrolledCallback);
padSurface.setFocusable (true);
padSurface.setCallbackFunction (BEvents::FOCUS_IN_EVENT, padsFocusedCallback);
padSurface.setCallbackFunction (BEvents::FOCUS_OUT_EVENT, padsFocusedCallback);
flipButton.setClickable (true);
flipButton.setCallbackFunction (BEvents::BUTTON_CLICK_EVENT, patternFlippedClickedCallback);
// Configure widgets
loadButton.hide();
sampleNameLabel.hide();
sampleAmpDial.hide();
midiBox.hide();
pageBackSymbol.setFocusable (false);
pageForwardSymbol.setFocusable (false);
pageBackSymbol.hide();
pageForwardSymbol.hide();
for (int i = 0; i < MAXPAGES; ++i)
{
tabs[i].playSymbol.setState (BColors::INACTIVE);
tabs[i].midiSymbol.setState (BColors::INACTIVE);
for (int j = 0; j < 4; ++j) tabs[i].symbols[j].setState (BColors::ACTIVE);
if (i > 0) tabs[i].container.hide();
}
tabs[0].container.rename ("activetab");
tabs[0].playSymbol.setState (BColors::ACTIVE);
tabs[0].symbols[CLOSESYMBOL].hide(); // -
tabs[0].symbols[LEFTSYMBOL].hide(); // <
tabs[0].symbols[RIGHTSYMBOL].hide(); // >
for (Tab& t : tabs) t.icon.setClickable (false);
for (Pattern& p : pattern) p.clear();
// Load background & apply theme
bgImageSurface = cairo_image_surface_create_from_png ((pluginPath + BG_FILE).c_str());
for (int i = 0; i < 5; ++i)
{
BColors::Color col = BColors::yellow;
col.applyBrightness (- 0.25 * double(i));
drawButton (bgImageSurface, 960, 140 + i * 30, 40, 18, col);
}
BColors::Color col = BColors::white;
col.applyBrightness (- 0.25);
drawButton (bgImageSurface, 960, 400, 40, 18, col, BUTTON_HOME_SYMBOL);
drawButton (bgImageSurface, 960, 430, 40, 18, col, BUTTON_UP_SYMBOL);
drawButton (bgImageSurface, 960, 490, 40, 18, col, BUTTON_DOWN_SYMBOL);
drawButton (bgImageSurface, 960, 460, 40, 18, col, BUTTON_BOTTOM_SYMBOL);
widgetBg.loadFillFromCairoSurface (bgImageSurface);
applyTheme (theme);
// Pack widgets
mContainer.add (sourceLabel);
mContainer.add (calibrationLabel);
mContainer.add (stepEditModeLabel);
mContainer.add (stepSizeLabel);
mContainer.add (patternSizeLabel);
mContainer.add (padLevelLabel);
mContainer.add (playbackLabel);
mContainer.add (speedLabel);
mContainer.add (messageLabel);
mContainer.add (pageWidget);
pageWidget.add (pageBackSymbol);
pageWidget.add (pageForwardSymbol);
for (int i = MAXPAGES - 1; i >= 0; --i)
{
Tab& t = tabs[i];
t.container.add (t.icon);
for (SymbolWidget& s : t.symbols) t.container.add (s);
for (BWidgets::ValueWidget& m : t.midiWidgets) t.container.add (m);
t.container.add (t.playSymbol);
t.container.add (t.midiSymbol);
pageWidget.add (t.container);
}
mContainer.add (playButton);
mContainer.add (bypassButton);
mContainer.add (stopButton);
for (int i = 0; i < EDIT_RESET; ++i) mContainer.add (edit1Buttons[i]);
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i) mContainer.add (edit2Buttons[i]);
syncWidget.add (zeroStepOffsetButton);
syncWidget.add (decStepOffsetButton);
syncWidget.add (hostSyncButton);
syncWidget.add (incStepOffsetButton);
mContainer.add (syncWidget);
mContainer.add (editModeListBox);
mContainer.add (stepSizeListBox);
mContainer.add (stepBaseListBox);
mContainer.add (padSizeListBox);
mContainer.add (padSurface);
mContainer.add (flipButton);
mContainer.add (markerFwd);
mContainer.add (markerRev);
mContainer.add (monitorWidget);
for (int i = 0; i < 5; ++i) mContainer.add (levelButtons[i]);
mContainer.add (sourceListBox);
mContainer.add (loadButton);
mContainer.add (sampleNameLabel);
mContainer.add (sampleAmpDial);
mContainer.add (levelDial);
mContainer.add (delayDisplayLabel);
mContainer.add (manualProgressionDelayWidget);
mContainer.add (resetDelayButton);
mContainer.add (increaseDelayButton);
mContainer.add (decreaseDelayButton);
mContainer.add (setStartDelayButton);
mContainer.add (speedDial);
mContainer.add (helpButton);
mContainer.add (ytButton);
mContainer.add (midiBox);
midiBox.add (midiText);
midiBox.add (midiStatusLabel);
midiBox.add (midiStatusListBox);
midiBox.add (midiChannelLabel);
midiBox.add (midiChannelListBox);
midiBox.add (midiNoteLabel);
midiBox.add (midiNoteListBox);
midiBox.add (midiValueLabel);
midiBox.add (midiValueListBox);
midiBox.add (midiLearnButton);
midiBox.add (midiCancelButton);
midiBox.add (midiOkButton);
drawPad();
add (mContainer);
getKeyGrabStack()->add (this);
for (Pattern& p : pattern) p.clear ();
//Scan host features for URID map
LV2_URID_Map* map = NULL;
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_URID__map) == 0)
{
map = (LV2_URID_Map*) features[i]->data;
}
}
if (!map) throw std::invalid_argument ("Host does not support urid:map");
//Map URIS
getURIs (map, &uris);
// Initialize forge
lv2_atom_forge_init (&forge, map);
}
BJumblrGUI::~BJumblrGUI ()
{
if (fileChooser) delete fileChooser;
send_ui_off ();
}
void BJumblrGUI::Pattern::clear ()
{
Pad pad0 = Pad ();
changes.oldMessage.clear ();
changes.newMessage.clear ();
journal.clear ();
for (int r = 0; r < MAXSTEPS; ++r)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
setPad (r, s, pad0);
}
}
store ();
}
Pad BJumblrGUI::Pattern::getPad (const size_t row, const size_t step) const
{
return pads[LIMIT (row, 0, MAXSTEPS)][LIMIT (step, 0, MAXSTEPS)];
}
void BJumblrGUI::Pattern::setPad (const size_t row, const size_t step, const Pad& pad)
{
size_t r = LIMIT (row, 0, MAXSTEPS);
size_t s = LIMIT (step, 0, MAXSTEPS);
changes.oldMessage.push_back (PadMessage (s, r, pads[r][s]));
changes.newMessage.push_back (PadMessage (s, r, pad));
pads[r][s] = pad;
}
std::vector<PadMessage> BJumblrGUI::Pattern::undo ()
{
if (!changes.newMessage.empty ()) store ();
std::vector<PadMessage> padMessages = journal.undo ();
std::reverse (padMessages.begin (), padMessages.end ());
for (PadMessage const& p : padMessages)
{
size_t r = LIMIT (p.row, 0, MAXSTEPS);
size_t s = LIMIT (p.step, 0, MAXSTEPS);
pads[r][s] = Pad (p);
}
return padMessages;
}
std::vector<PadMessage> BJumblrGUI::Pattern::redo ()
{
if (!changes.newMessage.empty ()) store ();
std::vector<PadMessage> padMessages = journal.redo ();
for (PadMessage const& p : padMessages)
{
size_t r = LIMIT (p.row, 0, MAXSTEPS);
size_t s = LIMIT (p.step, 0, MAXSTEPS);
pads[r][s] = Pad (p);
}
return padMessages;
}
void BJumblrGUI::Pattern::store ()
{
if (changes.newMessage.empty ()) return;
journal.push (changes.oldMessage, changes.newMessage);
changes.oldMessage.clear ();
changes.newMessage.clear ();
}
void BJumblrGUI::port_event(uint32_t port, uint32_t buffer_size,
uint32_t format, const void* buffer)
{
// Notify port
if ((format == uris.atom_eventTransfer) && (port == NOTIFY))
{
const LV2_Atom* atom = (const LV2_Atom*) buffer;
if ((atom->type == uris.atom_Blank) || (atom->type == uris.atom_Object))
{
const LV2_Atom_Object* obj = (const LV2_Atom_Object*) atom;
// Pad notification
if (obj->body.otype == uris.notify_padEvent)
{
LV2_Atom *oEdit = NULL, *oPage = NULL, *oPad = NULL, *oFull = NULL;
int page = -1;
lv2_atom_object_get(obj,
uris.notify_editMode, &oEdit,
uris.notify_padPage, &oPage,
uris.notify_pad, &oPad,
uris.notify_padFullPattern, &oFull,
NULL);
if (oEdit && (oEdit->type == uris.atom_Int))
{
editModeListBox.setValue (((LV2_Atom_Int*)oEdit)->body);
}
if (oPage && (oPage->type == uris.atom_Int))
{
page = (((LV2_Atom_Int*)oPage)->body);
while (page >= nrPages) pushPage();
}
if (oPad && (oPad->type == uris.atom_Vector) && (page >= 0) && (page < MAXPAGES))
{
const LV2_Atom_Vector* vec = (const LV2_Atom_Vector*) oPad;
if (vec->body.child_type == uris.atom_Float)
{
if (wheelScrolled)
{
pattern[page].store ();
wheelScrolled = false;
}
uint32_t size = (uint32_t) ((oPad->size - sizeof(LV2_Atom_Vector_Body)) / sizeof (PadMessage));
PadMessage* pMes = (PadMessage*)(&vec->body + 1);
for (unsigned int i = 0; i < size; ++i)
{
int step = (int) pMes[i].step;
int row = (int) pMes[i].row;
if ((step >= 0) && (step < MAXSTEPS) && (row >= 0) && (row < MAXSTEPS))
{
pattern[page].setPad (row, step, Pad (pMes[i]));
}
}
pattern[page].store ();
if (page == actPage) drawPad ();
}
}
if (oFull && (oFull->type == uris.atom_Vector) && (page >= 0) && (page < MAXPAGES))
{
const LV2_Atom_Vector* vec = (const LV2_Atom_Vector*) oFull;
if (vec->body.child_type == uris.atom_Float)
{
if (wheelScrolled)
{
pattern[page].store ();
wheelScrolled = false;
}
uint32_t size = (uint32_t) ((oFull->size - sizeof(LV2_Atom_Vector_Body)) / sizeof (Pad));
Pad* data = (Pad*)(&vec->body + 1);
if (size == MAXSTEPS * MAXSTEPS)
{
// Copy pattern data
for (int r = 0; r < MAXSTEPS; ++r)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
pattern[page].setPad (r, s, data[r * MAXSTEPS + s]);
}
}
}
pattern[page].store ();
if (page == actPage) drawPad ();
}
}
}
// Message notification
else if (obj->body.otype == uris.notify_messageEvent)
{
const LV2_Atom* data = NULL;
lv2_atom_object_get(obj, uris.notify_message, &data, 0);
if (data && (data->type == uris.atom_Int))
{
const int messageNr = ((LV2_Atom_Int*)data)->body;
std::string msg = ((messageNr >= NO_MSG) && (messageNr < MAXMESSAGES) ? messageStrings[messageNr] : "");
messageLabel.setText (msg);
}
}
// Path notification
else if (obj->body.otype == uris.notify_pathEvent)
{
const LV2_Atom* oPath = NULL, *oStart = NULL, *oEnd = NULL, *oAmp = NULL, *oLoop = NULL;
lv2_atom_object_get
(
obj,
uris.notify_samplePath, &oPath,
uris.notify_sampleStart, &oStart,
uris.notify_sampleEnd, &oEnd,
uris.notify_sampleAmp, &oAmp,
uris.notify_sampleLoop, &oLoop,
0
);
if (oPath && (oPath->type == uris.atom_Path))
{
const BUtilities::Path p = BUtilities::Path ((const char*)LV2_ATOM_BODY_CONST(oPath));
samplePath = p.dir();
sampleNameLabel.setText (p.filename());
}
if (oStart && (oStart->type == uris.atom_Long)) sampleStart = ((LV2_Atom_Long*)oStart)->body;
if (oEnd && (oEnd->type == uris.atom_Long)) sampleEnd = ((LV2_Atom_Long*)oEnd)->body;
if (oAmp && (oAmp->type == uris.atom_Float)) sampleAmpDial.setValue (((LV2_Atom_Float*)oAmp)->body);
if (oLoop && (oLoop->type == uris.atom_Bool)) sampleLoop = bool (((LV2_Atom_Bool*)oLoop)->body);
}
// Status notifications
else if (obj->body.otype == uris.notify_statusEvent)
{
LV2_Atom *oMax = NULL, *oSched = NULL, *oPlay = NULL, *oMid = NULL, *oCursor = NULL, *oDelay = NULL, *oFlip = NULL;
lv2_atom_object_get
(
obj,
uris.notify_maxPage, &oMax,
uris.notify_schedulePage, &oSched,
uris.notify_playbackPage, &oPlay,
uris.notify_midiLearned, &oMid,
uris.notify_cursor, &oCursor,
uris.notify_progressionDelay, &oDelay,
uris.notify_padFlipped, &oFlip,
NULL
);
if (oMax && (oMax->type == uris.atom_Int))
{
int newPages = (((LV2_Atom_Int*)oMax)->body);
while (newPages > nrPages) pushPage();
while (newPages < nrPages) popPage();
}
if (oSched && (oSched->type == uris.atom_Int))
{
int newSched = (((LV2_Atom_Int*)oSched)->body);
pageWidget.setValue (LIMIT (newSched, 0, MAXPAGES - 1));
}
if (oPlay && (oPlay->type == uris.atom_Int))
{
int newPlay = (((LV2_Atom_Int*)oPlay)->body);
newPlay = LIMIT (newPlay, 0, MAXPAGES - 1);
int val = pageWidget.getValue();
for (int i = 0; i < MAXPAGES; ++i)
{
if (i == newPlay) tabs[i].playSymbol.setState (BColors::ACTIVE);
else if (i != val) tabs[i].playSymbol.setState (BColors::INACTIVE);
}
drawPad();
}
if (oMid && (oMid->type == uris.atom_Int))
{
uint32_t newMid = (((LV2_Atom_Int*)oMid)->body);
uint8_t st = newMid >> 24;
uint8_t ch = (newMid >> 16) & 0xFF;
uint8_t nt = (newMid >> 8) & 0xFF;
uint8_t vl = newMid & 0xFF;
midiStatusListBox.setValue ((st == 8) || (st == 9) || (st == 11) ? st : 0);
midiChannelListBox.setValue (LIMIT (ch, 0, 15) + 1);
midiNoteListBox.setValue (LIMIT (nt, 0, 127));
midiValueListBox.setValue (LIMIT (vl, 0, 127));
midiLearnButton.setValue (0.0);
}
// Cursor notifications
if (oCursor && (oCursor->type == uris.atom_Float) && (cursor != ((LV2_Atom_Float*)oCursor)->body))
{
const int iOldCursor = cursor;
cursor = ((LV2_Atom_Float*)oCursor)->body;
if (int (cursor) != iOldCursor)
{
setMarkers();
drawPad ();
}
}
// Delay notifications
if (oDelay && (oDelay->type == uris.atom_Float))
{
float delay = ((LV2_Atom_Float*)oDelay)->body;
std::string delaytxt = BUtilities::to_string (delay, "%5.2f");
if (delaytxt != delayDisplayLabel.getText()) delayDisplayLabel.setText (delaytxt);
}
// Flip notification
if (oFlip && (oFlip->type == uris.atom_Bool))
{
const bool newFlip = ((LV2_Atom_Bool*)oFlip)->body;
if (newFlip != patternFlipped)
{
patternFlipped = newFlip;
monitorWidget.flip (patternFlipped);
setMarkers();
drawPad();
}
}
}
// Monitor notification
if (obj->body.otype == uris.notify_waveformEvent)
{
int start = -1;
const LV2_Atom *oStart = NULL, *oData = NULL;
lv2_atom_object_get (obj,
uris.notify_waveformStart, &oStart,
uris.notify_waveformData, &oData,
NULL);
if (oStart && (oStart->type == uris.atom_Int)) start = ((LV2_Atom_Int*)oStart)->body;
if (oData && (oData->type == uris.atom_Vector))
{
const LV2_Atom_Vector* vec = (const LV2_Atom_Vector*) oData;
if (vec->body.child_type == uris.atom_Float)
{
uint32_t size = (uint32_t) ((oData->size - sizeof(LV2_Atom_Vector_Body)) / sizeof (float));
float* data = (float*) (&vec->body + 1);
if ((start >= 0) && (size > 0))
{
monitorWidget.addData (start, size, data);
monitorWidget.redrawRange (start, size);
}
}
}
}
}
}
// Scan remaining ports
else if ((format == 0) && (port >= CONTROLLERS))
{
float* pval = (float*) buffer;
controllerWidgets[port - CONTROLLERS]->setValue (*pval);
}
}
void BJumblrGUI::resize ()
{
hide ();
//Scale fonts
ctLabelFont.setFontSize (12 * sz);
tLabelFont.setFontSize (12 * sz);
tgLabelFont.setFontSize (12 * sz);
lfLabelFont.setFontSize (12 * sz);
boldLfLabelFont.setFontSize (12 * sz);
smLabelFont.setFontSize (8 * sz);
//Background
cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1020 * sz, 620 * sz);
cairo_t* cr = cairo_create (surface);
cairo_scale (cr, sz, sz);
cairo_set_source_surface(cr, bgImageSurface, 0, 0);
cairo_paint(cr);
widgetBg.loadFillFromCairoSurface(surface);
cairo_destroy (cr);
cairo_surface_destroy (surface);
//Scale widgets
RESIZE (mContainer, 0, 0, 1020, 620, sz);
RESIZE (messageLabel, 400, 45, 600, 20, sz);
RESIZE (pageWidget, 18, 86, 504, 30, sz);
updatePageContainer();
for (int i = 0; i < MAXPAGES; ++i)
{
RESIZE (tabs[i].icon, 0, 8, 40, 20, sz);
RESIZE (tabs[i].playSymbol, 40, 12, 20, 12, sz);
RESIZE (tabs[i].midiSymbol, 60, 12, 20, 12, sz);
for (int j = 0; j < 4; ++j) RESIZE (tabs[i].symbols[j], 68 - j * 10, 2, 8, 8, sz);
}
RESIZE (sourceLabel, 510, 95, 60, 10, sz);
RESIZE (calibrationLabel, 405, 577, 80, 10, sz);
RESIZE (stepEditModeLabel ,535, 577, 80, 10, sz);
RESIZE (stepSizeLabel, 690, 577, 80, 10, sz);
RESIZE (patternSizeLabel, 850, 577, 80, 10, sz);
RESIZE (padLevelLabel, 950, 120, 60, 10, sz);
RESIZE (playbackLabel, 950, 350, 60, 10, sz);
RESIZE (speedLabel, 950, 515, 60, 10, sz);
RESIZE (midiBox, 290, 168, 510, 120, sz);
RESIZE (midiText, 20, 10, 450, 20, sz);
RESIZE (midiStatusLabel, 10, 30, 130, 20, sz);
RESIZE (midiStatusListBox, 10, 50, 130, 20, sz);
midiStatusListBox.resizeListBox(BUtilities::Point (130 * sz, 100 * sz));
midiStatusListBox.moveListBox(BUtilities::Point (0, 20 * sz));
midiStatusListBox.resizeListBoxItems(BUtilities::Point (130 * sz, 20 * sz));
RESIZE (midiChannelLabel, 150, 30, 50, 20, sz);
RESIZE (midiChannelListBox, 150, 50, 50, 20, sz);
midiChannelListBox.resizeListBox(BUtilities::Point (50 * sz, 360 * sz));
midiChannelListBox.moveListBox(BUtilities::Point (0, 20 * sz));
midiChannelListBox.resizeListBoxItems(BUtilities::Point (50 * sz, 20 * sz));
RESIZE (midiNoteLabel, 210, 30, 160, 20, sz);
RESIZE (midiNoteListBox, 210, 50, 160, 20, sz);
midiNoteListBox.resizeListBox(BUtilities::Point (160 * sz, 360 * sz));
midiNoteListBox.moveListBox(BUtilities::Point (0, 20 * sz));
midiNoteListBox.resizeListBoxItems(BUtilities::Point (160 * sz, 20 * sz));
RESIZE (midiValueLabel, 380, 30, 50, 20, sz);
RESIZE (midiValueListBox, 380, 50, 50, 20, sz);
midiValueListBox.resizeListBox(BUtilities::Point (50 * sz, 360 * sz));
midiValueListBox.moveListBox(BUtilities::Point (0, 20 * sz));
midiValueListBox.resizeListBoxItems(BUtilities::Point (50 * sz, 20 * sz));
RESIZE (midiLearnButton, 440, 50, 60, 20, sz);
RESIZE (midiCancelButton, 170, 90, 60, 20, sz);
RESIZE (midiOkButton, 280, 90, 60, 20, sz);
RESIZE (flipButton, 940, 120, 10, 10, sz);
RESIZE (padSurface, 18, 128, 924, 434, sz);
setMarkers();
RESIZE (monitorWidget, 20, 130, 920, 430, sz);
RESIZE (sourceListBox, 570, 90, 120, 20, sz);
sourceListBox.resizeListBox (BUtilities::Point (120 * sz, 60 * sz));
sourceListBox.resizeListBoxItems (BUtilities::Point (120 * sz, 20 * sz));
RESIZE (loadButton, 710, 90, 20, 20, sz);
RESIZE (sampleNameLabel, 740, 90, 160, 20, sz);
RESIZE (sampleAmpDial, 918, 88, 24, 24, sz);
RESIZE (playButton, 18, 588, 24, 24, sz);
RESIZE (bypassButton, 48, 588, 24, 24, sz);
RESIZE (stopButton, 78, 588, 24, 24, sz);
for (int i = 0; i < EDIT_RESET; ++i) RESIZE (edit1Buttons[i], 128 + i * 30, 588, 24, 24, sz);
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i) RESIZE (edit2Buttons[i], 298 + i * 30, 588, 24, 24, sz);
RESIZE (syncWidget, 400, 590, 95, 20, sz);
RESIZE (zeroStepOffsetButton, 0, 0, 20, 20, sz);
RESIZE (decStepOffsetButton, 25, 0, 20, 20, sz);
RESIZE (hostSyncButton, 50, 0, 20, 20, sz);
RESIZE (incStepOffsetButton, 75, 0, 20, 20, sz);
RESIZE (editModeListBox, 530, 590, 90, 20, sz);
editModeListBox.resizeListBox(BUtilities::Point (90 * sz, 60 * sz));
editModeListBox.moveListBox(BUtilities::Point (0, -60 * sz));
editModeListBox.resizeListBoxItems(BUtilities::Point (90 * sz, 20 * sz));
RESIZE (stepSizeListBox, 650, 590, 70, 20, sz);
stepSizeListBox.resizeListBox(BUtilities::Point (70 * sz, 280 * sz));
stepSizeListBox.moveListBox(BUtilities::Point (0, -280 * sz));
stepSizeListBox.resizeListBoxItems(BUtilities::Point (70 * sz, 20 * sz));
RESIZE (stepBaseListBox, 730, 590, 90, 20, sz);
stepBaseListBox.resizeListBox(BUtilities::Point (90 * sz, 80 * sz));
stepBaseListBox.moveListBox(BUtilities::Point (0, -80 * sz));
stepBaseListBox.resizeListBoxItems(BUtilities::Point (90 * sz, 20 * sz));
RESIZE (padSizeListBox, 850, 590, 90, 20, sz);
padSizeListBox.resizeListBox(BUtilities::Point (90 * sz, 240 * sz));
padSizeListBox.moveListBox(BUtilities::Point (0, -240 * sz));
padSizeListBox.resizeListBoxItems(BUtilities::Point (90 * sz, 20 * sz));
for (int i = 0; i < 5; ++i) RESIZE (levelButtons[i], 958, 138 + 30 * i, 44, 22, sz);
RESIZE (levelDial, 960, 290, 40, 48, sz);
RESIZE (delayDisplayLabel, 958, 370, 44, 20, sz);
RESIZE (increaseDelayButton, 958, 398, 44, 22, sz);
RESIZE (increaseDelayButton, 958, 428, 44, 22, sz);
RESIZE (decreaseDelayButton, 958, 488, 44, 22, sz);
RESIZE (setStartDelayButton, 958, 458, 44, 22, sz);
RESIZE (speedDial, 960, 530, 40, 48, sz);
RESIZE (helpButton, 958, 588, 24, 24, sz);
RESIZE (ytButton, 988, 588, 24, 24, sz);
if (fileChooser) RESIZE ((*fileChooser), 200, 140, 640, 400, sz);
applyTheme (theme);
drawPad ();
show ();
}
void BJumblrGUI::applyTheme (BStyles::Theme& theme)
{
mContainer.applyTheme (theme);
messageLabel.applyTheme (theme);
pageWidget.applyTheme (theme);
pageBackSymbol.applyTheme (theme);
pageForwardSymbol.applyTheme (theme);
for (Tab& t : tabs)
{
t.container.applyTheme (theme);
t.icon.applyTheme (theme);
t.playSymbol.applyTheme (theme);
t.midiSymbol.applyTheme (theme);
for (SymbolWidget& s : t.symbols) s.applyTheme (theme);
}
sourceLabel.applyTheme (theme);
calibrationLabel.applyTheme (theme);
stepEditModeLabel.applyTheme (theme);
stepSizeLabel.applyTheme (theme);
patternSizeLabel.applyTheme (theme);
padLevelLabel.applyTheme (theme);
playbackLabel.applyTheme (theme);
speedLabel.applyTheme (theme);
midiBox.applyTheme (theme);
midiText.applyTheme (theme);
midiStatusLabel.applyTheme (theme);
midiStatusListBox.applyTheme (theme);
midiChannelLabel.applyTheme (theme);
midiChannelListBox.applyTheme (theme);
midiNoteLabel.applyTheme (theme);
midiNoteListBox.applyTheme (theme);
midiValueLabel.applyTheme (theme);
midiValueListBox.applyTheme (theme);
midiLearnButton.applyTheme (theme);
midiCancelButton.applyTheme (theme);
midiOkButton.applyTheme (theme);
flipButton.applyTheme (theme);
padSurface.applyTheme (theme);
markerFwd.applyTheme (theme);
markerRev.applyTheme (theme);
monitorWidget.applyTheme (theme);
sourceListBox.applyTheme (theme);
loadButton.applyTheme (theme);
sampleNameLabel.applyTheme (theme);
sampleAmpDial.applyTheme (theme);
playButton.applyTheme (theme);
bypassButton.applyTheme (theme);
stopButton.applyTheme (theme);
for (int i = 0; i < EDIT_RESET; ++i) edit1Buttons[i].applyTheme (theme);
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i) edit2Buttons[i].applyTheme (theme);
syncWidget.applyTheme (theme);
zeroStepOffsetButton.applyTheme (theme);
decStepOffsetButton.applyTheme (theme);
hostSyncButton.applyTheme (theme);
incStepOffsetButton.applyTheme (theme);
editModeListBox.applyTheme (theme);
stepSizeListBox.applyTheme (theme);
stepBaseListBox.applyTheme (theme);
padSizeListBox.applyTheme (theme);
for (int i = 0; i < 5; ++i) levelButtons[i].applyTheme (theme);
levelDial.applyTheme (theme);
delayDisplayLabel.applyTheme (theme);
manualProgressionDelayWidget.applyTheme (theme);
resetDelayButton.applyTheme (theme);
increaseDelayButton.applyTheme (theme);
decreaseDelayButton.applyTheme (theme);
setStartDelayButton.applyTheme (theme);
speedDial.applyTheme (theme);
helpButton.applyTheme (theme);
ytButton.applyTheme (theme);
if (fileChooser) fileChooser->applyTheme (theme);
}
void BJumblrGUI::onConfigureRequest (BEvents::ExposeEvent* event)
{
Window::onConfigureRequest (event);
sz = (getWidth() / 1020 > getHeight() / 620 ? getHeight() / 620 : getWidth() / 1020);
resize ();
}
void BJumblrGUI::onCloseRequest (BEvents::WidgetEvent* event)
{
if (!event) return;
Widget* requestWidget = event->getRequestWidget ();
if (!requestWidget) return;
if (requestWidget == fileChooser)
{
if (fileChooser->getValue() == 1.0)
{
sampleNameLabel.setText (fileChooser->getFileName());
samplePath = fileChooser->getPath();
sampleStart = fileChooser->getStart();
sampleEnd = fileChooser->getEnd();
sampleLoop = fileChooser->getLoop();
send_samplePath ();
}
// Close fileChooser
mContainer.release (fileChooser); // TODO Check why this is required
delete fileChooser;
fileChooser = nullptr;
return;
}
Window::onCloseRequest (event);
}
void BJumblrGUI::onKeyPressed (BEvents::KeyEvent* event)
{
if ((event) && (event->getKey() == BDevices::KEY_SHIFT))
{
monitorWidget.setScrollable (true);
}
}
void BJumblrGUI::onKeyReleased (BEvents::KeyEvent* event)
{
if ((event) && (event->getKey() == BDevices::KEY_SHIFT))
{
monitorWidget.setScrollable (false);
}
}
void BJumblrGUI::send_ui_on ()
{
uint8_t obj_buf[64];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.ui_on);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_ui_off ()
{
uint8_t obj_buf[64];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.ui_off);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_samplePath ()
{
std::string path = samplePath + BUTILITIES_PATH_SLASH + sampleNameLabel.getText();
uint8_t obj_buf[1024];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_pathEvent);
lv2_atom_forge_key(&forge, uris.notify_samplePath);
lv2_atom_forge_path (&forge, path.c_str(), path.size() + 1);
lv2_atom_forge_key(&forge, uris.notify_sampleStart);
lv2_atom_forge_long(&forge, sampleStart);
lv2_atom_forge_key(&forge, uris.notify_sampleEnd);
lv2_atom_forge_long(&forge, sampleEnd);
lv2_atom_forge_key(&forge, uris.notify_sampleAmp);
lv2_atom_forge_float(&forge, sampleAmpDial.getValue());
lv2_atom_forge_key(&forge, uris.notify_sampleLoop);
lv2_atom_forge_bool(&forge, int32_t (sampleLoop));
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_sampleAmp ()
{
uint8_t obj_buf[1024];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_pathEvent);
lv2_atom_forge_key(&forge, uris.notify_sampleAmp);
lv2_atom_forge_float(&forge, sampleAmpDial.getValue());
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_editMode ()
{
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_padEvent);
lv2_atom_forge_key(&forge, uris.notify_editMode);
lv2_atom_forge_int(&forge, editMode);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_maxPage ()
{
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(&forge, uris.notify_maxPage);
lv2_atom_forge_int(&forge, nrPages);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_playbackPage ()
{
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(&forge, uris.notify_playbackPage);
lv2_atom_forge_int(&forge, int (pageWidget.getValue()));
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_requestMidiLearn ()
{
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(&forge, uris.notify_requestMidiLearn);
lv2_atom_forge_bool(&forge, midiLearnButton.getValue() != 0.0);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_pad (int page)
{
Pad padmsg [MAXSTEPS * MAXSTEPS];
for (int r = 0; r < MAXSTEPS; ++r)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
padmsg[r * MAXSTEPS + s] = pattern[page].getPad (r, s);
}
}
uint8_t obj_buf[8192];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_padEvent);
lv2_atom_forge_key(&forge, uris.notify_padPage);
lv2_atom_forge_int(&forge, page);
lv2_atom_forge_key(&forge, uris.notify_padFullPattern);
lv2_atom_forge_vector(&forge, sizeof(float), uris.atom_Float, MAXSTEPS * MAXSTEPS * sizeof(Pad) / sizeof(float), (void*) padmsg);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_pad (int page, int row, int step)
{
PadMessage padmsg (step, row, pattern[page].getPad (row, step));
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_padEvent);
lv2_atom_forge_key(&forge, uris.notify_padPage);
lv2_atom_forge_int(&forge, page);
lv2_atom_forge_key(&forge, uris.notify_pad);
lv2_atom_forge_vector(&forge, sizeof(float), uris.atom_Float, sizeof(PadMessage) / sizeof(float), (void*) &padmsg);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::send_flip ()
{
uint8_t obj_buf[128];
lv2_atom_forge_set_buffer(&forge, obj_buf, sizeof(obj_buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object(&forge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(&forge, uris.notify_padFlipped);
lv2_atom_forge_bool(&forge, patternFlipped);
lv2_atom_forge_pop(&forge, &frame);
write_function(controller, CONTROL, lv2_atom_total_size(msg), uris.atom_eventTransfer, msg);
}
void BJumblrGUI::pushPage ()
{
if (nrPages >= MAXPAGES) return;
tabs[nrPages - 1].symbols[CLOSESYMBOL].show();
tabs[nrPages - 1].symbols[RIGHTSYMBOL].show();
tabs[nrPages].container.show();
tabs[nrPages].symbols[CLOSESYMBOL].show();
tabs[nrPages].symbols[LEFTSYMBOL].show();
tabs[nrPages].symbols[RIGHTSYMBOL].hide();
if (nrPages == MAXPAGES - 1)
{
for (Tab& t : tabs) t.symbols[ADDSYMBOL].hide();
}
++nrPages;
updatePageContainer();
}
void BJumblrGUI::popPage ()
{
if (nrPages <= 1) return;
tabs[nrPages - 2].symbols[RIGHTSYMBOL].hide();
if (nrPages == 2) tabs[0].symbols[CLOSESYMBOL].hide();
tabs[nrPages - 1].container.hide();
for (Tab& t : tabs) t.symbols[ADDSYMBOL].show();
if (actPage >= nrPages - 1) gotoPage (nrPages - 2);
if (pageWidget.getValue() >= nrPages - 1) pageWidget.setValue (0);
--nrPages;
updatePageContainer();
}
void BJumblrGUI::gotoPage (const int page)
{
if ((page < 0) || (page >= nrPages)) return;
actPage = page;
for (int i = 0; i < MAXPAGES; ++i)
{
if (i == page) tabs[i].container.rename ("activetab");
else tabs[i].container.rename ("tab");
tabs[i].container.applyTheme (theme);
}
drawPad();
updatePageContainer();
}
void BJumblrGUI::insertPage (const int page)
{
if ((page < 0) || (nrPages >= MAXPAGES)) return;
pushPage();
if (actPage >= page) gotoPage (actPage + 1);
if (pageWidget.getValue() >= page) pageWidget.setValue (pageWidget.getValue() + 1);
// Move pages
for (int i = nrPages - 1; i > page; --i)
{
pattern[i] = pattern[i - 1];
send_pad (i);
if (i == actPage) drawPad();
for (int j = 0; j < NR_MIDI_CTRLS; ++j)
{
tabs[i].midiWidgets[j].setValue (tabs[i - 1].midiWidgets[j].getValue());
}
}
// Init new page
pattern[page].clear();
for (int i = 0; i < MAXSTEPS; ++i) pattern[page].setPad (i, i, Pad (1.0));
send_pad (page);
if (page == actPage) drawPad();
tabs[page].midiWidgets[STATUS].setValue (0);
tabs[page].midiWidgets[CHANNEL].setValue (0);
tabs[page].midiWidgets[NOTE].setValue (128);
tabs[page].midiWidgets[VALUE].setValue (128);
}
void BJumblrGUI::deletePage (const int page)
{
if ((page < 0) || (page >= nrPages)) return;
if (actPage > page) gotoPage (actPage - 1);
if (pageWidget.getValue() > page) pageWidget.setValue (pageWidget.getValue() - 1);
for (int i = page; i < nrPages -1; ++i)
{
pattern[i] = pattern[i + 1];
send_pad (i);
if (i == actPage) drawPad ();
for (int j = 0; j < NR_MIDI_CTRLS; ++j)
{
tabs[i].midiWidgets[j].setValue (tabs[i + 1].midiWidgets[j].getValue());
}
}
tabs[nrPages - 1].midiWidgets[STATUS].setValue (0);
tabs[nrPages - 1].midiWidgets[CHANNEL].setValue (0);
tabs[nrPages - 1].midiWidgets[NOTE].setValue (128);
tabs[nrPages - 1].midiWidgets[VALUE].setValue (128);
popPage();
send_maxPage();
}
void BJumblrGUI::swapPage (const int page1, const int page2)
{
if ((page1 < 0) || (page1 >= nrPages) || (page2 < 0) || (page2 >= nrPages)) return;
Pattern p;
p.clear();
p = pattern[page1];
pattern[page1] = pattern[page2];
pattern[page2] = p;
send_pad (page1);
send_pad (page2);
if (actPage == page1) gotoPage (page2);
else if (actPage == page2) gotoPage (page1);
if (pageWidget.getValue() == page1) pageWidget.setValue (page2);
else if (pageWidget.getValue() == page2) pageWidget.setValue (page1);
for (int j = 0; j < NR_MIDI_CTRLS; ++j)
{
double v = tabs[page1].midiWidgets[j].getValue();
tabs[page1].midiWidgets[j].setValue (tabs[page2].midiWidgets[j].getValue());
tabs[page2].midiWidgets[j].setValue (v);
}
}
void BJumblrGUI::updatePageContainer()
{
if (nrPages > 6) pageOffset = LIMIT (pageOffset, 0, nrPages - 6);
else pageOffset = 0;
int x0 = (pageOffset == 0 ? 0 : 12 * sz);
if (pageOffset != 0) pageBackSymbol.show();
else pageBackSymbol.hide();
if (pageOffset + 6 < nrPages) pageForwardSymbol.show();
else pageForwardSymbol.hide();
for (int p = 0; p < nrPages; ++p)
{
if ((p < pageOffset) || (p >= pageOffset + 6)) tabs[p].container.hide();
else
{
tabs[p].container.moveTo (x0 + (p - pageOffset) * 80 * sz, 0);
tabs[p].container.resize (78 * sz, 30 * sz);
tabs[p].container.show();
}
}
for (int p = nrPages; p < MAXPAGES; ++p ) tabs[p].container.hide();
pageBackSymbol.moveTo (0, 0);
pageBackSymbol.resize (10 * sz, 30 * sz);
pageForwardSymbol.moveTo (x0 + 480 * sz, 0);
pageForwardSymbol.resize (10 * sz, 30 * sz);
}
bool BJumblrGUI::validatePad (int page)
{
bool changed = false;
// REPLACE mode
if (editMode == 1)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
bool padOn = false;
for (int r = 0; r < MAXSTEPS; ++r)
{
// Clear if there is already an active pad
if (padOn)
{
if (pattern[page].getPad (r, s).level != 0.0)
{
pattern[page].setPad (r, s, Pad(0));
send_pad (page, r, s);
changed = true;
}
}
// First active pad
else if (pattern[page].getPad (r, s).level != 0.0)
{
padOn = true;
}
}
// Empty step: Set default
if (!padOn)
{
pattern[page].setPad (s, s, Pad (1.0));
send_pad (page, s, s);
changed = true;
}
}
}
return (!changed);
}
bool BJumblrGUI::validatePad (int page, int row, int step, Pad& pad)
{
bool changed = false;
// REPLACE mode
if (editMode == 1)
{
if (pad.level != 0.0)
{
pattern[page].setPad (row, step, pad);
send_pad (page, row, step);
for (int r = 0; r < MAXSTEPS; ++r)
{
// Clear all other active pads
if (r != row)
{
if (pattern[page].getPad (r, step).level != 0.0)
{
pattern[page].setPad (r, step, Pad(0));
send_pad (page, r, step);
changed = true;
}
}
}
}
}
else
{
pattern[page].setPad (row, step, pad);
send_pad (page, row, step);
}
return (!changed);
}
void BJumblrGUI::valueChangedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
int controllerNr = -1;
// Identify controller
for (int i = 0; i < MAXCONTROLLERS; ++i)
{
if (widget == ui->controllerWidgets[i])
{
controllerNr = i;
break;
}
}
// Controllers
if (controllerNr >= 0)
{
ui->controllers[controllerNr] = value;
ui->write_function(ui->controller, CONTROLLERS + controllerNr, sizeof(float), 0, &ui->controllers[controllerNr]);
switch (controllerNr)
{
case SOURCE: if (value == 0.0)
{
ui->loadButton.hide();
ui->sampleNameLabel.hide();
ui->sampleAmpDial.hide();
}
else
{
ui->loadButton.show();
ui->sampleNameLabel.show();
ui->sampleAmpDial.show();
}
break;
case NR_OF_STEPS: ui->drawPad ();
break;
case PLAY: ui->bypassButton.setValue (value == 2.0 ? 1 : 0);
break;
case PAGE: for (int i = 0; i < MAXPAGES; ++i)
{
if (ui->tabs[i].playSymbol.getState() != BColors::ACTIVE)
{
if (i == value) ui->tabs[i].playSymbol.setState (BColors::NORMAL);
else ui->tabs[i].playSymbol.setState (BColors::INACTIVE);
}
}
ui->drawPad();
break;
default: if (controllerNr >= MIDI)
{
int page = (controllerNr - MIDI) / NR_MIDI_CTRLS;
int midiCtrl = (controllerNr - MIDI) % NR_MIDI_CTRLS;
if (midiCtrl == STATUS)
{
if (value < 8) ui->tabs[page].midiSymbol.setState (BColors::INACTIVE);
else ui->tabs[page].midiSymbol.setState (BColors::ACTIVE);
}
}
break;
}
}
// Other widgets
else if (widget == &ui->editModeListBox)
{
ui->editMode = ui->editModeListBox.getValue();
ui->send_editMode();
for (int i = 0; i < ui->nrPages; ++i)
{
if (!ui->validatePad(i))
{
if (i == ui->actPage) ui->drawPad();
ui->pattern[i].store ();
}
}
}
// Buttons
else if (widget == &ui->bypassButton)
{
if ((value == 0.0) && (ui->playButton.getValue() == 2.0)) ui->playButton.setValue (0.0);
else if (value == 1.0) ui->playButton.setValue (2.0);
}
else if (widget == &ui->stopButton)
{
if (value == 1.0)
{
ui->playButton.setValue (0.0);
ui->bypassButton.setValue (0.0);
}
}
else if (widget == &ui->sampleAmpDial) ui->send_sampleAmp();
}
void BJumblrGUI::pageClickedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::Widget* widget = event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
for (int i = 0; i < ui->nrPages; ++i)
{
if (&ui->tabs[i].container == widget)
{
ui->gotoPage (i);
break;
}
}
}
void BJumblrGUI::pageSymbolClickedCallback(BEvents::Event* event)
{
if (!event) return;
SymbolWidget* widget = (SymbolWidget*)event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
for (int i = 0; i < ui->nrPages; ++i)
{
for (int j = 0; j < 4; ++j)
{
if (&ui->tabs[i].symbols[j] == widget)
{
switch (j)
{
// Symbol +
case ADDSYMBOL: ui->insertPage (i + 1);
break;
// Symbol -
case CLOSESYMBOL: ui->deletePage (i);
break;
// Symbol <
case LEFTSYMBOL: ui->swapPage (i, i - 1);
break;
// Symbol >
case RIGHTSYMBOL: ui->swapPage (i, i + 1);
break;
}
return;
}
}
}
}
void BJumblrGUI::pagePlayClickedCallback(BEvents::Event* event)
{
if (!event) return;
SymbolWidget* widget = (SymbolWidget*)event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
for (int i = 0; i < ui->nrPages; ++i)
{
if (&ui->tabs[i].playSymbol == widget)
{
ui->pageWidget.setValue (i);
break;
}
}
}
void BJumblrGUI::pageScrollClickedCallback(BEvents::Event* event)
{
if (!event) return;
SymbolWidget* widget = (SymbolWidget*)event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
if (widget == &ui->pageBackSymbol) --ui->pageOffset;
else if (widget == &ui->pageForwardSymbol) ++ui->pageOffset;
ui->updatePageContainer();
}
void BJumblrGUI::midiSymbolClickedCallback(BEvents::Event* event)
{
if (!event) return;
SymbolWidget* widget = (SymbolWidget*)event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
for (int i = 0; i < ui->nrPages; ++i)
{
if (widget == &ui->tabs[i].midiSymbol)
{
ui->midiText.setText (BJUMBLR_LABEL_MIDI_PAGE " #" + std::to_string (i + 1));
ui->midiStatusListBox.setValue (ui->controllers[MIDI + i * NR_MIDI_CTRLS + STATUS]);
ui->midiChannelListBox.setValue (ui->controllers[MIDI + i * NR_MIDI_CTRLS + CHANNEL]);
ui->midiNoteListBox.setValue (ui->controllers[MIDI + i * NR_MIDI_CTRLS + NOTE]);
ui->midiValueListBox.setValue (ui->controllers[MIDI + i * NR_MIDI_CTRLS + VALUE]);
ui->midiBox.setValue (i);
ui->midiBox.show();
return;
}
}
}
void BJumblrGUI::midiButtonClickedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
if (widget == &ui->midiLearnButton)
{
if (value == 1) ui->send_requestMidiLearn();
}
else if (widget == &ui->midiCancelButton)
{
if (value == 1)
{
ui->midiLearnButton.setValue (0);
ui->midiBox.hide();
}
}
else if (widget == &ui->midiOkButton)
{
if (value == 1)
{
int page = ui->midiBox.getValue();
ui->midiLearnButton.setValue (0);
ui->tabs[page].midiWidgets[STATUS].setValue (ui->midiStatusListBox.getValue());
ui->tabs[page].midiWidgets[CHANNEL].setValue (ui->midiChannelListBox.getValue());
ui->tabs[page].midiWidgets[NOTE].setValue (ui->midiNoteListBox.getValue());
ui->tabs[page].midiWidgets[VALUE].setValue (ui->midiValueListBox.getValue());
ui->midiBox.hide();
}
}
}
void BJumblrGUI::midiStatusChangedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::PopupListBox* widget = (BWidgets::PopupListBox*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
BWidgets::PopupListBox& nlb = ui->midiNoteListBox;
BWidgets::Label& nl = ui->midiNoteLabel;
int nr = nlb.getValue();
if (value == 11)
{
nlb = BWidgets::PopupListBox
(
210 * ui->sz, 50 * ui->sz, 160 * ui->sz, 20 * ui->sz, 0, 20 * ui->sz, 160 * ui->sz, 360 *ui->sz,
"menu",
BItems::ItemList ({CCLIST}),
0
);
nl.setText (BJUMBLR_LABEL_CC);
}
else
{
nlb = BWidgets::PopupListBox
(
210 * ui->sz, 50 * ui->sz, 160 * ui->sz, 20 * ui->sz, 0, 20 * ui->sz, 160 * ui->sz, 360 * ui->sz,
"menu",
BItems::ItemList ({NOTELIST}),
0
);
nl.setText (BJUMBLR_LABEL_NOTE);
}
nlb.resizeListBoxItems(BUtilities::Point (160 * ui->sz, 20 * ui->sz));
nlb.applyTheme (ui->theme);
nlb.setValue (nr);
}
void BJumblrGUI::levelChangedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
if (widget == &ui->levelDial)
{
for (int i = 0; i < 5; ++i)
{
if (value == 1.0 - double (i) * 0.25) ui->levelButtons[i].setValue (1.0);
else ui->levelButtons[i].setValue (0.0);
}
}
else
{
int buttonNr = -1;
// Identify controller
for (int i = 0; i < 5; ++i)
{
if (widget == &ui->levelButtons[i])
{
buttonNr = i;
break;
}
}
// Controllers
if ((buttonNr >= 0) && (value == 1.0)) ui->levelDial.setValue (1.0 - double (buttonNr) * 0.25);
}
}
void BJumblrGUI::edit1ChangedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
if (value != 1.0) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
// Identify editButtons: CUT ... PASTE
int widgetNr = -1;
for (int i = 0; i < EDIT_RESET; ++i)
{
if (widget == &ui->edit1Buttons[i])
{
widgetNr = i;
break;
}
}
// Untoggle all other edit1Buttons
if (widgetNr >= 0)
{
// Allow only one button pressed
for (int i = 0; i < EDIT_RESET; ++i)
{
if (i != widgetNr) ui->edit1Buttons[i].setValue (0.0);
}
}
}
void BJumblrGUI::edit2ChangedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
if (value != 1.0) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
int page = ui->actPage;
// Identify editButtons: RESET ... REDO
int widgetNr = -1;
for (int i = 0; i < MAXEDIT - EDIT_RESET; ++i)
{
if (widget == &ui->edit2Buttons[i])
{
widgetNr = i + EDIT_RESET;
break;
}
}
// RESET ... REDO
switch (widgetNr)
{
case EDIT_RESET:
{
if (ui->wheelScrolled)
{
ui->pattern[page].store ();
ui->wheelScrolled = false;
}
Pad p0 = Pad ();
for (int r = 0; r < MAXSTEPS; ++r)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
if (s == r) ui->pattern[page].setPad (r, s, Pad (1.0));
else ui->pattern[page].setPad (r, s, p0);
ui->send_pad (page, r, s);
}
}
ui->drawPad ();
ui->pattern[page].store ();
}
break;
case EDIT_UNDO:
{
std::vector<PadMessage> padMessages = ui->pattern[page].undo ();
for (PadMessage const& p : padMessages)
{
size_t r = LIMIT (p.row, 0, MAXSTEPS);
size_t s = LIMIT (p.step, 0, MAXSTEPS);
ui->send_pad (page, r, s);
}
ui->validatePad (page);
ui->drawPad ();
}
break;
case EDIT_REDO:
{
std::vector<PadMessage> padMessages = ui->pattern[page].redo ();
for (PadMessage const& p : padMessages)
{
size_t r = LIMIT (p.row, 0, MAXSTEPS);
size_t s = LIMIT (p.step, 0, MAXSTEPS);
ui->send_pad (page, r, s);
}
ui->validatePad (page);
ui->drawPad ();
}
break;
default: break;
}
}
void BJumblrGUI::padsPressedCallback (BEvents::Event* event)
{
if (!event) return;
BEvents::PointerEvent* pointerEvent = (BEvents::PointerEvent*) event;
BWidgets::DrawingSurface* widget = (BWidgets::DrawingSurface*) event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
int page = ui->actPage;
if
(
(event->getEventType () == BEvents::BUTTON_PRESS_EVENT) ||
(event->getEventType () == BEvents::BUTTON_RELEASE_EVENT) ||
(event->getEventType () == BEvents::POINTER_DRAG_EVENT)
)
{
if (ui->wheelScrolled)
{
ui->pattern[page].store ();
ui->wheelScrolled = false;
}
// Get size of drawing area
const double width = ui->padSurface.getEffectiveWidth ();
const double height = ui->padSurface.getEffectiveHeight ();
const int maxstep = ui->controllerWidgets[NR_OF_STEPS]->getValue ();
const int s0 = maxstep - 1 - int ((pointerEvent->getPosition ().y - widget->getYOffset()) / (height / maxstep));
const int r0 = (pointerEvent->getPosition ().x - widget->getXOffset()) / (width / maxstep);
const int step = (ui->patternFlipped ? r0 : s0);
const int row = (ui->patternFlipped ? s0 : r0);
if ((event->getEventType () == BEvents::BUTTON_PRESS_EVENT) || (event->getEventType () == BEvents::POINTER_DRAG_EVENT))
{
if ((row >= 0) && (row < maxstep) && (step >= 0) && (step < maxstep))
{
Pad oldPad = ui->pattern[page].getPad (row, step);
// Left button
if (pointerEvent->getButton() == BDevices::LEFT_BUTTON)
{
// Check if edit mode
int editNr = -1;
for (int i = 0; i < EDIT_RESET; ++i)
{
if (ui->edit1Buttons[i].getValue() != 0.0)
{
editNr = i;
break;
}
}
// Edit
if (editNr >= 0)
{
if ((editNr == EDIT_CUT) || (editNr == EDIT_COPY) || (editNr == EDIT_XFLIP) || (editNr == EDIT_YFLIP))
{
if (ui->clipBoard.ready)
{
ui->clipBoard.origin = std::make_pair (row, step);
ui->clipBoard.extends = std::make_pair (0, 0);
ui->clipBoard.ready = false;
ui->drawPad (row, step);
}
else
{
std::pair<int, int> newExtends = std::make_pair (row - ui->clipBoard.origin.first, step - ui->clipBoard.origin.second);
if (newExtends != ui->clipBoard.extends)
{
ui->clipBoard.extends = newExtends;
ui->drawPad ();
}
}
}
else if (editNr == EDIT_PASTE)
{
if (!ui->clipBoard.data.empty ())
{
bool valid = true;
const int f = (ui->patternFlipped ? -1 : 1);
for (int r = 0; r < int (ui->clipBoard.data.size ()); ++r)
{
for (int s = 0; s < int (ui->clipBoard.data[r].size ()); ++s)
{
if
(
(row + f * r >= 0) &&
(row + f * r < maxstep) &&
(step - f * s >= 0) &&
(step - f * s < maxstep)
)
{
const int clr = (ui->patternFlipped ? ui->clipBoard.data.size () - 1 - r : r);
const int cls = (ui->patternFlipped ? ui->clipBoard.data[r].size () - 1 - s : s);
if (!ui->validatePad (page, row + f * r, step - f * s, ui->clipBoard.data.at(clr).at(cls)))
{
valid = false;
}
else if (valid) ui->drawPad (row + f * r, step - f * s);
}
}
}
if (!valid) ui->drawPad();
}
}
}
// Set (or unset) pad
else
{
if (!ui->padPressed) ui->deleteMode = ((oldPad.level == float (ui->levelDial.getValue())) && (ui->editMode != 1));
Pad newPad = (ui->deleteMode ? Pad (0.0) : Pad (ui->levelDial.getValue()));
if (!ui->validatePad (page, row, step, newPad)) ui->drawPad();
else ui->drawPad (row,step);
}
ui->padPressed = true;
}
else if (pointerEvent->getButton() == BDevices::RIGHT_BUTTON)
{
ui->levelDial.setValue (ui->pattern[page].getPad (row, step).level);
}
}
}
else if ((event->getEventType () == BEvents::BUTTON_RELEASE_EVENT) && (pointerEvent->getButton() == BDevices::LEFT_BUTTON))
{
// Check if edit mode
int editNr = -1;
for (int i = 0; i < EDIT_RESET; ++i)
{
if (ui->edit1Buttons[i].getValue() != 0.0)
{
editNr = i;
break;
}
}
// Edit mode
if (editNr >= 0)
{
if ((editNr == EDIT_CUT) || (editNr == EDIT_COPY) || (editNr == EDIT_XFLIP) || (editNr == EDIT_YFLIP))
{
int clipRMin = ui->clipBoard.origin.first;
int clipRMax = ui->clipBoard.origin.first + ui->clipBoard.extends.first;
if (clipRMin > clipRMax) std::swap (clipRMin, clipRMax);
int clipSMin = ui->clipBoard.origin.second;
int clipSMax = ui->clipBoard.origin.second + ui->clipBoard.extends.second;
if (clipSMin > clipSMax) std::swap (clipSMin, clipSMax);
// XFLIP
// No need to validate
if (((editNr == EDIT_XFLIP) && (!ui->patternFlipped)) || ((editNr == EDIT_YFLIP) && (ui->patternFlipped)))
{
for (int dr = 0; dr < int ((clipRMax + 1 - clipRMin) / 2); ++dr)
{
for (int s = clipSMin; s <= clipSMax; ++s)
{
Pad pd = ui->pattern[page].getPad (clipRMin + dr, s);
ui->pattern[page].setPad (clipRMin + dr, s, ui->pattern[page].getPad (clipRMax -dr, s));
ui->send_pad (page, clipRMin + dr, s);
ui->pattern[page].setPad (clipRMax - dr, s, pd);
ui->send_pad (page, clipRMax - dr, s);
}
}
ui->pattern[page].store ();
}
// YFLIP
// Validation required for REPLACE mode
if (((editNr == EDIT_YFLIP) && (!ui->patternFlipped)) || ((editNr == EDIT_XFLIP) && (ui->patternFlipped)))
{
// Temp. copy selection
Pad pads[clipRMax + 1 - clipRMin][clipSMax + 1 - clipSMin];
for (int ds = 0; ds <= clipSMax - clipSMin; ++ds)
{
for (int dr = 0; dr <= clipRMax - clipRMin; ++dr)
{
pads[dr][ds] = ui->pattern[page].getPad (clipRMin + dr, clipSMin + ds);
}
}
// X flip temp. copy & paste selection
bool valid = true;
for (int ds = 0; ds <= clipSMax - clipSMin; ++ds)
{
for (int dr = 0; dr <= clipRMax - clipRMin; ++dr)
{
if (!ui->validatePad (page, clipRMin + dr, clipSMax - ds, pads[dr][ds]))
{
valid = false;
}
else if (valid) ui->drawPad (clipRMin + dr, clipSMax - ds);
}
}
if (!valid) ui->drawPad();
ui->pattern[page].store ();
}
// Store selected data in clipboard after flip (XFLIP, YFLIP)
// Or store selected data in clipboard before deletion (CUT)
// Or store selected data anyway (COPY)
ui->clipBoard.data.clear ();
for (int r = clipRMin; r <= clipRMax; ++r)
{
std::vector<Pad> padRow;
padRow.clear ();
for (int s = clipSMax; s >= clipSMin; --s) padRow.push_back (ui->pattern[page].getPad (r, s));
ui->clipBoard.data.push_back (padRow);
}
// CUT
// Validation required for REPLACE mode
if (editNr == EDIT_CUT)
{
for (int s = clipSMin; s <= clipSMax; ++s)
{
bool empty = false;
for (int r = clipRMin; r <= clipRMax; ++r)
{
// Limit action to not empty pads
if (ui->pattern[page].getPad (r, s) != Pad())
{
// REPLACE mode: delete everything except default pads
if (ui->editMode == 1)
{
if (r != s)
{
ui->pattern[page].setPad (r, s, Pad ());
ui->send_pad (page, r, s);
empty = true;
}
else empty = true;
}
// ADD mode: simply delete
else
{
ui->pattern[page].setPad (r, s, Pad ());
ui->send_pad (page, r, s);
}
}
}
// Emptied column in REPLACE mode: set default
if (empty)
{
ui->pattern[page].setPad (s, s, Pad (1.0));
ui->send_pad (page, s, s);
}
}
ui->pattern[page].store ();
}
ui->clipBoard.ready = true;
ui->drawPad ();
}
}
else
{
ui->padPressed = false;
ui->pattern[page].store ();
}
}
}
}
void BJumblrGUI::padsScrolledCallback (BEvents::Event* event)
{
if ((event) && (event->getWidget ()) && (event->getWidget()->getMainWindow()) &&
((event->getEventType () == BEvents::WHEEL_SCROLL_EVENT)))
{
BWidgets::DrawingSurface* widget = (BWidgets::DrawingSurface*) event->getWidget ();
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
BEvents::WheelEvent* wheelEvent = (BEvents::WheelEvent*) event;
// Get size of drawing area
const double width = ui->padSurface.getEffectiveWidth ();
const double height = ui->padSurface.getEffectiveHeight ();
const int page = ui->actPage;
const int maxstep = ui->controllerWidgets[NR_OF_STEPS]->getValue ();
const int s0 = maxstep - 1 - int ((wheelEvent->getPosition ().y - widget->getYOffset()) / (height / maxstep));
const int r0 = (wheelEvent->getPosition ().x - widget->getXOffset()) / (width / maxstep);
const int step = (ui->patternFlipped ? r0 : s0);
const int row = (ui->patternFlipped ? s0 : r0);
if ((row >= 0) && (row < maxstep) && (step >= 0) && (step < maxstep))
{
Pad pd = ui->pattern[page].getPad (row, step);
pd.level = LIMIT (pd.level + 0.01 * wheelEvent->getDelta().y, 0.0, 1.0);
if (!ui->validatePad (page, row, step, pd)) ui->drawPad();
else ui->drawPad (row, step);
ui->wheelScrolled = true;
}
}
}
void BJumblrGUI::padsFocusedCallback (BEvents::Event* event)
{
if (!event) return;
BEvents::FocusEvent* focusEvent = (BEvents::FocusEvent*) event;
BWidgets::DrawingSurface* widget = (BWidgets::DrawingSurface*) event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
// Get size of drawing area
const double width = ui->padSurface.getEffectiveWidth ();
const double height = ui->padSurface.getEffectiveHeight ();
const int page = ui->actPage;
const int maxstep = ui->controllerWidgets[NR_OF_STEPS]->getValue ();
const int s0 = maxstep - 1 - int ((focusEvent->getPosition ().y - widget->getYOffset()) / (height / maxstep));
const int r0 = (focusEvent->getPosition ().x - widget->getXOffset()) / (width / maxstep);
const int step = (ui->patternFlipped ? r0 : s0);
const int row = (ui->patternFlipped ? s0 : r0);
if ((row >= 0) && (row < maxstep) && (step >= 0) && (step < maxstep))
{
ui->padSurface.focusText.setText
(
BJUMBLR_LABEL_ROW ": " + std::to_string (row + 1) + "\n" +
BJUMBLR_LABEL_STEP ": " + std::to_string (step + 1) + "\n" +
BJUMBLR_LABEL_LEVEL ": " + BUtilities::to_string (ui->pattern[page].getPad (row, step).level, "%1.2f")
);
}
}
void BJumblrGUI::syncButtonClickedCallback(BEvents::Event* event)
{
if (!event) return;
BWidgets::ValueWidget* widget = (BWidgets::ValueWidget*) event->getWidget ();
if (!widget) return;
float value = widget->getValue();
if (value != 1.0) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
int offset = 0;
if (widget == &ui->zeroStepOffsetButton)
{
offset = (int (ui->controllers[NR_OF_STEPS] - int (ui->cursor) + ui->controllers[STEP_OFFSET])) % int (ui->controllers[NR_OF_STEPS]);
}
else if (widget == &ui->decStepOffsetButton)
{
offset = (int (ui->controllers[STEP_OFFSET] + ui->controllers[NR_OF_STEPS]) - 1) % int (ui->controllers[NR_OF_STEPS]);
}
else if (widget == &ui->hostSyncButton) offset = 0;
else if (widget == &ui->incStepOffsetButton)
{
offset = int (ui->controllers[STEP_OFFSET] + 1) % int (ui->controllers[NR_OF_STEPS]);
}
else return;
ui->syncWidget.setValue (offset);
}
void BJumblrGUI::loadButtonClickedCallback (BEvents::Event* event)
{
if (!event) return;
BWidgets::Widget* widget = event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
if (ui->fileChooser) delete ui->fileChooser;
ui->fileChooser = new SampleChooser
(
200, 140, 640, 400, "filechooser", ui->samplePath,
std::vector<BWidgets::FileFilter>
{
BWidgets::FileFilter {BJUMBLR_LABEL_ALL_FILES, std::regex (".*")},
BWidgets::FileFilter {BJUMBLR_LABEL_AUDIO_FILES, std::regex (".*\\.((wav)|(wave)|(aif)|(aiff)|(au)|(sd2)|(flac)|(caf)|(ogg)|(mp3))$", std::regex_constants::icase)}
},
std::vector<std::string>
{
BJUMBLR_LABEL_OK, BJUMBLR_LABEL_OPEN, BJUMBLR_LABEL_CANCEL,
"", "", BJUMBLR_LABEL_NEW_FOLDER, BJUMBLR_LABEL_CANT_CREATE_NEW_FOLDER, BJUMBLR_LABEL_PLAY_AS_LOOP,
BJUMBLR_LABEL_FILE, BJUMBLR_LABEL_SELECTION_START, BJUMBLR_LABEL_SELECTION_END,
BJUMBLR_LABEL_FRAMES, BJUMBLR_LABEL_NO_FILE_SELECTED
}
);
if (ui->fileChooser)
{
const std::string filename = ui->sampleNameLabel.getText();
if (filename != "")
{
ui->fileChooser->setFileName (ui->sampleNameLabel.getText());
ui->fileChooser->setStart (ui->sampleStart);
ui->fileChooser->setEnd (ui->sampleEnd);
ui->fileChooser->setLoop (ui->sampleLoop);
}
RESIZE ((*ui->fileChooser), 200, 140, 640, 400, ui->sz);
ui->fileChooser->applyTheme (ui->theme);
ui->fileChooser->selectFilter (BJUMBLR_LABEL_AUDIO_FILES);
ui->mContainer.add (*ui->fileChooser);
}
}
void BJumblrGUI::delayButtonsClickedCallback (BEvents::Event* event)
{
if (!event) return;
HaloButton* widget = (HaloButton*) event->getWidget ();
if (!widget) return;
double val = widget->getValue();
if (!val) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
if (widget == &ui->resetDelayButton) ui->manualProgressionDelayWidget.setValue (0.0);
else if (widget == &ui->increaseDelayButton) ui->manualProgressionDelayWidget.setValue (ui->manualProgressionDelayWidget.getValue() + 1.0);
else if (widget == &ui->decreaseDelayButton) ui->manualProgressionDelayWidget.setValue (ui->manualProgressionDelayWidget.getValue() - 1.0);
else if (widget == &ui->setStartDelayButton)
{
ui->manualProgressionDelayWidget.setValue
(
floormod
(
ui->manualProgressionDelayWidget.getValue() - floorfrac (ui->cursor),
ui->controllerWidgets[NR_OF_STEPS]->getValue ()
)
);
}
}
void BJumblrGUI::patternFlippedClickedCallback (BEvents::Event* event)
{
if (!event) return;
BWidgets::Widget* widget = event->getWidget ();
if (!widget) return;
BJumblrGUI* ui = (BJumblrGUI*) widget->getMainWindow();
if (!ui) return;
ui->patternFlipped = !ui->patternFlipped;
ui->monitorWidget.flip (ui->patternFlipped);
ui->setMarkers();
ui->drawPad();
ui->send_flip();
}
void BJumblrGUI::helpButtonClickedCallback (BEvents::Event* event)
{
char cmd[] = WWW_BROWSER_CMD;
char param[] = HELP_URL;
char* argv[] = {cmd, param, NULL};
std::cerr << "BJumblr.lv2#GUI: Call " << HELP_URL << " for help.\n";
if (BUtilities::vsystem (argv) == -1) std::cerr << "BJumblr.lv2#GUI: Couldn't fork.\n";
}
void BJumblrGUI::ytButtonClickedCallback (BEvents::Event* event)
{
char cmd[] = WWW_BROWSER_CMD;
char param[] = YT_URL;
char* argv[] = {cmd, param, NULL};
std::cerr << "BJumblr.lv2#GUI: Call " << YT_URL << " for tutorial video.\n";
if (BUtilities::vsystem (argv) == -1) std::cerr << "BJumblr.lv2#GUI: Couldn't fork.\n";
}
void BJumblrGUI::setMarkers()
{
const double maxstep = controllerWidgets[NR_OF_STEPS]->getValue ();
markerFwd.resize (20 * sz, 20 * sz);
markerRev.resize (20 * sz, 20 * sz);
if (patternFlipped)
{
markerFwd.setMarker (MARKER_DOWN);
markerRev.setMarker (MARKER_UP);
markerFwd.moveTo ((20 + (0.5 + int (cursor)) * (920.0 / maxstep) - 10) * sz, 110 * sz);
markerRev.moveTo ((20 + (0.5 + int (cursor)) * (920.0 / maxstep) - 10) * sz, 560 * sz);
}
else
{
markerFwd.setMarker (MARKER_RIGHT);
markerRev.setMarker (MARKER_LEFT);
markerFwd.moveTo (0, (130 + (maxstep - 0.5 - int (cursor)) * (430.0 / maxstep) - 10) * sz);
markerRev.moveTo (940 * sz, (130 + (maxstep - 0.5 - int (cursor)) * (430.0 / maxstep) - 10) *sz);
}
}
void BJumblrGUI::drawPad ()
{
cairo_surface_t* surface = padSurface.getDrawingSurface();
cairo_t* cr = cairo_create (surface);
int maxstep = controllerWidgets[NR_OF_STEPS]->getValue ();
for (int row = 0; row < maxstep; ++row)
{
for (int step = 0; step < maxstep; ++step) drawPad (cr, row, step);
}
cairo_destroy (cr);
padSurface.update();
}
void BJumblrGUI::drawPad (int row, int step)
{
cairo_surface_t* surface = padSurface.getDrawingSurface();
cairo_t* cr = cairo_create (surface);
drawPad (cr, row, step);
cairo_destroy (cr);
padSurface.update();
}
void BJumblrGUI::drawPad (cairo_t* cr, int row, int step)
{
int maxstep = controllerWidgets[NR_OF_STEPS]->getValue ();
if ((!cr) || (cairo_status (cr) != CAIRO_STATUS_SUCCESS) || (row < 0) || (row >= maxstep) || (step < 0) ||
(step >= maxstep)) return;
// Get size of drawing area
const double width = padSurface.getEffectiveWidth ();
const double height = padSurface.getEffectiveHeight ();
const double w = width / maxstep;
const double h = height / maxstep;
const double x = (patternFlipped ? step : row) * w;
const double y = (maxstep - 1 - (patternFlipped ? row : step)) * h;
const double xr = round (x);
const double yr = round (y);
const double wr = round (x + w) - xr;
const double hr = round (y + h) - yr;
// Draw background
// Odd or even?
BColors::Color bg =
(
int (cursor) == step ?
BColors::Color (0.25, 0.25, 0.0, 1.0) :
((int (row / 4) % 2) ? oddPadBgColor : evenPadBgColor)
);
// Highlight selection
int clipRMin = clipBoard.origin.first;
int clipRMax = clipBoard.origin.first + clipBoard.extends.first;
if (clipRMin > clipRMax) std::swap (clipRMin, clipRMax);
int clipSMin = clipBoard.origin.second;
int clipSMax = clipBoard.origin.second + clipBoard.extends.second;
if (clipSMin > clipSMax) std::swap (clipSMin, clipSMax);
if ((!clipBoard.ready) && (row >= clipRMin) && (row <= clipRMax) && (step >= clipSMin) && (step <= clipSMax)) bg.applyBrightness (1.5);
cairo_set_source_rgba (cr, CAIRO_RGBA (bg));
cairo_set_line_width (cr, 0.0);
cairo_rectangle (cr, xr, yr, wr, hr);
cairo_fill (cr);
// Draw pad
Pad pd = pattern[actPage].getPad (row, step);
Pad pdc = pattern[actPage].getPad (row, cursor);
BColors::Color color = BColors::yellow;
color.applyBrightness (pd.level - 1.0);
if ((tabs[actPage].playSymbol.getState() == BColors::ACTIVE) && (pdc.level != 0.0)) color.applyBrightness (pdc.level * 0.75);
drawButton (cr, xr + 1, yr + 1, wr - 2, hr - 2, color);
}
static LV2UI_Handle instantiate (const LV2UI_Descriptor *descriptor,
const char *plugin_uri,
const char *bundle_path,
LV2UI_Write_Function write_function,
LV2UI_Controller controller,
LV2UI_Widget *widget,
const LV2_Feature *const *features)
{
PuglNativeView parentWindow = 0;
LV2UI_Resize* resize = NULL;
if (strcmp(plugin_uri, BJUMBLR_URI) != 0)
{
std::cerr << "BJumblr.lv2#GUI: GUI does not support plugin with URI " << plugin_uri << std::endl;
return NULL;
}
for (int i = 0; features[i]; ++i)
{
if (!strcmp(features[i]->URI, LV2_UI__parent)) parentWindow = (PuglNativeView) features[i]->data;
else if (!strcmp(features[i]->URI, LV2_UI__resize)) resize = (LV2UI_Resize*)features[i]->data;
}
if (parentWindow == 0) std::cerr << "BJumblr.lv2#GUI: No parent window.\n";
// New instance
BJumblrGUI* ui;
try {ui = new BJumblrGUI (bundle_path, features, parentWindow);}
catch (std::exception& exc)
{
std::cerr << "BJumblr.lv2#GUI: Instantiation failed. " << exc.what () << std::endl;
return NULL;
}
ui->controller = controller;
ui->write_function = write_function;
// Reduce min GUI size for small displays
double sz = 1.0;
int screenWidth = getScreenWidth ();
int screenHeight = getScreenHeight ();
if ((screenWidth < 730) || (screenHeight < 460)) sz = 0.5;
else if ((screenWidth < 1060) || (screenHeight < 660)) sz = 0.66;
if (resize) resize->ui_resize(resize->handle, 1020 * sz, 620 * sz);
*widget = (LV2UI_Widget) puglGetNativeWindow (ui->getPuglView ());
ui->send_ui_on();
return (LV2UI_Handle) ui;
}
static void cleanup(LV2UI_Handle ui)
{
BJumblrGUI* self = (BJumblrGUI*) ui;
if (self) delete self;
}
static void port_event(LV2UI_Handle ui, uint32_t port_index, uint32_t buffer_size,
uint32_t format, const void* buffer)
{
BJumblrGUI* self = (BJumblrGUI*) ui;
if (self) self->port_event(port_index, buffer_size, format, buffer);
}
static int call_idle (LV2UI_Handle ui)
{
BJumblrGUI* self = (BJumblrGUI*) ui;
if (self) self->handleEvents ();
return 0;
}
static int call_resize (LV2UI_Handle ui, int width, int height)
{
BJumblrGUI* self = (BJumblrGUI*) ui;
if (!self) return 0;
BEvents::ExposeEvent* ev = new BEvents::ExposeEvent (self, self, BEvents::CONFIGURE_REQUEST_EVENT, self->getPosition().x, self->getPosition().y, width, height);
self->addEventToQueue (ev);
return 0;
}
static const LV2UI_Idle_Interface idle = {call_idle};
static const LV2UI_Resize resize = {nullptr, call_resize} ;
static const void* extension_data(const char* uri)
{
if (!strcmp(uri, LV2_UI__idleInterface)) return &idle;
if(!strcmp(uri, LV2_UI__resize)) return &resize;
else return NULL;
}
static const LV2UI_Descriptor guiDescriptor = {
BJUMBLR_GUI_URI,
instantiate,
cleanup,
port_event,
extension_data
};
// LV2 Symbol Export
LV2_SYMBOL_EXPORT const LV2UI_Descriptor *lv2ui_descriptor(uint32_t index)
{
switch (index) {
case 0: return &guiDescriptor;
default:return NULL;
}
}
/* End of LV2 specific declarations
*
* *****************************************************************************
*
*
*/
| 80,519
|
C++
|
.cpp
| 2,204
| 33.081216
| 166
| 0.66709
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,374
|
BJumblr.cpp
|
sjaehn_BJumblr/src/BJumblr.cpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "BJumblr.hpp"
#ifndef SF_FORMAT_MP3
#ifndef MINIMP3_IMPLEMENTATION
#define MINIMP3_IMPLEMENTATION
#endif
#endif
#include "Sample.hpp"
inline double floorfrac (const double value) {return value - floor (value);}
inline double floormod (const double numer, const double denom) {return numer - floor(numer / denom) * denom;}
BJumblr::BJumblr (double samplerate, const LV2_Feature* const* features) :
map (NULL), unmap (NULL), workerSchedule (NULL),
controlPort (nullptr), notifyPort (nullptr),
audioInput1 (nullptr), audioInput2 (nullptr),
audioOutput1 (nullptr), audioOutput2 (nullptr),
notifyForge (), notifyFrame (),
waveform {0.0f}, waveformCounter (0), lastWaveformCounter (0),
new_controllers {nullptr}, controllers {0},
editMode (0), midiLearn (false), nrPages (1),
schedulePage (0), playPage (0), lastPage (0),
pads {Pad()}, patternFlipped (false),
sample (nullptr), sampleAmp (1.0f),
rate (samplerate), bpm (120.0f), beatsPerBar (4.0f), beatUnit (0),
speed (0.0f), bar (0), barBeat (0.0f),
outCapacity (0), position (0.0), cursor (0.0f), offset (0.0), refFrame (0),
progressionDelay (0), progressionDelayFrac (0),
maxBufferSize (samplerate * 24 * 32),
audioBuffer1 (maxBufferSize, 0.0f),
audioBuffer2 (maxBufferSize, 0.0f),
audioBufferCounter (0), audioBufferSize (samplerate * 8),
activated (false),
ui_on (false), scheduleNotifyPadsToGui (false),
scheduleNotifyFullPatternToGui {false},
scheduleNotifySchedulePageToGui (false),
scheduleNotifyPlaybackPageToGui (false),
scheduleNotifyStatusToGui (false),
scheduleNotifyWaveformToGui (false), scheduleNotifySamplePathToGui (false),
scheduleNotifyMidiLearnedToGui (false),
scheduleNotifyStateChanged (false),
message ()
{
// Inits
for (std::array <PadMessage, MAXSTEPS * MAXSTEPS>& p : padMessageBuffer)
{
p.fill ({PadMessage()});
p[0] = PadMessage (ENDPADMESSAGE);
};
//Scan host features for URID map
LV2_URID_Map* m = NULL;
LV2_URID_Unmap* u = NULL;
for (int i = 0; features[i]; ++i)
{
if (strcmp (features[i]->URI, LV2_URID__map) == 0)
{
m = (LV2_URID_Map*) features[i]->data;
}
else if (strcmp (features[i]->URI, LV2_URID__unmap) == 0)
{
u = (LV2_URID_Unmap*) features[i]->data;
}
else if (!strcmp(features[i]->URI, LV2_WORKER__schedule))
{
workerSchedule = (LV2_Worker_Schedule*)features[i]->data;
}
}
if (!m) throw std::invalid_argument ("BJumblr.lv2: Host does not support urid:map.");
if (!workerSchedule) throw std::invalid_argument ("BJumblr.lv2: Host does not support work:schedule.");
//Map URIS
map = m;
unmap = u;
getURIs (m, &uris);
// Initialize notify
lv2_atom_forge_init (¬ifyForge, map);
// Initialize pads
for (int p = 0; p < MAXPAGES; ++p)
{
for (int i = 0; i < MAXSTEPS; ++i) pads[p][i][i].level = 1.0;
}
// Initialize controllers
// Controllers are zero initialized and will get data from host, only
// NR_OF_STEPS need to be set to prevent div by zero.
controllers[NR_OF_STEPS] = 32;
ui_on = false;
}
BJumblr::~BJumblr()
{
if (sample) delete sample;
}
void BJumblr::connect_port (uint32_t port, void *data)
{
switch (port)
{
case CONTROL:
controlPort = (LV2_Atom_Sequence*) data;
break;
case NOTIFY:
notifyPort = (LV2_Atom_Sequence*) data;
break;
case AUDIO_IN_1:
audioInput1 = (float*) data;
break;
case AUDIO_IN_2:
audioInput2 = (float*) data;
break;
case AUDIO_OUT_1:
audioOutput1 = (float*) data;
break;
case AUDIO_OUT_2:
audioOutput2 = (float*) data;
break;
default:
// Connect controllers
if ((port >= CONTROLLERS) && (port < CONTROLLERS + MAXCONTROLLERS)) new_controllers[port - CONTROLLERS] = (float*) data;
}
}
void BJumblr::runSequencer (const int start, const int end)
{
int iNrOfSteps = controllers[NR_OF_STEPS];
double delay = progressionDelay + controllers[MANUAL_PROGRSSION_DELAY];
// Calculate start position data
double relpos = getPositionFromFrames (start - refFrame); // Position relative to reference frame
double pos = floorfrac (position + relpos); // 0..1 position
double step = floormod (pos * controllers[NR_OF_STEPS] + controllers[STEP_OFFSET] + delay, controllers[NR_OF_STEPS]); // 0..NR_OF_STEPS position
for (int i = start; i < end; ++i)
{
int iStep = step;
float input1 = 0;
float input2 = 0;
// Store audio input signal to buffer
if (controllers[SOURCE] == 0) // Audio stream
{
input1 = audioInput1[i];
input2 = audioInput2[i];
}
else // Sample
{
input1 = 0;
input2 = 0;
if (sample)
{
if (sample->end > sample->start)
{
const uint64_t f0 = getFramesFromValue (pos * controllers[NR_OF_STEPS] * controllers[STEP_SIZE]);
const int64_t frame = (sample->loop ? (f0 % (sample->end - sample->start)) + sample->start : f0 + sample->start);
if (frame < sample->end)
{
input1 = sampleAmp * sample->get (frame, 0, rate);
input2 = sampleAmp * sample->get (frame, 1, rate);
}
}
}
}
audioBuffer1[audioBufferCounter] = input1;
audioBuffer2[audioBufferCounter] = input2;
if (controllers[PLAY] == 1.0f) // Play
{
double fracTime = 0; // Time from start of step
switch (int (controllers[STEP_BASE]))
{
case SECONDS: fracTime = (step - iStep) * controllers[STEP_SIZE];
break;
case BEATS: fracTime = (step - iStep) * controllers[STEP_SIZE] / (bpm / 60);
break;
case BARS: fracTime = (step - iStep) * controllers[STEP_SIZE] / (bpm / (60 * beatsPerBar));
break;
default: break;
}
double fade = (fracTime < FADETIME ? fracTime / FADETIME : 1.0);
double prevAudio1 = 0;
double prevAudio2 = 0;
double audio1 = 0;
double audio2 = 0;
// Fade out: Extrapolate audio using previous step data
if (fade < 1.0)
{
// Begin of step: Page change scheduled ?
if ((fade < 0.1) && (schedulePage != playPage))
{
playPage = schedulePage;
scheduleNotifyPlaybackPageToGui = true;
scheduleNotifyStateChanged = true;
}
int iPrevStep = (fade < 1.0 ? (iStep + iNrOfSteps - 1) % iNrOfSteps : iStep); // Previous step
for (int r = 0; r < iNrOfSteps; ++r)
{
float factor = pads[lastPage][r][iPrevStep].level;
if (factor != 0.0)
{
int stepDiff = floormod (iPrevStep - r - delay, iNrOfSteps);
size_t frame = size_t (maxBufferSize + audioBufferCounter - audioBufferSize * (double (stepDiff) / double (iNrOfSteps))) % maxBufferSize;
prevAudio1 += factor * audioBuffer1[frame];
prevAudio2 += factor * audioBuffer2[frame];
if (editMode == 1) break; // Only one active pad allowed in REPLACE mode
}
}
}
else lastPage = playPage;
// Calculate audio for this step
for (int r = 0; r < iNrOfSteps; ++r)
{
float factor = pads[playPage][r][iStep].level;
if (factor != 0.0)
{
int stepDiff = floormod (iStep - r - delay, iNrOfSteps);
size_t frame = size_t (maxBufferSize + audioBufferCounter - audioBufferSize * (double (stepDiff) / double (iNrOfSteps))) % maxBufferSize;
audio1 += factor * audioBuffer1[frame];
audio2 += factor * audioBuffer2[frame];
if (editMode == 1) break; // Only one active pad allowed in REPLACE mode
}
}
// Mix audio and store into output
audioOutput1[i] = fade * audio1 + (1 - fade) * prevAudio1;
audioOutput2[i] = fade * audio2 + (1 - fade) * prevAudio2;
waveformCounter = int ((pos + controllers[STEP_OFFSET] / controllers[NR_OF_STEPS]) * WAVEFORMSIZE) % WAVEFORMSIZE;
waveform[waveformCounter] = (input1 + input2) / 2;
}
else if (controllers[PLAY] == 2.0f) // Bypass
{
audioOutput1[i] = input1;
audioOutput2[i] = input2;
waveformCounter = int ((pos + controllers[STEP_OFFSET] / controllers[NR_OF_STEPS]) * WAVEFORMSIZE) % WAVEFORMSIZE;
waveform[waveformCounter] = (input1 + input2) / 2;
}
else // Stop
{
audioOutput1[i] = 0;
audioOutput2[i] = 0;
}
// Calculate next position
relpos = getPositionFromFrames (i + 1 - refFrame);
pos = floorfrac (position + relpos);
step = floormod (pos * controllers[NR_OF_STEPS] + controllers[STEP_OFFSET] + delay, controllers[NR_OF_STEPS]);
// Change step ? Update delaySteps
int nextiStep = step;
if (nextiStep != iStep)
{
progressionDelayFrac += controllers[SPEED] - 1;
double floorDelayFrac = floor (progressionDelayFrac);
progressionDelay += floorDelayFrac;
progressionDelayFrac -= floorDelayFrac;
scheduleNotifyStatusToGui = true;
}
// Increment counter
audioBufferCounter = (audioBufferCounter + 1) % maxBufferSize;
}
}
double BJumblr::getPositionFromBeats (const double beats) const
{
if (controllers[STEP_SIZE] == 0.0) return 0.0;
switch (int (controllers[STEP_BASE]))
{
case SECONDS: return (bpm ? beats / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS] * (bpm / 60.0)) : 0.0);
case BEATS: return beats / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
case BARS: return (beatsPerBar ? beats / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS] * beatsPerBar) : 0.0);
default: return 0.0;
}
}
double BJumblr::getPositionFromFrames (const uint64_t frames) const
{
if ((controllers[STEP_SIZE] == 0.0) || (rate == 0)) return 0.0;
switch (int (controllers[STEP_BASE]))
{
case SECONDS: return frames * (1.0 / rate) / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
case BEATS: return (bpm ? frames * (speed / (rate / (bpm / 60))) / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]) : 0.0);
case BARS: return (bpm && beatsPerBar ? frames * (speed / (rate / (bpm / 60))) / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS] * beatsPerBar) : 0.0);
default: return 0.0;
}
}
double BJumblr::getPositionFromSeconds (const double seconds) const
{
if (controllers[STEP_SIZE] == 0.0) return 0.0;
switch (int (controllers[STEP_BASE]))
{
case SECONDS : return seconds / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
case BEATS: return seconds * (bpm / 60.0) / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
case BARS: return (beatsPerBar ? seconds * (bpm / 60.0 / beatsPerBar) / (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]) : 0.0);
default: return 0;
}
}
uint64_t BJumblr::getFramesFromValue (const double value) const
{
if (bpm < 1.0) return 0;
switch (int (controllers[STEP_BASE]))
{
case SECONDS : return value * rate;
case BEATS: return value * (60.0 / bpm) * rate;
case BARS: return value * beatsPerBar * (60.0 / bpm) * rate;
default: return 0;
}
}
void BJumblr::activate() {activated = true;}
void BJumblr::deactivate() {activated = false;}
void BJumblr::run (uint32_t n_samples)
{
uint32_t last_t = 0;
if ((!controlPort) || (!notifyPort) || (!audioInput1) || (!audioInput2) || (!audioOutput1) || (!audioOutput2)) return;
// Init notify port
uint32_t space = notifyPort->atom.size;
lv2_atom_forge_set_buffer(¬ifyForge, (uint8_t*) notifyPort, space);
lv2_atom_forge_sequence_head(¬ifyForge, ¬ifyFrame, 0);
// Validate controllers
for (int i = 0; i < MAXCONTROLLERS; ++i)
{
if (new_controllers[i])
{
float val = validateValue (*(new_controllers[i]), controllerLimits[i]);
if (val != *(new_controllers[i]))
{
fprintf (stderr, "BJumblr.lv2: Value out of range in run (): Controller#%i\n", i);
*(new_controllers[i]) = val;
// TODO update GUI controller
}
if (controllers[i] != val)
{
if (i == SOURCE)
{
if (val == 0.0) message.deleteMessage (CANT_OPEN_SAMPLE);
}
else if (i == STEP_BASE)
{
if (val == SECONDS)
{
if (bpm < 1.0) message.setMessage (JACK_STOP_MSG);
else message.deleteMessage (JACK_STOP_MSG);
}
else
{
if ((speed == 0) || (bpm < 1.0)) message.setMessage (JACK_STOP_MSG);
else message.deleteMessage (JACK_STOP_MSG);
}
}
else if (i == PAGE)
{
schedulePage = val;
scheduleNotifySchedulePageToGui = true;
}
controllers[i] = val;
uint64_t size = getFramesFromValue (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
audioBufferSize = LIMIT (size, 0, maxBufferSize);
// Also re-calculate waveform buffer for GUI
if ((i == SOURCE) || (i == NR_OF_STEPS) || (i == STEP_BASE) || (i == STEP_SIZE) || (i == STEP_OFFSET))
{
for (size_t i = 0; i < WAVEFORMSIZE; ++i)
{
double di = double (i) / WAVEFORMSIZE;
int wcount = size_t ((position + di + controllers[STEP_OFFSET] / controllers[NR_OF_STEPS]) * WAVEFORMSIZE) % WAVEFORMSIZE;
size_t acount = (maxBufferSize + audioBufferCounter - audioBufferSize + (i * audioBufferSize) / WAVEFORMSIZE) % maxBufferSize;
waveform[wcount] = (audioBuffer1[acount] + (audioBuffer2[acount])) / 2;
}
if (ui_on) notifyWaveformToGui ((waveformCounter + 1) % WAVEFORMSIZE, waveformCounter);
}
}
}
}
// Read CONTROL port (notifications from GUI and host)
LV2_ATOM_SEQUENCE_FOREACH (controlPort, ev)
{
if ((ev->body.type == uris.atom_Object) || (ev->body.type == uris.atom_Blank))
{
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)&ev->body;
// GUI on
if (obj->body.otype == uris.ui_on)
{
ui_on = true;
for (int i = 0; i < nrPages; ++i) scheduleNotifyFullPatternToGui[i] = true;
scheduleNotifyPadsToGui = true;
scheduleNotifyStatusToGui = true;
scheduleNotifySamplePathToGui = true;
}
// GUI off
else if (obj->body.otype == uris.ui_off)
{
ui_on = false;
}
// GUI pad changed notifications
else if (obj->body.otype == uris.notify_padEvent)
{
LV2_Atom *oEd = NULL, *oPg = NULL, *oPd = NULL, *oPat = NULL;
int page = -1;
lv2_atom_object_get (obj,
uris.notify_editMode, &oEd,
uris.notify_padPage, &oPg,
uris.notify_pad, &oPd,
uris.notify_padFullPattern, &oPat,
NULL);
// EditMode notification
if (oEd && (oEd->type == uris.atom_Int)) editMode = ((LV2_Atom_Int*)oEd)->body;
// padPage notification
if (oPg && (oPg->type == uris.atom_Int))
{
page = ((LV2_Atom_Int*)oPg)->body;
if (page >= nrPages)
{
nrPages = LIMIT (page + 1, 1, MAXPAGES);
if (playPage >= nrPages)
{
schedulePage = nrPages - 1;
scheduleNotifySchedulePageToGui = true;
}
}
}
// Pad notification
if (oPd && (oPd->type == uris.atom_Vector) && (page >= 0) && (page < MAXPAGES))
{
const LV2_Atom_Vector* vec = (const LV2_Atom_Vector*) oPd;
if (vec->body.child_type == uris.atom_Float)
{
const uint32_t size = (uint32_t) ((oPd->size - sizeof(LV2_Atom_Vector_Body)) / sizeof (PadMessage));
PadMessage* pMes = (PadMessage*) (&vec->body + 1);
for (unsigned int i = 0; i < size; ++i)
{
int row = pMes[i].row;
int step = pMes[i].step;
// Copy PadMessages to pads
if ((row >= 0) && (row < MAXSTEPS) && (step >= 0) && (step < MAXSTEPS))
{
Pad pd (pMes[i].level);
Pad valPad = validatePad (pd);
pads[page][row][step] = valPad;
if (valPad != pd)
{
fprintf (stderr, "BJumblr.lv2: Pad out of range in run (): pads[%i][%i][%i].\n", page, row, step);
padMessageBufferAppendPad (page, row, step, valPad);
scheduleNotifyPadsToGui = true;
}
scheduleNotifyStateChanged = true;
}
}
}
}
// Full pattern notification
if (oPat && (oPat->type == uris.atom_Vector) && (page >= 0) && (page < MAXPAGES))
{
const LV2_Atom_Vector* vec = (const LV2_Atom_Vector*) oPat;
if (vec->body.child_type == uris.atom_Float)
{
const uint32_t size = (uint32_t) ((oPat->size - sizeof(LV2_Atom_Vector_Body)) / sizeof (Pad));
Pad* data = (Pad*) (&vec->body + 1);
if (size == MAXSTEPS * MAXSTEPS)
{
// Copy pattern data
for (int r = 0; r < MAXSTEPS; ++r)
{
for (int s = 0; s < MAXSTEPS; ++s)
{
pads[page][r][s] = data[r * MAXSTEPS + s];
}
}
scheduleNotifyStateChanged = true;
}
else fprintf (stderr, "BJumblr.lv2: Corrupt pattern size of %i for page %i.\n", size, page);
}
}
}
// Status notifications
else if (obj->body.otype == uris.notify_statusEvent)
{
LV2_Atom *oMx = NULL, *oPp = NULL, *oMl = NULL, *oFlip = NULL;
lv2_atom_object_get (obj,
uris.notify_maxPage, &oMx,
uris.notify_playbackPage, &oPp,
uris.notify_requestMidiLearn, &oMl,
uris.notify_padFlipped, &oFlip,
NULL);
// padMaxPage notification
if (oMx && (oMx->type == uris.atom_Int))
{
int newPages = ((LV2_Atom_Int*)oMx)->body;
if (newPages != nrPages)
{
nrPages = LIMIT (newPages, 1, MAXPAGES);
if (playPage >= nrPages)
{
schedulePage = nrPages - 1;
scheduleNotifyPlaybackPageToGui = true;
}
}
}
// playbackPage notification
if (oPp && (oPp->type == uris.atom_Int))
{
int newPp = ((LV2_Atom_Int*)oPp)->body;
if (newPp != playPage)
{
playPage = LIMIT (newPp, 0, MAXPAGES - 1);
scheduleNotifyStateChanged = true;
}
}
// Midi learn request notification
if (oMl && (oMl->type == uris.atom_Bool)) midiLearn = ((LV2_Atom_Bool*)oMl)->body;
// Pattern orientation
if (oFlip && (oFlip->type == uris.atom_Bool))
{
patternFlipped = ((LV2_Atom_Bool*)oFlip)->body;
scheduleNotifyStateChanged = true;
}
}
// Sample path notification -> forward to worker
else if (obj->body.otype ==uris.notify_pathEvent)
{
LV2_Atom* oPath = NULL, *oStart = NULL, *oEnd = NULL, *oAmp = NULL, *oLoop = NULL;
lv2_atom_object_get
(
obj,
uris.notify_samplePath, &oPath,
uris.notify_sampleStart, &oStart,
uris.notify_sampleEnd, &oEnd,
uris.notify_sampleAmp, &oAmp,
uris.notify_sampleLoop, &oLoop,
NULL
);
// New sample
if (oPath && (oPath->type == uris.atom_Path))
{
workerSchedule->schedule_work (workerSchedule->handle, lv2_atom_total_size(&ev->body), &ev->body);
}
// Only start / end /amp / loop changed
else if (sample)
{
if (oStart && (oStart->type == uris.atom_Long)) sample->start = LIMIT (((LV2_Atom_Long*)oStart)->body, 0, sample->info.frames - 1);
if (oEnd && (oEnd->type == uris.atom_Long)) sample->end = LIMIT (((LV2_Atom_Long*)oEnd)->body, 0, sample->info.frames);
if (oAmp && (oAmp->type == uris.atom_Float)) sampleAmp = LIMIT (((LV2_Atom_Float*)oAmp)->body, 0.0f, 1.0f);
if (oLoop && (oLoop->type == uris.atom_Bool)) sample->loop = bool(((LV2_Atom_Bool*)oLoop)->body);
scheduleNotifyStateChanged = true;
}
}
// Process time / position data
else if (obj->body.otype == uris.time_Position)
{
bool scheduleUpdatePosition = false;
// Update bpm, speed, position
LV2_Atom *oBbeat = NULL, *oBpm = NULL, *oSpeed = NULL, *oBpb = NULL, *oBu = NULL, *oBar = NULL;
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)&ev->body;
lv2_atom_object_get
(
obj, uris.time_bar, &oBar,
uris.time_barBeat, &oBbeat,
uris.time_beatsPerMinute, &oBpm,
uris.time_beatsPerBar, &oBpb,
uris.time_beatUnit, &oBu,
uris.time_speed, &oSpeed,
NULL
);
// BPM changed?
if (oBpm && (oBpm->type == uris.atom_Float) && (bpm != ((LV2_Atom_Float*)oBpm)->body))
{
bpm = ((LV2_Atom_Float*)oBpm)->body;
scheduleUpdatePosition = true;
}
// Beats per bar changed?
if (oBpb && (oBpb->type == uris.atom_Float) && (beatsPerBar != ((LV2_Atom_Float*)oBpb)->body))
{
beatsPerBar = ((LV2_Atom_Float*)oBpb)->body;
scheduleUpdatePosition = true;
}
// BeatUnit changed?
if (oBu && (oBu->type == uris.atom_Int) && (beatUnit != ((LV2_Atom_Int*)oBu)->body))
{
beatUnit = ((LV2_Atom_Int*)oBu)->body;
scheduleUpdatePosition = true;
}
// Speed changed?
if (oSpeed && (oSpeed->type == uris.atom_Float) && (speed != ((LV2_Atom_Float*)oSpeed)->body))
{
speed = ((LV2_Atom_Float*)oSpeed)->body;
scheduleUpdatePosition = true;
}
// Bar position changed
if (oBar && (oBar->type == uris.atom_Long) && (bar != ((long)((LV2_Atom_Long*)oBar)->body)))
{
bar = ((LV2_Atom_Long*)oBar)->body;
scheduleUpdatePosition = true;
}
// Beat position changed (during playing) ?
if (oBbeat && (oBbeat->type == uris.atom_Float) && (barBeat != ((LV2_Atom_Float*)oBbeat)->body))
{
barBeat = ((LV2_Atom_Float*)oBbeat)->body;
scheduleUpdatePosition = true;
}
if (scheduleUpdatePosition)
{
// Hard set new position if new data received
double pos = getPositionFromBeats (barBeat + beatsPerBar * bar);
position = floorfrac (pos - offset);
refFrame = ev->time.frames;
uint64_t size = getFramesFromValue (controllers[STEP_SIZE] * controllers[NR_OF_STEPS]);
audioBufferSize = LIMIT (size, 0, maxBufferSize);
// Store message
if (((bpm < 1.0) || (speed == 0.0)) && (controllers[STEP_BASE] != SECONDS)) message.setMessage (JACK_STOP_MSG);
else message.deleteMessage (JACK_STOP_MSG);
}
}
}
// Read incoming MIDI events
else if (ev->body.type == uris.midi_Event)
{
const uint8_t* const msg = (const uint8_t*)(ev + 1);
const uint8_t status = (msg[0] >> 4);
const uint8_t channel = msg[0] & 0x0F;
const uint8_t note = ((status == 8) || (status == 9) || (status == 11) ? msg[1] : 0);
const uint8_t value = ((status == 8) || (status == 9) || (status == 11) ? msg[2] : 0);
if (midiLearn)
{
midiLearned[0] = status;
midiLearned[1] = channel;
midiLearned[2] = note;
midiLearned[3] = value;
midiLearn = false;
scheduleNotifyMidiLearnedToGui = true;
}
else
{
for (int p = 0; p < nrPages; ++p)
{
if
(
controllers[MIDI + p * NR_MIDI_CTRLS + STATUS] &&
(controllers[MIDI + p * NR_MIDI_CTRLS + STATUS] == status) &&
(
(controllers[MIDI + p * NR_MIDI_CTRLS + CHANNEL] == 0) ||
(controllers[MIDI + p * NR_MIDI_CTRLS + CHANNEL] - 1 == channel)
) &&
(
(controllers[MIDI + p * NR_MIDI_CTRLS + NOTE] == 128) ||
(controllers[MIDI + p * NR_MIDI_CTRLS + NOTE] == note)
) &&
(
(controllers[MIDI + p * NR_MIDI_CTRLS + VALUE] == 128) ||
(controllers[MIDI + p * NR_MIDI_CTRLS + VALUE] == value)
)
)
{
schedulePage = p;
scheduleNotifySchedulePageToGui = true;
break;
}
}
}
}
// Update for this iteration
uint32_t next_t = (ev->time.frames < n_samples ? ev->time.frames : n_samples);
runSequencer (last_t, next_t);
last_t = next_t;
}
// Update for the remainder of the cycle
if (last_t < n_samples) runSequencer (last_t, n_samples);
// Update position in case of no new barBeat submitted on next call
double relpos = getPositionFromFrames (n_samples - refFrame); // Position relative to reference frame
position = floorfrac (position + relpos);
refFrame = 0;
if (controllers[PLAY])
{
cursor = floormod
(
position * controllers[NR_OF_STEPS] + controllers[STEP_OFFSET] + progressionDelay + controllers[MANUAL_PROGRSSION_DELAY],
controllers[NR_OF_STEPS]
);
scheduleNotifyStatusToGui = true;
}
if (waveformCounter != lastWaveformCounter) scheduleNotifyWaveformToGui = true;
if (ui_on)
{
if (scheduleNotifyStatusToGui) notifyStatusToGui();
if (scheduleNotifyPadsToGui) notifyPadsToGui();
if (scheduleNotifyWaveformToGui) notifyWaveformToGui (lastWaveformCounter, waveformCounter);
if (scheduleNotifySamplePathToGui) notifySamplePathToGui ();
if (scheduleNotifySchedulePageToGui) notifySchedulePageToGui ();
if (scheduleNotifyPlaybackPageToGui) notifyPlaybackPageToGui ();
if (scheduleNotifyMidiLearnedToGui) notifyMidiLearnedToGui ();
if (message.isScheduled ()) notifyMessageToGui();
}
if (scheduleNotifyStateChanged) notifyStateChanged();
lv2_atom_forge_pop(¬ifyForge, ¬ifyFrame);
}
LV2_State_Status BJumblr::state_save (LV2_State_Store_Function store, LV2_State_Handle handle, uint32_t flags,
const LV2_Feature* const* features)
{
// Store sample path
if (sample && sample->path && (sample->path[0] != 0) && (controllers[SOURCE] == 1.0))
{
LV2_State_Map_Path* mapPath = NULL;
#ifdef LV2_STATE__freePath
LV2_State_Free_Path* freePath = NULL;
#endif
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_STATE__mapPath) == 0)
{
mapPath = (LV2_State_Map_Path*) features[i]->data;
break;
}
}
#ifdef LV2_STATE__freePath
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_STATE__freePath) == 0)
{
freePath = (LV2_State_Free_Path*) features[i]->data;
break;
}
}
#endif
if (mapPath)
{
char* abstrPath = mapPath->abstract_path(mapPath->handle, sample->path);
if (abstrPath)
{
fprintf(stderr, "BJumblr.lv2: Save abstr_path:%s\n", abstrPath);
store(handle, uris.notify_samplePath, abstrPath, strlen (abstrPath) + 1, uris.atom_Path, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
store(handle, uris.notify_sampleStart, &sample->start, sizeof (sample->start), uris.atom_Long, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
store(handle, uris.notify_sampleEnd, &sample->end, sizeof (sample->end), uris.atom_Long, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
store(handle, uris.notify_sampleAmp, &sampleAmp, sizeof (sampleAmp), uris.atom_Float, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
const int32_t sloop = int32_t (sample->loop);
store(handle, uris.notify_sampleLoop, &sloop, sizeof (sloop), uris.atom_Bool, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
#ifdef LV2_STATE__freePath
if (freePath) freePath->free_path (freePath->handle, abstrPath);
else
#endif
{
free (abstrPath);
}
}
else fprintf(stderr, "BJumblr.lv2: Can't generate abstr_path from %s\n", sample->path);
}
else
{
fprintf (stderr, "BJumblr.lv2: Feature map_path not available! Can't save sample!\n" );
return LV2_STATE_ERR_NO_FEATURE;
}
}
// Store pattern orientation
store(handle, uris.notify_padFlipped, &patternFlipped, sizeof (patternFlipped), uris.atom_Bool, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE);
// Store playbackPage
uint32_t pp = playPage;
store (handle, uris.notify_playbackPage, &pp, sizeof(uint32_t), uris.atom_Int, LV2_STATE_IS_POD);
// Store edit mode
uint32_t em = editMode;
store (handle, uris.notify_editMode, &em, sizeof(uint32_t), uris.atom_Int, LV2_STATE_IS_POD);
// Store pads
char padDataString[0x80100] = "\nMatrix data:\n";
for (int page = 0; page < nrPages; ++page)
{
for (int step = 0; step < MAXSTEPS; ++step)
{
for (int row = 0; row < MAXSTEPS; ++row)
{
Pad* pd = &pads[page][row][step];
if (*pd != Pad())
{
char valueString[64];
int id = step * MAXSTEPS + row;
snprintf (valueString, 62, "pg:%d; id:%d; lv:%f", page, id, pd->level);
if ((step < MAXSTEPS - 1) || (row < MAXSTEPS)) strcat (valueString, ";\n");
else strcat(valueString, "\n");
strcat (padDataString, valueString);
}
}
}
}
store (handle, uris.state_pad, padDataString, strlen (padDataString) + 1, uris.atom_String, LV2_STATE_IS_POD);
return LV2_STATE_SUCCESS;
}
LV2_State_Status BJumblr::state_restore (LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags,
const LV2_Feature* const* features)
{
// Get host features
LV2_Worker_Schedule* schedule = nullptr;
LV2_State_Map_Path* mapPath = nullptr;
#ifdef LV2_STATE__freePath
LV2_State_Free_Path* freePath = NULL;
#endif
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_STATE__mapPath) == 0)
{
mapPath = (LV2_State_Map_Path*) features[i]->data;
break;
}
}
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_WORKER__schedule) == 0)
{
schedule = (LV2_Worker_Schedule*) features[i]->data;
break;
}
}
#ifdef LV2_STATE__freePath
for (int i = 0; features[i]; ++i)
{
if (strcmp(features[i]->URI, LV2_STATE__freePath) == 0)
{
freePath = (LV2_State_Free_Path*) features[i]->data;
break;
}
}
#endif
if (!mapPath)
{
fprintf (stderr, "BJumblr.lv2: Host doesn't support required features.\n");
return LV2_STATE_ERR_NO_FEATURE;
}
size_t size;
uint32_t type;
uint32_t valflags;
// Retireve sample data
{
char samplePath[PATH_MAX] = {0};
int64_t sampleStart = 0;
int64_t sampleEnd = 0;
float sampleAmp = 1.0;
int32_t sampleLoop = false;
const void* pathData = retrieve (handle, uris.notify_samplePath, &size, &type, &valflags);
if (pathData)
{
char* absPath = mapPath->absolute_path (mapPath->handle, (char*)pathData);
if (absPath)
{
if (strlen (absPath) < PATH_MAX) strcpy (samplePath, absPath);
else
{
fprintf (stderr, "BJumblr.lv2: Sample path too long.\n");
message.setMessage (CANT_OPEN_SAMPLE);
}
fprintf(stderr, "BJumblr.lv2: Restore abs_path:%s\n", absPath);
#ifdef LV2_STATE__freePath
if (freePath) freePath->free_path (freePath->handle, absPath);
else
#endif
{
free (absPath);
}
}
}
const void* startData = retrieve (handle, uris.notify_sampleStart, &size, &type, &valflags);
if (startData && (type == uris.atom_Long)) sampleStart = *(int64_t*)startData;
const void* endData = retrieve (handle, uris.notify_sampleEnd, &size, &type, &valflags);
if (endData && (type == uris.atom_Long)) sampleEnd = *(int64_t*)endData;
const void* ampData = retrieve (handle, uris.notify_sampleAmp, &size, &type, &valflags);
if (ampData && (type == uris.atom_Float)) sampleAmp = *(float*)ampData;
const void* loopData = retrieve (handle, uris.notify_sampleLoop, &size, &type, &valflags);
if (loopData && (type == uris.atom_Bool)) sampleLoop = *(int32_t*)loopData;
if (activated && schedule)
{
LV2_Atom_Forge forge;
lv2_atom_forge_init(&forge, map);
uint8_t buf[1200];
lv2_atom_forge_set_buffer(&forge, buf, sizeof(buf));
LV2_Atom_Forge_Frame frame;
LV2_Atom* msg = (LV2_Atom*)forgeSamplePath (&forge, &frame, samplePath, sampleStart, sampleEnd, sampleAmp, sampleLoop);
lv2_atom_forge_pop(&forge, &frame);
if (msg) schedule->schedule_work(schedule->handle, lv2_atom_total_size(msg), msg);
}
else
{
// Free old sample
if (sample)
{
delete sample;
sample = nullptr;
sampleAmp = 1.0;
}
// Load new sample
message.deleteMessage (CANT_OPEN_SAMPLE);
try {sample = new Sample (samplePath);}
catch (std::bad_alloc &ba)
{
fprintf (stderr, "Jumblr.lv2: Can't allocate enoug memory to open sample file.\n");
message.setMessage (CANT_OPEN_SAMPLE);
}
catch (std::invalid_argument &ia)
{
fprintf (stderr, "%s\n", ia.what());
message.setMessage (CANT_OPEN_SAMPLE);
}
// Set new sample properties
if (sample)
{
sample->start = sampleStart;
sample->end = sampleEnd;
sample->loop = bool (sampleLoop);
this->sampleAmp = sampleAmp;
}
scheduleNotifySamplePathToGui = true;
}
}
// Retrieve pattern orientation
const void* flipData = retrieve (handle, uris.notify_padFlipped, &size, &type, &valflags);
if (flipData && (type == uris.atom_Bool))
{
patternFlipped = *(bool*) flipData;
scheduleNotifyStatusToGui = true;
}
// Retrieve playbackPage
const void* ppData = retrieve (handle, uris.notify_playbackPage, &size, &type, &valflags);
if (ppData && (size == sizeof (uint32_t)) && (type == uris.atom_Int))
{
const uint32_t pp = *(const uint32_t*) ppData;
if ((pp < 0) || (pp >= MAXPAGES)) fprintf (stderr, "BJumblr.lv2: Invalid playbackPage data\n");
else playPage = pp;
scheduleNotifyPlaybackPageToGui = true;
}
// Retrieve edit mode
const void* modeData = retrieve (handle, uris.notify_editMode, &size, &type, &valflags);
if (modeData && (size == sizeof (uint32_t)) && (type == uris.atom_Int))
{
const uint32_t mode = *(const uint32_t*) modeData;
if ((mode < 0) || (mode > 1)) fprintf (stderr, "BJumblr.lv2: Invalid editMode data\n");
else editMode = mode;
}
// Retrieve pad data
const void* padData = retrieve(handle, uris.state_pad, &size, &type, &valflags);
if (padData && (type == uris.atom_String))
{
nrPages = 1;
for (int i = 0; i < MAXPAGES; ++i)
{
for (int j = 0; j < MAXSTEPS; ++j)
{
for (int k = 0; k < MAXSTEPS; ++k)
{
pads[i][j][k] = Pad();
}
}
}
std::string padDataString = (char*) padData;
const std::string keywords[3] = {"pg:", "id:", "lv:"};
// Restore pads
// Parse retrieved data
while (!padDataString.empty())
{
// Look for optional "pg:"
int page = 0;
size_t strPos = padDataString.find (keywords[0]);
size_t nextPos = 0;
if ((strPos != std::string::npos) && (strPos + 3 <= padDataString.length()))
{
padDataString.erase (0, strPos + 3);
int p;
try {p = std::stof (padDataString, &nextPos);}
catch (const std::exception& e)
{
fprintf (stderr, "BJumblr.lv2: Restore pad state incomplete. Can't parse page from \"%s...\"", padDataString.substr (0, 63).c_str());
break;
}
if (nextPos > 0) padDataString.erase (0, nextPos);
if ((p < 0) || (p >= MAXPAGES))
{
fprintf (stderr, "BJumblr.lv2: Restore pad state incomplete. Invalid matrix data block loaded with page %i. Try to use the data before this page.\n", p);
break;
}
if (p >= nrPages) nrPages = p + 1;
page = p;
}
// Look for "id:"
strPos = padDataString.find (keywords[1]);
nextPos = 0;
if (strPos == std::string::npos) break; // No "id:" found => end
if (strPos + 3 > padDataString.length()) break; // Nothing more after id => end
padDataString.erase (0, strPos + 3);
int id;
try {id = std::stof (padDataString, &nextPos);}
catch (const std::exception& e)
{
fprintf (stderr, "BJumblr.lv2: Restore pad state incomplete. Can't parse ID from \"%s...\"", padDataString.substr (0, 63).c_str());
break;
}
if (nextPos > 0) padDataString.erase (0, nextPos);
if ((id < 0) || (id >= MAXSTEPS * MAXSTEPS))
{
fprintf (stderr, "BJumblr.lv2: Restore pad state incomplete. Invalid matrix data block loaded with ID %i. Try to use the data before this id.\n", id);
break;
}
int row = id % MAXSTEPS;
int step = id / MAXSTEPS;
// Look for pad data
for (int i = 2; i < 3; ++i)
{
strPos = padDataString.find (keywords[i]);
if (strPos == std::string::npos) continue; // Keyword not found => next keyword
if (strPos + 3 >= padDataString.length()) // Nothing more after keyword => end
{
padDataString ="";
break;
}
if (strPos > 0) padDataString.erase (0, strPos + 3);
float val;
try {val = std::stof (padDataString, &nextPos);}
catch (const std::exception& e)
{
fprintf (stderr, "BJumblr.lv2: Restore padstate incomplete. Can't parse %s from \"%s...\"",
keywords[i].substr(0,2).c_str(), padDataString.substr (0, 63).c_str());
break;
}
if (nextPos > 0) padDataString.erase (0, nextPos);
switch (i) {
case 2: pads[page][row][step].level = val;
break;
default:break;
}
}
}
// Validate all pads
for (int p = 0; p < nrPages; ++p)
{
for (int i = 0; i < MAXSTEPS; ++i)
{
for (int j = 0; j < MAXSTEPS; ++j)
{
Pad valPad = validatePad (pads[p][i][j]);
if (valPad != pads[p][i][j])
{
fprintf (stderr, "BJumblr.lv2: Pad out of range in state_restore (): pads[%i][%i][%i].\n", p, i, j);
pads[p][i][j] = valPad;
}
}
}
scheduleNotifyFullPatternToGui[p] = true;
}
// Force GUI notification
scheduleNotifyPadsToGui = true;
}
// Force GUI notification
scheduleNotifyStatusToGui = true;
return LV2_STATE_SUCCESS;
}
LV2_Worker_Status BJumblr::work (LV2_Worker_Respond_Function respond, LV2_Worker_Respond_Handle handle, uint32_t size, const void* data)
{
const LV2_Atom* atom = (const LV2_Atom*)data;
if (!atom) return LV2_WORKER_ERR_UNKNOWN;
// Free old sample
if (atom->type == uris.notify_sampleFreeEvent)
{
const WorkerMessage* workerMessage = (WorkerMessage*) atom;
if (workerMessage->sample) delete workerMessage->sample;
}
// Load sample
else
{
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)data;
if (obj->body.otype == uris.notify_pathEvent)
{
const LV2_Atom* path = NULL, *oStart = NULL, *oEnd = NULL, *oAmp = NULL, *oLoop = NULL;
lv2_atom_object_get
(
obj,
uris.notify_samplePath, &path,
uris.notify_sampleStart, &oStart,
uris.notify_sampleEnd, &oEnd,
uris.notify_sampleAmp, &oAmp,
uris.notify_sampleLoop, &oLoop,
0
);
if (path && (path->type == uris.atom_Path))
{
message.deleteMessage (CANT_OPEN_SAMPLE);
Sample* s = nullptr;
try {s = new Sample ((const char*)LV2_ATOM_BODY_CONST(path));}
catch (std::bad_alloc &ba)
{
fprintf (stderr, "BJumblr.lv2: Can't allocate enough memory to open sample file.\n");
message.setMessage (CANT_OPEN_SAMPLE);
return LV2_WORKER_ERR_NO_SPACE;
}
catch (std::invalid_argument &ia)
{
fprintf (stderr, "%s\n", ia.what());
message.setMessage (CANT_OPEN_SAMPLE);
return LV2_WORKER_ERR_UNKNOWN;
}
if (s)
{
WorkerMessage sAtom;
sAtom.atom = {sizeof (s), uris.notify_installSample};
sAtom.sample = s;
sAtom.start = (oStart && (oStart->type == uris.atom_Long) ? ((LV2_Atom_Long*)oStart)->body : 0);
sAtom.end = (oEnd && (oEnd->type == uris.atom_Long) ? ((LV2_Atom_Long*)oEnd)->body : s->info.frames);
sAtom.amp = (oAmp && (oAmp->type == uris.atom_Float) ? ((LV2_Atom_Float*)oAmp)->body : 1.0f);
sAtom.loop = (oLoop && (oLoop->type == uris.atom_Bool) ? ((LV2_Atom_Bool*)oLoop)->body : 0);
respond (handle, sizeof(sAtom), &sAtom);
}
if (s) respond (handle, sizeof(s), &s);
}
else return LV2_WORKER_ERR_UNKNOWN;
}
}
return LV2_WORKER_SUCCESS;
}
LV2_Worker_Status BJumblr::work_response (uint32_t size, const void* data)
{
const LV2_Atom* atom = (const LV2_Atom*)data;
if (!atom) return LV2_WORKER_ERR_UNKNOWN;
if (atom->type == uris.notify_installSample)
{
const WorkerMessage* nAtom = (const WorkerMessage*)data;
// Schedule worker to free old sample
WorkerMessage sAtom = {{sizeof (Sample*), uris.notify_sampleFreeEvent}, sample};
workerSchedule->schedule_work (workerSchedule->handle, sizeof (sAtom), &sAtom);
// Install new sample from data
sample = nAtom->sample;
if (sample)
{
sample->start = LIMIT (nAtom->start, 0, sample->info.frames - 1);
sample->end = LIMIT (nAtom->end, sample->start, sample->info.frames);
sampleAmp = LIMIT (nAtom->amp, 0.0f, 1.0f);
sample->loop = bool (nAtom->loop);
scheduleNotifyStateChanged = true;
return LV2_WORKER_SUCCESS;
}
else
{
scheduleNotifyStateChanged = true;
return LV2_WORKER_ERR_UNKNOWN;
}
}
else return LV2_WORKER_ERR_UNKNOWN;
}
/*
* Checks if a value is within a limit, and if not, puts the value within
* this limit.
* @param value
* @param limit
* @return Value is within the limit
*/
float BJumblr::validateValue (float value, const Limit limit)
{
float ltdValue = ((limit.step != 0) ? (limit.min + round ((value - limit.min) / limit.step) * limit.step) : value);
return LIMIT (ltdValue, limit.min, limit.max);
}
/*
* Validates a single pad
*/
Pad BJumblr::validatePad (Pad pad)
{
return Pad(validateValue (pad.level, {0, 1, 0}));
}
/*
* Appends a single pad to padMessageBuffer
*/
bool BJumblr::padMessageBufferAppendPad (int page, int row, int step, Pad pad)
{
PadMessage end = PadMessage (ENDPADMESSAGE);
PadMessage msg = PadMessage (step, row, pad.level);
for (int i = 0; i < MAXSTEPS * MAXSTEPS; ++i)
{
if (padMessageBuffer[page][i] != end)
{
padMessageBuffer[page][i] = msg;
if (i < MAXSTEPS * MAXSTEPS - 1) padMessageBuffer[page][i + 1] = end;
return true;
}
}
return false;
}
LV2_Atom_Forge_Ref BJumblr::forgeSamplePath (LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, const char* path, const int64_t start, const int64_t end, const float amp, const int32_t loop)
{
const LV2_Atom_Forge_Ref msg = lv2_atom_forge_object (forge, frame, 0, uris.notify_pathEvent);
if (msg)
{
lv2_atom_forge_key (forge, uris.notify_samplePath);
lv2_atom_forge_path (forge, path, strlen (path) + 1);
lv2_atom_forge_key (forge, uris.notify_sampleStart);
lv2_atom_forge_long (forge, start);
lv2_atom_forge_key (forge, uris.notify_sampleEnd);
lv2_atom_forge_long (forge, end);
lv2_atom_forge_key (forge, uris.notify_sampleAmp);
lv2_atom_forge_float (forge, amp);
lv2_atom_forge_key (forge, uris.notify_sampleLoop);
lv2_atom_forge_bool (forge, loop);
}
return msg;
}
void BJumblr::notifyPadsToGui ()
{
PadMessage endmsg (ENDPADMESSAGE);
for (int p = 0; p < nrPages; ++p)
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_padEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_editMode);
lv2_atom_forge_int(¬ifyForge, editMode);
lv2_atom_forge_key(¬ifyForge, uris.notify_padPage);
lv2_atom_forge_int(¬ifyForge, p);
if (scheduleNotifyFullPatternToGui[p])
{
lv2_atom_forge_key(¬ifyForge, uris.notify_padFullPattern);
lv2_atom_forge_vector(¬ifyForge, sizeof(float), uris.atom_Float, MAXSTEPS * MAXSTEPS * sizeof(Pad) / sizeof(float), (void*) &pads[p]);
}
else if (!(endmsg == padMessageBuffer[p][0]))
{
// Get padMessageBuffer size
int end = 0;
for (int i = 0; (i < MAXSTEPS * MAXSTEPS) && (!(padMessageBuffer[p][i] == endmsg)); ++i) end = i;
lv2_atom_forge_key(¬ifyForge, uris.notify_pad);
lv2_atom_forge_vector(¬ifyForge, sizeof(float), uris.atom_Float, sizeof(PadMessage) / sizeof(float) * (end + 1), (void*) &padMessageBuffer[p]);
}
lv2_atom_forge_pop(¬ifyForge, &frame);
// Empty padMessageBuffer
padMessageBuffer[p][0] = endmsg;
scheduleNotifyFullPatternToGui[p] = false;
}
scheduleNotifyPadsToGui = false;
}
void BJumblr::notifyStatusToGui ()
{
// Prepare forge buffer and initialize atom sequence
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_cursor);
lv2_atom_forge_float(¬ifyForge, cursor);
float delay = progressionDelay + controllers[MANUAL_PROGRSSION_DELAY];
lv2_atom_forge_key(¬ifyForge, uris.notify_progressionDelay);
lv2_atom_forge_float(¬ifyForge, delay);
lv2_atom_forge_key(¬ifyForge, uris.notify_padFlipped);
lv2_atom_forge_bool(¬ifyForge, patternFlipped);
lv2_atom_forge_pop(¬ifyForge, &frame);
scheduleNotifyStatusToGui = false;
}
void BJumblr::notifyWaveformToGui (const int start, const int end)
{
int p1 = (start <= end ? end : WAVEFORMSIZE - 1);
// Notify shapeBuffer (position to end)
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_waveformEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_waveformStart);
lv2_atom_forge_int(¬ifyForge, start);
lv2_atom_forge_key(¬ifyForge, uris.notify_waveformData);
lv2_atom_forge_vector(¬ifyForge, sizeof(float), uris.atom_Float, (uint32_t) (p1 + 1 - start), &waveform[start]);
lv2_atom_forge_pop(¬ifyForge, &frame);
// Additional notification if position exceeds end
if (start > waveformCounter)
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_waveformEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_waveformStart);
lv2_atom_forge_int(¬ifyForge, 0);
lv2_atom_forge_key(¬ifyForge, uris.notify_waveformData);
lv2_atom_forge_vector(¬ifyForge, sizeof(float), uris.atom_Float, (uint32_t) (end), &waveform[0]);
lv2_atom_forge_pop(¬ifyForge, &frame);
}
scheduleNotifyWaveformToGui = false;
lastWaveformCounter = end;
}
void BJumblr::notifySchedulePageToGui ()
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_schedulePage);
lv2_atom_forge_int(¬ifyForge, schedulePage);
lv2_atom_forge_pop(¬ifyForge, &frame);
scheduleNotifySchedulePageToGui = false;
}
void BJumblr::notifyPlaybackPageToGui ()
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_playbackPage);
lv2_atom_forge_int(¬ifyForge, playPage);
lv2_atom_forge_pop(¬ifyForge, &frame);
scheduleNotifyPlaybackPageToGui = false;
}
void BJumblr::notifyMidiLearnedToGui ()
{
uint32_t ml = midiLearned[0] * 0x1000000 + midiLearned[1] * 0x10000 + midiLearned[2] * 0x100 + midiLearned[3];
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_statusEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_midiLearned);
lv2_atom_forge_int(¬ifyForge, ml);
lv2_atom_forge_pop(¬ifyForge, &frame);
scheduleNotifyMidiLearnedToGui = false;
}
void BJumblr::notifyMessageToGui()
{
uint32_t messageNr = message.loadMessage ();
// Send notifications
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.notify_messageEvent);
lv2_atom_forge_key(¬ifyForge, uris.notify_message);
lv2_atom_forge_int(¬ifyForge, messageNr);
lv2_atom_forge_pop(¬ifyForge, &frame);
}
void BJumblr::notifySamplePathToGui ()
{
if (sample && sample->path)
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
if (sample && sample->path && (sample->path[0] != 0))
{
forgeSamplePath (¬ifyForge, &frame, sample->path, sample->start, sample->end, sampleAmp, int32_t (sample->loop));
}
else
{
const char* path = ".";
forgeSamplePath (¬ifyForge, &frame, path, 0, 0, sampleAmp, false);
}
lv2_atom_forge_pop(¬ifyForge, &frame);
}
scheduleNotifySamplePathToGui = false;
}
void BJumblr::notifyStateChanged()
{
LV2_Atom_Forge_Frame frame;
lv2_atom_forge_frame_time(¬ifyForge, 0);
lv2_atom_forge_object(¬ifyForge, &frame, 0, uris.state_StateChanged);
lv2_atom_forge_pop(¬ifyForge, &frame);
scheduleNotifyStateChanged = false;
}
/*
*
*
******************************************************************************
* LV2 specific declarations
*/
static LV2_Handle instantiate (const LV2_Descriptor* descriptor, double samplerate, const char* bundle_path, const LV2_Feature* const* features)
{
// New instance
BJumblr* instance;
try {instance = new BJumblr(samplerate, features);}
catch (std::exception& exc)
{
fprintf (stderr, "BJumblr.lv2: Plugin instantiation failed. %s\n", exc.what ());
return NULL;
}
return (LV2_Handle)instance;
}
static void connect_port (LV2_Handle instance, uint32_t port, void *data)
{
BJumblr* inst = (BJumblr*) instance;
inst->connect_port (port, data);
}
static void activate (LV2_Handle instance)
{
BJumblr* inst = (BJumblr*) instance;
if (inst) inst->activate();
}
static void run (LV2_Handle instance, uint32_t n_samples)
{
BJumblr* inst = (BJumblr*) instance;
if (inst) inst->run (n_samples);
}
static void deactivate (LV2_Handle instance)
{
BJumblr* inst = (BJumblr*) instance;
if (inst) inst->deactivate();
}
static LV2_State_Status state_save(LV2_Handle instance, LV2_State_Store_Function store, LV2_State_Handle handle, uint32_t flags,
const LV2_Feature* const* features)
{
BJumblr* inst = (BJumblr*)instance;
if (!inst) return LV2_STATE_SUCCESS;
return inst->state_save (store, handle, flags, features);
}
static LV2_State_Status state_restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags,
const LV2_Feature* const* features)
{
BJumblr* inst = (BJumblr*)instance;
if (!inst) return LV2_STATE_SUCCESS;
return inst->state_restore (retrieve, handle, flags, features);
}
static LV2_Worker_Status work (LV2_Handle instance, LV2_Worker_Respond_Function respond, LV2_Worker_Respond_Handle handle,
uint32_t size, const void* data)
{
BJumblr* inst = (BJumblr*)instance;
if (!inst) return LV2_WORKER_SUCCESS;
return inst->work (respond, handle, size, data);
}
static LV2_Worker_Status work_response (LV2_Handle instance, uint32_t size, const void* data)
{
BJumblr* inst = (BJumblr*)instance;
if (!inst) return LV2_WORKER_SUCCESS;
return inst->work_response (size, data);
}
static void cleanup (LV2_Handle instance)
{
BJumblr* inst = (BJumblr*) instance;
if (inst) delete inst;
}
static const void* extension_data(const char* uri)
{
static const LV2_State_Interface state = {state_save, state_restore};
static const LV2_Worker_Interface worker = {work, work_response, NULL};
if (!strcmp(uri, LV2_STATE__interface)) return &state;
if (!strcmp(uri, LV2_WORKER__interface)) return &worker;
return NULL;
}
static const LV2_Descriptor descriptor =
{
BJUMBLR_URI,
instantiate,
connect_port,
activate,
run,
deactivate,
cleanup,
extension_data
};
// LV2 Symbol Export
LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor (uint32_t index)
{
switch (index)
{
case 0: return &descriptor;
default: return NULL;
}
}
/* End of LV2 specific declarations
*
* *****************************************************************************
*
*
*/
| 50,630
|
C++
|
.cpp
| 1,438
| 31.283727
| 191
| 0.664386
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,375
|
Urids.hpp
|
sjaehn_BJumblr/src/Urids.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef URIDS_HPP_
#define URIDS_HPP_
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
#include <lv2/lv2plug.in/ns/ext/atom/util.h>
#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
#include <lv2/lv2plug.in/ns/ext/time/time.h>
#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
#include <lv2/lv2plug.in/ns/ext/state/state.h>
#include "definitions.h"
#ifndef LV2_STATE__StateChanged
#define LV2_STATE__StateChanged LV2_STATE_PREFIX "StateChanged"
#endif
struct BJumblrURIs
{
LV2_URID atom_Sequence;
LV2_URID atom_Float;
LV2_URID atom_Double;
LV2_URID atom_Bool;
LV2_URID atom_Int;
LV2_URID atom_Object;
LV2_URID atom_Blank;
LV2_URID atom_eventTransfer;
LV2_URID atom_Vector;
LV2_URID atom_Long;
LV2_URID atom_String;
LV2_URID atom_Path;
LV2_URID time_Position;
LV2_URID time_bar;
LV2_URID time_barBeat;
LV2_URID time_beatsPerMinute;
LV2_URID time_beatsPerBar;
LV2_URID time_beatUnit;
LV2_URID time_speed;
LV2_URID midi_Event;
LV2_URID state_StateChanged;
LV2_URID ui_on;
LV2_URID ui_off;
LV2_URID state_pad;
LV2_URID notify_padEvent;
LV2_URID notify_padPage;
LV2_URID notify_pad;
LV2_URID notify_padFullPattern;
LV2_URID notify_padFlipped;
LV2_URID notify_editMode;
LV2_URID notify_sampleFreeEvent;
LV2_URID notify_installSample;
LV2_URID notify_pathEvent;
LV2_URID notify_samplePath;
LV2_URID notify_sampleStart;
LV2_URID notify_sampleEnd;
LV2_URID notify_sampleAmp;
LV2_URID notify_sampleLoop;
LV2_URID notify_statusEvent;
LV2_URID notify_requestMidiLearn;
LV2_URID notify_midiLearned;
LV2_URID notify_maxPage;
LV2_URID notify_schedulePage;
LV2_URID notify_playbackPage;
LV2_URID notify_cursor;
LV2_URID notify_progressionDelay;
LV2_URID notify_messageEvent;
LV2_URID notify_message;
LV2_URID notify_waveformEvent;
LV2_URID notify_waveformStart;
LV2_URID notify_waveformData;
};
void getURIs (LV2_URID_Map* m, BJumblrURIs* uris)
{
uris->atom_Sequence = m->map(m->handle, LV2_ATOM__Sequence);
uris->atom_Float = m->map(m->handle, LV2_ATOM__Float);
uris->atom_Double = m->map(m->handle, LV2_ATOM__Double);
uris->atom_Bool = m->map(m->handle, LV2_ATOM__Bool);
uris->atom_Int = m->map(m->handle, LV2_ATOM__Int);
uris->atom_Object = m->map(m->handle, LV2_ATOM__Object);
uris->atom_Blank = m->map(m->handle, LV2_ATOM__Blank);
uris->atom_eventTransfer = m->map(m->handle, LV2_ATOM__eventTransfer);
uris->atom_Vector = m->map(m->handle, LV2_ATOM__Vector);
uris->atom_Long = m->map (m->handle, LV2_ATOM__Long);
uris->atom_String = m->map (m->handle, LV2_ATOM__String);
uris->atom_Path = m->map(m->handle, LV2_ATOM__Path);
uris->time_Position = m->map(m->handle, LV2_TIME__Position);
uris->time_bar = m->map(m->handle, LV2_TIME__bar);
uris->time_barBeat = m->map(m->handle, LV2_TIME__barBeat);
uris->time_beatsPerMinute = m->map(m->handle, LV2_TIME__beatsPerMinute);
uris->time_beatUnit = m->map(m->handle, LV2_TIME__beatUnit);
uris->time_beatsPerBar = m->map(m->handle, LV2_TIME__beatsPerBar);
uris->time_speed = m->map(m->handle, LV2_TIME__speed);
uris->midi_Event = m->map(m->handle, LV2_MIDI__MidiEvent);
uris->state_StateChanged = m->map(m->handle, LV2_STATE__StateChanged);
uris->ui_on = m->map(m->handle, BJUMBLR_URI "#UIon");
uris->ui_off = m->map(m->handle, BJUMBLR_URI "#UIoff");
uris->state_pad = m->map(m->handle, BJUMBLR_URI "#STATEpad");
uris->notify_padEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYpadEvent");
uris->notify_padPage = m->map(m->handle, BJUMBLR_URI "#NOTIFYpadPage");
uris->notify_pad = m->map(m->handle, BJUMBLR_URI "#NOTIFYpad");
uris->notify_padFullPattern = m->map(m->handle, BJUMBLR_URI "#NOTIFYpadFullPattern");
uris->notify_padFlipped = m->map(m->handle, BJUMBLR_URI "#NOTIFYpadFlipped");
uris->notify_editMode = m->map(m->handle, BJUMBLR_URI "#NOTIFYeditMode");
uris->notify_sampleFreeEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYsampleFreeEvent");
uris->notify_installSample = m->map(m->handle, BJUMBLR_URI "#NOTIFYinstallSample");
uris->notify_pathEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYpathEvent");
uris->notify_samplePath = m->map(m->handle, BJUMBLR_URI "#NOTIFYsamplePath");
uris->notify_sampleStart = m->map(m->handle, BJUMBLR_URI "#NOTIFYsampleStart");
uris->notify_sampleEnd = m->map(m->handle, BJUMBLR_URI "#NOTIFYsampleEnd");
uris->notify_sampleAmp = m->map(m->handle, BJUMBLR_URI "#NOTIFYsampleAmp");
uris->notify_sampleLoop = m->map(m->handle, BJUMBLR_URI "#NOTIFYsampleLoop");
uris->notify_statusEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYstatusEvent");
uris->notify_requestMidiLearn = m->map(m->handle, BJUMBLR_URI "#NOTIFYrequestMidiLearn");
uris->notify_midiLearned = m->map(m->handle, BJUMBLR_URI "#NOTIFYmidiLearned");
uris->notify_maxPage = m->map(m->handle, BJUMBLR_URI "#NOTIFYpadMaxPage");
uris->notify_schedulePage = m->map(m->handle, BJUMBLR_URI "#NOTIFYschedulePage");
uris->notify_playbackPage = m->map(m->handle, BJUMBLR_URI "#NOTIFYplaybackPage");
uris->notify_cursor = m->map(m->handle, BJUMBLR_URI "#NOTIFYcursor");
uris->notify_progressionDelay = m->map(m->handle, BJUMBLR_URI "#NOTIFYplaybackDelay");
uris->notify_messageEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYmessageEvent");
uris->notify_message = m->map(m->handle, BJUMBLR_URI "#NOTIFYmessage");
uris->notify_waveformEvent = m->map(m->handle, BJUMBLR_URI "#NOTIFYwaveformEvent");
uris->notify_waveformStart = m->map(m->handle, BJUMBLR_URI "#NOTIFYwaveformStart");
uris->notify_waveformData = m->map(m->handle, BJUMBLR_URI "#NOTIFYwaveformData");
}
#endif /* URIDS_HPP_ */
| 6,421
|
C++
|
.h
| 142
| 43.330986
| 90
| 0.740475
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,376
|
Locale_EN.hpp
|
sjaehn_BJumblr/src/Locale_EN.hpp
|
#ifndef BJUMBLR_LOCALE
#define BJUMBLR_LOCALE
#define BJUMBLR_LABEL_JACK_OFF "Msg: Jack transport off or halted. Plugin halted."
#define BJUMBLR_LABEL_CANT_OPEN_SAMPLE "Msg: Can't open sample file."
#define BJUMBLR_LABEL_SELECT_CUT "Select & cut"
#define BJUMBLR_LABEL_SELECT_COPY "Select & copy"
#define BJUMBLR_LABEL_SELECT_XFLIP "Select & X flip"
#define BJUMBLR_LABEL_SELECT_YFLIP "Select & Y flip"
#define BJUMBLR_LABEL_PASTE "Paste"
#define BJUMBLR_LABEL_RESET "Reset"
#define BJUMBLR_LABEL_UNDO "Undo"
#define BJUMBLR_LABEL_REDO "Redo"
#define BJUMBLR_LABEL_MIDI_PAGE "MIDI control page"
#define BJUMBLR_LABEL_MIDI_STATUS "MIDI status"
#define BJUMBLR_LABEL_NONE "None"
#define BJUMBLR_LABEL_NOTE_ON "Note on"
#define BJUMBLR_LABEL_NOTE_OFF "Note off"
#define BJUMBLR_LABEL_CC "Control change"
#define BJUMBLR_LABEL_CHANNEL "Channel"
#define BJUMBLR_LABEL_ALL "All"
#define BJUMBLR_LABEL_NOTE "Note"
#define BJUMBLR_LABEL_VALUE "Value"
#define BJUMBLR_LABEL_LEARN "Learn"
#define BJUMBLR_LABEL_CANCEL "Cancel"
#define BJUMBLR_LABEL_OK "OK"
#define BJUMBLR_LABEL_AUDIO_STREAM "Audio stream"
#define BJUMBLR_LABEL_SAMPLE "Sample"
#define BJUMBLR_LABEL_PLAY "Play"
#define BJUMBLR_LABEL_BYPASS "Bypass"
#define BJUMBLR_LABEL_STOP "Stop"
#define BJUMBLR_LABEL_ADD "Add"
#define BJUMBLR_LABEL_REPLACE "Replace"
#define BJUMBLR_LABEL_SECONDS "Seconds"
#define BJUMBLR_LABEL_BEATS "Beats"
#define BJUMBLR_LABEL_BARS "Bars"
#define BJUMBLR_LABEL_STEPS "Steps"
#define BJUMBLR_LABEL_RESET_DELAY "Reset delay"
#define BJUMBLR_LABEL_INCREASE_DELAY "Increase delay"
#define BJUMBLR_LABEL_DECREASE_DELAY "Decrease delay"
#define BJUMBLR_LABEL_DELAY_TO_START "Delay to start"
#define BJUMBLR_LABEL_HELP "Help"
#define BJUMBLR_LABEL_TUTORIAL "Tutorial"
#define BJUMBLR_LABEL_ROW "Row"
#define BJUMBLR_LABEL_STEP "Step"
#define BJUMBLR_LABEL_LEVEL "Level"
#define BJUMBLR_LABEL_ALL_FILES "All files"
#define BJUMBLR_LABEL_AUDIO_FILES "Audio files"
#define BJUMBLR_LABEL_OPEN "Open"
#define BJUMBLR_LABEL_PLAY_AS_LOOP "Play selection as loop"
#define BJUMBLR_LABEL_FILE "File"
#define BJUMBLR_LABEL_SELECTION_START "Selection start"
#define BJUMBLR_LABEL_SELECTION_END "Selection end"
#define BJUMBLR_LABEL_FRAMES "frames"
#define BJUMBLR_LABEL_NO_FILE_SELECTED "No audio file selected"
#define BJUMBLR_LABEL_NEW_FOLDER "Create new folder:"
#define BJUMBLR_LABEL_CANT_CREATE_NEW_FOLDER "Error: Can't create new folder"
#define BJUMBLR_LABEL_SOURCE "Source"
#define BJUMBLR_LABEL_CALIBRATION "Calibration"
#define BJUMBLR_LABEL_STEP_EDIT_MODE "Step edit mode"
#define BJUMBLR_LABEL_STEP_SIZE "Step size"
#define BJUMBLR_LABEL_PATTERN_SIZE "Pattern size"
#define BJUMBLR_LABEL_PAD_LEVEL "Pad level"
#define BJUMBLR_LABEL_PLAYBACK "Playback"
#define BJUMBLR_LABEL_SPEED "Speed"
#endif
| 2,775
|
C++
|
.h
| 65
| 41.646154
| 82
| 0.799778
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,377
|
VLine.hpp
|
sjaehn_BJumblr/src/VLine.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2020 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef VLINE_HPP_
#define VLINE_HPP_
#include "BWidgets/Widget.hpp"
class VLine : public BWidgets::Widget
{
public:
VLine () : VLine (0, 0, 0, 0, "line") {}
VLine (const double x, const double y, const double width, const double height, const std::string& name) :
Widget (x, y, width, height, name),
bgColors (BWIDGETS_DEFAULT_BGCOLORS)
{}
VLine& operator= (const VLine& that)
{
bgColors = that.bgColors;
Widget::operator= (that);
return *this;
}
virtual BWidgets::Widget* clone () const override {return new VLine (*this);}
virtual void applyTheme (BStyles::Theme& theme) override {applyTheme (theme, name_);}
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override
{
Widget::applyTheme (theme, name);
void* fgPtr = theme.getStyle(name, BWIDGETS_KEYWORD_BGCOLORS);
if (fgPtr)
{
bgColors = *((BColors::ColorSet*) fgPtr);
update ();
}
}
protected:
BColors::ColorSet bgColors;
void draw (const BUtilities::RectArea& area)
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((getWidth () >= 1) && (getHeight () >= 1))
{
// Draw super class widget elements first
Widget::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX (), area.getY (), area.getWidth (), area.getHeight ());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
BColors::Color color = *bgColors.getColor (getState ());
color.applyBrightness (BWIDGETS_DEFAULT_ILLUMINATED);
cairo_set_line_width (cr, w / 2);
cairo_move_to (cr, x0 + w / 2, y0);
cairo_rel_line_to (cr, 0, h);
cairo_set_source_rgba (cr, CAIRO_RGBA (color));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
}
};
#endif /* VLINE_HPP_ */
| 2,814
|
C++
|
.h
| 80
| 32.1125
| 107
| 0.69746
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,378
|
Locale_FR.hpp
|
sjaehn_BJumblr/src/Locale_FR.hpp
|
#ifndef BJUMBLR_LOCALE
#define BJUMBLR_LOCALE
#define BJUMBLR_LABEL_JACK_OFF "Msg : Transport JACK arrêté. Greffon arrêté."
#define BJUMBLR_LABEL_CANT_OPEN_SAMPLE "Msg : Impossible d'ouvrir le fichier d'échantillon"
#define BJUMBLR_LABEL_SELECT_CUT "Sélectionner et couper"
#define BJUMBLR_LABEL_SELECT_COPY "Sélectionner et copier"
#define BJUMBLR_LABEL_SELECT_XFLIP "Sélectionner et basculer horizontalement"
#define BJUMBLR_LABEL_SELECT_YFLIP "Sélectionner et basculer verticalement"
#define BJUMBLR_LABEL_PASTE "Coller"
#define BJUMBLR_LABEL_RESET "Réinitialiser"
#define BJUMBLR_LABEL_UNDO "Annuler"
#define BJUMBLR_LABEL_REDO "Refaire"
#define BJUMBLR_LABEL_MIDI_PAGE "Page de contrôle MIDI"
#define BJUMBLR_LABEL_MIDI_STATUS "État du MIDI"
#define BJUMBLR_LABEL_NONE "Aucun"
#define BJUMBLR_LABEL_NOTE_ON "Note on"
#define BJUMBLR_LABEL_NOTE_OFF "Note off"
#define BJUMBLR_LABEL_CC "Control change"
#define BJUMBLR_LABEL_CHANNEL "Canal"
#define BJUMBLR_LABEL_ALL "Tout"
#define BJUMBLR_LABEL_NOTE "Note"
#define BJUMBLR_LABEL_VALUE "Valeur"
#define BJUMBLR_LABEL_LEARN "Apprentissage"
#define BJUMBLR_LABEL_CANCEL "Annuler"
#define BJUMBLR_LABEL_OK "OK"
#define BJUMBLR_LABEL_AUDIO_STREAM "Flux audio"
#define BJUMBLR_LABEL_SAMPLE "Échantillon"
#define BJUMBLR_LABEL_PLAY "Lecture"
#define BJUMBLR_LABEL_BYPASS "Court-circuit"
#define BJUMBLR_LABEL_STOP "Stop"
#define BJUMBLR_LABEL_ADD "Ajouter"
#define BJUMBLR_LABEL_REPLACE "Remplacer"
#define BJUMBLR_LABEL_SECONDS "Secondes"
#define BJUMBLR_LABEL_BEATS "Temps"
#define BJUMBLR_LABEL_BARS "Mesures"
#define BJUMBLR_LABEL_STEPS "Pas"
#define BJUMBLR_LABEL_RESET_DELAY "Réinitialiser le délai"
#define BJUMBLR_LABEL_INCREASE_DELAY "Augmenter le délaI"
#define BJUMBLR_LABEL_DECREASE_DELAY "Diminuer le délai"
#define BJUMBLR_LABEL_DELAY_TO_START "Délai au démarrage"
#define BJUMBLR_LABEL_HELP "Aide"
#define BJUMBLR_LABEL_TUTORIAL "Tutoriel"
#define BJUMBLR_LABEL_ROW "Brut"
#define BJUMBLR_LABEL_STEP "Pas"
#define BJUMBLR_LABEL_LEVEL "Niveau"
#define BJUMBLR_LABEL_ALL_FILES "Tous les fichiers"
#define BJUMBLR_LABEL_AUDIO_FILES "Fichiers audio"
#define BJUMBLR_LABEL_OPEN "Ouvrir"
#define BJUMBLR_LABEL_PLAY_AS_LOOP "Jouer la sélection en boucle"
#define BJUMBLR_LABEL_FILE "Fichier"
#define BJUMBLR_LABEL_SELECTION_START "Début de la sélection"
#define BJUMBLR_LABEL_SELECTION_END "Fin de la sélection"
#define BJUMBLR_LABEL_FRAMES "trames"
#define BJUMBLR_LABEL_NO_FILE_SELECTED "Pas de fichier audio sélectionné"
#define BJUMBLR_LABEL_NEW_FOLDER "Create new folder:"
#define BJUMBLR_LABEL_CANT_CREATE_NEW_FOLDER "Error: Can't create new folder"
#define BJUMBLR_LABEL_SOURCE "Source"
#define BJUMBLR_LABEL_CALIBRATION "Calibration"
#define BJUMBLR_LABEL_STEP_EDIT_MODE "Édition par pas"
#define BJUMBLR_LABEL_STEP_SIZE "Taille des pas"
#define BJUMBLR_LABEL_PATTERN_SIZE "Taille du motif"
#define BJUMBLR_LABEL_PAD_LEVEL "Niveau du pad"
#define BJUMBLR_LABEL_PLAYBACK "Lecture"
#define BJUMBLR_LABEL_SPEED "Vitesse"
#endif
| 3,017
|
C++
|
.h
| 65
| 44.969231
| 91
| 0.810127
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,379
|
SampleChooser.hpp
|
sjaehn_BJumblr/src/SampleChooser.hpp
|
/* B.Oops
* Glitch effect sequencer LV2 plugin
*
* Copyright (C) 2020 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SAMPLECHOOSER_HPP_
#define SAMPLECHOOSER_HPP_
#include "BWidgets/FileChooser.hpp"
#include "BWidgets/DrawingSurface.hpp"
#include "HRangeScrollbar.hpp"
#include "VLine.hpp"
#include "Checkbox.hpp"
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_WIDTH 800
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_HEIGHT 320
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_FILTERS std::regex (".*\\.((wav)|(wave)|(aif)|(aiff)|(au)|(sd2)|(flac)|(caf)|(ogg)|(mp3))$", std::regex_constants::icase)
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_PLAY_AS_LOOP_INDEX 7
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_FILE_INDEX 8
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_SELECTION_START_INDEX 9
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_SELECTION_END_INDEX 10
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_FRAMES_INDEX 11
#define BWIDGETS_DEFAULT_SAMPLECHOOSER_NO_FILE_INDEX 12
class Sample; // Forward declaration
class SampleChooser : public BWidgets::FileChooser
{
public:
SampleChooser ();
SampleChooser (const double x, const double y, const double width, const double height, const std::string& name);
SampleChooser (const double x, const double y, const double width, const double height, const std::string& name,
const std::string& path);
SampleChooser (const double x, const double y, const double width, const double height, const std::string& name,
const std::string& path, const std::vector<BWidgets::FileFilter>& filters);
SampleChooser (const double x, const double y, const double width, const double height, const std::string& name,
const std::string& path, const std::vector<BWidgets::FileFilter>& filters, const std::string& buttonText);
SampleChooser (const double x, const double y, const double width, const double height, const std::string& name,
const std::string& path, const std::vector<BWidgets::FileFilter>& filters, const std::vector<std::string>& texts);
SampleChooser (const SampleChooser& that);
~SampleChooser();
SampleChooser& operator= (const SampleChooser& that);
virtual Widget* clone () const override;
virtual void setFileName (const std::string& filename);
void setStart (const int64_t start);
int64_t getStart() const;
void setEnd (const int64_t end);
int64_t getEnd() const;
void setLoop (const bool loop);
bool getLoop() const;
virtual void resize () override;
virtual void resize (const double width, const double height) override;
virtual void resize (const BUtilities::Point extends) override;
virtual void update () override;
virtual void applyTheme (BStyles::Theme& theme) override;
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override;
static void sfileListBoxClickedCallback (BEvents::Event* event);
static void scrollbarChangedCallback (BEvents::Event* event);
static void lineDraggedCallback (BEvents::Event* event);
static void filenameEnteredCallback (BEvents::Event* event);
protected:
BWidgets::DrawingSurface waveform;
HRangeScrollbar scrollbar;
VLine startMarker;
VLine endMarker;
BWidgets::Label sizeLabel;
BWidgets::Label startLabel;
BWidgets::Label endLabel;
Checkbox loopCheckbox;
BWidgets::Label loopLabel;
BWidgets::Label noFileLabel;
Sample* sample;
void drawWaveform();
virtual std::function<void (BEvents::Event*)> getFileListBoxClickedCallback() override;
};
#endif /* SAMPLECHOOSER_HPP_ */
| 4,107
|
C++
|
.h
| 86
| 45.534884
| 160
| 0.777556
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,380
|
PadMessage.hpp
|
sjaehn_BJumblr/src/PadMessage.hpp
|
#ifndef PADMESSAGE_HPP_
#define PADMESSAGE_HPP_
#include "Pad.hpp"
#define ENDPADMESSAGE -1.0, 0.0, 0.0
struct PadMessage : Pad
{
PadMessage () : PadMessage (ENDPADMESSAGE) {}
PadMessage (float step, float row, Pad pad) :
Pad (pad), step (step), row (row) {}
PadMessage (float step, float row, float level) :
Pad (level), step (step), row (row) {}
bool operator== (PadMessage& that) {return (Pad::operator== (that) && (step == that.step) && (row == that.row));}
float step;
float row;
};
#endif /* PADMESSAGE_HPP_ */
| 534
|
C++
|
.h
| 16
| 31.3125
| 114
| 0.67319
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,381
|
MonitorWidget.hpp
|
sjaehn_BJumblr/src/MonitorWidget.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef MONITORWIDGET_HPP_
#define MONITORWIDGET_HPP_
#include "BWidgets/Widget.hpp"
#include "definitions.h"
#include <cmath>
class MonitorWidget : public BWidgets::Widget
{
public:
MonitorWidget () : MonitorWidget (0, 0, 0, 0, "monitor") {}
MonitorWidget (const double x, const double y, const double width, const double height, const std::string& name) :
Widget (x, y, width, height, name),
fgColors (BColors::whites), zoom (0.5), flipped (false)
{
clear ();
setClickable (false);
setScrollable (false);
setFocusable (false);
}
void clear () {data.fill (0.0f);}
void addData (const unsigned int pos, const unsigned int size, const float* data)
{
for (unsigned int i = 0; i < size; ++i) this->data[(i + pos) % WAVEFORMSIZE] = data[i];
}
void setZoom (const double factor)
{
zoom = factor;
update ();
}
double getZoom () const {return zoom;}
void flip (const bool flip)
{
flipped = flip;
update();
}
bool isFlipped () const {return flipped;}
void redrawRange (const unsigned int start, const unsigned int size)
{
unsigned int s = LIMIT (int (start) - 1, 0, WAVEFORMSIZE - 1);
unsigned int e = LIMIT (start + size - 1, 0, WAVEFORMSIZE - 1);
double xabs = getAbsolutePosition().x;
double yabs = getAbsolutePosition().y;
double x1 = getWidth() * s / (WAVEFORMSIZE - 1);
double w = getWidth() * (e - s) / (WAVEFORMSIZE - 1);
drawData (s, e);
if (isVisible ()) postRedisplay (BUtilities::RectArea (floor (xabs + x1), yabs, ceil (w), getHeight()));
if (start + size > WAVEFORMSIZE)
{
unsigned int e2 = (start + size - 1) % WAVEFORMSIZE;
double w2 = getWidth() * e2 / (WAVEFORMSIZE - 1);
drawData (0, e2);
if (isVisible ()) postRedisplay (BUtilities::RectArea (floor (xabs), yabs, ceil (w2), getHeight()));
}
}
virtual void applyTheme (BStyles::Theme& theme) override {applyTheme (theme, name_);}
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override
{
Widget::applyTheme (theme, name);
void* fgPtr = theme.getStyle(name, BWIDGETS_KEYWORD_FGCOLORS);
if (fgPtr)
{
fgColors = *((BColors::ColorSet*) fgPtr);
update ();
}
}
virtual void onWheelScrolled (BEvents::WheelEvent* event) override
{
double step = getZoom() * 0.01;
setZoom (getZoom() + event->getDelta ().y * step);
}
protected:
void drawData (const unsigned int start, const unsigned int end)
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
BColors::Color col = *fgColors.getColor (getState ());
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_set_line_width (cr, 0);
if (!flipped)
{
const double p0 = ceil (getWidth() * start / (WAVEFORMSIZE - 1));
const double p1 = floor (getWidth() * end / (WAVEFORMSIZE - 1));
cairo_rectangle (cr, p0, 0, p1 - p0, getHeight());
}
else
{
const double p0 = ceil (getHeight() * start / (WAVEFORMSIZE - 1));
const double p1 = floor (getHeight() * end / (WAVEFORMSIZE - 1));
cairo_rectangle (cr, 0, p0, getWidth(), p1 - p0);
}
cairo_clip (cr);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_set_line_width (cr, 1);
if (!flipped) cairo_move_to (cr, getWidth() * double (start) / (WAVEFORMSIZE - 1), getHeight() * (0.5 - (0.48 * data[start] / zoom)));
else cairo_move_to (cr, getWidth() * (0.5 - (0.48 * data[start] / zoom)), getHeight() * double (start) / (WAVEFORMSIZE - 1));
for (int i = start + 1; i <= int (end); ++i)
{
if (!flipped) cairo_line_to (cr, getWidth() * double (i) / (WAVEFORMSIZE - 1), getHeight() * (0.5 - (0.48 * data[i] / zoom)));
else cairo_line_to (cr, getWidth() * (0.5 - (0.48 * data[i] / zoom)), getHeight() * double (i) / (WAVEFORMSIZE - 1));
}
cairo_set_source_rgba (cr, CAIRO_RGBA (col));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
virtual void draw (const BUtilities::RectArea& area) override
{
drawData (0, WAVEFORMSIZE - 1);
}
std::array<float, WAVEFORMSIZE> data;
BColors::ColorSet fgColors;
double zoom;
bool flipped;
};
#endif /* MONITORWIDGET_HPP_ */
| 6,440
|
C++
|
.h
| 137
| 34.167883
| 159
| 0.528034
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,382
|
HomeButton.hpp
|
sjaehn_BJumblr/src/HomeButton.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BWIDGETS_HOMEBUTTON_HPP_
#define BWIDGETS_HOMEBUTTON_HPP_
#include "BWidgets/Button.hpp"
class HomeButton : public BWidgets::Button
{
public:
HomeButton () : HomeButton (0.0, 0.0, BWIDGETS_DEFAULT_BUTTON_WIDTH, BWIDGETS_DEFAULT_BUTTON_HEIGHT, "homebutton", 0.0) {}
HomeButton (const double x, const double y, const double width, const double height, const std::string& name, double defaultValue = 0.0) :
Button (x, y, width, height, name, defaultValue) {}
/**
* Pattern cloning. Creates a new instance of the widget and copies all
* its properties.
*/
virtual Widget* clone () const override {return new HomeButton (*this);}
protected:
virtual void draw (const BUtilities::RectArea& area) override
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((getWidth () >= 6) && (getHeight () >= 6))
{
Button::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX (), area.getY (), area.getWidth (), area.getHeight ());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
double size = (w < h ? 0.8 * w : 0.8 * h);
BColors::Color butColor = *bgColors.getColor (getState ()); butColor.applyBrightness (BWIDGETS_DEFAULT_NORMALLIGHTED);
BColors::Color frColor= *bgColors.getColor (getState ());
if (value) frColor.applyBrightness (2 * BWIDGETS_DEFAULT_ILLUMINATED);
else frColor.applyBrightness (2 * BWIDGETS_DEFAULT_SHADOWED);
// Symbol
cairo_set_line_width (cr, BWIDGETS_DEFAULT_BUTTON_BORDER);
cairo_move_to (cr, x0 + w/2, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 + 0.375 * size, y0 + h/2);
cairo_move_to (cr, x0 + w/2 + 0.3 * size, y0 + h/2 - 0.075 * size);
cairo_line_to (cr, x0 + w/2 + 0.3 * size, y0 + h/2 + 0.375 * size);
cairo_line_to (cr, x0 + w/2 + 0.3 * size, y0 + h/2 + 0.375 * size);
cairo_line_to (cr, x0 + w/2, y0 + h/2 + 0.375 * size);
cairo_line_to (cr, x0 + w/2, y0 + h/2 + 0.125 * size);
cairo_line_to (cr, x0 + w/2 - 0.15 * size, y0 + h/2 + 0.125 * size);
cairo_line_to (cr, x0 + w/2 - 0.15 * size, y0 + h/2 + 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.3 * size, y0 + h/2 + 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.3 * size, y0 + h/2 - 0.075 * size);
cairo_move_to (cr, x0 + w/2, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.15 * size, y0 + h/2 - 0.225 * size);
cairo_line_to (cr, x0 + w/2 - 0.15 * size, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.2 * size, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.2 * size, y0 + h/2 - 0.175 * size);
cairo_line_to (cr, x0 + w/2 - 0.375 * size, y0 + h/2);
cairo_set_source_rgba (cr, CAIRO_RGBA (frColor));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
}
};
#endif /* BWIDGETS_HOMEBUTTON_HPP_ */
| 3,837
|
C++
|
.h
| 81
| 43.814815
| 139
| 0.647326
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,383
|
BJumblr.hpp
|
sjaehn_BJumblr/src/BJumblr.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef BJUMBLR_HPP_
#define BJUMBLR_HPP_
#define FADETIME 0.01
#define CONTROLLER_CHANGED(con) ((new_controllers[con]) ? (controllers[con] != *(new_controllers[con])) : false)
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <stdexcept>
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
#include <lv2/lv2plug.in/ns/ext/atom/util.h>
#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
#include <lv2/lv2plug.in/ns/ext/time/time.h>
#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
#include <lv2/lv2plug.in/ns/ext/state/state.h>
#include "lv2/lv2plug.in/ns/ext/worker/worker.h"
#include "definitions.h"
#include "Ports.hpp"
#include "Urids.hpp"
#include "Pad.hpp"
#include "PadMessage.hpp"
#include "Message.hpp"
#include "sndfile.h"
class Sample; // Forward declaration
struct Limit
{
float min;
float max;
float step;
};
class BJumblr
{
public:
BJumblr (double samplerate, const LV2_Feature* const* features);
~BJumblr();
void connect_port(uint32_t port, void *data);
void run(uint32_t n_samples);
void activate();
void deactivate();
LV2_State_Status state_save(LV2_State_Store_Function store, LV2_State_Handle handle, uint32_t flags, const LV2_Feature* const* features);
LV2_State_Status state_restore(LV2_State_Retrieve_Function retrieve, LV2_State_Handle handle, uint32_t flags, const LV2_Feature* const* features);
LV2_Worker_Status work (LV2_Worker_Respond_Function respond, LV2_Worker_Respond_Handle handle, uint32_t size, const void* data);
LV2_Worker_Status work_response (uint32_t size, const void* data);
private:
double getPositionFromBeats (const double beats) const;
double getPositionFromFrames (const uint64_t frames) const;
double getPositionFromSeconds (const double seconds) const;
uint64_t getFramesFromValue (const double value) const;
void runSequencer (const int start, const int end);
float validateValue (float value, const Limit limit);
Pad validatePad (Pad pad);
bool padMessageBufferAppendPad (int page, int row, int step, Pad pad);
LV2_Atom_Forge_Ref forgeSamplePath (LV2_Atom_Forge* forge, LV2_Atom_Forge_Frame* frame, const char* path, const int64_t start, const int64_t end, const float amp, const int32_t loop);
void notifyPadsToGui ();
void notifyStatusToGui ();
void notifyWaveformToGui (const int start, const int end);
void notifySchedulePageToGui ();
void notifyPlaybackPageToGui ();
void notifyMidiLearnedToGui ();
void notifyMessageToGui();
void notifySamplePathToGui ();
void notifyStateChanged ();
// URIs
BJumblrURIs uris;
LV2_URID_Map* map;
LV2_URID_Unmap* unmap;
LV2_Worker_Schedule* workerSchedule;
// DSP <-> GUI communication
const LV2_Atom_Sequence* controlPort;
LV2_Atom_Sequence* notifyPort;
float* audioInput1;
float* audioInput2;
float* audioOutput1;
float* audioOutput2;
LV2_Atom_Forge notifyForge;
LV2_Atom_Forge_Frame notifyFrame;
std::array<std::array <PadMessage, MAXSTEPS * MAXSTEPS>, MAXPAGES> padMessageBuffer;
float waveform[WAVEFORMSIZE];
int waveformCounter;
int lastWaveformCounter;
// Controllers
float* new_controllers [MAXCONTROLLERS];
float controllers [MAXCONTROLLERS];
Limit controllerLimits [MAXCONTROLLERS] =
{
{0, 1, 1}, // SOURCE
{0, 2, 1}, // PLAY
{2, 32, 1}, // NR_OF_STEPS
{0, 2, 1}, // STEP_BASE
{0.01, 4, 0}, // STEP_SIZE
{0, 31, 1}, // STEP_OFFSET
{-32, 32, 0}, // MANUAL_PROGRSSION_DELAY
{0, 4, 0}, // SPEED
{0, 15, 1}, // PAGE
{0, 15, 1}, // MIDI
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1},
{0, 15, 1},
{0, 16, 1},
{0, 128, 1},
{0, 128, 1}
};
// Pads
int editMode;
bool midiLearn;
uint8_t midiLearned[4];
int nrPages;
int schedulePage;
int playPage;
int lastPage;
Pad pads [MAXPAGES] [MAXSTEPS] [MAXSTEPS];
bool patternFlipped;
Sample* sample;
float sampleAmp;
struct WorkerMessage
{
LV2_Atom atom;
Sample* sample;
int64_t start;
int64_t end;
float amp;
int32_t loop;
};
// Host communicated data
double rate;
float bpm;
float beatsPerBar;
int beatUnit;
float speed;
long bar;
float barBeat;
uint32_t outCapacity;
// Position data
double position;
float cursor;
double offset;
uint64_t refFrame;
float progressionDelay;
float progressionDelayFrac;
size_t maxBufferSize;
std::vector<float> audioBuffer1;
std::vector<float> audioBuffer2;
size_t audioBufferCounter;
size_t audioBufferSize;
// Internals
bool activated;
bool ui_on;
bool scheduleNotifyPadsToGui;
bool scheduleNotifyFullPatternToGui[MAXPAGES];
bool scheduleNotifySchedulePageToGui;
bool scheduleNotifyPlaybackPageToGui;
bool scheduleNotifyStatusToGui;
bool scheduleNotifyWaveformToGui;
bool scheduleNotifySamplePathToGui;
bool scheduleNotifyMidiLearnedToGui;
bool scheduleNotifyStateChanged;
Message message;
};
#endif /* BJUMBLR_HPP_ */
| 6,554
|
C++
|
.h
| 239
| 25.125523
| 184
| 0.706771
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,384
|
drawbutton.hpp
|
sjaehn_BJumblr/src/drawbutton.hpp
|
#ifndef DRAWBUTTON_HPP_
#define DRAWBUTTON_HPP_
#include "BWidgets/cairoplus.h"
#include "BWidgets/BColors.hpp"
#include <cmath>
enum ButtonSymbol
{
BUTTON_NO_SYMBOL,
BUTTON_UP_SYMBOL,
BUTTON_DOWN_SYMBOL,
BUTTON_BOTTOM_SYMBOL,
BUTTON_HOME_SYMBOL,
};
void drawButton (cairo_t* cr, double x, double y, double width, double height, BColors::Color color)
{
if ((width <= 0) || (height <= 0)) return;
// Draw button
BColors::Color illuminated = color; illuminated.applyBrightness (0.05);
BColors::Color darkened = color; darkened.applyBrightness (-0.33);
cairo_pattern_t* pat = cairo_pattern_create_radial (x + width / 2, y + height / 2, 0.125 * width, x + width / 2, y + height / 2, 0.5 * width);
cairo_pattern_add_color_stop_rgba (pat, 0.0, CAIRO_RGBA (illuminated));
cairo_pattern_add_color_stop_rgba (pat, 1.0, CAIRO_RGBA (darkened));
double rad = ((width < 20) || (height < 20) ? (width < height ? width : height) / 4 : 5);
cairo_rectangle_rounded (cr, x, y, width, height, rad, 0b1111);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
}
void drawButton (cairo_surface_t* surface, double x, double y, double width, double height, BColors::Color color)
{
cairo_t* cr = cairo_create (surface);
drawButton (cr, x, y, width, height, color);
cairo_destroy (cr);
}
void drawButton (cairo_surface_t* surface, double x, double y, double width, double height, BColors::Color color, const ButtonSymbol symbol)
{
cairo_t* cr = cairo_create (surface);
drawButton (cr, x, y, width, height, color);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (BColors::black));
switch (symbol)
{
case BUTTON_UP_SYMBOL: cairo_move_to (cr, x + width * 0.375, y + height * 0.625);
cairo_line_to (cr, x + width * 0.5, y + height * 0.375);
cairo_line_to (cr, x + width * 0.625, y + height * 0.625);
cairo_stroke (cr);
break;
case BUTTON_DOWN_SYMBOL: cairo_move_to (cr, x + width * 0.375, y + height * 0.375);
cairo_line_to (cr, x + width * 0.5, y + height * 0.625);
cairo_line_to (cr, x + width * 0.625, y + height * 0.375);
cairo_stroke (cr);
break;
case BUTTON_BOTTOM_SYMBOL: cairo_move_to (cr, x + width * 0.375, y + height * 0.375);
cairo_arc (cr, x + width * 0.5, y + height * 0.5, 0.125 * height, - 0.5 * M_PI, 0.5 * M_PI);
cairo_line_to (cr, x + width * 0.375, y + height * 0.625);
cairo_move_to (cr, x + width * 0.5, y + height * 0.5);
cairo_line_to (cr, x + width * 0.375, y + height * 0.625);
cairo_line_to (cr, x + width * 0.5, y + height * 0.75);
cairo_stroke (cr);
break;
case BUTTON_HOME_SYMBOL: cairo_move_to (cr, x + width/2, y + height/2 - 0.375 * height);
cairo_line_to (cr, x + width/2 + 0.375 * height, y + height/2);
cairo_move_to (cr, x + width/2 + 0.3 * height, y + height/2 - 0.075 * height);
cairo_line_to (cr, x + width/2 + 0.3 * height, y + height/2 + 0.375 * height);
cairo_line_to (cr, x + width/2 + 0.3 * height, y + height/2 + 0.375 * height);
cairo_line_to (cr, x + width/2, y + height/2 + 0.375 * height);
cairo_line_to (cr, x + width/2, y + height/2 + 0.125 * height);
cairo_line_to (cr, x + width/2 - 0.15 * height, y + height/2 + 0.125 * height);
cairo_line_to (cr, x + width/2 - 0.15 * height, y + height/2 + 0.375 * height);
cairo_line_to (cr, x + width/2 - 0.3 * height, y + height/2 + 0.375 * height);
cairo_line_to (cr, x + width/2 - 0.3 * height, y + height/2 - 0.075 * height);
cairo_move_to (cr, x + width/2, y + height/2 - 0.375 * height);
cairo_line_to (cr, x + width/2 - 0.15 * height, y + height/2 - 0.225 * height);
cairo_line_to (cr, x + width/2 - 0.15 * height, y + height/2 - 0.375 * height);
cairo_line_to (cr, x + width/2 - 0.2 * height, y + height/2 - 0.375 * height);
cairo_line_to (cr, x + width/2 - 0.2 * height, y + height/2 - 0.175 * height);
cairo_line_to (cr, x + width/2 - 0.375 * height, y + height/2);
cairo_stroke (cr);
break;
default: break;
}
cairo_destroy (cr);
}
#endif /* DRAWBUTTON_HPP_ */
| 4,137
|
C++
|
.h
| 84
| 45.22619
| 143
| 0.616109
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,385
|
Pad.hpp
|
sjaehn_BJumblr/src/Pad.hpp
|
#ifndef PAD_HPP_
#define PAD_HPP_
struct Pad
{
Pad () : Pad (0) {}
Pad (float level) :
level (level) {}
bool operator== (const Pad& that) {return (level == that.level);}
bool operator!= (const Pad& that) {return (!operator== (that));}
float level;
};
#endif /* PAD_HPP_ */
| 283
|
C++
|
.h
| 12
| 21.75
| 66
| 0.634328
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,386
|
Locale_DE.hpp
|
sjaehn_BJumblr/src/Locale_DE.hpp
|
#ifndef BJUMBLR_LOCALE
#define BJUMBLR_LOCALE
#define BJUMBLR_LABEL_JACK_OFF "Msg: Jack-Transport angehalten."
#define BJUMBLR_LABEL_CANT_OPEN_SAMPLE "Msg: Sample kann nicht geööfnet werden."
#define BJUMBLR_LABEL_SELECT_CUT "Markieren & ausschneiden"
#define BJUMBLR_LABEL_SELECT_COPY "Markieren & kopieren"
#define BJUMBLR_LABEL_SELECT_XFLIP "Markieren & X spiegeln"
#define BJUMBLR_LABEL_SELECT_YFLIP "Markieren & Y spiegeln"
#define BJUMBLR_LABEL_PASTE "Einfügen"
#define BJUMBLR_LABEL_RESET "Zurücksetzen"
#define BJUMBLR_LABEL_UNDO "Rückgängig"
#define BJUMBLR_LABEL_REDO "Wiederherstellen"
#define BJUMBLR_LABEL_MIDI_PAGE "MIDI-Kontrollerseite"
#define BJUMBLR_LABEL_MIDI_STATUS "MIDI-Status"
#define BJUMBLR_LABEL_NONE "-"
#define BJUMBLR_LABEL_NOTE_ON "Note an"
#define BJUMBLR_LABEL_NOTE_OFF "Note aus"
#define BJUMBLR_LABEL_CC "CC"
#define BJUMBLR_LABEL_CHANNEL "Kanal"
#define BJUMBLR_LABEL_ALL "Alle"
#define BJUMBLR_LABEL_NOTE "Note"
#define BJUMBLR_LABEL_VALUE "Wert"
#define BJUMBLR_LABEL_LEARN "Anlernen"
#define BJUMBLR_LABEL_CANCEL "Abbruch"
#define BJUMBLR_LABEL_OK "OK"
#define BJUMBLR_LABEL_AUDIO_STREAM "Audio-Stream"
#define BJUMBLR_LABEL_SAMPLE "Sample"
#define BJUMBLR_LABEL_PLAY "Abspielen"
#define BJUMBLR_LABEL_BYPASS "Bypass"
#define BJUMBLR_LABEL_STOP "Stop"
#define BJUMBLR_LABEL_ADD "Hinzufügen"
#define BJUMBLR_LABEL_REPLACE "Ersetzen"
#define BJUMBLR_LABEL_SECONDS "Sekunden"
#define BJUMBLR_LABEL_BEATS "Beats"
#define BJUMBLR_LABEL_BARS "Takte"
#define BJUMBLR_LABEL_STEPS "Schritte"
#define BJUMBLR_LABEL_RESET_DELAY "Verzögerung zurücksetzen"
#define BJUMBLR_LABEL_INCREASE_DELAY "Verzögerung +1"
#define BJUMBLR_LABEL_DECREASE_DELAY "Verzögerung -1"
#define BJUMBLR_LABEL_DELAY_TO_START "Verzögerung zu Start setzen"
#define BJUMBLR_LABEL_HELP "Hilfe"
#define BJUMBLR_LABEL_TUTORIAL "Tutorial"
#define BJUMBLR_LABEL_ROW "Reihe"
#define BJUMBLR_LABEL_STEP "SChritt"
#define BJUMBLR_LABEL_LEVEL "Level"
#define BJUMBLR_LABEL_ALL_FILES "Alle Dateien"
#define BJUMBLR_LABEL_AUDIO_FILES "Audiodateien"
#define BJUMBLR_LABEL_OPEN "Öffnen"
#define BJUMBLR_LABEL_PLAY_AS_LOOP "Auswahl als Schleife spielen"
#define BJUMBLR_LABEL_FILE "Datei"
#define BJUMBLR_LABEL_SELECTION_START "Beginn Auswahl"
#define BJUMBLR_LABEL_SELECTION_END "Ende Auswahl"
#define BJUMBLR_LABEL_FRAMES "Frames"
#define BJUMBLR_LABEL_NO_FILE_SELECTED "Keine Audiodatei ausgewählt"
#define BJUMBLR_LABEL_NEW_FOLDER "Erstelle neuen Ordner:"
#define BJUMBLR_LABEL_CANT_CREATE_NEW_FOLDER "Fehler: Ordner konnte nicht erstellt werden."
#define BJUMBLR_LABEL_SOURCE "Quelle"
#define BJUMBLR_LABEL_CALIBRATION "Kalibrierung"
#define BJUMBLR_LABEL_STEP_EDIT_MODE "Bearbeitungsmodus"
#define BJUMBLR_LABEL_STEP_SIZE "Schrittgröße"
#define BJUMBLR_LABEL_PATTERN_SIZE "Patterngröße"
#define BJUMBLR_LABEL_PAD_LEVEL "Blocklevel"
#define BJUMBLR_LABEL_PLAYBACK "Playback"
#define BJUMBLR_LABEL_SPEED "Geschwindigk."
#endif
| 2,937
|
C++
|
.h
| 65
| 43.861538
| 91
| 0.812697
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,387
|
MessageDefinitions.hpp
|
sjaehn_BJumblr/src/MessageDefinitions.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef MESSAGEDEFINITIONS_HPP_
#define MESSAGEDEFINITIONS_HPP_
#include <string>
#ifdef LOCALEFILE
#include LOCALEFILE
#else
#include "Locale_EN.hpp"
#endif
#define MAXMESSAGES 3
enum MessageNr
{
NO_MSG = 0,
JACK_STOP_MSG = 1,
CANT_OPEN_SAMPLE = 2
};
const std::string messageStrings[MAXMESSAGES] =
{
"",
BJUMBLR_LABEL_JACK_OFF,
BJUMBLR_LABEL_CANT_OPEN_SAMPLE
};
#endif /* MESSAGEDEFINITIONS_HPP_ */
| 1,253
|
C++
|
.h
| 41
| 28.804878
| 74
| 0.763485
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,388
|
SymbolWidget.hpp
|
sjaehn_BJumblr/src/SymbolWidget.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018 - 2020 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SYMBOLWIDGET_HPP_
#define SYMBOLWIDGET_HPP_
#include "BWidgets/Widget.hpp"
#include "BWidgets/Label.hpp"
#include "BWidgets/Focusable.hpp"
#include <cmath>
enum SWSymbol
{
NOSYMBOL = -1,
ADDSYMBOL = 0,
CLOSESYMBOL = 1,
RIGHTSYMBOL = 2,
LEFTSYMBOL = 3,
PLAYSYMBOL = 4,
MIDISYMBOL = 5
};
const std::string symboltxt[7] = {"", "Insert", "Delete", "Move forward", "Move backward", "Play", "MIDI"};
class SymbolWidget : public BWidgets::Widget, public BWidgets::Focusable
{
protected:
BColors::ColorSet fgColors_;
SWSymbol symbol_;
BWidgets::Label focusLabel_;
public:
SymbolWidget () : SymbolWidget (0.0, 0.0, 0.0, 0.0, "symbol", NOSYMBOL) {}
SymbolWidget (const double x, const double y, const double width, const double height, const std::string& name, SWSymbol symbol) :
Widget (x, y, width, height, name),
Focusable (std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_IN_MS),
std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_OUT_MS)),
fgColors_ (BColors::whites),
symbol_ (symbol),
focusLabel_ (0, 0, 80, 20, name_ + BWIDGETS_DEFAULT_FOCUS_NAME, symboltxt[symbol + 1])
{
focusLabel_.setStacking (BWidgets::STACKING_OVERSIZE);
focusLabel_.resize ();
focusLabel_.hide ();
add (focusLabel_);
}
SymbolWidget (const SymbolWidget& that) :
Widget (that), Focusable (that),
fgColors_ (that.fgColors_),
symbol_ (that.symbol_),
focusLabel_ (that.focusLabel_)
{
focusLabel_.hide();
add (focusLabel_);
}
SymbolWidget& operator= (const SymbolWidget& that)
{
release (&focusLabel_);
focusLabel_ = that.focusLabel_;
focusLabel_.hide();
fgColors_ = that.fgColors_;
symbol_ = that.symbol_;
Widget::operator= (that);
Focusable::operator= (that);
add (focusLabel_);
return *this;
}
virtual BWidgets::Widget* clone () const override {return new SymbolWidget (*this);}
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override
{
Widget::applyTheme (theme, name);
focusLabel_.applyTheme (theme, name + BWIDGETS_DEFAULT_FOCUS_NAME);
focusLabel_.resize();
void* colorsPtr = theme.getStyle(name, BWIDGETS_KEYWORD_FGCOLORS);
if (colorsPtr)
{
fgColors_ = *((BColors::ColorSet*) colorsPtr);
update ();
}
}
virtual void applyTheme (BStyles::Theme& theme) override {applyTheme (theme, name_);}
virtual void onFocusIn (BEvents::FocusEvent* event) override
{
if (event && event->getWidget())
{
BUtilities::Point pos = event->getPosition();
focusLabel_.moveTo (pos.x - 0.5 * focusLabel_.getWidth(), pos.y - focusLabel_.getHeight());
focusLabel_.show();
}
Widget::onFocusIn (event);
}
virtual void onFocusOut (BEvents::FocusEvent* event) override
{
if (event && event->getWidget()) focusLabel_.hide();
Widget::onFocusOut (event);
}
protected:
virtual void draw (const BUtilities::RectArea& area) override
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
Widget::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX(), area.getY(), area.getWidth(), area.getHeight());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
double ext = (w < h ? w : h);
switch (symbol_)
{
case ADDSYMBOL: cairo_move_to (cr, x0 + w / 2 - ext / 2, y0 + h / 2);
cairo_line_to (cr, x0 + w / 2 + ext / 2, y0 + h / 2);
cairo_move_to (cr, x0 + w / 2, y0 + h / 2 - ext / 2);
cairo_line_to (cr, x0 + w / 2, y0 + h / 2 + ext / 2);
cairo_set_line_width (cr, 2.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
cairo_stroke (cr);
break;
case CLOSESYMBOL: cairo_move_to (cr, x0 + w / 2 - ext / 2, y0 + h / 2);
cairo_line_to (cr, x0 + w / 2 + ext / 2, y0 + h / 2);
cairo_set_line_width (cr, 2.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
cairo_stroke (cr);
break;
case LEFTSYMBOL: cairo_move_to (cr, x0 + w / 2 + 0.25 * ext, y0 + h / 2 - ext / 2);
cairo_line_to (cr, x0 + w / 2 - 0.25 * ext, y0 + h / 2);
cairo_line_to (cr, x0 + w / 2 + 0.25 * ext, y0 + h / 2 + ext / 2);
cairo_set_line_width (cr, 2.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
cairo_stroke (cr);
break;
case RIGHTSYMBOL: cairo_move_to (cr, x0 + w / 2 - 0.25 * ext, y0 + h / 2 - ext / 2);
cairo_line_to (cr, x0 + w / 2 + 0.25 * ext, y0 + h / 2);
cairo_line_to (cr, x0 + w / 2 - 0.25 * ext, y0 + h / 2 + ext / 2);
cairo_set_line_width (cr, 2.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
cairo_stroke (cr);
break;
case PLAYSYMBOL: cairo_move_to (cr, x0 + 0.25 * w, y0);
cairo_line_to (cr, x0 + 0.75 * w, y0 + 0.5 * h);
cairo_line_to (cr, x0 + 0.25 * w, y0 + h);
cairo_close_path (cr);
cairo_set_line_width (cr, 0.0);
if (getState() == BColors::NORMAL)
{
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (BColors::ACTIVE)));
cairo_stroke (cr);
}
else
{
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
cairo_fill (cr);
}
break;
case MIDISYMBOL: cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (*fgColors_.getColor (getState ())));
for (int i = 0; i < 3; ++i) cairo_rectangle (cr, x0 + 0.5 * w - 0.375 * ext + i * 0.25 * ext, y0 + 0.5 * h - 0.45 * ext, 0.25 * ext, 0.9 * ext);
cairo_stroke (cr);
cairo_set_line_width (cr, 0.0);
for (int i = 0; i < 2; ++i)
{
cairo_rectangle (cr, x0 + 0.5 * w - 0.2 * ext + i * 0.25 * ext, y0 + 0.5 * h - 0.45 * ext, 0.15 * ext, 0.6 * ext);
cairo_fill (cr);
}
default: break;
}
cairo_destroy (cr);
}
}
};
#endif /* SYMBOLWIDGET_HPP_ */
| 10,268
|
C++
|
.h
| 187
| 33.657754
| 200
| 0.428287
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,389
|
Message.hpp
|
sjaehn_BJumblr/src/Message.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef MESSAGE_HPP_
#define MESSAGE_HPP_
#include <cstdint>
#include "MessageDefinitions.hpp"
class Message
{
public:
Message () : messageBits (0), scheduled (true) {}
void clearMessages ()
{
messageBits = 0;
scheduled = true;
}
void setMessage (MessageNr messageNr)
{
if ((messageNr > NO_MSG) && (messageNr < MAXMESSAGES) && (!isMessage (messageNr)))
{
messageBits = messageBits | (1 << (messageNr - 1));
scheduled = true;
}
}
void deleteMessage (MessageNr messageNr)
{
if ((messageNr > NO_MSG) && (messageNr < MAXMESSAGES) && (isMessage (messageNr)))
{
messageBits = messageBits & (~(1 << (messageNr - 1)));
scheduled = true;
}
}
bool isMessage (MessageNr messageNr)
{
if ((messageNr > NO_MSG) && (messageNr < MAXMESSAGES)) return ((messageBits & (1 << (messageNr - 1))) != 0);
else if (messageNr == NO_MSG) return (messageBits == 0);
else return false;
}
MessageNr loadMessage ()
{
scheduled = false;
for (int i = NO_MSG + 1; i < MAXMESSAGES; ++i)
{
MessageNr messageNr = MessageNr (i);
if (isMessage (messageNr)) return messageNr;
}
return NO_MSG;
}
bool isScheduled () {return scheduled;}
private:
uint32_t messageBits;
bool scheduled;
};
#endif /* MESSAGE_HPP_ */
| 2,086
|
C++
|
.h
| 70
| 27.414286
| 110
| 0.707378
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,390
|
Ports.hpp
|
sjaehn_BJumblr/src/Ports.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018 - 2020 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef PORTS_HPP_
#define PORTS_HPP_
enum PortIndex {
CONTROL = 0,
NOTIFY = 1,
AUDIO_IN_1 = 2,
AUDIO_IN_2 = 3,
AUDIO_OUT_1 = 4,
AUDIO_OUT_2 = 5,
CONTROLLERS = 6,
SOURCE = 0,
PLAY = 1,
NR_OF_STEPS = 2,
STEP_BASE = 3,
STEP_SIZE = 4,
STEP_OFFSET = 5,
MANUAL_PROGRSSION_DELAY = 6,
SPEED = 7,
PAGE = 8,
MIDI = 9,
STATUS = 0,
CHANNEL = 1,
NOTE = 2,
VALUE = 3,
NR_MIDI_CTRLS = 4,
MAXCONTROLLERS = MIDI + 16 * NR_MIDI_CTRLS
};
enum BaseIndex
{
SECONDS = 0,
BEATS = 1,
BARS = 2
};
#endif /* PORTS_HPP_ */
| 1,402
|
C++
|
.h
| 53
| 24.509434
| 74
| 0.691735
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,391
|
MarkerWidget.hpp
|
sjaehn_BJumblr/src/MarkerWidget.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018 - 2020 by Sven Jähnichen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef BWIDGETS_MARKERWIDGET_HPP_
#define BWIDGETS_MARKERWIDGET_HPP_
#include "BWidgets/Widget.hpp"
enum MarkerIndex
{
MARKER_RIGHT,
MARKER_LEFT,
MARKER_DOWN,
MARKER_UP
};
class MarkerWidget : public BWidgets::Widget
{
public:
MarkerWidget () : MarkerWidget (0.0, 0.0, 0.0, 0.0, "marker") {}
MarkerWidget (const double x, const double y, const double width, const double height, const std::string& name, MarkerIndex index = MARKER_RIGHT) :
Widget (x, y, width, height, name),
index_ (index)
{}
/**
* Pattern cloning. Creates a new instance of the widget and copies all
* its properties.
*/
virtual Widget* clone () const override {return new MarkerWidget (*this);}
void setMarker (MarkerIndex index)
{
index_ = index;
update();
};
protected:
MarkerIndex index_;
virtual void draw (const BUtilities::RectArea& area) override
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((getWidth () >= 6) && (getHeight () >= 6))
{
Widget::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX (), area.getY (), area.getWidth (), area.getHeight ());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
double size = (w < h ? 0.8 * w : 0.8 * h);
// Symbol
cairo_set_line_width (cr, 0);
switch (index_)
{
case MARKER_RIGHT: cairo_move_to (cr, x0 + w/2 - 0.25 * size, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 + 0.25 * size, y0 + h/2);
cairo_line_to (cr, x0 + w/2 - 0.25 * size, y0 + h/2 + 0.375 * size);
break;
case MARKER_LEFT: cairo_move_to (cr, x0 + w/2 + 0.25 * size, y0 + h/2 - 0.375 * size);
cairo_line_to (cr, x0 + w/2 - 0.25 * size, y0 + h/2);
cairo_line_to (cr, x0 + w/2 + 0.25 * size, y0 + h/2 + 0.375 * size);
break;
case MARKER_DOWN: cairo_move_to (cr, x0 + w/2 - 0.375 * size, y0 + h/2 - 0.25 * size);
cairo_line_to (cr, x0 + w/2, y0 + h/2 + 0.25 * size);
cairo_line_to (cr, x0 + w/2 + 0.375 * size, y0 + h/2 - 0.25 * size);
break;
case MARKER_UP: cairo_move_to (cr, x0 + w/2 - 0.375 * size, y0 + h/2 + 0.25 * size);
cairo_line_to (cr, x0 + w/2, y0 + h/2 - 0.25 * size);
cairo_line_to (cr, x0 + w/2 + 0.375 * size, y0 + h/2 + 0.25 * size);
break;
}
cairo_close_path (cr);
cairo_set_source_rgba (cr, CAIRO_RGBA (BColors::yellow));
cairo_fill (cr);
cairo_destroy (cr);
}
}
}
};
#endif /* BWIDGETS_MARKERWIDGET_HPP_ */
| 3,520
|
C++
|
.h
| 95
| 33.189474
| 148
| 0.638392
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,392
|
UpClick.hpp
|
sjaehn_BJumblr/src/UpClick.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef UPCLICK_HPP_
#define UPCLICK_HPP_
#include "BWidgets/Button.hpp"
class UpClick : public BWidgets::Button
{
public:
UpClick () : UpClick (0.0, 0.0, BWIDGETS_DEFAULT_BUTTON_WIDTH, BWIDGETS_DEFAULT_BUTTON_HEIGHT, "button", 0.0) {}
UpClick (const double x, const double y, const double width, const double height, const std::string& name, double defaultValue = 0) :
Button (x, y, width, height, name, defaultValue) {}
virtual void draw (const BUtilities::RectArea& area) override
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((area.getWidth() >= 6) && (area.getHeight() >= 6))
{
// Draw super class widget elements first
Widget::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX(), area.getY(), area.getWidth(), area.getHeight());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
BColors::Color butColor = *bgColors.getColor (value == 1 ? BColors::ACTIVE : BColors::NORMAL);
cairo_move_to (cr, x0, y0 + 0.75 * h);
cairo_line_to (cr, x0 + 0.5 * w, y0 + 0.25 * h);
cairo_line_to (cr, x0 + w, y0 + 0.75 * h);
cairo_set_line_width (cr, 2);
cairo_set_source_rgba (cr, CAIRO_RGBA (butColor));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
}
};
#endif /* UPCLICK_HPP_ */
| 2,361
|
C++
|
.h
| 58
| 37.62069
| 134
| 0.695462
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,393
|
PadSurface.hpp
|
sjaehn_BJumblr/src/PadSurface.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef PADSURFACE_HPP_
#define PADSURFACE_HPP_
#include "BWidgets/DrawingSurface.hpp"
#include "BWidgets/Focusable.hpp"
#include "BWidgets/Text.hpp"
class PadSurface : public BWidgets::DrawingSurface, public BWidgets::Focusable
{
public:
BWidgets::Text focusText;
PadSurface () : PadSurface (0, 0, 0, 0, "padsurface") {}
PadSurface (const double x, const double y, const double width, const double height, const std::string& name) :
DrawingSurface (x, y, width, height, name),
Focusable (std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_IN_MS),
std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_OUT_MS)),
focusText (0, 0, 120, 100, name + "/focus", "", true)
{
focusText.setStacking (BWidgets::STACKING_OVERSIZE);
focusText.hide ();
add (focusText);
}
void onFocusIn (BEvents::FocusEvent* event) override
{
Widget::onFocusIn (event);
if (event && event->getWidget())
{
BUtilities::Point pos = event->getPosition();
focusText.moveTo (pos.x - 0.5 * focusText.getWidth(), pos.y - focusText.getHeight());
// Resize
cairo_surface_t* surface = getDrawingSurface();
cairo_t* cr = cairo_create (surface);
focusText.resize (400,100); // Maximize size first to omit breaks
std::vector<std::string> textblock = focusText.getTextBlock ();
double blockheight = focusText.getTextBlockHeight (textblock);
double blockwidth = 0.0;
for (std::string textline : textblock)
{
cairo_text_extents_t ext = focusText.getFont ()->getTextExtents (cr, textline);
if (ext.width > blockwidth) blockwidth = ext.width;
}
cairo_destroy (cr);
focusText.resize (blockwidth + 2 * focusText.getXOffset (), blockheight + 2 * focusText.getYOffset ());
focusText.resize();
focusText.show();
}
}
void onFocusOut (BEvents::FocusEvent* event) override
{
Widget::onFocusOut (event);
if (event && event->getWidget()) focusText.hide();
}
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override
{
focusText.applyTheme (theme, name + "/focus");
focusText.resize ();
}
virtual void applyTheme (BStyles::Theme& theme) override
{
applyTheme (theme, name_);
}
};
#endif /*PADSURFACE_HPP_*/
| 3,519
|
C++
|
.h
| 80
| 35.0625
| 120
| 0.623468
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,394
|
DownClick.hpp
|
sjaehn_BJumblr/src/DownClick.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DOWNCLICK_HPP_
#define DOWNCLICK_HPP_
#include "BWidgets/Button.hpp"
class DownClick : public BWidgets::Button
{
public:
DownClick () : DownClick (0.0, 0.0, BWIDGETS_DEFAULT_BUTTON_WIDTH, BWIDGETS_DEFAULT_BUTTON_HEIGHT, "togglebutton", 0.0) {}
DownClick (const double x, const double y, const double width, const double height, const std::string& name, double defaultValue = 0) :
Button (x, y, width, height, name, defaultValue) {}
virtual void draw (const BUtilities::RectArea& area) override
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((area.getWidth() >= 6) && (area.getHeight() >= 6))
{
// Draw super class widget elements first
Widget::draw (area);
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX(), area.getY(), area.getWidth(), area.getHeight());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
BColors::Color butColor = *bgColors.getColor (value == 1 ? BColors::ACTIVE : BColors::NORMAL);
cairo_move_to (cr, x0, y0 + 0.25 * h);
cairo_line_to (cr, x0 + 0.5 * w, y0 + 0.75 * h);
cairo_line_to (cr, x0 + w, y0 + 0.25 * h);
cairo_set_line_width (cr, 2);
cairo_set_source_rgba (cr, CAIRO_RGBA (butColor));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
}
};
#endif /* DOWNCLICK_HPP_ */
| 2,381
|
C++
|
.h
| 58
| 37.965517
| 136
| 0.698097
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,395
|
BJumblrGUI.hpp
|
sjaehn_BJumblr/src/BJumblrGUI.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef BJUMBLRGUI_HPP_
#define BJUMBLRGUI_HPP_
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
#include <lv2/lv2plug.in/ns/ext/time/time.h>
#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
#include <iostream>
#include <algorithm>
#include "BWidgets/Widget.hpp"
#include "BWidgets/Window.hpp"
#include "BWidgets/Label.hpp"
#include "BWidgets/DrawingSurface.hpp"
#include "BWidgets/DialValue.hpp"
#include "BWidgets/PopupListBox.hpp"
#include "BWidgets/LeftButton.hpp"
#include "BWidgets/PlusButton.hpp"
#include "BWidgets/MinusButton.hpp"
#include "BWidgets/ImageIcon.hpp"
#include "BWidgets/TextToggleButton.hpp"
#include "screen.h"
#ifdef LOCALEFILE
#include LOCALEFILE
#else
#include "Locale_EN.hpp"
#endif
#include "drawbutton.hpp"
#include "HaloButton.hpp"
#include "HaloToggleButton.hpp"
#include "HomeButton.hpp"
#include "LoadButton.hpp"
#include "PadSurface.hpp"
#include "definitions.h"
#include "Ports.hpp"
#include "Urids.hpp"
#include "Pad.hpp"
#include "PadMessage.hpp"
#include "Journal.hpp"
#include "MonitorWidget.hpp"
#include "MarkerWidget.hpp"
#include "SymbolWidget.hpp"
#include "SampleChooser.hpp"
#define BG_FILE "inc/surface.png"
#define HELP_URL "https://github.com/sjaehn/BJumblr/blob/master/README.md"
#define YT_URL "https://www.youtube.com/watch?v=DFSi7TMqvMw"
#define MAXUNDO 20
#ifndef WWW_BROWSER_CMD
#define WWW_BROWSER_CMD "x-www-browser"
#endif
#define RESIZE(widget, x, y, w, h, sz) {widget.moveTo ((x) * (sz), (y) * (sz)); widget.resize ((w) * (sz), (h) * (sz));}
enum editIndex
{
EDIT_CUT = 0,
EDIT_COPY = 1,
EDIT_XFLIP = 2,
EDIT_YFLIP = 3,
EDIT_PASTE = 4,
EDIT_RESET = 5,
EDIT_UNDO = 6,
EDIT_REDO = 7,
MAXEDIT = 8
};
const std::string editLabels[MAXEDIT] =
{
BJUMBLR_LABEL_SELECT_CUT,
BJUMBLR_LABEL_SELECT_COPY,
BJUMBLR_LABEL_SELECT_XFLIP,
BJUMBLR_LABEL_SELECT_YFLIP,
BJUMBLR_LABEL_PASTE,
BJUMBLR_LABEL_RESET,
BJUMBLR_LABEL_UNDO,
BJUMBLR_LABEL_REDO};
class BJumblrGUI : public BWidgets::Window
{
public:
BJumblrGUI (const char *bundle_path, const LV2_Feature *const *features, PuglNativeView parentWindow);
~BJumblrGUI ();
void port_event (uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer);
void send_ui_on ();
void send_ui_off ();
void send_samplePath ();
void send_sampleAmp();
void send_editMode ();
void send_maxPage ();
void send_playbackPage ();
void send_requestMidiLearn ();
void send_pad (int page);
void send_pad (int page, int row, int step);
void send_flip ();
virtual void onConfigureRequest (BEvents::ExposeEvent* event) override;
virtual void onCloseRequest (BEvents::WidgetEvent* event) override;
virtual void onKeyPressed (BEvents::KeyEvent* event) override;
virtual void onKeyReleased (BEvents::KeyEvent* event) override;
void applyTheme (BStyles::Theme& theme) override;
LV2UI_Controller controller;
LV2UI_Write_Function write_function;
private:
static void valueChangedCallback(BEvents::Event* event);
static void pageClickedCallback(BEvents::Event* event);
static void pageSymbolClickedCallback(BEvents::Event* event);
static void pagePlayClickedCallback(BEvents::Event* event);
static void pageScrollClickedCallback(BEvents::Event* event);
static void midiSymbolClickedCallback(BEvents::Event* event);
static void midiButtonClickedCallback(BEvents::Event* event);
static void midiStatusChangedCallback(BEvents::Event* event);
static void levelChangedCallback(BEvents::Event* event);
static void edit1ChangedCallback(BEvents::Event* event);
static void edit2ChangedCallback(BEvents::Event* event);
static void padsPressedCallback (BEvents::Event* event);
static void padsScrolledCallback (BEvents::Event* event);
static void padsFocusedCallback (BEvents::Event* event);
static void loadButtonClickedCallback (BEvents::Event* event);
static void syncButtonClickedCallback (BEvents::Event* event);
static void delayButtonsClickedCallback (BEvents::Event* event);
static void patternFlippedClickedCallback (BEvents::Event* event);
static void helpButtonClickedCallback (BEvents::Event* event);
static void ytButtonClickedCallback (BEvents::Event* event);
virtual void resize () override;
void pushPage ();
void popPage ();
void gotoPage (const int page);
void insertPage (const int page);
void deletePage (const int page);
void swapPage (const int page1, const int page2);
void updatePageContainer ();
bool validatePad (int page);
bool validatePad (int page, int row, int step, Pad& pad);
void setMarkers();
void drawPad ();
void drawPad (int row, int step);
void drawPad (cairo_t* cr, int row, int step);
std::string pluginPath;
double sz;
cairo_surface_t* bgImageSurface;
BJumblrURIs uris;
LV2_Atom_Forge forge;
// Controllers
std::array<BWidgets::ValueWidget*, MAXCONTROLLERS> controllerWidgets;
std::array<float, MAXCONTROLLERS> controllers;
int editMode;
//Pads
class Pattern
{
public:
void clear ();
Pad getPad (const size_t row, const size_t step) const;
void setPad (const size_t row, const size_t step, const Pad& pad);
std::vector<PadMessage> undo ();
std::vector<PadMessage> redo ();
void store ();
private:
Journal<std::vector<PadMessage>, MAXUNDO> journal;
std::array<std::array<Pad, MAXSTEPS>, MAXSTEPS> pads;
struct
{
std::vector<PadMessage> oldMessage;
std::vector<PadMessage> newMessage;
} changes;
};
std::array<Pattern, MAXPAGES> pattern;
bool patternFlipped;
struct ClipBoard
{
std::vector<std::vector<Pad>> data;
std::pair<int, int> origin;
std::pair<int, int> extends;
bool ready = true;
std::chrono::steady_clock::time_point time;
};
ClipBoard clipBoard;
// Cursor
float cursor;
bool wheelScrolled;
bool padPressed;
bool deleteMode;
std::string samplePath;
int64_t sampleStart;
int64_t sampleEnd;
bool sampleLoop;
// Pages
int actPage;
int nrPages;
int pageOffset;
//Widgets
BWidgets::Widget mContainer;
BWidgets::Label messageLabel;
BWidgets::ValueWidget pageWidget;
SymbolWidget pageBackSymbol;
SymbolWidget pageForwardSymbol;
BWidgets::Label sourceLabel;
BWidgets::Label calibrationLabel;
BWidgets::Label stepEditModeLabel;
BWidgets::Label stepSizeLabel;
BWidgets::Label patternSizeLabel;
BWidgets::Label padLevelLabel;
BWidgets::Label playbackLabel;
BWidgets::Label speedLabel;
struct Tab
{
BWidgets::Widget container;
BWidgets::ImageIcon icon;
SymbolWidget playSymbol;
SymbolWidget midiSymbol;
std::array<SymbolWidget, 4> symbols;
std::array<BWidgets::ValueWidget, 4> midiWidgets;
};
std::array<Tab, MAXPAGES> tabs;
BWidgets::ValueWidget midiBox;
BWidgets::Label midiText;
BWidgets::Label midiStatusLabel;
BWidgets::PopupListBox midiStatusListBox;
BWidgets::Label midiChannelLabel;
BWidgets::PopupListBox midiChannelListBox;
BWidgets::Label midiNoteLabel;
BWidgets::PopupListBox midiNoteListBox;
BWidgets::Label midiValueLabel;
BWidgets::PopupListBox midiValueListBox;
BWidgets::TextToggleButton midiLearnButton;
BWidgets::TextButton midiCancelButton;
BWidgets::TextButton midiOkButton;
BWidgets::Widget flipButton;
PadSurface padSurface;
MarkerWidget markerFwd;
MarkerWidget markerRev;
MonitorWidget monitorWidget;
BWidgets::PopupListBox sourceListBox;
LoadButton loadButton;
BWidgets::Label sampleNameLabel;
BWidgets::Dial sampleAmpDial;
HaloToggleButton playButton;
HaloToggleButton bypassButton;
HaloButton stopButton;
std::array<HaloToggleButton, EDIT_RESET> edit1Buttons;
std::array<HaloButton, MAXEDIT - EDIT_RESET> edit2Buttons;
BWidgets::ValueWidget syncWidget;
BWidgets::LeftButton zeroStepOffsetButton;
BWidgets::MinusButton decStepOffsetButton;
HomeButton hostSyncButton;
BWidgets::PlusButton incStepOffsetButton;
BWidgets::PopupListBox editModeListBox;
BWidgets::PopupListBox stepSizeListBox;
BWidgets::PopupListBox stepBaseListBox;
BWidgets::PopupListBox padSizeListBox;
std::array<HaloToggleButton, 5> levelButtons;
BWidgets::DialValue levelDial;
BWidgets::Label delayDisplayLabel;
BWidgets::RangeWidget manualProgressionDelayWidget;
HaloButton resetDelayButton;
HaloButton increaseDelayButton;
HaloButton decreaseDelayButton;
HaloButton setStartDelayButton;
BWidgets::DialValue speedDial;
HaloButton helpButton;
HaloButton ytButton;
SampleChooser* fileChooser;
// Definition of styles
BColors::ColorSet fgColors = {{{0.75, 0.75, 0.0, 1.0}, {1.0, 1.0, 0.25, 1.0}, {0.1, 0.1, 0.0, 1.0}, {0.0, 0.0, 0.0, 0.0}}};
BColors::ColorSet tgColors = {{BColors::grey, BColors::white, BColors::grey, BColors::darkgrey}};
BColors::ColorSet buttonBgColors = {{{0.4, 0.4, 0.4, 1.0}, {0.6, 0.6, 0.6, 1.0}, {0.05, 0.05, 0.05, 1.0}, {0.0, 0.0, 0.0, 1.0}}};
BColors::ColorSet knobBgColors = {{{0.15, 0.15, 0.15, 1.0}, {0.3, 0.3, 0.3, 1.0}, {0.05, 0.05, 0.05, 1.0}, {0.0, 0.0, 0.0, 1.0}}};
BColors::ColorSet tgBgColors = {{{0.0, 0.03, 0.06, 1.0}, {0.3, 0.3, 0.3, 1.0}, {0.0, 0.0, 0.0, 1.0}, {0.0, 0.0, 0.0, 1.0}}};
BColors::ColorSet ltColors = {{{1.0, 1.0, 1.0, 1.0}, {1.0, 1.0, 1.0, 1.0}, {0.25, 0.25, 0.25, 1.0}, {0.0, 0.0, 0.0, 1.0}}};
BColors::ColorSet wvColors = {{{1.0, 1.0, 1.0, 0.15}, {1.0, 1.0, 1.0, 0.15}, {0.25, 0.25, 0.25, 0.15}, {0.0, 0.0, 0.0, 0.15}}};
BColors::ColorSet blkColors = {{{0.0, 0.0, 0.0, 0.75}, {0.0, 0.0, 0.0, 1.0}, {0.0, 0.0, 0.0, 0.25}, {0.0, 0.0, 0.0, 0.0}}};
BColors::Color ink = {0.0, 0.25, 0.5, 1.0};
BColors::Color evenPadBgColor = {0.0, 0.05, 0.2, 1.0};
BColors::Color oddPadBgColor = {0.0, 0.0, 0.0, 1.0};
BStyles::Border border = {{ink, 1.0}, 0.0, 2.0, 0.0};
BStyles::Border menuBorder = {{BColors::grey, 1.0}, 0.0, 0.0, 0.0};
BStyles::Border labelborder = {BStyles::noLine, 4.0, 0.0, 0.0};
BStyles::Border boxlabelborder = {{BColors::grey, 1.0}, 0.0, 3.0, 0.0};
BStyles::Border focusborder = BStyles::Border (BStyles::Line (BColors::Color (0.0, 0.0, 0.0, 0.5), 2.0));
BStyles::Fill widgetBg = BStyles::noFill;
BStyles::Fill tabBg = BStyles::Fill (BColors::Color (0.75, 0.75, 0.0, 0.5));
BStyles::Fill activeTabBg = BStyles::Fill (BColors::Color (0.75, 0.75, 0.0, 1.0));
BStyles::Fill menuBg = BStyles::Fill (BColors::Color (0.0, 0.0, 0.05, 1.0));
BStyles::Fill screenBg = BStyles::Fill (BColors::Color (0.0, 0.0, 0.0, 0.8));
BStyles::Fill boxBg = BStyles::Fill (BColors::Color (0.0, 0.0, 0.0, 0.9));
BStyles::Font ctLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, 12.0,
BStyles::TEXT_ALIGN_CENTER, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::Font tLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD, 12.0,
BStyles::TEXT_ALIGN_CENTER, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::Font tgLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, 12.0,
BStyles::TEXT_ALIGN_CENTER, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::Font lfLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, 12.0,
BStyles::TEXT_ALIGN_LEFT, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::Font boldLfLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD, 12.0,
BStyles::TEXT_ALIGN_LEFT, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::Font smLabelFont = BStyles::Font ("Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, 8.0,
BStyles::TEXT_ALIGN_CENTER, BStyles::TEXT_VALIGN_MIDDLE);
BStyles::StyleSet defaultStyles = {"default", {{"background", STYLEPTR (&BStyles::noFill)},
{"border", STYLEPTR (&BStyles::noBorder)}}};
BStyles::StyleSet labelStyles = {"labels", {{"background", STYLEPTR (&BStyles::noFill)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&ctLabelFont)}}};
BStyles::StyleSet smlabelStyles = {"labels", {{"background", STYLEPTR (&BStyles::noFill)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&smLabelFont)}}};
BStyles::StyleSet focusStyles = {"labels", {{"background", STYLEPTR (&screenBg)},
{"border", STYLEPTR (&focusborder)},
{"textcolors", STYLEPTR (<Colors)},
{"font", STYLEPTR (&lfLabelFont)}}};
BStyles::Theme theme = BStyles::Theme
({
defaultStyles,
{"B.Jumblr", {{"background", STYLEPTR (&BStyles::blackFill)},
{"border", STYLEPTR (&BStyles::noBorder)}}},
{"main", {{"background", STYLEPTR (&widgetBg)},
{"border", STYLEPTR (&BStyles::noBorder)}}},
{"monitor", {{"uses", STYLEPTR (&defaultStyles)},
{"fgcolors", STYLEPTR (&wvColors)}}},
{"widget", {{"uses", STYLEPTR (&defaultStyles)}}},
{"widget/focus", {{"uses", STYLEPTR (&focusStyles)}}},
{"screen", {{"background", STYLEPTR (&screenBg)},
{"border", STYLEPTR (&BStyles::noBorder)}}},
{"tab", {{"background", STYLEPTR (&tabBg)},
{"border", STYLEPTR (&BStyles::noBorder)},
{"fgcolors", STYLEPTR (&blkColors)}}},
{"activetab", {{"background", STYLEPTR (&activeTabBg)},
{"border", STYLEPTR (&BStyles::noBorder)},
{"fgcolors", STYLEPTR (&blkColors)}}},
{"symbol", {{"uses", STYLEPTR (&defaultStyles)},
{"fgcolors", STYLEPTR (&blkColors)}}},
{"symbol/focus", {{"uses", STYLEPTR (&focusStyles)}}},
{"box", {{"background", STYLEPTR (&boxBg)},
{"border", STYLEPTR (&border)}}},
{"box/focus", {{"uses", STYLEPTR (&focusStyles)}}},
{"boxlabel", {{"background", STYLEPTR (&boxBg)},
{"border", STYLEPTR (&boxlabelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"smboxlabel", {{"background", STYLEPTR (&boxBg)},
{"border", STYLEPTR (&boxlabelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&smLabelFont)}}},
{"button", {{"background", STYLEPTR (&BStyles::blackFill)},
{"border", STYLEPTR (&border)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}},
{"tgbutton", {{"border", STYLEPTR (&BStyles::noBorder)},
{"textcolors", STYLEPTR (&tgColors)},
{"bgcolors", STYLEPTR (&tgBgColors)},
{"font", STYLEPTR (&tgLabelFont)}}},
{"tgbutton/focus", {{"uses", STYLEPTR (&focusStyles)}}},
{"dial", {{"uses", STYLEPTR (&defaultStyles)},
{"fgcolors", STYLEPTR (&fgColors)},
{"bgcolors", STYLEPTR (&knobBgColors)},
{"textcolors", STYLEPTR (&fgColors)},
{"font", STYLEPTR (&ctLabelFont)}}},
{"dial/focus", {{"uses", STYLEPTR (&focusStyles)}}},
{"tlabel", {{"uses", STYLEPTR (&smlabelStyles)},
{"font", STYLEPTR (&tLabelFont)}}},
{"ylabel", {{"uses", STYLEPTR (&smlabelStyles)},
{"textcolors", STYLEPTR (&fgColors)}}},
{"ctlabel", {{"uses", STYLEPTR (&labelStyles)}}},
{"lflabel", {{"uses", STYLEPTR (&labelStyles)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"menu", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"menu/item", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"menu/button", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}},
{"menu/listbox", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"menu/listbox/item", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"menu/listbox/button", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}},
{"filechooser", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"filechooser/label", {{"background", STYLEPTR (&menuBg)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/textbox", {{"background", STYLEPTR (&menuBg)},
{"border", STYLEPTR (&boxlabelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/scrollbar", {{"uses", STYLEPTR (&defaultStyles)},
{"fgcolors", STYLEPTR (&blkColors)},
{"bgcolors", STYLEPTR (&knobBgColors)}}},
{"filechooser/marker", {{"uses", STYLEPTR (&defaultStyles)},
{"bgcolors", STYLEPTR (&fgColors)}}},
{"filechooser/checkbox", {{"uses", STYLEPTR (&defaultStyles)},
{"fgcolors", STYLEPTR (&fgColors)},
{"bgcolors", STYLEPTR (&knobBgColors)}}},
{"filechooser/listbox", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"filechooser/listbox/item", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/listbox/item/dir", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&boldLfLabelFont)}}},
{"filechooser/listbox/item/file", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/listbox/button", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}},
{"filechooser/popup", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"filechooser/popup/item", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/popup/button", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}},
{"filechooser/popup/listbox", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)}}},
{"filechooser/popup/listbox/item", {{"uses", STYLEPTR (&defaultStyles)},
{"border", STYLEPTR (&labelborder)},
{"textcolors", STYLEPTR (&BColors::whites)},
{"font", STYLEPTR (&lfLabelFont)}}},
{"filechooser/popup/listbox/button", {{"border", STYLEPTR (&menuBorder)},
{"background", STYLEPTR (&menuBg)},
{"bgcolors", STYLEPTR (&buttonBgColors)}}}
});
};
#endif /* BJUMBLRGUI_HPP_ */
| 19,536
|
C++
|
.h
| 452
| 39.75
| 131
| 0.692845
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,396
|
definitions.h
|
sjaehn_BJumblr/src/definitions.h
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2018, 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef DEFINITIONS_H_
#define DEFINITIONS_H_
#define MAXPAGES 16
#define MAXSTEPS 32
#define WAVEFORMSIZE 1024
#define BJUMBLR_URI "https://www.jahnichen.de/plugins/lv2/BJumblr"
#define BJUMBLR_GUI_URI "https://www.jahnichen.de/plugins/lv2/BJumblr#gui"
#ifndef LIMIT
#define LIMIT(val, min, max) ((val) > (max) ? (max) : ((val) < (min) ? (min) : (val)))
#endif /* LIMIT */
#endif /* DEFINITIONS_H_ */
| 1,242
|
C++
|
.h
| 30
| 39.666667
| 86
| 0.744205
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,397
|
Sample.hpp
|
sjaehn_BJumblr/src/Sample.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2020 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef SAMPLE_HPP_
#define SAMPLE_HPP_
#include "sndfile.h"
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <stdexcept>
#ifndef SF_FORMAT_MP3
#ifndef MINIMP3_FLOAT_OUTPUT
#define MINIMP3_FLOAT_OUTPUT
#endif
#include "minimp3_ex.h"
#endif /* SF_FORMAT_MP3 */
struct Sample
{
SF_INFO info; // Info about sample from sndfile
float* data; // Sample data in float
char* path; // Path of file
bool loop; // Loop playing mode
sf_count_t start; // Start frame
sf_count_t end; // End frame
Sample () : info {0, 0, 0, 0, 0, 0}, data (nullptr), path (nullptr) {}
Sample (const char* samplepath) :
info {0, 0, 0, 0, 0, 0}, data (nullptr), path (nullptr),
loop (false), start (0), end (0)
{
if (!samplepath) return;
int len = strlen (samplepath);
path = (char*) malloc (len + 1);
if (!path) throw std::bad_alloc();
memcpy (path, samplepath, len + 1);
if (!len) return;
// Extract file name
char* name = strrchr (path, '/') + 1;
if (!name) name = path;
// Extract file extension
char ext[16] = {0};
char* extptr = strrchr (name, '.');
if (!extptr) extptr = path + strlen (path);
const int extsz = strlen (extptr) + 1;
if ((extsz > 1) && (extsz < 16)) memcpy (ext, extptr, extsz);
for (char* s = ext; *s; ++s) *s = tolower ((unsigned char)*s);
// Check for known non-sndfiles
#ifndef SF_FORMAT_MP3
if (!strcmp (ext, ".mp3"))
{
mp3dec_t mp3dec;
mp3dec_file_info_t mp3info;
if (mp3dec_load (&mp3dec, path, &mp3info, NULL, NULL)) throw std::invalid_argument ("Can't open " + std::string (name) + ".");
info.samplerate = mp3info.hz;
info.channels = mp3info.channels;
info.frames = mp3info.samples / mp3info.channels;
data = (float*) malloc (sizeof(float) * info.frames * info.channels);
if (!data) throw std::bad_alloc();
memcpy (data, mp3info.buffer, sizeof(float) * info.frames * info.channels);
}
else
#endif /* !SF_FORMAT_MP3 */
{
SNDFILE* sndfile = sf_open (samplepath, SFM_READ, &info);
//if (!sndfile) throw std::invalid_argument ("Can't open " + std::string (name) + ".");
if (sf_error (sndfile) != SF_ERR_NO_ERROR) throw std::invalid_argument (std::string (sf_strerror (sndfile)));
if (!info.frames) throw std::invalid_argument ("Empty sample file " + std::string (name) + ".");
// Read & render data
data = (float*) malloc (sizeof(float) * info.frames * info.channels);
if (!data)
{
sf_close (sndfile);
throw std::bad_alloc();
}
sf_seek (sndfile, 0, SEEK_SET);
sf_read_float (sndfile, data, info.frames * info.channels);
sf_close (sndfile);
}
end = info.frames;
}
Sample (const Sample& that) :
info (that.info), data (nullptr), path (nullptr),
loop (that.loop), start (that.start), end (that.end)
{
if (that.data)
{
data = (float*) malloc (sizeof(float) * info.frames * info.channels);
if (!data) throw std::bad_alloc();
memcpy (data, that.data, sizeof(float) * info.frames * info.channels);
}
if (that.path)
{
int len = strlen (that.path);
path = (char*) malloc (len + 1);
if (!path) throw std::bad_alloc();
memcpy (path, that.path, len + 1);
}
}
~Sample()
{
if (data) free (data);
if (path) free (path);
}
Sample& operator= (const Sample& that)
{
if (data) free (data);
if (path) free (path);
info = that.info;
data = nullptr;
path = nullptr;
loop = that.loop;
start = that.start;
end = that.end;
if (that.data)
{
data = (float*) malloc (sizeof(float) * info.frames * info.channels);
if (!data) throw std::bad_alloc();
memcpy (data, that.data, sizeof(float) * info.frames * info.channels);
}
if (that.path)
{
int len = strlen (that.path);
path = (char*) malloc (len + 1);
if (!path) throw std::bad_alloc();
memcpy (path, that.path, len + 1);
}
return *this;
}
float get (const sf_count_t frame, const int channel, const int rate)
{
if (!data) return 0.0f;
// Direct access if same frame rate
if (info.samplerate == rate)
{
if (frame >= info.frames) return 0.0f;
else return data[frame * info.channels + channel];
}
// Linear rendering if frame rates differ
const double f = (frame * info.samplerate) / rate;
const double frac = fmod (f, 1.0);
sf_count_t f1 = f;
if (f1 >= info.frames) return 0.0f;
if (frac == 0.0) return data[f1 * info.channels + channel];
float data1 = data[f1 * info.channels + channel];
float data2 = (f1 + 1 < info.frames ? data[(f1 + 1) * info.channels + channel] : data1);
return (1.0 - frac) * data1 + frac * data2;
}
};
#endif /* SAMPLE_HPP_ */
| 7,236
|
C++
|
.h
| 165
| 30.448485
| 150
| 0.490547
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,398
|
HaloButton.hpp
|
sjaehn_BJumblr/src/HaloButton.hpp
|
/* B.Jumblr
* Pattern-controlled audio stream / sample re-sequencer LV2 plugin
*
* Copyright (C) 2019 by Sven Jähnichen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef HALOBUTTON_HPP_
#define HALOBUTTON_HPP_
#include "BWidgets/ValueWidget.hpp"
#include "BWidgets/Focusable.hpp"
#include "BWidgets/Label.hpp"
class HaloButton : public BWidgets::ValueWidget, public BWidgets::Focusable
{
public:
HaloButton () : HaloButton (0, 0, 0, 0, "editwidget", "") {}
HaloButton (const double x, const double y, const double width, const double height, const std::string& name, const std::string& focusText) :
ValueWidget (x, y, width, height, name, 0.0),
Focusable (std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_IN_MS),
std::chrono::milliseconds (BWIDGETS_DEFAULT_FOCUS_OUT_MS)),
focusLabel_ (0, 0, 40, 20, name_ + BWIDGETS_DEFAULT_FOCUS_NAME, focusText)
{
focusLabel_.setStacking (BWidgets::STACKING_OVERSIZE);
focusLabel_.resize ();
focusLabel_.hide ();
add (focusLabel_);
}
HaloButton (const HaloButton& that) :
ValueWidget (that), Focusable (that),
focusLabel_ (that.focusLabel_)
{
focusLabel_.hide();
add (focusLabel_);
}
HaloButton& operator= (const HaloButton& that)
{
release (&focusLabel_);
focusLabel_ = that.focusLabel_;
focusLabel_.hide();
Widget::operator= (that);
Focusable::operator= (that);
add (focusLabel_);
return *this;
}
virtual BWidgets::Widget* clone () const override {return new HaloButton (*this);}
virtual void applyTheme (BStyles::Theme& theme) override {applyTheme (theme, name_);}
virtual void applyTheme (BStyles::Theme& theme, const std::string& name) override
{
Widget::applyTheme (theme, name);
focusLabel_.applyTheme (theme, name + BWIDGETS_DEFAULT_FOCUS_NAME);
focusLabel_.resize();
}
virtual void onButtonPressed (BEvents::PointerEvent* event) override
{
setValue (1.0);
Widget::cbfunction_[BEvents::EventType::BUTTON_PRESS_EVENT] (event);
}
virtual void onButtonReleased (BEvents::PointerEvent* event) override
{
setValue (0.0);
Widget::cbfunction_[BEvents::EventType::BUTTON_RELEASE_EVENT] (event);
}
virtual void onFocusIn (BEvents::FocusEvent* event) override
{
if (event && event->getWidget())
{
BUtilities::Point pos = event->getPosition();
focusLabel_.moveTo (pos.x - 0.5 * focusLabel_.getWidth(), pos.y - focusLabel_.getHeight());
focusLabel_.show();
}
Widget::onFocusIn (event);
}
virtual void onFocusOut (BEvents::FocusEvent* event) override
{
if (event && event->getWidget()) focusLabel_.hide();
Widget::onFocusOut (event);
}
protected:
BWidgets::Label focusLabel_;
void draw (const BUtilities::RectArea& area)
{
if ((!widgetSurface_) || (cairo_surface_status (widgetSurface_) != CAIRO_STATUS_SUCCESS)) return;
if ((getWidth () >= 1) && (getHeight () >= 1))
{
// Draw super class widget elements first
Widget::draw (area);
if (value == 1.0)
{
cairo_t* cr = cairo_create (widgetSurface_);
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
{
// Limit cairo-drawing area
cairo_rectangle (cr, area.getX (), area.getY (), area.getWidth (), area.getHeight ());
cairo_clip (cr);
double x0 = getXOffset ();
double y0 = getYOffset ();
double w = getEffectiveWidth ();
double h = getEffectiveHeight ();
cairo_rectangle (cr, x0, y0, w, h);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, CAIRO_RGBA (BColors::yellow));
cairo_stroke (cr);
cairo_destroy (cr);
}
}
}
}
};
#endif /* HALOBUTTON_HPP_ */
| 4,257
|
C++
|
.h
| 121
| 31.950413
| 142
| 0.704838
|
sjaehn/BJumblr
| 35
| 1
| 6
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,402
|
Svf.cpp
|
monome_softcut-lib/softcut-lib/src/Svf.cpp
|
//
// Created by ezra on 11/8/18.
//
#include <math.h>
#include "softcut/Svf.h"
const float Svf::MAX_NORM_FC = 0.4;
Svf::Svf() = default;
float Svf::getNextSample(float x) {
update(x);
return lp * lpMix + hp * hpMix + bp * bpMix + br * brMix;
}
void Svf::setSampleRate(float aSr) {
sr = aSr;
pi_sr = M_PI / sr;
minFc = 10.f;
maxFc = sr * MAX_NORM_FC;
calcWarp();
calcCoeffs();
}
void Svf::setFc(float aFc) {
fc = (aFc > maxFc) ? maxFc : aFc;
fc = (fc < minFc) ? minFc : fc;
calcWarp();
calcCoeffs();
}
void Svf::setRq(float aRq) {
rq = aRq;
calcCoeffs();
}
void Svf::setLpMix(float mix) {
lpMix = mix;
}
void Svf::setHpMix(float mix) {
hpMix = mix;
}
void Svf::setBpMix(float mix) {
bpMix = mix;
}
void Svf::setBrMix(float mix) {
brMix = mix;
}
void Svf::reset() {
clearState();
}
void Svf::calcWarp() {
// NB: wasn't actually able to beat `tan` for performance+accuracy sweet spot
// on raspi with aggressive optimizations
g = static_cast<float>(tan(fc * pi_sr));
}
void Svf::calcCoeffs() {
g1 = g / (1.f + g * (g + rq));
g2 = 2.f * (g + rq) * g1;
g3 = g * g1;
g4 = 2.f * g1;
}
void Svf::clearState() {
v0z = 0;
v1 = 0;
v2 = 0;
}
void Svf::update(float in) {
// update
v0 = in;
v1z = v1;
v2z = v2;
v3 = v0 + v0z - 2.f * v2z;
v1 += g1 * v3 - g2 * v1z;
v2 += g3 * v3 + g4 * v1z;
v0z = v0;
// output
lp = v2;
bp = v1;
hp = v0 - rq * v1 - v2;
br = v0 - rq * v1;
}
float Svf::getFc() {
return fc;
}
| 1,586
|
C++
|
.cpp
| 78
| 16.884615
| 81
| 0.556673
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,403
|
ReadWriteHead.cpp
|
monome_softcut-lib/softcut-lib/src/ReadWriteHead.cpp
|
//
// Created by ezra on 12/6/17.
//
#include <cassert>
#include <cmath>
#include <limits>
#include "softcut/Interpolate.h"
#include "softcut/Resampler.h"
#include "softcut/ReadWriteHead.h"
using namespace softcut;
using namespace std;
void ReadWriteHead::init(FadeCurves *fc) {
start = 0.f;
end = 0.f;
active = 0;
rate = 1.f;
setFadeTime(0.1f);
testBuf.init();
queuedCrossfade = 0;
queuedCrossfadeFlag = false;
head[0].init(fc);
head[1].init(fc);
setRecOnceFlag(false);
}
void ReadWriteHead::processSample(sample_t in, sample_t *out) {
*out = mixFade(head[0].peek(), head[1].peek(), head[0].fade(), head[1].fade());
// assert(!(head[0].state_ == Playing && head[1].state_ == Playing) /*multiple active heads*/);
if (recOnceFlag || recOnceDone || (recOnceHead > -1)) {
if (recOnceHead > -1) {
head[recOnceHead].poke(in, pre, rec);
}
} else {
head[0].poke(in, pre, rec);
head[1].poke(in, pre, rec);
}
takeAction(head[0].updatePhase(start, end, loopFlag));
takeAction(head[1].updatePhase(start, end, loopFlag));
head[0].updateFade(fadeInc);
head[1].updateFade(fadeInc);
dequeueCrossfade();
}
void ReadWriteHead::processSampleNoRead(sample_t in, sample_t *out) {
(void)out;
//BOOST_ASSERT_MSG(!(head[0].state_ == Playing && head[1].state_ == Playing), "multiple active heads");
assert(!(head[0].state_ == Playing && head[1].state_ == Playing));
if (recOnceFlag || recOnceDone || (recOnceHead > -1)) {
if (recOnceHead > -1) {
head[recOnceHead].poke(in, pre, rec);
}
} else {
head[0].poke(in, pre, rec);
head[1].poke(in, pre, rec);
}
takeAction(head[0].updatePhase(start, end, loopFlag));
takeAction(head[1].updatePhase(start, end, loopFlag));
head[0].updateFade(fadeInc);
head[1].updateFade(fadeInc);
dequeueCrossfade();
}
void ReadWriteHead::processSampleNoWrite(sample_t in, sample_t *out) {
(void)in;
*out = mixFade(head[0].peek(), head[1].peek(), head[0].fade(), head[1].fade());
// assert(!(head[0].state_ == Playing && head[1].state_ == Playing) /*multiple active heads*/);
takeAction(head[0].updatePhase(start, end, loopFlag));
takeAction(head[1].updatePhase(start, end, loopFlag));
head[0].updateFade(fadeInc);
head[1].updateFade(fadeInc);
dequeueCrossfade();
}
void ReadWriteHead::setRate(rate_t x)
{
rate = x;
calcFadeInc();
head[0].setRate(x);
head[1].setRate(x);
}
void ReadWriteHead::setLoopStartSeconds(float x)
{
start = x * sr;
queuedCrossfadeFlag = false;
}
void ReadWriteHead::setLoopEndSeconds(float x)
{
end = x * sr;
queuedCrossfadeFlag = false;
}
void ReadWriteHead::takeAction(Action act)
{
switch (act) {
case Action::LoopPos:
enqueueCrossfade(start);
break;
case Action::LoopNeg:
enqueueCrossfade(end);
break;
case Action::Stop:
break;
case Action::None:
default: ;;
}
}
void ReadWriteHead::enqueueCrossfade(phase_t pos) {
queuedCrossfade = pos;
queuedCrossfadeFlag = true;
}
void ReadWriteHead::dequeueCrossfade() {
State s = head[active].state();
if(! (s == State::FadeIn || s == State::FadeOut)) {
if(queuedCrossfadeFlag ) {
cutToPhase(queuedCrossfade);
}
queuedCrossfadeFlag = false;
}
}
void ReadWriteHead::cutToPhase(phase_t pos) {
State s = head[active].state();
if(s == State::FadeIn || s == State::FadeOut) {
// should never enter this condition
std::cerr << "badness! performed a cut while still fading" << std::endl;
return;
}
// activate the inactive head
int newActive = active ^ 1;
if(s != State::Stopped) {
head[active].setState(State::FadeOut);
}
if (recOnceHead==newActive) {
recOnceHead = -1;
recOnceDone = true;
}
if (recOnceFlag) {
recOnceFlag = false;
recOnceHead = newActive;
}
head[newActive].setState(State::FadeIn);
head[newActive].setPhase(pos);
head[active].active_ = false;
head[newActive].active_ = true;
active = newActive;
}
void ReadWriteHead::setFadeTime(float secs) {
fadeTime = secs;
calcFadeInc();
}
void ReadWriteHead::calcFadeInc() {
fadeInc = (float) fabs(rate) / std::max(1.f, (fadeTime * sr));
fadeInc = std::max(0.f, std::min(fadeInc, 1.f));
}
void ReadWriteHead::setBuffer(float *b, uint32_t bf) {
buf = b;
head[0].setBuffer(b, bf);
head[1].setBuffer(b, bf);
}
void ReadWriteHead::setLoopFlag(bool val) {
loopFlag = val;
}
void ReadWriteHead::setRecOnceFlag(bool val) {
recOnceFlag = val;
recOnceDone = false;
recOnceHead = -1;
}
bool ReadWriteHead::getRecOnceDone() {
return recOnceDone;
}
bool ReadWriteHead::getRecOnceActive() {
return (recOnceDone || recOnceFlag || recOnceHead>-1);
}
void ReadWriteHead::setSampleRate(float sr_) {
sr = sr_;
head[0].setSampleRate(sr);
head[1].setSampleRate(sr);
}
sample_t ReadWriteHead::mixFade(sample_t x, sample_t y, float a, float b) {
return x * sinf(a * (float)M_PI_2) + y * sinf(b * (float) M_PI_2);
}
void ReadWriteHead::setRec(float x) {
rec = x;
}
void ReadWriteHead::setPre(float x) {
pre = x;
}
phase_t ReadWriteHead::getActivePhase() {
return head[active].phase();
}
void ReadWriteHead::cutToPos(float seconds) {
auto s = head[active].state();
if (s == State::FadeIn || s == State::FadeOut) {
enqueueCrossfade(seconds * sr);
} else {
cutToPhase(seconds * sr);
}
}
rate_t ReadWriteHead::getRate() {
return rate;
}
void ReadWriteHead::setRecOffsetSamples(int d) {
head[0].setRecOffsetSamples(d);
head[1].setRecOffsetSamples(d);
}
void ReadWriteHead::stop() {
head[0].setState(State::Stopped);
head[1].setState(State::Stopped);
}
void ReadWriteHead::run() {
head[active].setState(State::Playing);
}
| 6,014
|
C++
|
.cpp
| 206
| 24.786408
| 107
| 0.647968
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,404
|
main.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/main.cpp
|
//
// Created by emb on 1/20/20.
//
#include <iostream>
#include <chrono>
#include <thread>
#include <memory>
#include "SoftcutClient.h"
#include "OscInterface.h"
#include "BufDiskWorker.h"
static inline void sleep(int ms) {
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
int main() {
using namespace softcut_jack_osc;
using std::cout;
using std::endl;
std::unique_ptr<SoftcutClient> sc;
sc = std::make_unique<SoftcutClient>();
sc->setup();
BufDiskWorker::init(static_cast<float>(sc->getSampleRate()));
sc->start();
sc->connectAdcPorts();
sc->connectDacPorts();
OscInterface::init(sc.get());
cout << "entering main loop..." << endl;
while(!OscInterface::shouldQuit()) {
sleep(100);
}
sc->stop();
sc->cleanup();
return 0;
}
| 827
|
C++
|
.cpp
| 33
| 21.393939
| 65
| 0.656489
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,405
|
OscInterface.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/OscInterface.cpp
|
//
// Created by ezra on 11/4/18.
//
#include <string>
#include <utility>
#include <thread>
//#include <boost/format.hpp>
#include "softcut/FadeCurves.h"
#include "BufDiskWorker.h"
#include "Commands.h"
#include "OscInterface.h"
using namespace softcut_jack_osc;
using softcut::FadeCurves;
bool OscInterface::quitFlag;
std::string OscInterface::port;
lo_server_thread OscInterface::st;
lo_address OscInterface::clientAddress;
std::array<OscInterface::OscMethod, OscInterface::MaxNumMethods> OscInterface::methods;
unsigned int OscInterface::numMethods = 0;
std::unique_ptr<Poll> OscInterface::vuPoll;
std::unique_ptr<Poll> OscInterface::phasePoll;
SoftcutClient *OscInterface::softCutClient;
OscInterface::OscMethod::OscMethod(string p, string f, OscInterface::Handler h)
: path(std::move(p)), format(std::move(f)), handler(h) {}
void OscInterface::init(SoftcutClient *sc) {
quitFlag = false;
// FIXME: should get port configs from program args or elsewhere
port = "9999";
#if 0
clientAddress = lo_address_new("127.0.0.1", "8888");
#else // testing with SC
clientAddress = lo_address_new("127.0.0.1", "57120");
#endif
std::cout << "OSC server listening on port " << port << std::endl;
st = lo_server_thread_new(port.c_str(), handleLoError);
addServerMethods();
softCutClient = sc;
//--- softcut phase poll
phasePoll = std::make_unique<Poll>("softcut/phase");
phasePoll->setCallback([](const char *path) {
for (int i = 0; i < softCutClient->getNumVoices(); ++i) {
if (softCutClient->checkVoiceQuantPhase(i)) {
lo_send(clientAddress, path, "if", i, softCutClient->getQuantPhase(i));
}
}
});
phasePoll->setPeriod(1);
//--- TODO: softcut trigger poll?
lo_server_thread_start(st);
}
void OscInterface::addServerMethod(const char *path, const char *format, Handler handler) {
OscMethod m(path, format, handler);
methods[numMethods] = m;
lo_server_thread_add_method(st, path, format,
[](const char *path,
const char *types,
lo_arg **argv,
int argc,
lo_message msg,
void *data)
-> int {
(void) path;
(void) types;
(void) msg;
auto pm = static_cast<OscMethod *>(data);
//std::cerr << "osc rx: " << path << std::endl;
pm->handler(argv, argc);
return 0;
}, &(methods[numMethods]));
numMethods++;
}
void OscInterface::addServerMethods() {
addServerMethod("/hello", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
std::cout << "hello" << std::endl;
});
addServerMethod("/goodbye", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
std::cout << "goodbye" << std::endl;
OscInterface::quitFlag = true;
});
addServerMethod("/quit", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
OscInterface::quitFlag = true;
});
//---------------------------
//--- mixer polls
addServerMethod("/poll/start/vu", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
vuPoll->start();
});
addServerMethod("/poll/stop/vu", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
vuPoll->stop();
});
//--------------------------------
//-- softcut routing
addServerMethod("/set/enabled/cut", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_ENABLED_CUT, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/level/cut", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_LEVEL_CUT, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/pan/cut", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_PAN_CUT, argv[0]->i, argv[1]->f);
});
//--- NB: these are handled by the softcut command queue,
// because their corresponding mix points are processed by the softcut client.
// input channel -> voice levels
addServerMethod("/set/level/in_cut", "iif", [](lo_arg **argv, int argc) {
if (argc < 3) { return; }
Commands::softcutCommands.post(Commands::Id::SET_LEVEL_IN_CUT, argv[0]->i, argv[1]->i, argv[2]->f);
});
// voice -> voice levels
addServerMethod("/set/level/cut_cut", "iif", [](lo_arg **argv, int argc) {
if (argc < 3) { return; }
Commands::softcutCommands.post(Commands::Id::SET_LEVEL_CUT_CUT, argv[0]->i, argv[1]->i, argv[2]->f);
});
//--------------------------------
//-- softcut params
addServerMethod("/set/param/cut/rate", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_RATE, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/loop_start", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_LOOP_START, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/loop_end", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_LOOP_END, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/loop_flag", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_LOOP_FLAG, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/fade_time", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_FADE_TIME, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/rec_level", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_REC_LEVEL, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_level", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_LEVEL, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/rec_flag", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_REC_FLAG, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/rec_once", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_REC_ONCE, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/play_flag", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PLAY_FLAG, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/rec_offset", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_REC_OFFSET, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/position", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POSITION, argv[0]->i, argv[1]->f);
});
// --- input filter
addServerMethod("/set/param/cut/pre_filter_fc", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_FC, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_fc_mod", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_FC_MOD, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_rq", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_RQ, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_lp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_LP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_hp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_HP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_bp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_BP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_br", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_BR, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pre_filter_dry", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PRE_FILTER_DRY, argv[0]->i, argv[1]->f);
});
// --- output filter
addServerMethod("/set/param/cut/post_filter_fc", "if", [
](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_FC, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_rq", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_RQ, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_lp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_LP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_hp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_HP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_bp", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_BP, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_br", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_BR, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/post_filter_dry", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_POST_FILTER_DRY, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/voice_sync", "iif", [](lo_arg **argv, int argc) {
if (argc < 3) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_VOICE_SYNC, argv[0]->i, argv[1]->i, argv[2]->f);
});
addServerMethod("/set/param/cut/level_slew_time", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_LEVEL_SLEW_TIME, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/pan_slew_time", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_PAN_SLEW_TIME, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/recpre_slew_time", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_RECPRE_SLEW_TIME, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/rate_slew_time", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_RATE_SLEW_TIME, argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/buffer", "ii", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
Commands::softcutCommands.post(Commands::Id::SET_CUT_BUFFER, argv[0]->i, argv[1]->i);
});
//-------------------------------
//--- softcut buffer manipulation
// FIXME: hrm, our system doesn't allow variable argument count. maybe need to make multiple methods
addServerMethod("/softcut/buffer/read_mono", "sfffii", [](lo_arg **argv, int argc) {
float startSrc = 0.f;
float startDst = 0.f;
float dur = -1.f;
int chanSrc = 0;
int chanDst = 0;
if (argc < 1) {
std::cerr << "/softcut/buffer/read_mono requires at least one argument (file path)" << std::endl;
return;
}
if (argc > 1) {
startSrc = argv[1]->f;
}
if (argc > 2) {
startDst = argv[2]->f;
}
if (argc > 3) {
dur = argv[3]->f;
}
if (argc > 4) {
chanSrc = argv[4]->i;
}
if (argc > 5) {
chanDst = argv[5]->i;
}
const char *str = &argv[0]->s;
softCutClient->readBufferMono(str, startSrc, startDst, dur, chanSrc, chanDst);
});
// FIXME: hrm, our system doesn't allow variable argument count. maybe need to make multiple methods
addServerMethod("/softcut/buffer/read_stereo", "sfff", [](lo_arg **argv, int argc) {
float startSrc = 0.f;
float startDst = 0.f;
float dur = -1.f;
if (argc < 1) {
std::cerr << "/softcut/buffer/read_stereo requires at least one argument (file path)" << std::endl;
return;
}
if (argc > 1) {
startSrc = argv[1]->f;
}
if (argc > 2) {
startDst = argv[2]->f;
}
if (argc > 3) {
dur = argv[3]->f;
}
const char *str = &argv[0]->s;
softCutClient->readBufferStereo(str, startSrc, startDst, dur);
});
// FIXME: hrm, our system doesn't allow variable argument count. maybe need to make multiple methods
addServerMethod("/softcut/buffer/write_mono", "sffi", [](lo_arg **argv, int argc) {
float start = 0.f;
float dur = -1.f;
int chan = 0;
if (argc < 1) {
std::cerr << "/softcut/buffer/write_mono requires at least one argument (file path)" << std::endl;
return;
}
if (argc > 1) {
start = argv[1]->f;
}
if (argc > 2) {
dur = argv[2]->f;
}
if (argc > 3) {
chan = argv[3]->i;
}
const char *str = &argv[0]->s;
softCutClient->writeBufferMono(str, start, dur, chan);
});
// FIXME: hrm, our system doesn't allow variable argument count. maybe need to make multiple methods
addServerMethod("/softcut/buffer/write_stereo", "sff", [](lo_arg **argv, int argc) {
float start = 0.f;
float dur = -1.f;
if (argc < 1) {
std::cerr << "/softcut/buffer/write_stereo requires at least one argument (file path)" << std::endl;
return;
}
if (argc > 1) {
start = argv[1]->f;
}
if (argc > 2) {
dur = argv[2]->f;
}
const char *str = &argv[0]->s;
softCutClient->writeBufferStereo(str, start, dur);
});
addServerMethod("/softcut/buffer/clear", "", [](lo_arg **argv, int argc) {
(void) argc;
(void) argv;
softCutClient->clearBuffer(0);
softCutClient->clearBuffer(1);
});
addServerMethod("/softcut/buffer/clear_channel", "i", [](lo_arg **argv, int argc) {
if (argc < 1) {
return;
}
softCutClient->clearBuffer(argv[0]->i);
});
addServerMethod("/softcut/buffer/clear_region", "ff", [](lo_arg **argv, int argc) {
if (argc < 2) {
return;
}
softCutClient->clearBuffer(0, argv[0]->f, argv[1]->f);
softCutClient->clearBuffer(1, argv[0]->f, argv[1]->f);
});
addServerMethod("/softcut/buffer/clear_region_channel", "iff", [](lo_arg **argv, int argc) {
if (argc < 3) {
return;
}
softCutClient->clearBuffer(argv[0]->i, argv[1]->f, argv[2]->f);
});
addServerMethod("/softcut/reset", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
softCutClient->clearBuffer(0, 0, -1);
softCutClient->clearBuffer(1, 0, -1);
softCutClient->reset();
for (int i = 0; i < SoftcutClient::NumVoices; ++i) {
phasePoll->stop();
}
});
//---------------------
//--- softcut polls
addServerMethod("/set/param/cut/phase_quant", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
softCutClient->setPhaseQuant(argv[0]->i, argv[1]->f);
});
addServerMethod("/set/param/cut/phase_offset", "if", [](lo_arg **argv, int argc) {
if (argc < 2) { return; }
softCutClient->setPhaseOffset(argv[0]->i, argv[1]->f);
});
addServerMethod("/poll/start/cut/phase", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
phasePoll->start();
});
addServerMethod("/poll/stop/cut/phase", "", [](lo_arg **argv, int argc) {
(void) argv;
(void) argc;
phasePoll->stop();
});
}
void OscInterface::printServerMethods() {
using std::cout;
using std::endl;
using std::string;
//using boost::format;
cout << "osc methods: " << endl;
for (unsigned int i = 0; i < numMethods; ++i) {
//cout << format(" %1% [%2%]") % methods[i].path % methods[i].format << endl;
cout << methods[i].path << "\t" << methods[i].format << endl;
}
}
void OscInterface::deinit() {
lo_address_free(clientAddress);
}
| 18,545
|
C++
|
.cpp
| 423
| 35.553191
| 112
| 0.556721
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,406
|
SoftcutClient.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/SoftcutClient.cpp
|
//
// Created by emb on 11/28/18.
//
#include <sndfile.hh>
#include "BufDiskWorker.h"
#include "Commands.h"
#include "SoftcutClient.h"
using namespace softcut_jack_osc;
// clamp unsigned int to upper bound, inclusive
static inline void clamp(size_t &x, const size_t a) {
if (x > a) { x = a; }
}
SoftcutClient::SoftcutClient() : JackClient<2, 2>("softcut") {
for (unsigned int i = 0; i < NumVoices; ++i) {
cut.setVoiceBuffer(i, buf[i & 1], BufFrames);
}
bufIdx[0] = BufDiskWorker::registerBuffer(buf[0], BufFrames);
bufIdx[1] = BufDiskWorker::registerBuffer(buf[1], BufFrames);
}
void SoftcutClient::process(jack_nframes_t numFrames) {
Commands::softcutCommands.handlePending(this);
clearBusses(numFrames);
mixInput(numFrames);
// process softcuts (overwrites output bus)
for (int v = 0; v < NumVoices; ++v) {
if (enabled[v]) {
cut.processBlock(v, input[v].buf[0], output[v].buf[0], static_cast<int>(numFrames));
}
}
mixOutput(numFrames);
mix.copyTo(sink[0], numFrames);
}
void SoftcutClient::setSampleRate(jack_nframes_t sr) {
sampleRate = sr;
cut.setSampleRate(sr);
}
void SoftcutClient::clearBusses(size_t numFrames) {
mix.clear(numFrames);
for (auto &b : input) { b.clear(numFrames); }
}
void SoftcutClient::mixInput(size_t numFrames) {
for (int dst = 0; dst < NumVoices; ++dst) {
if (cut.getRecFlag(dst)) {
for (int ch = 0; ch < 2; ++ch) {
input[dst].mixFrom(&source[SourceAdc][ch], numFrames, inLevel[ch][dst]);
}
for (int src = 0; src < NumVoices; ++src) {
if (cut.getPlayFlag(src)) {
input[dst].mixFrom(output[src], numFrames, fbLevel[src][dst]);
}
}
}
}
}
void SoftcutClient::mixOutput(size_t numFrames) {
for (int v = 0; v < NumVoices; ++v) {
if (cut.getPlayFlag(v)) {
mix.panMixEpFrom(output[v], numFrames, outLevel[v], outPan[v]);
}
}
}
void SoftcutClient::handleCommand(Commands::CommandPacket *p) {
switch (p->id) {
//-- softcut routing
case Commands::Id::SET_ENABLED_CUT:
enabled[p->idx_0] = p->value > 0.f;
break;
case Commands::Id::SET_LEVEL_CUT:
outLevel[p->idx_0].setTarget(p->value);
break;;
case Commands::Id::SET_PAN_CUT:
outPan[p->idx_0].setTarget((p->value/2)+0.5); // map -1,1 to 0,1
break;
case Commands::Id::SET_LEVEL_IN_CUT:
inLevel[p->idx_0][p->idx_1].setTarget(p->value);
break;
case Commands::Id::SET_LEVEL_CUT_CUT:
fbLevel[p->idx_0][p->idx_1].setTarget(p->value);
break;
//-- softcut commands
case Commands::Id::SET_CUT_RATE:
cut.setRate(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_LOOP_START:
cut.setLoopStart(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_LOOP_END:
cut.setLoopEnd(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_LOOP_FLAG:
cut.setLoopFlag(p->idx_0, p->value > 0.f);
break;
case Commands::Id::SET_CUT_FADE_TIME:
cut.setFadeTime(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_REC_LEVEL:
cut.setRecLevel(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_LEVEL:
cut.setPreLevel(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_REC_FLAG:
cut.setRecFlag(p->idx_0, p->value > 0.f);
break;
case Commands::Id::SET_CUT_PLAY_FLAG:
cut.setPlayFlag(p->idx_0, p->value > 0.f);
break;
case Commands::Id::SET_CUT_REC_OFFSET:
cut.setRecOffset(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POSITION:
cut.cutToPos(p->idx_0, p->value);
break;
// input filter
case Commands::Id::SET_CUT_PRE_FILTER_FC:
cut.setPreFilterFc(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_FC_MOD:
cut.setPreFilterFcMod(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_RQ:
cut.setPreFilterRq(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_LP:
cut.setPreFilterLp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_HP:
cut.setPreFilterHp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_BP:
cut.setPreFilterBp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_BR:
cut.setPreFilterBr(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_PRE_FILTER_DRY:
cut.setPreFilterDry(p->idx_0, p->value);
break;
// output filter
case Commands::Id::SET_CUT_POST_FILTER_FC:
cut.setPostFilterFc(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_RQ:
cut.setPostFilterRq(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_LP:
cut.setPostFilterLp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_HP:
cut.setPostFilterHp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_BP:
cut.setPostFilterBp(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_BR:
cut.setPostFilterBr(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_POST_FILTER_DRY:
cut.setPostFilterDry(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_LEVEL_SLEW_TIME:
outLevel[p->idx_0].setTime(p->value);
break;
case Commands::Id::SET_CUT_PAN_SLEW_TIME:
outPan[p->idx_0].setTime(p->value);
break;
case Commands::Id::SET_CUT_RECPRE_SLEW_TIME:
cut.setRecPreSlewTime(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_RATE_SLEW_TIME:
cut.setRateSlewTime(p->idx_0, p->value);
break;
case Commands::Id::SET_CUT_VOICE_SYNC:
cut.syncVoice(p->idx_0, p->idx_1, p->value);
break;
case Commands::Id::SET_CUT_BUFFER:
cut.setVoiceBuffer(p->idx_0, buf[p->idx_1], BufFrames);
break;
default:;;
}
}
void SoftcutClient::reset() {
for (int v = 0; v < NumVoices; ++v) {
cut.setVoiceBuffer(v, buf[v%2], BufFrames);
outLevel[v].setTarget(0.f);
outLevel->setTime(0.001);
outPan[v].setTarget(0.5f);
outPan->setTime(0.001);
enabled[v] = false;
setPhaseQuant(v, 1.f);
setPhaseOffset(v, 0.f);
for (int i=0; i<2; ++i) {
inLevel[i][v].setTime(0.001);
inLevel[i][v].setTarget(0.0);
}
for (int w=0; w<NumVoices; ++w) {
fbLevel[v][w].setTime(0.001);
fbLevel[v][w].setTarget(0.0);
}
cut.setLoopStart(v, v*2);
cut.setLoopEnd(v, v*2 + 1);
output[v].clear();
input[v].clear();
}
cut.reset();
}
| 7,499
|
C++
|
.cpp
| 206
| 26.980583
| 96
| 0.551994
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,407
|
BufDiskWorker.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/BufDiskWorker.cpp
|
//
// Created by emb on 11/30/19.
//
//-----------------------
//-- debugging
#include <iostream>
#include <iomanip>
#include <chrono>
//--------------
#include <sndfile.hh>
#include <utility>
#include "BufDiskWorker.h"
using namespace softcut_jack_osc;
std::unique_ptr<std::thread> BufDiskWorker::worker = nullptr;
std::queue<BufDiskWorker::Job> BufDiskWorker::jobQ;
std::mutex BufDiskWorker::qMut;
std::array<BufDiskWorker::BufDesc, BufDiskWorker::maxBufs> BufDiskWorker::bufs;
int BufDiskWorker::numBufs = 0;
bool BufDiskWorker::shouldQuit = false;
int BufDiskWorker::sampleRate = 48000;
// clamp unsigned int to upper bound, inclusive
static inline void clamp(size_t &x, const size_t a) {
if (x > a) { x = a; }
}
int BufDiskWorker::registerBuffer(float *data, size_t frames) {
int n = numBufs++;
bufs[n].data = data;
bufs[n].frames = frames;
return n;
}
void BufDiskWorker::requestJob(BufDiskWorker::Job &job) {
qMut.lock();
jobQ.push(job);
qMut.unlock();
// FIXME: use condvar to signal worker
}
void BufDiskWorker::requestClear(size_t idx, float start, float dur) {
BufDiskWorker::Job job{BufDiskWorker::JobType::Clear, {idx, 0}, "", 0, start, dur, 0};
requestJob(job);
}
void
BufDiskWorker::requestReadMono(size_t idx, std::string path, float startSrc, float startDst, float dur, int chanSrc) {
BufDiskWorker::Job job{BufDiskWorker::JobType::ReadMono, {idx, 0}, std::move(path), startSrc, startDst, dur,
chanSrc};
requestJob(job);
}
void BufDiskWorker::requestReadStereo(size_t idx0, size_t idx1, std::string path,
float startSrc, float startDst, float dur) {
BufDiskWorker::Job job{BufDiskWorker::JobType::ReadStereo, {idx0, idx1}, std::move(path), startSrc, startDst, dur,
0};
requestJob(job);
}
void BufDiskWorker::requestWriteMono(size_t idx, std::string path, float start, float dur) {
BufDiskWorker::Job job{BufDiskWorker::JobType::WriteMono, {idx, 0}, std::move(path), start, start, dur, 0};
requestJob(job);
}
void BufDiskWorker::requestWriteStereo(size_t idx0, size_t idx1, std::string path,
float start, float dur) {
BufDiskWorker::Job job{BufDiskWorker::JobType::WriteStereo, {idx0, idx1}, std::move(path), start, start, dur, 0};
requestJob(job);
}
void BufDiskWorker::workLoop() {
while (!shouldQuit) {
// FIXME: use condvar to wait here instead of sleeping...
qMut.lock();
if (!jobQ.empty()) {
Job job = jobQ.front();
jobQ.pop();
qMut.unlock();
switch (job.type) {
case JobType::Clear:
clearBuffer(bufs[job.bufIdx[0]], job.startDst, job.dur);
break;
case JobType::ReadMono:
readBufferMono(job.path, bufs[job.bufIdx[0]], job.startSrc, job.startDst, job.dur, job.chan);
break;
case JobType::ReadStereo:
readBufferStereo(job.path, bufs[job.bufIdx[0]], bufs[job.bufIdx[1]], job.startSrc, job.startDst,
job.dur);
break;
case JobType::WriteMono:
writeBufferMono(job.path, bufs[job.bufIdx[0]], job.startSrc, job.dur);
break;
case JobType::WriteStereo:
writeBufferStereo(job.path, bufs[job.bufIdx[0]], bufs[job.bufIdx[1]], job.startSrc, job.dur);
break;
}
#if 0 // debug, timing
auto ms_now = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
auto ms_dur = ms_now - ms_start;
std::cout << "job finished; elapsed time = " << ms_dur << " ms" << std::endl;
#endif
} else {
qMut.unlock();
std::this_thread::sleep_for(std::chrono::milliseconds(sleepPeriodMs));
}
}
}
void BufDiskWorker::init(int sr) {
sampleRate = sr;
if (worker == nullptr) {
worker = std::make_unique<std::thread>(std::thread(BufDiskWorker::workLoop));
worker->detach();
}
}
int BufDiskWorker::secToFrame(float seconds) {
return static_cast<int>(seconds * (float) sampleRate);
}
//------------------------
//---- private buffer routines
void BufDiskWorker::clearBuffer(BufDesc &buf, float start, float dur) {
size_t frA = secToFrame(start);
clamp(frA, buf.frames - 1);
size_t frB;
if (dur < 0) {
frB = buf.frames;
} else {
frB = frA + secToFrame(dur);
}
clamp(frB, buf.frames);
for (size_t i = frA; i < frB; ++i) {
buf.data[i] = 0.f;
}
}
void BufDiskWorker::readBufferMono(const std::string &path, BufDesc &buf,
float startSrc, float startDst, float dur, int chanSrc)
noexcept {
SndfileHandle file(path);
if (file.frames() < 1) {
std::cerr << "readBufferMono(): empty / missing file: " << path << std::endl;
return;
}
size_t bufFrames = buf.frames;
size_t frSrc = secToFrame(startSrc);
clamp(frSrc, bufFrames - 1);
size_t frDst = secToFrame(startDst);
clamp(frDst, bufFrames - 1);
size_t frDur;
if (dur < 0.f) {
auto maxDurSrc = file.frames() - frSrc;
auto maxDurDst = bufFrames - frDst;
frDur = maxDurSrc > maxDurDst ? maxDurDst : maxDurSrc;
} else {
frDur = secToFrame(dur);
}
auto numSrcChan = file.channels();
chanSrc = std::min(numSrcChan - 1, std::max(0, chanSrc));
std::cout << "reading soundfile channel " << chanSrc << std::endl;
auto *ioBuf = new float[numSrcChan * ioBufFrames];
size_t numBlocks = frDur / ioBufFrames;
size_t rem = frDur - (numBlocks * ioBufFrames);
std::cout << "file contains " << file.frames() << " frames" << std::endl;
std::cout << "reading " << numBlocks << " blocks and " << rem << " remainder frames..." << std::endl;
for (size_t block = 0; block < numBlocks; ++block) {
int res = file.seek(frSrc, SF_SEEK_SET);
if (res == -1) {
std::cerr << "error seeking to frame: " << frSrc << "; aborting read" << std::endl;
goto cleanup;
}
file.readf(ioBuf, ioBufFrames);
for (int fr=0; fr<ioBufFrames; ++fr) {
buf.data[frDst] = ioBuf[fr * numSrcChan + chanSrc];
frDst++;
}
frSrc += ioBufFrames;
}
for (size_t i=0; i<rem; ++i) {
int res = file.seek(frSrc, SF_SEEK_SET);
if (res == -1) {
std::cerr << "error seeking to frame: " << frSrc << "; aborting read" << std::endl;
goto cleanup;
}
file.read(ioBuf, numSrcChan);
buf.data[frDst] = ioBuf[chanSrc];
frDst++;
frSrc++;
}
std::cout << "SoftCutClient::readBufferMono(): done; read " << frDur << " frames" << std::endl;
cleanup:
delete[] ioBuf;
}
void BufDiskWorker::readBufferStereo(const std::string &path, BufDesc &buf0, BufDesc &buf1,
float startTimeSrc, float startTimeDst, float dur)
noexcept {
SndfileHandle file(path);
if (file.frames() < 1) {
std::cerr << "SoftCutClient::readBufferStereo(): empty / missing file: " << path << std::endl;
return;
}
size_t bufFrames = buf0.frames < buf1.frames ? buf0.frames : buf1.frames;
size_t frSrc = secToFrame(startTimeSrc);
clamp(frSrc, bufFrames - 1);
size_t frDst = secToFrame(startTimeDst);
clamp(frDst, bufFrames - 1);
size_t frDur;
if (dur < 0.f) {
auto maxDurSrc = file.frames() - frSrc;
auto maxDurDst = bufFrames - frDst;
frDur = maxDurSrc > maxDurDst ? maxDurDst : maxDurSrc;
} else {
frDur = secToFrame(dur);
}
auto numSrcChan = file.channels();
if (numSrcChan < 2) {
std::cerr << "SoftCutClient::readBufferStereo(): not enough channels in source; aborting" << std::endl;
return;
}
auto *ioBuf = new float[numSrcChan * ioBufFrames];
size_t numBlocks = frDur / ioBufFrames;
size_t rem = frDur - (numBlocks * ioBufFrames);
std::cout << "file contains " << file.frames() << " frames" << std::endl;
std::cout << "reading " << numBlocks << " blocks and " << rem << " remainder frames..." << std::endl;
for (size_t block = 0; block < numBlocks; ++block) {
int res = file.seek(frSrc, SF_SEEK_SET);
if (res == -1) {
std::cerr << "error seeking to frame: " << frSrc << "; aborting read" << std::endl;
return;
}
file.readf(ioBuf, ioBufFrames);
// FIXME? SEEK_CUR gives weird results, i must be using it wrong
//int res = file.seek(ioBufFrames, SF_SEEK_CUR);
for (int fr=0; fr<ioBufFrames; ++fr) {
buf0.data[frDst] = ioBuf[fr * numSrcChan];
buf1.data[frDst] = ioBuf[fr * numSrcChan + 1];
frDst++;
}
frSrc += ioBufFrames;
}
for (size_t i=0; i<rem; ++i) {
int res = file.seek(frSrc, SF_SEEK_CUR);
if (res == -1) {
std::cerr << "error seeking to frame: " << frSrc << "; aborting read" << std::endl;
return;
}
file.read(ioBuf, numSrcChan);
buf0.data[frDst] = ioBuf[0];
buf1.data[frDst] = ioBuf[1];
frDst++;
frSrc++;
}
// std::cout << "SoftCutClient::readBufferStereo(): done; read " << frDur << " frames" << std::endl;
delete[] ioBuf;
}
void BufDiskWorker::writeBufferMono(const std::string &path, BufDesc &buf, float start, float dur) noexcept {
const int sr = 48000;
const int channels = 1;
const int format = SF_FORMAT_WAV | SF_FORMAT_PCM_24;
SndfileHandle file(path, SFM_WRITE, format, channels, sr);
if (not file) {
std::cerr << "BufDiskWorker::writeBufferMono(): cannot open sndfile" << path << " for writing" << std::endl;
return;
}
file.command(SFC_SET_CLIPPING, NULL, SF_TRUE);
// std::cout << "BufDiskWorker::writeBufferMono(): opened file for writing: " << path << std::endl;
size_t frSrc = secToFrame(start);
size_t bufFrames = buf.frames;
clamp(frSrc, bufFrames - 1);
size_t frDur;
if (dur < 0.f) {
// FIXME: should check available disk space
frDur = bufFrames - frSrc;
} else {
frDur = secToFrame(dur);
}
size_t numBlocks = frDur / ioBufFrames;
size_t rem = frDur - (numBlocks * ioBufFrames);
size_t nf = 0;
// std::cout << "writing " << numBlocks << " blocks and " << rem << " remainder frames..." << std::endl;
float *pbuf = buf.data + frSrc;
for (size_t block = 0; block < numBlocks; ++block) {
size_t n = file.writef(pbuf, ioBufFrames);
pbuf += ioBufFrames;
nf += n;
if (n != ioBufFrames) {
std::cerr << "BufDiskWorker::writeBufferMono(): write aborted (disk space?) after " << nf << " frames"
<< std::endl;
return;
}
}
for (size_t i=0; i<rem; ++i) {
if (file.writef(pbuf++, 1) != 1) {
std::cerr << "BufDiskWorker::writeBufferMono(): write aborted (disk space?) after " << nf << " frames"
<< std::endl;
return;
}
++nf;
}
// std::cout << std::dec << "BufDiskWorker::writeBufferMono(): done; wrote " << nf << " frames" << std::endl;
}
void BufDiskWorker::writeBufferStereo(const std::string &path, BufDesc &buf0, BufDesc &buf1, float start, float dur)
noexcept {
const int sr = 48000;
const int channels = 2;
const int format = SF_FORMAT_WAV | SF_FORMAT_PCM_24;
SndfileHandle file(path, SFM_WRITE, format, channels, sr);
if (not file) {
std::cerr << "ERROR: cannot open sndfile" << path << " for writing" << std::endl;
return;
}
file.command(SFC_SET_CLIPPING, NULL, SF_TRUE);
// std::cout << "BufDiskWorker::writeBufferStereo(): opened file for writing: " << path << std::endl;
size_t frSrc = secToFrame(start);
size_t bufFrames = buf0.frames < buf1.frames ? buf0.frames : buf1.frames;
clamp(frSrc, bufFrames - 1);
size_t frDur;
if (dur < 0.f) {
// FIXME: should check available disk space
frDur = bufFrames - frSrc;
} else {
frDur = secToFrame(dur);
}
size_t numBlocks = frDur / ioBufFrames;
size_t rem = frDur - (numBlocks * ioBufFrames);
size_t nf = 0;
// std::cout << "writing " << numBlocks << " blocks and " << rem << " remainder frames..." << std::endl;
float ioBuf[ioBufFrames*2];
float *pbuf0 = buf0.data;
float *pbuf1 = buf1.data;
for (size_t block = 0; block < numBlocks; ++block) {
float *pio = ioBuf;
for (size_t fr=0; fr<ioBufFrames; ++fr) {
*pio++ = *pbuf0++;
*pio++ = *pbuf1++;
}
size_t n = file.writef(ioBuf, ioBufFrames);
nf += n;
if (n != ioBufFrames) {
std::cerr << "BufDiskWorker::writeBufferStereo(): write aborted (disk space?) after " << nf << " frames"
<< std::endl;
return;
}
frSrc += ioBufFrames;
}
for (size_t i=0; i<rem; ++i) {
ioBuf[0] = *(buf0.data + frSrc);
ioBuf[1] = *(buf1.data + frSrc);
if (file.writef(ioBuf, 1) != 1) {
std::cerr << "BufDiskWorker::writeBufferStereo(): write aborted (disk space?) after " << nf << " frames"
<< std::endl;
return;
}
++frSrc;
++nf;
}
// std::cout << std::dec << "BufDiskWorker::writeBufferStereo(): done; wrote " << nf << " frames" << std::endl;
}
| 13,448
|
C++
|
.cpp
| 346
| 32.095376
| 118
| 0.594599
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,408
|
Window.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/Window.cpp
|
//
// Created by emb on 1/25/19.
//
#include "Window.h"
using namespace softcut_jack_osc;
const float Window::raisedCosShort[Window::raisedCosShortLen] = {
#include "cos_win.inc"
};
| 184
|
C++
|
.cpp
| 8
| 21.75
| 65
| 0.747126
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,409
|
Commands.cpp
|
monome_softcut-lib/clients/softcut_jack_osc/src/Commands.cpp
|
//
// Created by ezra on 11/3/18.
//
#include <iostream>
#include "Commands.h"
#include "SoftcutClient.h"
using namespace softcut_jack_osc;
Commands Commands::softcutCommands;
Commands::Commands() = default;
void Commands::post(Commands::Id id, float f) {
CommandPacket p(id, -1, f);
q.enqueue(p);
}
void Commands::post(Commands::Id id, int i, float f) {
CommandPacket p(id, i, f);
q.enqueue(p);
}
void Commands::post(Commands::Id id, int i, int j) {
CommandPacket p(id, i, j);
q.enqueue(p);
}
void Commands::post(Commands::Id id, int i, int j, float f) {
CommandPacket p(id, i, j, f);
q.enqueue(p);
}
void Commands::handlePending(SoftcutClient *client) {
CommandPacket p;
while (q.try_dequeue(p)) {
client->handleCommand(&p);
}
}
| 794
|
C++
|
.cpp
| 31
| 22.580645
| 61
| 0.675532
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,410
|
Svf.h
|
monome_softcut-lib/softcut-lib/include/softcut/Svf.h
|
//
// Created by ezra on 11/8/18.
//
// state variable filter
// after Hal Chamberlin, Andy Simper
#ifndef Softcut_SVF_H
#define Softcut_SVF_H
#include <memory>
class Svf {
public:
Svf();
float getNextSample(float x);
void setSampleRate(float sr);
void setFc(float fc);
void setRq(float rq);
void setLpMix(float mix);
void setHpMix(float mix);
void setBpMix(float mix);
void setBrMix(float mix);
void reset();
void update(float x);
void calcWarp();
void calcCoeffs();
void clearState();
float getFc();
private:
static const float MAX_NORM_FC;
float lpMix;
float hpMix;
float bpMix;
float brMix;
float minFc;
float maxFc;
float pi_sr;
// sample rate
float sr;
// corner frequency in hz
float fc;
// reciprocal of Q in [0,1]
float rq;
// intermediate coefficients
float g;
float g1;
float g2;
float g3;
float g4;
// state variables
float v0;
float v1;
float v2;
float v0z;
float v1z;
float v2z;
float v3;
// outputs
float lp; // lowpass
float hp; // highpass
float bp; // bandpass
float br; // bandreject
};
#endif //Softcut_SVF_H
| 1,234
|
C++
|
.h
| 61
| 15.868852
| 36
| 0.639655
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,415
|
ReadWriteHead.h
|
monome_softcut-lib/softcut-lib/include/softcut/ReadWriteHead.h
|
//
// Created by ezra on 12/6/17.
//
#ifndef CUTFADEVOICE_CUTFADEVOICELOGIC_H
#define CUTFADEVOICE_CUTFADEVOICELOGIC_H
#include <cstdint>
#include "SubHead.h"
#include "Types.h"
#include "TestBuffers.h"
#include "FadeCurves.h"
namespace softcut {
class ReadWriteHead {
public:
void init(FadeCurves *fc);
// per-sample update functions
void processSample(sample_t in, sample_t *out);
void processSampleNoRead(sample_t in, sample_t *out);
void processSampleNoWrite(sample_t in, sample_t *out);
void setSampleRate(float sr);
void setBuffer(sample_t *buf, uint32_t size);
void setRate(rate_t x);
// set loop (region) start point in seconds
void setLoopStartSeconds(float x);
// set loop (region) end point in seconds
void setLoopEndSeconds(float x);
void setFadeTime(float secs);
void setLoopFlag(bool val);
void setRecOnceFlag(bool val);
bool getRecOnceDone();
bool getRecOnceActive();
// set amplitudes
void setRec(float x);
void setPre(float x);
// enqueue a position change with crossfade
void cutToPos(float seconds);
// immediately put both subheads in stopped state
void stop();
// immediately start playing from current position (no fadein)
void run();
void setRecOffsetSamples(int d);
phase_t getActivePhase();
rate_t getRate();
protected:
friend class SubHead;
private:
// fade in to new position (given in samples)
// assumption: phase is in range!
void cutToPhase(phase_t newPhase);
void enqueueCrossfade(phase_t newPhase);
void dequeueCrossfade();
void takeAction(Action act);
sample_t mixFade(sample_t x, sample_t y, float a, float b); // mix two inputs with phases
void calcFadeInc();
private:
SubHead head[2];
sample_t *buf; // audio buffer (allocated elsewhere)
float sr; // sample rate
phase_t start; // start/end points
phase_t end;
phase_t queuedCrossfade;
bool queuedCrossfadeFlag;
float fadeTime; // fade time in seconds
float fadeInc; // linear fade increment per sample
int active; // current active play head index (0 or 1)
bool loopFlag; // set to loop, unset for 1-shot
float pre; // pre-record level
float rec; // record level
bool recOnceFlag; // set to record one full loop
bool recOnceDone; // triggers done to tell voice to unset rec flag
int recOnceHead; // keeps track of which subhead is writing
rate_t rate; // current rate
TestBuffers testBuf;
};
}
#endif //CUTFADEVOICE_CUTFADEVOICELOGIC_H
| 2,816
|
C++
|
.h
| 75
| 30.733333
| 97
| 0.649394
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,417
|
FadeCurves.h
|
monome_softcut-lib/softcut-lib/include/softcut/FadeCurves.h
|
//
// Created by ezra on 11/15/18.
//
// static class for producing curves in fade period
//
// FIXME: this should be an object owned by SoftcutHead, passed to child SubHeads
#ifndef Softcut_FADECURVES_H
#define Softcut_FADECURVES_H
namespace softcut {
class FadeCurves {
public:
typedef enum { Linear=0, Sine=1, Raised=2 } Shape;
// initialize with defaults
void init();
void setRecDelayRatio(float x);
void setPreWindowRatio(float x);
void setMinRecDelayFrames(unsigned int x);
void setMinPreWindowFrames(unsigned int x);
// set curve shape
void setPreShape(Shape x);
void setRecShape(Shape x);
// x is assumed to be in [0,1]
float getRecFadeValue(float x);
float getPreFadeValue(float x);
private:
void calcPreFade();
void calcRecFade();
private:
// xfade curve buffers
static constexpr unsigned int fadeBufSize = 1001;
// record delay and pre window in fade, as proportion of fade time
float recDelayRatio;
float preWindowRatio;
// minimum record delay/pre window, in frames
unsigned int recDelayMinFrames;
unsigned int preWindowMinFrames;
float recFadeBuf[fadeBufSize];
float preFadeBuf[fadeBufSize];
Shape recShape;
Shape preShape;
};
}
#endif //Softcut_FADECURVES_H
| 1,438
|
C++
|
.h
| 43
| 26.27907
| 81
| 0.657514
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,421
|
SubHead.h
|
monome_softcut-lib/softcut-lib/include/softcut/SubHead.h
|
//
// Created by ezra on 4/21/18.
//
/*
* this class implements one half of a crossfaded read/write sch.
*/
#ifndef Softcut_SUBHEAD_H
#define Softcut_SUBHEAD_H
#include "Resampler.h"
#include "SoftClip.h"
#include "Types.h"
#include "FadeCurves.h"
namespace softcut {
typedef enum { Playing=0, Stopped=1, FadeIn=2, FadeOut=3 } State;
typedef enum { None, Stop, LoopPos, LoopNeg } Action ;
class SubHead {
friend class ReadWriteHead;
public:
void init(FadeCurves *fc);
void setSampleRate(float sr);
private:
sample_t peek4();
unsigned int wrapBufIndex(int x);
protected:
static constexpr int blockSize = 2048;
sample_t peek();
//! poke
//! @param in: input value
//! @param pre: scaling level for previous buffer content
//! @param rec: scaling level for new content
void poke(sample_t in, float pre, float rec);
Action updatePhase(phase_t start, phase_t end, bool loop);
void updateFade(float inc);
// getters
phase_t phase() { return phase_; }
float fade() { return fade_; }
float trig() { return trig_; }
State state() { return state_; }
// setters
void setState(State state);
void setPhase(phase_t phase);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// **NB** buffer size must be a power of two!!!!
void setBuffer(sample_t *buf, unsigned int frames);
void setRate(rate_t rate);
FadeCurves *fadeCurves;
private:
Resampler resamp_;
SoftClip clip_;
sample_t* buf_; // output buffer
unsigned int wrIdx_; // write index
unsigned int bufFrames_;
unsigned int bufMask_;
State state_;
rate_t rate_;
int inc_dir_;
phase_t phase_;
float fade_;
float trig_; // output trigger value
bool active_;
int recOffset_;
float preFade_;
float recFade_;
void setRecOffsetSamples(int d);
};
}
#endif //Softcut_SUBHEAD_H
| 2,120
|
C++
|
.h
| 67
| 24.462687
| 69
| 0.591111
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,422
|
OscInterface.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/OscInterface.h
|
#include <utility>
//
// Created by ezra on 11/4/18.
//
#ifndef CRONE_OSCINTERFACE_H
#define CRONE_OSCINTERFACE_H
#include <iostream>
#include <string>
#include <vector>
#include <lo/lo.h>
#include <array>
#include "SoftcutClient.h"
#include "Poll.h"
// FIXME: didn't realize that liblo has a perfectly ok-looking cpp interface already. this could be cleaner.
// having a custom method wrapper is probably fine, easier to refactor if we move to different IPC.
namespace softcut_jack_osc {
using std::string;
class OscInterface {
private:
static lo_server_thread st;
static lo_address clientAddress;
static bool quitFlag;
static string port;
static unsigned int numMethods;
enum { MaxNumMethods = 256 };
// OscMethod: thin wrapper for passing lambdas to OSC server thread
class OscMethod {
typedef void(*Handler)(lo_arg **argv, int argc);
public:
string path;
string format;
OscMethod() = default;
OscMethod(string p, string f, Handler h);
Handler handler{};
};
static std::array<OscMethod, MaxNumMethods> methods;
static std::unique_ptr<Poll> vuPoll;
static std::unique_ptr<Poll> phasePoll;
static SoftcutClient *softCutClient;
private:
typedef void(*Handler)(lo_arg **argv, int argc);
static void handleLoError(int num, const char *m, const char *path) {
std::cerr << "liblo error: " << num << "; " << m << "; " << path << std::endl;
}
static void addServerMethod(const char* path, const char* format, Handler handler);
static void addServerMethods();
public:
static void init(SoftcutClient *sc);
static void deinit();
static void printServerMethods();
static bool shouldQuit() { return quitFlag; }
static std::string getPortNumber() { return port; }
};
}
#endif //CRONE_OSCINTERFACE_H
| 2,006
|
C++
|
.h
| 55
| 29.672727
| 108
| 0.648033
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,423
|
Window.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/Window.h
|
//
// Created by emb on 1/25/19.
//
#ifndef CRONE_WINDOW_H
#define CRONE_WINDOW_H
#include <cstddef>
namespace softcut_jack_osc {
class Window {
public:
// raised-cosine window
static constexpr size_t raisedCosShortLen = 48 * 50;
static const float raisedCosShort[raisedCosShortLen];
};
}
#endif //CRONE_WINDOW_H
| 353
|
C++
|
.h
| 15
| 19.933333
| 61
| 0.700906
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,424
|
SoftcutClient.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/SoftcutClient.h
|
//
// Created by emb on 11/28/18.
//
#ifndef CRONE_CUTCLIENT_H
#define CRONE_CUTCLIENT_H
#include <iostream>
#include "BufDiskWorker.h"
#include "Bus.h"
#include "JackClient.h"
#include "Utilities.h"
#include "softcut/Softcut.h"
#include "softcut/Types.h"
namespace softcut_jack_osc {
class SoftcutClient: public JackClient<2, 2> {
public:
enum { MaxBlockFrames = 2048};
enum { BufFrames = 16777216 };
enum { NumVoices = 6 };
typedef enum { SourceAdc=0 } SourceId;
typedef Bus<2, MaxBlockFrames> StereoBus;
typedef Bus<1, MaxBlockFrames> MonoBus;
public:
SoftcutClient();
private:
// processors
softcut::Softcut<NumVoices> cut;
// main buffer
float buf[2][BufFrames];
// buffer index for use with BufDiskWorker
int bufIdx[2];
// busses
StereoBus mix;
MonoBus input[NumVoices];
MonoBus output[NumVoices];
// levels
LogRamp inLevel[2][NumVoices];
LogRamp outLevel[NumVoices];
LogRamp outPan[NumVoices];
LogRamp fbLevel[NumVoices][NumVoices];
// enabled flags
bool enabled[NumVoices];
softcut::phase_t quantPhase[NumVoices];
float sampleRate;
private:
void process(jack_nframes_t numFrames) override;
void setSampleRate(jack_nframes_t) override;
inline size_t secToFrame(float sec) {
return static_cast<size_t >(sec * jack_get_sample_rate(JackClient::client));
}
public:
/// FIXME: the "commands" structure shouldn't really be necessary.
/// should be able to refactor most/all parameters for atomic access.
// called from audio thread
void handleCommand(Commands::CommandPacket *p) override;
// these accessors can be called from other threads, so don't need to go through the commands queue
//-- buffer manipulation
//-- time parameters are in seconds
//-- negative 'dur' parameter reads/clears/writes as much as possible.
void readBufferMono(const std::string &path, float startTimeSrc = 0.f, float startTimeDst = 0.f,
float dur = -1.f, int chanSrc = 0, int chanDst = 0) {
BufDiskWorker::requestReadMono(bufIdx[chanDst], path, startTimeSrc, startTimeDst, dur, chanSrc);
}
void readBufferStereo(const std::string &path, float startTimeSrc = 0.f, float startTimeDst = 0.f,
float dur = -1.f) {
BufDiskWorker::requestReadStereo(bufIdx[0], bufIdx[1], path, startTimeSrc, startTimeDst, dur);
}
void writeBufferMono(const std::string &path, float start, float dur, int chan) {
BufDiskWorker::requestWriteMono(bufIdx[chan], path, start, dur);
}
void writeBufferStereo(const std::string &path, float start, float dur) {
BufDiskWorker::requestWriteStereo(bufIdx[0], bufIdx[1], path, start, dur);
}
void clearBuffer(int chan, float start=0.f, float dur=-1) {
if (chan < 0 || chan > 1) { return; }
BufDiskWorker::requestClear(bufIdx[chan], start, dur);
}
// check if quantized phase has changed for a given voice
// returns true
bool checkVoiceQuantPhase(int i) {
if (quantPhase[i] != cut.getQuantPhase(i)) {
quantPhase[i] = cut.getQuantPhase(i);
return true;
} else {
return false;
}
}
softcut::phase_t getQuantPhase(int i) {
return cut.getQuantPhase(i);
}
void setPhaseQuant(int i, softcut::phase_t q) {
cut.setPhaseQuant(i, q);
}
void setPhaseOffset(int i, float sec) {
cut.setPhaseOffset(i, sec);
}
int getNumVoices() const { return NumVoices; }
float getSampleRate() const { return sampleRate; }
void reset();
private:
void clearBusses(size_t numFrames);
void mixInput(size_t numFrames);
void mixOutput(size_t numFrames);
};
}
#endif //CRONE_CUTCLIENT_H
| 4,167
|
C++
|
.h
| 105
| 30.87619
| 108
| 0.618906
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,425
|
BufDiskWorker.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/BufDiskWorker.h
|
//
// Created by emb on 11/30/19.
//
/*
* BufDiskWorker is an Audio Buffer Disk Interface static class.
*
* it requires users to _register_ buffers (returns numerical index for registered buf)
* disk read/write work can be requested for registered buffers, executed in background thread
*
* TODO:
* - callback for request completion?
* - use condvar for signaling, instead of sleep+poll
*/
#ifndef CRONE_BUFMANAGER_H
#define CRONE_BUFMANAGER_H
#include <array>
#include <atomic>
#include <thread>
#include <mutex>
#include <queue>
#include <memory>
namespace softcut_jack_osc {
// class for asynchronous management of mono audio buffers
class BufDiskWorker {
enum class JobType {
Clear,
ReadMono, ReadStereo,
WriteMono, WriteStereo
};
struct Job {
JobType type;
size_t bufIdx[2];
std::string path;
float startSrc;
float startDst;
float dur;
int chan;
};
struct BufDesc {
float *data;
size_t frames;
};
static std::queue<Job> jobQ;
static std::mutex qMut;
static std::unique_ptr<std::thread> worker;
static constexpr size_t maxBufs = 16;
static std::array<BufDesc, maxBufs> bufs;
static int numBufs;
static bool shouldQuit;
static constexpr int sleepPeriodMs = 100;
static int sampleRate;
static constexpr int ioBufFrames = 1024;
static int secToFrame(float seconds);
private:
static void requestJob(Job &job);
public:
// initialize with sample rate
static void init(int sr);
// register a buffer to manage.
// returns index to be used in work requests
static int registerBuffer(float *data, size_t frames);
// clear a portion of a mono buffer
static void requestClear(size_t idx, float start = 0, float dur = -1);
// read mono soundfile to mono buffer
static void
requestReadMono(size_t idx, std::string path, float startSrc = 0, float startDst = 0, float dur = -1,
int chanSrc = 0);
// read and de-interleave stereo soundfile to 2x mono buffers
static void
requestReadStereo(size_t idx0, size_t idx1, std::string path, float startSrc = 0, float startDst = 0,
float dur = -1);
// write mono buf to mono soundfile
static void requestWriteMono(size_t idx, std::string path, float start = 0, float dur = -1);
// write and interleave two mono buffers to one stereo file
static void requestWriteStereo(size_t idx0, size_t idx1, std::string path, float start = 0, float dur = -1);
private:
static void workLoop();
static void clearBuffer(BufDesc &buf, float start = 0, float dur = -1);
static void readBufferMono(const std::string &path, BufDesc &buf,
float startSrc = 0, float startDst = 0, float dur = -1, int chanSrc = 0) noexcept;
static void readBufferStereo(const std::string &path, BufDesc &buf0, BufDesc &buf1,
float startSrc = 0, float startDst = 0, float dur = -1) noexcept;
static void writeBufferMono(const std::string &path, BufDesc &buf,
float start = 0, float dur = -1) noexcept;
static void writeBufferStereo(const std::string &path, BufDesc &buf0, BufDesc &buf1,
float start = 0, float dur = -1) noexcept;
};
}
#endif //CRONE_BUFMANAGER_H
| 3,677
|
C++
|
.h
| 89
| 32.168539
| 117
| 0.61683
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,426
|
JackClient.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/JackClient.h
|
//
// Created by emb on 11/28/18.
//
/*
* jack client abstraction
*
* notice that inputs and outputs are assumed to exist in stereo pairs.
* the abstraction of a stereo pair of input ports is called a _sink_.
* ... of output ports, a _source_.
*/
#ifndef CRONE_CLIENT_H
#define CRONE_CLIENT_H
#include <array>
#include <iostream>
#include <string>
#include <jack/jack.h>
#include <sstream>
#include "Commands.h"
namespace softcut_jack_osc {
template<int NumIns, int NumOuts>
class JackClient {
private:
static_assert(NumIns % 2 == 0, "non-even input count");
static_assert(NumOuts % 2 == 0, "non-even output count");
typedef const jack_default_audio_sample_t* Source[2];
typedef jack_default_audio_sample_t* Sink[2];
std::array<jack_port_t*, NumIns> inPort;
std::array<jack_port_t*, NumOuts> outPort;
const char *name;
protected:
jack_client_t *client{};
std::array<Source, NumIns/2> source;
std::array<Sink, NumOuts/2> sink;
private:
// set up pointers for the current buffer
void preProcess(jack_nframes_t numFrames) {
int j=0;
// FIXME: unroll with template?
for(int i=0; i<NumIns/2; ++i) {
source[i][0] = static_cast<const float*>(jack_port_get_buffer(inPort[j++], numFrames));
source[i][1] = static_cast<const float*>(jack_port_get_buffer(inPort[j++], numFrames));
}
j = 0;
for(int i=0; i<NumOuts/2; ++i) {
sink[i][0] = static_cast<float*>(jack_port_get_buffer(outPort[j++], numFrames));
sink[i][1] = static_cast<float*>(jack_port_get_buffer(outPort[j++], numFrames));
}
}
// process using our source and sink pointers.
// subclasses must implement this!
virtual void process(jack_nframes_t numFrames) = 0;
virtual void setSampleRate(jack_nframes_t sr) = 0;
public:
virtual void handleCommand(Commands::CommandPacket *p) = 0;
private:
//---------------------------------
//--- static handlers for jack API
static int callback(jack_nframes_t numFrames, void*data) {
auto *self = (JackClient*)(data);
self->preProcess(numFrames);
self->process(numFrames);
return 0;
}
// static handler for shutdown from jack
static void jack_shutdown(void* data) {
(void)data;
// FIXME: nothing to do?
}
public:
virtual void setup() {
using std::cerr;
using std::cout;
using std::endl;
jack_status_t status;
client = jack_client_open(name, JackNullOption, &status, nullptr);
if(client == nullptr) {
std::cerr << "jack_client_open() failed; status = " << status << endl;
if (status & JackServerFailed) {
cerr << "unable to connect to JACK server" << endl;
}
throw;
}
if (status & JackServerStarted) {
fprintf (stderr, "JACK server started\n");
}
if (status & JackNameNotUnique) {
name = jack_get_client_name(client);
fprintf (stderr, "unique name `%s' assigned\n", name);
}
jack_set_process_callback (client, JackClient::callback, this);
jack_on_shutdown (client, jack_shutdown, this);
auto sr = jack_get_sample_rate (client);
std::cout << "engine sample rate: " << sr << std::endl;
this->setSampleRate( sr );
for(int i=0; i<NumIns; ++i) {
std::ostringstream os;
os << "input_" << (i+1);
const char* name = os.str().c_str();
inPort[i] = jack_port_register (client, name,
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
if(inPort[i] == nullptr) {
throw std::runtime_error("no inputs available");
}
}
for(int i=0; i<NumOuts; ++i) {
std::ostringstream os;
os << "output_" << (i+1);
const char* name = os.str().c_str();
outPort[i] = jack_port_register (client, name,
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
if(outPort[i] == nullptr) {
os << " failed to connect";
throw std::runtime_error(os.str());
}
}
}
void cleanup() {
jack_client_close(client);
}
public:
// NB: alas, we can't call setup() from c-tor because it includes a virtual method call
// setup() will have to be called explicitly after creation
explicit JackClient(const char* n) : name(n), client(nullptr) {
std::cout << "constructed Client: " << name << std::endl;
}
virtual ~JackClient() = default;
void start() {
if (jack_activate (client)) {
throw std::runtime_error("client failed to activate");
}
}
void stop() {
jack_deactivate(client);
}
void connectAdcPorts() {
const char **ports = jack_get_ports (client, nullptr, nullptr,
JackPortIsPhysical|JackPortIsOutput);
if (ports == nullptr) {
throw std::runtime_error("no ADC ports found");
}
for(int i=0; i<NumIns; ++i) {
if(i > 1) { break; }
if (jack_connect (client, ports[i], jack_port_name (inPort[i]))) {
std::cerr << "failed to connect input port " << i << std::endl;
throw std::runtime_error("connectAdcPorts() failed");
}
}
free(ports);
}
void connectDacPorts() {
const char **ports = jack_get_ports (client, nullptr, nullptr,
JackPortIsPhysical|JackPortIsInput);
if (ports == nullptr) {
throw std::runtime_error("no DAC ports found");
}
for(int i=0; i<NumOuts; ++i) {
if(i > 1) { break; }
if (jack_connect (client, jack_port_name (outPort[i]), ports[i])) {
std::cerr << "failed to connect output port " << i << std::endl;
throw std::runtime_error("failed to connect output port");
}
}
free(ports);
}
//---- getters
const char* getInputPortName(int idx) {
return jack_port_name(inPort[idx]);
}
const char* getOutputPortName(int idx) {
return jack_port_name(outPort[idx]);
}
int getNumSinks() { return NumIns/2; }
int getNumSources() { return NumOuts/2; }
// FIXME: surely there is a cleaner way to use templated class reference parameter, here
template<int N, int M>
bool connect(JackClient<N,M> *other,
int sinkIdx, int sourceIdx) {
if (sinkIdx >= this->getNumSinks()) {
std::cerr << "invalid sink index in Client::connect()" << std::endl;
return false;
}
if (sourceIdx >= other->getNumSources()) {
std::cerr << "invalid source index in Client::connect()" << std::endl;
return false;
}
for (int i=0; i<2; ++i) {
const int srcPortIdx = sinkIdx*2 + i;
const int dstPortIdx = sourceIdx*2 + i;
const char* srcPortName = this->getOutputPortName(srcPortIdx);
const char* dstPortName = other->getInputPortName(dstPortIdx);
if(jack_connect(this->client, srcPortName, dstPortName)) {
std::cerr << "Client::connect(): port failed for channel " << i << std::endl;
return false;
}
}
return true;
}
};
}
#endif //CRONE_CLIENT_H
| 8,338
|
C++
|
.h
| 200
| 29.15
| 103
| 0.514388
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,427
|
Commands.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/Commands.h
|
//
// Created by ezra on 11/3/18.
//
#ifndef CRONE_COMMANDS_H
#define CRONE_COMMANDS_H
//#include <boost/lockfree/spsc_queue.hpp>
#include "readerwriterqueue/readerwriterqueue.h"
namespace softcut_jack_osc {
class SoftcutClient;
class Commands {
public:
typedef enum {
//-- softcut commands
// mix
SET_ENABLED_CUT,
SET_LEVEL_CUT,
SET_PAN_CUT,
// level of individual input channel -> cut voice
// (separate commands just to avoid a 3rd parameter)
SET_LEVEL_IN_CUT,
SET_LEVEL_CUT_CUT,
// params
SET_CUT_REC_FLAG,
SET_CUT_PLAY_FLAG,
SET_CUT_RATE,
SET_CUT_LOOP_START,
SET_CUT_LOOP_END,
SET_CUT_LOOP_FLAG,
SET_CUT_POSITION,
SET_CUT_FADE_TIME,
SET_CUT_REC_LEVEL,
SET_CUT_PRE_LEVEL,
SET_CUT_REC_OFFSET,
SET_CUT_PRE_FILTER_FC,
SET_CUT_PRE_FILTER_FC_MOD,
SET_CUT_PRE_FILTER_RQ,
SET_CUT_PRE_FILTER_LP,
SET_CUT_PRE_FILTER_HP,
SET_CUT_PRE_FILTER_BP,
SET_CUT_PRE_FILTER_BR,
SET_CUT_PRE_FILTER_DRY,
SET_CUT_POST_FILTER_FC,
SET_CUT_POST_FILTER_RQ,
SET_CUT_POST_FILTER_LP,
SET_CUT_POST_FILTER_HP,
SET_CUT_POST_FILTER_BP,
SET_CUT_POST_FILTER_BR,
SET_CUT_POST_FILTER_DRY,
SET_CUT_LEVEL_SLEW_TIME,
SET_CUT_PAN_SLEW_TIME,
SET_CUT_RECPRE_SLEW_TIME,
SET_CUT_RATE_SLEW_TIME,
SET_CUT_VOICE_SYNC,
SET_CUT_BUFFER,
SET_CUT_REC_ONCE,
NUM_COMMANDS,
} Id;
public:
Commands();
void post(Commands::Id id, float f);
void post(Commands::Id id, int i, float f);
void post(Commands::Id id, int i, int j);
void post(Commands::Id id, int i, int j, float f);
void handlePending(SoftcutClient *client);
struct CommandPacket {
CommandPacket() = default;
CommandPacket(Commands::Id i, int i0, float f) : id(i), idx_0(i0), idx_1(-1), value(f) {}
CommandPacket(Commands::Id i, int i0, int i1) : id(i), idx_0(i0), idx_1(i1) {}
CommandPacket(Commands::Id i, int i0, int i1, float f) : id(i), idx_0(i0), idx_1(i1), value(f) {}
Id id;
int idx_0{};
int idx_1{};
float value{};
};
static Commands softcutCommands;
private:
// boost::lockfree::spsc_queue <CommandPacket,
// boost::lockfree::capacity<200> > q;
moodycamel::ReaderWriterQueue<CommandPacket> q;
};
}
#endif //CRONE_COMMANDS_H
| 2,819
|
C++
|
.h
| 82
| 24.134146
| 109
| 0.539566
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,429
|
Poll.h
|
monome_softcut-lib/clients/softcut_jack_osc/src/Poll.h
|
//
// Created by emb on 11/30/18.
//
#ifndef CRONE_POLL_H
#define CRONE_POLL_H
#include <string>
#include <thread>
#include <functional>
#include <atomic>
#include <sstream>
#include <chrono>
#include <utility>
#include <lo/lo.h>
namespace softcut_jack_osc {
class Poll {
public:
typedef std::function<void(const char *)> Callback;
explicit Poll(std::string name) {
std::ostringstream os;
os << "/poll/" << name;
path = os.str();
}
void setCallback(Callback c) {
cb = std::move(c);
}
void start() {
shouldStop = false;
th = std::make_unique<std::thread>(std::thread(
[this] {
while (!shouldStop) {
this->cb(path.c_str());
std::this_thread::sleep_for(std::chrono::milliseconds(period));
}
}));
th->detach();
}
void stop() {
// in c++ there's no way to safely and non-cooperatively interrupt a thread.
shouldStop = true;
// i am reasonably sure this won't leak...
th.reset();
}
void setPeriod(int ms) {
period = ms;
}
private:
Callback cb;
std::atomic<int> period;
std::atomic<bool> shouldStop;
std::unique_ptr<std::thread> th;
std::string path;
lo_address addr;
};
}
#endif //CRONE_POLL_H
| 1,542
|
C++
|
.h
| 55
| 18.781818
| 91
| 0.504413
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,431
|
cos_win.inc
|
monome_softcut-lib/clients/softcut_jack_osc/src/cos_win.inc
|
0.0,
4.2872538208449384e-7,
0.0000017149007930927773,
0.000003858524027344767,
0.000006859591408836518,
0.000010718097790907155,
0.00001543403655662745,
0.000021007399618688805,
0.00002743817741929222,
0.00003472635893025933,
0.0000428719316531434,
0.00005187488161895182,
0.00006173519338870115,
0.00007245285005275104,
0.00008402783323147034,
0.00009646012307490404,
0.00010974969826288428,
0.00012389653600508588,
0.00013890061204108184,
0.00015476190064034334,
0.00017148037460235077,
0.00018905600525659372,
0.00020748876246251546,
0.00022677861460984605,
0.0002469255286182692,
0.000267929469937922,
0.00028979040254911714,
0.0003125082889623987,
0.00033608309021887495,
0.00036051476589016307,
0.00038580327407827797,
0.0004119485714159099,
0.00043895061306642447,
0.00046680935272408464,
0.0004955247426137732,
0.0005250967334914924,
0.0005555252746441974,
0.0005868103138899072,
0.0006189517975778713,
0.0006519496705886252,
0.0006858038763339902,
0.0007205143567574623,
0.000756081052333879,
0.0007925039020699187,
0.0008297828435039345,
0.0008679178127062315,
0.0009069087442791224,
0.0009467555713569831,
0.000987458225606419,
0.0010290166372263765,
0.0010714307349483088,
0.0011147004460361765,
0.001158825696286725,
0.0012038064100294288,
0.0012496425101268804,
0.0012963339179746236,
0.0013438805535014864,
0.0013922823351697478,
0.001441539179974971,
0.0014916510034466701,
0.0015426177196479207,
0.0015944392411758601,
0.0016471154791616316,
0.0017006463432707175,
0.0017550317417029393,
0.001810271581192735,
0.0018663657670091593,
0.0019233142029562167,
0.001981116791372972,
0.002039773433133718,
0.002099284027647974,
0.002159648472861042,
0.0022208666652537845,
0.0022829384998430124,
0.002345863870181708,
0.0024096426683590244,
0.0024742747850006186,
0.0025397601092687627,
0.0026060985288625105,
0.0026732899300180857,
0.0027413341975088823,
0.0028102312146455755,
0.002879980863276621,
0.0029505830237882558,
0.0030220375751046635,
0.0030943443946884197,
0.0031675033585404355,
0.00324151434120018,
0.0033163772157462357,
0.0033920918537960754,
0.003468658125506563,
0.0035460758995740638,
0.003624345043234778,
0.0037034654222647956,
0.0037834369009804303,
0.0038642593422384963,
0.003945932607436475,
0.004028456556512738,
0.004111831047946879,
0.004196055938759824,
0.004281131084514167,
0.004367056339314446,
0.004453831555807197,
0.00454145658518168,
0.00462993127716943,
0.004719255480045148,
0.004809429040626534,
0.004900451804274897,
0.0049923236148951,
0.00508504431493606,
0.00517861374539097,
0.005273031745797352,
0.005368298154237727,
0.005464412807339503,
0.005561375540275637,
0.00565918618676442,
0.005757844579070359,
0.005857350548003959,
0.005957703922922386,
0.006058904531729359,
0.006160952200875813,
0.00626384675536007,
0.006367588018728165,
0.006472175813073966,
0.006577609959039776,
0.00668389027581634,
0.006791016581143394,
0.0068989886913098375,
0.007007806421154283,
0.007117469584064895,
0.007227977991980217,
0.007339331455389175,
0.0074515297833315786,
0.007564572783398282,
0.00767846026173169,
0.007793192023026085,
0.007908767870527744,
0.008025187606035378,
0.008142451029900744,
0.008260557941028479,
0.00837950813687699,
0.008499301413458282,
0.008619937565338798,
0.008741416385639356,
0.008863737666035765,
0.008986901196759045,
0.009110906766595872,
0.00923575416288891,
0.009361443171537198,
0.009487973576996489,
0.009615345162279465,
0.009743557708956463,
0.009872610997155695,
0.010002504805563361,
0.010133238911424425,
0.010264813090542724,
0.010397227117281527,
0.01053048076456381,
0.010664573803872646,
0.010799506005251758,
0.010935277137305688,
0.011071886967200295,
0.0112093352606632,
0.011347621781984063,
0.011486746294015138,
0.011626708558171606,
0.011767508334431964,
0.011909145381338415,
0.01205161945599742,
0.012194930314079977,
0.01233907770982201,
0.012484061396025037,
0.01262988112405622,
0.012776536643849146,
0.012924027703903995,
0.013072354051288149,
0.013221515431636466,
0.013371511589151952,
0.013522342266605925,
0.013674007205338623,
0.013826506145259654,
0.013979838824848323,
0.014134004981154136,
0.014289004349797407,
0.01444483666496943,
0.014601501659433136,
0.014758999064523493,
0.01491732861014794,
0.015076490024786893,
0.015236483035494186,
0.015397307367897628,
0.015558962746199334,
0.01572144889317617,
0.015884765530180422,
0.016048912377140123,
0.016213889152559613,
0.016379695573520037,
0.016546331355679622,
0.0167137962132744,
0.01688208985911871,
0.017051212004605465,
0.017221162359706776,
0.017391940632974667,
0.01756354653154113,
0.01773597976111896,
0.017909240026002138,
0.0180833270290664,
0.01825824047176966,
0.018433980054152477,
0.01861054547483898,
0.018787936431036767,
0.01896615261853779,
0.019145193731718912,
0.01932505946354207,
0.019505749505555503,
0.019687263547893408,
0.019869601279277116,
0.020052762387015366,
0.02023674655700497,
0.02042155347373109,
0.020607182820268022,
0.020793634278279904,
0.02098090752802073,
0.02116900224833529,
0.021357918116659713,
0.02154765480902182,
0.021738212000042,
0.02192958936293332,
0.022121786569502477,
0.02231480329015023,
0.02250863919387186,
0.022703293948257874,
0.02289876721949452,
0.023095058672364444,
0.023292167970247135,
0.02349009477511954,
0.023688838747556673,
0.023888399546732164,
0.02408877683041888,
0.02428997025498958,
0.02449197947541737,
0.02469480414527625,
0.024898443916741897,
0.025102898440592214,
0.025308167366207723,
0.02551425034157251,
0.025721147013274603,
0.02592885702650649,
0.026137380025065993,
0.02634671565135671,
0.026556863546388698,
0.02676782334977884,
0.02697959469975203,
0.027192177233141157,
0.027405570585388228,
0.027619774390544527,
0.027834788281271616,
0.028050611888841948,
0.028267244843139194,
0.028484686772659307,
0.028702937304510623,
0.02892199606441509,
0.02914186267670843,
0.02936253676434103,
0.02958401794887866,
0.029806305850502868,
0.030029400088011804,
0.030253300278820783,
0.03047800603896289,
0.03070351698309015,
0.03092983272447336,
0.031156952875003308,
0.03138487704519133,
0.03161360484416992,
0.03184313587969334,
0.03207346975813846,
0.03230460608450553,
0.03253654446241844,
0.03276928449412564,
0.0330028257805009,
0.03323716792104403,
0.033472310513881165,
0.03370825315576598,
0.033944995442080184,
0.03418253696683393,
0.034420877322666965,
0.03466001610084907,
0.03489995289128062,
0.035140687282493865,
0.035382218861652937,
0.03562454721455499,
0.03586767192563073,
0.03611159257794516,
0.03635630875319851,
0.03660182003172646,
0.03684812599250159,
0.037095226213133214,
0.03734312026986891,
0.03759180773759474,
0.03784128818983612,
0.03809156119875878,
0.03834262633516905,
0.03859448316851499,
0.038847131266886936,
0.039100570197018236,
0.03935479952428611,
0.039609818812712194,
0.039865627624963706,
0.040122225522353616,
0.04037961206484186,
0.04063778681103575,
0.04089674931819115,
0.0411564991422127,
0.04141703583765516,
0.04167835895772376,
0.04194046805427504,
0.04220336267781771,
0.04246704237751342,
0.04273150670117726,
0.042996755195279235,
0.04326278740494416,
0.043529602873952966,
0.04379720114474345,
0.04406558175841091,
0.04433474425470907,
0.044604688172050544,
0.04487541304750842,
0.04514691841681595,
0.045419203814368314,
0.0456922687732228,
0.04596611282509977,
0.04624073550038382,
0.04651613632812407,
0.04679231483603524,
0.04706927055049831,
0.04734700299656153,
0.0476255116979411,
0.047904796177021924,
0.04818485595485883,
0.04846569055117678,
0.04874729948437212,
0.049029682271513164,
0.04931283842834122,
0.04959676746927161,
0.049881468907393756,
0.050166942254472824,
0.050453187020950085,
0.05074020271594398,
0.05102798884725085,
0.051316544921345686,
0.051605870443383495,
0.05189596491719939,
0.05218682784530987,
0.05247845872891366,
0.05277085706789253,
0.053064022360812146,
0.05335795410492272,
0.05365265179616058,
0.05394811492914797,
0.05424434299719477,
0.05454133549229906,
0.054839091905147797,
0.055137611725118274,
0.05543689444027833,
0.05573693953738745,
0.05603774650189802,
0.056339314817955566,
0.05664164396840021,
0.05694473343476708,
0.05724858269728783,
0.05755319123489078,
0.057858558525202275,
0.0581646840445475,
0.05847156726795116,
0.05877920766913908,
0.059087604720538034,
0.05939675789327753,
0.059706666657190266,
0.06001733048081331,
0.06032874883138867,
0.06064092117486458,
0.060953846975896286,
0.06126752569784688,
0.06158195680278811,
0.061897139751501684,
0.06221307400347975,
0.06252975901692653,
0.0628471942487579,
0.06316537915460413,
0.0634843131888092,
0.06380399580443274,
0.0641244264532505,
0.06444560458575538,
0.06476752965115878,
0.06509020109739072,
0.06541361837110143,
0.06573778091766225,
0.06606268818116623,
0.06638833960442941,
0.06671473462899163,
0.06704187269511774,
0.067369753241798,
0.06769837570674969,
0.06802773952641755,
0.06835784413597495,
0.06868868896932528,
0.06902027345910206,
0.06935259703667052,
0.06968565913212854,
0.07001945917430735,
0.07035399659077274,
0.07068927080782589,
0.07102528125050483,
0.07136202734258451,
0.07169950850657858,
0.0720377241637401,
0.07237667373406242,
0.07271635663628073,
0.07305677228787183,
0.07339792010505669,
0.07373979950280041,
0.0740824098948134,
0.07442575069355262,
0.07476982131022225,
0.0751146211547753,
0.07546014963591391,
0.07580640616109074,
0.0761533901365099,
0.07650110096712803,
0.07684953805665556,
0.07719870080755675,
0.07754858862105218,
0.07789920089711866,
0.07825053703449064,
0.0786025964306612,
0.07895537848188305,
0.07930888258316993,
0.07966310812829702,
0.08001805450980237,
0.08037372111898794,
0.08073010734592051,
0.08108721257943269,
0.08144503620712418,
0.08180357761536289,
0.08216283618928544,
0.08252281131279882,
0.08288350236858111,
0.08324490873808255,
0.08360702980152718,
0.08396986493791253,
0.08433341352501245,
0.08469767493937674,
0.08506264855633305,
0.08542833374998748,
0.08579472989322579,
0.08616183635771502,
0.08652965251390354,
0.08689817773102287,
0.08726741137708854,
0.08763735281890117,
0.08800800142204784,
0.08837935655090229,
0.08875141756862742,
0.08912418383717507,
0.08949765471728782,
0.08987182956849987,
0.09024670774913801,
0.09062228861632343,
0.0909985715259718,
0.09137555583279489,
0.09175324089030179,
0.09213162605079983,
0.09251071066539573,
0.09289049408399652,
0.09327097565531134,
0.09365215472685157,
0.09403403064493271,
0.09441660275467517,
0.09479987040000526,
0.09518383292365701,
0.09556848966717241,
0.0959538399709029,
0.09633988317401077,
0.0967266186144699,
0.09711404562906711,
0.09750216355340308,
0.09789097172189404,
0.09828046946777214,
0.09867065612308706,
0.09906153101870718,
0.09945309348432041,
0.09984534284843599,
0.10023827843838445,
0.10063189958032032,
0.10102620559922199,
0.10142119581889336,
0.10181686956196523,
0.10221322614989586,
0.10261026490297304,
0.10300798514031428,
0.10340638617986858,
0.10380546733841728,
0.10420522793157544,
0.10460566727379339,
0.10500678467835656,
0.10540857945738846,
0.1058110509218505,
0.10621419838154378,
0.1066180211451101,
0.10702251852003303,
0.10742768981263967,
0.107833534328101,
0.10824005137043369,
0.108647240242501,
0.10905510024601411,
0.10946363068153331,
0.109872830848469,
0.11028270004508345,
0.11069323756849114,
0.11110444271466074,
0.11151631477841589,
0.11192885305343642,
0.11234205683226023,
0.11275592540628293,
0.11317045806576109,
0.11358565409981197,
0.11400151279641518,
0.11441803344241402,
0.11483521532351643,
0.11525305772429689,
0.11567155992819672,
0.11609072121752573,
0.11651054087346369,
0.11693101817606105,
0.11735215240424107,
0.1177739428357995,
0.11819638874740762,
0.1186194894146122,
0.1190432441118372,
0.11946765211238519,
0.11989271268843793,
0.12031842511105878,
0.12074478865019267,
0.12117180257466809,
0.1215994661521983,
0.12202777864938225,
0.12245673933170631,
0.12288634746354493,
0.12331660230816277,
0.12374750312771504,
0.12417904918324918,
0.12461123973470628,
0.12504407404092188,
0.12547755135962818,
0.12591167094745398,
0.12634643205992702,
0.12678183395147474,
0.12721787587542582,
0.12765455708401136,
0.1280918768283658,
0.12852983435852922,
0.1289684289234474,
0.1294076597709739,
0.12984752614787104,
0.13028802729981115,
0.13072916247137856,
0.1311709309060693,
0.13161333184629448,
0.13205636453337993,
0.13250002820756812,
0.1329443221080196,
0.13338924547281394,
0.1338347975389516,
0.13428097754235463,
0.13472778471786823,
0.13517521829926205,
0.13562327751923137,
0.13607196160939933,
0.1365212698003162,
0.13697120132146312,
0.13742175540125173,
0.1378729312670261,
0.13832472814506414,
0.13877714526057844,
0.13923018183771857,
0.13968383709957127,
0.14013811026816236,
0.14059300056445811,
0.14104850720836654,
0.14150462941873848,
0.1419613664133692,
0.14241871740900003,
0.14287668162131884,
0.14333525826496218,
0.14379444655351614,
0.144254245699518,
0.1447146549144579,
0.14517567340877874,
0.14563730039187972,
0.14609953507211582,
0.1465623766568001,
0.1470258243522048,
0.14748987736356262,
0.14795453489506866,
0.14841979614988082,
0.14888566033012196,
0.14935212663688074,
0.14981919427021329,
0.15028686242914513,
0.1507551303116707,
0.15122399711475726,
0.1516934620343442,
0.15216352426534535,
0.15263418300165038,
0.15310543743612576,
0.15357728676061672,
0.15404973016594808,
0.15452276684192595,
0.15499639597733889,
0.1554706167599597,
0.15594542837654635,
0.15642083001284351,
0.15689682085358458,
0.1573734000824919,
0.1578505668822791,
0.15832832043465206,
0.1588066599203103,
0.15928558451894903,
0.15976509340925965,
0.16024518576893154,
0.16072586077465362,
0.16120711760211553,
0.16168895542600925,
0.16217137342003024,
0.16265437075687939,
0.1631379466082637,
0.1636221001448982,
0.16410683053650726,
0.16459213695182584,
0.16507801855860166,
0.16556447452359502,
0.16605150401258228,
0.16653910619035572,
0.16702728022072555,
0.16751602526652143,
0.16800534048959354,
0.16849522505081482,
0.1689856781100813,
0.16947669882631428,
0.16996828635746158,
0.17046043986049897,
0.17095315849143172,
0.1714464414052957,
0.1719402877561596,
0.1724346966971254,
0.17292966738033044,
0.1734251989569488,
0.17392129057719236,
0.1744179413903134,
0.17491515054460405,
0.17541291718739982,
0.17591124046508033,
0.1764101195230695,
0.17690955350583965,
0.1774095415569099,
0.17791008281885068,
0.17841117643328236,
0.17891282154087912,
0.17941501728136922,
0.17991776279353577,
0.1804210572152205,
0.18092489968332226,
0.18142928933380148,
0.18193422530167902,
0.1824397067210397,
0.18294573272503295,
0.1834523024458734,
0.18395941501484453,
0.18446706956229747,
0.18497526521765545,
0.18548400110941216,
0.18599327636513607,
0.1865030901114706,
0.18701344147413468,
0.1875243295779263,
0.18803575354672303,
0.1885477125034824,
0.189060205570246,
0.1895732318681379,
0.19008679051736926,
0.19060088063723685,
0.1911155013461271,
0.1916306517615165,
0.19214633099997214,
0.19266253817715562,
0.19317927240782168,
0.19369653280582283,
0.19421431848410758,
0.1947326285547249,
0.19525146212882444,
0.195770818316657,
0.19629069622757844,
0.19681109497004884,
0.1973320136516361,
0.19785345137901544,
0.19837540725797276,
0.1988978803934055,
0.19942086988932295,
0.19994437484885041,
0.20046839437422764,
0.20099292756681347,
0.20151797352708445,
0.20204353135463882,
0.20256960014819697,
0.20309617900560206,
0.20362326702382355,
0.2041508632989577,
0.20467896692622817,
0.20520757699998998,
0.20573669261372818,
0.20626631286006225,
0.206796436830745,
0.2073270636166663,
0.2078581923078539,
0.2083898219934736,
0.2089219517618336,
0.20945458070038303,
0.2099877078957164,
0.2105213324335724,
0.2110554533988378,
0.21159006987554818,
0.2121251809468881,
0.21266078569519553,
0.21319688320196034,
0.21373347254782887,
0.2142705528126025,
0.21480812307524172,
0.21534618241386694,
0.21588472990575863,
0.21642376462736157,
0.21696328565428358,
0.21750329206129992,
0.2180437829223521,
0.21858475731055188,
0.2191262142981818,
0.21966815295669573,
0.2202105723567226,
0.22075347156806685,
0.22129684965970914,
0.2218407056998103,
0.22238503875570997,
0.22292984789393133,
0.22347513218017961,
0.22402089067934633,
0.2245671224555098,
0.22511382657193552,
0.2256610020910806,
0.226208648074592,
0.2267567635833117,
0.22730534767727473,
0.22785439941571378,
0.22840391785705955,
0.22895390205894134,
0.22950435107819112,
0.2300552639708422,
0.23060663979213408,
0.2311584775965107,
0.231710776437625,
0.23226353536833916,
0.23281675344072533,
0.23337042970606936,
0.23392456321487137,
0.23447915301684658,
0.23503419816092763,
0.23558969769526728,
0.2361456506672388,
0.23670205612343687,
0.23725891310968134,
0.2378162206710176,
0.23837397785171732,
0.23893218369528268,
0.23949083724444487,
0.2400499375411687,
0.24060948362665163,
0.24116947454132748,
0.24172990932486743,
0.24229078701618018,
0.2428521066534165,
0.2434138672739678,
0.24397606791447057,
0.24453870761080543,
0.245101785398101,
0.24566530031073475,
0.24622925138233331,
0.2467936376457769,
0.2473584581331979,
0.24792371187598555,
0.24848939790478453,
0.24905551524949948,
0.24962206293929518,
0.25018904000259745,
0.25075644546709686,
0.25132427835974913,
0.25189253770677655,
0.25246122253366987,
0.25303033186519097,
0.25359986472537377,
0.2541698201375248,
0.2547401971242269,
0.25531099470734026,
0.2558822119080023,
0.2564538477466327,
0.25702590124293134,
0.2575983714158837,
0.258171257283759,
0.25874455786411477,
0.2593182721737973,
0.2598923992289424,
0.26046693804497945,
0.26104188763663005,
0.2616172470179131,
0.2621930152021433,
0.2627691912019351,
0.2633457740292039,
0.263922762695166,
0.2645001562103437,
0.26507795358456293,
0.26565615382695906,
0.2662347559459747,
0.2668137589493646,
0.2673931618441961,
0.2679729636368494,
0.26855316333302204,
0.26913375993772903,
0.26971475245530385,
0.27029613988940127,
0.2708779212429995,
0.2714600955184011,
0.2720426617172338,
0.2726256188404543,
0.2732089658883489,
0.27379270186053417,
0.2743768257559611,
0.274961336572914,
0.2755462333090151,
0.27613151496122335,
0.27671718052583877,
0.2773032289985029,
0.2778896593741996,
0.2784764706472593,
0.2790636618113576,
0.27965123185952034,
0.28023917978412194,
0.28082750457689,
0.2814162052289058,
0.28200528073060493,
0.28259473007178126,
0.28318455224158773,
0.2837747462285369,
0.2843653110205038,
0.2849562456047284,
0.2855475489678164,
0.2861392200957401,
0.2867312579738421,
0.2873236615868361,
0.28791642991880795,
0.2885095619532178,
0.2891030566729031,
0.2896969130600792,
0.29029113009634017,
0.29088570676266257,
0.2914806420394065,
0.2920759349063156,
0.29267158434252216,
0.2932675893265452,
0.29386394883629563,
0.2944606618490748,
0.29505772734157915,
0.2956551442899005,
0.2962529116695268,
0.2968510284553466,
0.29744949362164785,
0.29804830614212247,
0.29864746498986505,
0.2992469691373777,
0.2998468175565702,
0.3004470092187608,
0.3010475430946802,
0.3016484181544724,
0.3022496333676955,
0.30285118770332414,
0.3034530801297523,
0.3040553096147941,
0.30465787512568454,
0.3052607756290835,
0.30586401009107633,
0.3064675774771749,
0.30707147675232027,
0.3076757068808851,
0.3082802668266744,
0.3088851555529267,
0.309490372022318,
0.3100959151969618,
0.3107017840384104,
0.31130797750765926,
0.31191449456514553,
0.3125213341707529,
0.3131284952838105,
0.313735976863097,
0.3143437778668419,
0.31495189725272554,
0.31556033397788374,
0.31616908699890667,
0.31677815527184366,
0.3173875377522018,
0.31799723339495056,
0.3186072411545223,
0.31921755998481305,
0.3198281888391864,
0.32043912667047453,
0.3210503724309788,
0.3216619250724724,
0.3222737835462032,
0.32288594680289473,
0.3234984137927463,
0.3241111834654378,
0.32472425477013006,
0.3253376266554653,
0.32595129806957185,
0.3265652679600629,
0.32717953527404153,
0.32779409895809875,
0.32840895795831887,
0.32902411122027964,
0.32963955768905295,
0.3302552963092096,
0.3308713260248176,
0.3314876457794475,
0.33210425451617076,
0.33272115117756457,
0.3333383347057123,
0.3339558040422041,
0.3345735581281417,
0.33519159590413694,
0.33580991631031665,
0.33642851828632137,
0.3370474007713101,
0.3376665627039607,
0.3382860030224706,
0.33890572066456104,
0.33952571456747777,
0.34014598366799187,
0.3407665269024024,
0.3413873432065393,
0.3420084315157642,
0.3426297907649709,
0.34325141988859,
0.34387331782058905,
0.34449548349447356,
0.34511791584329155,
0.34574061379963184,
0.3463635762956298,
0.34698680226296513,
0.3476102906328671,
0.34823404033611505,
0.3488580503030386,
0.34948231946352326,
0.3501068467470078,
0.3507316310824904,
0.35135667139852655,
0.3519819666232341,
0.3526075156842937,
0.3532333175089495,
0.3538593710240139,
0.35448567515586576,
0.3551122288304561,
0.35573903097330634,
0.3563660805095128,
0.35699337636374767,
0.3576209174602596,
0.3582487027228778,
0.3588767310750127,
0.3595050014396572,
0.360133512739389,
0.36076226389637356,
0.36139125383236503,
0.3620204814687067,
0.3626499457263356,
0.36327964552578285,
0.36390957978717453,
0.36453974743023626,
0.36517014737429176,
0.365800778538268,
0.3664316398406937,
0.3670627301997045,
0.36769404853304277,
0.36832559375805907,
0.36895736479171626,
0.36958936055058844,
0.3702215799508659,
0.3708540219083539,
0.37148668533847706,
0.37211956915628036,
0.3727526722764295,
0.37338599361321545,
0.37401953208055494,
0.3746532865919914,
0.37528725606069774,
0.3759214393994793,
0.3765558355207745,
0.3771904433366556,
0.37782526175883313,
0.37846028969865636,
0.3790955260671146,
0.3797309697748395,
0.38036661973210817,
0.38100247484884386,
0.38163853403461695,
0.3822747961986489,
0.38291126024981315,
0.38354792509663577,
0.3841847896473,
0.3848218528096451,
0.38545911349117123,
0.3860965705990383,
0.38673422304007044,
0.3873720697207571,
0.38801010954725307,
0.3886483414253838,
0.3892867642606435,
0.38992537695820084,
0.39056417842289703,
0.39120316755925094,
0.39184234327145945,
0.39248170446339836,
0.39312125003862664,
0.39376097890038697,
0.394400889951607,
0.39504098209490174,
0.3956812542325767,
0.3963217052666287,
0.3969623340987463,
0.3976031396303147,
0.3982441207624158,
0.39888527639582977,
0.3995266054310373,
0.4001681067682228,
0.4008097793072749,
0.4014516219477877,
0.4020936335890647,
0.4027358131301194,
0.4033781594696765,
0.40402067150617593,
0.40466334813777205,
0.4053061882623386,
0.4059491907774672,
0.40659235458047227,
0.4072356785683917,
0.4078791616379872,
0.4085228026857497,
0.4091666006078972,
0.40981055430038066,
0.41045466265888186,
0.411098924578819,
0.41174333895534665,
0.41238790468335673,
0.41303262065748303,
0.4136774857721015,
0.4143224989213315,
0.41496765899903865,
0.4156129648988373,
0.41625841551409193,
0.41690400973791725,
0.4175497464631833,
0.4181956245825156,
0.4188416429882959,
0.4194878005726671,
0.4201340962275317,
0.4207805288445572,
0.42142709731517436,
0.42207380053058247,
0.4227206373817496,
0.4233676067594133,
0.4240147075540857,
0.4246619386560519,
0.425309298955375,
0.42595678734189507,
0.4266044027052337,
0.4272521439347947,
0.42790000991976485,
0.4285479995491186,
0.4291961117116167,
0.42984434529581145,
0.43049269919004524,
0.4311411722824554,
0.4317897634609749,
0.4324384716133329,
0.43308729562705917,
0.43373623438948483,
0.4343852867877434,
0.43503445170877353,
0.4356837280393217,
0.4363331146659434,
0.43698261047500364,
0.43763221435268146,
0.4382819251849706,
0.4389317418576802,
0.43958166325643944,
0.44023168826669623,
0.44088181577372265,
0.4415320446626131,
0.44218237381828945,
0.4428328021255018,
0.4434833284688287,
0.44413395173268244,
0.44478467080130724,
0.44543548455878496,
0.44608639188903315,
0.4467373916758103,
0.44738848280271626,
0.4480396641531931,
0.44869093461052967,
0.4493422930578605,
0.4499937383781708,
0.4506452694542951,
0.4512968851689223,
0.451948584404596,
0.4526003660437153,
0.4532522289685393,
0.4539041720611877,
0.4545561942036419,
0.45520829427774767,
0.4558604711652181,
0.45651272374763435,
0.4571650509064467,
0.4578174515229787,
0.458469924478428,
0.45912246865386686,
0.4597750829302471,
0.4604277661883987,
0.461080517309035,
0.4617333351727511,
0.4623862186600293,
0.463039166651239,
0.46369217802663787,
0.4643452516663766,
0.46499838645049724,
0.46565158125893896,
0.46630483497153596,
0.466958146468023,
0.46761151462803563,
0.4682649383311108,
0.4689184164566918,
0.46957194788412837,
0.470225531492678,
0.4708791661615087,
0.47153285076970186,
0.4721865841962532,
0.4728403653200734,
0.47349419301999257,
0.47414806617476113,
0.4748019836630505,
0.4754559443634561,
0.4761099471545003,
0.47676399091463306,
0.47741807452223284,
0.47807219685561114,
0.478726356793013,
0.4793805532126177,
0.48003478499254365,
0.48068905101084686,
0.4813433501455264,
0.48199768127452297,
0.48265204327572336,
0.4833064350269617,
0.4839608554060197,
0.4846153032906317,
0.48526977755848316,
0.485924277087216,
0.4865788007544272,
0.4872333474376735,
0.4878879160144722,
0.48854250536230176,
0.4891971143586064,
0.4898517418807966,
0.4905063868062502,
0.4911610480123151,
0.49181572437631227,
0.49247041477553666,
0.4931251180872578,
0.4937798331887244,
0.4944345589571651,
0.4950892942697891,
0.49574403800378947,
0.4963987890363455,
0.4970535462446242,
0.4977083085057805,
0.49836307469696206,
0.4990178436953097,
0.49967261437795835,
0.5003273856220415,
0.5009821563046901,
0.5016369253030377,
0.5022916914942193,
0.5029464537553756,
0.5036012109636543,
0.5042559619962104,
0.5049107057302111,
0.5055654410428347,
0.5062201668112754,
0.506874881912742,
0.5075295852244631,
0.5081842756236875,
0.5088389519876847,
0.5094936131937496,
0.5101482581192032,
0.5108028856413934,
0.5114574946376981,
0.5121120839855277,
0.5127666525623263,
0.5134211992455726,
0.5140757229127838,
0.5147302224415167,
0.5153846967093682,
0.5160391445939801,
0.5166935649730381,
0.5173479567242765,
0.5180023187254769,
0.5186566498544734,
0.519310948989153,
0.5199652150074562,
0.5206194467873821,
0.5212736432069868,
0.5219278031443887,
0.5225819254777669,
0.5232360090853668,
0.5238900528454995,
0.5245440556365437,
0.5251980163369497,
0.5258519338252386,
0.5265058069800073,
0.5271596346799264,
0.5278134158037466,
0.5284671492302979,
0.5291208338384911,
0.5297744685073218,
0.5304280521158715,
0.531081583543308,
0.531735061668889,
0.5323884853719643,
0.5330418535319768,
0.5336951650284638,
0.5343484187410609,
0.5350016135495026,
0.5356547483336233,
0.5363078219733619,
0.5369608333487608,
0.5376137813399705,
0.5382666648272487,
0.5389194826909649,
0.5395722338116011,
0.5402249170697527,
0.5408775313461329,
0.5415300755215718,
0.5421825484770211,
0.5428349490935531,
0.5434872762523655,
0.5441395288347818,
0.5447917057222521,
0.5454438057963583,
0.5460958279388121,
0.5467477710314605,
0.5473996339562845,
0.5480514155954038,
0.5487031148310775,
0.5493547305457047,
0.5500062616218291,
0.5506577069421393,
0.5513090653894706,
0.5519603358468067,
0.5526115171972835,
0.5532626083241895,
0.5539136081109667,
0.5545645154412149,
0.5552153291986925,
0.5558660482673174,
0.5565166715311711,
0.557167197874498,
0.5578176261817104,
0.5584679553373868,
0.5591181842262771,
0.5597683117333035,
0.5604183367435603,
0.5610682581423196,
0.5617180748150292,
0.5623677856473184,
0.5630173895249961,
0.5636668853340564,
0.5643162719606781,
0.5649655482912262,
0.5656147132122569,
0.566263765610515,
0.5669127043729407,
0.567561528386667,
0.5682102365390249,
0.5688588277175444,
0.5695073008099546,
0.5701556547041884,
0.5708038882883831,
0.5714520004508816,
0.5720999900802349,
0.5727478560652051,
0.5733955972947661,
0.5740432126581048,
0.5746907010446248,
0.5753380613439479,
0.5759852924459141,
0.5766323932405866,
0.5772793626182503,
0.5779261994694174,
0.5785729026848254,
0.5792194711554426,
0.5798659037724682,
0.5805121994273328,
0.5811583570117039,
0.5818043754174842,
0.5824502535368165,
0.5830959902620826,
0.583741584485908,
0.5843870351011625,
0.5850323410009611,
0.5856775010786683,
0.5863225142278984,
0.5869673793425167,
0.587612095316643,
0.5882566610446531,
0.5889010754211809,
0.5895453373411179,
0.5901894456996192,
0.5908333993921026,
0.5914771973142505,
0.5921208383620126,
0.5927643214316082,
0.5934076454195275,
0.5940508092225326,
0.5946938117376612,
0.5953366518622277,
0.595979328493824,
0.5966218405303234,
0.5972641868698804,
0.5979063664109352,
0.5985483780522121,
0.5991902206927249,
0.599831893231777,
0.6004733945689625,
0.6011147236041705,
0.601755879237584,
0.6023968603696851,
0.6030376659012535,
0.6036782947333711,
0.6043187457674231,
0.6049590179050981,
0.6055991100483928,
0.6062390210996128,
0.6068787499613731,
0.6075182955366014,
0.6081576567285404,
0.6087968324407489,
0.6094358215771027,
0.6100746230417989,
0.6107132357393563,
0.611351658574616,
0.6119898904527468,
0.6126279302792427,
0.6132657769599293,
0.6139034294009615,
0.6145408865088285,
0.6151781471903547,
0.6158152103526998,
0.6164520749033641,
0.6170887397501866,
0.617725203801351,
0.6183614659653829,
0.6189975251511559,
0.6196333802678917,
0.6202690302251603,
0.6209044739328857,
0.6215397103013435,
0.6221747382411668,
0.6228095566633443,
0.6234441644792253,
0.6240785606005206,
0.6247127439393021,
0.6253467134080084,
0.625980467919445,
0.6266140063867843,
0.6272473277235703,
0.6278804308437195,
0.6285133146615227,
0.629145978091646,
0.6297784200491339,
0.6304106394494113,
0.6310426352082835,
0.6316744062419408,
0.632305951466957,
0.6329372698002953,
0.6335683601593061,
0.6341992214617319,
0.6348298526257081,
0.6354602525697636,
0.6360904202128252,
0.636720354474217,
0.6373500542736643,
0.6379795185312931,
0.6386087461676349,
0.6392377361036262,
0.6398664872606108,
0.6404949985603431,
0.6411232689249872,
0.6417512972771221,
0.6423790825397402,
0.6430066236362522,
0.6436339194904871,
0.6442609690266935,
0.6448877711695437,
0.6455143248441341,
0.6461406289759863,
0.6467666824910503,
0.6473924843157062,
0.6480180333767658,
0.6486433286014732,
0.6492683689175094,
0.649893153252992,
0.6505176805364765,
0.6511419496969612,
0.6517659596638848,
0.6523897093671327,
0.6530131977370347,
0.65363642370437,
0.6542593862003679,
0.6548820841567083,
0.6555045165055262,
0.6561266821794108,
0.6567485801114099,
0.6573702092350289,
0.6579915684842357,
0.6586126567934605,
0.6592334730975975,
0.6598540163320084,
0.6604742854325221,
0.6610942793354387,
0.6617139969775292,
0.6623334372960391,
0.6629525992286898,
0.6635714817136784,
0.6641900836896831,
0.6648084040958628,
0.6654264418718585,
0.6660441959577957,
0.6666616652942876,
0.6672788488224353,
0.667895745483829,
0.6685123542205523,
0.6691286739751823,
0.6697447036907902,
0.6703604423109468,
0.6709758887797201,
0.671591042041681,
0.672205901041901,
0.6728204647259584,
0.6734347320399369,
0.674048701930428,
0.6746623733445346,
0.6752757452298698,
0.675888816534562,
0.6765015862072535,
0.6771140531971052,
0.6777262164537966,
0.6783380749275275,
0.6789496275690211,
0.6795608733295253,
0.6801718111608135,
0.6807824400151868,
0.6813927588454776,
0.6820027666050493,
0.682612462247798,
0.6832218447281562,
0.6838309130010931,
0.6844396660221166,
0.6850481027472743,
0.6856562221331579,
0.6862640231369028,
0.6868715047161894,
0.6874786658292469,
0.6880855054348542,
0.6886920224923405,
0.6892982159615895,
0.6899040848030381,
0.6905096279776819,
0.691114844447073,
0.6917197331733255,
0.6923242931191148,
0.6929285232476795,
0.6935324225228253,
0.6941359899089236,
0.6947392243709163,
0.6953421248743152,
0.6959446903852057,
0.6965469198702475,
0.6971488122966757,
0.6977503666323044,
0.6983515818455274,
0.6989524569053196,
0.699552990781239,
0.7001531824434296,
0.7007530308626221,
0.7013525350101347,
0.7019516938578774,
0.7025505063783519,
0.7031489715446536,
0.7037470883304731,
0.7043448557100993,
0.7049422726584207,
0.705539338150925,
0.7061360511637043,
0.7067324106734547,
0.7073284156574777,
0.7079240650936842,
0.7085193579605934,
0.7091142932373372,
0.7097088699036597,
0.7103030869399206,
0.7108969433270967,
0.711490438046782,
0.7120835700811919,
0.7126763384131637,
0.7132687420261578,
0.7138607799042598,
0.7144524510321835,
0.7150437543952715,
0.715634688979496,
0.716225253771463,
0.7168154477584121,
0.7174052699282185,
0.717994719269395,
0.718583794771094,
0.7191724954231098,
0.7197608202158778,
0.7203487681404794,
0.7209363381886422,
0.7215235293527409,
0.7221103406258003,
0.7226967710014969,
0.7232828194741611,
0.7238684850387764,
0.7244537666909847,
0.7250386634270858,
0.7256231742440391,
0.7262072981394653,
0.7267910341116509,
0.7273743811595456,
0.7279573382827661,
0.7285399044815988,
0.7291220787570003,
0.7297038601105985,
0.7302852475446959,
0.7308662400622709,
0.7314468366669777,
0.7320270363631504,
0.7326068381558037,
0.7331862410506352,
0.7337652440540252,
0.7343438461730408,
0.7349220464154369,
0.7354998437896565,
0.7360772373048338,
0.736654225970796,
0.7372308087980648,
0.7378069847978566,
0.7383827529820867,
0.7389581123633698,
0.7395330619550209,
0.7401076007710574,
0.7406817278262026,
0.7412554421358851,
0.7418287427162409,
0.7424016285841162,
0.7429740987570685,
0.7435461522533675,
0.7441177880919971,
0.7446890052926596,
0.7452598028757729,
0.745830179862475,
0.746400135274626,
0.7469696681348088,
0.74753877746633,
0.7481074622932233,
0.7486757216402506,
0.749243554532903,
0.7498109599974023,
0.7503779370607047,
0.7509444847505004,
0.7515106020952154,
0.7520762881240144,
0.752641541866802,
0.7532063623542233,
0.7537707486176666,
0.754334699689265,
0.7548982146018988,
0.7554612923891943,
0.7560239320855293,
0.756586132726032,
0.7571478933465837,
0.7577092129838197,
0.7582700906751324,
0.7588305254586724,
0.7593905163733482,
0.7599500624588311,
0.7605091627555549,
0.7610678163047175,
0.7616260221482821,
0.7621837793289823,
0.7627410868903186,
0.763297943876563,
0.763854349332761,
0.7644103023047326,
0.7649658018390721,
0.7655208469831534,
0.7660754367851285,
0.7666295702939305,
0.7671832465592745,
0.7677364646316607,
0.7682892235623748,
0.7688415224034891,
0.7693933602078658,
0.7699447360291576,
0.7704956489218091,
0.7710460979410585,
0.7715960821429403,
0.772145600584286,
0.7726946523227252,
0.7732432364166881,
0.7737913519254078,
0.7743389979089197,
0.7748861734280639,
0.7754328775444901,
0.7759791093206535,
0.7765248678198202,
0.7770701521060686,
0.7776149612442899,
0.7781592943001899,
0.7787031503402904,
0.779246528431933,
0.7797894276432773,
0.780331847043304,
0.780873785701818,
0.781415242689448,
0.7819562170776477,
0.7824967079387,
0.7830367143457163,
0.7835762353726387,
0.7841152700942413,
0.7846538175861328,
0.7851918769247581,
0.7857294471873975,
0.786266527452171,
0.7868031167980395,
0.7873392143048047,
0.7878748190531117,
0.7884099301244517,
0.788944546601162,
0.7894786675664274,
0.7900122921042834,
0.7905454192996169,
0.7910780482381666,
0.7916101780065259,
0.792141807692146,
0.7926729363833336,
0.7932035631692549,
0.7937336871399376,
0.7942633073862717,
0.7947924230000099,
0.7953210330737713,
0.7958491367010422,
0.7963767329761764,
0.7969038209943977,
0.7974303998518029,
0.7979564686453611,
0.7984820264729153,
0.7990070724331864,
0.7995316056257722,
0.8000556251511498,
0.8005791301106768,
0.8011021196065944,
0.8016245927420271,
0.8021465486209844,
0.8026679863483637,
0.803188905029951,
0.8037093037724217,
0.8042291816833429,
0.8047485378711754,
0.8052673714452749,
0.8057856815158922,
0.8063034671941771,
0.8068207275921782,
0.8073374618228446,
0.8078536690000273,
0.8083693482384833,
0.8088844986538728,
0.809399119362763,
0.8099132094826306,
0.810426768131862,
0.8109397944297538,
0.8114522874965171,
0.8119642464532768,
0.8124756704220736,
0.8129865585258652,
0.8134969098885292,
0.8140067236348638,
0.8145159988905877,
0.8150247347823445,
0.8155329304377024,
0.8160405849851557,
0.8165476975541264,
0.8170542672749669,
0.8175602932789602,
0.8180657746983209,
0.8185707106661984,
0.8190751003166776,
0.8195789427847797,
0.820082237206464,
0.8205849827186307,
0.8210871784591207,
0.8215888235667175,
0.8220899171811491,
0.82259045844309,
0.8230904464941605,
0.8235898804769299,
0.8240887595349196,
0.8245870828126001,
0.8250848494553958,
0.8255820586096865,
0.8260787094228075,
0.8265748010430511,
0.8270703326196692,
0.8275653033028745,
0.8280597122438405,
0.8285535585947041,
0.8290468415085681,
0.829539560139501,
0.8300317136425384,
0.8305233011736854,
0.8310143218899186,
0.8315047749491853,
0.8319946595104063,
0.8324839747334785,
0.8329727197792745,
0.8334608938096442,
0.8339484959874175,
0.8344355254764049,
0.8349219814413985,
0.835407863048174,
0.8358931694634926,
0.8363778998551018,
0.8368620533917361,
0.8373456292431203,
0.8378286265799697,
0.838311044573991,
0.8387928823978842,
0.8392741392253462,
0.8397548142310685,
0.8402349065907402,
0.8407144154810506,
0.8411933400796896,
0.8416716795653478,
0.8421494331177206,
0.842626599917508,
0.8431031791464154,
0.8435791699871563,
0.8440545716234535,
0.8445293832400403,
0.845003604022661,
0.8454772331580738,
0.8459502698340517,
0.8464227132393833,
0.8468945625638742,
0.8473658169983495,
0.8478364757346546,
0.8483065379656557,
0.8487760028852425,
0.8492448696883291,
0.8497131375708551,
0.8501808057297866,
0.8506478733631191,
0.8511143396698782,
0.851580203850119,
0.8520454651049311,
0.8525101226364372,
0.8529741756477953,
0.8534376233431996,
0.8539004649278841,
0.8543626996081203,
0.8548243265912211,
0.855285345085542,
0.8557457543004818,
0.8562055534464836,
0.8566647417350375,
0.857123318378681,
0.857581282591,
0.8580386335866306,
0.8584953705812614,
0.8589514927916335,
0.8594069994355418,
0.8598618897318373,
0.8603161629004286,
0.8607698181622814,
0.8612228547394214,
0.8616752718549358,
0.8621270687329738,
0.8625782445987482,
0.8630287986785365,
0.8634787301996837,
0.8639280383906008,
0.8643767224807681,
0.8648247817007378,
0.8652722152821317,
0.8657190224576452,
0.8661652024610481,
0.866610754527186,
0.8670556778919806,
0.8674999717924317,
0.8679436354666199,
0.8683866681537056,
0.8688290690939305,
0.8692708375286213,
0.8697119727001887,
0.8701524738521289,
0.8705923402290259,
0.8710315710765525,
0.8714701656414708,
0.8719081231716341,
0.8723454429159885,
0.8727821241245741,
0.8732181660485252,
0.8736535679400728,
0.8740883290525459,
0.8745224486403719,
0.874955925959078,
0.8753887602652937,
0.8758209508167508,
0.8762524968722849,
0.8766833976918369,
0.8771136525364549,
0.8775432606682938,
0.8779722213506175,
0.8784005338478016,
0.8788281974253319,
0.8792552113498072,
0.879681574888941,
0.880107287311562,
0.8805323478876147,
0.8809567558881626,
0.8813805105853877,
0.8818036112525924,
0.8822260571642004,
0.8826478475957589,
0.8830689818239388,
0.8834894591265362,
0.883909278782474,
0.8843284400718032,
0.884746942275703,
0.8851647846764834,
0.8855819665575859,
0.8859984872035849,
0.8864143459001879,
0.8868295419342387,
0.8872440745937169,
0.8876579431677399,
0.8880711469465634,
0.888483685221584,
0.8888955572853392,
0.8893067624315087,
0.8897172999549163,
0.8901271691515309,
0.8905363693184669,
0.8909448997539856,
0.8913527597574988,
0.8917599486295664,
0.8921664656718988,
0.8925723101873602,
0.8929774814799669,
0.8933819788548898,
0.8937858016184559,
0.8941889490781494,
0.8945914205426115,
0.8949932153216433,
0.8953943327262065,
0.8957947720684245,
0.8961945326615826,
0.8965936138201311,
0.8969920148596856,
0.897389735097027,
0.897786773850104,
0.8981831304380347,
0.8985788041811067,
0.8989737944007778,
0.8993681004196794,
0.8997617215616154,
0.9001546571515642,
0.9005469065156795,
0.9009384689812927,
0.901329343876913,
0.9017195305322278,
0.9021090282781057,
0.9024978364465968,
0.9028859543709331,
0.9032733813855298,
0.9036601168259891,
0.9040461600290971,
0.9044315103328275,
0.9048161670763427,
0.9052001295999946,
0.9055833972453247,
0.905965969355067,
0.9063478452731484,
0.9067290243446887,
0.9071095059160034,
0.9074892893346042,
0.9078683739492002,
0.9082467591096981,
0.9086244441672049,
0.9090014284740281,
0.9093777113836765,
0.9097532922508619,
0.9101281704315001,
0.9105023452827122,
0.9108758161628248,
0.9112485824313723,
0.9116206434490977,
0.9119919985779523,
0.9123626471810988,
0.9127325886229114,
0.9131018222689771,
0.9134703474860963,
0.9138381636422848,
0.9142052701067741,
0.9145716662500127,
0.9149373514436667,
0.9153023250606231,
0.9156665864749876,
0.9160301350620874,
0.9163929701984728,
0.9167550912619173,
0.9171164976314188,
0.917477188687201,
0.9178371638107145,
0.9181964223846372,
0.9185549637928757,
0.9189127874205671,
0.9192698926540795,
0.9196262788810119,
0.9199819454901974,
0.9203368918717029,
0.9206911174168301,
0.921044621518117,
0.9213974035693386,
0.9217494629655094,
0.9221007991028812,
0.9224514113789476,
0.9228012991924431,
0.9231504619433446,
0.9234988990328716,
0.92384660986349,
0.9241935938389093,
0.924539850364086,
0.9248853788452245,
0.9252301786897776,
0.9255742493064476,
0.9259175901051864,
0.9262602004971995,
0.9266020798949433,
0.9269432277121281,
0.9272836433637193,
0.9276233262659375,
0.9279622758362598,
0.9283004914934212,
0.9286379726574154,
0.9289747187494952,
0.9293107291921741,
0.9296460034092271,
0.9299805408256927,
0.9303143408678713,
0.9306474029633293,
0.9309797265408979,
0.9313113110306748,
0.9316421558640249,
0.9319722604735823,
0.9323016242932503,
0.9326302467582019,
0.9329581273048821,
0.9332852653710082,
0.9336116603955706,
0.9339373118188337,
0.9342622190823378,
0.9345863816288986,
0.9349097989026092,
0.935232470348841,
0.9355543954142445,
0.9358755735467494,
0.936196004195567,
0.9365156868111908,
0.9368346208453959,
0.9371528057512419,
0.9374702409830733,
0.9377869259965201,
0.9381028602484982,
0.9384180431972117,
0.938732474302153,
0.9390461530241037,
0.9393590788251354,
0.9396712511686112,
0.9399826695191867,
0.9402933333428096,
0.9406032421067223,
0.9409123952794619,
0.941220792330861,
0.9415284327320488,
0.9418353159554524,
0.9421414414747977,
0.9424468087651091,
0.942751417302712,
0.9430552665652328,
0.9433583560315999,
0.9436606851820442,
0.9439622534981019,
0.9442630604626125,
0.9445631055597217,
0.9448623882748814,
0.9451609080948521,
0.9454586645077008,
0.945755657002805,
0.9460518850708519,
0.9463473482038395,
0.9466420458950772,
0.9469359776391878,
0.9472291429321075,
0.9475215412710862,
0.94781317215469,
0.9481040350828005,
0.9483941295566165,
0.9486834550786543,
0.9489720111527491,
0.949259797284056,
0.9495468129790499,
0.949833057745527,
0.9501185310926061,
0.9504032325307284,
0.9506871615716587,
0.9509703177284867,
0.9512527005156279,
0.9515343094488231,
0.951815144045141,
0.952095203822978,
0.9523744883020591,
0.9526529970034383,
0.9529307294495016,
0.9532076851639648,
0.9534838636718759,
0.953759264499616,
0.9540338871749001,
0.9543077312267771,
0.9545807961856315,
0.9548530815831839,
0.9551245869524916,
0.9553953118279493,
0.9556652557452909,
0.9559344182415891,
0.9562027988552564,
0.9564703971260469,
0.9567372125950557,
0.9570032448047208,
0.9572684932988227,
0.9575329576224865,
0.9577966373221822,
0.9580595319457248,
0.9583216410422761,
0.9585829641623447,
0.9588435008577874,
0.9591032506818089,
0.9593622131889641,
0.9596203879351581,
0.9598777744776463,
0.9601343723750362,
0.9603901811872877,
0.960645200475714,
0.9608994298029816,
0.961152868733113,
0.961405516831485,
0.9616573736648308,
0.9619084388012411,
0.9621587118101638,
0.9624081922624053,
0.9626568797301309,
0.9629047737868667,
0.9631518740074985,
0.9633981799682734,
0.9636436912468014,
0.9638884074220548,
0.9641323280743692,
0.9643754527854449,
0.964617781138347,
0.9648593127175061,
0.9651000471087193,
0.9653399838991509,
0.965579122677333,
0.965817463033166,
0.9660550045579197,
0.966291746844234,
0.9665276894861189,
0.9667628320789559,
0.9669971742194989,
0.9672307155058744,
0.9674634555375815,
0.9676953939154943,
0.9679265302418615,
0.9681568641203068,
0.96838639515583,
0.9686151229548086,
0.9688430471249967,
0.9690701672755266,
0.9692964830169097,
0.969521993961037,
0.9697466997211792,
0.9699705999119881,
0.9701936941494971,
0.9704159820511213,
0.9706374632356589,
0.9708581373232915,
0.9710780039355849,
0.9712970626954893,
0.9715153132273406,
0.9717327551568606,
0.971949388111158,
0.9721652117187283,
0.9723802256094554,
0.9725944294146118,
0.9728078227668587,
0.9730204053002478,
0.9732321766502211,
0.9734431364536114,
0.9736532843486432,
0.973862619974934,
0.9740711429734935,
0.9742788529867253,
0.9744857496584274,
0.9746918326337922,
0.9748971015594077,
0.9751015560832579,
0.9753051958547236,
0.9755080205245827,
0.9757100297450103,
0.975911223169581,
0.9761116004532678,
0.9763111612524433,
0.9765099052248803,
0.9767078320297529,
0.9769049413276356,
0.9771012327805054,
0.9772967060517421,
0.9774913608061282,
0.9776851967098497,
0.9778782134304973,
0.9780704106370666,
0.978261787999958,
0.9784523451909781,
0.9786420818833402,
0.9788309977516647,
0.9790190924719793,
0.97920636572172,
0.9793928171797319,
0.979578446526269,
0.979763253442995,
0.9799472376129845,
0.9801303987207228,
0.9803127364521065,
0.9804942504944444,
0.9806749405364579,
0.980854806268281,
0.9810338473814622,
0.9812120635689632,
0.981389454525161,
0.9815660199458475,
0.9817417595282303,
0.9819166729709337,
0.9820907599739979,
0.9822640202388809,
0.9824364534684589,
0.9826080593670253,
0.9827788376402932,
0.9829487879953944,
0.9831179101408813,
0.9832862037867256,
0.9834536686443203,
0.98362030442648,
0.9837861108474404,
0.9839510876228599,
0.9841152344698195,
0.9842785511068238,
0.9844410372538006,
0.9846026926321023,
0.9847635169645057,
0.9849235099752132,
0.985082671389852,
0.9852410009354765,
0.9853984983405668,
0.9855551633350306,
0.9857109956502026,
0.9858659950188458,
0.9860201611751516,
0.9861734938547402,
0.9863259927946613,
0.986477657733394,
0.986628488410848,
0.9867784845683635,
0.986927645948712,
0.987075972296096,
0.9872234633561507,
0.9873701188759437,
0.9875159386039749,
0.987660922290178,
0.98780506968592,
0.9879483805440026,
0.9880908546186615,
0.988232491665568,
0.9883732914418284,
0.9885132537059849,
0.9886523782180159,
0.9887906647393367,
0.9889281130327997,
0.9890647228626943,
0.9892004939947481,
0.9893354261961274,
0.9894695192354362,
0.9896027728827184,
0.9897351869094573,
0.9898667610885756,
0.9899974951944366,
0.9901273890028442,
0.9902564422910435,
0.9903846548377204,
0.9905120264230034,
0.9906385568284628,
0.9907642458371111,
0.990889093233404,
0.9910130988032408,
0.9911362623339642,
0.9912585836143606,
0.9913800624346611,
0.9915006985865417,
0.9916204918631231,
0.9917394420589716,
0.9918575489700993,
0.9919748123939647,
0.9920912321294723,
0.9922068079769739,
0.9923215397382683,
0.9924354272166018,
0.9925484702166684,
0.9926606685446109,
0.9927720220080198,
0.9928825304159351,
0.9929921935788457,
0.9931010113086901,
0.9932089834188567,
0.9933161097241836,
0.9934223900409602,
0.9935278241869261,
0.9936324119812718,
0.9937361532446398,
0.9938390477991241,
0.9939410954682706,
0.9940422960770776,
0.994142649451996,
0.9942421554209296,
0.9943408138132356,
0.9944386244597243,
0.9945355871926604,
0.9946317018457622,
0.9947269682542026,
0.994821386254609,
0.9949149556850639,
0.9950076763851049,
0.995099548195725,
0.9951905709593735,
0.9952807445199549,
0.9953700687228305,
0.9954585434148183,
0.9955461684441929,
0.9956329436606856,
0.9957188689154859,
0.9958039440612402,
0.9958881689520531,
0.9959715434434873,
0.9960540673925635,
0.9961357406577616,
0.9962165630990195,
0.9962965345777353,
0.9963756549567653,
0.996453924100426,
0.9965313418744934,
0.9966079081462039,
0.9966836227842537,
0.9967584856587998,
0.9968324966414596,
0.9969056556053115,
0.9969779624248953,
0.9970494169762117,
0.9971200191367233,
0.9971897687853544,
0.9972586658024911,
0.9973267100699819,
0.9973939014711375,
0.9974602398907313,
0.9975257252149994,
0.9975903573316409,
0.9976541361298182,
0.9977170615001569,
0.9977791333347462,
0.997840351527139,
0.997900715972352,
0.9979602265668663,
0.998018883208627,
0.9980766857970438,
0.9981336342329908,
0.9981897284188073,
0.998244968258297,
0.9982993536567293,
0.9983528845208384,
0.9984055607588241,
0.9984573822803521,
0.9985083489965534,
0.9985584608200251,
0.9986077176648303,
0.9986561194464985,
0.9987036660820254,
0.9987503574898731,
0.9987961935899705,
0.9988411743037133,
0.9988852995539639,
0.9989285692650516,
0.9989709833627736,
0.9990125417743936,
0.9990532444286431,
0.9990930912557209,
0.9991320821872938,
0.999170217156496,
0.99920749609793,
0.9992439189476661,
0.9992794856432425,
0.999314196123666,
0.9993480503294114,
0.9993810482024221,
0.99941318968611,
0.9994444747253558,
0.9994749032665085,
0.9995044752573863,
0.999533190647276,
0.9995610493869336,
0.9995880514285841,
0.9996141967259218,
0.9996394852341098,
0.9996639169097811,
0.9996874917110377,
0.9997102095974508,
0.9997320705300621,
0.9997530744713817,
0.9997732213853902,
0.9997925112375374,
0.9998109439947434,
0.9998285196253976,
0.9998452380993597,
0.9998610993879589,
0.9998761034639949,
0.9998902503017371,
0.9999035398769252,
0.9999159721667685,
0.9999275471499472,
0.9999382648066113,
0.999948125118381,
0.9999571280683468,
0.9999652736410698,
0.9999725618225808,
0.9999789926003813,
0.9999845659634434,
0.9999892819022091,
0.9999931404085911,
0.9999961414759726,
0.9999982850992069,
0.9999995712746179,
1.0,
| 49,004
|
C++
|
.inc
| 2,400
| 19.418333
| 25
| 0.896983
|
monome/softcut-lib
| 34
| 6
| 10
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,432
|
stack_dump.cpp
|
nettigo_namf/src/stack_dump.cpp
|
#include "stack_dump.h"
extern "C" void custom_crash_callback(struct rst_info *rst_info, uint32_t stack, uint32_t stack_end) {
cont_t g_cont __attribute__ ((aligned (16)));
File out;
boolean dump = true;
noInterrupts();
out = SPIFFS.open("/stack_dump", "w");
time_t now = time(nullptr);
char tmp[48];
strncpy(tmp, ctime(&now), 47);
out.print(tmp);
out.println(SOFTWARE_VERSION);
out.println(INTL_LANG);
out.println(ESP.getSketchMD5());
out.println();
uint32_t cont_stack_start = (uint32_t) &(g_cont.stack);
uint32_t cont_stack_end = (uint32_t) g_cont.stack_end;
uint32_t offset = 0;
switch (rst_info->reason) {
case REASON_SOFT_WDT_RST:
offset = 0x1b0;
out.println(F("Soft WDT reset"));
break;
case REASON_EXCEPTION_RST:
offset = 0x1a0;
snprintf(tmp, 47, "Exception (%i):\nepc1=0x%08x epc2=0x%08x",
rst_info->exccause, rst_info->epc1, rst_info->epc2
);
out.print(tmp);
snprintf(tmp, 47, " epc3=0x%08x excvaddr=0x%08x", rst_info->epc2, rst_info->excvaddr);
out.print(tmp);
snprintf(tmp, 47, " depc=0x%08x", rst_info->depc);
out.println(tmp);
break;
case REASON_WDT_RST:
offset = 0x10;
out.println(F("wdt_reset"));
dump = false;
break;
default:
snprintf(tmp,47,"Unknown reset cause: %i", rst_info->reason);
out.println(tmp);
}
out.println(F("\n>>>stack>>>\n"));
if (stack - offset > cont_stack_start && stack - offset < cont_stack_end) {
out.println("ctx: cont");
} else {
out.println("ctx: sys");
}
//Hardware WDT reset does not dump stack on serial...
if (dump) {
snprintf(tmp, 47, "sp: %08x end: %08x offset: %04x\n", stack - offset, stack_end, offset);
out.print(tmp);
for (uint32_t pos = stack; pos < stack_end; pos += 0x10) {
uint32_t *values = (uint32_t *) (pos);
//rough indicator: stack frames usually have SP saved as the second word
bool looksLikeStackFrame = (values[2] == pos + 0x10);
snprintf(tmp, 47, "%08x: %08x %08x %08x %08x %c", pos, values[0], values[1], values[2], values[3],
(looksLikeStackFrame) ? '<' : ' ');
out.println(tmp);
}
out.println(F("<<<stack<<<\n\n\n\n\n\n"));
}
out.close();
interrupts();
delay(30);
}
| 2,557
|
C++
|
.cpp
| 67
| 29.402985
| 111
| 0.549839
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,433
|
main.cpp
|
nettigo_namf/src/main.cpp
|
#include <Arduino.h>
/*****************************************************************
* Includes *
*****************************************************************/
#include "defines.h"
#include "variables.h"
#include <Schedule.h>
#include "variables_init.h"
#include "update.h"
#include "helpers.h"
#include "system/scheduler.h"
#include "system/components.h"
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <base64.h>
#include <ArduinoJson.h>
#include <time.h>
#include <coredecls.h>
#include <assert.h>
#include "system/reporting.h"
#include "html-content.h"
#include "webserver.h"
#include "sending.h"
#include "sensors/sds011/sds011.h"
//#include "sensors/bme280.h"
#include "sensors/dht.h"
#include "display/commons.h"
#include "display/ledbar.h"
SimpleScheduler::NAMFScheduler scheduler;
unsigned long PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS;
/*****************************************************************
* send Plantower PMS sensor command start, stop, cont. mode *
*****************************************************************/
static bool PMS_cmd(PmSensorCmd cmd) {
static constexpr uint8_t start_cmd[] PROGMEM = {
0x42, 0x4D, 0xE4, 0x00, 0x01, 0x01, 0x74
};
static constexpr uint8_t stop_cmd[] PROGMEM = {
0x42, 0x4D, 0xE4, 0x00, 0x00, 0x01, 0x73
};
static constexpr uint8_t continuous_mode_cmd[] PROGMEM = {
0x42, 0x4D, 0xE1, 0x00, 0x01, 0x01, 0x71
};
constexpr uint8_t cmd_len = array_num_elements(start_cmd);
uint8_t buf[cmd_len];
switch (cmd) {
case PmSensorCmd::Start:
memcpy_P(buf, start_cmd, cmd_len);
break;
case PmSensorCmd::Stop:
memcpy_P(buf, stop_cmd, cmd_len);
break;
case PmSensorCmd::ContinuousMode:
memcpy_P(buf, continuous_mode_cmd, cmd_len);
break;
case PmSensorCmd::VersionDate:
assert(false && "not supported by this sensor");
break;
}
serialSDS.write(buf, cmd_len);
return cmd != PmSensorCmd::Stop;
}
/*****************************************************************
* disable unneeded NMEA sentences, TinyGPS++ needs GGA, RMC *
*****************************************************************/
void disable_unneeded_nmea() {
serialGPS.println(F("$PUBX,40,GLL,0,0,0,0*5C")); // Geographic position, latitude / longitude
// serialGPS.println(F("$PUBX,40,GGA,0,0,0,0*5A")); // Global Positioning System Fix Data
serialGPS.println(F("$PUBX,40,GSA,0,0,0,0*4E")); // GPS DOP and active satellites
// serialGPS.println(F("$PUBX,40,RMC,0,0,0,0*47")); // Recommended minimum specific GPS/Transit data
serialGPS.println(F("$PUBX,40,GSV,0,0,0,0*59")); // GNSS satellites in view
serialGPS.println(F("$PUBX,40,VTG,0,0,0,0*5E")); // Track made good and ground speed
}
//This is meant to be run on first time. Not only sets default values for sensors, but also makes sure
//that pointers are properly inited
void setDefaultConfig(void) {
//init
debug_out(F("Set defaults"), DEBUG_MIN_INFO, 1);
stringToChar(&cfg::www_username, FPSTR(WWW_USERNAME));
stringToChar(&cfg::www_password, FPSTR(WWW_PASSWORD));
stringToChar(&cfg::wlanssid, FPSTR(EMPTY_STRING));
stringToChar(&cfg::wlanpwd, FPSTR(EMPTY_STRING));
stringToChar(&cfg::fbssid, FPSTR(EMPTY_STRING));
stringToChar(&cfg::fbpwd, FPSTR(EMPTY_STRING));
stringToChar(&cfg::user_custom, FPSTR(USER_CUSTOM));
stringToChar(&cfg::pwd_custom, FPSTR(PWD_CUSTOM));
stringToChar(&cfg::pwd_influx, FPSTR(EMPTY_STRING));
stringToChar(&cfg::user_influx, FPSTR(EMPTY_STRING));
SDS011::setDefaults();
HECA::setDefaults();
// BMPx80::setDefaults();
BME280::setDefaults();
// SHT3x::setDefaults();
}
/*****************************************************************
* read config from spiffs *
*****************************************************************/
void readConfig() {
setDefaultConfig();
debug_out(F("mounting FS: "), DEBUG_MIN_INFO, 0);
if (SPIFFS.begin()) {
debug_out(F("OK"), DEBUG_MIN_INFO, 1);
if (SPIFFS.exists("/config.json")) {
//file exists, reading and loading
debug_out(F("reading config"), DEBUG_MED_INFO, 1);
File configFile = SPIFFS.open("/config.json", "r");
if (!readAndParseConfigFile(configFile)){
//not failed opening & reading
debug_out(F("Config parsed"), DEBUG_MIN_INFO, true);
}else{
debug_out(F("FAILED config parsing and loading"), DEBUG_ERROR, true);
setDefaultConfig();
};
} else {
debug_out(F("config file not found ..."), DEBUG_ERROR, 1);
}
} else {
debug_out(F("\nFailed mount FS!"), DEBUG_ERROR, 1);
}
}
String tmpl(const String& patt, const String& value) {
String s = patt;
s.replace("{v}", value);
return s;
}
String tmpl(const String& patt, const String& value1, const String& value2) {
String s = patt;
s.replace("{v1}", value1);
s.replace("{v2}", value2);
return s;
}
String tmpl(const String& patt, const String& value1, const String& value2, const String& value3) {
String s = patt;
s.replace("{v1}", value1);
s.replace("{v2}", value2);
s.replace("{v3}", value3);
return s;
}
String add_sensor_type(const String& sensor_text) {
String s = sensor_text;
s.replace("{pm}", FPSTR(INTL_PARTICULATE_MATTER));
s.replace("{t}", FPSTR(INTL_TEMPERATURE));
s.replace("{h}", FPSTR(INTL_HUMIDITY));
s.replace("{p}", FPSTR(INTL_PRESSURE));
return s;
}
static int selectChannelForAp(struct struct_wifiInfo *info, int count) {
std::array<int, 14> channels_rssi;
std::fill(channels_rssi.begin(), channels_rssi.end(), -100);
for (int i = 0; i < count; i++) {
if (info[i].RSSI > channels_rssi[info[i].channel]) {
channels_rssi[info[i].channel] = info[i].RSSI;
}
}
if ((channels_rssi[1] < channels_rssi[6]) && (channels_rssi[1] < channels_rssi[11])) {
return 1;
} else if ((channels_rssi[6] < channels_rssi[1]) && (channels_rssi[6] < channels_rssi[11])) {
return 6;
} else {
return 11;
}
}
/*****************************************************************
* WifiConfig *
*****************************************************************/
void wifiConfig() {
debug_out(F("Starting WiFiManager"), DEBUG_MIN_INFO, 1);
debug_out(F("AP ID: "), DEBUG_MIN_INFO, 0);
debug_out(cfg::fs_ssid, DEBUG_MIN_INFO, 1);
debug_out(F("Password: "), DEBUG_MIN_INFO, 0);
debug_out(cfg::fs_pwd, DEBUG_MIN_INFO, 1);
wificonfig_loop = true;
WiFi.disconnect(true);
debug_out(F("scan for wifi networks..."), DEBUG_MIN_INFO, 1);
count_wifiInfo = WiFi.scanNetworks(false, true);
wifiInfo = new struct_wifiInfo[count_wifiInfo];
for (int i = 0; i < count_wifiInfo; i++) {
uint8_t* BSSID;
String SSID;
WiFi.getNetworkInfo(i, SSID, wifiInfo[i].encryptionType, wifiInfo[i].RSSI, BSSID, wifiInfo[i].channel, wifiInfo[i].isHidden);
SSID.toCharArray(wifiInfo[i].ssid, 35);
}
WiFi.mode(WIFI_AP);
const IPAddress apIP(192, 168, 4, 1);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
if (cfg::fs_pwd == nullptr || !strcmp(cfg::fs_pwd, "")) {
debug_out(F("Starting AP with default password"), DEBUG_MIN_INFO);
WiFi.softAP(cfg::fs_ssid, "nettigo.pl", selectChannelForAp(wifiInfo, count_wifiInfo));
} else {
WiFi.softAP(cfg::fs_ssid, cfg::fs_pwd, selectChannelForAp(wifiInfo, count_wifiInfo));
}
DNSServer dnsServer;
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(53, "*", apIP); // 53 is port for DNS server
// 10 minutes timeout for wifi config
last_page_load = millis();
while (((millis() - last_page_load) < cfg::time_for_wifi_config)) {
dnsServer.processNextRequest();
server.handleClient();
wdt_reset(); // nodemcu is alive
yield();
}
// half second to answer last requests
last_page_load = millis();
while ((millis() - last_page_load) < 500) {
dnsServer.processNextRequest();
server.handleClient();
yield();
}
WiFi.disconnect(true);
WiFi.softAPdisconnect(true);
WiFi.mode(WIFI_STA);
delete []wifiInfo;
dnsServer.stop();
delay(100);
debug_out(F("Connecting to "), DEBUG_MIN_INFO, 0);
debug_out(cfg::wlanssid, DEBUG_MIN_INFO, 1);
// we could set hostname also here
WiFi.begin(cfg::wlanssid, cfg::wlanpwd);
debug_out(F("---- Result Webconfig ----"), DEBUG_MIN_INFO, 1);
debug_out(F("WLANSSID: "), DEBUG_MIN_INFO, 0);
debug_out(cfg::wlanssid, DEBUG_MIN_INFO, 1);
debug_out(F("----\nReading ..."), DEBUG_MIN_INFO, 1);
debug_out(F("SDS: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::sds_read), DEBUG_MIN_INFO, 1);
debug_out(F("PMS: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::pms_read), DEBUG_MIN_INFO, 1);
debug_out(F("DHT: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::dht_read), DEBUG_MIN_INFO, 1);
debug_out(F("DS18B20: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::ds18b20_read), DEBUG_MIN_INFO, 1);
debug_out(F("----\nSend to ..."), DEBUG_MIN_INFO, 1);
debug_out(F("Dusti: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::send2dusti), DEBUG_MIN_INFO, 1);
debug_out(F("Madavi: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::send2madavi), DEBUG_MIN_INFO, 1);
debug_out(F("CSV: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::send2csv), DEBUG_MIN_INFO, 1);
debug_out("----", DEBUG_MIN_INFO, 1);
debug_out(F("Autoupdate: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::auto_update), DEBUG_MIN_INFO, 1);
debug_out(F("Display: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::has_display), DEBUG_MIN_INFO, 1);
debug_out(F("LCD 1602: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::has_lcd1602), DEBUG_MIN_INFO, 1);
debug_out(F("Debug: "), DEBUG_MIN_INFO, 0);
debug_out(String(cfg::debug), DEBUG_MIN_INFO, 1);
wificonfig_loop = false;
}
static void waitForWifiToConnect(int maxRetries) {
int retryCount = 0;
while ((WiFi.status() != WL_CONNECTED) && (retryCount < maxRetries)) {
delay(500);
debug_out(".", DEBUG_MIN_INFO, 0);
++retryCount;
}
}
/*****************************************************************
* Start WiFi in AP mode (for configuration)
*****************************************************************/
void startAP(void) {
String fss = String(cfg::fs_ssid);
display_debug(fss.substring(0, 16), fss.substring(16));
wifiConfig();
if (WiFi.status() != WL_CONNECTED) {
waitForWifiToConnect(20);
debug_out("", DEBUG_MIN_INFO, 1);
}
}
/*****************************************************************
* WiFi auto connecting script *
*****************************************************************/
void connectWifi() {
display_debug(F("Connecting to"), String(cfg::wlanssid));
debug_out(F("SSID: '"), DEBUG_ERROR, 0);
debug_out(cfg::wlanssid, DEBUG_ERROR, 0);
debug_out(F("'"), DEBUG_ERROR, 1);
debug_out(String(WiFi.status()), DEBUG_MIN_INFO, 1);
WiFi.disconnect();
WiFi.setOutputPower(cfg::outputPower);
WiFi.setPhyMode(WIFI_PHY_MODE_11N);
WiFi.setPhyMode((WiFiPhyMode_t)cfg::phyMode);
WiFi.mode(WIFI_STA);
//String hostname = F("NAM-");
//hostname += esp_chipid();
//WiFi.hostname(hostname.c_str()); // Hostname for DHCP Server.
WiFi.hostname(cfg::fs_ssid); // Hostname for DHCP Server
WiFi.begin(cfg::wlanssid, cfg::wlanpwd); // Start WiFI
waitForWifiToConnect(40);
debug_out("", DEBUG_MIN_INFO, 1);
if (WiFi.status() != WL_CONNECTED) {
if (strlen(cfg::fbssid)) {
display_debug(F("Connecting to"), String(cfg::fbssid));
debug_out(F("Failed to connect to WiFi. Trying to connect to fallback WiFi"), DEBUG_ERROR);
debug_out(cfg::fbssid, DEBUG_ERROR);
WiFi.begin(cfg::fbssid, cfg::fbpwd); // Start WiFI
waitForWifiToConnect(40);
}
if (WiFi.status() != WL_CONNECTED)
startAP();
}
debug_out(F("WiFi connected\nIP address: "), DEBUG_MIN_INFO, 0);
debug_out(WiFi.localIP().toString(), DEBUG_MIN_INFO, 1);
}
/*****************************************************************
* read DS18B20 sensor values *
*****************************************************************/
static String sensorDS18B20() {
double t;
debug_out(String(FPSTR(DBG_TXT_START_READING)) + FPSTR(SENSORS_DS18B20), DEBUG_MED_INFO, 1);
//it's very unlikely (-127: impossible) to get these temperatures in reality. Most times this means that the sensor is currently faulty
//try 5 times to read the sensor, otherwise fail
const int MAX_ATTEMPTS = 5;
int count = 0;
do {
ds18b20.requestTemperatures();
//for now, we want to read only the first sensor
t = ds18b20.getTempCByIndex(0);
++count;
debug_out(F("DS18B20 trying...."), DEBUG_MIN_INFO, 0);
debug_out(String(count), DEBUG_MIN_INFO, 1);
} while (count < MAX_ATTEMPTS && (isnan(t) || t >= 85.0 || t <= (-127.0)));
String s;
if (count == MAX_ATTEMPTS) {
last_value_DS18B20_T = -128.0;
debug_out(String(FPSTR(SENSORS_DS18B20)) + FPSTR(DBG_TXT_COULDNT_BE_READ), DEBUG_ERROR, 1);
} else {
debug_out(FPSTR(DBG_TXT_TEMPERATURE), DEBUG_MIN_INFO, 0);
debug_out(Float2String(t) + " C", DEBUG_MIN_INFO, 1);
last_value_DS18B20_T = t;
s += Value2Json(F("DS18B20_temperature"), Float2String(last_value_DS18B20_T));
}
debug_out("----", DEBUG_MIN_INFO, 1);
debug_out(String(FPSTR(DBG_TXT_END_READING)) + FPSTR(SENSORS_DS18B20), DEBUG_MED_INFO, 1);
return s;
}
/*****************************************************************
* read Plantronic PM sensor sensor values *
*****************************************************************/
String sensorPMS() {
String s = "";
char buffer;
int value;
int len = 0;
int pm1_serial = 0;
int pm10_serial = 0;
int pm25_serial = 0;
int checksum_is = 0;
int checksum_should = 0;
int checksum_ok = 0;
int frame_len = 24; // min. frame length
debug_out(String(FPSTR(DBG_TXT_START_READING)) + FPSTR(SENSORS_PMSx003), DEBUG_MED_INFO, 1);
if (msSince(starttime) < (cfg::sending_intervall_ms - (WARMUPTIME_SDS_MS + READINGTIME_SDS_MS))) {
if (is_PMS_running) {
is_PMS_running = PMS_cmd(PmSensorCmd::Stop);
}
} else {
if (! is_PMS_running) {
is_PMS_running = PMS_cmd(PmSensorCmd::Start);
}
while (serialSDS.available() > 0) {
buffer = serialSDS.read();
debug_out(String(len) + " - " + String(buffer, DEC) + " - " + String(buffer, HEX) + " - " + int(buffer) + " .", DEBUG_MAX_INFO, 1);
// "aa" = 170, "ab" = 171, "c0" = 192
value = int(buffer);
switch (len) {
case (0):
if (value != 66) {
len = -1;
};
break;
case (1):
if (value != 77) {
len = -1;
};
break;
case (2):
checksum_is = value;
break;
case (3):
frame_len = value + 4;
break;
case (10):
pm1_serial += ( value << 8);
break;
case (11):
pm1_serial += value;
break;
case (12):
pm25_serial = ( value << 8);
break;
case (13):
pm25_serial += value;
break;
case (14):
pm10_serial = ( value << 8);
break;
case (15):
pm10_serial += value;
break;
case (22):
if (frame_len == 24) {
checksum_should = ( value << 8 );
};
break;
case (23):
if (frame_len == 24) {
checksum_should += value;
};
break;
case (30):
checksum_should = ( value << 8 );
break;
case (31):
checksum_should += value;
break;
}
if ((len > 2) && (len < (frame_len - 2))) { checksum_is += value; }
len++;
if (len == frame_len) {
debug_out(FPSTR(DBG_TXT_CHECKSUM_IS), DEBUG_MED_INFO, 0);
debug_out(String(checksum_is + 143), DEBUG_MED_INFO, 0);
debug_out(FPSTR(DBG_TXT_CHECKSUM_SHOULD), DEBUG_MED_INFO, 0);
debug_out(String(checksum_should), DEBUG_MED_INFO, 1);
if (checksum_should == (checksum_is + 143)) {
checksum_ok = 1;
} else {
len = 0;
};
if (checksum_ok == 1 && (msSince(starttime) > (cfg::sending_intervall_ms - READINGTIME_SDS_MS))) {
if ((! isnan(pm1_serial)) && (! isnan(pm10_serial)) && (! isnan(pm25_serial))) {
pms_pm1_sum += pm1_serial;
pms_pm10_sum += pm10_serial;
pms_pm25_sum += pm25_serial;
if (pms_pm1_min > pm10_serial) {
pms_pm1_min = pm1_serial;
}
if (pms_pm1_max < pm10_serial) {
pms_pm1_max = pm1_serial;
}
if (pms_pm10_min > pm10_serial) {
pms_pm10_min = pm10_serial;
}
if (pms_pm10_max < pm10_serial) {
pms_pm10_max = pm10_serial;
}
if (pms_pm25_min > pm25_serial) {
pms_pm25_min = pm25_serial;
}
if (pms_pm25_max < pm25_serial) {
pms_pm25_max = pm25_serial;
}
debug_out(F("PM1 (sec.): "), DEBUG_MED_INFO, 0);
debug_out(Float2String(double(pm1_serial)), DEBUG_MED_INFO, 1);
debug_out(F("PM2.5 (sec.): "), DEBUG_MED_INFO, 0);
debug_out(Float2String(double(pm25_serial)), DEBUG_MED_INFO, 1);
debug_out(F("PM10 (sec.) : "), DEBUG_MED_INFO, 0);
debug_out(Float2String(double(pm10_serial)), DEBUG_MED_INFO, 1);
pms_val_count++;
}
len = 0;
checksum_ok = 0;
pm1_serial = 0.0;
pm10_serial = 0.0;
pm25_serial = 0.0;
checksum_is = 0;
}
}
yield();
}
}
if (send_now) {
last_value_PMS_P0 = -1;
last_value_PMS_P1 = -1;
last_value_PMS_P2 = -1;
if (pms_val_count > 2) {
pms_pm1_sum = pms_pm1_sum - pms_pm1_min - pms_pm1_max;
pms_pm10_sum = pms_pm10_sum - pms_pm10_min - pms_pm10_max;
pms_pm25_sum = pms_pm25_sum - pms_pm25_min - pms_pm25_max;
pms_val_count = pms_val_count - 2;
}
if (pms_val_count > 0) {
last_value_PMS_P0 = double(pms_pm1_sum) / (pms_val_count * 1.0);
last_value_PMS_P1 = double(pms_pm10_sum) / (pms_val_count * 1.0);
last_value_PMS_P2 = double(pms_pm25_sum) / (pms_val_count * 1.0);
debug_out("PM1: " + Float2String(last_value_PMS_P0), DEBUG_MIN_INFO, 1);
debug_out("PM2.5: " + Float2String(last_value_PMS_P2), DEBUG_MIN_INFO, 1);
debug_out("PM10: " + Float2String(last_value_PMS_P1), DEBUG_MIN_INFO, 1);
debug_out("-------", DEBUG_MIN_INFO, 1);
s += Value2Json("PMS_P0", Float2String(last_value_PMS_P0));
s += Value2Json("PMS_P1", Float2String(last_value_PMS_P1));
s += Value2Json("PMS_P2", Float2String(last_value_PMS_P2));
}
pms_pm1_sum = 0;
pms_pm10_sum = 0;
pms_pm25_sum = 0;
pms_val_count = 0;
pms_pm1_max = 0;
pms_pm1_min = 20000;
pms_pm10_max = 0;
pms_pm10_min = 20000;
pms_pm25_max = 0;
pms_pm25_min = 20000;
if (cfg::sending_intervall_ms > (WARMUPTIME_SDS_MS + READINGTIME_SDS_MS)) {
is_PMS_running = PMS_cmd(PmSensorCmd::Stop);
}
}
debug_out(String(FPSTR(DBG_TXT_END_READING)) + FPSTR(SENSORS_PMSx003), DEBUG_MED_INFO, 1);
return s;
}
/*****************************************************************
* read GPS sensor values *
*****************************************************************/
String sensorGPS() {
String s = "";
String gps_lat = "";
String gps_lon = "";
debug_out(String(FPSTR(DBG_TXT_START_READING)) + F("GPS"), DEBUG_MED_INFO, 1);
while (serialGPS.available() > 0) {
if (gps.encode(serialGPS.read())) {
if (gps.location.isValid()) {
last_value_GPS_lat = gps.location.lat();
last_value_GPS_lon = gps.location.lng();
gps_lat = Float2String(last_value_GPS_lat, 6);
gps_lon = Float2String(last_value_GPS_lon, 6);
} else {
last_value_GPS_lat = -200;
last_value_GPS_lon = -200;
debug_out(F("Lat/Lng INVALID"), DEBUG_MAX_INFO, 1);
}
if (gps.altitude.isValid()) {
last_value_GPS_alt = gps.altitude.meters();
String gps_alt = Float2String(last_value_GPS_lat, 2);
} else {
last_value_GPS_alt = -1000;
debug_out(F("Altitude INVALID"), DEBUG_MAX_INFO, 1);
}
if (gps.date.isValid()) {
String gps_date = "";
if (gps.date.month() < 10) {
gps_date += "0";
}
gps_date += String(gps.date.month());
gps_date += "/";
if (gps.date.day() < 10) {
gps_date += "0";
}
gps_date += String(gps.date.day());
gps_date += "/";
gps_date += String(gps.date.year());
last_value_GPS_date = gps_date;
} else {
debug_out(F("Date INVALID"), DEBUG_MAX_INFO, 1);
}
if (gps.time.isValid()) {
String gps_time = "";
if (gps.time.hour() < 10) {
gps_time += "0";
}
gps_time += String(gps.time.hour());
gps_time += ":";
if (gps.time.minute() < 10) {
gps_time += "0";
}
gps_time += String(gps.time.minute());
gps_time += ":";
if (gps.time.second() < 10) {
gps_time += "0";
}
gps_time += String(gps.time.second());
gps_time += ".";
if (gps.time.centisecond() < 10) {
gps_time += "0";
}
gps_time += String(gps.time.centisecond());
last_value_GPS_time = gps_time;
} else {
debug_out(F("Time: INVALID"), DEBUG_MAX_INFO, 1);
}
}
}
if (send_now) {
debug_out("Lat/Lng: " + Float2String(last_value_GPS_lat, 6) + "," + Float2String(last_value_GPS_lon, 6), DEBUG_MIN_INFO, 1);
debug_out("Altitude: " + Float2String(last_value_GPS_alt, 2), DEBUG_MIN_INFO, 1);
debug_out("Date: " + last_value_GPS_date, DEBUG_MIN_INFO, 1);
debug_out("Time " + last_value_GPS_time, DEBUG_MIN_INFO, 1);
debug_out("----", DEBUG_MIN_INFO, 1);
s += Value2Json(F("GPS_lat"), Float2String(last_value_GPS_lat, 6));
s += Value2Json(F("GPS_lon"), Float2String(last_value_GPS_lon, 6));
s += Value2Json(F("GPS_height"), Float2String(last_value_GPS_alt, 2));
s += Value2Json(F("GPS_date"), last_value_GPS_date);
s += Value2Json(F("GPS_time"), last_value_GPS_time);
}
if ( gps.charsProcessed() < 10) {
debug_out(F("No GPS data received: check wiring"), DEBUG_ERROR, 1);
}
debug_out(String(FPSTR(DBG_TXT_END_READING)) + F("GPS"), DEBUG_MED_INFO, 1);
return s;
}
/*****************************************************************
* Init OLED display *
*****************************************************************/
void init_display() {
if (cfg::has_display) {
display = new SSD1306(0x3c, I2C_PIN_SDA, I2C_PIN_SCL);
display->init();
}
}
/*****************************************************************
* Init LCD display *
*****************************************************************/
void init_lcd() {
if (cfg::has_lcd1602_27) {
char_lcd = new LiquidCrystal_I2C(0x27, 16, 2);
} else if (cfg::has_lcd1602) {
char_lcd = new LiquidCrystal_I2C(0x3F, 16, 2);
} else if (cfg::has_lcd2004_27) {
char_lcd = new LiquidCrystal_I2C(0x27, 20, 4);
} else if (cfg::has_lcd2004_3f) {
char_lcd = new LiquidCrystal_I2C(0x3F, 20, 4);
}
//LCD is set? Configure it!
if (char_lcd) {
char_lcd->init();
char_lcd->backlight();
}
}
static void powerOnTestSensors() {
debug_out(F("PowerOnTest"),0,1);
cfg::debug = DEBUG_MED_INFO;
if (cfg::pms_read) {
debug_out(F("Read PMS(1,3,5,6,7)003..."), DEBUG_MIN_INFO, 1);
PMS_cmd(PmSensorCmd::Start);
delay(100);
PMS_cmd(PmSensorCmd::ContinuousMode);
delay(100);
debug_out(F("Stopping PMS..."), DEBUG_MIN_INFO, 1);
is_PMS_running = PMS_cmd(PmSensorCmd::Stop);
}
if (cfg::dht_read) {
dht.begin(); // Start DHT
debug_out(F("Read DHT..."), DEBUG_MIN_INFO, 1);
}
if (cfg::ds18b20_read) {
ds18b20.begin(); // Start DS18B20
debug_out(F("Read DS18B20..."), DEBUG_MIN_INFO, 1);
}
cfg::debug = DEBUG;
}
static void logEnabledAPIs() {
debug_out(F("Send to :"), DEBUG_MIN_INFO, 1);
if (cfg::send2dusti) {
debug_out(F("luftdaten.info"), DEBUG_MIN_INFO, 1);
}
if (cfg::send2madavi) {
debug_out(F("Madavi.de"), DEBUG_MIN_INFO, 1);
}
if (cfg::send2lora) {
debug_out(F("LoRa gateway"), DEBUG_MIN_INFO, 1);
}
if (cfg::send2csv) {
debug_out(F("Serial as CSV"), DEBUG_MIN_INFO, 1);
}
if (cfg::send2custom) {
debug_out(F("custom API"), DEBUG_MIN_INFO, 1);
}
if (cfg::send2influx) {
debug_out(F("custom influx DB"), DEBUG_MIN_INFO, 1);
}
debug_out("", DEBUG_MIN_INFO, 1);
if (cfg::auto_update) {
debug_out(F("Auto-Update active..."), DEBUG_MIN_INFO, 1);
debug_out("", DEBUG_MIN_INFO, 1);
}
}
static void logEnabledDisplays() {
if (cfg::has_display) {
debug_out(F("Show on OLED..."), DEBUG_MIN_INFO, 1);
}
if (cfg::has_lcd1602 || cfg::has_lcd1602_27) {
debug_out(F("Show on LCD 1602 ..."), DEBUG_MIN_INFO, 1);
}
if (cfg::has_lcd2004_27 || cfg::has_lcd2004_3f) {
debug_out(F("Show on LCD 2004 ..."), DEBUG_MIN_INFO, 1);
}
if (cfg::has_ledbar_32) {
debug_out(F("Show on LED Bar..."), DEBUG_MIN_INFO, 1);
}
}
void time_is_set (void) {
sntp_time_is_set = true;
}
static bool acquireNetworkTime() {
int retryCount = 0;
debug_out(F("Setting time using SNTP"), DEBUG_MIN_INFO, 1);
time_t now = time(nullptr);
debug_out(ctime(&now), DEBUG_MIN_INFO, 1);
debug_out(NTP_SERVER,DEBUG_MIN_INFO,1);
settimeofday_cb(time_is_set);
configTime("GMT", NTP_SERVER);
while (retryCount++ < 20) {
// later than 2000/01/01:00:00:00
if (sntp_time_is_set) {
now = time(nullptr);
debug_out(ctime(&now), DEBUG_MIN_INFO, 1);
return true;
}
delay(500);
debug_out(".",DEBUG_MIN_INFO,0);
}
debug_out(F("\nrouter/gateway:"),DEBUG_MIN_INFO,1);
retryCount = 0;
configTime(0, 0, WiFi.gatewayIP().toString().c_str());
while (retryCount++ < 20) {
// later than 2000/01/01:00:00:00
if (sntp_time_is_set) {
now = time(nullptr);
debug_out(ctime(&now), DEBUG_MIN_INFO, 1);
return true;
}
delay(500);
debug_out(".",DEBUG_MIN_INFO,0);
}
return false;
}
void initNonTrivials(const char *id) {
strcpy(cfg::current_lang, CURRENT_LANG);
if (cfg::fs_ssid == nullptr || cfg::fs_ssid[0] == '\0') {
String ssid = F("NAM-");
ssid.concat(id);
stringToChar(&cfg::fs_ssid, ssid);
}
}
/*****************************************************************
* The Setup *
*****************************************************************/
void setup() {
Debug.begin(115200); // Output to Serial at 9600 baud
serialSDS.begin(9600, SWSERIAL_8N1, PM_SERIAL_RX, PM_SERIAL_TX, false, SDS_SERIAL_BUFF_SIZE);
serialGPS.begin(9600, SWSERIAL_8N1, GPS_SERIAL_RX, GPS_SERIAL_TX, false, 64);
schedule_recurrent_function_us([]() {
serialSDS.perform_work();
serialGPS.perform_work();
return true;
}, 500);
serialSDS.enableIntTx(false);
Wire.begin(I2C_PIN_SDA, I2C_PIN_SCL);
Wire.setClock(100000); // Force bus speed 100 Khz
initNonTrivials(esp_chipid().c_str());
debug_out(F("\nNAMF ver: "), DEBUG_ERROR, false);
debug_out(SOFTWARE_VERSION, DEBUG_ERROR, false);
debug_out(F("/"), DEBUG_ERROR, false);
debug_out(FPSTR(INTL_LANG), DEBUG_ERROR);
debug_out(F("Chip ID: "), DEBUG_ERROR, false);
debug_out(esp_chipid(), DEBUG_ERROR);
FSInfo fs_info;
SPIFFS.info(fs_info);
debug_out(F("SPIFFS (kB): "), DEBUG_ERROR, false);
debug_out(String(fs_info.totalBytes/(1024)), DEBUG_ERROR);
debug_out(F("Free sketch space (kB): "), DEBUG_ERROR, false);
debug_out(String(ESP.getFreeSketchSpace()/1024), DEBUG_ERROR);
debug_out(F("CPU freq (MHz): "), DEBUG_ERROR, false);
debug_out(String(ESP.getCpuFreqMHz()), DEBUG_ERROR);
readConfig();
debug_out(getConfigString(), DEBUG_MED_INFO);
resetMemoryStats();
Reporting::setupHomePhone();
init_display();
init_lcd();
powerOnTestSensors();
//set update check interval
switch (cfg::update_channel) {
case UPDATE_CHANNEL_ALFA:
PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS = 3600 * 1000;
break;
case UPDATE_CHANNEL_BETA:
PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS = 3 * 3600 * 1000;
break;
default:
PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS = ONE_DAY_IN_MS;
}
setup_webserver();
if (strlen(cfg::wlanssid) > 0) {
connectWifi();
got_ntp = acquireNetworkTime();
debug_out(F("NTP time "), DEBUG_MIN_INFO, 0);
debug_out(String(got_ntp ? "" : "not ") + F("received"), DEBUG_MIN_INFO, 1);
if(cfg::auto_update) {
updateFW();
}
Reporting::reportBoot();
Serial.println(F(" After Report boot"));
} else {
startAP();
}
if (cfg::gps_read) {
serialGPS.begin(9600);
debug_out(F("Read GPS..."), DEBUG_MIN_INFO, 1);
disable_unneeded_nmea();
}
logEnabledAPIs();
logEnabledDisplays();
//String server_name = F("NAM-");
//server_name += esp_chipid();
//if (MDNS.begin(server_name.c_str())) {
if (MDNS.begin(cfg::fs_ssid)) {
MDNSResponder::hMDNSService hService = MDNS.addService( cfg::fs_ssid, "http", "tcp", 80);
// MDNS.addService("http", "tcp", 80);
char buff[20];
sprintf(buff, "NAM-%u", ESP.getChipId());
MDNS.addServiceTxt(hService, "id", buff);
MDNS.addServiceTxt(hService, "manufacturer", "Nettigo");
} else {
debug_out(F("\nmDNS failure!"), DEBUG_ERROR, 1);
}
delay(50);
// sometimes parallel sending data and web page will stop nodemcu, watchdogtimer set to 30 seconds
wdt_disable();
wdt_enable(30000);
serialSDS.flush(); //drop any packets sent on startup...
starttime = millis(); // store the start time
time_point_device_start_ms = starttime;
starttime_SDS = starttime;
// next_display_millis = starttime + DISPLAY_UPDATE_INTERVAL_MS;
}
static void checkForceRestart() {
if (msSince(time_point_device_start_ms) > DURATION_BEFORE_FORCED_RESTART_MS) {
ESP.restart();
}
}
static unsigned long sendDataToOptionalApis(const String &data) {
unsigned long start_send = 0;
unsigned long sum_send_time = 0;
if (cfg::send2madavi) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("madavi.de: "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendData(LoggerMadavi, data, 0, HOST_MADAVI, (cfg::ssl_madavi ? 443 : 80), URL_MADAVI, true);
sum_send_time += millis() - start_send;
server.handleClient();
}
if (cfg::send2sensemap && (cfg::senseboxid[0] != '\0')) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("opensensemap: "), DEBUG_MIN_INFO, 1);
start_send = millis();
String sensemap_path = URL_SENSEMAP;
sensemap_path.replace("BOXID", cfg::senseboxid);
sendData(LoggerSensemap, data, 0, HOST_SENSEMAP, PORT_SENSEMAP, sensemap_path.c_str(), false);
sum_send_time += millis() - start_send;
server.handleClient();
}
if (cfg::send2fsapp) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("Server FS App: "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendData(LoggerFSapp, data, 0, HOST_FSAPP, PORT_FSAPP, URL_FSAPP, false);
sum_send_time += millis() - start_send;
server.handleClient();
}
if (cfg::send2influx) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("custom influx db: "), DEBUG_MIN_INFO, 1);
start_send = millis();
const String data_4_influxdb = create_influxdb_string(data);
sendData(LoggerInflux, data_4_influxdb, 0, cfg::host_influx, cfg::port_influx, cfg::url_influx, false);
sum_send_time += millis() - start_send;
server.handleClient();
}
/* if (send2lora) {
debug_out(F("## Sending to LoRa gateway: "), DEBUG_MIN_INFO, 1);
send_lora(data);
}
*/
if (cfg::send2csv) {
debug_out(F("## Sending as csv: "), DEBUG_MIN_INFO, 1);
send_csv(data);
server.handleClient();
}
if (cfg::send2custom) {
String data_4_custom = data;
data_4_custom.remove(0, 1);
data_4_custom = "{\"esp8266id\": \"" + esp_chipid() + "\", " + data_4_custom;
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("custom api: "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendData(LoggerCustom, data_4_custom, 0, cfg::host_custom, cfg::port_custom, cfg::url_custom, false);
sum_send_time += millis() - start_send;
server.handleClient();
}
if (cfg::send2aqi) {
String data_4_custom = data;
data_4_custom.remove(0, 1);
data_4_custom = "{\"esp8266id\": \"" + esp_chipid() + "\", " + data_4_custom;
debug_out(String(FPSTR(DBG_TXT_SENDING_TO)) + F("AQI.eco api: "), DEBUG_MIN_INFO, 1);
String path = F("/update/");
path.concat(cfg::token_AQI);
start_send = millis();
sendData(LoggerAQI, data_4_custom, 0, F("api.aqi.eco"), 443, path, false);
sum_send_time += millis() - start_send;
server.handleClient();
}
return sum_send_time;
}
/*****************************************************************
* And action *
*****************************************************************/
void loop() {
String result_SDS = "";
String result_PMS = "";
String result_DHT = "";
String result_BME280 = "";
String result_HECA = "";
String result_MHZ14 = "";
String result_DS18B20 = "";
String result_GPS = "";
unsigned long sum_send_time = 0;
unsigned long start_send;
act_micro = micros();
act_milli = millis();
send_now = msSince(starttime) > cfg::sending_intervall_ms;
sample_count++;
MDNS.update();
if (enable_ota_time > act_milli) {
ArduinoOTA.handle();
}
wdt_reset(); // nodemcu is alive
scheduler.process();
if (last_micro != 0) {
unsigned long diff_micro = act_micro - last_micro;
if (max_micro < diff_micro) {
max_micro = diff_micro;
}
if (min_micro > diff_micro) {
min_micro = diff_micro;
}
}
last_micro = act_micro;
server.handleClient();
yield();
#if !defined(BOOT_FW)
if ((msSince(starttime_SDS) > SAMPLETIME_SDS_MS) || send_now) {
if (cfg::pms_read) {
debug_out(String(FPSTR(DBG_TXT_CALL_SENSOR)) + "PMS", DEBUG_MAX_INFO, 1);
result_PMS = sensorPMS();
starttime_SDS = act_milli;
}
}
server.handleClient();
yield();
if (send_now) {
debug_out(String(F("****************** Upload data to APIs*****************************")),DEBUG_MED_INFO);
if (cfg::dht_read) {
debug_out(String(FPSTR(DBG_TXT_CALL_SENSOR)) + FPSTR(SENSORS_DHT22), DEBUG_MAX_INFO, 1);
result_DHT = sensorDHT(); // getting temperature and humidity (optional)
}
if (cfg::ds18b20_read) {
debug_out(String(FPSTR(DBG_TXT_CALL_SENSOR)) + FPSTR(SENSORS_DS18B20), DEBUG_MAX_INFO, 1);
result_DS18B20 = sensorDS18B20(); // getting temperature (optional)
}
}
if (cfg::gps_read && ((msSince(starttime_GPS) > SAMPLETIME_GPS_MS) || send_now)) {
debug_out(String(FPSTR(DBG_TXT_CALL_SENSOR)) + F("GPS"), DEBUG_MAX_INFO, 1);
result_GPS = sensorGPS(); // getting GPS coordinates
starttime_GPS = act_milli;
}
cycleDisplay();
yield();
if ((cfg::has_ledbar_32) && (send_now)) {
displayLEDBar();
}
if (send_now) {
debug_out(F("Creating data string:"), DEBUG_MIN_INFO, 1);
String data = FPSTR(data_first_part);
data.replace("{v}", String(SOFTWARE_VERSION));
String data_sample_times = Value2Json(F("samples"), String(sample_count));
data_sample_times.concat(Value2Json(String(F("min_micro")), String(min_micro)));
data_sample_times.concat(Value2Json(String(F("max_micro")), String(max_micro)));
String signal_strength = String(WiFi.RSSI());
debug_out(F("WLAN signal strength: "), DEBUG_MIN_INFO, 0);
debug_out(signal_strength, DEBUG_MIN_INFO, 0);
debug_out(" dBm", DEBUG_MIN_INFO, 1);
debug_out("----", DEBUG_MIN_INFO, 1);
server.handleClient();
yield();
// server.stop();
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
if (cfg::pms_read) {
data.concat(result_PMS);
if (cfg::send2dusti) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO_LUFTDATEN)) + F("(PMS): "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendLuftdaten(result_PMS, PMS_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "PMS_");
sum_send_time += millis() - start_send;
}
}
server.handleClient();
if (cfg::dht_read) {
data.concat(result_DHT);
if (cfg::send2dusti) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO_LUFTDATEN)) + F("(DHT): "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendLuftdaten(result_DHT, DHT_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "DHT_");
sum_send_time += millis() - start_send;
}
}
server.handleClient();
if (cfg::ds18b20_read) {
data.concat(result_DS18B20);
if (cfg::send2dusti) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO_LUFTDATEN)) + F("(DS18B20): "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendLuftdaten(result_DS18B20, DS18B20_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "DS18B20_");
sum_send_time += millis() - start_send;
}
}
server.handleClient();
if (cfg::gps_read) {
data.concat(result_GPS);
if (cfg::send2dusti) {
debug_out(String(FPSTR(DBG_TXT_SENDING_TO_LUFTDATEN)) + F("(GPS): "), DEBUG_MIN_INFO, 1);
start_send = millis();
sendLuftdaten(result_GPS, GPS_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "GPS_");
sum_send_time += millis() - start_send;
}
}
server.handleClient();
//add results from new scheduler
SimpleScheduler::getResults(data);
// reconnect to WiFi if disconnected
if (WiFi.status() != WL_CONNECTED) {
debug_out(F("Connection lost, reconnecting "), DEBUG_MIN_INFO, 0);
WiFi.reconnect();
waitForWifiToConnect(20);
debug_out("", DEBUG_MIN_INFO, 1);
if (WiFi.status() != WL_CONNECTED) { //still no connection
debug_out(F("Still no WiFi, turn off..."),DEBUG_MIN_INFO);
WiFi.mode(WIFI_OFF);
delay(2000);
debug_out(F("WiFi, reconnecting"),DEBUG_MIN_INFO);
WiFi.mode(WIFI_STA);
WiFi.begin(cfg::wlanssid, cfg::wlanpwd); // Start WiFI
waitForWifiToConnect(20);
}
}
if (cfg::send2dusti) {
SimpleScheduler::sendToSC();
}
data_sample_times.concat(Value2Json("signal", signal_strength));
data_sample_times.remove(data_sample_times.length()-1);
data.concat(data_sample_times) ;
data.concat(F("]}"));
sum_send_time += sendDataToOptionalApis(data);
//as for now we do not collect sending status, so we assume sending was successful
SimpleScheduler::afterSendData(true);
// server.client().setNoDelay(true);
checkForceRestart();
if (cfg::auto_update && msSince(last_update_attempt) > PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS) {
updateFW();
}
sending_time = (4 * sending_time + sum_send_time) / 5;
debug_out(F("Time for sending data (ms): "), DEBUG_MIN_INFO, 0);
debug_out(String(sending_time), DEBUG_MIN_INFO, 1);
server.handleClient();
// Resetting for next sampling
last_data_string = data;
sample_count = 0;
last_micro = 0;
min_micro = 1000000000;
max_micro = 0;
sum_send_time = 0;
starttime = millis(); // store the start time
first_cycle = false;
count_sends += 1;
resetMemoryStats();
}
delay(1);
collectMemStats();
Reporting::homePhone();
#endif
// if (sample_count % 500 == 0) { Serial.println(ESP.getFreeHeap(),DEC); }
}
| 39,420
|
C++
|
.cpp
| 1,079
| 32.50139
| 136
| 0.596777
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,434
|
helpers.cpp
|
nettigo_namf/src/helpers.cpp
|
//
// Created by viciu on 28.01.2020.
//
#include "variables.h"
#include "helpers.h"
#include "system/scheduler.h"
extern const char UNIT_PERCENT[] PROGMEM = "%";
extern const char UNIT_CELCIUS[] PROGMEM = "°C";
extern const unsigned char UNIT_CELCIUS_LCD[] PROGMEM = {0xDF, 0x43, 0x0};
LoggingSerial Debug;
LoggingSerial::LoggingSerial()
: HardwareSerial(UART0)
, m_buffer(new circular_queue<uint8_t>(1024))
{
skipBuffer = false;
}
void LoggingSerial::stopWebCopy(void) {
skipBuffer = true;
}
void LoggingSerial::resumeWebCopy(void) {
skipBuffer = false;
}
size_t LoggingSerial::write(uint8_t c)
{
if (!skipBuffer) m_buffer->push(c);
return HardwareSerial::write(c);
}
size_t LoggingSerial::write(const uint8_t *buffer, size_t size)
{
if (!skipBuffer) m_buffer->push_n(buffer, size);
return HardwareSerial::write(buffer, size);
}
String LoggingSerial::popLines()
{
String r;
while (m_buffer->available() > 0) {
uint8_t c = m_buffer->pop();
r += (char) c;
// if (c == '\n' && r.length() > m_buffer->available())
// break;
}
return r;
}
int32_t calcWiFiSignalQuality(int32_t rssi) {
if (rssi > -50) {
rssi = -50;
}
if (rssi < -100) {
rssi = -100;
}
return (rssi + 100) * 2;
}
//store string as char array, for functions
unsigned stringToChar(char **dst, const String src) {
// Serial.println(F("stringToChar"));
// Serial.println(src.c_str());
if (*dst != nullptr) {
// Serial.println(F("Deleting DST"));
delete (*dst);
}
// Serial.println(F("allocating"));
unsigned int len = src.length() + 1;
*dst = new char[len];
// Serial.println(F("after allocating"));
if (*dst == nullptr) return 0; //does it return nullptr or raises Abort? Probaby fails in 3.0.0 ArduinoCore
// Serial.print(F("copying len: "));
// Serial.println(len);
strncpy(*dst, src.c_str(), len);
// Serial.println(F("copied..."));
// Serial.println(*dst);
return len;
}
unsigned setDefault(char **dst, const __FlashStringHelper *defaultValue) {
// Serial.println(F("setDefault"));
if (dst == nullptr || !strlen(*dst)) {
String src = String(defaultValue);
// Serial.println(F("SRC READY"));
return stringToChar(dst, src);
}
return strlen(*dst) + 1;
}
//same as stringToChar but for JSON char string as source
unsigned charStringToChar(char *dst, const char *src) {
if (dst != nullptr) delete (dst);
size_t len = strlen(src);
dst = new(char[len + 1]);
if (dst == nullptr) return 0;
strncpy(dst, src, len+1);
return len + 1;
}
/*****************************************************************
* convert float to string with a *
* precision of two (or a given number of) decimal places *
*****************************************************************/
String Float2String(const double value) {
return Float2String(value, 2);
}
String Float2String(const double value, uint8_t digits) {
// Convert a float to String with two decimals.
char temp[15];
dtostrf(value, 13, digits, temp);
String s = temp;
s.trim();
return s;
}
/*****************************************************************
* convert value to json string *
*****************************************************************/
String Value2Json(const String& type, const String& value) {
String s = F("{\"value_type\":\"{t}\",\"value\":\"{v}\"},");
s.replace("{t}", type);
s.replace("{v}", value);
return s;
}
String Value2Json( const __FlashStringHelper * t, const String& value) {
String type(t);
String s = F("{\"value_type\":\"{t}\",\"value\":\"{v}\"},");
s.replace("{t}", type);
s.replace("{v}", value);
return s;
}
/*****************************************************************
* convert string value to json string *
*****************************************************************/
String Var2Json(const String& name, const String& value) {
String s = F("\"{n}\":\"{v}\",");
String tmp = value;
tmp.replace("\\", "\\\\"); tmp.replace("\"", "\\\"");
s.replace("{n}", name);
s.replace("{v}", tmp);
return s;
}
/*****************************************************************
* convert boolean value to json string *
*****************************************************************/
String Var2Json(const String &name, const bool value) {
String s = F("\"{n}\":\"{v}\",");
s.replace("{n}", name);
s.replace("{v}", (value ? "true" : "false"));
return s;
}
String Var2Json(const String &name, const char *value) {
return Var2Json(name, String(value));
}
String Var2JsonInt(const String &name, const bool value) {
String s = F("\"{n}\":{v},");
s.replace("{n}", name);
s.replace("{v}", (value ? "1" : "0"));
return s;
}
/*****************************************************************
* convert boolean value to json string *
*****************************************************************/
String Var2Json(const String &name, const int value) {
String s = F("\"{n}\":\"{v}\",");
s.replace("{n}", name);
s.replace("{v}", String(value));
return s;
}
String Var2Json(const String &name, const unsigned long value) {
String s = F("\"{n}\":\"{v}\",");
s.replace(F("{n}"), name);
s.replace(F("{v}"), String(value));
return s;
}
String Var2Json(const String& name, const float value) {
String s = F("\"{n}\":\"{v}\",");
s.replace("{n}", name);
s.replace("{v}", String(value));
return s;
}
void addJsonIfNotDefault(String &str,const __FlashStringHelper *name, const unsigned long defaultValue, const unsigned long current) {
if (defaultValue != current){
str += Var2Json(name, current);
}
return;
}
/*****************************************************************
* Debug output *
*****************************************************************/
void debug_out(const String& text, const int level, const bool linebreak) {
static bool timestamp=true;
if (level <= cfg::debug) {
if (timestamp) {
time_t rawtime;
struct tm *timeinfo;
char buffer[30];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer, 30, "%F %T: ", timeinfo);
Debug.print(buffer);
timestamp = false;
}
if (linebreak) {
timestamp = true;
Debug.println(text);
} else {
Debug.print(text);
}
}
}
//Create string with config as JSON
String getConfigString(boolean maskPwd) {
using namespace cfg;
String json_string = "{";
#define copyToJSON_Bool(varname) json_string += Var2Json(#varname,varname);
#define copyToJSON_Int(varname) json_string += Var2Json(#varname,varname);
json_string += Var2Json(F("current_lang"), current_lang);
json_string += Var2Json(F("SOFTWARE_VERSION"), SOFTWARE_VERSION);
json_string += Var2Json(F("wlanssid"), wlanssid);
//mask WiFi password?
if (maskPwd) {
json_string += Var2Json(F("wlanpwd"), String(F("****")));
json_string += Var2Json(F("fbpwd"), String(F("****")));
json_string += Var2Json(F("fs_pwd"), String(F("****")));
} else {
json_string += Var2Json(F("wlanpwd"), wlanpwd);
json_string += Var2Json(F("fbpwd"), fbpwd);
json_string += Var2Json(F("fs_pwd"), fs_pwd);
}
json_string += Var2Json(F("www_username"), www_username);
json_string += Var2Json(F("www_password"), www_password);
json_string += Var2Json(F("fs_ssid"), fs_ssid);
json_string += Var2Json(F("fbssid"), fbssid);
copyToJSON_Bool(www_basicauth_enabled);
copyToJSON_Bool(dht_read);
// copyToJSON_Bool(sds_read);
copyToJSON_Bool(pms_read);
// copyToJSON_Bool(bmp280_read);
// copyToJSON_Bool(bme280_read);
// copyToJSON_Bool(heca_read);
copyToJSON_Bool(ds18b20_read);
copyToJSON_Bool(gps_read);
copyToJSON_Bool(send2dusti);
copyToJSON_Bool(ssl_dusti);
copyToJSON_Bool(send2madavi);
copyToJSON_Bool(ssl_madavi);
copyToJSON_Bool(send2sensemap);
copyToJSON_Bool(send2fsapp);
copyToJSON_Bool(send2lora);
copyToJSON_Bool(send2csv);
copyToJSON_Bool(auto_update);
copyToJSON_Int(update_channel);
copyToJSON_Bool(has_display);
copyToJSON_Bool(has_lcd1602);
copyToJSON_Bool(has_lcd1602_27);
copyToJSON_Bool(has_lcd2004_27);
copyToJSON_Bool(has_lcd2004_3f);
copyToJSON_Bool(show_wifi_info);
copyToJSON_Bool(sh_dev_inf);
copyToJSON_Bool(has_ledbar_32);
json_string += Var2Json(F("debug"), debug);
json_string += Var2Json(F("send_diag"), send_diag);
json_string += Var2Json(F("sending_intervall_ms"), sending_intervall_ms);
json_string += Var2Json(F("time_for_wifi_config"), time_for_wifi_config);
copyToJSON_Int(outputPower);
copyToJSON_Int(phyMode);
json_string += Var2Json(F("senseboxid"), senseboxid);
copyToJSON_Bool(send2custom);
json_string += Var2Json(F("host_custom"), host_custom);
json_string += Var2Json(F("url_custom"), url_custom);
copyToJSON_Int(port_custom);
json_string += Var2Json(F("user_custom"), user_custom);
json_string += Var2Json(F("pwd_custom"), pwd_custom);
copyToJSON_Bool(send2aqi);
json_string += Var2Json(F("token_AQI"), token_AQI);
json_string += Var2Json(F("host_custom"), host_custom);
copyToJSON_Bool(send2influx);
json_string += Var2Json(F("host_influx"), host_influx);
json_string += Var2Json(F("url_influx"), url_influx);
json_string.concat(Var2Json(F("UUID"), UUID));
copyToJSON_Int(port_influx);
json_string += Var2Json(F("user_influx"), user_influx);
json_string += Var2Json(F("pwd_influx"), pwd_influx);
#undef copyToJSON_Bool
#undef copyToJSON_Int
#undef Var2Json
SimpleScheduler::getConfigJSON(json_string);
json_string += "}";
return json_string;
}
//Create string with config as JSON
String getMaskedConfigString() {
return getConfigString(true);
}
//make sure lang is on supported list
void verifyLang(char *cl) {
if (!strcmp(cl,"PL")) return;
if (!strcmp(cl,"EN")) return;
if (!strcmp(cl,"HU")) return;
if (!strcmp(cl,"RO")) return;
strcpy(cl,"EN");
}
void dbg(char *v) { if (v == nullptr) Serial.println(F("NULL")); else Serial.println(v);}
void setCharVar(const JsonObject &json, char **var, const __FlashStringHelper *key, const __FlashStringHelper *def = nullptr) {
if (json.containsKey(key)) stringToChar(var, json[key]);
if (def != nullptr) setDefault(var, def);
}
int readAndParseConfigFile(File configFile) {
using namespace cfg;
String json_string = "";
bool pms24_read = false;
bool pms32_read = false;
if (configFile) {
debug_out(F("opened config file..."), DEBUG_MED_INFO, 1);
const size_t size = configFile.size();
// Allocate a buffer to store contents of the file.
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
DynamicJsonBuffer jsonBuffer;
JsonObject &json = jsonBuffer.parseObject(buf.get());
debug_out(F("Config - JSON object memory used:"),DEBUG_MED_INFO, false);
debug_out(String(jsonBuffer.size()),DEBUG_MED_INFO);
json.printTo(json_string);
debug_out(F("File content: "), DEBUG_MAX_INFO, 0);
debug_out(String(buf.get()), DEBUG_MAX_INFO, 1);
debug_out(F("JSON Buffer content: "), DEBUG_MAX_INFO, 0);
Debug.stopWebCopy();
debug_out(json_string, DEBUG_MAX_INFO, 1);
Debug.resumeWebCopy();
if (json.success()) {
debug_out(F("JSON parsed"), DEBUG_MED_INFO, 1);
setCharVar(json, &wlanssid, F("wlanssid"), FPSTR(EMPTY_STRING));
setCharVar(json, &wlanpwd, F("wlanpwd"), FPSTR(EMPTY_STRING));
setCharVar(json, &fbssid, F("fbssid"), FPSTR(EMPTY_STRING));
setCharVar(json, &fbpwd, F("fbpwd"), FPSTR(EMPTY_STRING));
setCharVar(json, &www_username, F("www_username"), FPSTR(WWW_USERNAME));
setCharVar(json, &www_password, F("www_password"), FPSTR(WWW_PASSWORD));
setCharVar(json, &fs_ssid, F("fs_ssid"), FPSTR(FS_SSID));
setCharVar(json, &fs_pwd, F("fs_pwd"), FPSTR(FS_PWD));
setCharVar(json, &user_custom, F("user_custom"), FPSTR(USER_CUSTOM));
setCharVar(json, &pwd_custom, F("pwd_custom"), FPSTR(PWD_CUSTOM));
setCharVar(json, &user_influx, F("user_influx"), FPSTR(EMPTY_STRING));
setCharVar(json, &pwd_influx, F("pwd_influx"), FPSTR(EMPTY_STRING));
#define setFromJSON(key) if (json.containsKey(#key)) key = json[#key];
#define strcpyFromJSON(key) if (json.containsKey(#key)) strcpy(key, json[#key]);
strcpyFromJSON(current_lang);
verifyLang(current_lang);
setFromJSON(www_basicauth_enabled);
setFromJSON(dht_read);
setFromJSON(sds_read);
setFromJSON(pms_read);
setFromJSON(pms24_read);
setFromJSON(pms32_read);
setFromJSON(bmp280_read);
setFromJSON(bme280_read);
setFromJSON(heca_read);
setFromJSON(ds18b20_read);
setFromJSON(gps_read);
setFromJSON(send2dusti);
setFromJSON(ssl_dusti);
setFromJSON(send2madavi);
setFromJSON(ssl_madavi);
setFromJSON(send2sensemap);
setFromJSON(send2fsapp);
setFromJSON(send2lora);
setFromJSON(send2csv);
setFromJSON(auto_update);
setFromJSON(update_channel);
setFromJSON(has_display);
setFromJSON(has_lcd1602);
setFromJSON(has_lcd1602_27);
setFromJSON(has_lcd2004_27);
setFromJSON(has_lcd2004_3f);
setFromJSON(show_wifi_info);
setFromJSON(sh_dev_inf);
setFromJSON(has_ledbar_32);
setFromJSON(debug);
setFromJSON(send_diag);
setFromJSON(sending_intervall_ms);
setFromJSON(time_for_wifi_config);
setFromJSON(outputPower);
setFromJSON(phyMode);
strcpyFromJSON(senseboxid);
if (strcmp(senseboxid, "00112233445566778899aabb") == 0) {
strcpy(senseboxid, "");
send2sensemap = 0;
}
setFromJSON(send2custom);
if (json.containsKey(F("host_custom"))) host_custom = json.get<String>(F("host_custom"));
if (json.containsKey(F("url_custom"))) url_custom = json.get<String>(F("url_custom"));
setFromJSON(port_custom);
setFromJSON(send2aqi);
if (json.containsKey(F("token_AQI"))) token_AQI = json.get<String>(F("token_AQI"));
setFromJSON(send2influx);
if (json.containsKey(F("host_influx"))) host_influx = json.get<String>(F("host_influx"));
if (json.containsKey(F("url_influx"))) url_influx = json.get<String>(F("url_influx"));
setFromJSON(port_influx);
if (host_influx.equals(F("api.luftdaten.info"))) {
host_influx = F("");
send2influx = 0;
}
if (json.containsKey(F("UUID"))) UUID = json.get<String>(F("UUID"));
configFile.close();
if (pms24_read || pms32_read) {
pms_read = 1;
writeConfig();
};
#undef setFromJSON
#undef strcpyFromJSON
//Sensor configs from simple scheduler
if (!json.containsKey(F("sensors")))
json.createNestedObject(F("sensors"));
if (json.containsKey(F("sensors"))) {
JsonObject& item = json[F("sensors")];
if (cfg::sds_read) {
if (!item.containsKey(F("SDS011"))) {
item.createNestedObject(F("SDS011"));
}
item[F("SDS011")][F("e")] = 1;
item[F("SDS011")][F("d")] = 1;
}
if (cfg::bme280_read) {
if (!item.containsKey(F("BME280"))) {
item.createNestedObject(F("BME280"));
}
item[F("BME280")][F("e")] = 1;
// item[F("BME280")][F("d")] = 1;
}
if (cfg::heca_read) {
if (!item.containsKey(F("HECA"))) {
item.createNestedObject(F("HECA"));
}
item[F("HECA")][F("e")] = 1;
item[F("HECA")][F("d")] = 1;
}
SimpleScheduler::readConfigJSON(item);
}
return 0;
} else {
debug_out(F("failed to load json config"), DEBUG_ERROR, 1);
return -1;
}
}
return -1;
}
/*****************************************************************
* write config to spiffs *
*****************************************************************/
int writeConfigRaw(const String &json_string, const char * filename) {
Debug.stopWebCopy();
debug_out(json_string, DEBUG_MAX_INFO, 1);
Debug.resumeWebCopy();
File configFile;
if (filename) {
configFile = SPIFFS.open(filename, "w");
} else {
configFile = SPIFFS.open("/config.json", "w");
}
if (configFile) {
configFile.print(json_string);
debug_out(F("Config written OK."), DEBUG_MIN_INFO, 0);
Debug.stopWebCopy();
debug_out(json_string, DEBUG_MIN_INFO, 1);
Debug.resumeWebCopy();
configFile.close();
return 0;
} else {
debug_out(F("failed to open config file for writing"), DEBUG_ERROR, 1);
return -1;
}
}
/*
* get current config and save it
*/
void writeConfig(){
debug_out(F("saving config..."), DEBUG_MIN_INFO);
String json_string = getConfigString();
writeConfigRaw(json_string);
}
void parseHTTP(const __FlashStringHelper *name, unsigned long &value ){
if (server.hasArg(name)) {
value = server.arg(name).toInt();
}
};
void parseHTTP(const String name, unsigned long &value ){
if (server.hasArg(name)) {
value = server.arg(name).toInt();
}
};
void parseHTTP(const __FlashStringHelper *name, byte &value ){
if (server.hasArg(name)) {
value = server.arg(name).toInt();
}
};
void parseHTTP(const __FlashStringHelper *name, String &value ){
value = F("");
if (server.hasArg(name)) {
value = server.arg(name);
}
};
void parseHTTP(const __FlashStringHelper *name, bool &value ){
value = false;
if (server.hasArg(name)) {
value = server.arg(name) == "1";
}
};
void parseHTTP(const String &name, bool &value ){
value = false;
if (server.hasArg(name)) {
value = server.arg(name) == "1";
}
};
void setHTTPVarName(String &varName, String const name, byte id) {
varName = F("{n}-{s}");
varName.replace(F("{s}"), String(id));
varName.replace(F("{n}"), name);
}
void advancedSectionStart( String &html, SimpleScheduler::LoopEntryType sensor){
html.concat(F("</div><div class='gc'><div class='row'><input type='button' value='"));
html.concat(FPSTR(INTL_ADVANCED_BUTTON));
html.concat("' data-code=");
html.concat(String(sensor));
html.concat(F(" class='asb'/></div></div><div class='advSect' id='as-"));
html.concat(String(sensor));
html.concat(F("'><div class='gc'><div class='row'><p>"));
html.concat(FPSTR(INTL_ADVANCED_DISCL));
html.concat(F("</p></div>\n"));
}
void advancedSectionEnd( String &html, SimpleScheduler::LoopEntryType sensor){
html.concat(F("</div>"));
}
/* get read and set bool variables for new scheduler. Works with checkbox
named var_name-SENSOR_ID (var name it is enable or display currently
Getting enable val from client is code done by each sensor, to make it easier this
helper was created. It supports any bool var.
*/
void setBoolVariableFromHTTP(String const name, bool &v, byte i){
String sensorID;
setHTTPVarName(sensorID, name, i);
parseHTTP(sensorID, v);
}
void setVariableFromHTTP(String const name, unsigned long &v, byte i){
String sensorID;
setHTTPVarName(sensorID, name, i);
parseHTTP(sensorID, v);
}
void setVariableFromHTTP(const __FlashStringHelper *name, unsigned long &v, byte i){
String sensorID;
setHTTPVarName(sensorID, name, i);
parseHTTP(sensorID, v);
}
unsigned long time2Measure(void){
unsigned long timeFromStart = millis() - starttime;
if ( timeFromStart > cfg::sending_intervall_ms) return 0;
return cfg::sending_intervall_ms - timeFromStart;
};
//Form helpers
//
// bold
// 0 - use <b>
// 1 - use <h1>
// 2 - use <h2>
// 3 - do not use any tags
String formSectionHeader(String &page_content, const String& name, byte bold) {
page_content.concat(formSectionHeader(name, bold));
}
String formSectionHeader(const String& name, byte bold) {
String s;
switch (bold){
case(1):
s = F("<div class='row sect'><h1>{n}</h1></div>\n");
break;
case(2):
s = F("<div class='row sect'><h2>{n}</h2></div>\n");
break;
case(3):
s = F("<div class='row sect'>{n}</div>\n");
break;
default:
s = F("<div class='row sect'><b>{n}</b></div>\n");
}
s.replace("{n}", name);
return s;
}
String formInputGrid(const String& name, const String& info, const String& value, const int length) {
String s = F( "<div>{i}</div><div class='c2'>"
"<input type='text' name='{n}' id='{n}' placeholder='{i}' value='{v}' maxlength='{l}'/>"
"</div>");
String t_value = value;
t_value.replace("'", "'");
s.replace("{i}", info);
s.replace("{n}", name);
s.replace("{v}", t_value);
s.replace("{l}", String(length));
return s;
}
String form_input(const String& name, const String& info, const String& value, const int length) {
String s = F( "<tr>"
"<td>{i} </td>"
"<td style='width:90%;'>"
"<input type='text' name='{n}' id='{n}' placeholder='{i}' value='{v}' maxlength='{l}'/>"
"</td>"
"</tr>");
String t_value = value;
t_value.replace("'", "'");
s.replace("{i}", info);
s.replace("{n}", name);
s.replace("{v}", t_value);
s.replace("{l}", String(length));
return s;
}
const char form_password_templ[] PROGMEM = "<tr>"
"<td>{i} </td>"
"<td style='width:90%;'>"
"<input type='password' name='{n}' id='{n}' placeholder='{i}' value='{v}' maxlength='{l}'/>"
"</td>"
"</tr>";
String form_password(const String& name, const String& info, const String& value, const int length) {
unsigned size = strlen_P(form_password_templ) + 1 ;
size += name.length() + info.length() + value.length() - 9;
String s;
s.reserve(size);
s = FPSTR(form_password_templ);
String password = "";
password.reserve(value.length());
for (uint8_t i = 0; i < value.length(); i++) {
password.concat(F("*"));
}
s.replace("{i}", info);
s.replace("{n}", name);
s.replace("{v}", password);
s.replace("{l}", String(length));
return s;
}
const char formPasswordGrid_templ[] PROGMEM = "<div>{i}</div><div class='c2'><input type='password' name='{n}' id='{n}' placeholder='{i}' value='{v}' maxlength='{l}'/></div>\n";
String formPasswordGrid(const String& name, const String& info, const String& value, const int length) {
unsigned size = strlen_P(formPasswordGrid_templ) + 1 ;
size += name.length() + info.length() + value.length() - 9;
String s;
s.reserve(size);
s = FPSTR(formPasswordGrid_templ);
String password = "";
password.reserve(value.length());
for (uint8_t i = 0; i < value.length(); i++) {
password.concat(F("*"));
}
s.replace("{i}", info);
s.replace("{n}", name);
s.replace("{v}", password);
s.replace("{l}", String(length));
return s;
}
const char formCheckboxGrid_templ[] PROGMEM = "<div class='row'><input type='checkbox' name='{n}' value='1' id='{n}' {c}/><label for='{n}'>{i}</label></div>";
String formCheckboxGrid(const String& name, const String& info, const bool checked) {
String newInfo = add_sensor_type(info);
unsigned size = strlen_P(formCheckboxGrid_templ) + 1 ;
size += name.length() + newInfo.length();
size += checked ? 19 : 0;
String s;
s.reserve(size);
s = FPSTR(formCheckboxGrid_templ);
if (checked) {
s.replace("{c}", F(" checked='checked'"));
} else {
s.replace("{c}", "");
};
s.replace("{i}", newInfo);
s.replace("{n}", name);
return s;
}
const char formCheckboxOpenGrid_templ[] PROGMEM = "<div><input type='checkbox' name='{n}' value='1' id='{n}' {c}/><label for='{n}'>{i}</label></div>";
//Use only columns 1 & 2 from grid
String formCheckboxOpenGrid(const String& name, const String& info, const bool checked) {
String newInfo = add_sensor_type(info);
unsigned size = strlen_P(formCheckboxOpenGrid_templ) + 1 ;
size += name.length() + newInfo.length();
size += checked ? 19 : 0;
String s;
s.reserve(size);
s = FPSTR(formCheckboxOpenGrid_templ);
if (checked) {
s.replace("{c}", F(" checked='checked'"));
} else {
s.replace("{c}", "");
};
s.replace("{i}", newInfo);
s.replace("{n}", name);
return s;
}
const char form_checkbox_templ[] PROGMEM = "<label for='{n}'><input type='checkbox' name='{n}' value='1' id='{n}' {c}/> {i}</label><br/>";
String form_checkbox(const String& name, const String& info, const bool checked, const bool linebreak) {
unsigned size = strlen_P(form_checkbox_templ) + 1 ;
size += name.length() + info.length();
size += checked ? 19 : 0;
size += linebreak ? 6 : 0;
String s;
s.reserve(size);
s = FPSTR(form_checkbox_templ);
if (checked) {
s.replace("{c}", F(" checked='checked'"));
} else {
s.replace("{c}", "");
};
s.replace("{i}", info);
s.replace("{n}", name);
if (! linebreak) {
s.replace("<br/>", "");
}
return s;
}
String form_option(String const &name, const String & info, const bool checked){
String ret;
ret = F("<option value=");
ret += name;
if (checked) {
ret += F(" selected=\"selected\"");
}
ret += F(">");
ret += info;
ret += "</option>";
return ret;
}
String form_checkbox_sensor(const String& name, const String& info, const bool checked) {
return form_checkbox(name, add_sensor_type(info), checked);
}
String form_submit(const String& value) {
String s = F( "<tr>"
"<td> </td>"
"<td>"
"<input type='submit' name='submit' value='{v}' class='s_r'/>"
"</td>"
"</tr>");
s.replace("{v}", value);
return s;
}
String formSubmitGrid(const String& value) {
String s = F( "<div><input type='submit' name='submit' value='{v}' class='s_r'/></div>");
s.replace("{v}", value);
return s;
}
String form_select_lang() {
String s_select = F(" selected='selected'");
String s = F( "<div>{t}</div><div class='c2'>"
"<select name='current_lang'>"
"<option value='EN'{s_EN}>English (EN)</option>"
"<option value='HU'{s_HU}>Hungarian (HU)</option>"
"<option value='PL'{s_PL}>Polski (PL)</option>"
"<option value='RO'{s_RO}>ROMÂNĂ (RO)</option>"
"</select>"
"</div>");
s.reserve(s.length()+40);
s.replace("{t}", FPSTR(INTL_LANGUAGE));
s.replace("{s_" + String(cfg::current_lang) + "}", s_select);
while (s.indexOf("{s_") != -1) {
s.remove(s.indexOf("{s_"), 6);
}
return s;
}
void resetMemoryStats() {
memoryStatsMax = memory_stat_t{0,0,0, 0};
memoryStatsMin = memory_stat_t{UINT32_MAX, UINT16_MAX, UINT8_MAX, UINT32_MAX};
}
void collectMemStats() {
memory_stat_t memoryStats;
ESP.getHeapStats(&memoryStats.freeHeap, &memoryStats.maxFreeBlock, &memoryStats.frag);
if (memoryStats.freeHeap > memoryStatsMax.freeHeap) memoryStatsMax.freeHeap = memoryStats.freeHeap;
if (memoryStats.maxFreeBlock > memoryStatsMax.maxFreeBlock) memoryStatsMax.maxFreeBlock = memoryStats.maxFreeBlock;
if (memoryStats.frag > memoryStatsMax.frag) memoryStatsMax.frag = memoryStats.frag;
if (memoryStats.freeHeap < memoryStatsMin.freeHeap) memoryStatsMin.freeHeap = memoryStats.freeHeap;
if (memoryStats.maxFreeBlock < memoryStatsMin.maxFreeBlock) memoryStatsMin.maxFreeBlock = memoryStats.maxFreeBlock;
if (memoryStats.frag < memoryStatsMin.frag) memoryStatsMin.frag = memoryStats.frag;
uint32_t cont = ESP.getFreeContStack();
if (cont > memoryStatsMax.freeContStack) memoryStatsMax.freeContStack = cont;
if (cont < memoryStatsMin.freeContStack) memoryStatsMin.freeContStack = cont;
}
void dumpCurrentMemStats() {
memory_stat_t memoryStats;
ESP.getHeapStats(&memoryStats.freeHeap, &memoryStats.maxFreeBlock, &memoryStats.frag);
debug_out(F("Memory stats: "),DEBUG_MIN_INFO,true);
debug_out(F("Free heap: \t"),DEBUG_MIN_INFO,false);
debug_out(String(memoryStats.freeHeap),DEBUG_MIN_INFO,true);
debug_out(F("Mx free blk: \t"),DEBUG_MIN_INFO,false);
debug_out(String(memoryStats.maxFreeBlock),DEBUG_MIN_INFO,true);
debug_out(F("Frag: \t"),DEBUG_MIN_INFO,false);
debug_out(String(memoryStats.frag),DEBUG_MIN_INFO,true);
debug_out(F("Free cont stack: \t"),DEBUG_MIN_INFO,false);
debug_out(String(ESP.getFreeContStack()),DEBUG_MIN_INFO,true);
}
/*****************************************************************
* display values *
*****************************************************************/
void display_debug(const String& text1, const String& text2) {
debug_out(F("output debug text to displays..."), DEBUG_MIN_INFO, 1);
debug_out(text1 + "\n" + text2, DEBUG_MAX_INFO, 1);
if (display) {
display->clear();
display->displayOn();
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 12, text1);
display->drawString(0, 24, text2);
display->display();
}
if (char_lcd) {
char_lcd -> clear();
char_lcd->setCursor(0, 0);
char_lcd->print(text1);
char_lcd->setCursor(0, 1);
char_lcd->print(text2);
}
}
/* Convert millis value to string like (2 d 3h 20m 30s)
*/
String millisToTime(const unsigned long time) {
String tmp = "";
unsigned dt = 0;
unsigned long t = time;
if ((dt = t / (24 * 60 * 60 * 1000)) > 0) {
t = t - dt * 24 * 60 * 60 * 1000;
tmp += String(dt) + String("d ");
}
//they are some hours left or hours = 0 but already have some time value in string
if ((dt = t / (60 * 60 * 1000)) > 0 || tmp.length() > 0) {
t = t - dt * 60 * 60 * 1000;
tmp += String(dt) + String("h ");
}
if ((dt = t / (60 * 1000)) > 0 || tmp.length() > 0) {
t = t - dt * 60 * 1000;
tmp += String(dt) + String("m ");
}
tmp += String(t / 1000) + String("s");
return tmp;
}
| 32,115
|
C++
|
.cpp
| 823
| 32.428919
| 177
| 0.569215
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,435
|
sending.cpp
|
nettigo_namf/src/sending.cpp
|
#include "sending.h"
#if defined(ESP8266)
BearSSL::X509List x509_dst_root_ca(dst_root_ca_x1);
void configureCACertTrustAnchor(WiFiClientSecure* client) {
constexpr time_t fw_built_year = (__DATE__[ 7] - '0') * 1000 + \
(__DATE__[ 8] - '0') * 100 + \
(__DATE__[ 9] - '0') * 10 + \
(__DATE__[10] - '0');
if (time(nullptr) < (fw_built_year - 1970) * 365 * 24 * 3600) {
debug_out(F("Time incorrect; Disabling CA verification."), DEBUG_MIN_INFO,1);
client->setInsecure();
}
else {
client->setTrustAnchors(&x509_dst_root_ca);
}
}
#endif
/*****************************************************************
* send data to rest api *
*****************************************************************/
void sendData(const LoggerEntry logger, const String &data, const int pin, const String &host, const int httpPort, const String &url, const bool verify) {
WiFiClient *client;
const __FlashStringHelper *contentType;
bool ssl = false;
if (httpPort == 443) {
client = new WiFiClientSecure;
ssl = true;
configureCACertTrustAnchor(static_cast<WiFiClientSecure *>(client));
static_cast<WiFiClientSecure *>(client)->setBufferSizes(1024, TCP_MSS > 1024 ? 2048 : 1024);
} else {
client = new WiFiClient;
}
client->setTimeout(20000);
int result = 0;
switch (logger)
{
case LoggerInflux:
contentType = FPSTR(TXT_CONTENT_TYPE_INFLUXDB);
break;
default:
contentType = FPSTR(TXT_CONTENT_TYPE_JSON);
break;
}
debug_out(F("Start connecting to "), DEBUG_MED_INFO, 0);
debug_out(host, DEBUG_MED_INFO, 1);
HTTPClient *http;
http = new HTTPClient;
http->setTimeout(20 * 1000);
http->setUserAgent(String(SOFTWARE_VERSION) + "/" + esp_chipid());
http->setReuse(false);
debug_out(String(host), DEBUG_MAX_INFO, 1);
debug_out(String(httpPort), DEBUG_MAX_INFO, 1);
debug_out(String(url), DEBUG_MAX_INFO, 1);
if (http->begin(*client, host, httpPort, url, ssl)) {
if (logger == LoggerCustom && (*cfg::user_custom || *cfg::pwd_custom))
{
http->setAuthorization(cfg::user_custom, cfg::pwd_custom);
}
if (logger == LoggerInflux && (*cfg::user_influx || *cfg::pwd_influx))
{
http->setAuthorization(cfg::user_influx, cfg::pwd_influx);
}
http->addHeader(F("Content-Type"), contentType);
http->addHeader(F("X-Sensor"), String(F("esp8266-")) + esp_chipid());
if (pin) {
http->addHeader(F("X-PIN"), String(pin));
}
debug_out(data, DEBUG_MAX_INFO);
result = http->POST(data);
if (result >= HTTP_CODE_OK && result <= HTTP_CODE_ALREADY_REPORTED) {
debug_out(F("Succeeded - "), DEBUG_MIN_INFO);
} else {
debug_out(F("Not succeeded. HTTP status code: "), DEBUG_MIN_INFO, false);
debug_out(String(result), DEBUG_MIN_INFO);
}
debug_out(F("Request result: "), DEBUG_MED_INFO, 0);
debug_out(String(result), DEBUG_MED_INFO, 1);
if (result != 204 && http->getString().length() > 0) {
debug_out(F("Details:"), DEBUG_MED_INFO, 1);
debug_out(http->getString(), DEBUG_MED_INFO, 1);
}
} else {
debug_out(F("Failed connecting"), DEBUG_MIN_INFO, 1);
}
http->end();
debug_out(F("End connecting to "), DEBUG_MED_INFO, 0);
debug_out(host, DEBUG_MED_INFO);
delete (http);
delete (client);
wdt_reset(); // nodemcu is alive
yield();
}
/*****************************************************************
* send single sensor data to luftdaten.info api *
*****************************************************************/
void sendLuftdaten(const String& data, const int pin, const char* host, const int httpPort, const char* url, const bool verify, const char* replace_str) {
String data_4_dusti = FPSTR(data_first_part);
data_4_dusti.replace(String(F("{v}")), String(SOFTWARE_VERSION));
data_4_dusti.concat(data);
data_4_dusti.remove(data_4_dusti.length() - 1);
data_4_dusti.replace(replace_str, String(F("")));
data_4_dusti.concat(String(F("]}")));
if (data != "") {
sendData(LoggerDusti, data_4_dusti, pin, host, httpPort, url, verify);
} else {
debug_out(F("No data sent..."), DEBUG_MED_INFO, 1);
}
// debugData(data_4_dusti,F("sendLuftdaten data4dusti:"));
// debugData(data,F("sendLuftdaten data out:"));
}
/*****************************************************************
* send data to LoRa gateway *
*****************************************************************/
// void send_lora(const String& data) {
// }
/*****************************************************************
* send data to mqtt api *
*****************************************************************/
// rejected (see issue #33)
/*****************************************************************
* send data to influxdb *
*****************************************************************/
String create_influxdb_string(const String& data) {
String data_4_influxdb = "";
debug_out(F("Parse JSON for influx DB"), DEBUG_MIN_INFO, 1);
debug_out(data, DEBUG_MIN_INFO, 1);
DynamicJsonBuffer jsonBuffer;
JsonObject& json2data = jsonBuffer.parseObject(data);
if (json2data.success()) {
bool first_line = true;
data_4_influxdb.concat(F("feinstaub,node=esp8266-"));
data_4_influxdb.concat(esp_chipid() + F(","));
data_4_influxdb.concat(F("fw="));
data_4_influxdb.concat(F(SOFTWARE_VERSION));
data_4_influxdb.concat(F(","));
data_4_influxdb.concat(F("hostname="));
data_4_influxdb.concat(cfg::fs_ssid);
data_4_influxdb.concat(F(","));
data_4_influxdb.concat(F("chann="));
switch (cfg::update_channel) {
case UPDATE_CHANNEL_ALFA:
data_4_influxdb.concat(F("alfa"));
break;
case UPDATE_CHANNEL_BETA:
data_4_influxdb.concat(F("beta"));
break;
case UPDATE_CHANNEL_STABLE:
data_4_influxdb.concat(F("stable"));
break;
default:
data_4_influxdb.concat(F("unknown"));
break;
}
data_4_influxdb.concat(F(" "));
for (uint8_t i = 0; i < json2data["sensordatavalues"].size(); i++) {
String tmp_str = "";
if (first_line)
first_line = false;
else
tmp_str.concat(F(","));
tmp_str.concat(json2data["sensordatavalues"][i]["value_type"].as<char *>());
tmp_str.concat(F("="));
if (
json2data["sensordatavalues"][i]["value_type"] == String(F("GPS_date")) ||
json2data["sensordatavalues"][i]["value_type"] == String(F("GPS_time"))
)
tmp_str.concat(String(F("\"")) + json2data["sensordatavalues"][i]["value"].as<char *>() + String(F("\"")));
else
tmp_str.concat(json2data["sensordatavalues"][i]["value"].as<char *>());
data_4_influxdb.concat(tmp_str);
}
#ifdef DBG_NAMF_SDS_NO_DATA
if (SDS011::enabled && (last_value_SDS_P1 == -1 || last_value_SDS_P2 == -1)) {
data_4_influxdb.concat(F(",SDS_P1="));
data_4_influxdb.concat(String(last_value_SDS_P1));
data_4_influxdb.concat(F(",SDS_P2="));
data_4_influxdb.concat(String(last_value_SDS_P2));
}
#endif
data_4_influxdb.concat(F(",measurements="));
data_4_influxdb.concat(String(count_sends+1));
data_4_influxdb.concat(F(",free="));
data_4_influxdb.concat(String(memoryStatsMin.freeHeap));
data_4_influxdb.concat(F(",frag="));
data_4_influxdb.concat(String(memoryStatsMax.frag));
data_4_influxdb.concat(F(",max_block="));
data_4_influxdb.concat(String(memoryStatsMin.maxFreeBlock));
data_4_influxdb.concat(F(",cont_stack="));
data_4_influxdb.concat(String(memoryStatsMin.freeContStack));
data_4_influxdb.concat("\n");
} else {
debug_out(FPSTR(DBG_TXT_DATA_READ_FAILED), DEBUG_ERROR, 1);
}
debug_out(data_4_influxdb,DEBUG_MIN_INFO,1);
return data_4_influxdb;
}
/*****************************************************************
* send data as csv to serial out *
*****************************************************************/
void send_csv(const String& data) {
DynamicJsonBuffer jsonBuffer;
JsonObject& json2data = jsonBuffer.parseObject(data);
debug_out(F("CSV Output"), DEBUG_MIN_INFO, 1);
debug_out(data, DEBUG_MIN_INFO, 1);
if (json2data.success()) {
String headline = F("Timestamp_ms;");
String valueline = String(act_milli) + ";";
for (uint8_t i = 0; i < json2data["sensordatavalues"].size(); i++) {
String tmp_str = json2data["sensordatavalues"][i]["value_type"].as<char*>();
headline += tmp_str + ";";
tmp_str = json2data["sensordatavalues"][i]["value"].as<char*>();
valueline += tmp_str + ";";
}
static bool first_csv_line = true;
if (first_csv_line) {
if (headline.length() > 0) {
headline.remove(headline.length() - 1);
}
Serial.println(headline);
first_csv_line = false;
}
if (valueline.length() > 0) {
valueline.remove(valueline.length() - 1);
}
Serial.println(valueline);
} else {
debug_out(FPSTR(DBG_TXT_DATA_READ_FAILED), DEBUG_ERROR, 1);
}
}
| 9,987
|
C++
|
.cpp
| 229
| 35.655022
| 154
| 0.522382
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,436
|
webserver.cpp
|
nettigo_namf/src/webserver.cpp
|
//
// Created by viciu on 17.02.2020.
//
#include "webserver.h"
unsigned maxSizeTemp = 0;
void webserverPartialSend(String &s) {
if (s.length() == 0) return; //do not end by accident, when no data to send
if (s.length() > maxSizeTemp) maxSizeTemp = s.length();
server.client().setNoDelay(1);
server.sendContent(s);
s = F("");
}
void endPartialSend(){
maxSizeTemp = 0;
server.sendContent(F(""));
}
template<typename T, std::size_t N> constexpr std::size_t capacity_null_terminated_char_array(const T(&)[N]) {
return N - 1;
}
String line_from_value(const String& name, const String& value) {
String s = F("<br/>{n}: {v}");
s.replace("{n}", name);
s.replace("{v}", value);
return s;
}
static int constexpr constexprstrlen(const char* str) {
return *str ? 1 + constexprstrlen(str + 1) : 0;
}
void sendHttpRedirect(ESP8266WebServer &httpServer) {
httpServer.sendHeader(F("Location"), F("http://192.168.4.1/config"));
httpServer.send(302, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), "");
}
String wlan_ssid_to_table_row(const String& ssid, const String& encryption, int32_t rssi) {
String s = F( "<tr>"
"<td>"
"<a href='#wlanpwd' onclick='setSSID(this)' class='wifi'>{n}</a> {e}"
"</td>"
"<td style='width:80%;vertical-align:middle;'>"
"{v}%"
"</td>"
"</tr>");
s.replace("{n}", ssid);
s.replace("{e}", encryption);
s.replace("{v}", String(calcWiFiSignalQuality(rssi)));
return s;
}
String time2NextMeasure() {
String s = FPSTR(INTL_TIME_TO_MEASUREMENT);
s.replace("{v}", String(time2Measure()/1000));
return s;
}
String timeSinceLastMeasure() {
String s = F("");
unsigned long time_since_last = msSince(starttime);
if (time_since_last > cfg::sending_intervall_ms) {
time_since_last = 0;
}
s += String((long)((time_since_last + 500) / 1000));
s += FPSTR(INTL_TIME_SINCE_LAST_MEASUREMENT);
s += F("<br/><br/>");
return s;
}
void getTimeHeadings(String &page_content){
if (first_cycle) page_content += F("<span style='color:red'>");
page_content.concat(time2NextMeasure());
if (first_cycle) page_content.concat(F(".</span><br/><br/>"));
if (!first_cycle) {
page_content.concat(F(", "));
page_content.concat(timeSinceLastMeasure());
}
}
void webserver_not_found() {
last_page_load = millis();
debug_out(F("output not found page: "), DEBUG_MIN_INFO, 0);
debug_out(server.uri(),DEBUG_MIN_INFO);
if (WiFi.status() != WL_CONNECTED) {
if ((server.uri().indexOf(F("success.html")) != -1) || (server.uri().indexOf(F("detect.html")) != -1)) {
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), FPSTR(WEB_IOS_REDIRECT));
} else {
sendHttpRedirect(server);
}
} else {
server.send(404, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), F("Not found."));
}
}
void webserver_images() {
if (server.arg("n") == F("l")) {
server.sendHeader(F("Cache-Control"), F("max-age=604800"));
server.send(200, FPSTR(TXT_CONTENT_TYPE_IMAGE_SVG), FPSTR(LUFTDATEN_INFO_LOGO_SVG));
} else if (server.arg("n") == F("c")) { //config CSS
server.sendHeader(F("Cache-Control"), F("max-age=604800"));
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_CSS), FPSTR(CONFIG_CSS));
} else if (server.arg("n") == F("c1")) { //common CSS
server.sendHeader(F("Cache-Control"), F("max-age=604800"));
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_CSS), FPSTR(COMMON_CSS));
} else if (server.arg("n") == F("j")) { //config JS
server.sendHeader(F("Cache-Control"), F("max-age=604800"));
server.send(200, FPSTR(TXT_CONTENT_TYPE_APPLICATION_JS), FPSTR(CONFIG_JS));
}
else {
webserver_not_found();
}
}
/*****************************************************************
* Webserver request auth: prompt for BasicAuth
*
* -Provide BasicAuth for all page contexts except /values and images
*****************************************************************/
bool webserver_request_auth(bool dbg_msg) {
if (dbg_msg) debug_out(F("validate request auth..."), DEBUG_MAX_INFO, 1);
if (cfg::www_basicauth_enabled && ! wificonfig_loop) {
if (!server.authenticate(cfg::www_username, cfg::www_password)) {
server.requestAuthentication();
return false;
}
}
return true;
}
void webserver_dump_stack(){
if (!SPIFFS.exists ("/stack_dump")) {
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), "No stack dump");
return;
}
File dump;
char buf[100];
dump = SPIFFS.open("/stack_dump","r");
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), "");
unsigned size = dump.size();
for (byte i=0; i<=size/100; i++) {
dump.readBytes(buf,99);
server.sendContent(buf);
}
// sprintf(buf,"File size: %i bytes\n",size);
// server.sendContent(buf);
}
/*****************************************************************
* Webserver root: show all options *
*****************************************************************/
void webserver_root() {
if (WiFi.status() != WL_CONNECTED) {
sendHttpRedirect(server);
} else {
if (!webserver_request_auth())
{ return; }
String page_content = make_header(cfg::fs_ssid);
last_page_load = millis();
debug_out(F("output root page..."), DEBUG_MIN_INFO, 1);
page_content += FPSTR(WEB_ROOT_PAGE_CONTENT);
page_content.replace("{t}", FPSTR(INTL_CURRENT_DATA));
//page_content.replace(F("{map}"), FPSTR(INTL_ACTIVE_SENSORS_MAP));
page_content.replace(F("{conf}"), FPSTR(INTL_CONFIGURATION));
page_content.replace(F("{status}"), FPSTR(INTL_STATUS_PAGE));
page_content.replace(F("{conf_delete}"), FPSTR(INTL_CONFIGURATION_DELETE));
page_content.replace(F("{restart}"), FPSTR(INTL_RESTART_SENSOR));
page_content.replace(F("{debug}"), FPSTR(INTL_DEBUG));
page_content += make_footer();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
}
/*****************************************************************
* html helper functions *
*****************************************************************/
String make_header(const String& title, bool configPage) {
String s;
if (configPage)
s = FPSTR(CONFIG_WEB_PAGE_HEADER);
else
s = FPSTR(WEB_PAGE_HEADER);
s.replace("{tt}", FPSTR(INTL_PM_SENSOR));
s.replace("{h}", FPSTR(INTL_HOME));
if (title != " ") {
s.replace("{n}", F("»"));
} else {
s.replace("{n}", "");
}
String v = F("<a class=\"plain\" href=\"https://github.com/nettigo/namf/blob/");
switch (cfg::update_channel) {
case UPDATE_CHANNEL_STABLE:
v += F("master/Versions.md");
break;
case UPDATE_CHANNEL_BETA:
v += F("beta/Versions.md");
break;
case UPDATE_CHANNEL_ALFA:
v += F("new_sds011/Versions-alfa.md");
break;
}
v += F("\">");
v += String(SOFTWARE_VERSION);
v += F("</a>");
#ifdef BUILD_TIME
v+="(";
char timestamp[16];
struct tm ts;
time_t t = BUILD_TIME;
ts = *localtime(&t);
strftime(timestamp,16, "%Y%m%d-%H%M%S", &ts);
v+=String(timestamp);
v+=")";
#endif
s.replace("{t}", title);
s.replace("{sname}", cfg::fs_ssid);
s.replace("{id}", esp_chipid());
s.replace("{mac}", WiFi.macAddress());
s.replace("{fwt}", FPSTR(INTL_FIRMWARE));
s.replace("{fw}", v);
return s;
}
String make_footer(bool configPage) {
String s;
if (configPage)
s = FPSTR(CONFIG_WEB_PAGE_FOOTER);
else
s = FPSTR(WEB_PAGE_FOOTER);
s.replace("{t}", FPSTR(INTL_BACK_TO_HOME));
return s;
}
//Webserver - current config as JSON (txt) to save
void webserver_config_json() {
if (!webserver_request_auth())
{ return; }
String page_content = getMaskedConfigString();
server.send(200, FPSTR(TXT_CONTENT_TYPE_JSON), page_content);
}
//Webserver - force update with custom URL
void webserver_config_force_update() {
if (!webserver_request_auth()) { return; }
String page_content = make_header(FPSTR(INTL_CONFIGURATION));
if (server.method() == HTTP_POST) {
if (server.hasArg("ver") && server.hasArg("lg") ) {
page_content.concat(make_footer());
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
delay(200);
cfg::auto_update = false;
writeConfig();
cfg::auto_update = true;
String p = F("/NAMF/data/2020-");
p.concat(server.arg("ver"));
p.concat(F("/latest_"));
p.concat(server.arg("lg"));
p.concat(F(".bin"));
debug_out(F("Downgrade attempt to: "),DEBUG_ERROR, false);
debug_out(p, DEBUG_ERROR);
updateFW(F("fw.nettigo.pl"), F("80"), p);
delay(5000);
ESP.restart();
}
else {
server.sendHeader(F("Location"), F("/"));
}
}else {
page_content.concat(F("<h2>Force update</h2>"));
page_content.concat(
F("<p>It will disable autoupdate, and try to reinstall older NAMF version. To return to newest version "
"just re-eneable autoupdate in config.</p>"
"<form method='POST' action='/rollback' style='width:100%;'>")
);
page_content.concat(F("Select version: <select name='ver'><option value='43'>2020-43</option><option value='42'>2020-42</option></select><br/>"));
page_content.concat(F("Select language: <select name='lg'><option value='en'>English</option><option value='pl'>Polish</option></select><br/>"));
page_content.concat(F("<br/>"));
page_content.concat(form_submit(FPSTR(INTL_SAVE_AND_RESTART)));
page_content.concat(F("</form>"));
page_content.concat(make_footer());
}
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
//Webserver - current config as JSON (txt) to save
void webserver_config_json_save() {
if (!webserver_request_auth())
{ return; }
String page_content = make_header(FPSTR(INTL_CONFIGURATION));
if (server.method() == HTTP_POST) {
if (server.hasArg("json")) {
if (writeConfigRaw(server.arg("json"),"/test.json")) {
server.send(500, TXT_CONTENT_TYPE_TEXT_PLAIN,F("Error writing config"));
return; //we dont have reason to restart, current config was not altered yet
};
File tempCfg = SPIFFS.open ("/test.json", "r");
if (readAndParseConfigFile(tempCfg)) {
server.send(500, TXT_CONTENT_TYPE_TEXT_PLAIN,F("Error parsing config"));
delay(500);
ESP.restart(); // we dont know in what state config is. Maybe something was read maybe not
return;
}
//now config is mix of and new config file. Should be save to save it
writeConfig();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
delay(5000);
Serial.println(F("RESET"));
ESP.restart();
}
else {
server.sendHeader(F("Location"), F("/"));
}
}else {
page_content += F("<a href=\"/config.json\" target=\"_blank\">Sensor config in JSON</a><br/><br/>");
page_content += F("<form name=\"json_form\" method='POST' action='/configSave.json' style='width:100%;'>");
page_content += F("<textarea id=\"json\" name=\"json\" rows=\"10\" cols=\"120\"></textarea><br/>");
page_content += form_submit(FPSTR(INTL_SAVE_AND_RESTART));
page_content += F("</form>");
page_content += make_footer();
}
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
void readPwdParam(char **dst, const String key) {
if (server.hasArg(key)) {
String masked_pwd = F("");
unsigned int respSize = server.arg(key).length();
masked_pwd.reserve(respSize);
for (uint8_t i=0;i<respSize;i++)
masked_pwd += F("*");
if (masked_pwd != server.arg(key) || server.arg(key) == F("")) {
stringToChar(dst,server.arg(key));
}
}
}
/*****************************************************************
* Webserver config: show config page *
*****************************************************************/
void webserverConfigBasic(String & page_content) {
}
#pragma clang diagnostic push
#pragma ide diagnostic ignored "bugprone-macro-parentheses"
void parse_config_request(String &page_content) {
using namespace cfg;
String masked_pwd = "";
#define readCharParam(param) \
if (server.hasArg(#param)){ \
server.arg(#param).toCharArray(param, sizeof(param)); \
}
#define readBoolParam(param) \
param = false; \
if (server.hasArg(#param)){ \
(param) = server.arg(#param) == "1";\
}
#define readIntParam(param) \
if (server.hasArg(#param)){ \
param = server.arg(#param).toInt(); \
}
#define readFloatParam(param) \
if (server.hasArg(#param)){ \
param = server.arg(#param).toFloat(); \
}
#define readTimeParam(param) \
if (server.hasArg(#param)){ \
int val = server.arg(#param).toInt(); \
param = val*1000; \
}
#define readPasswdParam(param) \
if (server.hasArg(#param)){ \
masked_pwd = ""; \
for (uint8_t i=0;i<server.arg(#param).length();i++) \
masked_pwd += "*"; \
if (masked_pwd != server.arg(#param) || server.arg(#param) == "") {\
server.arg(#param).toCharArray(param, sizeof(param)); \
}\
}
if (server.hasArg(F("wlanssid")) && server.arg(F("wlanssid")) != F("")) {
if (server.hasArg(F("wlanssid"))){
stringToChar(&wlanssid,server.arg(F("wlanssid")));
}
readPwdParam(&wlanpwd,F("wlanpwd"));
}
if (server.hasArg(F("fbssid")) && server.arg(F("fbssid")) != F("")) {
if (server.hasArg(F("fbssid"))){
stringToChar(&fbssid,server.arg(F("fbssid")));
}
readPwdParam(&fbpwd,F("fbpwd"));
}
//always allow to change output power
readFloatParam(outputPower);
readIntParam(phyMode);
readCharParam(current_lang);
if (server.hasArg(F("www_username"))){
stringToChar(&www_username,server.arg(F("www_username")));
}
readPwdParam(&www_password,F("www_password"));
// readPasswdParam(www_password);
readBoolParam(www_basicauth_enabled);
if (server.hasArg(F("fs_ssid"))){
stringToChar(&fs_ssid,server.arg(F("fs_ssid")));
}
if (server.hasArg(F("fs_pwd")) &&
((server.arg(F("fs_pwd")).length() > 7) || (server.arg(F("fs_pwd")).length() == 0))) {
readPwdParam(&fs_pwd,F("fs_pwd"));
}
readBoolParam(send2dusti);
readBoolParam(ssl_dusti);
readBoolParam(send2madavi);
readBoolParam(ssl_madavi);
readBoolParam(dht_read);
readBoolParam(sds_read);
readBoolParam(pms_read);
readBoolParam(bmp280_read);
readBoolParam(bme280_read);
readBoolParam(heca_read);
readBoolParam(ds18b20_read);
readBoolParam(gps_read);
readIntParam(debug);
readTimeParam(sending_intervall_ms);
readTimeParam(time_for_wifi_config);
readBoolParam(send2csv);
readBoolParam(send2fsapp);
readBoolParam(send2sensemap);
readCharParam(senseboxid);
readBoolParam(send2custom);
parseHTTP(F("host_custom"), host_custom);
parseHTTP(F("url_custom"), url_custom);
readIntParam(port_custom);
readCharParam(user_custom);
readPasswdParam(pwd_custom);
if (server.hasArg(F("user_custom"))){
stringToChar(&user_custom,server.arg(F("user_custom")));
}
if (server.hasArg(F("pwd_custom"))) {
readPwdParam(&pwd_custom,F("pwd_custom"));
}
readBoolParam(send2aqi);
parseHTTP(F("token_AQI"), token_AQI);
readBoolParam(send2influx);
parseHTTP(F("host_influx"), host_influx);
parseHTTP(F("url_influx"), url_influx);
readIntParam(port_influx);
if (server.hasArg(F("user_influx"))){
stringToChar(&user_influx,server.arg(F("user_influx")));
}
if (server.hasArg(F("pwd_custom"))) {
readPwdParam(&pwd_custom,F("pwd_custom"));
}
readBoolParam(auto_update);
parseHTTP(F("channel"), update_channel);
readBoolParam(has_display);
has_lcd1602 = false;
has_lcd1602_27 = false;
has_lcd2004_27 = false;
has_lcd2004_3f = false;
if (server.hasArg("has_lcd")) {
switch (server.arg("lcd_type").toInt()) {
case 1:
has_lcd1602_27 = true;
break;
case 2:
has_lcd1602 = true;
break;
case 3:
has_lcd2004_27 = true;
break;
case 4:
has_lcd2004_3f = true;
break;
}
}
readBoolParam(show_wifi_info);
readBoolParam(sh_dev_inf);
readBoolParam(has_ledbar_32);
#undef readCharParam
#undef readBoolParam
#undef readIntParam
#undef readTimeParam
#undef readPasswdParam
page_content.concat(formSectionHeader(FPSTR(INTL_SENSOR_IS_REBOOTING), 1));
}
#pragma clang diagnostic pop
void tabTemplate(String &page_content, const __FlashStringHelper *id, const __FlashStringHelper *name){
page_content.concat(F("<button class=\"tablinks\" onclick=\"tab(event, '"));
page_content.concat(id);
page_content.concat(F("')\">"));
page_content.concat(name);
page_content.concat(F("</button>\n"));
}
void webserver_config(){
if (!webserver_request_auth()) { return; }
server.sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
server.sendHeader(F("Pragma"), F("no-cache"));
server.sendHeader(F("Expires"), F("0"));
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
String page_content;
page_content.reserve(5000);
page_content = make_header(FPSTR(INTL_CONFIGURATION), true);
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
page_content = F("");
last_page_load = millis();
debug_out(F("output config page ..."), DEBUG_MIN_INFO, 1);
if (wificonfig_loop) { // scan for wlan ssids
page_content += FPSTR(WEB_CONFIG_SCRIPT);
}
// webserverPartialSend(page_content);
using namespace cfg;
// webserverPartialSend(page_content);
if (server.method() == HTTP_GET) {
page_content.concat(F("<div class=\"tab\">\n"));
tabTemplate(page_content, F("basic"), FPSTR(INTL_TAB_BASIC));
tabTemplate(page_content, F("api"), FPSTR(INTL_TAB_API));
tabTemplate(page_content, F("adv"), FPSTR(INTL_TAB_ADVANCED));
tabTemplate(page_content, F("sensors"), FPSTR(INTL_TAB_SENSORS));
page_content.concat(F("</div>"));
page_content.concat(F("<form method='POST' id='oldForm' action='/config' >"));
page_content.concat(F("<div id='basic' class='tabcontent'>"));
page_content.concat(F("<div class='gc'>"));
page_content.concat( formSectionHeader(FPSTR(INTL_WIFI_SETTINGS)));
debug_out(F("output config page 1"), DEBUG_MIN_INFO, 1);
if (wificonfig_loop) { // scan for wlan ssids
page_content.concat(F("<div id='wifilist' class='row'>"));
page_content.concat(FPSTR(INTL_WIFI_NETWORKS));
page_content.concat(F("</div>"));
page_content.concat(F("<script>window.setTimeout(load_wifi_list,1000);</script>"));
}
page_content.concat(formInputGrid(F("wlanssid"), FPSTR(INTL_FS_WIFI_NAME), wlanssid,
35));
if (!wificonfig_loop) {
page_content.concat(formPasswordGrid(F("wlanpwd"), FPSTR(INTL_PASSWORD), wlanpwd,
65));
} else {
page_content.concat(formInputGrid(F("wlanpwd"), FPSTR(INTL_PASSWORD), F(""),
65));
}
page_content.concat(formSectionHeader(FPSTR(INTL_BASICAUTH)));
page_content.concat(formCheckboxGrid("www_basicauth_enabled", FPSTR(INTL_ENABLE), www_basicauth_enabled));
page_content.concat(formInputGrid(F("www_username"), FPSTR(INTL_USER), www_username,
30));
page_content.concat(formPasswordGrid(F("www_password"), FPSTR(INTL_PASSWORD), www_password,
30));
page_content.concat(formSectionHeader(FPSTR(INTL_MORE_SETTINGS)));
page_content.concat(formCheckboxOpenGrid("has_lcd", FPSTR(INTL_LCD),
has_lcd1602 || has_lcd1602_27 || has_lcd2004_3f || has_lcd2004_27));
page_content.concat(F("<div class='c2'><select name=\"lcd_type\">"));
page_content.concat(form_option("1", FPSTR(INTL_LCD1602_27), has_lcd1602_27));
page_content.concat(form_option("2", FPSTR(INTL_LCD1602_3F), has_lcd1602));
page_content.concat(form_option("3", FPSTR(INTL_LCD2004_27), has_lcd2004_27));
page_content.concat(form_option("4", FPSTR(INTL_LCD2004_3F), has_lcd2004_3f));
page_content.concat(F("</select></div>"));
page_content.concat(formCheckboxGrid("show_wifi_info", FPSTR(INTL_SHOW_WIFI_INFO), show_wifi_info));
page_content.concat(formCheckboxGrid("sh_dev_inf", FPSTR(INTL_SHOW_DEVICE_INFO), sh_dev_inf));
webserverPartialSend(page_content);
page_content.concat(form_select_lang());
page_content.concat(formInputGrid("sending_intervall_ms", FPSTR(INTL_MEASUREMENT_INTERVAL),
String(sending_intervall_ms / 1000), 5));
page_content.concat(formSubmitGrid(FPSTR(INTL_SAVE_AND_RESTART)));
page_content.concat(F("</div>")); //grid
page_content.concat(F("</div>")); //tabcontent
page_content.concat(F("<div id='api' class='tabcontent'>"));
page_content.concat(F("<div class='gc'>"));
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), F("API Sensor Community")));
page_content.concat(formCheckboxGrid("send2dusti", FPSTR(INTL_ENABLE), send2dusti));
page_content.concat(formCheckboxGrid("ssl_dusti", FPSTR(INTL_USE_HTTPS), ssl_dusti));
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), F("API Madavi.de")));
page_content.concat(formCheckboxGrid("send2madavi", FPSTR(INTL_ENABLE), send2madavi));
page_content.concat(formCheckboxGrid("ssl_madavi", FPSTR(INTL_USE_HTTPS), ssl_madavi));
webserverPartialSend(page_content);
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), FPSTR(INTL_AQI_ECO_API)));
page_content.concat(formCheckboxGrid("send2aqi", FPSTR(INTL_ENABLE), send2aqi));
page_content.concat(formInputGrid(F("token_AQI"), FPSTR(INTL_AQI_TOKEN), token_AQI, 60));
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), FPSTR(INTL_SEND_TO_OWN_API)));
page_content.concat(formCheckboxGrid("send2custom", FPSTR(INTL_ENABLE), send2custom));
page_content.concat(formInputGrid(F("host_custom"), FPSTR(INTL_SERVER), host_custom, 60));
page_content.concat(formInputGrid(F("url_custom"), FPSTR(INTL_PATH), url_custom, 60));
constexpr int max_port_digits = constexprstrlen("65535");
page_content.concat(formInputGrid(F("port_custom"), FPSTR(INTL_PORT), String(port_custom), max_port_digits));
page_content.concat(formInputGrid(F("user_custom"), FPSTR(INTL_USER), user_custom,
35));
page_content.concat(formPasswordGrid("pwd_custom", FPSTR(INTL_PASSWORD), pwd_custom,
35));
webserverPartialSend(page_content);
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), F("InfluxDB")));
page_content.concat(formCheckboxGrid("send2influx", FPSTR(INTL_ENABLE), send2influx));
page_content.concat(formInputGrid(F("host_influx"), FPSTR(INTL_SERVER), host_influx, 60));
page_content.concat(formInputGrid(F("url_influx"), FPSTR(INTL_PATH), url_influx, 60));
page_content.concat(formInputGrid("port_influx", FPSTR(INTL_PORT), String(port_influx), max_port_digits));
page_content.concat(formInputGrid(F("user_influx"), FPSTR(INTL_USER), user_influx,
35));
page_content.concat(formPasswordGrid(F("pwd_influx"), FPSTR(INTL_PASSWORD), pwd_influx,
35));
formSectionHeader(page_content, FPSTR(INTL_OTHER_APIS));
page_content.concat(formCheckboxGrid("send2csv", tmpl(FPSTR(INTL_SEND_TO), F("CSV")), send2csv));
page_content.concat(formCheckboxGrid("send2fsapp", tmpl(FPSTR(INTL_SEND_TO), F("Feinstaub-App")), send2fsapp));
formSectionHeader(page_content, tmpl(FPSTR(INTL_SEND_TO), F("OpenSenseMap")));
page_content.concat(
formCheckboxGrid("send2sensemap", FPSTR(INTL_ENABLE), send2sensemap));
page_content.concat(formInputGrid("senseboxid", "senseBox-ID: ", senseboxid,
capacity_null_terminated_char_array(senseboxid)));
page_content.concat(formSubmitGrid(FPSTR(INTL_SAVE_AND_RESTART)));
page_content.concat(F("</div>")); //grid
page_content.concat(F("</div>")); //tabcontent
webserverPartialSend(page_content);
page_content.concat(F("<div id='adv' class='tabcontent'>"));
page_content.concat(F("<div class='gc'>"));
formSectionHeader(page_content, FPSTR(INTL_MORE_SETTINGS));
page_content.concat(formSectionHeader(FPSTR(INTL_FALBACK_WIFI)));
page_content.concat(formInputGrid(F("fbssid"), FPSTR(INTL_FS_WIFI_NAME), fbssid,
35));
page_content.concat(formPasswordGrid(F("fbpwd"), FPSTR(INTL_PASSWORD), fbpwd,
65));
page_content.concat(formInputGrid("debug", FPSTR(INTL_DEBUG_LEVEL), String(debug), 1));
page_content.concat(formInputGrid("time_for_wifi_config", FPSTR(INTL_DURATION_ROUTER_MODE),
String(time_for_wifi_config / 1000), 5));
page_content.concat(formInputGrid("outputPower", FPSTR(INTL_WIFI_TX_PWR), String(outputPower), 5));
page_content.concat(formInputGrid("phyMode", FPSTR(INTL_WIFI_PHY_MODE), String(phyMode), 5));
page_content.concat(formSectionHeader(FPSTR(INTL_FS_WIFI)));
page_content.concat(formSectionHeader(FPSTR(INTL_FS_WIFI_DESCRIPTION), 3));
page_content.concat(formInputGrid(F("fs_ssid"), FPSTR(INTL_FS_WIFI_NAME), fs_ssid,
35));
page_content.concat(formPasswordGrid(F("fs_pwd"), FPSTR(INTL_PASSWORD), fs_pwd,
65));
webserverPartialSend(page_content);
page_content.concat(formCheckboxOpenGrid("auto_update", FPSTR(INTL_AUTO_UPDATE), auto_update));
page_content.concat(F("<div class='c2'><select name=\"channel\">"));
page_content.concat(form_option(String(UPDATE_CHANNEL_STABLE), FPSTR(INTL_UPDATE_STABLE),
update_channel == UPDATE_CHANNEL_STABLE));
page_content.concat(form_option(String(UPDATE_CHANNEL_BETA), FPSTR(INTL_UPDATE_BETA),
update_channel == UPDATE_CHANNEL_BETA));
page_content.concat(form_option(String(UPDATE_CHANNEL_ALFA), FPSTR(INTL_UPDATE_ALFA),
update_channel == UPDATE_CHANNEL_ALFA));
page_content.concat(F("</select></div>"));
page_content.concat(formCheckboxGrid("has_display", FPSTR(INTL_DISPLAY), has_display));
page_content.concat(formCheckboxGrid("has_ledbar_32", FPSTR(INTL_LEDBAR_32), has_ledbar_32));
page_content.concat(formCheckboxGrid("send_diag", FPSTR(INTL_DIAGNOSTIC), send_diag));
webserverPartialSend(page_content);
if (wificonfig_loop) { //outputPower should be able to change in both modes
page_content.concat(formInputGrid("outputPower", FPSTR(INTL_WIFI_TX_PWR), String(outputPower), 5));
page_content.concat(formInputGrid("phyMode", FPSTR(INTL_WIFI_PHY_MODE), String(phyMode), 5));
}
page_content.concat(formSubmitGrid(FPSTR(INTL_SAVE_AND_RESTART)));
page_content.concat(F("</div>")); //grid
page_content.concat(F("</div>")); //tabcontent
page_content.concat(F("<div id='sensors' class='tabcontent'>"));
page_content.concat(F("<div class='gc'>"));
page_content.concat(formSectionHeader(FPSTR(INTL_SENSORS)));
page_content.concat(formCheckboxGrid("pms_read", FPSTR(INTL_PMS), pms_read));
page_content.concat(formCheckboxGrid("dht_read", FPSTR(INTL_DHT22), dht_read));
page_content.concat(formCheckboxGrid("ds18b20_read", FPSTR(INTL_DS18B20), ds18b20_read));
page_content.concat(formCheckboxGrid("gps_read", FPSTR(INTL_NEO6M), gps_read));
page_content.concat(formSubmitGrid(FPSTR(INTL_SAVE_AND_RESTART)));
page_content.concat(F("</form>"));
page_content.concat(F("</div>"));
scheduler.getConfigForms(page_content);
page_content.concat(F("</div>"));
webserverPartialSend(page_content);
} else {
parse_config_request(page_content);
}
webserverPartialSend(page_content);
// page_content.concat(F("<br>"));
// page_content.concat(String(maxSizeTemp));
page_content.concat(F("<script>const beforeUnloadListener = (event) => {\n"
" event.preventDefault();\n"
" return event.returnValue = \"Are1 you sure you want to exit?\";"
"};"
"function warn(){addEventListener(\"beforeunload\", beforeUnloadListener, {capture: true});};\n"
"function submit(){removeEventListener(\"beforeunload\", beforeUnloadListener, {capture: true});};\n"
"document.querySelectorAll(\"#oldForm input:not(#ncf input)\").forEach(e=>{e.addEventListener(\"change\",warn)});\n"
"document.querySelector(\"#oldForm\").addEventListener(\"submit\",submit,false);\n"
"</script>"));
page_content.concat(make_footer(true));
webserverPartialSend(page_content);
endPartialSend();
if (server.method() == HTTP_POST) {
debug_out(F("Writing config and restarting"), DEBUG_MIN_INFO, true);
display_debug(F("Writing config"), F("and restarting"));
writeConfig();
delay(500);
ESP.restart();
}
//send.
}
/**************************************************************************
* Parse sensor config - new, simple scheduler
**************************************************************************/
void webserver_simple_config() {
if (!webserver_request_auth()) { return; }
String page_content = make_header(FPSTR(INTL_CONFIGURATION));
last_page_load = millis();
debug_out(F("output config page ..."), DEBUG_MIN_INFO, 1);
// if (server.method() == HTTP_POST) {
if (server.hasArg(F("sensor"))) {
SimpleScheduler::LoopEntryType sensor;
sensor = static_cast<SimpleScheduler::LoopEntryType>(server.arg(F("sensor")).toInt());
JsonObject &ret = SimpleScheduler::parseHTTPConfig(sensor);
ret.printTo(Serial);
if (ret.containsKey(F("err"))){
page_content += F("<h2>");
page_content += String(ret.get<char *>(F("err")) );//ret.get<char *>(F("err"));
page_content += F("</h2>");
} else {
SimpleScheduler::readConfigJSON(sensor, ret);
page_content.concat("<h3>");
page_content.concat(SimpleScheduler::findSlotKey(sensor));
page_content.concat("</h3>");
page_content.concat(FPSTR(INTL_CONFIG_SAVED));
}
writeConfig();
}
page_content += make_footer();
server.sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate"));
server.sendHeader(F("Pragma"), F("no-cache"));
server.sendHeader(F("Expires"), F("0"));
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
// } else {
// webserver_not_found();
// }
}
String table_row_from_value(const String &sensor, const String ¶m, const String &value, const String &unit) {
String s = F("<tr>"
"<td>{s}</td>"
"<td>{p}</td>"
"<td class='r'>{v} {u}</td>"
"</tr>");
s.replace("{s}", sensor);
s.replace("{p}", param);
s.replace("{v}", value);
s.replace("{u}", unit);
return s;
}
/*****************************************************************
* Webserver wifi: show available wifi networks *
*****************************************************************/
void webserver_wifi() {
debug_out(F("wifi networks found: "), DEBUG_MIN_INFO, 0);
debug_out(String(count_wifiInfo), DEBUG_MIN_INFO, 1);
String page_content = "";
if (count_wifiInfo == 0) {
page_content += BR_TAG;
page_content += FPSTR(INTL_NO_NETWORKS);
page_content += BR_TAG;
} else {
std::unique_ptr<int[]> indices(new int[count_wifiInfo]);
debug_out(F("output config page 2"), DEBUG_MIN_INFO, 1);
for (int i = 0; i < count_wifiInfo; i++) {
indices[i] = i;
}
for (int i = 0; i < count_wifiInfo; i++) {
for (int j = i + 1; j < count_wifiInfo; j++) {
if (wifiInfo[indices[j]].RSSI > wifiInfo[indices[i]].RSSI) {
std::swap(indices[i], indices[j]);
}
}
}
debug_out(F("output config page 3"), DEBUG_MIN_INFO, 1);
int duplicateSsids = 0;
for (int i = 0; i < count_wifiInfo; i++) {
if (indices[i] == -1) {
continue;
}
for (int j = i + 1; j < count_wifiInfo; j++) {
if (strncmp(wifiInfo[indices[i]].ssid, wifiInfo[indices[j]].ssid, 35) == 0) {
indices[j] = -1; // set dup aps to index -1
++duplicateSsids;
}
}
}
page_content += FPSTR(INTL_NETWORKS_FOUND);
page_content += String(count_wifiInfo - duplicateSsids);
page_content += FPSTR(BR_TAG);
page_content += FPSTR(BR_TAG);
page_content += FPSTR(TABLE_TAG_OPEN);
//if(n > 30) n=30;
for (int i = 0; i < count_wifiInfo; ++i) {
if (indices[i] == -1 || wifiInfo[indices[i]].isHidden) {
continue;
}
// Print SSID and RSSI for each network found
page_content += wlan_ssid_to_table_row(wifiInfo[indices[i]].ssid, ((wifiInfo[indices[i]].encryptionType == ENC_TYPE_NONE) ? " " : u8"🔒"), wifiInfo[indices[i]].RSSI);
}
page_content += FPSTR(TABLE_TAG_CLOSE_BR);
page_content += FPSTR(BR_TAG);
}
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/*****************************************************************
* Webserver root: show latest values *
*****************************************************************/
void webserver_values() {
if (WiFi.status() != WL_CONNECTED) {
sendHttpRedirect(server);
} else {
String page_content;
page_content.reserve(4000);
page_content = make_header(FPSTR(INTL_CURRENT_DATA));
const String unit_PM = "µg/m³";
const String unit_T = "°C";
const String unit_H = "%";
const String unit_P = "hPa";
last_page_load = millis();
debug_out(F("output values to web page..."), DEBUG_MIN_INFO, 1);
getTimeHeadings(page_content);
if (cfg::send2madavi) {
String link(F("<a class=\"plain\" href=\"https://api-rrd.madavi.de/grafana/d/GUaL5aZMz/pm-sensors?orgId=1&var-chipID=esp8266-{id}\" target=\"_blank\">{n}</a>"));
link.replace(F("{id}"), esp_chipid());
link.replace(F("{n}"), FPSTR(INTL_MADAVI_LINK));
page_content.concat(link);
}
page_content.concat(F("<table cellspacing='0' border='1' cellpadding='5'>"));
page_content.concat(tmpl(F("<tr><th>{v1}</th><th>{v2}</th><th>{v3}</th>"), FPSTR(INTL_SENSOR), FPSTR(INTL_PARAMETER), FPSTR(INTL_VALUE)));
if (cfg::pms_read) {
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_PMSx003), "PM1", check_display_value(last_value_PMS_P0, -1, 1, 0), unit_PM));
page_content.concat(table_row_from_value(FPSTR(SENSORS_PMSx003), "PM2.5", check_display_value(last_value_PMS_P2, -1, 1, 0), unit_PM));
page_content.concat(table_row_from_value(FPSTR(SENSORS_PMSx003), "PM10", check_display_value(last_value_PMS_P1, -1, 1, 0), unit_PM));
}
if (cfg::dht_read) {
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_DHT22), FPSTR(INTL_TEMPERATURE), check_display_value(last_value_DHT_T, -128, 1, 0), unit_T));
page_content.concat(table_row_from_value(FPSTR(SENSORS_DHT22), FPSTR(INTL_HUMIDITY), check_display_value(last_value_DHT_H, -1, 1, 0), unit_H));
}
if (cfg::ds18b20_read) {
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_DS18B20), FPSTR(INTL_TEMPERATURE), check_display_value(last_value_DS18B20_T, -128, 1, 0), unit_T));
}
if (cfg::gps_read) {
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(F("GPS"), FPSTR(INTL_LATITUDE), check_display_value(last_value_GPS_lat, -200.0, 6, 0), "°"));
page_content.concat(table_row_from_value(F("GPS"), FPSTR(INTL_LONGITUDE), check_display_value(last_value_GPS_lon, -200.0, 6, 0), "°"));
page_content.concat(table_row_from_value(F("GPS"), FPSTR(INTL_ALTITUDE), check_display_value(last_value_GPS_alt, -1000.0, 2, 0), "m"));
page_content.concat(table_row_from_value(F("GPS"), FPSTR(INTL_DATE), last_value_GPS_date, ""));
page_content.concat(table_row_from_value(F("GPS"), FPSTR(INTL_TIME), last_value_GPS_time, ""));
}
SimpleScheduler::getResultsAsHTML(page_content);
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(F("NAM"),FPSTR(INTL_NUMBER_OF_MEASUREMENTS),String(count_sends),""));
page_content.concat(table_row_from_value(F("NAM"),F("Uptime"), millisToTime(millis()),""));
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
}
/*****************************************************************
* Webserver set debug level *
*****************************************************************/
const char *DEBUG_NAMES[] PROGMEM = {INTL_NONE, INTL_ERROR, INTL_WARNING, INTL_MIN_INFO, INTL_MED_INFO, INTL_MAX_INFO};
void webserver_debug_level() {
if (!webserver_request_auth()) { return; }
String page_content = make_header(FPSTR(INTL_DEBUG_LEVEL));
last_page_load = millis();
debug_out(F("output change debug level page..."), DEBUG_MIN_INFO, 1);
page_content.concat(F("<div id='logField' style='height:300px;font-family:monospace;overflow-y:scroll;white-space:break-spaces'>"));
page_content.concat(Debug.popLines());
page_content.concat(("</div>\n"));
page_content.concat(FPSTR(DEBUG_JS));
page_content.concat(FPSTR(WEB_DEBUG_PAGE_CONTENT));
page_content.replace(F("{debug_level}"), FPSTR(INTL_DEBUG_LEVEL));
page_content.replace(F("{none}"), FPSTR(INTL_NONE));
page_content.replace(F("{error}"), FPSTR(INTL_ERROR));
page_content.replace(F("{warning}"), FPSTR(INTL_WARNING));
page_content.replace(F("{min_info}"), FPSTR(INTL_MIN_INFO));
page_content.replace(F("{med_info}"), FPSTR(INTL_MED_INFO));
page_content.replace(F("{max_info}"), FPSTR(INTL_MAX_INFO));
if (server.hasArg("lvl")) {
const int lvl = server.arg("lvl").toInt();
if (lvl >= 0 && lvl <= 5) {
cfg::debug = lvl;
page_content.concat(F("<h3>"));
page_content += FPSTR(INTL_DEBUG_SETTING_TO);
page_content.concat(F(" "));
page_content += FPSTR(DEBUG_NAMES[lvl]);
page_content += F(".</h3>");
}
} else {
page_content.concat(F("<h3>"));
page_content.concat(FPSTR(INTL_DEBUG_STATUS));
page_content.concat(F(" "));
page_content.concat(FPSTR(DEBUG_NAMES[cfg::debug]));
page_content.concat(F(".</h3>"));
}
page_content += make_footer();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/*****************************************************************
* Webserver enable ota *
*****************************************************************/
void webserver_enable_ota() {
String page_content;
if (cfg::www_basicauth_enabled) {
if (!webserver_request_auth()) { return; }
page_content = make_header(FPSTR(INTL_ENABLE_OTA));
last_page_load = millis();
enable_ota_time = millis() + 60 * 1000;
ArduinoOTA.setPassword(cfg::www_password);
ArduinoOTA.begin(true);
page_content += FPSTR(INTL_ENABLE_OTA_INFO);
page_content += make_footer();
} else {
page_content = make_header(FPSTR(INTL_ENABLE_OTA));
page_content += FPSTR(INTL_ENABLE_OTA_REFUSE);
page_content += make_footer();
}
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/*****************************************************************
* Webserver remove config *
*****************************************************************/
void webserver_removeConfig() {
if (!webserver_request_auth()) { return; }
String page_content = make_header(FPSTR(INTL_DELETE_CONFIG));
String message_string = F("<h3>{v}.</h3>");
last_page_load = millis();
debug_out(F("output remove config page..."), DEBUG_MIN_INFO, 1);
if (server.method() == HTTP_GET) {
page_content += FPSTR(WEB_REMOVE_CONFIG_CONTENT);
page_content.replace("{t}", FPSTR(INTL_CONFIGURATION_REALLY_DELETE));
page_content.replace("{b}", FPSTR(INTL_DELETE));
page_content.replace("{c}", FPSTR(INTL_CANCEL));
} else {
if (SPIFFS.exists("/config.json")) { //file exists
debug_out(F("removing config.json..."), DEBUG_MIN_INFO, 1);
if (SPIFFS.remove("/config.json")) {
page_content += tmpl(message_string, FPSTR(INTL_CONFIG_DELETED));
} else {
page_content += tmpl(message_string, FPSTR(INTL_CONFIG_CAN_NOT_BE_DELETED));
}
} else {
page_content += tmpl(message_string, FPSTR(INTL_CONFIG_NOT_FOUND));
}
}
page_content += make_footer();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/*****************************************************************
* Webserver reset NodeMCU *
*****************************************************************/
void webserver_reset() {
if (!webserver_request_auth()) { return; }
String page_content = make_header(FPSTR(INTL_RESTART_SENSOR));
last_page_load = millis();
debug_out(F("output reset NodeMCU page..."), DEBUG_MIN_INFO, 1);
if (server.method() == HTTP_GET) {
page_content += FPSTR(WEB_RESET_CONTENT);
page_content.replace("{t}", FPSTR(INTL_REALLY_RESTART_SENSOR));
page_content.replace("{b}", FPSTR(INTL_RESTART));
page_content.replace("{c}", FPSTR(INTL_CANCEL));
} else {
String page_content = make_header(FPSTR(INTL_SENSOR_IS_REBOOTING));
page_content += F("<p>");
page_content += FPSTR(INTL_SENSOR_IS_REBOOTING_NOW);
page_content += F("</p>");
page_content += make_footer();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
debug_out(F("restarting..."), DEBUG_MIN_INFO, 1);
delay(300);
ESP.restart();
}
page_content += make_footer();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/********************************
*
* Display status page
*
*********************************/
void webserver_status_page(void) {
if (!webserver_request_auth()) { return; }
const int signal_quality = calcWiFiSignalQuality(WiFi.RSSI());
debug_out(F("output status page"), DEBUG_MIN_INFO, 1);
String page_content = make_header(FPSTR(INTL_STATUS_PAGE));
page_content.reserve(6000);
getTimeHeadings(page_content);
page_content.concat(F("<table cellspacing='0' border='1' cellpadding='5'>"));
page_content.concat(FPSTR(EMPTY_ROW));
String I2Clist = F("");
for (uint8_t addr = 0x07; addr <= 0x7F; addr++) {
// Address the device
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
I2Clist += String(addr, 16);
I2Clist += F(", ");
}
}
page_content.concat(table_row_from_value(F("I2C"), FPSTR(INTL_I2C_BUS), I2Clist, F("")));
SimpleScheduler::getStatusReport(page_content);
// Check for ACK (detection of device), NACK or error
page_content.concat(FPSTR(EMPTY_ROW));
if (sntp_time_is_set) {
time_t now = time(nullptr);
String tmp = (ctime(&now));
page_content.concat(table_row_from_value(F("WiFi"), FPSTR(INTL_NTP_TIME), tmp, F("")));
} else {
page_content.concat(table_row_from_value(F("WiFi"), FPSTR(INTL_NTP_TIME), FPSTR(INTL_NTP_TIME_NOT_ACC),
F("")));
}
page_content.concat(table_row_from_value(F("WiFi"), FPSTR(INTL_SIGNAL_STRENGTH), String(WiFi.RSSI()), "dBm"));
page_content.concat(table_row_from_value(F("WiFi"), FPSTR(INTL_SIGNAL_QUALITY), String(signal_quality), "%"));
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(F("NAM"), FPSTR(INTL_NUMBER_OF_MEASUREMENTS), String(count_sends), ""));
page_content.concat(table_row_from_value(F("NAM"), F("Uptime"), millisToTime(millis()), ""));
page_content.concat(table_row_from_value(F("NAM"), FPSTR(INTL_TIME_FROM_UPDATE), millisToTime(msSince(last_update_attempt)), ""));
page_content.concat(FPSTR(EMPTY_ROW));
// page_content.concat(table_row_from_value(F("NAMF"),F("LoopEntries"), String(SimpleScheduler::NAMF_LOOP_SIZE) ,""));
page_content.concat(table_row_from_value(F("NAMF"),F("Sensor slots"), String(scheduler.sensorSlots()) ,""));
page_content.concat(table_row_from_value(F("NAMF"),F("Free slots"), String(scheduler.freeSlots()) ,""));
page_content.concat(table_row_from_value(F("NAMF"),F("Sensors"), scheduler.registeredNames() ,""));
#ifdef DBG_NAMF_TIMES
page_content.concat(table_row_from_value(F("NAMF"),F("Max loop time <a style='display:inline;padding:initial' href='/time'>(reset)</a>"), String(scheduler.runTimeMax()) ,F("µs")));
page_content.concat(table_row_from_value(F("NAMF"),F("Max time for"), scheduler.maxRunTimeSystemName() ,F("")));
page_content.concat(table_row_from_value(F("NAMF"),F("Last loop time"), String(scheduler.lastRunTime()) ,F("µs")));
#endif
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(F("ESP"),F("Reset Reason"), String(ESP.getResetReason()),""));
String tmp = String(memoryStatsMin.maxFreeBlock) + String("/") + String(memoryStatsMax.maxFreeBlock);
page_content.concat(table_row_from_value(F("ESP"),F("Max Free Block Size"), tmp,"B"));
tmp = String(memoryStatsMin.frag) + String("/") + String(memoryStatsMax.frag);
page_content.concat(table_row_from_value(F("ESP"),F("Heap Fragmentation"), tmp,"%"));
tmp = String(memoryStatsMin.freeContStack) + String("/") + String(memoryStatsMax.freeContStack);
page_content.concat(table_row_from_value(F("ESP"),F("Free Cont Stack"), tmp,"B"));
tmp = String(memoryStatsMin.freeHeap) + String("/") + String(memoryStatsMax.freeHeap);
page_content.concat(table_row_from_value(F("ESP"),F("Free Memory"), tmp,"B"));
page_content.concat(table_row_from_value(F("ESP"),F("Flash ID"), String(ESP.getFlashChipId()),""));
page_content.concat(table_row_from_value(F("ESP"),F("Flash Vendor ID"), String(ESP.getFlashChipVendorId()),""));
page_content.concat(table_row_from_value(F("ESP"),F("Flash Speed"), String(ESP.getFlashChipSpeed()/1000000.0),"MHz"));
page_content.concat(table_row_from_value(F("ESP"),F("Flash Mode"), String(ESP.getFlashChipMode()),""));
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(F("ENV"),F("Core version"), String(ESP.getCoreVersion()),""));
page_content.concat(table_row_from_value(F("ENV"),F("SDK version"), String(ESP.getSdkVersion()),""));
page_content.concat(FPSTR(EMPTY_ROW));
String dbg = F("");
#ifdef DBG_NAMF_TIMES
dbg.concat("NAMF_TIMES ");
#endif
#ifdef DBG_NAMF_SDS_NO_DATA
dbg.concat("SDS_NO_DATA ");
#endif
page_content.concat(table_row_from_value(F("DEBUG"),F("Debug options"), dbg, F("")));
page_content.concat(FPSTR(TABLE_TAG_CLOSE_BR));
page_content.concat(make_footer());
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_HTML), page_content);
}
/*****************************************************************
* Webserver data.json *
*****************************************************************/
void webserver_data_json() {
String s1 = "";
unsigned long age = 0;
debug_out(F("output data json..."), DEBUG_MIN_INFO, 1);
if (first_cycle) {
s1 = FPSTR(data_first_part);
s1.replace("{v}", String(SOFTWARE_VERSION));
s1 += "]}";
age = cfg::sending_intervall_ms - msSince(starttime);
if (age > cfg::sending_intervall_ms) {
age = 0;
}
age = 0 - age;
} else {
s1 = last_data_string;
debug_out(F("last data: "), DEBUG_MIN_INFO, 0);
debug_out(s1, DEBUG_MIN_INFO, 1);
age = msSince(starttime);
if (age > cfg::sending_intervall_ms) {
age = 0;
}
}
String s2 = F(", \"age\":\"");
s2 += String((long)((age + 500) / 1000));
s2 += String(F("\", \"measurements\":\""));
s2 += String((unsigned long)(count_sends));
s2 += String(F("\", \"uptime\":\""));
s2 += String((unsigned long)(millis()/1000));
s2 += F("\", \"sensordatavalues\"");
debug_out(F("replace with: "), DEBUG_MIN_INFO, 0);
debug_out(s2, DEBUG_MIN_INFO, 1);
s1.replace(F(", \"sensordatavalues\""), s2);
debug_out(F("replaced: "), DEBUG_MIN_INFO, 0);
debug_out(s1, DEBUG_MIN_INFO, 1);
server.send(200, FPSTR(TXT_CONTENT_TYPE_JSON), s1);
}
/*****************************************************************
* Webserver prometheus metrics endpoint *
*****************************************************************/
void webserver_prometheus_endpoint() {
debug_out(F("output prometheus endpoint..."), DEBUG_MIN_INFO, 1);
String data_4_prometheus = F("software_version{version=\"{ver}\",{id}} 1\nuptime_ms{{id}} {up}\nsending_intervall_ms{{id}} {si}\nnumber_of_measurements{{id}} {cs}\n");
String id = F("node=\"esp8266-");
id += esp_chipid() + "\"";
debug_out(F("Parse JSON for Prometheus"), DEBUG_MIN_INFO, 1);
debug_out(last_data_string, DEBUG_MED_INFO, 1);
data_4_prometheus.replace("{id}", id);
data_4_prometheus.replace("{ver}", String(SOFTWARE_VERSION));
data_4_prometheus.replace("{up}", String(msSince(time_point_device_start_ms)));
data_4_prometheus.replace("{si}", String(cfg::sending_intervall_ms));
data_4_prometheus.replace("{cs}", String(count_sends));
DynamicJsonBuffer jsonBuffer;
JsonObject& json2data = jsonBuffer.parseObject(last_data_string);
if (json2data.success()) {
for (uint8_t i = 0; i < json2data["sensordatavalues"].size() - 1; i++) {
String tmp_str = json2data["sensordatavalues"][i]["value_type"].as<char*>();
data_4_prometheus += tmp_str + "{" + id + "} ";
tmp_str = json2data["sensordatavalues"][i]["value"].as<char*>();
data_4_prometheus += tmp_str + "\n";
}
data_4_prometheus += F("last_sample_age_ms{");
data_4_prometheus += id + "} " + String(msSince(starttime)) + "\n";
} else {
debug_out(FPSTR(DBG_TXT_DATA_READ_FAILED), DEBUG_ERROR, 1);
}
debug_out(data_4_prometheus, DEBUG_MED_INFO, 1);
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), data_4_prometheus);
}
#ifdef DBG_NAMF_TIMES
void webserver_reset_time(){
scheduler.resetRunTime();
server.send(200, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), F("OK"));
}
#endif
static void webserver_serial() {
if (!webserver_request_auth(false)) { return; }
String payload(Debug.popLines());
server.send(payload.length() ? 200 : 204, FPSTR(TXT_CONTENT_TYPE_TEXT_PLAIN), payload);
}
/*****************************************************************
* Webserver setup *
*****************************************************************/
void setup_webserver() {
server.on(F("/"), webserver_root);
server.on(F("/config"), webserver_config);
server.on(F("/simple_config"), webserver_simple_config);
server.on(F("/config.json"), HTTP_GET, webserver_config_json);
server.on(F("/configSave.json"), webserver_config_json_save);
server.on(F("/rollback"), webserver_config_force_update);
server.on(F("/wifi"), webserver_wifi);
server.on(F("/values"), webserver_values);
server.on(F("/debug"), webserver_debug_level);
server.on(F("/serial"), webserver_serial);
server.on(F("/ota"), webserver_enable_ota);
server.on(F("/removeConfig"), webserver_removeConfig);
server.on(F("/reset"), webserver_reset);
server.on(F("/data.json"), webserver_data_json);
server.on(F("/metrics"), webserver_prometheus_endpoint);
server.on(F("/images"), webserver_images);
server.on(F("/stack_dump"), webserver_dump_stack);
server.on(F("/status"), webserver_status_page);
#ifdef DBG_NAMF_TIMES
server.on(F("/time"), webserver_reset_time);
#endif
server.onNotFound(webserver_not_found);
debug_out(F("Starting Webserver... "), DEBUG_MIN_INFO, 0);
// debug_out(IPAddress2String(WiFi.localIP()), DEBUG_MIN_INFO, 1);
debug_out(WiFi.localIP().toString(), DEBUG_MIN_INFO, 1);
server.begin();
server.client().setNoDelay(true);
}
| 55,765
|
C++
|
.cpp
| 1,136
| 40.941901
| 185
| 0.584665
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,437
|
ledbar.cpp
|
nettigo_namf/src/display/ledbar.cpp
|
//
// Created by irukard on 09.03.2020.
//
#include "ledbar.h"
/*****************************************************************
* display LEDBAR *
*****************************************************************/
void displayLEDBar() {
double pm10 = 0;
if (SDS011::enabled) {
pm10 = last_value_SDS_P1;
} else if (cfg::pms_read) {
pm10 = last_value_PMS_P1;
}
byte scale = 4;
if (pm10 >= 250) lightLED(0, 10, 150/scale, 0, 0); // 10 LEDs in red
else if (pm10 >= 180) lightLED(0, 9, 150/scale, 0, 0); // 9 LEDs in red
else if (pm10 >= 135) lightLED(0, 8, 150/scale, 75/scale, 0); // 8 LEDs in orange
else if (pm10 >= 90) lightLED(0, 7, 150/scale, 75/scale, 0); // 7 LEDs in orange
else if (pm10 >= 70) lightLED(0, 6, 150/scale, 120/scale, 0); // 6 LEDs in yellow
else if (pm10 >= 50) lightLED(0, 5, 150/scale, 120/scale, 0); // 5 LEDs in yellow
else if (pm10 >= 37) lightLED(0, 4, 75/scale, 150/scale, 0); // 4 LEDs in yellow-green
else if (pm10 >= 25) lightLED(0, 3, 75/scale, 150/scale, 0); // 3 LEDs in yellow-green
else if (pm10 >= 12) lightLED(0, 2, 0, 150/scale, 0); // 2 LEDs in green
else if (pm10 >= 0.5) lightLED(0, 1, 0, 150/scale, 0); // 1LEDs in green
else lightLED(0, 0, 0, 2, 0);
}
/*****************************************************************
* Light LED I2C command *
*****************************************************************/
void lightLED(byte mode, byte cnt, byte red, byte green, byte blue) {
// debug_out(F("LEDBAR RGB: "), DEBUG_MIN_INFO,0);
// debug_out(String(red), DEBUG_MIN_INFO,0);
// debug_out(F(", "), DEBUG_MIN_INFO,0);
// debug_out(String(green), DEBUG_MIN_INFO,0);
// debug_out(F(", "), DEBUG_MIN_INFO,0);
// debug_out(String(blue), DEBUG_MIN_INFO,1);
// debug_out(String(cnt), DEBUG_MIN_INFO, 1);
// debug_out(String(mode), DEBUG_MIN_INFO, 1);
Wire.beginTransmission(0x32);
Wire.write(mode);
Wire.write(cnt);
Wire.write(red);
Wire.write(green);
Wire.write(blue);
// Wire.write(brightness);
Wire.endTransmission();
}
| 2,335
|
C++
|
.cpp
| 48
| 45.104167
| 101
| 0.479139
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,438
|
commons.cpp
|
nettigo_namf/src/display/commons.cpp
|
//
// Created by viciu on 16.04.2020.
//
#include "commons.h"
//used internally no need to declare outside
enum class DisplayPages {
PagePM,
PageTemp,
PageHECA,
PageGPS,
PageWIFI,
PageInfo
};
unsigned long next_display_millis = 0;
unsigned long next_display_count = 0;
unsigned static_screen_count = 0;
/*****************************************************************
* check display values, return '-' if undefined *
*****************************************************************/
String check_display_value(double value, double undef, uint8_t len, uint8_t str_len) {
String s = (value != undef ? Float2String(value, len) : "-");
while (s.length() < str_len) {
s = " " + s;
}
return s;
}
String displayGenerateFooter(unsigned int screen_count) {
String display_footer;
for (unsigned int i = 0; i < screen_count; ++i) {
display_footer += (i != (next_display_count % screen_count)) ? " . " : " o ";
}
return display_footer;
}
/*****************************************************************
* display values *
*****************************************************************/
void display_values() {
double t_value = -128.0;
double h_value = -1.0;
double t_hc_value = -128.0; // temperature inside heating chamber
double h_hc_value = -1.0; // humidity inside heating chamber
double p_value = -1.0;
String t_sensor = "";
String h_sensor = "";
String p_sensor = "";
double pm10_value = -1.0;
double pm25_value = -1.0;
String pm10_sensor = "";
String pm25_sensor = "";
double lat_value = -200.0;
double lon_value = -200.0;
double alt_value = -1000.0;
String gps_sensor = "";
String display_header = "";
String display_lines[3] = { "", "", ""};
DisplayPages screens[5];
int line_count = 0;
static_screen_count = 0;
// debug_out(F("output values to display..."), DEBUG_MAX_INFO, 1);
if (cfg::pms_read) {
pm10_value = last_value_PMS_P1;
pm10_sensor = FPSTR(SENSORS_PMSx003);
pm25_value = last_value_PMS_P2;
pm25_sensor = FPSTR(SENSORS_PMSx003);
}
if (cfg::dht_read) {
t_value = last_value_DHT_T;
t_sensor = FPSTR(SENSORS_DHT22);
h_value = last_value_DHT_H;
h_sensor = FPSTR(SENSORS_DHT22);
}
if (cfg::ds18b20_read) {
t_value = last_value_DS18B20_T;
t_sensor = FPSTR(SENSORS_DS18B20);
}
if (cfg::bmp280_read) {
t_value = last_value_BMP280_T;
t_sensor = FPSTR(SENSORS_BMP280);
p_value = last_value_BMP280_P;
p_sensor = FPSTR(SENSORS_BMP280);
}
if (BME280::isEnabled()) {
t_value = last_value_BME280_T;
t_sensor = FPSTR(SENSORS_BME280);
h_value = last_value_BME280_H;
h_sensor = FPSTR(SENSORS_BME280);
p_value = last_value_BME280_P;
p_sensor = FPSTR(SENSORS_BME280);
}
if (cfg::gps_read) {
lat_value = last_value_GPS_lat;
lon_value = last_value_GPS_lon;
alt_value = last_value_GPS_alt;
gps_sensor = "NEO6M";
}
if (cfg::pms_read) {
screens[static_screen_count++] = DisplayPages::PagePM;
}
if (cfg::dht_read || cfg::ds18b20_read || BME280::isEnabled()) {
screens[static_screen_count++] = DisplayPages::PageTemp;
}
if (cfg::gps_read) {
screens[static_screen_count++] = DisplayPages::PageGPS;
}
if (cfg::show_wifi_info) {
screens[static_screen_count++] = DisplayPages::PageWIFI; // Wifi info
}
if (cfg::sh_dev_inf) {
screens[static_screen_count++] = DisplayPages::PageInfo; // chipID, firmware and count of measurements
}
bool skipOldDisplay = false;
if (next_display_count+1 > static_screen_count) {
byte diff = next_display_count - static_screen_count;
byte minor;
SimpleScheduler::LoopEntryType sensor = scheduler.selectSensorToDisplay(diff, minor);
if (sensor == SimpleScheduler::EMPTY) {
next_display_count = 0;
} else {
String lines[] = {"","","",""};
SimpleScheduler::displaySensor(sensor, lines, 20, 4, minor);
if (display) {
display->clear();
display->displayOn();
// display->setTextAlignment(TEXT_ALIGN_CENTER);
// display->drawString(64, 1, display_header);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 1, lines[0]);
display->drawString(0, 16, lines[1]);
display->drawString(0, 28, lines[2]);
display->drawString(0, 40, lines[3]);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 52, displayGenerateFooter(static_screen_count + scheduler.countScreens()));
display->display();
}
if (char_lcd) {
char_lcd->clear();
for (byte i = 0; i < 4; i++) {
char_lcd->setCursor(0,i);
if (i==0) char_lcd->print(getLCDHeader(getLCDRows()==4));
char_lcd->print(lines[i]);
}
}
next_display_count++;
skipOldDisplay = true;
}
}
if (!skipOldDisplay) {
if (cfg::has_display || cfg::has_lcd2004_27 || cfg::has_lcd2004_3f) {
switch (screens[next_display_count % static_screen_count]) {
case (DisplayPages::PagePM):
display_header = pm25_sensor;
if (pm25_sensor != pm10_sensor) {
display_header.concat(F(" / "));
display_header.concat(pm25_sensor);
}
display_lines[0] = "PM2.5: " + check_display_value(pm25_value, -1, 1, 6) + " µg/m³";
display_lines[1] = "PM10: " + check_display_value(pm10_value, -1, 1, 6) + " µg/m³";
display_lines[2] = "";
break;
case (DisplayPages::PageTemp):
display_header = t_sensor;
if (h_sensor != "" && t_sensor != h_sensor) {
display_header += " / " + h_sensor;
}
if ((h_sensor != "" && p_sensor != "" && (h_sensor != p_sensor)) ||
(h_sensor == "" && p_sensor != "" && (t_sensor != p_sensor))) {
display_header += " / " + p_sensor;
}
if (t_sensor != "") {
display_lines[line_count++] = "Temp.: " + check_display_value(t_value, -128, 1, 6) + " °C";
}
if (h_sensor != "") {
display_lines[line_count++] = "Hum.: " + check_display_value(h_value, -1, 1, 6) + " %";
}
if (p_sensor != "") {
display_lines[line_count++] =
"Pres.: " + check_display_value(p_value / 100, (-1 / 100.0), 1, 6) + " hPa";
}
while (line_count < 3) { display_lines[line_count++] = ""; }
break;
case (DisplayPages::PageHECA):
display_header = F("NAM HECA (SHT30)");
display_lines[0] = "Temp.: " + check_display_value(t_hc_value, -128, 1, 6) + " °C";
display_lines[1] = "Hum.: " + check_display_value(h_hc_value, -1, 1, 6) + " %";
display_lines[2] = "PTC HE: Soon :)"; // PTC heater status
break;
case (DisplayPages::PageGPS):
display_header = gps_sensor;
display_lines[0] = "Lat: " + check_display_value(lat_value, -200.0, 6, 10);
display_lines[1] = "Lon: " + check_display_value(lon_value, -200.0, 6, 10);
display_lines[2] = "Alt: " + check_display_value(alt_value, -1000.0, 2, 10);
break;
case (DisplayPages::PageWIFI):
display_header = F("Wifi info");
display_lines[0] = "IP: " + WiFi.localIP().toString();
display_lines[1] = "SSID:" + WiFi.SSID();
display_lines[2] = "Signal: " + String(calcWiFiSignalQuality(WiFi.RSSI())) + "%";
break;
case (DisplayPages::PageInfo):
display_header = F("Device Info");
display_lines[0] = "ID: " + esp_chipid();
display_lines[1] = "FW: " + String(SOFTWARE_VERSION);
display_lines[2] = "Measurements: " + String(count_sends);
break;
}
if (display) {
display->clear();
display->displayOn();
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 1, display_header);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 16, display_lines[0]);
display->drawString(0, 28, display_lines[1]);
display->drawString(0, 40, display_lines[2]);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64, 52, displayGenerateFooter(static_screen_count + scheduler.countScreens()));
display->display();
}
if (cfg::has_lcd2004_27 || cfg::has_lcd2004_3f) {
display_header = getLCDHeader() + " " + display_header;
display_lines[0].replace(" µg/m³", "");
display_lines[0].replace("°", String(char(223)));
display_lines[1].replace(" µg/m³", "");
char_lcd->clear();
char_lcd->setCursor(0, 0);
char_lcd->print(display_header);
char_lcd->setCursor(0, 1);
char_lcd->print(display_lines[0]);
char_lcd->setCursor(0, 2);
char_lcd->print(display_lines[1]);
char_lcd->setCursor(0, 3);
char_lcd->print(display_lines[2]);
}
}
if (cfg::has_lcd1602_27 || cfg::has_lcd1602) {
switch (screens[next_display_count % static_screen_count]) {
case (DisplayPages::PagePM):
display_lines[0] = "PM2.5: " + check_display_value(pm25_value, -1, 1, 6);
display_lines[1] = "PM10: " + check_display_value(pm10_value, -1, 1, 6);
break;
case (DisplayPages::PageTemp):
display_lines[0] = "T: " + check_display_value(t_value, -128, 1, 6) + char(223) + "C";
display_lines[1] = "H: " + check_display_value(h_value, -1, 1, 6) + "%";
break;
case (DisplayPages::PageHECA):
display_lines[0] = "Th: " + check_display_value(t_hc_value, -128, 1, 6) + char(223) + "C";
display_lines[1] = "Hh: " + check_display_value(h_hc_value, -1, 1, 6) + "%";
break;
case (DisplayPages::PageGPS):
display_lines[0] = "Lat: " + check_display_value(lat_value, -200.0, 6, 11);
display_lines[1] = "Lon: " + check_display_value(lon_value, -200.0, 6, 11);
break;
case (DisplayPages::PageWIFI):
display_lines[0] = WiFi.localIP().toString();
display_lines[1] = WiFi.SSID();
break;
case (DisplayPages::PageInfo):
display_lines[0] = esp_chipid() + " " + String(count_sends);
display_lines[1] = String(SOFTWARE_VERSION);
break;
}
char_lcd->clear();
char_lcd->setCursor(0, 0);
char_lcd->print(display_lines[0]);
char_lcd->setCursor(0, 1);
char_lcd->print(display_lines[1]);
}
next_display_count += 1;
}
yield();
next_display_millis = millis() + DISPLAY_UPDATE_INTERVAL_MS;
}
//get LCD screen sizes. returns 0 if no LCD or graphical one (SSD1306)
byte getLCDCols(){
if (cfg::has_lcd1602 || cfg::has_lcd1602_27) return 16;
if (cfg::has_lcd2004_27 || cfg::has_lcd2004_3f) return 20;
return 0;
};
byte getLCDRows(){
if (cfg::has_lcd1602 || cfg::has_lcd1602_27) return 2;
if (cfg::has_lcd2004_27 || cfg::has_lcd2004_3f || display) return 4;
return 0;
};
String getLCDHeader(bool longDisp) {
String ret = String(next_display_count + 1);
if (longDisp)
ret += F("/");
ret += String(static_screen_count + scheduler.countScreens());
ret += F(" ");
return ret;
};
void cycleDisplay(void){
if ((cfg::has_display || cfg::has_lcd2004_27 || cfg::has_lcd2004_3f || cfg::has_lcd1602 ||
cfg::has_lcd1602_27) && (act_milli > next_display_millis)) {
display_values();
}
}
| 13,154
|
C++
|
.cpp
| 297
| 32.535354
| 115
| 0.499922
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,440
|
sht3x.cpp
|
nettigo_namf/src/sensors/sht3x/sht3x.cpp
|
//
// Created by viciu on 04.09.2020.
//
#include "sht3x.h"
#include <Arduino.h>
#include "ClosedCube_SHT31D.h"
ClosedCube_SHT31D sht30;
namespace SHT3x {
const char KEY[] PROGMEM = "SHT3x";
bool enabled = false;
bool printOnLCD = false;
long temp;
unsigned long rh;
unsigned cnt;
bool initSensor() {
sht30.begin(0x45); //on 0x44 is HECA, which uses SHT30 internally
if (sht30.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_10HZ) != SHT3XD_NO_ERROR) {
return false;
}
return true;
}
float currentTemp(void) {
if (cnt == 0) { return -128;}
return ((float)temp/100.0)/(float)cnt;
}
float currentRH(void) {
if (cnt == 0) { return -1; }
return (float) rh / 10.0 / (float) cnt;
}
bool getDisplaySetting() {
return printOnLCD;
};
String getConfigHTML() {
String s = F("");
return s;
}
void display(byte rows, byte minor, String lines[]) {
byte row = 0;
if (rows == 4) {
lines[row++] = FPSTR(SENSOR_SHT3);
}
lines[row] += F("T: ");
lines[row] += check_display_value(currentTemp(), -128, 1, 0);
lines[row] += F(" ");
lines[row] += FPSTR(UNIT_CELCIUS_LCD);
row++;
lines[row] += F("RH: ");
lines[row] += check_display_value(currentRH(), -1, 1, 0);
lines[row] += F(" ");
lines[row] += FPSTR(UNIT_PERCENT);
}
JsonObject &parseHTTPRequest(void) {
// String host;
// parseHTTP(F("host"), host);
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::SHT3x);
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::SHT3x);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
ret.printTo(Serial);
return ret;
}
String getConfigJSON(void) {
String ret = F("");
ret += Var2JsonInt(F("e"), enabled);
ret += Var2JsonInt(F("d"), printOnLCD);
return ret;
}
void readConfigJSON(JsonObject &json) {
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
scheduler.enableSubsystem(SimpleScheduler::SHT3x, enabled, SHT3x::process, FPSTR(SHT3x::KEY));
if (enabled && printOnLCD) scheduler.registerDisplay(SimpleScheduler::SHT3x, 1);
}
unsigned long process (SimpleScheduler::LoopEventType event){
switch(event) {
case SimpleScheduler::INIT:
temp = 0;
rh = 0;
cnt = 0;
if (initSensor()) {
return 1000;
} else {
return 0;
}
case SimpleScheduler::RUN:
{
SHT31D result = sht30.periodicFetchData();
if (result.error == SHT3XD_NO_ERROR) {
temp += (int) (result.t * 100);
rh += (int) (result.rh * 10);
cnt++;
}
return (15 * 1000);
}
default:
return 1000;
}
};
void resultsAsHTML(String &page_content) {
if (!enabled) {return;}
page_content.concat(FPSTR(EMPTY_ROW));
if (cnt == 0) {
page_content.concat(table_row_from_value(FPSTR("SHT3X"), FPSTR(INTL_SPS30_NO_RESULT), F(""), ""));
} else {
page_content.concat(F("<tr><td colspan='3'>"));
page_content.concat(FPSTR(INTL_SHT3X_RESULTS));
page_content.concat(F("</td></tr>\n"));
page_content.concat(table_row_from_value(F("SHT3x"), FPSTR(INTL_SHT3x_TEMP), String(currentTemp()), F(" °C")));
page_content.concat(table_row_from_value(F("SHT3x"), FPSTR(INTL_SHT3x_HUM), String(currentRH()), F(" %")));
}
}
//send data to LD API...
void sendToLD(){
if (!enabled) return;
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
String data;
results(data);
debug_out(F("SHT3x to SensorCommunity"), DEBUG_MIN_INFO, 1);
sendLuftdaten(data, 7 , HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "SHT3X_");
};
//enable sensor if no config file
void setDefaults(){
enabled = true;
printOnLCD = true;
};
void results(String &s) {
if (!enabled || cnt == 0) { return; }
String tmp;
tmp.reserve(64);
tmp = Value2Json(F("SHT3X_temperature"), String(currentTemp()));
tmp.concat(Value2Json(F("SHT3X_humidity"), String(currentRH())));
s.concat(tmp);
}
void afterSend(bool success) {
temp = 0;
rh = 0;
cnt = 0;
}
}
| 4,874
|
C++
|
.cpp
| 141
| 25.64539
| 124
| 0.541879
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,441
|
tester.cpp
|
nettigo_namf/src/sensors/network_watchdog/tester.cpp
|
//
// Created by viciu on 26.06.2020.
//
#include "tester.h"
#define NTW_WTD_COUNT 10
namespace NetworkWatchdog {
// const char
const char KEY[] PROGMEM = "NTW_WTD";
bool enabled = false;
bool configured = false;
bool finishedTest = false;
unsigned long lastCheck = 0;
AsyncPingResponse lastCheckResult;
byte responseCount;
byte timeoutCount;
IPAddress addr;
AsyncPing pinger;
typedef enum {
IDLE,
PING, //doing regular ping
LOST_CONNECTION_1,
SECOND_CHECK,
LOST_CONNECTION_2,
THIRD_CHECK
} WatchdogState;
WatchdogState currentState = IDLE;
JsonObject &parseHTTPRequest(void) {
String host;
parseHTTP(F("host"), host);
String sensorID = F("enabled-{s}");
sensorID.replace(F("{s}"),String(SimpleScheduler::NTW_WTD));
parseHTTP(sensorID, enabled);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
if (addr.isValid(host)) {
addr.fromString(host);
ret[F("ip")] = host;
} else {
ret[F("err")] = FPSTR(INTL_NTW_WTD_ERROR);
}
ret[F("e")] = enabled;
return ret;
}
String getConfigJSON(void) {
String ret = F("");
ret += Var2JsonInt(F("e"), enabled);
ret += Var2Json(F("ip"), (addr.toString()));
return ret;
}
void readConfigJSON(JsonObject &json) {
String ip;
enabled = json.get<bool>(F("e"));
ip = json.get<String>(F("ip"));
if (addr.isValid(ip)) {
addr.fromString(ip);
configured = true;
} else {
configured = false;
}
scheduler.enableSubsystem(SimpleScheduler::NTW_WTD, enabled, NetworkWatchdog::process, FPSTR(KEY));
}
void resultsAsHTML(String &page_content) {
if (!enabled) { return; }
page_content.concat(FPSTR(EMPTY_ROW));
if (!configured) {
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "Wrong config", "", ""));
return;
}
if (lastCheck == 0) {
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "No test yet", "", ""));
return;
}
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "Status code", String(currentState), ""));
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "Last check", String((millis() - lastCheck) / 1000),
"sec"));
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "Pings", String(lastCheckResult.total_sent), ""));
page_content.concat(table_row_from_value(FPSTR("NTW WTD"), "Responses", String(lastCheckResult.total_recv), ""));
}
bool success(AsyncPingResponse r = lastCheckResult) {
if (r.total_recv > NTW_WTD_COUNT / 2) {
return true;
}
return false;
}
//which state
WatchdogState nextPingState() {
WatchdogState ret;
switch (currentState) {
case IDLE:
return PING;
case PING:
if (finishedTest && success())
ret = IDLE;
else
ret = LOST_CONNECTION_1;
if (finishedTest) finishedTest = false;
return ret;
case SECOND_CHECK:
if (finishedTest && success())
ret = IDLE;
else
ret = LOST_CONNECTION_2;
if (finishedTest) finishedTest = false;
return ret;
case THIRD_CHECK:
if (finishedTest && success()) {
finishedTest = false;
return IDLE;
}
debug_out(F("Third fail with PING. WiFi lost? Restarting"), DEBUG_MIN_INFO, true);
delay(500);
ESP.restart();
case LOST_CONNECTION_1:
return SECOND_CHECK;
case LOST_CONNECTION_2:
return THIRD_CHECK;
default:
return currentState;
}
}
void startPing(void) {
timeoutCount = 0;
responseCount = 0;
finishedTest = false;
lastCheck = millis();
//on response
// pinger.on(true, [](const AsyncPingResponse &response) {
// return false; //carry on
// });
//on end
pinger.on(false, [](const AsyncPingResponse &response) {
//IPAddress addr(response.addr); //to prevent with no const toString() in 2.3.0
lastCheckResult = response;
finishedTest = true;
// currentState = nextPingState();
return false;
});
if (configured) {
pinger.begin(addr, NTW_WTD_COUNT);
} else {
currentState = IDLE;
}
}
unsigned long nextCallTime() {
switch (currentState) {
case IDLE:
return 600 * 1000;
case PING:
case LOST_CONNECTION_1:
case LOST_CONNECTION_2:
return (NTW_WTD_COUNT + 2) * 1000;
case SECOND_CHECK:
case THIRD_CHECK:
return 60 * 1000;
}
return 0; //disable WTD
}
unsigned long processState(void) {
debug_out(F("PIIIING processor"), DEBUG_MIN_INFO, true);
switch (currentState) {
case IDLE:
debug_out(F("PING connectivity check:"), DEBUG_MIN_INFO, true);
startPing();
break;
case LOST_CONNECTION_1:
debug_out(F("Failed first PING check, running second"), DEBUG_MIN_INFO, true);
startPing();
break;
case LOST_CONNECTION_2:
debug_out(F("Failed second PING check, running third"), DEBUG_MIN_INFO, true);
startPing();
break;
default:
debug_out(F("PING connectivity check state:"), DEBUG_MIN_INFO, false);
debug_out(String(currentState), DEBUG_MIN_INFO, true);
break;
}
currentState = nextPingState();
debug_out (F("Next ping state: "), DEBUG_MIN_INFO,false);
debug_out (String(currentState), DEBUG_MIN_INFO,true);
return nextCallTime();
}
unsigned long process(SimpleScheduler::LoopEventType e) {
debug_out(F("Network wtchd 'process'"), DEBUG_MIN_INFO, true);
if (!enabled || !configured) {
return 0;
}
switch (e) {
case SimpleScheduler::INIT:
currentState = IDLE;
return 60 * 1000;
case SimpleScheduler::RUN:
return processState();
default:
return 0;
}
}
String getConfigHTML(void) {
String ret = F("");
ret += formInputGrid(F("host"), FPSTR(INTL_NTW_WTD_HOST), addr.toString(), 16);
return ret;
}
}
| 7,112
|
C++
|
.cpp
| 203
| 24.399015
| 121
| 0.532094
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,442
|
sensor.cpp
|
nettigo_namf/src/sensors/sps30/sensor.cpp
|
#include <Arduino.h>
#include "sensor.h"
#include "helpers.h"
#include "sending.h"
#include "display/commons.h"
#include "system/scheduler.h"
extern String table_row_from_value(const String &sensor, const String ¶m, const String &value, const String &unit);
namespace SPS30 {
const char KEY[] PROGMEM = "SPS30";
bool started = false;
bool enabled = false;
bool printOnLCD = false;
unsigned long refresh = 10;
int16_t ret;
uint8_t auto_clean_days = 4;
uint32_t auto_clean;
struct sps30_measurement sum;
unsigned int measurement_count;
char serial[SPS_MAX_SERIAL_LEN];
//helper function to zero measurements struct (for averaging)
void zeroMeasurementStruct(sps30_measurement &str) {
sps30_measurement zero = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
str = zero;
}
//return string with HTML used to configure SPS30 sensor. Right now it only takes number of seconds to wait between measurements
//taken to average
String getConfigHTML(void) {
String ret = F("");
ret += formInputGrid(F("refresh"), FPSTR(INTL_SPS30_REFRESH), String(refresh), 4);
return ret;
}
//register LCD display, for internal SPS30 use
void registerDisplaySPS() {
// register display
if (printOnLCD) {
if (started) {
switch (getLCDRows()) {
case 4:
scheduler.registerDisplay(SimpleScheduler::SPS30, 2);
break;
case 2:
scheduler.registerDisplay(SimpleScheduler::SPS30, 5);
break;
default:
break;
}
} else {
scheduler.registerDisplay(SimpleScheduler::SPS30, 1);
}
} else { //disable display if changed state in runtime
scheduler.registerDisplay(SimpleScheduler::SPS30,0);
}
}
//Start SPS30 sensor
unsigned long init() {
debug_out(F("************** SPS30 initBMPx80"), DEBUG_MIN_INFO, true);
zeroMeasurementStruct(sum);
sensirion_i2c_init();
byte cnt = 0;
while (
((ret = sps30_probe()) != 0) &&
(cnt++ < 15)
) {
delay(500);
if (cnt == 10) {
debug_out(F("SPS30 probing failed, disabling sensor"), DEBUG_ERROR, true);
return 0;
}
}
sps30_reset();
delay(200);
if (sps30_get_serial(serial) != 0) {
debug_out(F("Error getting SPS30 serial"), DEBUG_ERROR, true);
return 0;
}
debug_out("SPS30 serial: ", DEBUG_MIN_INFO, false);
debug_out(serial, DEBUG_MIN_INFO, true);
uint8_t major, minor;
if (sps30_read_firmware_version(&major, &minor) == 0) {
char tmp[60];
sprintf(tmp, "SPS30 rev: %i.%i", major, minor);
debug_out(tmp, DEBUG_MIN_INFO, true);
}
ret = sps30_set_fan_auto_cleaning_interval_days(auto_clean_days);
if (ret) {
debug_out(F("error setting the auto-clean interval: "), DEBUG_ERROR, true);
}
ret = sps30_start_measurement();
if (ret < 0) {
debug_out(F("error starting measurement"), DEBUG_ERROR, true);
} else {
started = true;
}
registerDisplaySPS();
return 10 * 1000;
}
//callback to parse HTML form sent from `getConfigHTML`
JsonObject &parseHTTPRequest(void) {
parseHTTP(F("refresh"), refresh);
//enabled?
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::SPS30);
//use display?
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::SPS30);
registerDisplaySPS(); //register display if enabled on runtime
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("refresh")] = refresh;
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
return ret;
}
//helper function to sum current measurement with previous results - for averaging
void addMeasurementStruct(sps30_measurement &storage, sps30_measurement reading) {
storage.mc_1p0 += reading.mc_1p0;
storage.mc_2p5 += reading.mc_2p5;
storage.mc_4p0 += reading.mc_4p0;
storage.mc_10p0 += reading.mc_10p0;
storage.nc_0p5 += reading.nc_0p5;
storage.nc_1p0 += reading.nc_1p0;
storage.nc_2p5 += reading.nc_2p5;
storage.nc_4p0 += reading.nc_4p0;
storage.nc_10p0 += reading.nc_10p0;
storage.typical_particle_size += reading.typical_particle_size;
}
/************************************************************************
* main function called periodically. It is called by scheduler with single param taking values:
* INIT - first run (aka start of sensor)
* RUN - regular call during work
* STOP - sensor is being deactivated
*/
unsigned long process(SimpleScheduler::LoopEventType e) {
struct sps30_measurement m;
switch (e) {
case SimpleScheduler::STOP:
zeroMeasurementStruct(sum);
measurement_count = 0;
started = false;
sps30_stop_measurement();
return 0;
case SimpleScheduler::INIT:
init();
break;
case SimpleScheduler::RUN:
debug_out(F("SPS30: process"), DEBUG_MAX_INFO, true);
ret = sps30_read_measurement(&m);
if (ret < 0) {
//Error reading
} else {
addMeasurementStruct(sum, m);
measurement_count++;
}
return refresh * 1000;
}
return 15 * 1000;
}
void getStatusReport (String &page_content) {
if (!enabled) return;
page_content.concat(FPSTR(EMPTY_ROW));
uint8_t major, minor;
if (sps30_read_firmware_version(&major, &minor) == 0) {
page_content.concat(table_row_from_value(FPSTR(KEY), F("FW ver"), String(major)+String(F("."))+String(minor), ""));
} else
page_content.concat(table_row_from_value(FPSTR(KEY), F("FW ver"), FPSTR(INTL_SPS30_FW_FAIL), ""));
}
//callback called after each sending data to APIs Bool parameter tell if there was success, or some API call failed
//in SPS30 it is being used start averaging results
void afterSend(bool success) {
zeroMeasurementStruct(sum);
measurement_count = 0;
}
//return JSON string with config (for save in SPIFFS)
String getConfigJSON(void) {
String ret = F("");
ret += Var2JsonInt(F("e"), enabled);
if (printOnLCD) ret += Var2JsonInt(F("d"), printOnLCD);
ret += Var2Json(F("refresh"), refresh);
return ret;
}
//get configuration data from JsonObject and save in own config
// if sensor is enabled then run init. On shutdown
void readConfigJSON(JsonObject &json) {
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
refresh = json.get<int>(F("refresh"));
if (enabled && !scheduler.isRegistered(SimpleScheduler::SPS30)) {
scheduler.registerSensor(SimpleScheduler::SPS30, SPS30::process, FPSTR(SPS30::KEY));
scheduler.init(SimpleScheduler::SPS30);
enabled = true;
debug_out(F("SPS30 enabled"), DEBUG_MIN_INFO, 1);
} else if (!enabled && scheduler.isRegistered(SimpleScheduler::SPS30)) { //de
debug_out(F("SPS30: stop"),DEBUG_MIN_INFO,1);
scheduler.unregisterSensor(SimpleScheduler::SPS30);
}
}
//append current readings (averaged) to JSON string
void results(String &s) {
if (!enabled || !started || measurement_count == 0) return;
String tmp;
tmp.reserve(512);
tmp.concat(Value2Json(F("SPS30_P0"), String(sum.mc_1p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_P2"), String(sum.mc_2p5 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_P4"), String(sum.mc_4p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_P1"), String(sum.mc_10p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_N05"), String(sum.nc_0p5 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_N1"), String(sum.nc_1p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_N25"), String(sum.nc_2p5 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_N4"), String(sum.nc_4p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_N10"), String(sum.nc_10p0 / measurement_count)));
tmp.concat(Value2Json(F("SPS30_TS"), String(sum.typical_particle_size / measurement_count)));
// debug_out(tmp,DEBUG_MIN_INFO,true);
s.concat(tmp);
}
//send data to LD API...
void sendToLD(){
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
String data;
results(data);
sendLuftdaten(data, 1 , HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "SPS30_");
};
//display table elements for current values page
void resultsAsHTML(String &page_content) {
if (!enabled) { return; }
const String unit_PM = "µg/m³";
const String unit_T = "°C";
const String unit_H = "%";
const String unit_P = "hPa";
page_content.concat(FPSTR(EMPTY_ROW));
if (measurement_count == 0) {
page_content.concat(table_row_from_value(FPSTR("SPS30"), FPSTR(INTL_SPS30_NO_RESULT), F(""), unit_PM));
} else {
page_content.concat(F("<tr><td colspan='3'>"));
page_content.concat(FPSTR(INTL_SPS30_CONCENTRATIONS));
page_content.concat(F("</td></tr>\n"));
page_content.concat(table_row_from_value(F("SPS30"), F("PM1"), String(sum.mc_1p0 / measurement_count), unit_PM));
page_content.concat(table_row_from_value(F("SPS30"), F("PM2.5"), String(sum.mc_2p5 / measurement_count),
unit_PM));
page_content.concat(table_row_from_value(F("SPS30"), F("PM4"), String(sum.mc_4p0 / measurement_count), unit_PM));
page_content.concat(table_row_from_value(F("SPS30"), F("PM10"), String(sum.mc_10p0 / measurement_count),
unit_PM));
page_content.concat(F("<tr><td colspan='3'>"));
page_content.concat(FPSTR(INTL_SPS30_COUNTS));
page_content.concat(F("</td></tr>\n"));
page_content.concat(table_row_from_value(F("SPS30"), F("NC0.5"), String(sum.nc_0p5 / measurement_count),
FPSTR(INTL_SPS30_CONCENTRATION)));
page_content.concat(table_row_from_value(F("SPS30"), F("NC1.0"), String(sum.nc_1p0 / measurement_count),
FPSTR(INTL_SPS30_CONCENTRATION)));
page_content.concat(table_row_from_value(F("SPS30"), F("NC2.5"), String(sum.nc_2p5 / measurement_count),
FPSTR(INTL_SPS30_CONCENTRATION)));
page_content.concat(table_row_from_value(F("SPS30"), F("NC4.0"), String(sum.nc_4p0 / measurement_count),
FPSTR(INTL_SPS30_CONCENTRATION)));
page_content.concat(table_row_from_value(F("SPS30"), F("NC10.0"), String(sum.nc_10p0 / measurement_count),
FPSTR(INTL_SPS30_CONCENTRATION)));
page_content.concat(table_row_from_value(F("SPS30"), F("TS"),
String(sum.typical_particle_size / measurement_count),
FPSTR(INTL_SPS30_SIZE)));
}
}
void display(byte cols, byte minor, String lines[]) {
if (!started) {
lines[0] = F("SPS30");
lines[1] = FPSTR(INTL_SPS30_NOT_STARTED);
return;
}
if (measurement_count == 0) {
lines[0] = F("SPS30");
lines[1] = FPSTR(INTL_SPS30_NO_RESULT);
return;
}
byte row = 0;
if (getLCDRows() == 2) { //16x2
switch (minor) {
case 0:
lines[row] += (F("SPS: PM1:"));
lines[row] += (String(sum.mc_1p0 / measurement_count, 1));
row++;
lines[row] += (F("PM2.5: "));
lines[row] += (String(sum.mc_2p5 / measurement_count, 1));
break;
case 1:
lines[row] += (F("SPS: PM4:"));
lines[row] += (String(sum.mc_4p0 / measurement_count, 1));
row++;
lines[row] += (F("PM10: "));
lines[row] += (String(sum.mc_10p0 / measurement_count, 1));
break;
case 2:
lines[row] += (F("SPS: NC1:"));
lines[row] += (String(sum.nc_1p0 / measurement_count, 1));
row++;
lines[row] += (F("NC2.5: "));
lines[row] += (String(sum.nc_2p5 / measurement_count, 1));
break;
case 3:
lines[row] += (F("SPS: NC4:"));
lines[row] += (String(sum.nc_4p0 / measurement_count, 1));
row++;
lines[row] += (F("NC10: "));
lines[row] += (String(sum.nc_10p0 / measurement_count, 1));
break;
case 4:
lines[row] += (F("Typical size:"));
row++;
lines[row] += (String(sum.typical_particle_size / measurement_count, 2));
}
} else { //LCD 20x4 or OLED, more real estate
switch (minor) {
case 0:
lines[row] = F("SPS: PM1:");
lines[row] += String(sum.mc_1p0 / measurement_count, 1);
row++;
lines[row] = F("PM2.5: ");
lines[row] += String(sum.mc_2p5 / measurement_count, 1);
row++;
lines[row] = F("PM4: ");
lines[row] += String(sum.mc_4p0 / measurement_count, 1);
row++;
lines[row] = F("PM10: ");
lines[row] += String(sum.mc_10p0 / measurement_count, 1);
break;
case 1:
lines[row] = F(" SPS: NC1:");
lines[row] += String(sum.nc_1p0 / measurement_count, 1);
row++;
lines[row] = F("NC2.5: ");
lines[row] += String(sum.nc_2p5 / measurement_count, 1);
row++;
lines[row] = F("NC4: ");
lines[row] += String(sum.nc_4p0 / measurement_count, 1);
row++;
lines[row] = F("NC10:");
lines[row] += String(sum.nc_10p0 / measurement_count, 1);
lines[row] += F(" TS:");
lines[row] += String(sum.typical_particle_size / measurement_count, 1);
break;
}
}
return;
};
bool getDisplaySetting() {
return printOnLCD;
};
}
| 15,707
|
C++
|
.cpp
| 342
| 33.084795
| 132
| 0.52849
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,443
|
SerialSDS.cpp
|
nettigo_namf/src/sensors/sds011/SerialSDS.cpp
|
//
// Created by viciu on 10.06.2021.
//
#include "SerialSDS.h"
void SerialSDS::process() {
while (_serial.available()) {
byte x;
static byte idx;
switch (_currState) {
case SER_UNDEF:
x = _serial.read();
if (x == 0xAA) {
_currState = SER_HDR;
idx = 2;
_buff[0] = 0xAA;
}
break;
case SER_HDR:
x = _serial.read();
_buff[1] = x;
if (x == 0xC0) {
_currState = SER_DATA;
} else if (x == 0xC5) {
_currState = SER_REPLY;
} else
_currState = SER_UNDEF;
break;
case SER_REPLY:
if (idx < 10) {
_buff[idx] = _serial.read();
idx++;
}
if (idx == 10) {
if (!checksumValid()) {
_currState = SER_UNDEF;
break;
}
storeReply();
_currState = SER_UNDEF;
}
break;
case SER_DATA:
if (idx < 10)
_buff[idx++] = _serial.read();
if (idx == 10) {
if (!checksumValid()) {
_currState = SER_UNDEF;
break;
}
_replies[SDS_DATA].received = true;
_replies[SDS_DATA].lastReply = millis();
for (byte i = 0; i < 5; i++) _replies[SDS_DATA].data[i] = _buff[2 + i];
if (cfg::debug > DEBUG_MIN_INFO) logReply(SDS_DATA);
_currState = SER_UNDEF;
}
break;
default:
_currState = SER_UNDEF;
}
yield();
}
}
bool SerialSDS::readingAvailable() {
return _replies[SDS_DATA].received;
};
bool SerialSDS::fetchReading(int &pm10, int &pm25) {
if (!readingAvailable()) return false;
pm25 = _replies[SDS_DATA].data[0] | (_replies[SDS_DATA].data[1] << 8);
pm10 = _replies[SDS_DATA].data[2] | (_replies[SDS_DATA].data[3] << 8);
_replies[SDS_DATA].received = false;
return true;
}
float SerialSDS::errorRate() {
if (packetCount == 0) return 0;
return (float)checksumFailed/(float)packetCount * 100.0;
}
bool SerialSDS::checksumValid(void) {
uint8_t checksum_is = 0;
for (unsigned i = 2; i < 8; ++i) {
checksum_is += _buff[i];
}
bool chk = _buff[9] == 0xAB && checksum_is == _buff[8];
packetCount++;
//overflow
if (packetCount == 0) {
checksumFailed = 0;
}
if (!chk) {
debug_out(F("SDS011 reply checksum failed "), DEBUG_ERROR);
checksumFailed++;
// Serial.println(checksum_is,16);
// for (byte i=0; i<10; i++) {
// Serial.print(_buff[i],16);
// Serial.print(" ");
// }
// Serial.println();
}
return (chk);
}
void SerialSDS::logReply(ResponseType type) {
ReplyInfo x = _replies[type];
debug_out(F("SDS packet"),DEBUG_MAX_INFO);
for (byte i=0; i<5;i++) {debug_out(String(x.data[i],16),DEBUG_MAX_INFO, 0); debug_out(F(" "), DEBUG_MAX_INFO, 0);}
debug_out(F(""),DEBUG_MAX_INFO);
// Serial.println();
// Serial.print(F("**** SDS**** Odpowiedź z SDS: "));
switch (type) {
case SDS_REPORTING:
Serial.print(F("REPORTING MODE "));
Serial.print(x.data[0] ? F("SET: ") : F("QUERY: "));
Serial.print(x.data[1] ? F("query ") : F("active"));
break;
case SDS_DATA:
// Serial.print(F("data packet"));
break;
case SDS_NEW_DEV_ID:
case SDS_SLEEP:
Serial.print(F("SLEEP MODE "));
Serial.print(x.data[0] ? F("SET: ") : F("QUERY: "));
Serial.print(x.data[1] ? F("work ") : F("sleep"));
break;
case SDS_PERIOD:
Serial.print(F("WORKING PERIOD "));
Serial.print(x.data[0] ? F("SET: ") : F("QUERY: "));
Serial.print(x.data[1] ? String(x.data[1]) : F("continous"));
break;
case SDS_FW_VER:
Serial.println(F("FIRMWARE VERSION response"));
break;
}
// Serial.println();
}
//store reply for command
void SerialSDS::storeReply() {
ResponseType type;
type = selectResponse(_buff[2]);
debug_out(F("Response type: "), DEBUG_MED_INFO, 0);
debug_out(String(type), DEBUG_MED_INFO);
if (type == SDS_UNKNOWN) { return; }
_replies[type].received = true;
_replies[type].lastReply = millis();
for (byte i = 0; i < 5; i++) _replies[type].data[i] = _buff[3 + i];
if (cfg::debug > DEBUG_MIN_INFO) logReply(type);
}
SerialSDS::ResponseType SerialSDS::selectResponse(byte x) {
switch (x) {
case 7:
return SDS_FW_VER;
case 8:
return SDS_PERIOD;
case 6:
return SDS_SLEEP;
case 5:
return SDS_NEW_DEV_ID;
case 2:
return SDS_REPORTING;
default:
return SDS_UNKNOWN;
}
}
//const char SerialSDS::SRT_0 [] PROGMEM = "Reporting mode";
//const char SerialSDS::SRT_1 [] PROGMEM = "Data packet";
//const char SerialSDS::SRT_2 [] PROGMEM = "New ID";
//const char SerialSDS::SRT_3 [] PROGMEM = "Sleep/work";
//const char SerialSDS::SRT_4 [] PROGMEM = "Working period";
//const char SerialSDS::SRT_5 [] PROGMEM = "FW version";
//const char SerialSDS::SRT_6 [] PROGMEM = "Unknown";
//const char *SerialSDS::SRT_NAMES[] PROGMEM = {SerialSDS::SRT_0, SerialSDS::SRT_1, SerialSDS::SRT_2, SerialSDS::SRT_3, SerialSDS::SRT_4, SerialSDS::SRT_5, SerialSDS::SRT_6};
| 5,872
|
C++
|
.cpp
| 168
| 25.244048
| 174
| 0.49499
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,444
|
sds011.cpp
|
nettigo_namf/src/sensors/sds011/sds011.cpp
|
#include "sds011.h"
namespace SDS011 {
const char KEY[]
PROGMEM = "SDS011";
bool enabled = false;
bool printOnLCD = false;
unsigned long SDS_error_count;
unsigned long warmupTime = WARMUPTIME_SDS_MS;
unsigned long readTime = READINGTIME_SDS_MS;
unsigned long pm10Sum, pm25Sum = 0;
unsigned readingCount = 0;
SerialSDS channelSDS(serialSDS);
bool hardwareWatchdog = 0;
byte hwWtdgFailedReadings = 0; //after SDS restart this counter is reset, failedReadings is global
byte hwWtdgCycles = 0; //how many times watchdog took action
unsigned long hwWtdgErrors = 0;
unsigned readings;
unsigned failedReadings;
enum {
SDS_REPLY_HDR = 10,
SDS_REPLY_BODY = 8
} SDS_waiting_for;
typedef enum {
SER_UNDEF,
SER_HDR,
SER_DATA,
SER_REPLY,
SER_IDLE
} SDSSerialState;
SDSSerialState currState = SER_UNDEF;
typedef enum {
POWERON, // 0 after poweron
STARTUP, // 1 first run
POST, // 2 measure data on POST
OFF, // 3 wait for measure period
HARDWARE_RESTART, // 4
HW_RESTART_CLEANUP, // 5
START, // 6 start fan
WARMUP, // 7 run, but no reading saved
READ, // 8 start reading
READING, // 9 run and collect data
STOP, // 10 turn off
AFTER_READING
} SDS011State;
unsigned long stateChangeTime = 0;
SDS011State sensorState = POWERON;
typedef enum {
SDS_REPORTING,
SDS_DATA,
SDS_NEW_DEV_ID,
SDS_SLEEP,
SDS_PERIOD,
SDS_FW_VER,
SDS_UNKNOWN
} SDSResponseType;
const char SRT_0[] PROGMEM = "Reporting mode";
const char SRT_1[] PROGMEM = "Data packet";
const char SRT_2[] PROGMEM = "New ID";
const char SRT_3[] PROGMEM = "Sleep/work";
const char SRT_4[] PROGMEM = "Working period";
const char SRT_5[] PROGMEM = "FW version";
const char SRT_6[] PROGMEM = "Unknown";
const char *SRT_NAMES[] PROGMEM = {SRT_0, SRT_1, SRT_2, SRT_3, SRT_4, SRT_5, SRT_6};
SDSResponseType selectResponse(byte x) {
switch (x) {
case 7:
return SDS_FW_VER;
case 8:
return SDS_PERIOD;
case 6:
return SDS_SLEEP;
case 5:
return SDS_NEW_DEV_ID;
case 2:
return SDS_REPORTING;
default:
return SDS_UNKNOWN;
}
}
//set default values
void setDefaults(void) {
enabled = true;
printOnLCD = true;
}
//change state and store timestamp
void updateState(SDS011State newState) {
if (newState == sensorState) return;
sensorState = newState;
stateChangeTime = millis();
}
#define UPDATE_MIN(MIN, SAMPLE) if (SAMPLE < MIN) { MIN = SAMPLE; }
#define UPDATE_MAX(MAX, SAMPLE) if (SAMPLE > MAX) { MAX = SAMPLE; }
#define UPDATE_MIN_MAX(MIN, MAX, SAMPLE) { UPDATE_MIN(MIN, SAMPLE); UPDATE_MAX(MAX, SAMPLE); }
void readSingleSDSPacket(int *pm10_serial, int *pm25_serial) {
// *pm25_serial = replies[SDS_DATA].data[0] | (replies[SDS_DATA].data[1] << 8);
// *pm10_serial = replies[SDS_DATA].data[2] | (replies[SDS_DATA].data[3] << 8);
// replies[SDS_DATA].received = false;
return;
const uint8_t constexpr hdr_measurement[2] = {0xAA, 0xC0};
uint8_t data[8];
while (serialSDS.available() > SDS_waiting_for) {
switch (SDS_waiting_for) {
case SDS_REPLY_HDR:
if (serialSDS.find(hdr_measurement, sizeof(hdr_measurement)))
SDS_waiting_for = SDS_REPLY_BODY;
break;
case SDS_REPLY_BODY:
debug_out(FPSTR(DBG_TXT_START_READING), DEBUG_MAX_INFO, 0);
debug_out(FPSTR(SENSORS_SDS011), DEBUG_MAX_INFO, 1);
size_t read = serialSDS.readBytes(data, sizeof(data));
if (read == sizeof(data) && SDS_checksum_valid(data)) {
*pm25_serial = data[0] | (data[1] << 8);
*pm10_serial = data[2] | (data[3] << 8);
} else {
*pm10_serial = -1;
*pm25_serial = -1;
}
SDS_waiting_for = SDS_REPLY_HDR;
for (byte i = 0; i < sizeof(data); i++) {
data[i] = 0;
}
}
}
}
/*****************************************************************
* send SDS011 command (start, stop, continuous mode, version *
*****************************************************************/
void SDS_rawcmd(const uint8_t cmd_head1, const uint8_t cmd_head2, const uint8_t cmd_head3) {
constexpr uint8_t cmd_len = 19;
uint8_t buf[cmd_len];
buf[0] = 0xAA;
buf[1] = 0xB4;
buf[2] = cmd_head1;
buf[3] = cmd_head2;
buf[4] = cmd_head3;
for (unsigned i = 5; i < 15; ++i) {
buf[i] = 0x00;
}
buf[15] = 0xFF;
buf[16] = 0xFF;
buf[17] = cmd_head1 + cmd_head2 + cmd_head3 - 2;
buf[18] = 0xAB;
serialSDS.write(buf, cmd_len);
}
// bool SDS_cmd(PmSensorCmd cmd) {
// switch (cmd) {
// case PmSensorCmd::Start:
// SDS_rawcmd(0x06, 0x01, 0x01);
// break;
// case PmSensorCmd::Stop:
// SDS_rawcmd(0x06, 0x01, 0x00);
// break;
// case PmSensorCmd::ContinuousMode:
// // TODO: Check mode first before (re-)setting it
// SDS_rawcmd(0x08, 0x01, 0x00);
// SDS_rawcmd(0x02, 0x01, 0x00);
// break;
// case PmSensorCmd::VersionDate:
// SDS_rawcmd(0x07, 0, 0);
// break;
// }
//
// return cmd != PmSensorCmd::Stop;
// }
//#define SDS_CMD_QUEUE_SIZE 5
// PmSensorCmd cmdQ[SDS_CMD_QUEUE_SIZE];
// byte cmdIdx = 0;
// unsigned long lastCmdSent = 0;
// PmSensorCmd sentCmd = PmSensorCmd::None;
// bool SDS_cmd(PmSensorCmd cmd) {
// if (cmdIdx < SDS_CMD_QUEUE_SIZE) {
// cmdQ[cmdIdx++] = cmd;
// }
// return cmd != PmSensorCmd::Stop;
//
// }
void clearIncoming() {
serialSDS.flush();
if (byte avail = serialSDS.available()) {
while(avail--) {serialSDS.read();}
}
}
bool SDS_cmd(PmSensorCmd cmd) {
static constexpr uint8_t start_cmd[] PROGMEM = {
0xAA, 0xB4, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x06, 0xAB
};
static constexpr uint8_t stop_cmd[] PROGMEM = {
0xAA, 0xB4, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x05, 0xAB
};
static constexpr uint8_t continuous_mode_cmd[] PROGMEM = {
0xAA, 0xB4, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x07, 0xAB
};
static constexpr uint8_t continuous_mode_cmd2[] PROGMEM = {
0xAA, 0xB4, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x01, 0xAB
};
static constexpr uint8_t version_cmd[] PROGMEM = {
0xAA, 0xB4, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
0x05, 0xAB
};
constexpr uint8_t cmd_len = 19;
uint8_t buf[cmd_len];
switch (cmd) {
case PmSensorCmd::Start:
// Serial.println(F("SDS cmd: start"));
memcpy_P(buf, start_cmd, cmd_len);
break;
case PmSensorCmd::Stop:
// Serial.println(F("SDS cmd: stop"));
memcpy_P(buf, stop_cmd, cmd_len);
break;
case PmSensorCmd::ContinuousMode:
// Serial.println(F("SDS cmd: continuous"));
memcpy_P(buf, continuous_mode_cmd, cmd_len);
break;
case PmSensorCmd::VersionDate:
// Serial.println(F("SDS cmd: version"));
memcpy_P(buf, version_cmd, cmd_len);
break;
}
clearIncoming();
serialSDS.write(buf, cmd_len);
return cmd != PmSensorCmd::Stop;
}
bool SDS_checksum_valid(const uint8_t (&data)[8]) {
uint8_t checksum_is = 0;
for (unsigned i = 0; i < 6; ++i) {
checksum_is += data[i];
}
return (data[7] == 0xAB && checksum_is == data[6]);
}
JsonObject &parseHTTPRequest() {
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::SDS011);
//use display?
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::SDS011);
setVariableFromHTTP(F("w"), warmupTime, SimpleScheduler::SDS011);
setVariableFromHTTP(String(F("r")), readTime, SimpleScheduler::SDS011);
setBoolVariableFromHTTP(F("dbg"), hardwareWatchdog, SimpleScheduler::SDS011);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
ret[F("w")] = warmupTime;
ret[F("r")] = readTime;
ret[F("dbg")] = hardwareWatchdog;
return ret;
};
bool getDisplaySetting() {
return printOnLCD;
};
bool display(byte rows, byte minor, String lines[]) {
byte row = 0;
if (rows == 4) {
lines[row].concat(FPSTR(INTL_SDS011_LCD_HDR));
}
row++;;
lines[row].concat(F("PM2.5:"));
lines[row].concat((check_display_value(last_value_SDS_P2, -1, 1, 6)));
// lines[row].concat((F(" µg/m³"))));
row++;;
lines[row].concat(F("PM10: "));
lines[row].concat(check_display_value(last_value_SDS_P1, -1, 1, 6));
// lines[row].concat((F(" µg/m³"))));
return false;
};
String getConfigJSON() {
String ret = F("");
ret.concat(Var2JsonInt(F("e"), enabled));
if (printOnLCD) ret.concat(Var2JsonInt(F("d"), printOnLCD));
addJsonIfNotDefault(ret, F("r"), READINGTIME_SDS_MS, readTime);
addJsonIfNotDefault(ret, F("w"), WARMUPTIME_SDS_MS, warmupTime);
addJsonIfNotDefault(ret, F("dbg"), false, hardwareWatchdog);
// if (readTime != READINGTIME_SDS_MS) ret.concat(Var2Json(F("r"), readTime));
// if (warmupTime != WARMUPTIME_SDS_MS) ret.concat(Var2Json(F("w"), warmupTime));
return ret;
};
void readConfigJSON(JsonObject &json) {
// Serial.println("SDS readConfigJson");
// json.printTo(Serial);
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
if (json.containsKey(F("r"))) {
readTime = json.get<unsigned long>(F("r"));
}
if (json.containsKey(F("w"))) {
warmupTime = json.get<unsigned long>(F("w"));
}
if (json.containsKey(F("dbg"))) {
hardwareWatchdog = json.get<bool>(F("dbg"));
Wire.beginTransmission(0x26);
Wire.write(0x01);
Wire.endTransmission();
}
//register/deregister sensor
if (enabled && !scheduler.isRegistered(SimpleScheduler::SDS011)) {
scheduler.registerSensor(SimpleScheduler::SDS011, SDS011::process, FPSTR(SDS011::KEY));
scheduler.init(SimpleScheduler::SDS011);
enabled = true;
debug_out(F("SDS011: start"), DEBUG_MIN_INFO, 1);
} else if (!enabled && scheduler.isRegistered(SimpleScheduler::SDS011)) { //de
debug_out(F("SDS011: stop"), DEBUG_MIN_INFO, 1);
scheduler.unregisterSensor(SimpleScheduler::SDS011);
}
//register display - separate check to allow enable/disable display not only when turning SDS011 on/off
if (enabled && printOnLCD) scheduler.registerDisplay(SimpleScheduler::SDS011, 1);
}
//reset counters
void resetReadings() {
pm10Sum = pm25Sum = readingCount = 0;
};
void storeReadings(const int pm10, const int pm25) {
if (pm10 == -1 || pm25 == -1) return;
pm10Sum += pm10;
pm25Sum += pm25;
readingCount++;
};
//store last values pm
void processReadings() {
readings++;
if (readingCount > 0) {
last_value_SDS_P1 = pm10Sum / readingCount / 10.0;
last_value_SDS_P2 = pm25Sum / readingCount / 10.0;
hwWtdgFailedReadings = 0;
} else {
last_value_SDS_P1 = last_value_SDS_P2 = -1;
hwWtdgFailedReadings++;
failedReadings++;
}
};
//did timeout happen (from last state change)
bool timeout(unsigned long t) {
//100 ms margin - to complete before sending
unsigned long diff = millis() + 100 - stateChangeTime;
if (diff > t) return true;
return false;
}
#define STARTUP_TIME 5000
//how many ms before read time reading cycle should be fished
#define SDS011_END_TIME 5000
//select proper state, depending on time left to
unsigned long processState() {
int pm25, pm10 = -1;
unsigned long t = time2Measure();
// if (t>1000) t -= 200;
switch (sensorState) {
case POWERON:
updateState(STARTUP);
return 10;
case STARTUP:
is_SDS_running = SDS_cmd(PmSensorCmd::Start);
delay(500);
is_SDS_running = SDS_cmd(PmSensorCmd::VersionDate);
resetReadings();
updateState(POST);
return 100;
case POST:
if (channelSDS.fetchReading(pm10, pm25)) {
storeReadings(pm10, pm25);
}
if (timeout(STARTUP_TIME)) {
processReadings();
is_SDS_running = SDS_cmd(PmSensorCmd::Stop);
updateState(OFF);
return 500;
}
return 20;
case OFF:
if (hardwareWatchdog && hwWtdgFailedReadings > 2) {
hwWtdgCycles++;
Wire.beginTransmission(0x26);
Wire.write(0x0);
byte error = Wire.endTransmission();
Serial.print(F("PCF status: "));
Serial.println(error);
if (error) {
delay(100);
hwWtdgErrors++;
} else {
updateState(HARDWARE_RESTART);
debug_out(F("SDS not responding -> hardware restart !!!! "), DEBUG_ERROR);
}
return 10;
}
if (t < warmupTime + readTime + SDS011_END_TIME) //aim to finish 2 sec before readingTime
updateState(START);
return 10;
case HARDWARE_RESTART:
if (timeout(5 * 1000)) {
debug_out(F("Starting SDS (power ON)"), DEBUG_ERROR);
Wire.beginTransmission(0x26);
delay(1);
Wire.write(0x01);
byte error = Wire.endTransmission();
Serial.println(error);
if (error) {
hwWtdgErrors++;
delay(100);
} else {
hwWtdgFailedReadings = 0;
updateState(HW_RESTART_CLEANUP);
}
}
return 10;
case HW_RESTART_CLEANUP:
if (timeout(5000)) {
is_SDS_running = SDS_cmd(Stop);
updateState(OFF);
}
return 10;
case START:
is_SDS_running = SDS_cmd(PmSensorCmd::Start);
updateState(WARMUP);
return 100;
case WARMUP:
if (t < readTime + SDS011_END_TIME)
updateState(READ);
return 10;
case READ:
// serialSDS.flush();
resetReadings();
SDS_waiting_for = SDS_REPLY_HDR;
updateState(READING);
return 10;
case READING:
if (channelSDS.fetchReading(pm10, pm25)) {
storeReadings(pm10, pm25);
}
if (timeout(readTime)) {
updateState(STOP);
return 50;
}
return 20;
case STOP:
processReadings();
debug_out(F("SDS011: end of cycle"), DEBUG_MIN_INFO, 1);
is_SDS_running = SDS_cmd(PmSensorCmd::Stop);
updateState(AFTER_READING);
return 100;
default:
return 1000;
}
}
void results(String &res) {
if (last_value_SDS_P2 != -1 && last_value_SDS_P1 != -1) {
res.concat(Value2Json(F("SDS_P1"), String(last_value_SDS_P1)));
res.concat(Value2Json(F("SDS_P2"), String(last_value_SDS_P2)));
}
}
void sendToLD() {
if (!enabled) return;
if (sensorState == AFTER_READING) {
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
String data;
results(data);
sendLuftdaten(data, 1, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "SDS_");
} else {
debug_out(F("SDS011 reading procedure not finished, not sending data."), DEBUG_MIN_INFO);
debug_out(String(stateChangeTime), DEBUG_MIN_INFO);
debug_out(String(sensorState), DEBUG_MIN_INFO);
}
}
void afterSend (bool status) {
//Make sure SDS011 sensor is OFF
SDS_cmd(PmSensorCmd::Stop);
updateState(OFF);
}
void getStatusReport(String &res) {
if (!enabled) return;
res.concat(FPSTR(EMPTY_ROW));
res.concat(table_row_from_value(F("SDS011"), F("Status"), String(sensorState), ""));
res.concat(table_row_from_value(F("SDS011"), F("Status change"), String(millis() - stateChangeTime), ""));
res.concat(table_row_from_value(F("SDS011"), F("Version data"), SDS_version_date(), ""));
res.concat(table_row_from_value(F("SDS011"), FPSTR(INTL_SDS011_FAILED_READINGS), String(failedReadings)+F("/")+String(readings), ""));
if (hardwareWatchdog) {
res.concat(table_row_from_value(F("SDS011"), F("Current failed readings"), String(hwWtdgFailedReadings), ""));
res.concat(table_row_from_value(F("SDS011"), F("Total failed readings"), String(failedReadings), ""));
res.concat(table_row_from_value(F("SDS011"), F("Watchdog cycles"), String(hwWtdgCycles), ""));
res.concat(table_row_from_value(F("SDS011"), F("Failed I2C PCF"), String(hwWtdgErrors), ""));
}
float fr = 0;
res.concat(table_row_from_value(F("SDS011"), F("Checksum failures"),
String(channelSDS.errorRate()) + F("% ") + String(channelSDS.checksumErrCnt()) + F("/") + String(
channelSDS.totalPacketCnt()), ""));
}
// void popCmd(PmSensorCmd &t) {
// t = cmdQ[0];
// cmdIdx--;
// for (byte i = 0; i < cmdIdx; i++) {
// cmdQ[i] = cmdQ[i + 1];
// }
// }
//
// void processCmdQueue() {
// if (cmdIdx) {
// if (lastCmdSent != PmSensorCmd::None ) {
// PmSensorCmd cmd;
// popCmd(cmd);
//
// }
// }
// }
void byteReceived(int cnt) {
if (cnt>=SDS_SERIAL_BUFF_SIZE) {
debug_out(F("SDS buffer full! Size : "), DEBUG_ERROR,0);
debug_out(String(cnt),DEBUG_ERROR);
}
channelSDS.process();
}
unsigned long process(SimpleScheduler::LoopEventType e) {
switch (e) {
case SimpleScheduler::STOP:
is_SDS_running = SDS_cmd(PmSensorCmd::Stop);
return 0;
case SimpleScheduler::INIT:
readings = failedReadings = 0;
serialSDS.flush(); //drop all packets 'pre-start'
SDS_cmd(PmSensorCmd::Start);
delay(500);
SDS_cmd(PmSensorCmd::VersionDate);
serialSDS.onReceive(byteReceived);
return processState();
case SimpleScheduler::RUN:
// channelSDS.process();
processState();
return 1;
default:
return 0;
}
}
String getConfigHTML(void) {
String ret = F("");
String name;
advancedSectionStart(ret, SimpleScheduler::SDS011);
setHTTPVarName(name, F("r"), SimpleScheduler::SDS011);
ret.concat(formInputGrid(name, FPSTR(INTL_SDS011_READTIME), String(readTime), 7));
setHTTPVarName(name, F("w"), SimpleScheduler::SDS011);
ret.concat(formInputGrid(name, FPSTR(INTL_SDS011_WARMUP), String(warmupTime), 7));
setHTTPVarName(name, F("dbg"), SimpleScheduler::SDS011);
ret.concat(formCheckboxGrid(name, FPSTR(INTL_SDS011_HWR), hardwareWatchdog));
advancedSectionEnd(ret, SimpleScheduler::SDS011);
return ret;
}
void resultsAsHTML(String &page_content) {
if (!enabled) return;
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_SDS011), "PM2.5",
check_display_value(last_value_SDS_P2, -1, 1, 0), F("µg/m³")));
page_content.concat(table_row_from_value(FPSTR(SENSORS_SDS011), "PM10",
check_display_value(last_value_SDS_P1, -1, 1, 0), F("µg/m³")));
}
/*****************************************************************
* read SDS011 sensor serial and firmware date *
*****************************************************************/
String SDS_version_date() {
static String version_date = "";
debug_out(String(FPSTR(DBG_TXT_END_READING)) + FPSTR(DBG_TXT_SDS011_VERSION_DATE), DEBUG_MED_INFO, 1);
if (!channelSDS._replies[SDS_FW_VER].received) {
is_SDS_running = SDS_cmd(PmSensorCmd::Start);
is_SDS_running = SDS_cmd(PmSensorCmd::VersionDate);
}
if (channelSDS._replies[SDS_FW_VER].received) {
char reply[30];
byte *buff = channelSDS._replies[SDS_FW_VER].data;
snprintf_P(reply, 30, PSTR("20%i-%i-%i(%02X%02X)"), buff[0], buff[1], buff[2], buff[3], buff[4]);
version_date = String(reply);
} else {
version_date = F("n/a");
}
return version_date;
}
}
| 23,324
|
C++
|
.cpp
| 574
| 30.101045
| 142
| 0.525137
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,445
|
bmpX80.cpp
|
nettigo_namf/src/sensors/bmpX80/bmpX80.cpp
|
#include "bmpX80.h"
namespace BMPx80 {
const char KEY[] PROGMEM = "BMPx80";
bool enabled = false;
bool printOnLCD = false;
bool sensorInsideCase = false;
const unsigned int SAMPLE_SIZE = 5;
byte sampleCount = 0;
float *samplesT = nullptr;
float *samplesP = nullptr;
Adafruit_BMP280 bmp280;
Adafruit_BMP085 bmp180;
typedef enum {
BMP_180,
BMP_280,
NONE
} SensorType;
SensorType currentSensor = NONE;
//ser defaults
void setDefaults(void) {
enabled = true;
}
/*****************************************************************
* Init BMP280 *
*****************************************************************/
bool initBMP280(char addr) {
debug_out(F("Trying BMP280 sensor on "), DEBUG_MIN_INFO, true);
debug_out(String(addr, HEX), DEBUG_MIN_INFO, 0);
if (bmp280.begin(addr)) {
debug_out(F(" ... found"), DEBUG_MIN_INFO, 1);
return true;
} else {
debug_out(F(" ... not found"), DEBUG_MIN_INFO, 1);
return false;
}
}
bool initBMP180(char addr = 0x77) {
debug_out(F("Trying BMP180/085 sensor on "), DEBUG_MIN_INFO, 0);
debug_out(String(addr, HEX), DEBUG_MIN_INFO, 0);
if (bmp180.begin(addr)) {
debug_out(F(" ... found"), DEBUG_MIN_INFO);
return true;
}
debug_out(F(" ... not found"), DEBUG_MIN_INFO);
return false;
}
bool readyBMPx80() {
return currentSensor != NONE;
}
bool initBMPx80() {
if (initBMP280(0x76) || initBMP280(0x77)) {
currentSensor = BMP_280;
return true;
}
if (initBMP180()) {
currentSensor = BMP_180;
return true;
}
return false;
}
const char *sensorPrefixBMPx80() {
static char buff[8];
switch (currentSensor) {
case NONE:
String(F("")).toCharArray(buff, 8);
break;
case BMP_280:
String(F("BMP280_")).toCharArray(buff, 8);
break;
case BMP_180:
String(F("BMP_")).toCharArray(buff, 8);
break;
}
return buff;
}
void readFromSensor() {
if (sampleCount >= SAMPLE_SIZE)
return;
float p = -1;
float t = -128;
switch (currentSensor) {
case NONE:
return;
case BMP_180:
p = (float) bmp180.readPressure();
t = bmp180.readTemperature();
break;
case BMP_280:
p = bmp280.readPressure();
t = bmp280.readTemperature();
break;
}
if (isnan(p) || isnan(t)) {
t = -128.0;
p = -1.0;
debug_out(String(FPSTR(SENSORS_BMP280)) + FPSTR(DBG_TXT_COULDNT_BE_READ), DEBUG_ERROR, 1);
} else {
samplesP[sampleCount] = p;
samplesT[sampleCount] = t;
sampleCount++;
}
}
float currentPressure() {
if (sampleCount == 0)
return -1;
float sum = 0;
for (byte i = 0; i < sampleCount; i++)
sum += samplesP[i];
return sum/sampleCount;
}
float currentTemp() {
if (sampleCount == 0)
return -128;
float sum = 0;
for (byte i = 0; i < sampleCount; i++)
sum += samplesT[i];
return sum/sampleCount;
}
void sendToLD(){
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
String result;
results(result);
sendLuftdaten(result, BMP280_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, sensorPrefixBMPx80());
}
String getConfigJSON() {
String ret = F("");
ret.concat(Var2JsonInt(F("e"), enabled));
if (printOnLCD) ret.concat(Var2JsonInt(F("d"), printOnLCD));
if (sensorInsideCase) ret.concat(Var2JsonInt(F("i"), sensorInsideCase));
return ret;
};
bool dataAvailable() {
return sampleCount > 0;
}
void results(String &s) {
if (!enabled) return;
if (!dataAvailable()) return;
String key2 = sensorPrefixBMPx80();
key2.concat(F("pressure"));
s.concat(Value2Json(key2, String(currentPressure())));
if (!sensorInsideCase) {
String key1 = sensorPrefixBMPx80();
key1.concat(F("temperature"));
s.concat(Value2Json(key1, String(currentTemp())));
}
}
void resultsAsHTML(String &page_content){
if (!enabled) return;
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(KEY), FPSTR(INTL_TEMPERATURE),
check_display_value(currentTemp(), -128, 1, 0), F("°C")));
page_content.concat(table_row_from_value(FPSTR(KEY), FPSTR(INTL_PRESSURE),
check_display_value(currentPressure()/100, -1, 1, 0), F("hPa")));
}
String getConfigHTML(void) {
String ret = F("");
String name;
setHTTPVarName(name, F("in"), SimpleScheduler::BMPx80);
ret.concat(formCheckboxGrid(name, FPSTR(INTL_BMPx80_INSIDE), sensorInsideCase));
return ret;
}
void getStatusReport(String &res) {
if (!enabled) return;
res.concat(FPSTR(EMPTY_ROW));
res.concat(table_row_from_value(F("BMx80"), F("Sensor type"), String(currentSensor), ""));
}
JsonObject &parseHTTPRequest() {
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::BMPx80);
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::BMPx80);
setBoolVariableFromHTTP(String(F("in")), sensorInsideCase, SimpleScheduler::BMPx80);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
ret[F("i")] = sensorInsideCase;
return ret;
};
void afterSend(bool status) {
if (!enabled) return;
debug_out(F("BMPx80 - reset stats"),DEBUG_MED_INFO);
last_value_BMP280_P = currentPressure();
last_value_BMP280_T = currentTemp();
sampleCount = 0;
}
unsigned long process(SimpleScheduler::LoopEventType e) {
switch (e) {
case SimpleScheduler::INIT:
initBMPx80();
if (readyBMPx80()) {
samplesT = new float[SAMPLE_SIZE];
samplesP = new float[SAMPLE_SIZE];
readFromSensor();
}
return time2Measure() - 5000 -
SAMPLE_SIZE * 5000; //do not deregister - on status page we can write about failure
case SimpleScheduler::RUN:
if (!readyBMPx80()) {
return 10000;
}
readFromSensor();
return 5000;
}
return 10000;
}
void readConfigJSON(JsonObject &json) {
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
sensorInsideCase = json.get<bool>(F("i"));
if (cfg::bmp280_read) { //old setting takes over
enabled = true;
}
//register/deregister sensor
if (enabled && !scheduler.isRegistered(SimpleScheduler::BMPx80)) {
scheduler.registerSensor(SimpleScheduler::BMPx80, BMPx80::process, FPSTR(BMPx80::KEY));
scheduler.init(SimpleScheduler::BMPx80);
enabled = true;
debug_out(F("BMPx80: start"), DEBUG_MIN_INFO, 1);
} else if (!enabled && scheduler.isRegistered(SimpleScheduler::BMPx80)) { //de
debug_out(F("BMPx80: stop"), DEBUG_MIN_INFO, 1);
scheduler.unregisterSensor(SimpleScheduler::BMPx80);
}
//register display - separate check to allow enable/disable display not only when turning BMPx80 on/off
if (enabled && printOnLCD) scheduler.registerDisplay(SimpleScheduler::BMPx80, 1);
}
}
| 8,295
|
C++
|
.cpp
| 225
| 26.715556
| 114
| 0.538356
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,446
|
bme280.cpp
|
nettigo_namf/src/sensors/bme280/bme280.cpp
|
#include "bme280.h"
namespace BME280 {
const char KEY[] PROGMEM = "BME280";
bool enabled = false;
bool printOnLCD = false;
const unsigned int SAMPLE_SIZE = 5;
byte sampleCount = 0;
float *samplesT = nullptr;
float *samplesP = nullptr;
float *samplesH = nullptr;
Adafruit_BME280 bme280;
bool readyBME280() {
return !bme280_init_failed;
}
bool isEnabled() {
return enabled;
}
/*****************************************************************
* Init BMP280 *
*****************************************************************/
bool initBME280(char addr) {
debug_out(F("Trying BME280 sensor on "), DEBUG_MIN_INFO, true);
debug_out(String(addr, HEX), DEBUG_MIN_INFO, 0);
if (bme280.begin(addr)) {
debug_out(F(" ... found"), DEBUG_MIN_INFO, 1);
bme280.setSampling(
Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::FILTER_OFF);
return true;
} else {
debug_out(F(" ... not found"), DEBUG_MIN_INFO, 1);
return false;
}
}
//set defaults if no config file
void setDefaults(void) {
enabled = true;
printOnLCD = true;
}
bool initBME280() {
if (initBME280(0x76) || initBME280(0x77)) {
bme280_init_failed = false;
return true;
}
bme280_init_failed = true;
return false;
}
void readFromSensor() {
if (sampleCount >= SAMPLE_SIZE)
return;
float p = -1;
float t = -128;
float h = -1;
if (bme280.takeForcedMeasurement()) {
p = bme280.readPressure();
t = bme280.readTemperature();
h = bme280.readHumidity();
}
if (isnan(p) || isnan(t) || isnan(h)) {
t = -128.0;
p = -1.0;
h = -1;
debug_out(String(FPSTR(SENSORS_BME280)) + FPSTR(DBG_TXT_COULDNT_BE_READ), DEBUG_ERROR, 1);
} else {
samplesP[sampleCount] = p;
samplesT[sampleCount] = t;
samplesH[sampleCount] = h;
sampleCount++;
}
}
float currentPressure() {
if (sampleCount == 0)
return -1;
float sum = 0;
for (byte i = 0; i < sampleCount; i++)
sum += samplesP[i];
return sum / sampleCount;
}
float currentPressureHPa() {
float ret = currentPressure();
if (ret == -1) return -1;
return ret/100.0;
}
float currentTemp() {
if (sampleCount == 0)
return -128;
float sum = 0;
for (byte i = 0; i < sampleCount; i++)
sum += samplesT[i];
return sum / sampleCount;
}
float currentHumidity() {
if (sampleCount == 0)
return -1;
float sum = 0;
for (byte i = 0; i < sampleCount; i++)
sum += samplesH[i];
return sum / sampleCount;
}
/*****************************************************************
* read BMP280 sensor values *
*****************************************************************/
void sendToLD() {
const int HTTP_PORT_DUSTI = (cfg::ssl_dusti ? 443 : 80);
String result;
results(result);
sendLuftdaten(result, BME280_API_PIN, HOST_DUSTI, HTTP_PORT_DUSTI, URL_DUSTI, true, "BME280_");
}
String getConfigJSON() {
String ret = F("");
ret.concat(Var2JsonInt(F("e"), enabled));
if (printOnLCD) ret.concat(Var2JsonInt(F("d"), printOnLCD));
return ret;
};
bool dataAvailable() {
return sampleCount > 0;
}
void results(String &s) {
if (!enabled) return;
if (!dataAvailable()) return;
s.concat(Value2Json(F("BME280_temperature"), String(currentTemp())));
s.concat(Value2Json(F("BME280_pressure"), String(currentPressure())));
s.concat(Value2Json(F("BME280_humidity"), String(currentHumidity())));
}
void resultsAsHTML(String &page_content) {
if (!enabled) return;
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(KEY), FPSTR(INTL_TEMPERATURE),
check_display_value(currentTemp(), -128, 1, 0), F("°C")));
page_content.concat(table_row_from_value(FPSTR(KEY), FPSTR(INTL_PRESSURE),
check_display_value(currentPressureHPa(), -1, 1, 0), F("hPa")));
page_content.concat(table_row_from_value(FPSTR(KEY), FPSTR(INTL_HUMIDITY),
check_display_value(currentHumidity(), -1, 1, 0), F("%")));
}
JsonObject &parseHTTPRequest() {
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::BME280);
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::BME280);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
return ret;
};
void afterSend(bool status) {
if (!enabled) return;
debug_out(F("BME280 - reset stats"), DEBUG_MED_INFO);
last_value_BME280_P = currentPressure();
last_value_BME280_T = currentTemp();
last_value_BME280_H = currentHumidity();
sampleCount = 0;
}
unsigned long interval() {
unsigned long ret = cfg::sending_intervall_ms;
if (ret > 10000) ret -= 10000;
return ret / SAMPLE_SIZE;
}
unsigned long process(SimpleScheduler::LoopEventType e) {
switch (e) {
case SimpleScheduler::INIT:
initBME280();
if (readyBME280()) {
samplesT = new float[SAMPLE_SIZE];
samplesP = new float[SAMPLE_SIZE];
samplesH = new float[SAMPLE_SIZE];
sampleCount = 0;
readFromSensor();
}
return interval();
case SimpleScheduler::RUN:
if (!readyBME280()) {
return 10000;
}
readFromSensor();
auto left = time2Measure();
if (left == 0) left = 100;
if (sampleCount >= SAMPLE_SIZE) return left; // we are full wait till period end
return interval();
}
return 10000;
}
void readConfigJSON(JsonObject &json) {
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
//register/deregister sensor
if (enabled && !scheduler.isRegistered(SimpleScheduler::BME280)) {
scheduler.registerSensor(SimpleScheduler::BME280, BME280::process, FPSTR(BME280::KEY));
scheduler.init(SimpleScheduler::BME280);
enabled = true;
debug_out(F("BME280: start"), DEBUG_MIN_INFO, 1);
} else if (!enabled && scheduler.isRegistered(SimpleScheduler::BME280)) { //de
debug_out(F("BME280: stop"), DEBUG_MIN_INFO, 1);
scheduler.unregisterSensor(SimpleScheduler::BME280);
}
//register display - separate check to allow enable/disable display not only when turning BME280 on/off
if (enabled && printOnLCD) scheduler.registerDisplay(SimpleScheduler::BME280, 1);
}
}
| 7,720
|
C++
|
.cpp
| 200
| 28.275
| 113
| 0.522779
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,447
|
winsen-mhz.cpp
|
nettigo_namf/src/sensors/mhz14a/winsen-mhz.cpp
|
//
// Created by viciu on 22.02.2020.
//
#include "winsen-mhz.h"
#include <stdint.h>
#include <stdbool.h>
namespace MHZ14A {
const char KEY[] PROGMEM = "MHZ14A";
bool enabled = false;
bool printOnLCD = false;
#define CMD_SIZE 9
typedef enum {
START_BYTE,
COMMAND,
DATA,
CHECK
} state_t;
//for internal use - register/deregister display
void registerDisplayMHZ() {
if (enabled && printOnLCD)
scheduler.registerDisplay(SimpleScheduler::MHZ14A, 1); // one screen
else
scheduler.registerDisplay(SimpleScheduler::MHZ14A, 0); // disable
}
JsonObject &parseHTTPRequest() {
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::MHZ14A);
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::MHZ14A);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
registerDisplayMHZ();
ret.printTo(Serial);
return ret;
};
//send data to LD API...
void sendToLD(){
};
void getResults(String &str) {
if (!enabled) return;
str.concat(sensorMHZ());
};
void resultsAsHTML(String &page_content) {
if (!enabled) { return; }
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(INTL_MHZ14A_VAL), F("CO2"), String(last_value_WINSEN_CO2),
F("ppm")));
}
void readConfigJSON(JsonObject &json) {
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
scheduler.enableSubsystem(SimpleScheduler::MHZ14A, enabled, MHZ14A::process, FPSTR(MHZ14A::KEY));
registerDisplayMHZ();
};
String getConfigJSON(void) {
String ret = F("");
ret += Var2JsonInt(F("e"), enabled);
if (printOnLCD) ret += Var2JsonInt(F("d"), printOnLCD);
return ret;
}
void display(byte cols, byte minor, String lines[]) {
lines[0] = (F("CO2 (MHZ14A)"));
lines[1] = String(last_value_WINSEN_CO2);
lines[1] += (F(" ppm"));
return;
};
bool getDisplaySetting() {
return printOnLCD;
};
unsigned long process(SimpleScheduler::LoopEventType event) {
switch (event) {
case SimpleScheduler::INIT:
setupWinsenMHZ(serialGPS);
return 1000;
case SimpleScheduler::RUN:
readWinsenMHZ(serialGPS);
return 1000;
default:
return 1000;
}
};
/**
Prepares a command buffer to send to an mhz19.
@param data tx data
@param buffer the tx buffer to fill
@param size the size of the tx buffer
@return number of bytes in buffer
*/
int prepare_tx(uint8_t cmd, const uint8_t *data, uint8_t buffer[], int size) {
if (size < CMD_SIZE) {
return 0;
}
// create command buffer
buffer[0] = 0xFF;
buffer[1] = 0x01;
buffer[2] = cmd;
for (int i = 3; i < 8; i++) {
buffer[i] = *data++;
}
// calculate checksum
uint8_t check = 0;
for (int i = 0; i < 8; i++) {
check += buffer[i];
}
buffer[8] = 255 - check;
return CMD_SIZE;
}
/**
Processes one received byte.
@param b the byte
@param cmd the command code
@param data the buffer to contain a received message
@return true if a full message was received, false otherwise
*/
bool process_rx(uint8_t b, uint8_t cmd, uint8_t data[]) {
static uint8_t check = 0;
static int idx = 0;
static int len = 0;
static state_t state = START_BYTE;
// update checksum
check += b;
switch (state) {
case START_BYTE:
if (b == 0xFF) {
check = 0;
state = COMMAND;
}
break;
case COMMAND:
if (b == cmd) {
idx = 0;
len = 6;
state = DATA;
} else {
state = START_BYTE;
process_rx(b, cmd, data);
}
break;
case DATA:
data[idx++] = b;
if (idx == len) {
state = CHECK;
}
break;
case CHECK:
state = START_BYTE;
return (check == 0);
default:
state = START_BYTE;
break;
}
return false;
}
bool exchange_command(SoftwareSerial &sensor, uint8_t cmd, uint8_t data[], unsigned int timeout) {
// create command buffer
uint8_t buf[9];
int len = prepare_tx(cmd, data, buf, sizeof(buf));
// send the command
sensor.write(buf, len);
// wait for response
unsigned long start = millis();
while ((millis() - start) < timeout) {
if (sensor.available() > 0) {
uint8_t b = sensor.read();
if (process_rx(b, cmd, data)) {
return true;
}
}
yield();
}
return false;
}
bool set_range(SoftwareSerial &serial, range_t r) {
uint8_t data[6];
uint8_t *p = data;
switch (r) {
case RANGE_2K:
*p++ = 0x00;
*p++ = 0x00;
*p++ = 0x00;
*p++ = 0x07;
*p++ = 0xD0;
*p++ = 0x8F;
break;
case RANGE_10K:
*p++ = 0x00;
*p++ = 0x00;
*p++ = 0x00;
*p++ = 0x27;
*p++ = 0x10;
*p++ = 0x2F;
break;
}
return exchange_command(serial, 0x99, p, 3000);
}
bool read_temp_co2(SoftwareSerial &serial, unsigned int *co2, unsigned int *temp) {
uint8_t data[] = {0, 0, 0, 0, 0, 0};
bool result = exchange_command(serial, 0x86, data, 3000);
if (result) {
*temp = data[2] - 40;
*co2 = (data[0] << 8) + data[1];
debug_out(F("Response from CO2 sensor"), DEBUG_MED_INFO);
#if 0
char raw[32];
sprintf(raw, "RAW: %02X %02X %02X %02X %02X %02X", data[0], data[1], data[2], data[3],
data[4], data[5]);
Serial.println(raw);
Serial.print(*temp);
Serial.print(F(" "));
Serial.println(*co2);
#endif
} else {
debug_out(F("Timeout waiting for CO2 sensor"),DEBUG_MED_INFO);
}
return result;
}
#define WINSEN_AVG_SAMPLE 10
unsigned int *samples = nullptr;
unsigned int samplesCount;
void setupWinsenMHZ(SoftwareSerial &serial) {
serial.begin(9600);
set_range(serial, RANGE_2K);
samples = new unsigned int[WINSEN_AVG_SAMPLE];
if (samples == nullptr) {
debug_out(F("MHZ14A - no array for data"), DEBUG_ERROR);
}
samplesCount = 0;
}
void readWinsenMHZ(SoftwareSerial &serial) {
unsigned int co2, temp;
static unsigned long lastRead = millis();
static unsigned long interval = cfg::sending_intervall_ms / (WINSEN_AVG_SAMPLE + 2);
// Serial.println(samplesCount);
// Serial.println(millis() - lastRead);
// Serial.println(interval);
if (samplesCount < WINSEN_AVG_SAMPLE && millis() - lastRead > interval) {
lastRead = millis();
if (read_temp_co2(serial, &co2, &temp)) {
// debug_out(String("read Winsen"), DEBUG_MIN_INFO, true);
samples[samplesCount++] = co2;
last_value_WINSEN_CO2 = co2;
} //else debug_out(String("**** NO read Winsen"), DEBUG_MIN_INFO, true);
}
}
//reset counter after sending
void afterSend(bool status) {
samplesCount = 0;
}
float currentReading() {
unsigned long sum = 0;
if (samplesCount == 0) return 0;
for (byte i = 0; i < samplesCount; i++)
sum += samples[i];
return sum /(float)samplesCount;
}
String sensorMHZ() {
String s;
if (samples == nullptr || samplesCount == 0) return s;
if (currentReading() > 0) {
s += Value2Json(F("conc_co2_ppm"), String(currentReading()));
}
return s;
}
}
| 8,693
|
C++
|
.cpp
| 264
| 22.981061
| 113
| 0.514609
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,448
|
heca.cpp
|
nettigo_namf/src/sensors/heca/heca.cpp
|
//
// Created by viciu on 10.05.2021.
//
#include "heca.h"
#include "../../helpers.h"
#define HECA_DATAPOINTS 20
namespace HECA {
const char KEY[]
PROGMEM = "HECA";
bool enabled = false;
bool printOnLCD = false;
ClosedCube_SHT31D heca;
unsigned long lastDatapoint = 0; //when last time we have saved T & RH to average
unsigned long interval = 0;
double rh_total, t_total;
unsigned dataCount, dutyCycleCount, dutyCycleValT, dutyCycleValRH, dutyCycleTotal;
unsigned long humidityClear, humiditySet;
//set defaults if no config file
void setDefaults(void) {
enabled = true;
printOnLCD = true;
humidityClear = 60; //this is default humidity value when HECA turns off
humiditySet = 63; //this is default humidity value when HECA turns on
}
JsonObject &parseHTTPRequest() {
setBoolVariableFromHTTP(String(F("enabled")), enabled, SimpleScheduler::HECA);
setBoolVariableFromHTTP(String(F("display")), printOnLCD, SimpleScheduler::HECA);
setVariableFromHTTP(String(F("s")), humiditySet, SimpleScheduler::HECA);
setVariableFromHTTP(String(F("c")), humidityClear, SimpleScheduler::HECA);
DynamicJsonBuffer jsonBuffer;
JsonObject &ret = jsonBuffer.createObject();
ret[F("e")] = enabled;
ret[F("d")] = printOnLCD;
return ret;
};
String getConfigJSON(){
String ret = F("");
ret.concat(Var2JsonInt(F("e"), enabled));
if (printOnLCD) ret.concat(Var2JsonInt(F("d"), printOnLCD));
addJsonIfNotDefault(ret, F("s"), 63, humiditySet);
addJsonIfNotDefault(ret, F("c"), 60, humidityClear);
return ret;
};
void readConfigJSON( JsonObject &json){
enabled = json.get<bool>(F("e"));
printOnLCD = json.get<bool>(F("d"));
if (json.containsKey(F("s"))) {
humiditySet = json.get<unsigned long>(F("s"));
}
if (json.containsKey(F("c"))) {
humidityClear = json.get<unsigned long>(F("c"));
}
if (enabled && !scheduler.isRegistered(SimpleScheduler::HECA)) {
scheduler.registerSensor(SimpleScheduler::HECA, HECA::process, FPSTR(HECA::KEY));
scheduler.init(SimpleScheduler::HECA);
debug_out(F("HECA started"), DEBUG_MED_INFO);
} else if (!enabled && scheduler.isRegistered(SimpleScheduler::HECA)) {
scheduler.unregisterSensor(SimpleScheduler::HECA);
debug_out(F("HECA stopped"), DEBUG_MED_INFO);
}
if (enabled && printOnLCD) scheduler.registerDisplay(SimpleScheduler::HECA, 1);
};
bool display(byte rows, byte minor, String lines[]) {
byte row = 0;
if (getLCDRows() == 4) {
lines[row].concat((FPSTR(SENSORS_HECA)));
}
row++;
lines[row].concat((F("RH: ")));
lines[row].concat((check_display_value(last_value_HECA_H, -1, 1, 0)));
lines[row].concat((F(" ")));
lines[row].concat((FPSTR(UNIT_PERCENT)));
row++;
lines[row].concat((F("T: ")));
lines[row].concat((check_display_value(last_value_HECA_T, -128, 1, 0)));
lines[row].concat((F(" ")));
lines[row].concat((FPSTR(UNIT_CELCIUS_LCD)));
// lines[row].concat((F(" µg/m³")));
if (getLCDRows() == 4) {
row++;
lines[row].concat((FPSTR(INTL_HECA_DC)));
lines[row].concat((F(" ")));
lines[row].concat((String(getDutyCycle(),1)));
lines[row].concat((F(" ")));
lines[row].concat((FPSTR(UNIT_PERCENT)));
}
return true;
}
void initCycle() {
t_total = rh_total = 0;
dutyCycleCount = dutyCycleValT = dutyCycleValRH = dataCount = dutyCycleTotal = 0;
}
void getData() {
SHT31D_RegisterStatus reg;
SHT31D result = heca.periodicFetchData();
reg = heca.readStatusRegister();
// SHT31D alertSetHigh = heca.readAlertHighSet();
// SHT31D alertSetLow = heca.readAlertLowSet();
// SHT31D alertClearHigh = heca.readAlertHighClear();
// SHT31D alertClearLow = heca.readAlertLowClear();
if (result.error == SHT3XD_NO_ERROR /*&& alertClearLow.error == SHT3XD_NO_ERROR &&
alertClearHigh.error == SHT3XD_NO_ERROR && alertSetLow.error == SHT3XD_NO_ERROR &&
alertSetHigh.error == SHT3XD_NO_ERROR*/) {
if (millis() - lastDatapoint > interval) {
lastDatapoint = millis();
t_total += result.t;
rh_total += result.rh;
dataCount++;
}
if (reg.rawData & 1<<10) //Temp tracking alert
dutyCycleValT++;
if (reg.rawData & 1<<11) //RH tracking alert
dutyCycleValRH++;
if (reg.rawData & 1<<15)
dutyCycleTotal++;
dutyCycleCount++;
/*
Serial.println("HECA\t\tSetH\tSetL\tClH\tClL\tAlert");
Serial.print(F("Temp\t"));
Serial.print(result.t);
Serial.print(F("\t"));
Serial.print(alertSetHigh.t);
Serial.print(F("\t"));
Serial.print(alertSetLow.t);
Serial.print(F("\t"));
Serial.print(alertClearHigh.t);
Serial.print(F("\t"));
Serial.print(alertClearLow.t);
Serial.print(F("\t"));
Serial.print((reg.rawData & 1<<10) ? 1:0);
Serial.print((reg.rawData & 1<<15) ? 1:0);
// Serial.print(F("\t"));
Serial.println();
Serial.print(F("RH\t"));
Serial.print(result.rh);
Serial.print(F("\t"));
Serial.print(alertSetHigh.rh);
Serial.print(F("\t"));
Serial.print(alertSetLow.rh);
Serial.print(F("\t"));
Serial.print(alertClearHigh.rh);
Serial.print(F("\t"));
Serial.print(alertClearLow.rh);
Serial.print(F("\t"));
Serial.print((reg.rawData & 1<<11) ? 1:0);
Serial.print((reg.rawData & 1<<15) ? 1:0);
Serial.print(reg.RH_TrackingAlert);
// Serial.print(F("\t"));
Serial.println();
// Serial.println(reg.rawData,HEX);
// Serial.println((unsigned long)(reg.rawData+65536), BIN);
// Serial.println(" EDCBA09876543210");
*/
} else {
Serial.println("HECA error");
}
}
void afterSend(bool status) {
initCycle();
}
float getDutyCycle() {
if (dutyCycleCount == 0) return 0.0;
return (float)dutyCycleTotal/dutyCycleCount*100;
}
bool dataAvailable() {
return dataCount > 0;
}
void getResults(String &res){
if (!enabled) return;
if (dataAvailable()) {
last_value_HECA_H = rh_total/dataCount;
last_value_HECA_T = t_total/dataCount;
res.concat(Value2Json(F("HECA_temperature"), Float2String(last_value_HECA_T)));
res.concat(Value2Json(F("HECA_humidity"), Float2String(last_value_HECA_H)));
if (dutyCycleCount) {
res.concat(Value2Json(F("HECA_Tdc"), String((float)dutyCycleValT/dutyCycleCount*100)));
res.concat(Value2Json(F("HECA_RHdc"), String((float)dutyCycleValRH/dutyCycleCount*100)));
res.concat(Value2Json(F("HECA_dc"), String(getDutyCycle())));
}
} else {
last_value_HECA_T = -128.0;
last_value_HECA_H = -1.0;
}
}
String getConfigHTML(void) {
String ret = F("");
String name;
advancedSectionStart(ret, SimpleScheduler::HECA);
setHTTPVarName(name, F("s"), SimpleScheduler::HECA);
ret.concat(formInputGrid(name, FPSTR(INTL_HECA_SET_RH), String(humiditySet), 3));
setHTTPVarName(name, F("c"), SimpleScheduler::HECA);
ret.concat(formInputGrid(name, FPSTR(INTL_HECA_CLEAR_RH), String(humidityClear), 3));
advancedSectionEnd(ret, SimpleScheduler::HECA);
return ret;
}
void resultsAsHTML(String &page_content) {
if (!enabled) return;
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_HECA), FPSTR(INTL_TEMPERATURE), check_display_value(last_value_HECA_T, -128, 1, 0), FPSTR(UNIT_CELCIUS)));
page_content.concat(table_row_from_value(FPSTR(SENSORS_HECA), FPSTR(INTL_HUMIDITY), check_display_value(last_value_HECA_H, -1, 1, 0), FPSTR(UNIT_PERCENT)));
}
void getStatusReport (String &page_content) {
if (!enabled) return;
if (dutyCycleCount) {
page_content.concat(FPSTR(EMPTY_ROW));
page_content.concat(table_row_from_value(FPSTR(SENSORS_HECA), "DutyCycle", String(getDutyCycle()), "%"));
page_content.concat(table_row_from_value(FPSTR(SENSORS_HECA), "DutyCycleTemp", String((float)dutyCycleValT/dutyCycleCount*100), FPSTR(UNIT_PERCENT)));
page_content.concat(table_row_from_value(FPSTR(SENSORS_HECA), "DutyCycleRH", String((float)dutyCycleValRH/dutyCycleCount*100), FPSTR(UNIT_PERCENT)));
}
}
unsigned long process(SimpleScheduler::LoopEventType e) {
switch (e) {
case SimpleScheduler::STOP:
break;
case SimpleScheduler::INIT:
if (initHECA())
return 1000;
else
return 0;
break;
case SimpleScheduler::RUN:
getData();
return 1000;
break;
}
return 1000;
}
/*****************************************************************
* read HECA (SHT30) sensor values *
*****************************************************************/
String sensorHECA() {
String s;
debug_out(String(FPSTR(DBG_TXT_START_READING)) + FPSTR(SENSORS_HECA), DEBUG_MED_INFO, 1);
SHT31D result = heca.periodicFetchData();
if (result.error == SHT3XD_NO_ERROR) {
last_value_HECA_T = result.t;
last_value_HECA_H = result.rh;
} else {
last_value_HECA_T = -128.0;
last_value_HECA_H = -1.0;
return s;
}
s.concat(Value2Json(F("HECA_temperature"), Float2String(last_value_HECA_T)));
s.concat(Value2Json(F("HECA_humidity"), Float2String(last_value_HECA_H)));
return s;
}
bool getDisplaySetting() {
return printOnLCD;
};
/*****************************************************************
* Init HECA *
*****************************************************************/
bool initHECA() {
debug_out(F("Trying HECA (SHT30) sensor on 0x44"), DEBUG_MED_INFO, 0);
heca.begin(0x44);
//heca.begin(addr);
if (heca.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_1HZ) != SHT3XD_NO_ERROR) {
debug_out(F(" ... not found"), DEBUG_MED_INFO, 1);
debug_out(F(" [HECA ERROR] Cannot start periodic mode"), DEBUG_ERROR, 1);
return false;
} else {
// temperature set, temperature clear, humidity set, humidity clear
if (heca.writeAlertHigh(120, 119, humiditySet, humidityClear) != SHT3XD_NO_ERROR) {
debug_out(F(" [HECA ERROR] Cannot set Alert HIGH"), DEBUG_ERROR, 1);
}
if (heca.writeAlertLow(5, -5, 0, 1) != SHT3XD_NO_ERROR) {
debug_out(F(" [HECA ERROR] Cannot set Alert LOW"), DEBUG_ERROR, 1);
}
if (heca.clearAll() != SHT3XD_NO_ERROR) {
debug_out(F(" [HECA ERROR] Cannot clear register"), DEBUG_ERROR, 1);
}
interval = cfg::sending_intervall_ms / (HECA_DATAPOINTS + 1);
initCycle();
return true;
}
}
}
| 12,030
|
C++
|
.cpp
| 277
| 33.711191
| 169
| 0.559283
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,449
|
scheduler.cpp
|
nettigo_namf/src/system/scheduler.cpp
|
//
// Created by viciu on 08.06.2020.
//
#include "scheduler.h"
#include "helpers.h"
#include "components.h"
#include "lang/select_lang.h"
namespace SimpleScheduler {
const char LET_0 [] PROGMEM = "EMPTY";
const char LET_1 [] PROGMEM = "SDS011";
const char LET_2 [] PROGMEM = "HECA";
const char LET_3 [] PROGMEM = "BME280";
const char LET_4 [] PROGMEM = "SHT3x";
const char LET_5 [] PROGMEM = "BMPx80";
const char LET_6 [] PROGMEM = "SPS30";
const char LET_7 [] PROGMEM = "NTW_WTD";
const char LET_8 [] PROGMEM = "MHZ14A";
const char LET_SIZE [] PROGMEM = "SIZE";
const char *LET_NAMES[] PROGMEM = {
LET_0, LET_1, LET_2, LET_3, LET_4, LET_5, LET_6, LET_7, LET_8, LET_SIZE
};
unsigned long nullF(LoopEventType event) { return 0; }
NAMFScheduler::NAMFScheduler() {
loopSize = 0;
#ifdef DBG_NAMF_TIMES
_runTimeMax = 0;
_lastRunTime = 0;
_runTimeMaxSystem = EMPTY;
#endif
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
_tasks[i].process = nullF;
_tasks[i].nextRun = 0;
_tasks[i].slotID = EMPTY;
}
}
void NAMFScheduler::process() {
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
yield(); // let internals run
//run if not EMPTY slot, has set nextRun and time has passed
if (_tasks[i].slotID && _tasks[i].nextRun && _tasks[i].nextRun < millis()) {
unsigned long nextRun = _tasks[i].process(RUN);
#ifdef DBG_NAMF_TIMES
unsigned long startTime = micros();
_lastRunTime = micros() - startTime;
if (( _lastRunTime) > 1000*1000) {
Serial.printf("Long run time for sensor %s (%lu ms)\n", LET_NAMES[_tasks[i].slotID], startTime/1000);
}
#endif
if (nextRun) {
_tasks[i].nextRun = millis() + nextRun;
} else {
_tasks[i].nextRun = 0;
}
#ifdef DBG_NAMF_TIMES
if (_lastRunTime > _runTimeMax) {
_runTimeMax = _lastRunTime;
_runTimeMaxSystem = _tasks[i].slotID;
}
#endif
}
}
}
void NAMFScheduler::init(LoopEntryType slot) {
if (slot == EMPTY) return;
int i = findSlot(slot);
if (i < 0) return;
unsigned long nextRun = _tasks[i].process(INIT);
if (nextRun) {
_tasks[i].nextRun = millis() + nextRun;
} else {
_tasks[i].nextRun = 0;
}
}
void NAMFScheduler::getConfigForms(String &page) {
String s = F("");
page.concat( F("<div id='ncf' >"));
LoopEntryType i = EMPTY;
i++;
for (; i < NAMF_LOOP_SIZE; i++) {
String templ = F(
"<form method='POST' action='/simple_config?sensor={sensor}' style='width:100%;'><div class='gc'>\n"
);
templ.concat(F("<div class='row'><hr/><h2>"));
templ.concat(findSlotDescription(i));
templ.concat(F("</h2></div>"));
boolean checked = findSlot(i) >= 0; // check if sensor is enabled
templ.concat(formCheckboxGrid(F("enabled-{sensor}"), FPSTR(INTL_ENABLE), checked));
String lines[] = {"","","",""};
if (SimpleScheduler::displaySensor(i,lines)) {
checked = sensorWantsDisplay(i);
templ.concat(formCheckboxGrid(F("display-{sensor}"), FPSTR(INTL_DISPLAY_NEW), checked));
}
//HTML to enable/disable given sensor
s = SimpleScheduler::selectConfigForm(i);
templ.concat(F("{body}</div><div class='gc'><div class='row'><input type='submit' value='"));
templ.concat(FPSTR(INTL_SAVE));
templ.concat(F("'/></div></div></form>\n"));
templ.replace(F("{sensor}"), String(i));
templ.replace(F("{body}"), s);
page.concat(templ);
if (page.length() > 1500)
webserverPartialSend(page);
}
page.concat(F("</div>"));
}
void NAMFScheduler::unregisterSensor(LoopEntryType slot) {
int i = findSlot(slot);
if (i < 0) return;
loopSize--;
_tasks[i].slotID = EMPTY;
_tasks[i].process(STOP);
return;
}
void NAMFScheduler::enableSubsystem(LoopEntryType subsyst, bool enabled, loopTimerFunc initFunc,
const __FlashStringHelper *code) {
if (enabled) {
if (!scheduler.isRegistered(subsyst)) {
scheduler.registerSensor(subsyst, initFunc, code);
scheduler.init(subsyst);
}
} else {
scheduler.unregisterSensor(subsyst);
}
};
bool NAMFScheduler::isRegistered(LoopEntryType slot) {
return findSlot(slot) >= 0;
}
//how many slots for sensors is available in total
byte NAMFScheduler::sensorSlots(void) {
return SCHEDULER_SIZE;
};
//how many free slots for
byte NAMFScheduler::freeSlots(void){
return SCHEDULER_SIZE - loopSize;
};
const __FlashStringHelper * NAMFScheduler::sensorName(LoopEntryType e){
return FPSTR(LET_NAMES[e]);
};
String NAMFScheduler::registeredNames(){
String t = F("");
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
if (_tasks[i].slotID != EMPTY) {
t += sensorName(_tasks[i].slotID);
t += F(" ");
}
}
return t;
}
#ifdef DBG_NAMF_TIMES
String NAMFScheduler::maxRunTimeSystemName(){
String t = F("");
t+= FPSTR(LET_NAMES[scheduler.timeMaxSystem()]);
return t;
}
#endif
//takes which screen to display and goes through list of all "display" sensor,
//counting which one is current. *minor* returns which screen from singe sensor should
//be displayed (sensor can register more than one screen to display)
LoopEntryType NAMFScheduler::selectSensorToDisplay(byte current_pos, byte &minor) {
byte sum = 0;
minor = 0;
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
if (sum + _tasks[i].hasDisplay > current_pos) {
minor = current_pos - sum;
return _tasks[i].slotID;
}
sum += _tasks[i].hasDisplay;
};
return EMPTY;
}
//inform scheduler that we want to display data on LCD
int NAMFScheduler::registerDisplay(LoopEntryType slot, byte screens) {
int i = findSlot(slot);
if (i < 0) return -1;
_tasks[i].hasDisplay = screens;
return 0;
}
//how many screens is being registered
unsigned NAMFScheduler::countScreens(void) {
unsigned sum = 0;
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
if (_tasks[i].slotID == EMPTY) continue;
sum += _tasks[i].hasDisplay;
}
return sum;
}
//register new sensor
int NAMFScheduler::registerSensor(LoopEntryType slot, loopTimerFunc processF, const __FlashStringHelper *code) {
{
if (loopSize + 1 >= SCHEDULER_SIZE)
return -1;
int i = findSlot(slot);
//no sensor yet
if (i < 0) i = findSlot(EMPTY);
if (i < 0) { return -1; };
_tasks[i].nextRun = 0;
_tasks[i].process = processF;
_tasks[i].slotID = slot;
_tasks[i].slotCode = code;
loopSize += 1;
//return idx
return loopSize - 1;
};
}
//find scheduler entry based on sensor type (slot ID)
int NAMFScheduler::findSlot(byte id) {
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
if (_tasks[i].slotID == id)
return i;
}
//no match
return -1;
}
void NAMFScheduler::dumpTable() {
for (byte i = 0; i < SCHEDULER_SIZE; i++) {
Serial.print(i);
Serial.print(",");
Serial.print(_tasks[i].slotID);
Serial.print(",");
Serial.print(_tasks[i].nextRun);
Serial.print(",");
Serial.println(_tasks[i].hasDisplay);
}
}
void NAMFScheduler::runIn(byte slot, unsigned long time, loopTimerFunc func) {
int idx;
idx = findSlot(slot);
if (idx < 0) return;
if (time > 0) {
_tasks[idx].nextRun = millis() + time;
} else {
_tasks[idx].nextRun = 0;
}
_tasks[idx].process = func;
};
void NAMFScheduler::runIn(byte slot, unsigned long time) {
int idx;
idx = findSlot(slot);
if (idx < 0) return;
if (time > 0) {
_tasks[idx].nextRun = millis() + time;
} else {
_tasks[idx].nextRun = 0;
}
}
LoopEntryType operator++(LoopEntryType &entry, int) {
LoopEntryType current = entry;
if (NAMF_LOOP_SIZE < entry + 1) entry = NAMF_LOOP_SIZE;
else entry = static_cast<LoopEntryType>( entry + 1);
return (current);
}
}
| 9,233
|
C++
|
.cpp
| 252
| 26.821429
| 121
| 0.537661
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,450
|
components.cpp
|
nettigo_namf/src/system/components.cpp
|
#include <Arduino.h>
#include "components.h"
namespace SimpleScheduler {
bool sensorWantsDisplay(LoopEntryType sensor){
switch (sensor) {
case SimpleScheduler::SHT3x:
return SHT3x::getDisplaySetting();
case SimpleScheduler::HECA:
return HECA::getDisplaySetting();
case SimpleScheduler::SDS011:
return SDS011::getDisplaySetting();
case SimpleScheduler::SPS30:
return SPS30::getDisplaySetting();
case SimpleScheduler::MHZ14A:
return MHZ14A::getDisplaySetting();
default:
return false;
}
};
//collect results as JSON. Currently it is called only before sending data, so it can be place where
//counters are reset and calculations are done
void getResults(String &res) {
SDS011::results(res);
SPS30::results(res);
SHT3x::results(res);
MHZ14A::getResults(res);
HECA::getResults(res);
BMPx80::results(res);
BME280::results(res);
}
//push results to Luftdaten/SensorCommunity
void sendToSC(void) {
if (cfg::send2dusti) {
SPS30::sendToLD();
server.handleClient();
SHT3x::sendToLD();
server.handleClient();
MHZ14A::sendToLD();
server.handleClient();
SDS011::sendToLD();
server.handleClient();
BMPx80::sendToLD();
server.handleClient();
BME280::sendToLD();
server.handleClient();
}
}
//did all API collect data?
void afterSendData(bool status) {
HECA::afterSend(status);
SDS011::afterSend(status);
SPS30::afterSend(status);
SHT3x::afterSend(status);
MHZ14A::afterSend(status);
BMPx80::afterSend(status);
BME280::afterSend(status);
}
//collect HTML table with current results
void getResultsAsHTML(String &res) {
SDS011::resultsAsHTML(res);
HECA::resultsAsHTML(res);
SPS30::resultsAsHTML(res);
SHT3x::resultsAsHTML(res);
MHZ14A::resultsAsHTML(res);
BMPx80::resultsAsHTML(res);
BME280::resultsAsHTML(res);
}
//collect sensors status
void getStatusReport(String &res){
HECA::getStatusReport(res);
SPS30::getStatusReport(res);
SDS011::getStatusReport(res);
BMPx80::getStatusReport(res);
NetworkWatchdog::resultsAsHTML(res);
}
//prepare forms with configuration
String selectConfigForm(LoopEntryType sensor) {
String s = F("");
switch (sensor) {
case SimpleScheduler::SDS011:
return SDS011::getConfigHTML();
case SimpleScheduler::SPS30:
return SPS30::getConfigHTML();
case SimpleScheduler::NTW_WTD:
return NetworkWatchdog::getConfigHTML();
case SimpleScheduler::SHT3x:
return SHT3x::getConfigHTML();
case SimpleScheduler::BMPx80:
return BMPx80::getConfigHTML();
case SimpleScheduler::HECA:
return HECA::getConfigHTML();
default:
return s;
}
}
JsonObject& parseHTTPConfig(LoopEntryType sensor) {
switch (sensor) {
case SimpleScheduler::HECA:
return HECA::parseHTTPRequest();
case SimpleScheduler::SDS011:
return SDS011::parseHTTPRequest();
case SimpleScheduler::SPS30:
return SPS30::parseHTTPRequest();
case SimpleScheduler::NTW_WTD:
return NetworkWatchdog::parseHTTPRequest();
case SimpleScheduler::SHT3x:
return SHT3x::parseHTTPRequest();
case SimpleScheduler::MHZ14A:
return MHZ14A::parseHTTPRequest();
case SimpleScheduler::BMPx80:
return BMPx80::parseHTTPRequest();
case SimpleScheduler::BME280:
return BME280::parseHTTPRequest();
default:
StaticJsonBuffer<16> jsonBuffer; //empty response
JsonObject & ret = jsonBuffer.createObject();
return ret;
}
}
String getConfigJSON(LoopEntryType sensor) {
String s = F("");
switch (sensor) {
case SimpleScheduler::HECA:
return HECA::getConfigJSON();
case SimpleScheduler::SDS011:
return SDS011::getConfigJSON();
case SimpleScheduler::SPS30:
return SPS30::getConfigJSON();
case SimpleScheduler::NTW_WTD:
return NetworkWatchdog::getConfigJSON();
case SimpleScheduler::SHT3x:
return SHT3x::getConfigJSON();
case SimpleScheduler::MHZ14A:
return MHZ14A::getConfigJSON();
case SimpleScheduler::BMPx80:
return BMPx80::getConfigJSON();
case SimpleScheduler::BME280:
return BME280::getConfigJSON();
default:
return s;
}
}
void readConfigJSON(LoopEntryType sensor, JsonObject &json) {
switch (sensor) {
case SimpleScheduler::HECA:
HECA::readConfigJSON(json);
return;
case SimpleScheduler::SDS011:
SDS011::readConfigJSON(json);
return;
case SimpleScheduler::SPS30:
SPS30::readConfigJSON(json);
return;
case SimpleScheduler::NTW_WTD:
NetworkWatchdog::readConfigJSON(json);
return;
case SimpleScheduler::SHT3x:
SHT3x::readConfigJSON(json);
return;
case SimpleScheduler::MHZ14A:
MHZ14A::readConfigJSON(json);
return;
case SimpleScheduler::BMPx80:
BMPx80::readConfigJSON(json);
return;
case SimpleScheduler::BME280:
BME280::readConfigJSON(json);
return;
default:
return;
}
}
void readConfigJSON(JsonObject &json) {
LoopEntryType i = EMPTY;
i++;
for (; i < NAMF_LOOP_SIZE; i++) {
if (json.containsKey(findSlotKey(i))) {
JsonObject &item = json[findSlotKey(i)];
readConfigJSON(i, item);
}
}
}
void getConfigJSON(String &json) {
String s, s1;
json += F("\"sensors\":{");
LoopEntryType i = EMPTY;
i++;
for (; i < NAMF_LOOP_SIZE; i++) {
s = getConfigJSON(i);
if (s.length() < 1) continue; //
s.remove(s.length() - 1);
s1 = F("\"{k}\":{{r}},");
s1.replace(F("{k}"), findSlotKey(i));
s1.replace(F("{r}"), s);
json += s1;
}
json.remove(json.length() - 1);
json += F("}");
}
const __FlashStringHelper *findSlotKey(LoopEntryType sensor) {
switch (sensor) {
case SimpleScheduler::HECA:
return FPSTR(HECA::KEY);
case SimpleScheduler::SDS011:
return FPSTR(SDS011::KEY);
case SimpleScheduler::SPS30:
return FPSTR(SPS30::KEY);
case SimpleScheduler::NTW_WTD:
return FPSTR(NetworkWatchdog::KEY);
case SimpleScheduler::SHT3x:
return FPSTR(SHT3x::KEY);
case SimpleScheduler::MHZ14A:
return FPSTR(MHZ14A::KEY);
case SimpleScheduler::BMPx80:
return FPSTR(BMPx80::KEY);
case SimpleScheduler::BME280:
return FPSTR(BME280::KEY);
default:
debug_out(F("**** MISSING SENSOR SLOT KEY: "), DEBUG_MIN_INFO, false);
debug_out(String(sensor), DEBUG_MIN_INFO, true);
return F("");
}
}
//convert sensor/subsytem type to string with code
const __FlashStringHelper *findSlotDescription(LoopEntryType sensor) {
switch (sensor) {
case SimpleScheduler::HECA:
return FPSTR(INTL_HECA_DESC);
case SimpleScheduler::SDS011:
return FPSTR(INTL_SDS011_DESC);
case SimpleScheduler::SPS30:
return FPSTR(INTL_SPS30_SENSOR_DESC);
case SimpleScheduler::NTW_WTD:
return FPSTR(INTL_NTW_WTD_DESC);
case SimpleScheduler::SHT3x:
return FPSTR(INTL_SHT3X_DESC);
case SimpleScheduler::MHZ14A:
return FPSTR(INTL_MHZ14A_DESC);
case SimpleScheduler::BMPx80:
return FPSTR(INTL_BMPx80_DESC);
case SimpleScheduler::BME280:
return FPSTR(INTL_BME280_DESC);
default:
return F("");
}
}
//check if senor has display subroutine. TODO - second parameter with LCD object
bool displaySensor(SimpleScheduler::LoopEntryType sensor, String (&lines)[4], byte cols, byte rows, byte minor) {
// Serial.print("displaySensor for: ");
// Serial.println(LET_NAMES[sensor]);
// Serial.println(cols);
switch (sensor) {
case SHT3x:
if (cols == 0) return true;
SHT3x::display(rows, minor, lines);
return true;
case HECA:
if (cols == 0) return true;
HECA::display(rows, minor, lines);
return true;
case SDS011:
if (cols == 0) return true; //we are able to do display
SDS011::display(rows, minor, lines);
return true;
case SPS30:
if (cols == 0) return true;
SPS30::display(rows, minor, lines);
return true;
case MHZ14A:
if (cols == 0) return true;
MHZ14A::display(rows, minor, lines);
return true;
default:
return false;
}
};
}
| 10,253
|
C++
|
.cpp
| 277
| 24.924188
| 117
| 0.545637
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,451
|
webserver.h
|
nettigo_namf/src/webserver.h
|
//
// Created by viciu on 17.02.2020.
//
#ifndef NAMF_WEBSERVER_H
#define NAMF_WEBSERVER_H
#include <Arduino.h>
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include "defines.h"
#include "variables.h"
#include "helpers.h"
#include "display/commons.h"
#include "system/scheduler.h"
#include "system/components.h"
#include "html-content.h"
extern String table_row_from_value(const String& sensor, const String& param, const String& value, const String& unit);
extern void updateFW(const String host, const String port, const String path);
extern void updateFW();
//latest stack dump
void webserver_dump_stack();
void sendHttpRedirect(ESP8266WebServer &httpServer);
/*****************************************************************
* Webserver Images *
*****************************************************************/
void webserver_images();
/*****************************************************************
* Webserver page not found *
*****************************************************************/
void webserver_not_found();
/*****************************************************************
* Webserver request auth: prompt for BasicAuth
*
* -Provide BasicAuth for all page contexts except /values and images
*****************************************************************/
bool webserver_request_auth(bool dbg_msg = true);
/*****************************************************************
* Webserver root: show all options *
*****************************************************************/
void webserver_root();
/*****************************************************************
* html helper functions *
*****************************************************************/
void webserverPartialSend(String &s);
String make_header(const String& title, bool configPage=false);
String make_footer(bool configPage = false);
//Webserver - current config as JSON (txt) to save
void webserver_config_json();
//Webserver - force update with custom URL
void webserver_config_force_update();
//Webserver - current config as JSON (txt) to save
void webserver_config_json_save();
void webserver_config();
/*****************************************************************
* Webserver wifi: show available wifi networks *
*****************************************************************/
void webserver_wifi();
/*****************************************************************
* Webserver root: show latest values *
*****************************************************************/
void webserver_values();
/*****************************************************************
* Webserver set debug level *
*****************************************************************/
void webserver_debug_level();
/*****************************************************************
* Webserver remove config *
*****************************************************************/
void webserver_removeConfig();
/*****************************************************************
* Webserver reset NodeMCU *
*****************************************************************/
void webserver_reset();
/*****************************************************************
* Webserver data.json *
*****************************************************************/
void webserver_data_json();
/*****************************************************************
* Webserver prometheus metrics endpoint *
*****************************************************************/
void webserver_prometheus_endpoint();
/*****************************************************************
* Webserver setup *
*****************************************************************/
void setup_webserver();
void webserver_status_page();
#endif //NAMF_WEBSERVER_H
| 4,185
|
C++
|
.h
| 86
| 47.186047
| 119
| 0.369799
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,452
|
html-content.h
|
nettigo_namf/src/html-content.h
|
#ifndef NAMF_HTML_CONTENT_H
#define NAMF_HTML_CONTENT_H
const char TXT_CONTENT_TYPE_JSON[] PROGMEM = "application/json";
const char TXT_CONTENT_TYPE_INFLUXDB[] PROGMEM = "application/x-www-form-urlencoded";
const char TXT_CONTENT_TYPE_TEXT_HTML[] PROGMEM = "text/html; charset=utf-8";
const char TXT_CONTENT_TYPE_TEXT_CSS[] PROGMEM = "text/css";
const char TXT_CONTENT_TYPE_APPLICATION_JS[] PROGMEM = "application/javascript";
const char TXT_CONTENT_TYPE_TEXT_PLAIN[] PROGMEM = "text/plain";
const char TXT_CONTENT_TYPE_IMAGE_SVG[] PROGMEM = "image/svg+xml";
const char SENSORS_SDS011[] PROGMEM = "SDS011";
const char SENSORS_DHT22[] PROGMEM = "DHT22";
const char SENSORS_PMSx003[] PROGMEM = "PMSx003";
const char SENSORS_DS18B20[] PROGMEM = "DS18B20";
const char SENSORS_BMP280[] PROGMEM = "BMPx80";
const char SENSORS_BME280[] PROGMEM = "BME280";
const char SENSORS_HECA[] PROGMEM = "HECA";
const char WEB_PAGE_HEADER[] PROGMEM = "<!DOCTYPE html><html>\
<head>\
<title>{t}</title>\
<meta name='viewport' content='width=device-width'>\
<link rel=\"stylesheet\" media=\"all\" href=\"/images?n=c1\" />\
</head><body>\
<div class='hdr'>\
<a href='/'><img src='/images?n=l'/></a>\
<h3>{tt}<br><a href='http://{sname}.local'>{sname}</a></h3>\
<small>ID: {id}<br/>MAC: {mac}<br/>{fwt}: {fw}</small></div><div class='content'><h4><a class='nn' href='/'>{h}</a> {n} {t}</h4>";
const char COMMON_CSS[] PROGMEM = "body{font-family:Arial;margin:0;}\n"
".content{margin:10px;}\n"
".spacer{padding:10px;}\n"
".r{text-align:right;}\n"
"td{vertical-align:top;}\n"
"a.nn{text-decoration:none;display:inline;color:inherit;background:none;padding:2px}\n"
"a.nn:hover{background:none}\n"
"a.plain{text-decoration:underline;display:inline;color:blue;background:inherit;}\n"
"a{text-decoration:none;padding:10px;background:#2B4;color:white;display:block;width:auto;border-radius:5px;}\n"
"a.plain:hover{background:inherit}\n"
"a:hover{background:#1A4}\n"
".wifi{background:none;color:blue;padding:5px;display:inline;}\n"
"input[type='text']{width:100%;}\n"
"input[type='password']{width:100%;}\n"
"input[type='submit']{border-radius:5px;font-size:medium;padding:5px;}\n"
".s_r{padding:9px !important;width:100%;border-style:none;background:#D44;color:white;text-align:left;}\n"
".s_r:hover {background:#E33;}\n"
".s_o{background:#F80;}\n"
".s_o:hover{background:#E70;}\n"
".hdr a{background:none;width:0;display:inline; color:black;padding:0px}\n"
".hdr{min-height:135px;background-color:#2B4;margin-bottom:20px}\n"
".hdr img{float:left;margin:20px}\n"
".hdr h3{margin:0; padding:20px 0 0 0;}\n"
"#ncf hr{margin:25px 10px;}\n";
const char CONFIG_WEB_PAGE_HEADER[] PROGMEM = "<!DOCTYPE html><html>\
<head>\
<title>{t}</title>\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\
<link rel=\"stylesheet\" media=\"all\" href=\"/images?n=c\" />\
<link rel=\"stylesheet\" media=\"all\" href=\"/images?n=c1\" />\
</head><body>\
<div class='hdr'>\
<a href='/'><img src='/images?n=l'/></a>\
<h3>{tt}<br><a href='http://{sname}.local'>{sname}</a></h3>\
<small>ID: {id}<br/>MAC: {mac}<br/>{fwt}: {fw}</small></div><div class='content'><h4><a class='nn' href='/'>{h}</a> {n} {t}</h4>";
const char CONFIG_CSS[] PROGMEM = ".tab {\n"
" overflow: hidden;\n"
" border: 1px solid #ccc;\n"
" background-color: #f1f1f1; max-width:920px\n"
"}\n"
".tab button {\n"
" background-color: inherit;\n"
" float: left;\n"
" border: none;\n"
" outline: none;\n"
" cursor: pointer;\n"
" padding: 14px 16px;\n"
" transition: 0.3s;\n"
"}\n"
".tab button:hover {\n"
" background-color: #ddd;\n"
"}\n"
".tab button.active {\n"
" background-color: #2B4;\n"
"}\n"
".tabcontent {\n"
" display: none;\n"
" padding: 6px 0px;\n"
" border: 1px solid #ccc;\n"
" border-top: none;\n"
"}\n"
".hidden { display: none;}\n"
".gc { display: grid;grid-template-columns: auto auto auto ; row-gap: 2px; column-gap: 10px;max-width:900px;}\n"
"@media screen and (min-width: 499px){.gc{margin-left:20px;}}\n"
".sect:not(:first-child){margin-top:10px;}\n"
".c2 {grid-column-start:2;grid-column-end: 4}\n"
"input[type='submit'] {margin-top:20px;}\n"
".row {grid-column-start:1;grid-column-end: 4}";
const char CONFIG_JS[] PROGMEM =
"function tab(evt, tabName) {\n"
" var i, tabcontent, tablinks;\n"
"\n"
" tabcontent = document.getElementsByClassName(\"tabcontent\");\n"
" for (i = 0; i < tabcontent.length; i++) {\n"
" tabcontent[i].style.display = \"none\";\n"
" }\n"
"\n"
" // Get all elements with class=\"tablinks\" and remove the class \"active\"\n"
" tablinks = document.getElementsByClassName(\"tablinks\");\n"
" for (i = 0; i < tablinks.length; i++) {\n"
" tablinks[i].className = tablinks[i].className.replace(\" active\", \"\");\n"
" }\n"
"\n"
" document.getElementById(tabName).style.display = \"block\";\n"
" evt.currentTarget.className += \" active\";\n"
"}\n"
"document.getElementsByClassName('tablinks')[0].click()\n"
"document.addEventListener(\"DOMContentLoaded\", function() {\n"
" console.log(\"DOM loaded\")\n"
" for (let el of document.querySelectorAll('.advSect')) el.classList.add('hidden');\n"
" for (let el of document.querySelectorAll('.asb')) el.addEventListener('click', function(e){\n"
" console.log(\"Click:\"+'as-'+e.target.dataset.code)\n"
" document.getElementById('as-'+e.target.dataset.code).classList.toggle('hidden')\n"
" });\n"
"})";
const char DEBUG_JS[] PROGMEM = "<script>function updateLog() {\n"
"fetch('/serial').then(r => r.text()).then((r) => {\n"
"var el = document.getElementById('logField')\n"
"if (r.length > 0 ) {el.scrollTop = el.scrollHeight}\n"
"el.innerText += r;}).catch(err => console.log(err));\n"
"};\n"
"setInterval(updateLog, 2000);</script>\n";
const char BR_TAG[] PROGMEM = "<br/>";
const char TABLE_TAG_OPEN[] PROGMEM = "<table>";
const char TABLE_TAG_CLOSE_BR[] PROGMEM = "</table>";
const char EMPTY_ROW[] PROGMEM = "<tr><td colspan='3' align='center'> </td></tr>";
const char WEB_PAGE_FOOTER[] PROGMEM = "<br/><br/><a href='/' style='display:inline;'>{t}</a><br/><br/><br/>\
<b><a href='https://air.nettigo.pl/' target='_blank' style='display:inline;background:none;color:black;'>© Nettigo Air Monitor (Koduj dla Polski)</a></b><br/><br/>\
<small>Firmware based on Sensor.Community project by<br/><a href='https://codefor.de/stuttgart/' target='_blank' style='display:inline;background:none;color:black;padding:0'>Open Knowledge Lab Stuttgart a.o. (Code for Germany)</a></small>\
</div></body></html>\r\n";
const char CONFIG_WEB_PAGE_FOOTER[] PROGMEM = "<br/><br/><a href='/' style='display:inline;'>{t}</a><br/><br/><br/>\
<b><a href='https://air.nettigo.pl/' target='_blank' style='display:inline;background:none;color:black;'>© Nettigo Air Monitor (Koduj dla Polski)</a></b><br/><br/>\
<small>Firmware based on Sensor.Community project by<br/><a href='https://codefor.de/stuttgart/' target='_blank' style='display:inline;background:none;color:black;padding:0'>Open Knowledge Lab Stuttgart a.o. (Code for Germany)</a></small>\
</div><script src=\"/images?n=j\"></script></body></html>\r\n";
const char WEB_ROOT_PAGE_CONTENT[] PROGMEM = "<a href='/values'>📈 {t}</a><br/>\
<a href='/config'>🔧 {conf}</a><br/>\
<a href='/status'>🩺 {status}</a><br/>\
<a href='/reset'>🔄 {restart}</a><br/>\
<a href='/debug'>🐛 {debug}</a><br/>\
<br/><a href='/removeConfig' class='s_o'>🔥 {conf_delete}</a><br/>\
";
const char WEB_DEBUG_PAGE_CONTENT[] PROGMEM = "<table style='width:100%;'>\
<tr><td colspan='3'>🐛 <b>{debug_level}</b></td></tr>\
<tr><td style='width:33%;'><a href='/debug?lvl=0'>{none}</a></td>\
<td style='width:33%;'><a href='/debug?lvl=1'>{error}</a></td>\
<td style='width:33%;'><a href='/debug?lvl=2'>{warning}</a></td>\
</tr><tr>\
<td><a href='/debug?lvl=3'>{min_info}</a></td>\
<td><a href='/debug?lvl=4'>{med_info}</a></td>\
<td><a href='/debug?lvl=5'>{max_info}</a></td>\
</tr>\
</table>\0";
const char WEB_CONFIG_SCRIPT[] PROGMEM = "<script>\
function setSSID(ssid){document.getElementById('wlanssid').value=ssid.innerText||ssid.textContent;document.getElementById('wlanpwd').focus();}\
function load_wifi_list(){var x=new XMLHttpRequest();x.open('GET','/wifi');x.onload = function(){if (x.status === 200) {document.getElementById('wifilist').innerHTML = x.responseText;}};x.send();}\
</script>";
const char WEB_REMOVE_CONFIG_CONTENT[] PROGMEM = "<h3>{t}</h3>\
<table><tr><td><form method='POST' action='/removeConfig'><input type='submit' class='s_r' name='submit' value='🔥 {b}'/></form></td><td><a href='/'>{c}</a></td></tr></table>\
";
const char WEB_RESET_CONTENT[] PROGMEM = "<h3>{t}</h3>\
<table><tr><td><form method='POST' action='/reset'><input type='submit' class='s_r' name='submit' value='🔄 {b}'/></form></td><td><a href='/'>{c}</a></td></tr></table>\
";
const char WEB_IOS_REDIRECT[] PROGMEM = "<html><body>Redirecting...\
<script type=\"text/javascript\">\
window.location = \"http://192.168.4.1/config\";\
</script>\
</body></html>";
#endif
| 11,373
|
C++
|
.h
| 174
| 51.195402
| 239
| 0.528076
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,453
|
ext_def.h
|
nettigo_namf/src/ext_def.h
|
#ifndef NAMF_EXT_DEF_H
#define NAMF_EXT_DEF_H
// Language config
#define CURRENT_LANG INTL_LANG
// Wifi config
const char EMPTY_STRING[] PROGMEM = "";
// BasicAuth config
const char WWW_USERNAME[] PROGMEM = "admin";
const char WWW_PASSWORD[] PROGMEM = "admin";
#define WWW_BASICAUTH_ENABLED 0
// Sensor Wifi config (config mode)
const char FS_SSID[] PROGMEM = "";
const char FS_PWD[] PROGMEM = "";
//Where send data
#define SEND2AQI 0
#define SEND2DUSTI 1
#define SSL_DUSTI 0
#define SEND2MADAVI 1
#define SSL_MADAVI 0
#define SEND2SENSEMAP 0
#define SEND2FSAPP 0
#define SEND2MQTT 0
#define SEND2INFLUX 0
#define SEND2LORA 0
#define SEND2CSV 0
#define SEND2CUSTOM 0
// OpenSenseMap
#define SENSEBOXID ""
enum LoggerEntry
{
LoggerDusti,
LoggerMadavi,
LoggerSensemap,
LoggerFSapp,
LoggerInflux,
LoggerCustom,
LoggerAQI
};
// IMPORTANT: NO MORE CHANGES TO VARIABLE NAMES NEEDED FOR EXTERNAL APIS
// Definition eigene API
const char HOST_CUSTOM[] PROGMEM = "192.168.234.1";
const char URL_CUSTOM[] PROGMEM = "/data.php";
#define PORT_CUSTOM 80
const char USER_CUSTOM[] PROGMEM = "";
const char PWD_CUSTOM[] PROGMEM= "";
// Definition eigene InfluxDB
const char HOST_INFLUX[] PROGMEM = "influx.server";
const char URL_INFLUX[] PROGMEM = "/write?db=luftdaten";
#define PORT_INFLUX 8086
// define pins for I2C
#define I2C_PIN_SCL D4
#define I2C_PIN_SDA D3
// define pin for one wire sensors
#if defined(ESP8266)
#define ONEWIRE_PIN D7
#endif
#if defined(ARDUINO_SAMD_ZERO)
#define ONEWIRE_PIN D7
#endif
// define serial interface pins for particle sensors
// Serial confusion: These definitions are based on SoftSerial
// TX (transmitting) pin on one side goes to RX (receiving) pin on other side
// SoftSerial RX PIN is D1 and goes to SDS TX
// SoftSerial TX PIN is D2 and goes to SDS RX
#if defined(ESP8266)
#define PM_SERIAL_RX D1
#define PM_SERIAL_TX D2
#endif
// define serial interface pins for GPS modules
#if defined(ESP8266)
#define GPS_SERIAL_RX D5
#define GPS_SERIAL_TX D6
#endif
// DHT22, temperature, humidity
#define DHT_READ 0
#define DHT_TYPE DHT22
#define DHT_API_PIN 7
// SDS011, der etwas teuerere Feinstaubsensor
#define SDS_READ 0
#define SDS_API_PIN 1
// PMS1003, PMS300, 3PMS5003, PMS6003, PMS7003
#define PMS_READ 0
#define PMS_API_PIN 1
// BMP280, temperature, pressure
#define BMP280_READ 0
#define BMP280_API_PIN 3
// BME280, temperature, humidity, pressure
#define BME280_READ 0
#define BME280_API_PIN 11
// HECA (SHT30), temperature, pressure
#define HECA_READ 0
#define HECA_API_PIN 7
#define WINSEN_MHZ14A_READ 0
#define WINSEN_MHZ14A_API 9
// DS18B20, temperature
#define DS18B20_READ 0
#define DS18B20_API_PIN 13
// GPS, bevorzugt Neo-6M
#define GPS_READ 0
#define GPS_API_PIN 9
// automatic firmware updates
#define AUTO_UPDATE 1
// use beta firmware
#define USE_BETA 0
// OLED Display SSD1306 angeschlossen?
#define HAS_DISPLAY 0
// LCD Display LCD1602 angeschlossen?
#define HAS_LCD1602 0
// LCD Display LCD1602 (0x27) angeschlossen?
#define HAS_LCD1602_27 0
// LCD Display LCD2004 (0x27) angeschlossen?
#define HAS_LCD2004_27 1
// LCD Display LCD2004 (0x3F)
#define HAS_LCD2004_3F 0
// RGB LED BAR (0x32)
#define HAS_LEDBAR_32 0
// show wifi info on LCD display
#define SHOW_WIFI_INFO 1
// show device info on LCD display
#define SHOW_DEVICE_INFO 1
//default TX trasnmit power
#define TX_OUTPUT_POWER 20.5
//default WiFi PHY MODE
#define PHY_MODE WIFI_PHY_MODE_11N;
// Wieviele Informationen sollen über die serielle Schnittstelle ausgegeben werden?
#define DEBUG 3
// Definition der Debuglevel
#define DEBUG_ERROR 1
#define DEBUG_WARNING 2
#define DEBUG_MIN_INFO 3
#define DEBUG_MED_INFO 4
#define DEBUG_MAX_INFO 5
/*
static const uint16_t suites[] PROGMEM = {
BR_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
BR_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
BR_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
BR_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
BR_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
BR_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
};
*/
// Definition GPIOs for Zero based Arduino Feather M0 LoRaWAN
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
//GPIO Pins
#define D0 0
#define D1 1
#define D2 2
#define D3 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#define D8 8
#define D9 9
#define D10 10
#define D11 11
#define D12 12
// LoRa module
#define RFM69_CS 8
#define RFM69_RST 4
#define RFM69_INT 3
#define RF69_FREQ 868.0
#define CLIENT_ADDRESS 2
#define SERVER_ADDRESS 100
#endif
#endif //NAMF_EXT_DEF_H
| 4,601
|
C++
|
.h
| 169
| 25.911243
| 84
| 0.781648
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,454
|
update.h
|
nettigo_namf/src/update.h
|
//
// Created by viciu on 25.01.2020.
//
#ifndef NAMF_UPDATE_H
#define NAMF_UPDATE_H
#include "defines.h"
#include "variables.h"
#include "helpers.h"
#include "sensors/sds011/sds011.h"
#ifdef ESP32
#include <WiFi.h> /// FOR ESP32
#include <HTTPClient.h> /// FOR ESP32 HTTP FOTA UPDATE ///
#include <HTTPUpdate.h> /// FOR ESP32 HTTP FOTA UPDATE ///
#include <WiFiClient.h> /// FOR ESP32 HTTP FOTA UPDATE ///
WiFiClient client; /// FOR ESP32 HTTP FOTA UPDATE ///
t_httpUpdate_return tryUpdate(char * const ver) {
t_httpUpdate_return ret = httpUpdate.update(client, UPDATE_HOST, UPDATE_PORT, UPDATE_URL, ver);
return ret;
}
#else
#include <ESP8266WiFi.h>
#include <ESP8266httpUpdate.h>
#include "helpers.h"
t_httpUpdate_return tryUpdate(const String host, const String port, const String path, const String ver) {
WiFiClient client;
Serial.println(ver);
t_httpUpdate_return ret = ESPhttpUpdate.update(client, host, port.toInt(), path, ver);
return ret;
};
#endif
t_httpUpdate_return tryUpdate(String const ver) {
String host;
String url;
switch(cfg::update_channel) {
case UPDATE_CHANNEL_ALFA:
host = String(UPDATE_HOST_ALFA);
url = String(UPDATE_URL_ALFA);
break;
case UPDATE_CHANNEL_BETA:
host = String(UPDATE_HOST_BETA);
url = String(UPDATE_URL_BETA);
break;
default:
host = String(UPDATE_HOST);
url = String(UPDATE_URL);
break;
}
debug_out(F("Update checked:"), DEBUG_MIN_INFO,true);
debug_out(host, DEBUG_MIN_INFO,true);
debug_out(url, DEBUG_MIN_INFO,true);
return tryUpdate(host,String(UPDATE_PORT), url, ver);
};
void verifyUpdate (t_httpUpdate_return result) {
last_update_attempt = millis();
switch (result) {
case HTTP_UPDATE_FAILED:
display_debug(F("[update] Update failed."),"");
Serial.println(F("[update] Update failed."));
break;
case HTTP_UPDATE_NO_UPDATES:
display_debug(F("[update] no Update."), String(SOFTWARE_VERSION));
Serial.println(F("[update] no Update."));
Serial.print(F("Still running version: "));
Serial.println(SOFTWARE_VERSION);
break;
case HTTP_UPDATE_OK:
Serial.println(F("[update] Update ok.")); // may not called we reboot the ESP
break;
}
}
String sds_report() {
String ret = F("");
if (SDS011::enabled || cfg::sds_read) {
ret += String(SDS011::failedReadings) + String(F("-")) + String(SDS011::readings);
// SDS011::failedReadings = SDS011::readings = 0;
} else {
ret += F("na-na");
}
return ret;
}
void updateFW(const String host, const String port, const String path) {
debug_out(F("Check for update with "),DEBUG_MIN_INFO,1);
display_debug(F("Update - check"), F(""));
debug_out(host,DEBUG_MIN_INFO,1);
debug_out(port,DEBUG_MIN_INFO,1);
debug_out(path,DEBUG_MIN_INFO,1);
Serial.println(SOFTWARE_VERSION);
String ver = String(SOFTWARE_VERSION)+ String(" ") + esp_chipid() + String(" ") + "SDS" + String(" ") +
String(cfg::current_lang) + String(" ") + String(FPSTR(INTL_LANG)) + sds_report();
t_httpUpdate_return ret = tryUpdate( host, port, path, ver);
verifyUpdate(ret);
};
void updateFW() {
Serial.print(F("Check for update with default URL"));
Serial.println(SOFTWARE_VERSION);
display_debug(F("Update - check"), F(""));
t_httpUpdate_return ret = tryUpdate(
String(SOFTWARE_VERSION) + String(" ") + esp_chipid() + String(" ") + "SDS" + String(" ") +
String(cfg::current_lang) + String(" ") + String(FPSTR(INTL_LANG)) + String(" ") + sds_report());
verifyUpdate(ret);
};
#endif //NAMF_UPDATE_H
| 3,836
|
C++
|
.h
| 102
| 31.764706
| 109
| 0.630885
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,455
|
variables.h
|
nettigo_namf/src/variables.h
|
//
// Created by viciu on 13.01.2020.
//
#ifndef AIRROHR_FIRMWARE_VARIABLES_H
#define AIRROHR_FIRMWARE_VARIABLES_H
#if defined(BOOT_FW)
#define SOFTWARE_VERSION "NAMF-2020-boot"
#else
#define SOFTWARE_VERSION "NAMF-2020-45a"
// undefine SOFTWARE_BETA in production releases
//#define SOFTWARE_BETA 1
#endif
#include "defines.h"
#include "system/scheduler.h"
#include <SoftwareSerial.h>
#include <ESP8266WebServer.h>
#include "./oledfont.h" // avoids including the default Arial font, needs to be included before SSD1306.h
#include <SSD1306.h>
#include <LiquidCrystal_I2C.h>
#include "ClosedCube_SHT31D.h" // support for Nettigo Air Monitor HECA
#include <DallasTemperature.h>
#include <TinyGPS++.h>
#include "ext_def.h"
#include "lang/select_lang.h"
extern SimpleScheduler::NAMFScheduler scheduler;
/******************************************************************
* The variables inside the cfg namespace are persistent *
* configuration values. They have defaults which can be *
* configured at compile-time via the ext_def.h file *
* They can be changed by the user via the web interface, the *
* changes are persisted to the flash and read back after reboot. *
* Note that the names of these variables can't be easily changed *
* as they are part of the json format used to persist the data. *
******************************************************************/
namespace cfg {
extern char *wlanssid;
extern char *wlanpwd;
//fallback SSID & pwd
extern char *fbssid;
extern char *fbpwd;
extern char current_lang[3];
extern char *www_username;
extern char *www_password;
extern bool www_basicauth_enabled;
extern char *fs_ssid;
extern char *fs_pwd;
extern bool dht_read;
extern bool sds_read;
extern bool pms_read;
extern bool bmp280_read;
extern bool bme280_read;
extern bool heca_read;
extern bool ds18b20_read;
extern bool gps_read;
extern bool send2dusti;
extern bool send2madavi;
extern bool send2sensemap;
extern bool send2fsapp;
extern bool send2custom;
extern bool send2aqi;
extern bool send2lora;
extern bool send2influx;
extern bool send2csv;
extern bool auto_update;
extern u8_t update_channel;
extern bool has_display;
extern bool has_lcd1602;
extern bool has_lcd1602_27;
extern bool has_lcd2004_27;
extern bool has_lcd2004_3f;
extern bool show_wifi_info;
extern bool sh_dev_inf;
extern bool has_ledbar_32;
extern float outputPower;
extern int phyMode;
extern int debug;
extern bool send_diag;
extern bool ssl_madavi;
extern bool ssl_dusti ;
extern char senseboxid[30];
extern int port_influx;
extern char *user_influx;
extern char *pwd_influx;
extern String host_custom;
extern String url_custom;
extern int port_custom;
extern char *user_custom;
extern char *pwd_custom;
extern String token_AQI;
extern String assign_token_AQI;
extern String host_influx;
extern String url_influx;
extern String UUID;
extern unsigned long time_for_wifi_config;
extern unsigned long sending_intervall_ms;
extern void initNonTrivials(const char* id);
}
typedef enum {
Start,
Stop,
ContinuousMode,
VersionDate,
None
}PmSensorCmd;
extern char *basic_auth_influx ;
extern char *basic_auth_custom ;
extern long int sample_count ;
extern bool bme280_init_failed ;
extern bool heca_init_failed ;
extern ESP8266WebServer server;
extern int TimeZone ;
/*****************************************************************
* Display definitions *
*****************************************************************/
extern SSD1306 * display;
extern LiquidCrystal_I2C * char_lcd;
/*****************************************************************
* SDS011 declarations *
*****************************************************************/
extern SoftwareSerial serialSDS;
extern SoftwareSerial serialGPS;
/*****************************************************************
* DS18B20 declaration *
*****************************************************************/
extern OneWire oneWire;
extern DallasTemperature ds18b20;
/*****************************************************************
* GPS declaration *
*****************************************************************/
extern TinyGPSPlus gps;
extern bool send_now ;
extern unsigned long starttime;
extern unsigned long time_point_device_start_ms;
extern unsigned long starttime_SDS;
extern unsigned long starttime_GPS;
extern unsigned long act_micro;
extern unsigned long act_milli;
extern unsigned long last_micro ;
extern unsigned long min_micro ;
extern unsigned long max_micro ;
extern bool is_SDS_running ;
extern bool is_PMS_running ;
extern unsigned long sending_time ;
extern unsigned long last_update_attempt;
extern int pms_pm1_sum ;
extern int pms_pm10_sum ;
extern int pms_pm25_sum ;
extern int pms_val_count ;
extern int pms_pm1_max ;
extern int pms_pm1_min ;
extern int pms_pm10_max ;
extern int pms_pm10_min ;
extern int pms_pm25_max ;
extern int pms_pm25_min ;
extern double last_value_SDS_P1 ;
extern double last_value_SDS_P2 ;
extern double last_value_PMS_P0 ;
extern double last_value_PMS_P1 ;
extern double last_value_PMS_P2 ;
extern double last_value_DHT_T ;
extern double last_value_DHT_H ;
extern double last_value_BMP280_T ;
extern double last_value_BMP280_P ;
extern double last_value_BME280_T ;
extern double last_value_BME280_H ;
extern double last_value_BME280_P ;
extern double last_value_HECA_T ;
extern double last_value_HECA_H ;
extern unsigned int last_value_WINSEN_CO2 ;
extern double last_value_DS18B20_T ;
extern double last_value_GPS_lat ;
extern double last_value_GPS_lon ;
extern double last_value_GPS_alt ;
extern String last_value_GPS_date ;
extern String last_value_GPS_time ;
extern String last_data_string ;
extern String esp_chipid();
extern long last_page_load ;
extern bool wificonfig_loop ;
extern bool first_cycle ;
extern bool sntp_time_is_set ;
extern bool got_ntp ;
extern unsigned long enable_ota_time ;
extern unsigned long count_sends ;
struct struct_wifiInfo {
char ssid[35];
uint8_t encryptionType;
int32_t RSSI;
int32_t channel;
bool isHidden;
};
extern struct struct_wifiInfo *wifiInfo;
extern uint8_t count_wifiInfo;
extern const char data_first_part[] ;
extern memory_stat_t memoryStatsMax;
extern memory_stat_t memoryStatsMin;
class LoggingSerial : public HardwareSerial {
public:
LoggingSerial();
size_t write(uint8_t c) override;
size_t write(const uint8_t *buffer, size_t size) override;
String popLines();
void stopWebCopy(void); //stop copying data to buffer available via network (passwords)
void resumeWebCopy(void); // enable copying data
private:
std::unique_ptr<circular_queue<uint8_t> > m_buffer;
bool skipBuffer;
};
extern class LoggingSerial Debug;
#endif //AIRROHR_FIRMWARE_VARIABLES_H
| 7,208
|
C++
|
.h
| 210
| 31.490476
| 108
| 0.665419
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,456
|
stack_dump.h
|
nettigo_namf/src/stack_dump.h
|
//
// Created by viciu on 16.05.2020.
//
#ifndef NAMF_STACK_DUMP_H
#define NAMF_STACK_DUMP_H
#include "Arduino.h"
#include <cont.h>
#include "FS.h"
#include <user_interface.h>
#include "variables.h"
#endif //NAMF_STACK_DUMP_H
| 228
|
C++
|
.h
| 11
| 19.545455
| 34
| 0.734884
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,457
|
sending.h
|
nettigo_namf/src/sending.h
|
//
// Created by viciu on 17.02.2021.
//
#ifndef NAMF_SENDING_H
#define NAMF_SENDING_H
#include <Arduino.h>
#include <ESP8266HTTPClient.h>
#include "ext_def.h"
#include "helpers.h"
#include "html-content.h"
#include "system/debug.h"
#include "variables.h"
#include "sensors/sds011/sds011.h" //debugging SDS and sending data to InfluxDB
#include <ESP8266WiFi.h>
#if defined(ESP8266)
#include "ca-root.h"
extern void configureCACertTrustAnchor(WiFiClientSecure* client);
#endif
/*****************************************************************
* send data to rest api *
*****************************************************************/
extern void sendData(const LoggerEntry logger, const String &data, const int pin, const String &host, const int httpPort, const String &url, const bool verify);
/*****************************************************************
* send single sensor data to luftdaten.info api *
*****************************************************************/
extern void sendLuftdaten(const String& data, const int pin, const char* host, const int httpPort, const char* url, const bool verify, const char* replace_str);
/*****************************************************************
* send data to LoRa gateway *
*****************************************************************/
// void send_lora(const String& data) {
// }
/*****************************************************************
* send data to mqtt api *
*****************************************************************/
// rejected (see issue #33)
/*****************************************************************
* send data to influxdb *
*****************************************************************/
extern String create_influxdb_string(const String& data);
/*****************************************************************
* send data as csv to serial out *
*****************************************************************/
extern void send_csv(const String& data);
#endif //NAMF_SENDING_H
| 2,219
|
C++
|
.h
| 44
| 48.909091
| 160
| 0.408965
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,458
|
helpers.h
|
nettigo_namf/src/helpers.h
|
//
// Created by viciu on 28.01.2020.
//
#ifndef NAMF_HELPERS_H
#define NAMF_HELPERS_H
#include "Arduino.h"
#include <ArduinoJson.h>
#include "variables.h"
#include <FS.h> // must be first
extern const char UNIT_PERCENT[];
extern const char UNIT_CELCIUS[];
extern const unsigned char UNIT_CELCIUS_LCD[];
int32_t calcWiFiSignalQuality(int32_t rssi);
void debug_out(const String& text, const int level, const bool linebreak = true);
//declarations for changing .ino to .cpp
String Float2String(const double value, uint8_t digits);
String Float2String(const double value);
void writeConfig();
String getConfigString(boolean);
String getMaskedConfigString();
int writeConfigRaw(const String &json_string, const char * filename = nullptr);
int readAndParseConfigFile(File);
String add_sensor_type(const String& sensor_text);
String Value2Json(const String& type, const String& value);
String Value2Json(const __FlashStringHelper *, const String& value);
String Var2Json(const String& name, const bool value);
String Var2JsonInt(const String& name, const bool value);
String Var2Json(const String& name, const int value);
String Var2Json(const String& name, const String & value);
String Var2Json(const String& name, const char * value);
String Var2Json(const String& name, const float value);
String Var2Json(const String& name, const unsigned long value);
void addJsonIfNotDefault(String &str,const __FlashStringHelper *name, const unsigned long defaultValue, const unsigned long current);
void parseHTTP(const __FlashStringHelper *, unsigned long & );
void parseHTTP(const __FlashStringHelper *, bool & );
void parseHTTP(const __FlashStringHelper *, String & );
void parseHTTP(const String &name, bool &value );
void parseHTTP(const __FlashStringHelper * , byte &value );
void setBoolVariableFromHTTP(String const name, bool &v, byte i);
void setVariableFromHTTP(String const name, unsigned long &v, byte i);
void setHTTPVarName(String &varName, String const name, byte id);
void advancedSectionStart( String &html, SimpleScheduler::LoopEntryType sensor);
void advancedSectionEnd( String &html, SimpleScheduler::LoopEntryType sensor);
unsigned long time2Measure(void);
String formSectionHeader(const String& name, byte bold = 0);
String formSectionHeader(String &page_content, const String& name, byte bold = 0);
String form_option(String const &name, const String & info, const bool checked = false);
String form_input(const String& name, const String& info, const String& value, const int length);
String formInputGrid(const String& name, const String& info, const String& value, const int length);
String form_password(const String& name, const String& info, const String& value, const int length);
String formPasswordGrid(const String& name, const String& info, const String& value, const int length);
String form_checkbox(const String& name, const String& info, const bool checked, const bool linebreak = true);
String formCheckboxGrid(const String& name, const String& info, const bool checked);
String formCheckboxOpenGrid(const String& name, const String& info, const bool checked);
String form_checkbox_sensor(const String& name, const String& info, const bool checked);
String form_submit(const String& value);
String formSubmitGrid(const String& value);
String form_select_lang();
void resetMemoryStats();
void collectMemStats();
void dumpCurrentMemStats();
void display_debug(const String& text1, const String& text2);
String millisToTime(const unsigned long);
unsigned stringToChar(char **dst, const String src);
//void dbg(char *v);
String getConfigString(boolean maskPwd = false);
#endif //NAMF_HELPERS_H
| 3,648
|
C++
|
.h
| 67
| 53.298507
| 134
| 0.789415
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,459
|
variables_init.h
|
nettigo_namf/src/variables_init.h
|
//
// Created by viciu on 28.01.2020.
//
#ifndef NAMF_VARIABLES_INIT_H
#define NAMF_VARIABLES_INIT_H
/******************************************************************
* The variables inside the cfg namespace are persistent *
* configuration values. They have defaults which can be *
* configured at compile-time via the ext_def.h file *
* They can be changed by the user via the web interface, the *
* changes are persisted to the flash and read back after reboot. *
* Note that the names of these variables can't be easily changed *
* as they are part of the json format used to persist the data. *
******************************************************************/
namespace cfg {
char *wlanssid = nullptr;
char *wlanpwd = nullptr;
char *fbssid = nullptr;
char *fbpwd = nullptr;
char current_lang[3] = "PL";
char *www_username = nullptr;
char *www_password = nullptr;
bool www_basicauth_enabled = WWW_BASICAUTH_ENABLED;
char *fs_ssid = nullptr;
char *fs_pwd = nullptr;
bool dht_read = DHT_READ;
bool sds_read = SDS_READ;
bool pms_read = PMS_READ;
bool bmp280_read = BMP280_READ;
bool bme280_read = BME280_READ;
bool heca_read = HECA_READ;
bool ds18b20_read = DS18B20_READ;
bool gps_read = GPS_READ;
bool send2dusti = SEND2DUSTI;
bool send2madavi = SEND2MADAVI;
bool send2sensemap = SEND2SENSEMAP;
bool send2fsapp = SEND2FSAPP;
bool send2custom = SEND2CUSTOM;
bool send2aqi = SEND2AQI;
bool send2lora = SEND2LORA;
bool send2influx = SEND2INFLUX;
bool send2csv = SEND2CSV;
bool auto_update = AUTO_UPDATE;
bool has_display = HAS_DISPLAY;
bool has_lcd1602 = HAS_LCD1602;
bool has_lcd1602_27 = HAS_LCD1602_27;
bool has_lcd2004_27 = HAS_LCD2004_27;
bool has_lcd2004_3f = HAS_LCD2004_3F;
bool show_wifi_info = SHOW_WIFI_INFO;
bool sh_dev_inf = SHOW_DEVICE_INFO;
bool has_ledbar_32 = HAS_LEDBAR_32;
float outputPower = TX_OUTPUT_POWER;
int phyMode = PHY_MODE;
int debug = DEBUG;
bool send_diag = true;
bool ssl_madavi = SSL_MADAVI;
bool ssl_dusti = SSL_DUSTI;
char senseboxid[30] = SENSEBOXID;
int port_influx = PORT_INFLUX;
char *user_influx = nullptr;
char *pwd_influx = nullptr;
String host_custom = FPSTR(HOST_CUSTOM);
String url_custom = FPSTR(URL_CUSTOM);
int port_custom = PORT_CUSTOM;
char *user_custom = nullptr;
char *pwd_custom = nullptr;
String token_AQI = FPSTR(EMPTY_STRING);
String assign_token_AQI = FPSTR(EMPTY_STRING);
String host_influx = FPSTR(HOST_INFLUX);
String url_influx = FPSTR(URL_INFLUX);
String UUID;
unsigned long time_for_wifi_config = 600000;
unsigned long sending_intervall_ms = 145000;
byte update_channel = UPDATE_CHANNEL_STABLE;
}
//enum class PmSensorCmd {
// Start,
// Stop,
// ContinuousMode,
// VersionDate
//};
long int sample_count = 0;
bool bme280_init_failed = false;
bool heca_init_failed = false;
ESP8266WebServer server(80);
int TimeZone = 1;
/*****************************************************************
* Display definitions *
*****************************************************************/
SSD1306 *display = nullptr;//(0x3c, I2C_PIN_SDA, I2C_PIN_SCL);
LiquidCrystal_I2C *char_lcd = nullptr;//(0x27, 16, 2);
/*****************************************************************
* SDS011 declarations *
*****************************************************************/
SoftwareSerial serialSDS;//(PM_SERIAL_RX, PM_SERIAL_TX, false);
SoftwareSerial serialGPS;//(GPS_SERIAL_RX, GPS_SERIAL_TX, false);
/*****************************************************************
* DS18B20 declaration *
*****************************************************************/
OneWire oneWire(ONEWIRE_PIN);
DallasTemperature ds18b20(&oneWire);
/*****************************************************************
* GPS declaration *
*****************************************************************/
TinyGPSPlus gps;
bool send_now = false;
unsigned long starttime;
unsigned long time_point_device_start_ms;
unsigned long starttime_SDS;
unsigned long starttime_GPS;
unsigned long act_micro;
unsigned long act_milli;
unsigned long last_micro = 0;
unsigned long min_micro = 1000000000;
unsigned long max_micro = 0;
bool is_SDS_running = true;
bool is_PMS_running = true;
unsigned long sending_time = 0;
unsigned long last_update_attempt;
int pms_pm1_sum = 0;
int pms_pm10_sum = 0;
int pms_pm25_sum = 0;
int pms_val_count = 0;
int pms_pm1_max = 0;
int pms_pm1_min = 20000;
int pms_pm10_max = 0;
int pms_pm10_min = 20000;
int pms_pm25_max = 0;
int pms_pm25_min = 20000;
double last_value_SDS_P1 = -1.0;
double last_value_SDS_P2 = -1.0;
double last_value_PMS_P0 = -1.0;
double last_value_PMS_P1 = -1.0;
double last_value_PMS_P2 = -1.0;
double last_value_DHT_T = -128.0;
double last_value_DHT_H = -1.0;
double last_value_BMP280_T = -128.0;
double last_value_BMP280_P = -1.0;
double last_value_BME280_T = -128.0;
double last_value_BME280_H = -1.0;
double last_value_BME280_P = -1.0;
double last_value_HECA_T = -128.0;
double last_value_HECA_H = -1.0;
unsigned int last_value_WINSEN_CO2 = 0;
double last_value_DS18B20_T = -1.0;
double last_value_GPS_lat = -200.0;
double last_value_GPS_lon = -200.0;
double last_value_GPS_alt = -1000.0;
String last_value_GPS_date = "";
String last_value_GPS_time = "";
String last_data_string = "";
String esp_chipid() {return String(ESP.getChipId());};
long last_page_load = millis();
bool wificonfig_loop = false;
bool first_cycle = true;
bool sntp_time_is_set = false;
bool got_ntp = false;
unsigned long enable_ota_time = 0;
unsigned long count_sends = 0;
struct struct_wifiInfo *wifiInfo;
uint8_t count_wifiInfo;
template<typename T, std::size_t N> constexpr std::size_t array_num_elements(const T(&)[N]) {
return N;
}
const char data_first_part[] PROGMEM = "{\"software_version\": \"{v}\", \"sensordatavalues\":[";
memory_stat_t memoryStatsMax;
memory_stat_t memoryStatsMin;
#endif //NAMF_VARIABLES_INIT_H
| 6,287
|
C++
|
.h
| 168
| 34.642857
| 96
| 0.612245
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,460
|
defines.h
|
nettigo_namf/src/defines.h
|
//
// Created by viciu on 28.01.2020.
//
#ifndef NAMF_DEFINES_H
#define NAMF_DEFINES_H
#include <stdint.h>
#include <Arduino.h>
/******************************************************************
* Constants *
******************************************************************/
const unsigned long SAMPLETIME_SDS_MS = 1000;
const unsigned long WARMUPTIME_SDS_MS = 15000;
const unsigned long READINGTIME_SDS_MS = 5000;
const unsigned long SAMPLETIME_GPS_MS = 50;
const unsigned long DISPLAY_UPDATE_INTERVAL_MS = 5000;
const unsigned long ONE_DAY_IN_MS = 24 * 60 * 60 * 1000;
extern unsigned long PAUSE_BETWEEN_UPDATE_ATTEMPTS_MS; // interval for check for firmware update
const unsigned long DURATION_BEFORE_FORCED_RESTART_MS = ONE_DAY_IN_MS * 28; // force a reboot every ~4 weeks
#define SDS_SERIAL_BUFF_SIZE 36
typedef struct memory_stat_t {
uint32_t freeHeap;
uint16_t maxFreeBlock;
uint8_t frag;
uint32_t freeContStack;
} memory_stat_t;
extern String tmpl(const String& patt, const String& value1, const String& value2, const String& value3);
extern String tmpl(const String& patt, const String& value1, const String& value2);
extern String tmpl(const String& patt, const String& value);
#define UPDATE_CHANNEL_ALFA 0
#define UPDATE_CHANNEL_BETA 1
#define UPDATE_CHANNEL_STABLE 2
#define HOST_MADAVI "api-rrd.madavi.de"
#define URL_MADAVI "/data.php"
#define PORT_MADAVI 80
#define HOST_DUSTI "api.sensor.community"
#define URL_DUSTI "/v1/push-sensor-data/"
#define PORT_DUSTI 80
#define HOST_SENSEMAP "ingress.opensensemap.org"
#define URL_SENSEMAP "/boxes/BOXID/data?luftdaten=1"
#define PORT_SENSEMAP 443
#define HOST_FSAPP "www.h2801469.stratoserver.net"
#define URL_FSAPP "/data.php"
#define PORT_FSAPP 80
#define UPDATE_HOST F("fw.nettigo.pl")
#define UPDATE_URL F("/NAMF/index.php")
#define UPDATE_HOST_ALFA F("alfa.fw.nettigo.pl")
#define UPDATE_URL_ALFA F("/NAMF/index.php")
#define UPDATE_HOST_BETA F("beta.fw.nettigo.pl")
#define UPDATE_URL_BETA F("/NAMF/index.php")
#define UPDATE_PORT 80
#define JSON_BUFFER_SIZE 2600
#define msSince(timestamp_before) (act_milli - (timestamp_before))
#endif //NAMF_DEFINES_H
| 2,222
|
C++
|
.h
| 53
| 40.301887
| 109
| 0.700093
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,462
|
commons.h
|
nettigo_namf/src/display/commons.h
|
//
// Created by viciu on 16.04.2020.
//
#ifndef NAMF_DISPLAY_COMMONS_H
#define NAMF_DISPLAY_COMMONS_H
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
#include "variables.h"
#include "system/components.h"
#include "defines.h"
#include "helpers.h"
#include "html-content.h"
//extern unsigned long next_display_millis ;
//extern unsigned long next_display_count ;
//extern unsigned static_screen_count;
void display_values();
String check_display_value(double value, double undef, uint8_t len, uint8_t str_len);
//get LCD screen sizes. returns 0 if no LCD or graphical one (SSD1306)
byte getLCDCols();
byte getLCDRows();
//returns "x/y" where x is current screen being displayed and y total count
String getLCDHeader(bool longDisp = true);
//should we display? Should we draw new screen?
void cycleDisplay();
#endif //NAMF_DISPLAY_COMMONS_H
| 846
|
C++
|
.h
| 25
| 32.72
| 85
| 0.776284
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,463
|
ledbar.h
|
nettigo_namf/src/display/ledbar.h
|
//
// Created by irukard on 09.03.2020.
//
#ifndef NAMF_LEDBAR_H
#define NAMF_LEDBAR_H
#include <Arduino.h>
#include "variables.h"
#include "defines.h"
#include "helpers.h"
#include "html-content.h"
#include "sensors/sds011/sds011.h"
void displayLEDBar();
void lightLED(byte mode, byte cnt, byte red, byte green, byte blue);
#endif //NAMF_LEDBAR_H
| 349
|
C++
|
.h
| 14
| 23.857143
| 68
| 0.754491
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,465
|
sht3x.h
|
nettigo_namf/src/sensors/sht3x/sht3x.h
|
//
// Created by viciu on 04.09.2020.
//
#ifndef NAMF_SHT3X_H
#define NAMF_SHT3X_H
#include <Arduino.h>
#include <ArduinoJson.h>
#include "sending.h"
#include "system/scheduler.h"
#include "system/components.h"
namespace SHT3x {
extern const char KEY[] PROGMEM;
extern String getConfigHTML();
extern JsonObject &parseHTTPRequest(void);
extern String getConfigJSON(void);
extern void readConfigJSON(JsonObject &json);
extern unsigned long process (SimpleScheduler::LoopEventType);
//send data to LD API...
extern void sendToLD();
extern void results (String &s);
extern void resultsAsHTML(String &page_content);
extern void afterSend(bool success);
extern void display(byte, byte, String[]);
bool getDisplaySetting();
void setDefaults();
}
#endif //NAMF_SHT3X_H
| 827
|
C++
|
.h
| 27
| 27.185185
| 66
| 0.731738
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,466
|
tester.h
|
nettigo_namf/src/sensors/network_watchdog/tester.h
|
//
// Created by viciu on 26.06.2020.
//
#ifndef NAMF_TESTER_H
#define NAMF_TESTER_H
#include <Arduino.h>
#include "../../variables.h"
#include "../../defines.h"
#include "../../helpers.h"
#include "../../html-content.h"
#include "../../webserver.h"
#include <ESP8266WiFi.h>
#include "AsyncPing.h"
namespace NetworkWatchdog {
extern const char KEY[] PROGMEM;
extern String getConfigHTML(void);
extern JsonObject & parseHTTPRequest(void);
extern void readConfigJSON (JsonObject & );
unsigned long process (SimpleScheduler::LoopEventType);
String getConfigJSON(void);
void resultsAsHTML(String &page_content);
}
#endif //NAMF_TESTER_H
| 667
|
C++
|
.h
| 23
| 26.521739
| 59
| 0.721003
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,467
|
sensor.h
|
nettigo_namf/src/sensors/sps30/sensor.h
|
//
// Created by viciu on 08.06.2020.
//
#ifndef NAMF_SENSOR_H
#define NAMF_SENSOR_H
#include "variables.h"
#include "system/scheduler.h"
#include "helpers.h"
#include "html-content.h"
#include <sps30.h>
#define SPS_MAX_SERIAL_LEN 32
namespace SPS30 {
extern bool started;
extern const char KEY[] PROGMEM;
extern unsigned long refresh;
extern int16_t ret;
extern uint8_t auto_clean_days;
extern uint32_t auto_clean;
extern struct sps30_measurement sum ;
extern unsigned int measurement_count;
extern char serial[SPS_MAX_SERIAL_LEN];
extern void zeroMeasurementStruct(sps30_measurement &str);
extern void addMeasurementStruct(sps30_measurement &storage, sps30_measurement reading);
extern unsigned long init();
extern unsigned long process(SimpleScheduler::LoopEventType e);
//we will reset average even on API failure
extern void afterSend(bool success);
extern String getConfigHTML(void);
extern JsonObject & parseHTTPRequest(void);
void getStatusReport (String &page_content);
extern String getConfigJSON(void);
extern void readConfigJSON( JsonObject &);
//return JSON with results
extern void results(String &s);
//send data to LD API...
extern void sendToLD();
extern void resultsAsHTML(String &page_content);
//display on LCD
extern void display(byte rows, byte minor, String lines[]);
bool getDisplaySetting();
}
#endif //NAMF_SENSOR_H
| 1,473
|
C++
|
.h
| 42
| 30.952381
| 92
| 0.740113
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,468
|
SerialSDS.h
|
nettigo_namf/src/sensors/sds011/SerialSDS.h
|
//
// Created by viciu on 10.06.2021.
//
#ifndef NAMF_SERIALSDS_H
#define NAMF_SERIALSDS_H
#include <Arduino.h>
#include "helpers.h"
class SerialSDS {
public:
typedef enum {
SER_UNDEF,
SER_HDR,
SER_DATA,
SER_REPLY,
SER_IDLE
} SerialState;
typedef enum {
SDS_REPORTING,
SDS_DATA,
SDS_NEW_DEV_ID,
SDS_SLEEP,
SDS_PERIOD,
SDS_FW_VER,
SDS_UNKNOWN
} ResponseType;
typedef struct {
bool sent;
bool received;
unsigned long lastRequest;
unsigned long lastReply;
byte data[5];
} ReplyInfo;
SerialSDS(Stream &serial) : _serial(serial) {
_currState = SER_UNDEF;
checksumFailed = 0;
packetCount = 0;
for (byte i = 0; i < SDS_UNKNOWN; i++) {
_replies[i].sent = false;
_replies[i].received = false;
_replies[i].lastRequest = 0;
_replies[i].lastReply = 0;
}
}
void process();
unsigned checksumErrCnt() { return checksumFailed; }
unsigned long totalPacketCnt() { return packetCount; }
bool readingAvailable();
bool fetchReading(int &pm10, int &pm25);
ReplyInfo _replies[SDS_UNKNOWN];
//checksum errors rate
float errorRate();
private:
Stream &_serial;
SerialState _currState;
byte _buff[10];
unsigned long checksumFailed;
unsigned long packetCount;
bool checksumValid();
void logReply(ResponseType type);
void storeReply();
ResponseType selectResponse(byte x);
// const char SRT_0 [];
// const char SRT_1 [];
// const char SRT_2 [];
// const char SRT_3 [];
// const char SRT_4 [];
// const char SRT_5 [] PROGMEM = "FW version";
// const char SRT_6 [] PROGMEM = "Unknown";
// const char *SRT_NAMES[] PROGMEM = {SRT_0, SRT_1, SRT_2, SRT_3, SRT_4, SRT_5, SRT_6};
};
#endif //NAMF_SERIALSDS_H
| 1,941
|
C++
|
.h
| 71
| 21.478873
| 90
| 0.601947
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,469
|
sds011.h
|
nettigo_namf/src/sensors/sds011/sds011.h
|
//
// Created by viciu on 13.01.2020.
//
#ifndef NAMF_SENSORS_SDS011
#define NAMF_SENSORS_SDS011
#include "Arduino.h"
#include "variables.h"
#include "helpers.h"
#include "sending.h"
#include "system/debug.h"
#include "html-content.h" //just for sensor name, to be removed later
#include "webserver.h" //HTML functions
//#include "PCF8574.h"
#include "SerialSDS.h"
namespace SDS011 {
extern const char KEY[] PROGMEM;
void readSingleSDSPacket(int *pm10_serial, int *pm25_serial);
extern bool enabled;
extern unsigned readings;
extern SerialSDS channelSDS;
extern unsigned failedReadings;
extern bool hardwareWatchdog;
extern byte hwWtdgCycles; //how many times watchdog took action
extern unsigned long hwWtdgErrors;
/*****************************************************************
* send SDS011 command (start, stop, continuous mode, version *
*****************************************************************/
void setDefaults();
void SDS_rawcmd(const uint8_t cmd_head1, const uint8_t cmd_head2, const uint8_t cmd_head3);
bool SDS_cmd(PmSensorCmd cmd);
bool SDS_checksum_valid(const uint8_t (&data)[8]);
JsonObject &parseHTTPRequest();
bool getDisplaySetting();
bool display(byte rows, byte minor, String lines[]);
String getConfigJSON();
void readConfigJSON(JsonObject &json);
unsigned long process(SimpleScheduler::LoopEventType e);
String getConfigHTML(void);
void resultsAsHTML(String &page_content);
void results(String &res);
void sendToLD();
void getStatusReport(String &);
void afterSend(bool);
/*****************************************************************
* read SDS011 sensor serial and firmware date *
*****************************************************************/
String SDS_version_date();
/*****************************************************************
* read SDS011 sensor values *
*****************************************************************/
void sensorSDS(String &s);
}
#endif //NAMF_SENSORS_SDS011
| 2,149
|
C++
|
.h
| 53
| 36.679245
| 95
| 0.572604
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,470
|
bmpX80.h
|
nettigo_namf/src/sensors/bmpX80/bmpX80.h
|
#ifndef NAMF_SENSORS_BMPX80_H
#define NAMF_SENSORS_BMPX80_H
#include <Arduino.h>
#include "system/scheduler.h"
#include "helpers.h"
#include "ext_def.h"
#include "../../system/debug.h"
#include "html-content.h"
#include "sending.h"
#include <Adafruit_BMP085.h>
#include <Adafruit_BMP280.h>
namespace BMPx80 {
extern const char KEY[] PROGMEM;
JsonObject &parseHTTPRequest();
void readConfigJSON(JsonObject &json);
unsigned long process(SimpleScheduler::LoopEventType e);
String getConfigJSON();
void results(String &);
void resultsAsHTML(String &);
void afterSend(bool status);
void sendToLD();
void setDefaults(void);
String getConfigHTML(void);
void getStatusReport(String &res);
}
#endif //NAMF_SENSORS_BMPX80_H
| 773
|
C++
|
.h
| 26
| 26.461538
| 60
| 0.740489
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,471
|
bme280.h
|
nettigo_namf/src/sensors/bme280/bme280.h
|
#ifndef NAMF_SENSORS_BME280_H
#define NAMF_SENSORS_BME280_H
#include <Arduino.h>
#include "system/scheduler.h"
#include "helpers.h"
#include "ext_def.h"
#include "../../system/debug.h"
#include "html-content.h"
#include "sending.h"
#include <Adafruit_BME280.h>
namespace BME280 {
extern const char KEY[] PROGMEM;
JsonObject &parseHTTPRequest();
void readConfigJSON(JsonObject &json);
unsigned long process(SimpleScheduler::LoopEventType e);
String getConfigJSON();
void results(String &);
void resultsAsHTML(String &);
void afterSend(bool status);
void sendToLD();
bool isEnabled();
void setDefaults();
}
#endif //NAMF_SENSORS_BME280_H
| 692
|
C++
|
.h
| 24
| 25.5
| 60
| 0.733232
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,472
|
winsen-mhz.h
|
nettigo_namf/src/sensors/mhz14a/winsen-mhz.h
|
//
// Created by viciu on 22.02.2020.
//
// Winsen MH-Z14A CO2 sensor
#ifndef NAMF_WINSEN_MHZ_H
#define NAMF_WINSEN_MHZ_H
#include <Arduino.h>
#include <stdbool.h>
#include "variables.h"
#include "helpers.h"
#include "webserver.h"
namespace MHZ14A {
extern const char KEY[] PROGMEM;
extern bool enabled;
extern bool printOnLCD;
typedef enum {
RANGE_2K,
RANGE_10K
} range_t;
JsonObject &parseHTTPRequest();
//send data to LD API...
extern void sendToLD();
void getResults (String &);
void resultsAsHTML (String &);
void readConfigJSON(JsonObject &);
String getConfigJSON(void);
void display(byte cols, byte minor, String lines[]);
bool getDisplaySetting();
unsigned long process(SimpleScheduler::LoopEventType);
bool process_rx(uint8_t b, uint8_t cmd, uint8_t data[]);
int prepare_tx(uint8_t cmd, const uint8_t *data, uint8_t buffer[], int size);
bool exchange_command(SoftwareSerial &, uint8_t cmd, uint8_t data[], unsigned int timeout);
bool set_range(SoftwareSerial &, range_t r);
bool read_temp_co2(SoftwareSerial &, unsigned int *co2, unsigned int *temp);
void setupWinsenMHZ(SoftwareSerial &);
void readWinsenMHZ(SoftwareSerial &);
void afterSend(bool);
String sensorMHZ();
}
#endif //NAMF_WINSEN_MHZ_H
| 1,341
|
C++
|
.h
| 40
| 29.2
| 95
| 0.704688
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,473
|
heca.h
|
nettigo_namf/src/sensors/heca/heca.h
|
//
// Created by viciu on 10.05.2021.
//
#ifndef NAMF_HECA_H
#define NAMF_HECA_H
#include "Arduino.h"
#include "ClosedCube_SHT31D.h" // support for Nettigo Air Monitor HECA
#include "variables.h"
#include "defines.h"
#include "helpers.h"
#include "webserver.h"
#include "html-content.h" //for sensor name, to remove after move to new scheduler
#include "system/debug.h"
namespace HECA {
extern const char KEY[] PROGMEM;
extern bool enabled;
String sensorHECA();
bool initHECA();
extern ClosedCube_SHT31D heca;
JsonObject& parseHTTPRequest();
String getConfigJSON();
void readConfigJSON( JsonObject &json);
unsigned long process(SimpleScheduler::LoopEventType e);
void afterSend(bool);
void getResults(String &);
String getConfigHTML(void);
void resultsAsHTML(String &);
void getStatusReport(String &);
bool getDisplaySetting();
bool display(byte rows, byte minor, String lines[]);
float getDutyCycle();
void setDefaults(void);
}
#endif //NAMF_HECA_H
| 1,030
|
C++
|
.h
| 34
| 27
| 84
| 0.729293
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,474
|
intl_en.h
|
nettigo_namf/src/lang/intl_en.h
|
/*
*** THIS IS AUTOGENERATED FILE DO NOT EDIT IT ****
(c) Nettigo 2020
Language translation file for Nettigo Air Monitor
For changes in translations do them in corresponding .lang file. File with translations has format:
KEY[SPACE]translation string
So entry in file:
INTL_DS18B20 Sensor DS18B20 ({t})
Will become
const char INTL_DS18B20[] PROGMEM = "Sensor DS18B20 ({t})";
in this file.
Generator will add path to source from which given line was generated. Generator is run by Platformio during build process.
Files with .lang extension are searched in following directories and it's subdirectories:
./src/lang/
./src/sensors/
./src/system/
*/
#ifndef LANG_DEF_en_H
#define LANG_DEF_en_H
/* ./src/lang/intl_en.lang */ const char INTL_ADVANCED_BUTTON[] PROGMEM = "Advanced options show/hide";
/* ./src/lang/intl_en.lang */ const char INTL_ADVANCED_DISCL[] PROGMEM = "Changes in settings in this section can result in sensor not working properly. Make sure You know what You are changing here or leave defaults.";
/* ./src/lang/intl_en.lang */ const char INTL_ALTITUDE[] PROGMEM = "Altitude";
/* ./src/lang/intl_en.lang */ const char INTL_AQI_ECO_API[] PROGMEM = "API aqi.eco";
/* ./src/lang/intl_en.lang */ const char INTL_AQI_TOKEN[] PROGMEM = "Sensor token from aqi.eco";
/* ./src/lang/intl_en.lang */ const char INTL_AUTO_UPDATE[] PROGMEM = "Auto update firmware, using channel";
/* ./src/lang/intl_en.lang */ const char INTL_BACK_TO_HOME[] PROGMEM = "Back to home page";
/* ./src/lang/intl_en.lang */ const char INTL_BASICAUTH[] PROGMEM = "Authorization";
/* ./src/lang/intl_en.lang */ const char INTL_BME280[] PROGMEM = "BME280 ({t}, {h}, {p})";
/* ./src/sensors/bme280/bme280_en.lang */ const char INTL_BME280_DESC[] PROGMEM = "BME280 humidity/temperature/pressure sensor";
/* ./src/lang/intl_en.lang */ const char INTL_BMP280[] PROGMEM = "BMP280/BMP180 ({t}, {p})";
/* ./src/sensors/bmpX80/bmpX80_en.lang */ const char INTL_BMPx80_DESC[] PROGMEM = "BMP180/280 pressure/temperature sensor";
/* ./src/sensors/bmpX80/bmpX80_en.lang */ const char INTL_BMPx80_INSIDE[] PROGMEM = "Sensor inside case (do not use temperature reading)";
/* ./src/lang/intl_en.lang */ const char INTL_CANCEL[] PROGMEM = "Cancel";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIGURATION[] PROGMEM = "Configuration";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIGURATION_DELETE[] PROGMEM = "Configuration delete";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIGURATION_REALLY_DELETE[] PROGMEM = "Are you sure you want to delete the configuration?";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIG_CAN_NOT_BE_DELETED[] PROGMEM = "Configuration can not be deleted";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIG_DELETED[] PROGMEM = "Configuration is deleted";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIG_NOT_FOUND[] PROGMEM = "Configuration not found";
/* ./src/lang/intl_en.lang */ const char INTL_CONFIG_SAVED[] PROGMEM = "Configuration saved.";
/* ./src/lang/intl_en.lang */ const char INTL_CURRENT_DATA[] PROGMEM = "Current data";
/* ./src/lang/intl_en.lang */ const char INTL_DATE[] PROGMEM = "Date";
/* ./src/lang/intl_en.lang */ const char INTL_DEBUG[] PROGMEM = "Logging settings";
/* ./src/lang/intl_en.lang */ const char INTL_DEBUG_LEVEL[] PROGMEM = "Debug Level";
/* ./src/lang/intl_en.lang */ const char INTL_DEBUG_SETTING_TO[] PROGMEM = "Debug setting to";
/* ./src/lang/intl_en.lang */ const char INTL_DEBUG_STATUS[] PROGMEM = "Current logging level:";
/* ./src/lang/intl_en.lang */ const char INTL_DELETE[] PROGMEM = "Delete";
/* ./src/lang/intl_en.lang */ const char INTL_DELETE_CONFIG[] PROGMEM = "delete saved configuration";
/* ./src/lang/intl_en.lang */ const char INTL_DHT22[] PROGMEM = "DHT22 ({t}, {h})";
/* ./src/lang/intl_en.lang */ const char INTL_DIAGNOSTIC[] PROGMEM = "Send diagnostic data to Nettigo";
/* ./src/lang/intl_en.lang */ const char INTL_DISPLAY[] PROGMEM = "OLED SSD1306";
/* ./src/system/system_en.lang */ const char INTL_DISPLAY_NEW[] PROGMEM = "Display on LCD";
/* ./src/lang/intl_en.lang */ const char INTL_DS18B20[] PROGMEM = "DS18B20 ({t})";
/* ./src/lang/intl_en.lang */ const char INTL_DURATION_ROUTER_MODE[] PROGMEM = "Duration router mode";
/* ./src/system/system_en.lang */ const char INTL_ENABLE[] PROGMEM = "Enable";
/* ./src/lang/intl_en.lang */ const char INTL_ENABLE_OTA[] PROGMEM = "Enable OTA";
/* ./src/lang/intl_en.lang */ const char INTL_ENABLE_OTA_INFO[] PROGMEM = "OTA enabled for 60 seconds.";
/* ./src/lang/intl_en.lang */ const char INTL_ENABLE_OTA_REFUSE[] PROGMEM = "Enable authorization in config panel in order to allow code upload";
/* ./src/lang/intl_en.lang */ const char INTL_ERROR[] PROGMEM = "only errors";
/* ./src/lang/intl_en.lang */ const char INTL_FALBACK_WIFI[] PROGMEM = "Fallback WiFi";
/* ./src/lang/intl_en.lang */ const char INTL_FIRMWARE[] PROGMEM = "Firmware version";
/* ./src/lang/intl_en.lang */ const char INTL_FS_WIFI[] PROGMEM = "WiFi Sensor";
/* ./src/lang/intl_en.lang */ const char INTL_FS_WIFI_DESCRIPTION[] PROGMEM = "WiFi Sensor in configuration mode";
/* ./src/lang/intl_en.lang */ const char INTL_FS_WIFI_NAME[] PROGMEM = "Name";
/* ./src/lang/intl_en.lang */ const char INTL_HECA[] PROGMEM = "HECA (SHT30) ({t}, {h})";
/* ./src/sensors/heca/heca_en.lang */ const char INTL_HECA_CLEAR_RH[] PROGMEM = "Heating stop RH level";
/* ./src/sensors/heca/heca_en.lang */ const char INTL_HECA_DC[] PROGMEM = "Duty cycle";
/* ./src/sensors/heca/heca_en.lang */ const char INTL_HECA_DESC[] PROGMEM = "HECA (SHT30) (temperature, humidity), keeps RH under 70%";
/* ./src/sensors/heca/heca_en.lang */ const char INTL_HECA_SET_RH[] PROGMEM = "Heating enable RH level";
/* ./src/lang/intl_en.lang */ const char INTL_HOME[] PROGMEM = "Home";
/* ./src/lang/intl_en.lang */ const char INTL_HUMIDITY[] PROGMEM = "humidity";
/* ./src/lang/intl_en.lang */ const char INTL_I2C_BUS[] PROGMEM = "On I2C bus";
/* ./src/lang/intl_en.lang */ const char INTL_LANG[] PROGMEM = "EN";
/* ./src/lang/intl_en.lang */ const char INTL_LANGUAGE[] PROGMEM = "Language";
/* ./src/lang/intl_en.lang */ const char INTL_LATITUDE[] PROGMEM = "Latitude";
/* ./src/lang/intl_en.lang */ const char INTL_LCD[] PROGMEM = "Has character LCD";
/* ./src/lang/intl_en.lang */ const char INTL_LCD1602_27[] PROGMEM = "LCD 1602 (I2C: 0x27)";
/* ./src/lang/intl_en.lang */ const char INTL_LCD1602_3F[] PROGMEM = "LCD 1602 (I2C: 0x3F)";
/* ./src/lang/intl_en.lang */ const char INTL_LCD2004_27[] PROGMEM = "LCD 2004 (I2C: 0x27)";
/* ./src/lang/intl_en.lang */ const char INTL_LCD2004_3F[] PROGMEM = "LCD 2004 (I2C: 0x3F)";
/* ./src/lang/intl_en.lang */ const char INTL_LEDBAR_32[] PROGMEM = "RGB LED BAR (I2C: 0x32)";
/* ./src/lang/intl_en.lang */ const char INTL_LONGITUDE[] PROGMEM = "Longitude";
/* ./src/lang/intl_en.lang */ const char INTL_MADAVI_LINK[] PROGMEM = "Sensor graphs on Madavi";
/* ./src/lang/intl_en.lang */ const char INTL_MAX_INFO[] PROGMEM = "max. info";
/* ./src/lang/intl_en.lang */ const char INTL_MEASUREMENT_INTERVAL[] PROGMEM = "Measuring interval";
/* ./src/lang/intl_en.lang */ const char INTL_MED_INFO[] PROGMEM = "mid. info";
/* ./src/lang/intl_en.lang */ const char INTL_MHZ14A[] PROGMEM = "Winsen MH-Z14A CO2 Sensor";
/* ./src/sensors/mhz14a/mhz14a_en.lang */ const char INTL_MHZ14A_DESC[] PROGMEM = "Winsen MHZ14A - CO2 sensor";
/* ./src/lang/intl_en.lang */ const char INTL_MHZ14A_VAL[] PROGMEM = "WINSEN";
/* ./src/lang/intl_en.lang */ const char INTL_MIN_INFO[] PROGMEM = "min. info";
/* ./src/lang/intl_en.lang */ const char INTL_MORE_APIS[] PROGMEM = "More APIs";
/* ./src/lang/intl_en.lang */ const char INTL_MORE_SETTINGS[] PROGMEM = "More settings";
/* ./src/lang/intl_en.lang */ const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
/* ./src/lang/intl_en.lang */ const char INTL_NETWORKS_FOUND[] PROGMEM = "Found Networks:";
/* ./src/lang/intl_en.lang */ const char INTL_NONE[] PROGMEM = "off";
/* ./src/lang/intl_en.lang */ const char INTL_NO_NETWORKS[] PROGMEM = "No WiFi Network Found";
/* ./src/lang/intl_en.lang */ const char INTL_NTP_TIME[] PROGMEM = "Time from NTP";
/* ./src/lang/intl_en.lang */ const char INTL_NTP_TIME_NOT_ACC[] PROGMEM = "Not set";
/* ./src/sensors/network_watchdog/ntw_wtd_en.lang */ const char INTL_NTW_WTD_DESC[] PROGMEM = "Network watchdog - restart sensor in case lack of connectivity";
/* ./src/sensors/network_watchdog/ntw_wtd_en.lang */ const char INTL_NTW_WTD_ERROR[] PROGMEM = "This is not proper IP";
/* ./src/sensors/network_watchdog/ntw_wtd_en.lang */ const char INTL_NTW_WTD_HOST[] PROGMEM = "Address to ping (IP)";
/* ./src/lang/intl_en.lang */ const char INTL_NUMBER_OF_MEASUREMENTS[] PROGMEM = "Number of measurements:";
/* ./src/lang/intl_en.lang */ const char INTL_OTHER_APIS[] PROGMEM = "Other API";
/* ./src/lang/intl_en.lang */ const char INTL_PARAMETER[] PROGMEM = "Parameter";
/* ./src/lang/intl_en.lang */ const char INTL_PARTICLES_PER_LITER[] PROGMEM = "particles/liter";
/* ./src/lang/intl_en.lang */ const char INTL_PARTICULATE_MATTER[] PROGMEM = "particulate matter";
/* ./src/lang/intl_en.lang */ const char INTL_PASSWORD[] PROGMEM = "Password";
/* ./src/lang/intl_en.lang */ const char INTL_PATH[] PROGMEM = "Path";
/* ./src/lang/intl_en.lang */ const char INTL_PMS[] PROGMEM = "Plantower PMS(1,3,5,6,7)003 ({pm})";
/* ./src/lang/intl_en.lang */ const char INTL_PM_SENSOR[] PROGMEM = "Particulate matter sensor";
/* ./src/lang/intl_en.lang */ const char INTL_PORT[] PROGMEM = "Port";
/* ./src/lang/intl_en.lang */ const char INTL_PRESSURE[] PROGMEM = "air pressure";
/* ./src/lang/intl_en.lang */ const char INTL_READ_FROM[] PROGMEM = "Read from {v}";
/* ./src/lang/intl_en.lang */ const char INTL_REALLY_RESTART_SENSOR[] PROGMEM = "Are you sure you want to restart the sensor?";
/* ./src/lang/intl_en.lang */ const char INTL_RESTART[] PROGMEM = "Restart";
/* ./src/lang/intl_en.lang */ const char INTL_RESTART_DEVICE[] PROGMEM = "Restart device";
/* ./src/lang/intl_en.lang */ const char INTL_RESTART_SENSOR[] PROGMEM = "Restart sensor";
/* ./src/lang/intl_en.lang */ const char INTL_SAVE[] PROGMEM = "Save";
/* ./src/lang/intl_en.lang */ const char INTL_SAVE_AND_RESTART[] PROGMEM = "Save and restart";
/* ./src/lang/intl_en.lang */ const char INTL_SDS011[] PROGMEM = "SDS011 ({pm})";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_DESC[] PROGMEM = "SDS011 - PM2.5/PM10 sensor";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_FAILED_READINGS[] PROGMEM = "Readings failed/total (counter reset with update check)";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_HWR[] PROGMEM = "Hardware SDS restarter";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_LCD_HDR[] PROGMEM = "SDS011 readings:";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_READTIME[] PROGMEM = "Measurement time (ms)";
/* ./src/sensors/sds011/sds011_en.lang */ const char INTL_SDS011_WARMUP[] PROGMEM = "Warmup time before measurement (ms)";
/* ./src/lang/intl_en.lang */ const char INTL_SEND_TO[] PROGMEM = "Send to {v}";
/* ./src/lang/intl_en.lang */ const char INTL_SEND_TO_OWN_API[] PROGMEM = "own API";
/* ./src/lang/intl_en.lang */ const char INTL_SENSOR[] PROGMEM = "Sensor";
/* ./src/lang/intl_en.lang */ const char INTL_SENSORS[] PROGMEM = "Sensors";
/* ./src/lang/intl_en.lang */ const char INTL_SENSOR_IS_REBOOTING[] PROGMEM = "Sensor is rebooting.";
/* ./src/lang/intl_en.lang */ const char INTL_SENSOR_IS_REBOOTING_NOW[] PROGMEM = "Sensor is being rebooted. Wait few seconds and click button below";
/* ./src/lang/intl_en.lang */ const char INTL_SERVER[] PROGMEM = "Server";
/* ./src/lang/intl_en.lang */ const char INTL_SHOW_DEVICE_INFO[] PROGMEM = "Display device info on LCD";
/* ./src/lang/intl_en.lang */ const char INTL_SHOW_WIFI_INFO[] PROGMEM = "Display WiFi connection info on LCD";
/* ./src/sensors/sht3x/sht3x_en.lang */ const char INTL_SHT3X_DESC[] PROGMEM = "SHT3x - temperature and humidity sensor";
/* ./src/sensors/sht3x/sht3x_en.lang */ const char INTL_SHT3X_RESULTS[] PROGMEM = "Humidity and temperature";
/* ./src/sensors/sht3x/sht3x_en.lang */ const char INTL_SHT3x_HUM[] PROGMEM = "Relative humidity";
/* ./src/sensors/sht3x/sht3x_en.lang */ const char INTL_SHT3x_TEMP[] PROGMEM = "Temperature";
/* ./src/lang/intl_en.lang */ const char INTL_SIGNAL_QUALITY[] PROGMEM = "signal quality";
/* ./src/lang/intl_en.lang */ const char INTL_SIGNAL_STRENGTH[] PROGMEM = "signal strength";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_CONCENTRATION[] PROGMEM = "pcs/cm³";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_CONCENTRATIONS[] PROGMEM = "Particle matter concentration";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_COUNTS[] PROGMEM = "Particle matter counts";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_FW_FAIL[] PROGMEM = "Reading failed";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_NOT_STARTED[] PROGMEM = "Not started";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_NO_RESULT[] PROGMEM = "no results";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_REFRESH[] PROGMEM = "Pause between saving measurements";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_SENSOR_DESC[] PROGMEM = "Sensirion SPS30 - high precision particle matter sensor";
/* ./src/sensors/sps30/sps30_en.lang */ const char INTL_SPS30_SIZE[] PROGMEM = "µm";
/* ./src/lang/intl_en.lang */ const char INTL_STATUS_PAGE[] PROGMEM = "Sensor status";
/* ./src/lang/intl_en.lang */ const char INTL_TAB_ADVANCED[] PROGMEM = "Advanced";
/* ./src/lang/intl_en.lang */ const char INTL_TAB_API[] PROGMEM = "API";
/* ./src/lang/intl_en.lang */ const char INTL_TAB_BASIC[] PROGMEM = "Basic";
/* ./src/lang/intl_en.lang */ const char INTL_TAB_SENSORS[] PROGMEM = "Sensors";
/* ./src/lang/intl_en.lang */ const char INTL_TEMPERATURE[] PROGMEM = "temperature";
/* ./src/lang/intl_en.lang */ const char INTL_TIME[] PROGMEM = "Time";
/* ./src/lang/intl_en.lang */ const char INTL_TIME_FROM_UPDATE[] PROGMEM = "Time from last update attempt";
/* ./src/lang/intl_en.lang */ const char INTL_TIME_SINCE_LAST_MEASUREMENT[] PROGMEM = " seconds since last measurement.";
/* ./src/lang/intl_en.lang */ const char INTL_TIME_TO_MEASUREMENT[] PROGMEM = "Still {v} seconds until measurement";
/* ./src/lang/intl_en.lang */ const char INTL_UPDATE_ALFA[] PROGMEM = "alfa (experimental fw, do not use unless You can recover sensor)";
/* ./src/lang/intl_en.lang */ const char INTL_UPDATE_BETA[] PROGMEM = "beta (stability testing for new features)";
/* ./src/lang/intl_en.lang */ const char INTL_UPDATE_STABLE[] PROGMEM = "stable (use if in doubt)";
/* ./src/lang/intl_en.lang */ const char INTL_USER[] PROGMEM = "User";
/* ./src/lang/intl_en.lang */ const char INTL_USE_HTTPS[] PROGMEM = "Use encrypted connection (HTTPS)";
/* ./src/lang/intl_en.lang */ const char INTL_VALUE[] PROGMEM = "Value";
/* ./src/lang/intl_en.lang */ const char INTL_WARNING[] PROGMEM = "warnings";
/* ./src/lang/intl_en.lang */ const char INTL_WIFI_NETWORKS[] PROGMEM = "Loading wifi networks ...";
/* ./src/lang/intl_en.lang */ const char INTL_WIFI_PHY_MODE[] PROGMEM = "WiFi Phy Mode (1=B / 2=G / 3=N)";
/* ./src/lang/intl_en.lang */ const char INTL_WIFI_SETTINGS[] PROGMEM = "WiFi Settings";
/* ./src/lang/intl_en.lang */ const char INTL_WIFI_TX_PWR[] PROGMEM = "TX power 0-20.5(dBm)";
/* ./src/lang/intl_en.lang */ const char LUFTDATEN_INFO_LOGO_SVG[] PROGMEM = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120px\" height=\"90px\" version=\"1.0\" style=\"shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd\" viewBox=\"0 0 120 90\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"NAM Logo\"><path fill=\"#fff\" d=\"M50 27c0,1 -1,2 -2,2 -1,0 -2,-1 -2,-2 0,-8 6,-14 14,-14 7,0 13,6 13,14 0,7 -6,13 -13,13l-32 0c-12,0 -21,10 -21,21 0,14 13,23 26,20 2,-1 3,-1 5,-2 1,-1 2,0 3,1 1,1 0,2 -1,3 -10,6 -22,4 -30,-4 -10,-10 -10,-26 0,-36 4,-4 11,-7 18,-7l32 0c8,0 12,-10 6,-16 -6,-6 -16,-1 -16,7zm5 52c0,0 -1,0 -1,0l0 0 -1 -2 -3 0c0,1 0,2 0,2 -1,0 -1,0 -2,0 0,0 0,0 0,0l3 -8c0,0 0,0 0,0l0 0c1,0 2,0 2,0l3 8c0,0 0,0 -1,0l0 0zm6 -13c0,0 0,-8 0,-10 0,-2 1,-2 1,-2l6 0 0 2 -4 0 0 3 4 0 0 2 -4 0 0 3 4 0 0 2 -7 0zm11 0l0 -10 -4 0c0,0 0,-2 2,-2l17 0 0 2 -3 0 0 10 -3 0 0 -10c-2,0 -4,0 -6,0l0 10 -3 0zm16 0c0,0 0,-8 0,-10 0,-2 3,-2 3,-2l0 12 -3 0zm22 -12c2,0 3,0 5,1 1,2 2,3 2,5 0,2 -1,4 -2,5 -2,1 -3,2 -5,2 -1,0 -3,-1 -4,-2 -2,-1 -2,-3 -2,-5 0,-2 0,-3 2,-5 1,-1 3,-1 4,-1zm0 2c-1,0 -1,0 -2,1 -1,1 -1,2 -1,3 0,2 0,3 1,3 0,1 1,2 2,2 1,0 2,-1 3,-2 0,-1 1,-2 1,-3 0,-1 -1,-2 -1,-3 -1,-1 -2,-1 -3,-1zm-62 10c0,0 0,-8 0,-10 0,-2 2,-2 2,-2l7 8c0,0 0,-4 0,-6 0,-2 2,-2 2,-2l0 12 -2 0 -7 -8 0 6 0 2 -2 0 0 0zm55 -6c0,0 -3,0 -3,0 -2,0 -2,2 -2,2l3 0c0,2 0,2 0,2 -1,0 -1,1 -2,1 -1,0 -2,-1 -3,-2 -1,0 -1,-2 -1,-3 0,-1 0,-2 1,-3 1,-1 2,-1 3,-1 1,0 2,0 3,0l1 -1c-2,-1 -3,-1 -4,-1 -1,0 -2,0 -3,0 -1,1 -2,1 -3,2 -1,1 -1,3 -1,4 0,1 0,2 0,3 1,1 1,2 2,2 2,1 3,2 5,2 1,0 3,-1 4,-1l0 -6 0 0zm-52 16l2 0 -1 -2 -1 2zm6 3c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm4 -3l0 3c0,0 -1,0 -1,0 -1,0 -1,0 -1,0l0 -8c0,0 0,0 1,0 1,0 2,0 3,0 1,0 1,1 2,1l0 0c0,2 0,3 -2,4l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm11 1l3 -5c0,0 0,0 0,0l0 0c0,0 0,0 0,0l0 0 1 0c0,0 0,0 0,0l0 8c0,0 0,0 -1,0 0,0 0,0 0,0l0 -4 -2 3c0,0 -1,0 -2,0l-1 -3 0 4c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0 0,0 1,0 1,0l2 5zm13 -1c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm4 -4c0,0 0,0 0,0l4 5 0 -5c0,0 1,0 1,0 0,0 1,0 1,0l0 8c0,1 -1,0 -2,0l0 0 0 0 -3 -5 0 5c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0zm8 8c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm8 -8c0,2 0,2 -3,2l0 6c0,0 0,0 -1,0 0,0 -1,0 -1,0l0 -6c-2,0 -2,0 -2,-2 0,0 0,0 1,0l5 0c1,0 1,0 1,0zm7 4c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm5 1l0 3c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 0,0 1,0 3,0 4,0 2,1 2,4 0,5l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm-85 -18c-3,0 -6,2 -7,4 1,2 4,4 7,4 3,0 5,-2 7,-4 -2,-2 -4,-4 -7,-4zm0 2c1,0 2,1 2,2 0,1 -1,2 -2,2 -2,0 -3,-1 -3,-2 0,-1 1,-2 3,-2zm22 -48c-1,0 -2,0 -3,-1 0,-1 0,-2 1,-3 9,-5 20,-4 28,4 9,8 9,23 0,32 -4,4 -10,7 -16,7l-32 0c-7,0 -12,5 -12,11 0,6 5,11 12,11 7,0 13,-7 11,-14 -1,-1 0,-2 1,-3 2,0 3,1 3,2 3,10 -5,20 -15,20 -9,0 -16,-7 -16,-16 0,-9 7,-16 16,-16l32 0c10,0 18,-8 18,-18 0,-12 -12,-21 -23,-18 -2,0 -3,1 -5,2z\"/></g></svg>";
/* ./src/sensors/sht3x/sht3x_en.lang */ const char SENSOR_SHT3[] PROGMEM = "SHT3x";
#endif
| 18,719
|
C++
|
.h
| 174
| 106.471264
| 3,225
| 0.668538
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,475
|
intl_pl.h
|
nettigo_namf/src/lang/intl_pl.h
|
/*
*** THIS IS AUTOGENERATED FILE DO NOT EDIT IT ****
(c) Nettigo 2020
Language translation file for Nettigo Air Monitor
For changes in translations do them in corresponding .lang file. File with translations has format:
KEY[SPACE]translation string
So entry in file:
INTL_DS18B20 Sensor DS18B20 ({t})
Will become
const char INTL_DS18B20[] PROGMEM = "Sensor DS18B20 ({t})";
in this file.
Generator will add path to source from which given line was generated. Generator is run by Platformio during build process.
Files with .lang extension are searched in following directories and it's subdirectories:
./src/lang/
./src/sensors/
./src/system/
*/
#ifndef LANG_DEF_pl_H
#define LANG_DEF_pl_H
/* ./src/lang/intl_pl.lang */ const char INTL_ADVANCED_BUTTON[] PROGMEM = "Pokaż/ukryj zaawansowane opcje";
/* ./src/lang/intl_pl.lang */ const char INTL_ADVANCED_DISCL[] PROGMEM = "Zmiany w tej sekcji mogą spowodować, że dany sensor może nie działać poprawnie. Edytuj te ustawienia tylko gdy dobrze wiesz co robisz.";
/* ./src/lang/intl_pl.lang */ const char INTL_ALTITUDE[] PROGMEM = "Wysokość";
/* ./src/lang/intl_pl.lang */ const char INTL_AQI_ECO_API[] PROGMEM = "API aqi.eco";
/* ./src/lang/intl_pl.lang */ const char INTL_AQI_TOKEN[] PROGMEM = "Token sensora z aqi.eco";
/* ./src/lang/intl_pl.lang */ const char INTL_AUTO_UPDATE[] PROGMEM = "Aktualizuj firmware automatycznie";
/* ./src/lang/intl_pl.lang */ const char INTL_BACK_TO_HOME[] PROGMEM = "Powrót do strony startowej";
/* ./src/lang/intl_pl.lang */ const char INTL_BASICAUTH[] PROGMEM = "Autoryzacja";
/* ./src/lang/intl_pl.lang */ const char INTL_BME280[] PROGMEM = "BME280 ({t}, {h}, {p})";
/* ./src/sensors/bme280/bme280_pl.lang */ const char INTL_BME280_DESC[] PROGMEM = "BME280 sensor temperatury/ciśnienia/wilgotności.";
/* ./src/lang/intl_pl.lang */ const char INTL_BMP280[] PROGMEM = "BMP280/BMP180 ({t}, {p})";
/* ./src/sensors/bmpX80/bmpX80_pl.lang */ const char INTL_BMPx80_DESC[] PROGMEM = "BMP180/280 sensor temperatury/ciśnienia.";
/* ./src/sensors/bmpX80/bmpX80_pl.lang */ const char INTL_BMPx80_INSIDE[] PROGMEM = "Sensor wewnątrz obudowy (nie uwzględniaj temperatury)";
/* ./src/lang/intl_pl.lang */ const char INTL_CANCEL[] PROGMEM = "Anuluj";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIGURATION[] PROGMEM = "Konfiguracja";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIGURATION_DELETE[] PROGMEM = "Usunięcie konfiguracji";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIGURATION_REALLY_DELETE[] PROGMEM = "Czy na pewno chcesz usunąć konfigurację?";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIG_CAN_NOT_BE_DELETED[] PROGMEM = "Konfiguracja nie może zostać usunięta";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIG_DELETED[] PROGMEM = "Usunięto konfigurację";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIG_NOT_FOUND[] PROGMEM = "Nie znaleziono konfiguracji";
/* ./src/lang/intl_pl.lang */ const char INTL_CONFIG_SAVED[] PROGMEM = "Konfiguracja zapisana.";
/* ./src/lang/intl_pl.lang */ const char INTL_CURRENT_DATA[] PROGMEM = "Obecne wskazania";
/* ./src/lang/intl_pl.lang */ const char INTL_DATE[] PROGMEM = "Data";
/* ./src/lang/intl_pl.lang */ const char INTL_DEBUG[] PROGMEM = "Ustawienia logowania";
/* ./src/lang/intl_pl.lang */ const char INTL_DEBUG_LEVEL[] PROGMEM = "Poziom debugowania";
/* ./src/lang/intl_pl.lang */ const char INTL_DEBUG_SETTING_TO[] PROGMEM = "Ustawiono poziom debugowania na";
/* ./src/lang/intl_pl.lang */ const char INTL_DEBUG_STATUS[] PROGMEM = "Obecny poziom logowania:";
/* ./src/lang/intl_pl.lang */ const char INTL_DELETE[] PROGMEM = "Usuń";
/* ./src/lang/intl_pl.lang */ const char INTL_DELETE_CONFIG[] PROGMEM = "Usuń zapisaną konfigurację";
/* ./src/lang/intl_pl.lang */ const char INTL_DHT22[] PROGMEM = "DHT22 ({t}, {h})";
/* ./src/lang/intl_pl.lang */ const char INTL_DIAGNOSTIC[] PROGMEM = "Wysyłaj dane diagnostyczne do Nettigo";
/* ./src/lang/intl_pl.lang */ const char INTL_DISPLAY[] PROGMEM = "OLED SSD1306";
/* ./src/system/system_pl.lang */ const char INTL_DISPLAY_NEW[] PROGMEM = "Wyświetl dane na LCD";
/* ./src/lang/intl_pl.lang */ const char INTL_DS18B20[] PROGMEM = "DS18B20 ({t})";
/* ./src/lang/intl_pl.lang */ const char INTL_DURATION_ROUTER_MODE[] PROGMEM = "Czas trwania w trybie routera (sek.)";
/* ./src/system/system_pl.lang */ const char INTL_ENABLE[] PROGMEM = "Włącz";
/* ./src/lang/intl_pl.lang */ const char INTL_ENABLE_OTA[] PROGMEM = "Włącz OTA";
/* ./src/lang/intl_pl.lang */ const char INTL_ENABLE_OTA_INFO[] PROGMEM = "OTA włączone na 60 sekund.";
/* ./src/lang/intl_pl.lang */ const char INTL_ENABLE_OTA_REFUSE[] PROGMEM = "Włącz autoryzację w panelu konfiguracyjnym, by móc włączyć zdalne ładowanie kodu";
/* ./src/lang/intl_pl.lang */ const char INTL_ERROR[] PROGMEM = "tylko błędy";
/* ./src/lang/intl_pl.lang */ const char INTL_FALBACK_WIFI[] PROGMEM = "Alternatywna sieć WiFi";
/* ./src/lang/intl_pl.lang */ const char INTL_FIRMWARE[] PROGMEM = "Wersja FW";
/* ./src/lang/intl_pl.lang */ const char INTL_FS_WIFI[] PROGMEM = "Czujnik WiFi";
/* ./src/lang/intl_pl.lang */ const char INTL_FS_WIFI_DESCRIPTION[] PROGMEM = "Parametry WiFi w trybie konfiguracji czujnika";
/* ./src/lang/intl_pl.lang */ const char INTL_FS_WIFI_NAME[] PROGMEM = "Nazwa sieci";
/* ./src/lang/intl_pl.lang */ const char INTL_HECA[] PROGMEM = "HECA (SHT30) ({t}, {h})";
/* ./src/sensors/heca/heca_pl.lang */ const char INTL_HECA_CLEAR_RH[] PROGMEM = "Wartość odcięcia (RH)";
/* ./src/sensors/heca/heca_pl.lang */ const char INTL_HECA_DC[] PROGMEM = "Grzanie";
/* ./src/sensors/heca/heca_pl.lang */ const char INTL_HECA_DESC[] PROGMEM = "HECA (SHT30) (temperatura, wilgotność), utrzymanie wilgotności poniżej 70%";
/* ./src/sensors/heca/heca_pl.lang */ const char INTL_HECA_SET_RH[] PROGMEM = "Wartość włączenia (RH)";
/* ./src/lang/intl_pl.lang */ const char INTL_HOME[] PROGMEM = "Strona startowa";
/* ./src/lang/intl_pl.lang */ const char INTL_HUMIDITY[] PROGMEM = "wilgotność";
/* ./src/lang/intl_pl.lang */ const char INTL_I2C_BUS[] PROGMEM = "Na szynie I2C";
/* ./src/lang/intl_pl.lang */ const char INTL_LANG[] PROGMEM = "PL";
/* ./src/lang/intl_pl.lang */ const char INTL_LANGUAGE[] PROGMEM = "Język";
/* ./src/lang/intl_pl.lang */ const char INTL_LATITUDE[] PROGMEM = "Szerokość geograficzna";
/* ./src/lang/intl_pl.lang */ const char INTL_LCD[] PROGMEM = "Ma wyświetlacz";
/* ./src/lang/intl_pl.lang */ const char INTL_LCD1602_27[] PROGMEM = "LCD 1602 (I2C: 0x27)";
/* ./src/lang/intl_pl.lang */ const char INTL_LCD1602_3F[] PROGMEM = "LCD 1602 (I2C: 0x3F)";
/* ./src/lang/intl_pl.lang */ const char INTL_LCD2004_27[] PROGMEM = "LCD 2004 (I2C: 0x27)";
/* ./src/lang/intl_pl.lang */ const char INTL_LCD2004_3F[] PROGMEM = "LCD 2004 (I2C: 0x3F)";
/* ./src/lang/intl_pl.lang */ const char INTL_LEDBAR_32[] PROGMEM = "Linijka diodowa RGB (I2C: 0x32)";
/* ./src/lang/intl_pl.lang */ const char INTL_LONGITUDE[] PROGMEM = "Długość geograficzna";
/* ./src/lang/intl_pl.lang */ const char INTL_MADAVI_LINK[] PROGMEM = "Wykresy z sensora na Madavi";
/* ./src/lang/intl_pl.lang */ const char INTL_MAX_INFO[] PROGMEM = "maks. info";
/* ./src/lang/intl_pl.lang */ const char INTL_MEASUREMENT_INTERVAL[] PROGMEM = "Czas między pomiarami (sek.)";
/* ./src/lang/intl_pl.lang */ const char INTL_MED_INFO[] PROGMEM = "śr. info";
/* ./src/sensors/mhz14a/mhz14a_pl.lang */ const char INTL_MHZ14A[] PROGMEM = "Winsen MH-Z14A CO2 sensor";
/* ./src/sensors/mhz14a/mhz14a_pl.lang */ const char INTL_MHZ14A_DESC[] PROGMEM = "Winsen MHZ14A - CO2 sensor";
/* ./src/sensors/mhz14a/mhz14a_pl.lang */ const char INTL_MHZ14A_VAL[] PROGMEM = "WINSEN MH-Z14A";
/* ./src/lang/intl_pl.lang */ const char INTL_MIN_INFO[] PROGMEM = "min. info";
/* ./src/lang/intl_pl.lang */ const char INTL_MORE_APIS[] PROGMEM = "Kolejne API";
/* ./src/lang/intl_pl.lang */ const char INTL_MORE_SETTINGS[] PROGMEM = "Więcej ustawień";
/* ./src/lang/intl_pl.lang */ const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
/* ./src/lang/intl_pl.lang */ const char INTL_NETWORKS_FOUND[] PROGMEM = "Znalezione sieci:";
/* ./src/lang/intl_pl.lang */ const char INTL_NONE[] PROGMEM = "wyłączony";
/* ./src/lang/intl_pl.lang */ const char INTL_NO_NETWORKS[] PROGMEM = "Nie znaleziono sieci WiFi";
/* ./src/lang/intl_pl.lang */ const char INTL_NTP_TIME[] PROGMEM = "Czas z NTP";
/* ./src/lang/intl_pl.lang */ const char INTL_NTP_TIME_NOT_ACC[] PROGMEM = "Nie ustawione";
/* ./src/sensors/network_watchdog/ntw_wtd_pl.lang */ const char INTL_NTW_WTD_DESC[] PROGMEM = "Network Watchdog - zrestartuje sensor jeśli nie będzie łączności";
/* ./src/sensors/network_watchdog/ntw_wtd_pl.lang */ const char INTL_NTW_WTD_ERROR[] PROGMEM = "To nie jest poprawny adres IP";
/* ./src/sensors/network_watchdog/ntw_wtd_pl.lang */ const char INTL_NTW_WTD_HOST[] PROGMEM = "IP adres, który pingować (IP)";
/* ./src/lang/intl_pl.lang */ const char INTL_NUMBER_OF_MEASUREMENTS[] PROGMEM = "Liczba pomiarów:";
/* ./src/lang/intl_pl.lang */ const char INTL_OTHER_APIS[] PROGMEM = "Inne API";
/* ./src/lang/intl_pl.lang */ const char INTL_PARAMETER[] PROGMEM = "Parametr";
/* ./src/lang/intl_pl.lang */ const char INTL_PARTICLES_PER_LITER[] PROGMEM = "cząsteczek/litr";
/* ./src/lang/intl_pl.lang */ const char INTL_PARTICULATE_MATTER[] PROGMEM = "pył zawieszony";
/* ./src/lang/intl_pl.lang */ const char INTL_PASSWORD[] PROGMEM = "Hasło";
/* ./src/lang/intl_pl.lang */ const char INTL_PATH[] PROGMEM = "Ścieżka";
/* ./src/lang/intl_pl.lang */ const char INTL_PMS[] PROGMEM = "Plantower PMS(1,3,5,6,7)003 ({pm})";
/* ./src/lang/intl_pl.lang */ const char INTL_PM_SENSOR[] PROGMEM = "Czujnik pyłu zawieszonego";
/* ./src/lang/intl_pl.lang */ const char INTL_PORT[] PROGMEM = "Port";
/* ./src/lang/intl_pl.lang */ const char INTL_PRESSURE[] PROGMEM = "ciśnienie";
/* ./src/lang/intl_pl.lang */ const char INTL_READ_FROM[] PROGMEM = "Czytaj z {v}";
/* ./src/lang/intl_pl.lang */ const char INTL_REALLY_RESTART_SENSOR[] PROGMEM = "Czy na pewno chcesz uruchomić czujnik ponownie?";
/* ./src/lang/intl_pl.lang */ const char INTL_RESTART[] PROGMEM = "Uruchom ponownie";
/* ./src/lang/intl_pl.lang */ const char INTL_RESTART_DEVICE[] PROGMEM = "Uruchom ponownie urządzenie";
/* ./src/lang/intl_pl.lang */ const char INTL_RESTART_SENSOR[] PROGMEM = "Uruchom ponownie czujnik";
/* ./src/lang/intl_pl.lang */ const char INTL_SAVE[] PROGMEM = "Zapisz";
/* ./src/lang/intl_pl.lang */ const char INTL_SAVE_AND_RESTART[] PROGMEM = "Zapisz i zrestartuj";
/* ./src/lang/intl_pl.lang */ const char INTL_SDS011[] PROGMEM = "SDS011 ({pm})";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_DESC[] PROGMEM = "SDS011 - Czujnik PM2.5/PM10";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_FAILED_READINGS[] PROGMEM = "Liczba braków/wszystkich odczytów z SDS (zerowana przy każdej próbie aktualizacji)";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_HWR[] PROGMEM = "Sprzętowy restarter dla SDS011";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_LCD_HDR[] PROGMEM = "SDS011 wartosci:";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_READTIME[] PROGMEM = "Czas, w którym jest dokonywany pomiar (ms)";
/* ./src/sensors/sds011/sds011_pl.lang */ const char INTL_SDS011_WARMUP[] PROGMEM = "Czas pracy przed rozpoczęciem pomiaru (ms)";
/* ./src/lang/intl_pl.lang */ const char INTL_SEND_TO[] PROGMEM = "Wysyłaj dane do: {v}";
/* ./src/lang/intl_pl.lang */ const char INTL_SEND_TO_OWN_API[] PROGMEM = "własne API";
/* ./src/lang/intl_pl.lang */ const char INTL_SENSOR[] PROGMEM = "Czujnik";
/* ./src/lang/intl_pl.lang */ const char INTL_SENSORS[] PROGMEM = "Sensory";
/* ./src/lang/intl_pl.lang */ const char INTL_SENSOR_IS_REBOOTING[] PROGMEM = "Ponowne uruchamianie czujnika.";
/* ./src/lang/intl_pl.lang */ const char INTL_SENSOR_IS_REBOOTING_NOW[] PROGMEM = "Trwa restart urządzenia... Za kilkanaście sekund kliknij przycisk poniżej.";
/* ./src/lang/intl_pl.lang */ const char INTL_SERVER[] PROGMEM = "Adres serwera";
/* ./src/lang/intl_pl.lang */ const char INTL_SHOW_DEVICE_INFO[] PROGMEM = "Pokaż status urządzenia na LCD";
/* ./src/lang/intl_pl.lang */ const char INTL_SHOW_WIFI_INFO[] PROGMEM = "Pokaż status WiFi na LCD";
/* ./src/sensors/sht3x/sht3x_pl.lang */ const char INTL_SHT3X_DESC[] PROGMEM = "SHT3x - czujnik temperatury i wilgotności";
/* ./src/sensors/sht3x/sht3x_pl.lang */ const char INTL_SHT3X_RESULTS[] PROGMEM = "Temperatura i wilgotność";
/* ./src/sensors/sht3x/sht3x_pl.lang */ const char INTL_SHT3x_HUM[] PROGMEM = "Wilgotność wzgl.";
/* ./src/sensors/sht3x/sht3x_pl.lang */ const char INTL_SHT3x_TEMP[] PROGMEM = "Temperatura";
/* ./src/lang/intl_pl.lang */ const char INTL_SIGNAL_QUALITY[] PROGMEM = "jakość sygnału";
/* ./src/lang/intl_pl.lang */ const char INTL_SIGNAL_STRENGTH[] PROGMEM = "siła sygnału";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_CONCENTRATION[] PROGMEM = "szt/cm³";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_CONCENTRATIONS[] PROGMEM = "Stężenie pyłów";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_COUNTS[] PROGMEM = "Liczba cząstek";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_FW_FAIL[] PROGMEM = "Nieudany odczyt";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_NOT_STARTED[] PROGMEM = "Nie działa";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_NO_RESULT[] PROGMEM = "brak rezultatów";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_REFRESH[] PROGMEM = "Odstęp w sek. między pomiarami";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_SENSOR_DESC[] PROGMEM = "Sensirion SPS30 - precyzyjny czujnik pyłów zawieszonych";
/* ./src/sensors/sps30/sps30_pl.lang */ const char INTL_SPS30_SIZE[] PROGMEM = "µm";
/* ./src/lang/intl_pl.lang */ const char INTL_STATUS_PAGE[] PROGMEM = "Status sensora";
/* ./src/lang/intl_pl.lang */ const char INTL_TAB_ADVANCED[] PROGMEM = "Zaawansowane";
/* ./src/lang/intl_pl.lang */ const char INTL_TAB_API[] PROGMEM = "API";
/* ./src/lang/intl_pl.lang */ const char INTL_TAB_BASIC[] PROGMEM = "Podstawy";
/* ./src/lang/intl_pl.lang */ const char INTL_TAB_SENSORS[] PROGMEM = "Sensory";
/* ./src/lang/intl_pl.lang */ const char INTL_TEMPERATURE[] PROGMEM = "temperatura";
/* ./src/lang/intl_pl.lang */ const char INTL_TIME[] PROGMEM = "Czas";
/* ./src/lang/intl_pl.lang */ const char INTL_TIME_FROM_UPDATE[] PROGMEM = "Czas od próby aktualizacji";
/* ./src/lang/intl_pl.lang */ const char INTL_TIME_SINCE_LAST_MEASUREMENT[] PROGMEM = " sekund od ostatniego pomiaru.";
/* ./src/lang/intl_pl.lang */ const char INTL_TIME_TO_MEASUREMENT[] PROGMEM = "Pozostało {v} sekund do pomiaru";
/* ./src/lang/intl_pl.lang */ const char INTL_UPDATE_ALFA[] PROGMEM = "alfa (eksperymentalne firmware)";
/* ./src/lang/intl_pl.lang */ const char INTL_UPDATE_BETA[] PROGMEM = "beta (testowanie stabilności nowych rozwiązań)";
/* ./src/lang/intl_pl.lang */ const char INTL_UPDATE_STABLE[] PROGMEM = "stable (najlepiej przetestowany kod)";
/* ./src/lang/intl_pl.lang */ const char INTL_USER[] PROGMEM = "Nazwa użytkownika";
/* ./src/lang/intl_pl.lang */ const char INTL_USE_HTTPS[] PROGMEM = "Używaj połączenia szyfrowanego (HTTPS)";
/* ./src/lang/intl_pl.lang */ const char INTL_VALUE[] PROGMEM = "Wartość";
/* ./src/lang/intl_pl.lang */ const char INTL_WARNING[] PROGMEM = "ostrzeżenia";
/* ./src/lang/intl_pl.lang */ const char INTL_WIFI_NETWORKS[] PROGMEM = "Ładowanie sieci WiFi...";
/* ./src/lang/intl_pl.lang */ const char INTL_WIFI_PHY_MODE[] PROGMEM = "Tryb pracy WiFi (1=B / 2=G / 3=N)";
/* ./src/lang/intl_pl.lang */ const char INTL_WIFI_SETTINGS[] PROGMEM = "Ustawienia WiFi";
/* ./src/lang/intl_pl.lang */ const char INTL_WIFI_TX_PWR[] PROGMEM = "Moc nadawcza 0-20.5(dBm)";
/* ./src/lang/intl_pl.lang */ const char LUFTDATEN_INFO_LOGO_SVG[] PROGMEM = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120px\" height=\"90px\" version=\"1.0\" style=\"shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd\" viewBox=\"0 0 120 90\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"NAM Logo\"><path fill=\"#fff\" d=\"M50 27c0,1 -1,2 -2,2 -1,0 -2,-1 -2,-2 0,-8 6,-14 14,-14 7,0 13,6 13,14 0,7 -6,13 -13,13l-32 0c-12,0 -21,10 -21,21 0,14 13,23 26,20 2,-1 3,-1 5,-2 1,-1 2,0 3,1 1,1 0,2 -1,3 -10,6 -22,4 -30,-4 -10,-10 -10,-26 0,-36 4,-4 11,-7 18,-7l32 0c8,0 12,-10 6,-16 -6,-6 -16,-1 -16,7zm5 52c0,0 -1,0 -1,0l0 0 -1 -2 -3 0c0,1 0,2 0,2 -1,0 -1,0 -2,0 0,0 0,0 0,0l3 -8c0,0 0,0 0,0l0 0c1,0 2,0 2,0l3 8c0,0 0,0 -1,0l0 0zm6 -13c0,0 0,-8 0,-10 0,-2 1,-2 1,-2l6 0 0 2 -4 0 0 3 4 0 0 2 -4 0 0 3 4 0 0 2 -7 0zm11 0l0 -10 -4 0c0,0 0,-2 2,-2l17 0 0 2 -3 0 0 10 -3 0 0 -10c-2,0 -4,0 -6,0l0 10 -3 0zm16 0c0,0 0,-8 0,-10 0,-2 3,-2 3,-2l0 12 -3 0zm22 -12c2,0 3,0 5,1 1,2 2,3 2,5 0,2 -1,4 -2,5 -2,1 -3,2 -5,2 -1,0 -3,-1 -4,-2 -2,-1 -2,-3 -2,-5 0,-2 0,-3 2,-5 1,-1 3,-1 4,-1zm0 2c-1,0 -1,0 -2,1 -1,1 -1,2 -1,3 0,2 0,3 1,3 0,1 1,2 2,2 1,0 2,-1 3,-2 0,-1 1,-2 1,-3 0,-1 -1,-2 -1,-3 -1,-1 -2,-1 -3,-1zm-62 10c0,0 0,-8 0,-10 0,-2 2,-2 2,-2l7 8c0,0 0,-4 0,-6 0,-2 2,-2 2,-2l0 12 -2 0 -7 -8 0 6 0 2 -2 0 0 0zm55 -6c0,0 -3,0 -3,0 -2,0 -2,2 -2,2l3 0c0,2 0,2 0,2 -1,0 -1,1 -2,1 -1,0 -2,-1 -3,-2 -1,0 -1,-2 -1,-3 0,-1 0,-2 1,-3 1,-1 2,-1 3,-1 1,0 2,0 3,0l1 -1c-2,-1 -3,-1 -4,-1 -1,0 -2,0 -3,0 -1,1 -2,1 -3,2 -1,1 -1,3 -1,4 0,1 0,2 0,3 1,1 1,2 2,2 2,1 3,2 5,2 1,0 3,-1 4,-1l0 -6 0 0zm-52 16l2 0 -1 -2 -1 2zm6 3c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm4 -3l0 3c0,0 -1,0 -1,0 -1,0 -1,0 -1,0l0 -8c0,0 0,0 1,0 1,0 2,0 3,0 1,0 1,1 2,1l0 0c0,2 0,3 -2,4l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm11 1l3 -5c0,0 0,0 0,0l0 0c0,0 0,0 0,0l0 0 1 0c0,0 0,0 0,0l0 8c0,0 0,0 -1,0 0,0 0,0 0,0l0 -4 -2 3c0,0 -1,0 -2,0l-1 -3 0 4c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0 0,0 1,0 1,0l2 5zm13 -1c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm4 -4c0,0 0,0 0,0l4 5 0 -5c0,0 1,0 1,0 0,0 1,0 1,0l0 8c0,1 -1,0 -2,0l0 0 0 0 -3 -5 0 5c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0zm8 8c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm8 -8c0,2 0,2 -3,2l0 6c0,0 0,0 -1,0 0,0 -1,0 -1,0l0 -6c-2,0 -2,0 -2,-2 0,0 0,0 1,0l5 0c1,0 1,0 1,0zm7 4c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm5 1l0 3c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 0,0 1,0 3,0 4,0 2,1 2,4 0,5l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm-85 -18c-3,0 -6,2 -7,4 1,2 4,4 7,4 3,0 5,-2 7,-4 -2,-2 -4,-4 -7,-4zm0 2c1,0 2,1 2,2 0,1 -1,2 -2,2 -2,0 -3,-1 -3,-2 0,-1 1,-2 3,-2zm22 -48c-1,0 -2,0 -3,-1 0,-1 0,-2 1,-3 9,-5 20,-4 28,4 9,8 9,23 0,32 -4,4 -10,7 -16,7l-32 0c-7,0 -12,5 -12,11 0,6 5,11 12,11 7,0 13,-7 11,-14 -1,-1 0,-2 1,-3 2,0 3,1 3,2 3,10 -5,20 -15,20 -9,0 -16,-7 -16,-16 0,-9 7,-16 16,-16l32 0c10,0 18,-8 18,-18 0,-12 -12,-21 -23,-18 -2,0 -3,1 -5,2z\"/></g></svg>";
/* ./src/sensors/sht3x/sht3x_pl.lang */ const char SENSOR_SHT3[] PROGMEM = "SHT3x";
#endif
| 19,205
|
C++
|
.h
| 174
| 108.465517
| 3,225
| 0.673677
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,476
|
intl_ro.h
|
nettigo_namf/src/lang/intl_ro.h
|
/*
*** THIS IS AUTOGENERATED FILE DO NOT EDIT IT ****
(c) Nettigo 2020
Language translation file for Nettigo Air Monitor
For changes in translations do them in corresponding .lang file. File with translations has format:
KEY[SPACE]translation string
So entry in file:
INTL_DS18B20 Sensor DS18B20 ({t})
Will become
const char INTL_DS18B20[] PROGMEM = "Sensor DS18B20 ({t})";
in this file.
Generator will add path to source from which given line was generated. Generator is run by Platformio during build process.
Files with .lang extension are searched in following directories and it's subdirectories:
./src/lang/
./src/sensors/
./src/system/
*/
#ifndef LANG_DEF_ro_H
#define LANG_DEF_ro_H
/* ./src/lang/intl_ro.lang */ const char INTL_ALTITUDE[] PROGMEM = "Altitudine";
/* ./src/lang/intl_ro.lang */ const char INTL_AUTO_UPDATE[] PROGMEM = "Actualizarea automată a firmware-ului, utilizând canalul";
/* ./src/lang/intl_ro.lang */ const char INTL_BACK_TO_HOME[] PROGMEM = "Înapoi la pagina principală";
/* ./src/lang/intl_ro.lang */ const char INTL_BASICAUTH[] PROGMEM = "Autorizare";
/* ./src/lang/intl_ro.lang */ const char INTL_BME280[] PROGMEM = "BME280 ({t}, {h}, {p})";
/* ./src/sensors/bme280/bme280_ro.lang */ const char INTL_BME280_DESC[] PROGMEM = "Senzor de umiditate/temperatură/presiune BME280";
/* ./src/lang/intl_ro.lang */ const char INTL_BMP280[] PROGMEM = "BMP280/BMP180 ({t}, {p})";
/* ./src/sensors/bmpX80/bmpX80_ro.lang */ const char INTL_BMPx80_DESC[] PROGMEM = "Senzor de presiune/temperatura BMP180/280";
/* ./src/sensors/bmpX80/bmpX80_ro.lang */ const char INTL_BMPx80_INSIDE[] PROGMEM = "Senzor în interiorul carcasei (nu utilizați citirea temperaturii)";
/* ./src/lang/intl_ro.lang */ const char INTL_CANCEL[] PROGMEM = "Anulează";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIGURATION[] PROGMEM = "Configura»õie";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIGURATION_DELETE[] PROGMEM = "»òtergerea configura»õiei";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIGURATION_REALLY_DELETE[] PROGMEM = "Sunteți sigur că doriți să ștergeți configurația?";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIG_CAN_NOT_BE_DELETED[] PROGMEM = "Configurația nu poate fi ștearsă";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIG_DELETED[] PROGMEM = "Configurația este ștearsă";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIG_NOT_FOUND[] PROGMEM = "Configurația nu a fost găsită";
/* ./src/lang/intl_ro.lang */ const char INTL_CONFIG_SAVED[] PROGMEM = "Configurație salvată";
/* ./src/lang/intl_ro.lang */ const char INTL_CURRENT_DATA[] PROGMEM = "Date curente";
/* ./src/lang/intl_ro.lang */ const char INTL_DATE[] PROGMEM = "Data";
/* ./src/lang/intl_ro.lang */ const char INTL_DEBUG_LEVEL[] PROGMEM = "Depanare Nivel";
/* ./src/lang/intl_ro.lang */ const char INTL_DEBUG_SETTING_TO[] PROGMEM = "Setarea Debug la";
/* ./src/lang/intl_ro.lang */ const char INTL_DELETE[] PROGMEM = "»òterge»õi";
/* ./src/lang/intl_ro.lang */ const char INTL_DELETE_CONFIG[] PROGMEM = "șterge configurația salvată";
/* ./src/lang/intl_ro.lang */ const char INTL_DHT22[] PROGMEM = "DHT22 ({t}, {h})";
/* ./src/lang/intl_ro.lang */ const char INTL_DIAGNOSTIC[] PROGMEM = "Trimiteți datele de diagnosticare către Nettigo";
/* ./src/lang/intl_ro.lang */ const char INTL_DISPLAY[] PROGMEM = "OLED SSD1306";
/* ./src/system/system_ro.lang */ const char INTL_DISPLAY_NEW[] PROGMEM = "Afi»ôare pe LCD";
/* ./src/lang/intl_ro.lang */ const char INTL_DS18B20[] PROGMEM = "DS18B20 ({t})";
/* ./src/lang/intl_ro.lang */ const char INTL_DURATION_ROUTER_MODE[] PROGMEM = "Durata modului router";
/* ./src/system/system_ro.lang */ const char INTL_ENABLE[] PROGMEM = "Activa»õi";
/* ./src/lang/intl_ro.lang */ const char INTL_ENABLE_OTA[] PROGMEM = "Activează OTA";
/* ./src/lang/intl_ro.lang */ const char INTL_ENABLE_OTA_INFO[] PROGMEM = "OTA activată timp de 60 de secunde.";
/* ./src/lang/intl_ro.lang */ const char INTL_ENABLE_OTA_REFUSE[] PROGMEM = "Activați autorizarea în panoul de configurare pentru a permite încărcarea codului";
/* ./src/lang/intl_ro.lang */ const char INTL_ERROR[] PROGMEM = "numai erori";
/* ./src/lang/intl_ro.lang */ const char INTL_FALBACK_WIFI[] PROGMEM = "Rețea WiFi alternativă";
/* ./src/lang/intl_ro.lang */ const char INTL_FIRMWARE[] PROGMEM = "Versiunea Firmware";
/* ./src/lang/intl_ro.lang */ const char INTL_FS_WIFI[] PROGMEM = "Senzor WiFi";
/* ./src/lang/intl_ro.lang */ const char INTL_FS_WIFI_DESCRIPTION[] PROGMEM = "Senzorul WiFi în modul de configurare";
/* ./src/lang/intl_ro.lang */ const char INTL_FS_WIFI_NAME[] PROGMEM = "Nume";
/* ./src/lang/intl_ro.lang */ const char INTL_HECA[] PROGMEM = "HECA (SHT30) ({t}, {h})";
/* ./src/sensors/heca/heca_ro.lang */ const char INTL_HECA_DC[] PROGMEM = "Ciclul de func»õionare";
/* ./src/sensors/heca/heca_ro.lang */ const char INTL_HECA_DESC[] PROGMEM = "HECA (SHT30) (temperatură, umiditate), menține RH sub 70%.";
/* ./src/lang/intl_ro.lang */ const char INTL_HOME[] PROGMEM = "Acasă";
/* ./src/lang/intl_ro.lang */ const char INTL_HUMIDITY[] PROGMEM = "umiditatea";
/* ./src/lang/intl_ro.lang */ const char INTL_I2C_BUS[] PROGMEM = "Pe magistrala I2C";
/* ./src/lang/intl_ro.lang */ const char INTL_LANG[] PROGMEM = "RO";
/* ./src/lang/intl_ro.lang */ const char INTL_LANGUAGE[] PROGMEM = "Limbă";
/* ./src/lang/intl_ro.lang */ const char INTL_LATITUDE[] PROGMEM = "Latitudine";
/* ./src/lang/intl_ro.lang */ const char INTL_LCD[] PROGMEM = "Dispune de caracter LCD";
/* ./src/lang/intl_ro.lang */ const char INTL_LCD1602_27[] PROGMEM = "LCD 1602 (I2C: 0x27)";
/* ./src/lang/intl_ro.lang */ const char INTL_LCD1602_3F[] PROGMEM = "LCD 1602 (I2C: 0x3F)";
/* ./src/lang/intl_ro.lang */ const char INTL_LCD2004_27[] PROGMEM = "LCD 2004 (I2C: 0x27)";
/* ./src/lang/intl_ro.lang */ const char INTL_LCD2004_3F[] PROGMEM = "LCD 2004 (I2C: 0x3F)";
/* ./src/lang/intl_ro.lang */ const char INTL_LEDBAR_32[] PROGMEM = "RGB LED BAR (I2C: 0x32)";
/* ./src/lang/intl_ro.lang */ const char INTL_LONGITUDE[] PROGMEM = "Longitudine";
/* ./src/lang/intl_ro.lang */ const char INTL_MADAVI_LINK[] PROGMEM = "Graficele senzorilor pe Madavi";
/* ./src/lang/intl_ro.lang */ const char INTL_MAX_INFO[] PROGMEM = "Informa»õii maxime";
/* ./src/lang/intl_ro.lang */ const char INTL_MEASUREMENT_INTERVAL[] PROGMEM = "Interval de măsurare";
/* ./src/lang/intl_ro.lang */ const char INTL_MED_INFO[] PROGMEM = "informa»õii medii";
/* ./src/lang/intl_ro.lang */ const char INTL_MHZ14A[] PROGMEM = "Senzor de CO2 Winsen MH-Z14A";
/* ./src/sensors/mhz14a/mhz14a_ro.lang */ const char INTL_MHZ14A_DESC[] PROGMEM = "Winsen MHZ14A - senzor CO2";
/* ./src/lang/intl_ro.lang */ const char INTL_MHZ14A_VAL[] PROGMEM = "WINSEN";
/* ./src/lang/intl_ro.lang */ const char INTL_MIN_INFO[] PROGMEM = "Informa»õii minime";
/* ./src/lang/intl_ro.lang */ const char INTL_MORE_APIS[] PROGMEM = "Mai multe API-uri";
/* ./src/lang/intl_ro.lang */ const char INTL_MORE_SETTINGS[] PROGMEM = "Mai multe setări";
/* ./src/lang/intl_ro.lang */ const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
/* ./src/lang/intl_ro.lang */ const char INTL_NETWORKS_FOUND[] PROGMEM = "Rețele găsite:";
/* ./src/lang/intl_ro.lang */ const char INTL_NONE[] PROGMEM = "închis";
/* ./src/lang/intl_ro.lang */ const char INTL_NO_NETWORKS[] PROGMEM = "Nu s-a găsit nicio rețea WiFi";
/* ./src/lang/intl_ro.lang */ const char INTL_NTP_TIME[] PROGMEM = "Ora de la serverul NTP";
/* ./src/lang/intl_ro.lang */ const char INTL_NTP_TIME_NOT_ACC[] PROGMEM = "Nu este setat";
/* ./src/sensors/network_watchdog/ntw_wtd_ro.lang */ const char INTL_NTW_WTD_DESC[] PROGMEM = "Watchdog de rețea - repornește senzorul în caz de lipsă de conectivitate";
/* ./src/sensors/network_watchdog/ntw_wtd_ro.lang */ const char INTL_NTW_WTD_ERROR[] PROGMEM = "Aceasta nu este o adresă IP adecvată";
/* ./src/sensors/network_watchdog/ntw_wtd_ro.lang */ const char INTL_NTW_WTD_HOST[] PROGMEM = "Adresa pentru test (IP)";
/* ./src/lang/intl_ro.lang */ const char INTL_NUMBER_OF_MEASUREMENTS[] PROGMEM = "Numărul de măsurători:";
/* ./src/lang/intl_ro.lang */ const char INTL_PARAMETER[] PROGMEM = "Parametru";
/* ./src/lang/intl_ro.lang */ const char INTL_PARTICLES_PER_LITER[] PROGMEM = "particule/litru";
/* ./src/lang/intl_ro.lang */ const char INTL_PARTICULATE_MATTER[] PROGMEM = "pulberi în suspensie";
/* ./src/lang/intl_ro.lang */ const char INTL_PASSWORD[] PROGMEM = "Parola de acces";
/* ./src/lang/intl_ro.lang */ const char INTL_PATH[] PROGMEM = "Calea de acces";
/* ./src/lang/intl_ro.lang */ const char INTL_PMS[] PROGMEM = "Plantower PMS(1,3,5,6,7)003 ({pm})";
/* ./src/lang/intl_ro.lang */ const char INTL_PM_SENSOR[] PROGMEM = "Senzor de pulberi în suspensie";
/* ./src/lang/intl_ro.lang */ const char INTL_PORT[] PROGMEM = "Portul";
/* ./src/lang/intl_ro.lang */ const char INTL_PRESSURE[] PROGMEM = "presiunea aerului";
/* ./src/lang/intl_ro.lang */ const char INTL_READ_FROM[] PROGMEM = "Citi»õi de la {v}";
/* ./src/lang/intl_ro.lang */ const char INTL_REALLY_RESTART_SENSOR[] PROGMEM = "Sunteți sigur că doriți să reporniți senzorul?";
/* ./src/lang/intl_ro.lang */ const char INTL_RESTART[] PROGMEM = "Reporni»õi";
/* ./src/lang/intl_ro.lang */ const char INTL_RESTART_DEVICE[] PROGMEM = "Reporni»õi dispozitivul";
/* ./src/lang/intl_ro.lang */ const char INTL_RESTART_SENSOR[] PROGMEM = "Reporni»õi senzorul";
/* ./src/lang/intl_ro.lang */ const char INTL_SAVE[] PROGMEM = "Salva»õi";
/* ./src/lang/intl_ro.lang */ const char INTL_SAVE_AND_RESTART[] PROGMEM = "Salva»õi »ôi reporni»õi";
/* ./src/lang/intl_ro.lang */ const char INTL_SDS011[] PROGMEM = "SDS011 ({pm})";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_DESC[] PROGMEM = "SDS011 - Senzor PM2.5/PM10";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_FAILED_READINGS[] PROGMEM = "Citiri eșuate/total (contor resetat cu verificarea actualizării)";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_HWR[] PROGMEM = "Repornire dispozitiv hardware";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_LCD_HDR[] PROGMEM = "Citiri SDS011:";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_READTIME[] PROGMEM = "Timp de măsurare (ms)";
/* ./src/sensors/sds011/sds011_ro.lang */ const char INTL_SDS011_WARMUP[] PROGMEM = "Timp de încălzire înainte de măsurare (ms)";
/* ./src/lang/intl_ro.lang */ const char INTL_SEND_TO[] PROGMEM = "Trimite»õi la {v}";
/* ./src/lang/intl_ro.lang */ const char INTL_SEND_TO_OWN_API[] PROGMEM = "Trimiteți date către propriul API";
/* ./src/lang/intl_ro.lang */ const char INTL_SENSOR[] PROGMEM = "Senzor";
/* ./src/lang/intl_ro.lang */ const char INTL_SENSORS[] PROGMEM = "Senzorii";
/* ./src/lang/intl_ro.lang */ const char INTL_SENSOR_IS_REBOOTING[] PROGMEM = "Senzorul se restartează.";
/* ./src/lang/intl_ro.lang */ const char INTL_SENSOR_IS_REBOOTING_NOW[] PROGMEM = "Senzorul este în curs de repornire. Așteptați câteva secunde și faceți clic pe butonul de mai jos";
/* ./src/lang/intl_ro.lang */ const char INTL_SERVER[] PROGMEM = "Server";
/* ./src/lang/intl_ro.lang */ const char INTL_SHOW_DEVICE_INFO[] PROGMEM = "Afișează informațiile despre dispozitiv pe LCD";
/* ./src/lang/intl_ro.lang */ const char INTL_SHOW_WIFI_INFO[] PROGMEM = "Afi»ôarea informa»õiilor despre conexiunea WiFi pe ecranul LCD";
/* ./src/sensors/sht3x/sht3x_ro.lang */ const char INTL_SHT3X_DESC[] PROGMEM = "SHT3x - senzor de temperatură și umiditate";
/* ./src/sensors/sht3x/sht3x_ro.lang */ const char INTL_SHT3X_RESULTS[] PROGMEM = "Umiditate și temperatură";
/* ./src/sensors/sht3x/sht3x_ro.lang */ const char INTL_SHT3x_HUM[] PROGMEM = "Umiditate relativă";
/* ./src/sensors/sht3x/sht3x_ro.lang */ const char INTL_SHT3x_TEMP[] PROGMEM = "Temperatura";
/* ./src/lang/intl_ro.lang */ const char INTL_SIGNAL_QUALITY[] PROGMEM = "calitatea semnalului";
/* ./src/lang/intl_ro.lang */ const char INTL_SIGNAL_STRENGTH[] PROGMEM = "puterea semnalului";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_CONCENTRATION[] PROGMEM = "pcs/cm³";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_CONCENTRATIONS[] PROGMEM = "Concentrația de particule în suspensie";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_COUNTS[] PROGMEM = "Numărul de particule";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_FW_FAIL[] PROGMEM = "Citirea a e»ôuat";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_NOT_STARTED[] PROGMEM = "Nu a început";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_NO_RESULT[] PROGMEM = "niciun rezultat";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_REFRESH[] PROGMEM = "Pauză între măsurătorile de salvare";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_SENSOR_DESC[] PROGMEM = "Sensirion SPS30 - senzor de particule în suspensie de mare precizie";
/* ./src/sensors/sps30/sps30_ro.lang */ const char INTL_SPS30_SIZE[] PROGMEM = "µm";
/* ./src/lang/intl_ro.lang */ const char INTL_STATUS_PAGE[] PROGMEM = "Starea senzorului";
/* ./src/lang/intl_ro.lang */ const char INTL_TEMPERATURE[] PROGMEM = "temperatura";
/* ./src/lang/intl_ro.lang */ const char INTL_TIME[] PROGMEM = "Timp";
/* ./src/lang/intl_ro.lang */ const char INTL_TIME_FROM_UPDATE[] PROGMEM = "Timpul de la ultima încercare de actualizare";
/* ./src/lang/intl_ro.lang */ const char INTL_TIME_SINCE_LAST_MEASUREMENT[] PROGMEM = " secunde de la ultima măsurare.";
/* ./src/lang/intl_ro.lang */ const char INTL_TIME_TO_MEASUREMENT[] PROGMEM = "Încă {v} secunde până la măsurare";
/* ./src/lang/intl_ro.lang */ const char INTL_UPDATE_ALFA[] PROGMEM = "alfa (fw experimental, nu folosiți decât dacă puteți recupera senzorul)";
/* ./src/lang/intl_ro.lang */ const char INTL_UPDATE_BETA[] PROGMEM = "beta (teste de stabilitate pentru noile caracteristici)";
/* ./src/lang/intl_ro.lang */ const char INTL_UPDATE_STABLE[] PROGMEM = "stabil (a se utiliza în caz de îndoială)";
/* ./src/lang/intl_ro.lang */ const char INTL_USER[] PROGMEM = "Utilizatorul";
/* ./src/lang/intl_ro.lang */ const char INTL_VALUE[] PROGMEM = "Valoare";
/* ./src/lang/intl_ro.lang */ const char INTL_WARNING[] PROGMEM = "avertismente";
/* ./src/lang/intl_ro.lang */ const char INTL_WIFI_NETWORKS[] PROGMEM = "Încărcare rețele wifi ...";
/* ./src/lang/intl_ro.lang */ const char INTL_WIFI_PHY_MODE[] PROGMEM = "Mod WiFi Phy (1=B / 2=G / 3=N)";
/* ./src/lang/intl_ro.lang */ const char INTL_WIFI_SETTINGS[] PROGMEM = "Setări WiFi";
/* ./src/lang/intl_ro.lang */ const char INTL_WIFI_TX_PWR[] PROGMEM = "Puterea TX 0-20,5 (dBm)";
/* ./src/lang/intl_ro.lang */ const char LUFTDATEN_INFO_LOGO_SVG[] PROGMEM = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120px\" height=\"90px\" version=\"1.0\" style=\"shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd\" viewBox=\"0 0 120 90\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"NAM Logo\"><path fill=\"#fff\" d=\"M50 27c0,1 -1,2 -2,2 -1,0 -2,-1 -2,-2 0,-8 6,-14 14,-14 7,0 13,6 13,14 0,7 -6,13 -13,13l-32 0c-12,0 -21,10 -21,21 0,14 13,23 26,20 2,-1 3,-1 5,-2 1,-1 2,0 3,1 1,1 0,2 -1,3 -10,6 -22,4 -30,-4 -10,-10 -10,-26 0,-36 4,-4 11,-7 18,-7l32 0c8,0 12,-10 6,-16 -6,-6 -16,-1 -16,7zm5 52c0,0 -1,0 -1,0l0 0 -1 -2 -3 0c0,1 0,2 0,2 -1,0 -1,0 -2,0 0,0 0,0 0,0l3 -8c0,0 0,0 0,0l0 0c1,0 2,0 2,0l3 8c0,0 0,0 -1,0l0 0zm6 -13c0,0 0,-8 0,-10 0,-2 1,-2 1,-2l6 0 0 2 -4 0 0 3 4 0 0 2 -4 0 0 3 4 0 0 2 -7 0zm11 0l0 -10 -4 0c0,0 0,-2 2,-2l17 0 0 2 -3 0 0 10 -3 0 0 -10c-2,0 -4,0 -6,0l0 10 -3 0zm16 0c0,0 0,-8 0,-10 0,-2 3,-2 3,-2l0 12 -3 0zm22 -12c2,0 3,0 5,1 1,2 2,3 2,5 0,2 -1,4 -2,5 -2,1 -3,2 -5,2 -1,0 -3,-1 -4,-2 -2,-1 -2,-3 -2,-5 0,-2 0,-3 2,-5 1,-1 3,-1 4,-1zm0 2c-1,0 -1,0 -2,1 -1,1 -1,2 -1,3 0,2 0,3 1,3 0,1 1,2 2,2 1,0 2,-1 3,-2 0,-1 1,-2 1,-3 0,-1 -1,-2 -1,-3 -1,-1 -2,-1 -3,-1zm-62 10c0,0 0,-8 0,-10 0,-2 2,-2 2,-2l7 8c0,0 0,-4 0,-6 0,-2 2,-2 2,-2l0 12 -2 0 -7 -8 0 6 0 2 -2 0 0 0zm55 -6c0,0 -3,0 -3,0 -2,0 -2,2 -2,2l3 0c0,2 0,2 0,2 -1,0 -1,1 -2,1 -1,0 -2,-1 -3,-2 -1,0 -1,-2 -1,-3 0,-1 0,-2 1,-3 1,-1 2,-1 3,-1 1,0 2,0 3,0l1 -1c-2,-1 -3,-1 -4,-1 -1,0 -2,0 -3,0 -1,1 -2,1 -3,2 -1,1 -1,3 -1,4 0,1 0,2 0,3 1,1 1,2 2,2 2,1 3,2 5,2 1,0 3,-1 4,-1l0 -6 0 0zm-52 16l2 0 -1 -2 -1 2zm6 3c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm4 -3l0 3c0,0 -1,0 -1,0 -1,0 -1,0 -1,0l0 -8c0,0 0,0 1,0 1,0 2,0 3,0 1,0 1,1 2,1l0 0c0,2 0,3 -2,4l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm11 1l3 -5c0,0 0,0 0,0l0 0c0,0 0,0 0,0l0 0 1 0c0,0 0,0 0,0l0 8c0,0 0,0 -1,0 0,0 0,0 0,0l0 -4 -2 3c0,0 -1,0 -2,0l-1 -3 0 4c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0 0,0 1,0 1,0l2 5zm13 -1c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm4 -4c0,0 0,0 0,0l4 5 0 -5c0,0 1,0 1,0 0,0 1,0 1,0l0 8c0,1 -1,0 -2,0l0 0 0 0 -3 -5 0 5c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0zm8 8c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm8 -8c0,2 0,2 -3,2l0 6c0,0 0,0 -1,0 0,0 -1,0 -1,0l0 -6c-2,0 -2,0 -2,-2 0,0 0,0 1,0l5 0c1,0 1,0 1,0zm7 4c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm5 1l0 3c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 0,0 1,0 3,0 4,0 2,1 2,4 0,5l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm-85 -18c-3,0 -6,2 -7,4 1,2 4,4 7,4 3,0 5,-2 7,-4 -2,-2 -4,-4 -7,-4zm0 2c1,0 2,1 2,2 0,1 -1,2 -2,2 -2,0 -3,-1 -3,-2 0,-1 1,-2 3,-2zm22 -48c-1,0 -2,0 -3,-1 0,-1 0,-2 1,-3 9,-5 20,-4 28,4 9,8 9,23 0,32 -4,4 -10,7 -16,7l-32 0c-7,0 -12,5 -12,11 0,6 5,11 12,11 7,0 13,-7 11,-14 -1,-1 0,-2 1,-3 2,0 3,1 3,2 3,10 -5,20 -15,20 -9,0 -16,-7 -16,-16 0,-9 7,-16 16,-16l32 0c10,0 18,-8 18,-18 0,-12 -12,-21 -23,-18 -2,0 -3,1 -5,2z\"/></g></svg>";
/* ./src/sensors/sht3x/sht3x_ro.lang */ const char SENSOR_SHT3[] PROGMEM = "SHT3x";
const char INTL_HECA_SET_RH[] PROGMEM = "Translate RO: INTL_HECA_SET_RH üê±;";
const char INTL_HECA_CLEAR_RH[] PROGMEM = "Translate RO: INTL_HECA_CLEAR_RH üê±;";
const char INTL_ADVANCED_BUTTON[] PROGMEM = "Translate RO: INTL_ADVANCED_BUTTON üê±;";
const char INTL_ADVANCED_DISCL[] PROGMEM = "Translate RO: INTL_ADVANCED_DISCL üê±;";
const char INTL_DEBUG_STATUS[] PROGMEM = "Translate RO: INTL_DEBUG_STATUS üê±;";
const char INTL_DEBUG[] PROGMEM = "Translate RO: INTL_DEBUG üê±;";
const char INTL_AQI_TOKEN[] PROGMEM = "Translate RO: INTL_AQI_TOKEN üê±;";
const char INTL_AQI_ECO_API[] PROGMEM = "Translate RO: INTL_AQI_ECO_API üê±;";
const char INTL_USE_HTTPS[] PROGMEM = "Translate RO: INTL_USE_HTTPS üê±;";
const char INTL_OTHER_APIS[] PROGMEM = "Translate RO: INTL_OTHER_APIS üê±;";
const char INTL_TAB_BASIC[] PROGMEM = "Translate RO: INTL_TAB_BASIC üê±;";
const char INTL_TAB_API[] PROGMEM = "Translate RO: INTL_TAB_API üê±;";
const char INTL_TAB_SENSORS[] PROGMEM = "Translate RO: INTL_TAB_SENSORS üê±;";
const char INTL_TAB_ADVANCED[] PROGMEM = "Translate RO: INTL_TAB_ADVANCED üê±;";
#endif
| 19,139
|
C++
|
.h
| 174
| 108.816092
| 3,225
| 0.672647
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,477
|
select_lang.h
|
nettigo_namf/src/lang/select_lang.h
|
#if defined(INTL_EN)
#include "lang/intl_en.h"
#define NTP_SERVER "0.europe.pool.ntp.org"
#elif defined(INTL_PL)
#include "lang/intl_pl.h"
#define NTP_SERVER "0.pl.pool.ntp.org"
#elif defined(INTL_RO)
#include "lang/intl_ro.h"
#define NTP_SERVER "0.ro.pool.ntp.org"
#elif defined(INTL_HU)
#include "lang/intl_hu.h"
#define NTP_SERVER "0.hu.pool.ntp.org"
#else
#include "lang/intl_en.h"
#define NTP_SERVER "0.europe.pool.ntp.org"
#endif
| 437
|
C++
|
.h
| 16
| 26.25
| 42
| 0.745238
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,478
|
intl_hu.h
|
nettigo_namf/src/lang/intl_hu.h
|
/*
*** THIS IS AUTOGENERATED FILE DO NOT EDIT IT ****
(c) Nettigo 2020
Language translation file for Nettigo Air Monitor
For changes in translations do them in corresponding .lang file. File with translations has format:
KEY[SPACE]translation string
So entry in file:
INTL_DS18B20 Sensor DS18B20 ({t})
Will become
const char INTL_DS18B20[] PROGMEM = "Sensor DS18B20 ({t})";
in this file.
Generator will add path to source from which given line was generated. Generator is run by Platformio during build process.
Files with .lang extension are searched in following directories and it's subdirectories:
./src/lang/
./src/sensors/
./src/system/
*/
#ifndef LANG_DEF_hu_H
#define LANG_DEF_hu_H
/* ./src/lang/intl_hu.lang */ const char INTL_ALTITUDE[] PROGMEM = "Tengerszint feletti magass√°g";
/* ./src/lang/intl_hu.lang */ const char INTL_AUTO_UPDATE[] PROGMEM = "Firmware automatikus frissítése";
/* ./src/lang/intl_hu.lang */ const char INTL_BACK_TO_HOME[] PROGMEM = "Vissza a főoldalra";
/* ./src/lang/intl_hu.lang */ const char INTL_BASICAUTH[] PROGMEM = "Azonosítás";
/* ./src/lang/intl_hu.lang */ const char INTL_BME280[] PROGMEM = "BME280 ({t}, {h}, {p})";
/* ./src/sensors/bme280/bme280_hu.lang */ const char INTL_BME280_DESC[] PROGMEM = "BME280 páratartalom/hőmérséklet/nyomás érzékelő";
/* ./src/lang/intl_hu.lang */ const char INTL_BMP280[] PROGMEM = "BMP280/BMP180 ({t}, {p})";
/* ./src/sensors/bmpX80/bmpX80_hu.lang */ const char INTL_BMPx80_DESC[] PROGMEM = "BMP180/280 hőmérséklet/nyomás érzékelő";
/* ./src/sensors/bmpX80/bmpX80_hu.lang */ const char INTL_BMPx80_INSIDE[] PROGMEM = "Érzékelő a házon belül (ne használjon hőmérséklet-leolvasást)";
/* ./src/lang/intl_hu.lang */ const char INTL_CANCEL[] PROGMEM = "Mégse";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIGURATION[] PROGMEM = "Konfiguráció";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIGURATION_DELETE[] PROGMEM = "Beállítások törlése";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIGURATION_REALLY_DELETE[] PROGMEM = "Biztosan törölni akarod a beállításokat?";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIG_CAN_NOT_BE_DELETED[] PROGMEM = "A beállítások törlése sikertelen.";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIG_DELETED[] PROGMEM = "Beállítások törölve";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIG_NOT_FOUND[] PROGMEM = "Beállítások nem találhatóak";
/* ./src/lang/intl_hu.lang */ const char INTL_CONFIG_SAVED[] PROGMEM = "A konfiguráció mentve";
/* ./src/lang/intl_hu.lang */ const char INTL_CURRENT_DATA[] PROGMEM = "Aktu√°lis adatok";
/* ./src/lang/intl_hu.lang */ const char INTL_DATE[] PROGMEM = "D√°tum";
/* ./src/lang/intl_hu.lang */ const char INTL_DEBUG_LEVEL[] PROGMEM = "Debug Level";
/* ./src/lang/intl_hu.lang */ const char INTL_DEBUG_SETTING_TO[] PROGMEM = "Debug beállítás";
/* ./src/lang/intl_hu.lang */ const char INTL_DELETE[] PROGMEM = "Törlés";
/* ./src/lang/intl_hu.lang */ const char INTL_DELETE_CONFIG[] PROGMEM = "A mentett beállítások törlése";
/* ./src/lang/intl_hu.lang */ const char INTL_DHT22[] PROGMEM = "DHT22 ({t}, {h})";
/* ./src/lang/intl_hu.lang */ const char INTL_DIAGNOSTIC[] PROGMEM = "Diagnosztikai adatok küldése a Nettigo -nak";
/* ./src/lang/intl_hu.lang */ const char INTL_DISPLAY[] PROGMEM = "OLED SSD1306";
/* ./src/lang/intl_hu.lang */ const char INTL_DS18B20[] PROGMEM = "DS18B20 ({t})";
/* ./src/lang/intl_hu.lang */ const char INTL_DURATION_ROUTER_MODE[] PROGMEM = "Hotspot mód időtartama";
/* ./src/lang/intl_hu.lang */ const char INTL_ENABLE_OTA[] PROGMEM = "Enable OTA";
/* ./src/lang/intl_hu.lang */ const char INTL_ENABLE_OTA_INFO[] PROGMEM = "OTA enabled for 60 seconds.";
/* ./src/lang/intl_hu.lang */ const char INTL_ENABLE_OTA_REFUSE[] PROGMEM = "Enable authorization in config panel in order to allow code upload";
/* ./src/lang/intl_hu.lang */ const char INTL_ERROR[] PROGMEM = "only errors";
/* ./src/lang/intl_hu.lang */ const char INTL_FALBACK_WIFI[] PROGMEM = "Alternatív WiFi hálózat";
/* ./src/lang/intl_hu.lang */ const char INTL_FIRMWARE[] PROGMEM = "Firmware verzió";
/* ./src/lang/intl_hu.lang */ const char INTL_FS_WIFI[] PROGMEM = "WiFi Szenzor";
/* ./src/lang/intl_hu.lang */ const char INTL_FS_WIFI_DESCRIPTION[] PROGMEM = "WiFi Szenzor konfigurációs módban";
/* ./src/lang/intl_hu.lang */ const char INTL_FS_WIFI_NAME[] PROGMEM = "Név";
/* ./src/lang/intl_hu.lang */ const char INTL_HECA[] PROGMEM = "HECA (SHT30) ({t}, {h})";
/* ./src/sensors/heca/heca_hu.lang */ const char INTL_HECA_DESC[] PROGMEM = "";
/* ./src/lang/intl_hu.lang */ const char INTL_HOME[] PROGMEM = "Főoldal";
/* ./src/lang/intl_hu.lang */ const char INTL_HUMIDITY[] PROGMEM = "relatív páratartalom";
/* ./src/lang/intl_hu.lang */ const char INTL_LANG[] PROGMEM = "HU";
/* ./src/lang/intl_hu.lang */ const char INTL_LANGUAGE[] PROGMEM = "Nyelv";
/* ./src/lang/intl_hu.lang */ const char INTL_LATITUDE[] PROGMEM = "Földrajzi szélesség";
/* ./src/lang/intl_hu.lang */ const char INTL_LCD[] PROGMEM = "Has character LCD";
/* ./src/lang/intl_hu.lang */ const char INTL_LCD1602_27[] PROGMEM = "LCD 1602 (I2C: 0x27)";
/* ./src/lang/intl_hu.lang */ const char INTL_LCD1602_3F[] PROGMEM = "LCD 1602 (I2C: 0x3F)";
/* ./src/lang/intl_hu.lang */ const char INTL_LCD2004_27[] PROGMEM = "LCD 2004 (I2C: 0x27)";
/* ./src/lang/intl_hu.lang */ const char INTL_LCD2004_3F[] PROGMEM = "LCD 2004 (I2C: 0x3F)";
/* ./src/lang/intl_hu.lang */ const char INTL_LEDBAR_32[] PROGMEM = "RGB LED BAR (I2C: 0x32)";
/* ./src/lang/intl_hu.lang */ const char INTL_LONGITUDE[] PROGMEM = "Földrajzi hosszúság";
/* ./src/lang/intl_hu.lang */ const char INTL_MAX_INFO[] PROGMEM = "max. info";
/* ./src/lang/intl_hu.lang */ const char INTL_MEASUREMENT_INTERVAL[] PROGMEM = "Mérési intervallum";
/* ./src/lang/intl_hu.lang */ const char INTL_MED_INFO[] PROGMEM = "mid. info";
/* ./src/sensors/mhz14a/mhz14a_hu.lang */ const char INTL_MHZ14A[] PROGMEM = "Winsen MH-Z14A CO2 Sensor";
/* ./src/sensors/mhz14a/mhz14a_hu.lang */ const char INTL_MHZ14A_DESC[] PROGMEM = "Winsen MHZ14A - CO2 sensor";
/* ./src/sensors/mhz14a/mhz14a_hu.lang */ const char INTL_MHZ14A_VAL[] PROGMEM = "WINSEN";
/* ./src/lang/intl_hu.lang */ const char INTL_MIN_INFO[] PROGMEM = "min. info";
/* ./src/lang/intl_hu.lang */ const char INTL_MORE_APIS[] PROGMEM = "Tov√°bbi API-k";
/* ./src/lang/intl_hu.lang */ const char INTL_MORE_SETTINGS[] PROGMEM = "További beállítások";
/* ./src/lang/intl_hu.lang */ const char INTL_NEO6M[] PROGMEM = "GPS (NEO 6M)";
/* ./src/lang/intl_hu.lang */ const char INTL_NETWORKS_FOUND[] PROGMEM = "Talált WiFi hálózatok:";
/* ./src/lang/intl_hu.lang */ const char INTL_NONE[] PROGMEM = "off";
/* ./src/lang/intl_hu.lang */ const char INTL_NUMBER_OF_MEASUREMENTS[] PROGMEM = "Mérések száma:";
/* ./src/lang/intl_hu.lang */ const char INTL_PARAMETER[] PROGMEM = "Paraméter";
/* ./src/lang/intl_hu.lang */ const char INTL_PARTICLES_PER_LITER[] PROGMEM = "részecske/liter";
/* ./src/lang/intl_hu.lang */ const char INTL_PARTICULATE_MATTER[] PROGMEM = "szálló por";
/* ./src/lang/intl_hu.lang */ const char INTL_PASSWORD[] PROGMEM = "Jelszó";
/* ./src/lang/intl_hu.lang */ const char INTL_PATH[] PROGMEM = "√ötvonal";
/* ./src/lang/intl_hu.lang */ const char INTL_PMS[] PROGMEM = "Plantower PMS(1,3,5,6,7)003 ({pm})";
/* ./src/lang/intl_hu.lang */ const char INTL_PM_SENSOR[] PROGMEM = "Szálló por szenzor";
/* ./src/lang/intl_hu.lang */ const char INTL_PORT[] PROGMEM = "Port";
/* ./src/lang/intl_hu.lang */ const char INTL_PRESSURE[] PROGMEM = "légnyomás";
/* ./src/lang/intl_hu.lang */ const char INTL_READ_FROM[] PROGMEM = "Read from {v}";
/* ./src/lang/intl_hu.lang */ const char INTL_REALLY_RESTART_SENSOR[] PROGMEM = "Biztosan újraindítod a szenzort?";
/* ./src/lang/intl_hu.lang */ const char INTL_RESTART[] PROGMEM = "Újraindítás";
/* ./src/lang/intl_hu.lang */ const char INTL_RESTART_DEVICE[] PROGMEM = "Eszköz újraindítása";
/* ./src/lang/intl_hu.lang */ const char INTL_RESTART_SENSOR[] PROGMEM = "A szenzor újraindítása";
/* ./src/lang/intl_hu.lang */ const char INTL_SAVE[] PROGMEM = "Mentés";
/* ./src/lang/intl_hu.lang */ const char INTL_SAVE_AND_RESTART[] PROGMEM = "Mentés és újraindítás";
/* ./src/lang/intl_hu.lang */ const char INTL_SDS011[] PROGMEM = "SDS011 ({pm})";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_DESC[] PROGMEM = "SDS011 - PM2.5/PM10 sensor";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_FAILED_READINGS[] PROGMEM = "Readings failed/total (counter reset with update check)";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_HWR[] PROGMEM = "Hardver újraindító az SDS011-hez";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_LCD_HDR[] PROGMEM = "SDS011 readings:";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_READTIME[] PROGMEM = "Measurement time (ms)";
/* ./src/sensors/sds011/sds011_hu.lang */ const char INTL_SDS011_WARMUP[] PROGMEM = "Warmup time before measurement (ms)";
/* ./src/lang/intl_hu.lang */ const char INTL_SEND_TO[] PROGMEM = "Send to {v}";
/* ./src/lang/intl_hu.lang */ const char INTL_SEND_TO_OWN_API[] PROGMEM = "Adatok küldése saját API-nak";
/* ./src/lang/intl_hu.lang */ const char INTL_SENSOR[] PROGMEM = "Szenzor";
/* ./src/lang/intl_hu.lang */ const char INTL_SENSORS[] PROGMEM = "Szenzorok";
/* ./src/lang/intl_hu.lang */ const char INTL_SENSOR_IS_REBOOTING[] PROGMEM = "A Szenzor √∫jraindul...";
/* ./src/lang/intl_hu.lang */ const char INTL_SERVER[] PROGMEM = "Szerver";
/* ./src/lang/intl_hu.lang */ const char INTL_SHOW_DEVICE_INFO[] PROGMEM = "Az eszköz adatainak megjelenítése az LCD-n";
/* ./src/lang/intl_hu.lang */ const char INTL_SHOW_WIFI_INFO[] PROGMEM = "A Wi-Fi kapcsolat adatainak megjelenítése az LCD-n";
/* ./src/sensors/sht3x/sht3x_hu.lang */ const char INTL_SHT3X_DESC[] PROGMEM = "SHT3x - temperature and humidity sensor";
/* ./src/sensors/sht3x/sht3x_hu.lang */ const char INTL_SHT3X_RESULTS[] PROGMEM = "Humidity and temperature";
/* ./src/sensors/sht3x/sht3x_hu.lang */ const char INTL_SHT3x_HUM[] PROGMEM = "Relative humidity";
/* ./src/sensors/sht3x/sht3x_hu.lang */ const char INTL_SHT3x_TEMP[] PROGMEM = "Temperature";
/* ./src/lang/intl_hu.lang */ const char INTL_SIGNAL_QUALITY[] PROGMEM = "Jelminőség";
/* ./src/lang/intl_hu.lang */ const char INTL_SIGNAL_STRENGTH[] PROGMEM = "Jelerősség";
/* ./src/lang/intl_hu.lang */ const char INTL_TEMPERATURE[] PROGMEM = "hőmérséklet";
/* ./src/lang/intl_hu.lang */ const char INTL_TIME[] PROGMEM = "Idő";
/* ./src/lang/intl_hu.lang */ const char INTL_TIME_SINCE_LAST_MEASUREMENT[] PROGMEM = " másodperc telt el az utolsó mérés óta.";
/* ./src/lang/intl_hu.lang */ const char INTL_TIME_TO_MEASUREMENT[] PROGMEM = "Még {v} másodperc van hátra az mérésig";
/* ./src/lang/intl_hu.lang */ const char INTL_USER[] PROGMEM = "Felhasználónév";
/* ./src/lang/intl_hu.lang */ const char INTL_VALUE[] PROGMEM = "Érték";
/* ./src/lang/intl_hu.lang */ const char INTL_WARNING[] PROGMEM = "warnings";
/* ./src/lang/intl_hu.lang */ const char INTL_WIFI_NETWORKS[] PROGMEM = "WiFi hálózatok keresése...";
/* ./src/lang/intl_hu.lang */ const char INTL_WIFI_PHY_MODE[] PROGMEM = "WiFi Phy Mode (1=B / 2=G / 3=N)";
/* ./src/lang/intl_hu.lang */ const char INTL_WIFI_SETTINGS[] PROGMEM = "WiFi beállítások";
/* ./src/lang/intl_hu.lang */ const char INTL_WIFI_TX_PWR[] PROGMEM = "TX power 0-20.5(dBm)";
/* ./src/lang/intl_hu.lang */ const char LUFTDATEN_INFO_LOGO_SVG[] PROGMEM = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"120px\" height=\"90px\" version=\"1.0\" style=\"shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd\" viewBox=\"0 0 120 90\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><g id=\"NAM Logo\"><path fill=\"#fff\" d=\"M50 27c0,1 -1,2 -2,2 -1,0 -2,-1 -2,-2 0,-8 6,-14 14,-14 7,0 13,6 13,14 0,7 -6,13 -13,13l-32 0c-12,0 -21,10 -21,21 0,14 13,23 26,20 2,-1 3,-1 5,-2 1,-1 2,0 3,1 1,1 0,2 -1,3 -10,6 -22,4 -30,-4 -10,-10 -10,-26 0,-36 4,-4 11,-7 18,-7l32 0c8,0 12,-10 6,-16 -6,-6 -16,-1 -16,7zm5 52c0,0 -1,0 -1,0l0 0 -1 -2 -3 0c0,1 0,2 0,2 -1,0 -1,0 -2,0 0,0 0,0 0,0l3 -8c0,0 0,0 0,0l0 0c1,0 2,0 2,0l3 8c0,0 0,0 -1,0l0 0zm6 -13c0,0 0,-8 0,-10 0,-2 1,-2 1,-2l6 0 0 2 -4 0 0 3 4 0 0 2 -4 0 0 3 4 0 0 2 -7 0zm11 0l0 -10 -4 0c0,0 0,-2 2,-2l17 0 0 2 -3 0 0 10 -3 0 0 -10c-2,0 -4,0 -6,0l0 10 -3 0zm16 0c0,0 0,-8 0,-10 0,-2 3,-2 3,-2l0 12 -3 0zm22 -12c2,0 3,0 5,1 1,2 2,3 2,5 0,2 -1,4 -2,5 -2,1 -3,2 -5,2 -1,0 -3,-1 -4,-2 -2,-1 -2,-3 -2,-5 0,-2 0,-3 2,-5 1,-1 3,-1 4,-1zm0 2c-1,0 -1,0 -2,1 -1,1 -1,2 -1,3 0,2 0,3 1,3 0,1 1,2 2,2 1,0 2,-1 3,-2 0,-1 1,-2 1,-3 0,-1 -1,-2 -1,-3 -1,-1 -2,-1 -3,-1zm-62 10c0,0 0,-8 0,-10 0,-2 2,-2 2,-2l7 8c0,0 0,-4 0,-6 0,-2 2,-2 2,-2l0 12 -2 0 -7 -8 0 6 0 2 -2 0 0 0zm55 -6c0,0 -3,0 -3,0 -2,0 -2,2 -2,2l3 0c0,2 0,2 0,2 -1,0 -1,1 -2,1 -1,0 -2,-1 -3,-2 -1,0 -1,-2 -1,-3 0,-1 0,-2 1,-3 1,-1 2,-1 3,-1 1,0 2,0 3,0l1 -1c-2,-1 -3,-1 -4,-1 -1,0 -2,0 -3,0 -1,1 -2,1 -3,2 -1,1 -1,3 -1,4 0,1 0,2 0,3 1,1 1,2 2,2 2,1 3,2 5,2 1,0 3,-1 4,-1l0 -6 0 0zm-52 16l2 0 -1 -2 -1 2zm6 3c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm4 -3l0 3c0,0 -1,0 -1,0 -1,0 -1,0 -1,0l0 -8c0,0 0,0 1,0 1,0 2,0 3,0 1,0 1,1 2,1l0 0c0,2 0,3 -2,4l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm11 1l3 -5c0,0 0,0 0,0l0 0c0,0 0,0 0,0l0 0 1 0c0,0 0,0 0,0l0 8c0,0 0,0 -1,0 0,0 0,0 0,0l0 -4 -2 3c0,0 -1,0 -2,0l-1 -3 0 4c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0 0,0 1,0 1,0l2 5zm13 -1c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm4 -4c0,0 0,0 0,0l4 5 0 -5c0,0 1,0 1,0 0,0 1,0 1,0l0 8c0,1 -1,0 -2,0l0 0 0 0 -3 -5 0 5c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 1,0zm8 8c0,0 -1,0 -1,0l0 -8c0,0 1,0 1,0 1,0 1,0 1,0l0 8c0,0 0,0 -1,0zm8 -8c0,2 0,2 -3,2l0 6c0,0 0,0 -1,0 0,0 -1,0 -1,0l0 -6c-2,0 -2,0 -2,-2 0,0 0,0 1,0l5 0c1,0 1,0 1,0zm7 4c0,6 -8,6 -8,0 0,-6 8,-6 8,0zm-2 0c0,-1 0,-1 0,-2l0 0c-1,-1 -2,-1 -3,0l0 0c-2,1 -1,5 2,5 1,-1 1,-2 1,-3zm5 1l0 3c0,0 -1,0 -2,0 0,0 0,0 0,0l0 -8c0,0 0,0 0,0 1,0 3,0 4,0 2,1 2,4 0,5l2 3c1,0 0,0 0,0l0 0c-1,0 -1,0 -2,0l-2 -3 0 0zm0 -1c1,0 2,0 2,-1 0,-1 -1,-1 -2,-1l0 2zm-85 -18c-3,0 -6,2 -7,4 1,2 4,4 7,4 3,0 5,-2 7,-4 -2,-2 -4,-4 -7,-4zm0 2c1,0 2,1 2,2 0,1 -1,2 -2,2 -2,0 -3,-1 -3,-2 0,-1 1,-2 3,-2zm22 -48c-1,0 -2,0 -3,-1 0,-1 0,-2 1,-3 9,-5 20,-4 28,4 9,8 9,23 0,32 -4,4 -10,7 -16,7l-32 0c-7,0 -12,5 -12,11 0,6 5,11 12,11 7,0 13,-7 11,-14 -1,-1 0,-2 1,-3 2,0 3,1 3,2 3,10 -5,20 -15,20 -9,0 -16,-7 -16,-16 0,-9 7,-16 16,-16l32 0c10,0 18,-8 18,-18 0,-12 -12,-21 -23,-18 -2,0 -3,1 -5,2z\"/></g></svg>";
/* ./src/sensors/sht3x/sht3x_hu.lang */ const char SENSOR_SHT3[] PROGMEM = "SHT3x";
const char INTL_NTW_WTD_DESC[] PROGMEM = "Translate HU: INTL_NTW_WTD_DESC üê±;";
const char INTL_NTW_WTD_HOST[] PROGMEM = "Translate HU: INTL_NTW_WTD_HOST üê±;";
const char INTL_NTW_WTD_ERROR[] PROGMEM = "Translate HU: INTL_NTW_WTD_ERROR üê±;";
const char INTL_HECA_DC[] PROGMEM = "Translate HU: INTL_HECA_DC üê±;";
const char INTL_HECA_SET_RH[] PROGMEM = "Translate HU: INTL_HECA_SET_RH üê±;";
const char INTL_HECA_CLEAR_RH[] PROGMEM = "Translate HU: INTL_HECA_CLEAR_RH üê±;";
const char INTL_SPS30_FW_FAIL[] PROGMEM = "Translate HU: INTL_SPS30_FW_FAIL üê±;";
const char INTL_SPS30_CONCENTRATION[] PROGMEM = "Translate HU: INTL_SPS30_CONCENTRATION üê±;";
const char INTL_SPS30_SIZE[] PROGMEM = "Translate HU: INTL_SPS30_SIZE üê±;";
const char INTL_SPS30_NO_RESULT[] PROGMEM = "Translate HU: INTL_SPS30_NO_RESULT üê±;";
const char INTL_SPS30_CONCENTRATIONS[] PROGMEM = "Translate HU: INTL_SPS30_CONCENTRATIONS üê±;";
const char INTL_SPS30_COUNTS[] PROGMEM = "Translate HU: INTL_SPS30_COUNTS üê±;";
const char INTL_SPS30_SENSOR_DESC[] PROGMEM = "Translate HU: INTL_SPS30_SENSOR_DESC üê±;";
const char INTL_SPS30_REFRESH[] PROGMEM = "Translate HU: INTL_SPS30_REFRESH üê±;";
const char INTL_SPS30_NOT_STARTED[] PROGMEM = "Translate HU: INTL_SPS30_NOT_STARTED üê±;";
const char INTL_ADVANCED_BUTTON[] PROGMEM = "Translate HU: INTL_ADVANCED_BUTTON üê±;";
const char INTL_ADVANCED_DISCL[] PROGMEM = "Translate HU: INTL_ADVANCED_DISCL üê±;";
const char INTL_DEBUG_STATUS[] PROGMEM = "Translate HU: INTL_DEBUG_STATUS üê±;";
const char INTL_DEBUG[] PROGMEM = "Translate HU: INTL_DEBUG üê±;";
const char INTL_AQI_TOKEN[] PROGMEM = "Translate HU: INTL_AQI_TOKEN üê±;";
const char INTL_AQI_ECO_API[] PROGMEM = "Translate HU: INTL_AQI_ECO_API üê±;";
const char INTL_USE_HTTPS[] PROGMEM = "Translate HU: INTL_USE_HTTPS üê±;";
const char INTL_ENABLE[] PROGMEM = "Translate HU: INTL_ENABLE üê±;";
const char INTL_OTHER_APIS[] PROGMEM = "Translate HU: INTL_OTHER_APIS üê±;";
const char INTL_TAB_BASIC[] PROGMEM = "Translate HU: INTL_TAB_BASIC üê±;";
const char INTL_TAB_API[] PROGMEM = "Translate HU: INTL_TAB_API üê±;";
const char INTL_TAB_SENSORS[] PROGMEM = "Translate HU: INTL_TAB_SENSORS üê±;";
const char INTL_TAB_ADVANCED[] PROGMEM = "Translate HU: INTL_TAB_ADVANCED üê±;";
const char INTL_MADAVI_LINK[] PROGMEM = "Translate HU: INTL_MADAVI_LINK üê±;";
const char INTL_TIME_FROM_UPDATE[] PROGMEM = "Translate HU: INTL_TIME_FROM_UPDATE üê±;";
const char INTL_NTP_TIME[] PROGMEM = "Translate HU: INTL_NTP_TIME üê±;";
const char INTL_NTP_TIME_NOT_ACC[] PROGMEM = "Translate HU: INTL_NTP_TIME_NOT_ACC üê±;";
const char INTL_I2C_BUS[] PROGMEM = "Translate HU: INTL_I2C_BUS üê±;";
const char INTL_STATUS_PAGE[] PROGMEM = "Translate HU: INTL_STATUS_PAGE üê±;";
const char INTL_UPDATE_ALFA[] PROGMEM = "Translate HU: INTL_UPDATE_ALFA üê±;";
const char INTL_UPDATE_BETA[] PROGMEM = "Translate HU: INTL_UPDATE_BETA üê±;";
const char INTL_UPDATE_STABLE[] PROGMEM = "Translate HU: INTL_UPDATE_STABLE üê±;";
const char INTL_NO_NETWORKS[] PROGMEM = "Translate HU: INTL_NO_NETWORKS üê±;";
const char INTL_SENSOR_IS_REBOOTING_NOW[] PROGMEM = "Translate HU: INTL_SENSOR_IS_REBOOTING_NOW üê±;";
const char INTL_DISPLAY_NEW[] PROGMEM = "Translate HU: INTL_DISPLAY_NEW üê±;";
#endif
| 18,179
|
C++
|
.h
| 174
| 103.149425
| 3,225
| 0.655569
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,536,479
|
reporting.h
|
nettigo_namf/src/system/reporting.h
|
//
// Created by viciu on 09.10.2021.
//
#ifndef NAMF_REPORTING_H
#define NAMF_REPORTING_H
#define REPORTING_MINRSSI_NO_VAL 127
#define REPORTING_MAXRSSI_NO_VAL -128
#include "helpers.h"
#include "sensors/sds011.h"
#include <ESP8266WiFi.h>
namespace Reporting {
#if SOFTWARE_BETA == 1
const char reportingHost[] PROGMEM = "et-dev.nettigo.pl";
const unsigned reportingHostPort = 80;
#else
const char reportingHost[] PROGMEM = "et.nettigo.pl";
const unsigned reportingHostPort = 80;
#endif
unsigned long lastPhone = 0;
unsigned long lastPeriodicCheck = 0;
bool first = true;
int8_t minRSSI = 255;
int8_t maxRSSI = 0;
#define RPRT_PERIODIC_CHECK_INTERVAL 1000
//extern SerialSDS channelSDS(serialSDS);
//we are using the same code in main loop, but in main namespace we are collecting stats for one
//measurement period, here we are collecting for 24 hrs, and just those min/max are sending
memory_stat_t memoryStatsMax;
memory_stat_t memoryStatsMin;
void resetMinMaxStats() {
memoryStatsMax = memory_stat_t{0,0,0, 0};
memoryStatsMin = memory_stat_t{UINT32_MAX, UINT16_MAX, UINT8_MAX, UINT32_MAX};
maxRSSI = REPORTING_MAXRSSI_NO_VAL;
minRSSI = REPORTING_MINRSSI_NO_VAL;
}
void collectPeriodicStats(){
int8_t rssi = WiFi.RSSI();
if (rssi == 31 ) return; //31 means no connection, so it does not make sense to
if (rssi > maxRSSI) maxRSSI = rssi;
if (rssi < minRSSI) minRSSI = rssi;
}
void collectMemStats() {
memory_stat_t memoryStats;
ESP.getHeapStats(&memoryStats.freeHeap, &memoryStats.maxFreeBlock, &memoryStats.frag);
if (memoryStats.freeHeap > memoryStatsMax.freeHeap) memoryStatsMax.freeHeap = memoryStats.freeHeap;
if (memoryStats.maxFreeBlock > memoryStatsMax.maxFreeBlock) memoryStatsMax.maxFreeBlock = memoryStats.maxFreeBlock;
if (memoryStats.frag > memoryStatsMax.frag) memoryStatsMax.frag = memoryStats.frag;
if (memoryStats.freeHeap < memoryStatsMin.freeHeap) memoryStatsMin.freeHeap = memoryStats.freeHeap;
if (memoryStats.maxFreeBlock < memoryStatsMin.maxFreeBlock) memoryStatsMin.maxFreeBlock = memoryStats.maxFreeBlock;
if (memoryStats.frag < memoryStatsMin.frag) memoryStatsMin.frag = memoryStats.frag;
uint32_t cont = ESP.getFreeContStack();
if (cont > memoryStatsMax.freeContStack) memoryStatsMax.freeContStack = cont;
if (cont < memoryStatsMin.freeContStack) memoryStatsMin.freeContStack = cont;
}
void registerSensor() {
WiFiClient client;
HTTPClient http;
String uri = F("/register/");
uri.concat(esp_chipid());
http.begin(client, FPSTR(reportingHost), reportingHostPort, uri ); //HTTP
http.addHeader(F("Content-Type"), F("application/json"));
String body = F("");
int httpCode = http.POST(body);
// Serial.println(httpCode);
String resp = http.getString();
// Serial.println(resp);
if (httpCode == HTTP_CODE_OK) {
cfg::UUID = resp;
writeConfig();
}
}
void reportBoot() {
// Serial.println(F("Report boot"));
if (!cfg::send_diag) return;
debug_out(F("Report boot..."), DEBUG_MED_INFO);
if (cfg::UUID.length() < 36) { registerSensor(); }
if (cfg::UUID.length() < 36) { return; } //failed register
WiFiClient client;
HTTPClient http;
String body = F("{");
body.reserve(512);
body.concat(Var2Json(F("VER"), SOFTWARE_VERSION));
body.concat(Var2Json(F("MD5"), ESP.getSketchMD5()));
body.concat(Var2Json(F("resetReason"), ESP.getResetReason()));
body.concat(Var2Json(F("enabledSubsystems"), scheduler.registeredNames()));
body.concat(Var2Json(F("updateChannel"), cfg::update_channel));
body.concat(Var2Json(F("autoUpdate"), cfg::auto_update));
body.concat(Var2Json(F("boot"), 1));
body.concat(Var2Json(F("lang"), cfg::current_lang));
body.remove(body.length() - 1);
body.concat(F("}"));
String uri = F("/store/");
uri.concat(cfg::UUID);
http.begin(client, FPSTR(reportingHost), reportingHostPort, uri, false); //HTTP
http.addHeader(F("Content-Type"), F("application/json"));
Serial.println(body);
int httpCode = http.POST(body);
Serial.println(httpCode);
//server does not have such UUID. Database reset or something other, just re-register next time
if (httpCode == HTTP_CODE_NOT_FOUND) {
cfg::UUID = F("");
writeConfig();
//well, next time
}
}
void setupHomePhone() {
resetMinMaxStats();
}
//sending stats interval in hours
unsigned sendingInterval() {
switch (cfg::update_channel) {
case UPDATE_CHANNEL_ALFA:
case UPDATE_CHANNEL_BETA:
return 8;
case UPDATE_CHANNEL_STABLE:
return 12;
default:
return 12;
}
}
void homePhone() {
if (!cfg::send_diag) return;
collectMemStats();
if (millis() - lastPeriodicCheck > RPRT_PERIODIC_CHECK_INTERVAL) {
collectPeriodicStats();
lastPeriodicCheck = millis();
}
if (
(first && millis() - lastPhone > 15 * 60 * 1000) ||
millis() - lastPhone > sendingInterval() * 60 * 60 *1000
) {
first = false;
WiFiClient client;
HTTPClient http;
String body = F("{");
body.reserve(1024);
if (SDS011::enabled) {
body.concat(F("\"SDS\":{"));
body.concat(Var2Json(F("failed"), String(SDS011::failedReadings)));
body.concat(Var2Json(F("rd"), String(SDS011::readings)));
body.concat(Var2Json(F("CRCerr"), String(SDS011::channelSDS.errorRate())));
if (SDS011::hardwareWatchdog) {
body.concat(Var2Json(F("wtgCycles"), String(SDS011::hwWtdgCycles)));
body.concat(Var2Json(F("wtgErrs"), String(SDS011::hwWtdgErrors)));
}
SDS011::failedReadings = SDS011::readings = 0;
body.remove(body.length() - 1);
body.concat(F("},"));
}
body.concat(Var2Json(F("minMaxFreeBlock"),memoryStatsMin.maxFreeBlock));
body.concat(Var2Json(F("maxMaxFreeBlock"),memoryStatsMax.maxFreeBlock));
body.concat(Var2Json(F("maxFrag"),memoryStatsMax.frag));
body.concat(Var2Json(F("minFrag"),memoryStatsMin.frag));
if (minRSSI != REPORTING_MINRSSI_NO_VAL) body.concat(Var2Json(F("minRSSI"),minRSSI));
if (maxRSSI != REPORTING_MAXRSSI_NO_VAL) body.concat(Var2Json(F("maxRSSI"),maxRSSI));
Reporting::resetMinMaxStats();
body.remove(body.length() - 1);
body.concat(F("}"));
String uri = F("/store/");
uri.concat(cfg::UUID);
http.begin(client, FPSTR(reportingHost), reportingHostPort, uri ); //HTTP
http.addHeader(F("Content-Type"), F("application/json"));
Serial.println(body);
int httpCode = http.POST(body);
Serial.println(httpCode);
//server does not have such UUID. Database reset or something other, just re-register next time
lastPhone = millis();
}
}
}
#endif //NAMF_REPORTING_H
| 7,724
|
C++
|
.h
| 171
| 36.005848
| 128
| 0.607822
|
nettigo/namf
| 33
| 19
| 27
|
GPL-3.0
|
9/20/2024, 10:44:35 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.