diff --git a/applications/plugins/airmouse/LICENSE b/applications/plugins/airmouse/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/applications/plugins/airmouse/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/applications/plugins/airmouse/README.md b/applications/plugins/airmouse/README.md deleted file mode 100644 index 9df0d69b0..000000000 --- a/applications/plugins/airmouse/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Flipper Air Mouse - -## Brief - -> "You can turn anything into an air mouse if you're brave enough" - - — Piper, a.k.a. Pez - -Naturally, the quote above applies to [Flipper](https://flipperzero.one/) as well. - -## What? - -The app allows you to turn your Flipper into a USB or Bluetooth air mouse (you do need an extra module, see the Hardware section below)... - -Using it is really simple: - * Connect the Flipper via a USB cable and pick `USB`, or pick `Bluetooth` and pair it with your PC; - * Hold the Flipper in your hand with the buttons pointing towards the screen; - * Wave your Flipper like you don't care to move the cursor; - * Up button for Left mouse click; - * Down button for Right mouse click; - * Center button for Middle mouse click; - * Use calibration menu option if you notice significant drift (place your Flipper onto a level surface, make sure it doesn't move, run this option, wait 2 seconds, done). - -See early prototype [in action](https://www.youtube.com/watch?v=DdxAmmsYfMA). - -## Hardware - -The custom module is using Bosch BMI160 accelerometer/gyroscope chip connected via I2C. - -Take a look into the [schematic](https://github.com/ginkage/FlippAirMouse/tree/main/schematic) folder for Gerber, BOM and CPL files, so you can order directly from JLCPCB. - -Original idea: - -![What I thought it would look like](https://github.com/ginkage/FlippAirMouse/blob/main/schematic/schematic.png) - -Expectation: - -![What EDA though it would look like](https://github.com/ginkage/FlippAirMouse/blob/main/schematic/render.png) - -Reality: - -![What it looks like](https://github.com/ginkage/FlippAirMouse/blob/main/schematic/flipper.jpg) - - -## Software - -The code is based on the original Bosch [driver](https://github.com/BoschSensortec/BMI160_driver/) and an orientation tracking implementation from the [Cardboard](https://github.com/googlevr/cardboard/tree/master/sdk/sensors) project - -If you're familiar with Flipper applications, start in the [firmware](https://github.com/flipperdevices/flipperzero-firmware) checkout folder and do the following: -``` -cd applications/plugins -git clone https://github.com/ginkage/FlippAirMouse -cd ../.. -./fbt fap_air_mouse -``` -If you're not familiar with those, just grab a `fap` file from Releases. diff --git a/applications/plugins/airmouse/air_mouse.c b/applications/plugins/airmouse/air_mouse.c deleted file mode 100644 index 7a90e49f1..000000000 --- a/applications/plugins/airmouse/air_mouse.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "air_mouse.h" - -#include -#include - -#include "tracking/imu/imu.h" - -#define TAG "AirMouseApp" - -enum AirMouseSubmenuIndex { - AirMouseSubmenuIndexBtMouse, - AirMouseSubmenuIndexUsbMouse, - AirMouseSubmenuIndexCalibration, -}; - -void air_mouse_submenu_callback(void* context, uint32_t index) { - furi_assert(context); - AirMouse* app = context; - if(index == AirMouseSubmenuIndexBtMouse) { - app->view_id = AirMouseViewBtMouse; - view_dispatcher_switch_to_view(app->view_dispatcher, AirMouseViewBtMouse); - } else if(index == AirMouseSubmenuIndexUsbMouse) { - app->view_id = AirMouseViewUsbMouse; - view_dispatcher_switch_to_view(app->view_dispatcher, AirMouseViewUsbMouse); - } else if(index == AirMouseSubmenuIndexCalibration) { - app->view_id = AirMouseViewCalibration; - view_dispatcher_switch_to_view(app->view_dispatcher, AirMouseViewCalibration); - } -} - -void air_mouse_dialog_callback(DialogExResult result, void* context) { - furi_assert(context); - AirMouse* app = context; - if(result == DialogExResultLeft) { - view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_NONE); // Exit - } else if(result == DialogExResultRight) { - view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id); // Show last view - } else if(result == DialogExResultCenter) { - view_dispatcher_switch_to_view(app->view_dispatcher, AirMouseViewSubmenu); // Menu - } -} - -uint32_t air_mouse_exit_confirm_view(void* context) { - UNUSED(context); - return AirMouseViewExitConfirm; -} - -uint32_t air_mouse_exit(void* context) { - UNUSED(context); - return VIEW_NONE; -} - -AirMouse* air_mouse_app_alloc() { - AirMouse* app = malloc(sizeof(AirMouse)); - - // Gui - app->gui = furi_record_open(RECORD_GUI); - - // View dispatcher - app->view_dispatcher = view_dispatcher_alloc(); - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - // Submenu view - app->submenu = submenu_alloc(); - submenu_add_item( - app->submenu, "Bluetooth", AirMouseSubmenuIndexBtMouse, air_mouse_submenu_callback, app); - submenu_add_item( - app->submenu, "USB", AirMouseSubmenuIndexUsbMouse, air_mouse_submenu_callback, app); - submenu_add_item( - app->submenu, - "Calibration", - AirMouseSubmenuIndexCalibration, - air_mouse_submenu_callback, - app); - view_set_previous_callback(submenu_get_view(app->submenu), air_mouse_exit); - view_dispatcher_add_view( - app->view_dispatcher, AirMouseViewSubmenu, submenu_get_view(app->submenu)); - - // Dialog view - app->dialog = dialog_ex_alloc(); - dialog_ex_set_result_callback(app->dialog, air_mouse_dialog_callback); - dialog_ex_set_context(app->dialog, app); - dialog_ex_set_left_button_text(app->dialog, "Exit"); - dialog_ex_set_right_button_text(app->dialog, "Stay"); - dialog_ex_set_center_button_text(app->dialog, "Menu"); - dialog_ex_set_header(app->dialog, "Close Current App?", 16, 12, AlignLeft, AlignTop); - view_dispatcher_add_view( - app->view_dispatcher, AirMouseViewExitConfirm, dialog_ex_get_view(app->dialog)); - - // Bluetooth view - app->bt_mouse = bt_mouse_alloc(app->view_dispatcher); - view_set_previous_callback(bt_mouse_get_view(app->bt_mouse), air_mouse_exit_confirm_view); - view_dispatcher_add_view( - app->view_dispatcher, AirMouseViewBtMouse, bt_mouse_get_view(app->bt_mouse)); - - // USB view - app->usb_mouse = usb_mouse_alloc(app->view_dispatcher); - view_set_previous_callback(usb_mouse_get_view(app->usb_mouse), air_mouse_exit_confirm_view); - view_dispatcher_add_view( - app->view_dispatcher, AirMouseViewUsbMouse, usb_mouse_get_view(app->usb_mouse)); - - // Calibration view - app->calibration = calibration_alloc(app->view_dispatcher); - view_set_previous_callback( - calibration_get_view(app->calibration), air_mouse_exit_confirm_view); - view_dispatcher_add_view( - app->view_dispatcher, AirMouseViewCalibration, calibration_get_view(app->calibration)); - - app->view_id = AirMouseViewSubmenu; - view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id); - - return app; -} - -void air_mouse_app_free(AirMouse* app) { - furi_assert(app); - - // Free views - view_dispatcher_remove_view(app->view_dispatcher, AirMouseViewSubmenu); - submenu_free(app->submenu); - view_dispatcher_remove_view(app->view_dispatcher, AirMouseViewExitConfirm); - dialog_ex_free(app->dialog); - view_dispatcher_remove_view(app->view_dispatcher, AirMouseViewBtMouse); - bt_mouse_free(app->bt_mouse); - view_dispatcher_remove_view(app->view_dispatcher, AirMouseViewUsbMouse); - usb_mouse_free(app->usb_mouse); - view_dispatcher_remove_view(app->view_dispatcher, AirMouseViewCalibration); - calibration_free(app->calibration); - view_dispatcher_free(app->view_dispatcher); - - // Close records - furi_record_close(RECORD_GUI); - app->gui = NULL; - - // Free rest - free(app); -} - -int32_t air_mouse_app(void* p) { - UNUSED(p); - - AirMouse* app = air_mouse_app_alloc(); - if(!imu_begin()) { - air_mouse_app_free(app); - return -1; - } - - DOLPHIN_DEED(DolphinDeedPluginStart); - view_dispatcher_run(app->view_dispatcher); - - imu_end(); - air_mouse_app_free(app); - - return 0; -} diff --git a/applications/plugins/airmouse/air_mouse.h b/applications/plugins/airmouse/air_mouse.h deleted file mode 100644 index 3a1ba783e..000000000 --- a/applications/plugins/airmouse/air_mouse.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "views/bt_mouse.h" -#include "views/usb_mouse.h" -#include "views/calibration.h" - -typedef struct { - Gui* gui; - ViewDispatcher* view_dispatcher; - Submenu* submenu; - DialogEx* dialog; - BtMouse* bt_mouse; - UsbMouse* usb_mouse; - Calibration* calibration; - uint32_t view_id; -} AirMouse; - -typedef enum { - AirMouseViewSubmenu, - AirMouseViewBtMouse, - AirMouseViewUsbMouse, - AirMouseViewCalibration, - AirMouseViewExitConfirm, -} AirMouseView; diff --git a/applications/plugins/airmouse/application.fam b/applications/plugins/airmouse/application.fam deleted file mode 100644 index 97003ef89..000000000 --- a/applications/plugins/airmouse/application.fam +++ /dev/null @@ -1,9 +0,0 @@ -App( - appid="Air_Mouse", - name="[BMI160] Air Mouse", - apptype=FlipperAppType.EXTERNAL, - entry_point="air_mouse_app", - stack_size=10 * 1024, - fap_icon="mouse_10px.png", - fap_category="NeedsTesting", -) diff --git a/applications/plugins/airmouse/mouse_10px.png b/applications/plugins/airmouse/mouse_10px.png deleted file mode 100644 index 94c3a7a14..000000000 Binary files a/applications/plugins/airmouse/mouse_10px.png and /dev/null differ diff --git a/applications/plugins/airmouse/tracking/calibration_data.cc b/applications/plugins/airmouse/tracking/calibration_data.cc deleted file mode 100644 index e62311c7a..000000000 --- a/applications/plugins/airmouse/tracking/calibration_data.cc +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include - -#define TAG "tracker" - -#include "calibration_data.h" - -#include -#include - -// Student's distribution T value for 95% (two-sided) confidence interval. -static const double Tn = 1.960; - -// Number of samples (degrees of freedom) for the corresponding T values. -static const int Nn = 200; - -void CalibrationData::reset() -{ - complete = false; - count = 0; - sum = Vector::Zero(); - sumSq = Vector::Zero(); - mean = Vector::Zero(); - median = Vector::Zero(); - sigma = Vector::Zero(); - delta = Vector::Zero(); - xData.clear(); - yData.clear(); - zData.clear(); -} - -bool CalibrationData::add(Vector& data) -{ - if (complete) { - return true; - } - - xData.push_back(data[0]); - yData.push_back(data[1]); - zData.push_back(data[2]); - - sum += data; - sumSq += data * data; - count++; - - if (count >= Nn) { - calcDelta(); - complete = true; - } - - return complete; -} - -static inline double medianOf(std::vector& list) -{ - std::sort(list.begin(), list.end()); - int count = list.size(); - int middle = count / 2; - return (count % 2 == 1) ? list[middle] : (list[middle - 1] + list[middle]) / 2.0l; -} - -void CalibrationData::calcDelta() -{ - median.Set(medianOf(xData), medianOf(yData), medianOf(zData)); - - mean = sum / count; - Vector m2 = mean * mean; - Vector d = sumSq / count - m2; - Vector s2 = (d * count) / (count - 1); - sigma = Vector(std::sqrt(d[0]), std::sqrt(d[1]), std::sqrt(d[2])); - Vector s = Vector(std::sqrt(s2[0]), std::sqrt(s2[1]), std::sqrt(s2[2])); - delta = s * Tn / std::sqrt((double)count); - Vector low = mean - delta; - Vector high = mean + delta; - - FURI_LOG_I(TAG, - "M[x] = { %f ... %f } // median = %f // avg = %f // delta = %f // sigma = %f", - low[0], high[0], median[0], mean[0], delta[0], sigma[0]); - FURI_LOG_I(TAG, - "M[y] = { %f ... %f } // median = %f // avg = %f // delta = %f // sigma = %f", - low[1], high[1], median[1], mean[1], delta[1], sigma[1]); - FURI_LOG_I(TAG, - "M[z] = { %f ... %f } // median = %f // avg = %f // delta = %f // sigma = %f", - low[2], high[2], median[2], mean[2], delta[2], sigma[2]); -} \ No newline at end of file diff --git a/applications/plugins/airmouse/tracking/calibration_data.h b/applications/plugins/airmouse/tracking/calibration_data.h deleted file mode 100644 index d47dab08d..000000000 --- a/applications/plugins/airmouse/tracking/calibration_data.h +++ /dev/null @@ -1,117 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "util/vector.h" - -#define CALIBRATION_DATA_VER (1) -#define CALIBRATION_DATA_FILE_NAME ".calibration.data" -#define CALIBRATION_DATA_PATH INT_PATH(CALIBRATION_DATA_FILE_NAME) -#define CALIBRATION_DATA_MAGIC (0x23) - -#define CALIBRATION_DATA_SAVE(x) \ - saved_struct_save( \ - CALIBRATION_DATA_PATH, \ - (x), \ - sizeof(CalibrationMedian), \ - CALIBRATION_DATA_MAGIC, \ - CALIBRATION_DATA_VER) - -#define CALIBRATION_DATA_LOAD(x) \ - saved_struct_load( \ - CALIBRATION_DATA_PATH, \ - (x), \ - sizeof(CalibrationMedian), \ - CALIBRATION_DATA_MAGIC, \ - CALIBRATION_DATA_VER) - -typedef struct { - double x; - double y; - double z; -} CalibrationMedian; - -typedef cardboard::Vector3 Vector; - -/** - * Helper class to gather some stats and store the calibration data. Right now it calculates a lot - * more stats than actually needed. Some of them are used for logging the sensors quality (and - * filing bugs), other may be required in the future, e.g. for bias. - */ -class CalibrationData { -public: - /** - * Check if the sensors were calibrated before. - * - * @return {@code true} if calibration data is available, or {@code false} otherwise. - */ - bool isComplete() { - return complete; - } - - /** Prepare to collect new calibration data. */ - void reset(); - - /** - * Retrieve the median gyroscope readings. - * - * @return Three-axis median vector. - */ - Vector getMedian() { - return median; - } - - /** - * Retrieve the mean gyroscope readings. - * - * @return Three-axis mean vector. - */ - Vector getMean() { - return mean; - } - - /** - * Retrieve the standard deviation of gyroscope readings. - * - * @return Three-axis standard deviation vector. - */ - Vector getSigma() { - return sigma; - } - - /** - * Retrieve the confidence interval size of gyroscope readings. - * - * @return Three-axis confidence interval size vector. - */ - Vector getDelta() { - return delta; - } - - /** - * Add a new gyroscope reading to the stats. - * - * @param data gyroscope values vector. - * @return {@code true} if we now have enough data for calibration, or {@code false} otherwise. - */ - bool add(Vector& data); - -private: - // Calculates the confidence interval (mean +- delta) and some other related values, like - // standard deviation, etc. See https://en.wikipedia.org/wiki/Student%27s_t-distribution - void calcDelta(); - - int count; - bool complete; - Vector sum; - Vector sumSq; - Vector mean; - Vector median; - Vector sigma; - Vector delta; - std::vector xData; - std::vector yData; - std::vector zData; -}; diff --git a/applications/plugins/airmouse/tracking/imu/bmi160.c b/applications/plugins/airmouse/tracking/imu/bmi160.c deleted file mode 100644 index 968dddd4d..000000000 --- a/applications/plugins/airmouse/tracking/imu/bmi160.c +++ /dev/null @@ -1,5988 +0,0 @@ -/** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. -* -* BSD-3-Clause -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* 3. Neither the name of the copyright holder nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -* -* @file bmi160.c -* @date 2021-10-05 -* @version v3.9.2 -* -*/ - -#include "bmi160.h" - -/* Below look up table follows the enum bmi160_int_types. - * Hence any change should match to the enum bmi160_int_types - */ -const uint8_t int_mask_lookup_table[13] = { - BMI160_INT1_SLOPE_MASK, - BMI160_INT1_SLOPE_MASK, - BMI160_INT2_LOW_STEP_DETECT_MASK, - BMI160_INT1_DOUBLE_TAP_MASK, - BMI160_INT1_SINGLE_TAP_MASK, - BMI160_INT1_ORIENT_MASK, - BMI160_INT1_FLAT_MASK, - BMI160_INT1_HIGH_G_MASK, - BMI160_INT1_LOW_G_MASK, - BMI160_INT1_NO_MOTION_MASK, - BMI160_INT2_DATA_READY_MASK, - BMI160_INT2_FIFO_FULL_MASK, - BMI160_INT2_FIFO_WM_MASK}; - -/*********************************************************************/ -/* Static function declarations */ - -/*! - * @brief This API configures the pins to fire the - * interrupt signal when it occurs - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_intr_pin_config(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the any-motion interrupt of the sensor. - * This interrupt occurs when accel values exceeds preset threshold - * for a certain period of time. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_any_motion_int(struct bmi160_int_settg* int_config, struct bmi160_dev* dev); - -/*! - * @brief This API sets tap interrupts.Interrupt is fired when - * tap movements happen. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_accel_tap_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the data ready interrupt for both accel and gyro. - * This interrupt occurs when new accel and gyro data come. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_accel_gyro_data_ready_int( - const struct bmi160_int_settg* int_config, - const struct bmi160_dev* dev); - -/*! - * @brief This API sets the significant motion interrupt of the sensor.This - * interrupt occurs when there is change in user location. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_sig_motion_int(struct bmi160_int_settg* int_config, struct bmi160_dev* dev); - -/*! - * @brief This API sets the no motion/slow motion interrupt of the sensor. - * Slow motion is similar to any motion interrupt.No motion interrupt - * occurs when slope bet. two accel values falls below preset threshold - * for preset duration. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_no_motion_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the step detection interrupt.This interrupt - * occurs when the single step causes accel values to go above - * preset threshold. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_step_detect_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the orientation interrupt of the sensor.This - * interrupt occurs when there is orientation change in the sensor - * with respect to gravitational field vector g. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_orientation_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the flat interrupt of the sensor.This interrupt - * occurs in case of flat orientation - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_flat_detect_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the low-g interrupt of the sensor.This interrupt - * occurs during free-fall. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_low_g_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the high-g interrupt of the sensor.The interrupt - * occurs if the absolute value of acceleration data of any enabled axis - * exceeds the programmed threshold and the sign of the value does not - * change for a preset duration. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t - set_accel_high_g_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the default configuration parameters of accel & gyro. - * Also maintain the previous state of configurations. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static void default_param_settg(struct bmi160_dev* dev); - -/*! - * @brief This API is used to validate the device structure pointer for - * null conditions. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t null_ptr_check(const struct bmi160_dev* dev); - -/*! - * @brief This API set the accel configuration. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_accel_conf(struct bmi160_dev* dev); - -/*! - * @brief This API gets the accel configuration. - * - * @param[out] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t get_accel_conf(struct bmi160_dev* dev); - -/*! - * @brief This API check the accel configuration. - * - * @param[in] data : Pointer to store the updated accel config. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t check_accel_config(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the accel odr. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_accel_odr(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the accel bandwidth. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_accel_bw(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the accel range. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_accel_range(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API checks the invalid settings for ODR & Bw for Accel and Gyro. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t check_invalid_settg(const struct bmi160_dev* dev); - -/*! - * @brief This API set the gyro configuration. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_gyro_conf(struct bmi160_dev* dev); - -/*! - * @brief This API get the gyro configuration. - * - * @param[out] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t get_gyro_conf(struct bmi160_dev* dev); - -/*! - * @brief This API check the gyro configuration. - * - * @param[in] data : Pointer to store the updated gyro config. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t check_gyro_config(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the gyro odr. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_gyro_odr(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the gyro bandwidth. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_gyro_bw(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API process the gyro range. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_gyro_range(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the accel power mode. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_accel_pwr(struct bmi160_dev* dev); - -/*! - * @brief This API process the undersampling setting of Accel. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t process_under_sampling(uint8_t* data, const struct bmi160_dev* dev); - -/*! - * @brief This API sets the gyro power mode. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - */ -static int8_t set_gyro_pwr(struct bmi160_dev* dev); - -/*! - * @brief This API reads accel data along with sensor time if time is requested - * by user. Kindly refer the user guide(README.md) for more info. - * - * @param[in] len : len to read no of bytes - * @param[out] accel : Structure pointer to store accel data - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - get_accel_data(uint8_t len, struct bmi160_sensor_data* accel, const struct bmi160_dev* dev); - -/*! - * @brief This API reads accel data along with sensor time if time is requested - * by user. Kindly refer the user guide(README.md) for more info. - * - * @param[in] len : len to read no of bytes - * @param[out] gyro : Structure pointer to store accel data - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - get_gyro_data(uint8_t len, struct bmi160_sensor_data* gyro, const struct bmi160_dev* dev); - -/*! - * @brief This API reads accel and gyro data along with sensor time - * if time is requested by user. - * Kindly refer the user guide(README.md) for more info. - * - * @param[in] len : len to read no of bytes - * @param[out] accel : Structure pointer to store accel data - * @param[out] gyro : Structure pointer to store accel data - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t get_accel_gyro_data( - uint8_t len, - struct bmi160_sensor_data* accel, - struct bmi160_sensor_data* gyro, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the any-motion interrupt for accel. - * - * @param[in] any_motion_int_cfg : Structure instance of - * bmi160_acc_any_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_accel_any_motion_int( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - struct bmi160_dev* dev); - -/*! - * @brief This API disable the sig-motion interrupt. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t disable_sig_motion_int(const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for any-motion interrupt. - * - * @param[in] any_motion_int_cfg : Structure instance of - * bmi160_acc_any_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_any_motion_src( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the duration and threshold of - * any-motion interrupt. - * - * @param[in] any_motion_int_cfg : Structure instance of - * bmi160_acc_any_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_any_dur_threshold( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure necessary setting of any-motion interrupt. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] any_motion_int_cfg : Structure instance of - * bmi160_acc_any_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_any_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enable the data ready interrupt. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_data_ready_int(const struct bmi160_dev* dev); - -/*! - * @brief This API enables the no motion/slow motion interrupt. - * - * @param[in] no_mot_int_cfg : Structure instance of - * bmi160_acc_no_motion_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_no_motion_int( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the interrupt PIN setting for - * no motion/slow motion interrupt. - * - * @param[in] int_config : structure instance of bmi160_int_settg. - * @param[in] no_mot_int_cfg : Structure instance of - * bmi160_acc_no_motion_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_no_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of interrupt for no motion. - * - * @param[in] no_mot_int_cfg : Structure instance of - * bmi160_acc_no_motion_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_no_motion_data_src( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the duration and threshold of - * no motion/slow motion interrupt along with selection of no/slow motion. - * - * @param[in] no_mot_int_cfg : Structure instance of - * bmi160_acc_no_motion_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_no_motion_dur_thr( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the sig-motion motion interrupt. - * - * @param[in] sig_mot_int_cfg : Structure instance of - * bmi160_acc_sig_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_sig_motion_int( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - struct bmi160_dev* dev); - -/*! - * @brief This API configure the interrupt PIN setting for - * significant motion interrupt. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] sig_mot_int_cfg : Structure instance of - * bmi160_acc_sig_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_sig_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for sig motion interrupt. - * - * @param[in] sig_mot_int_cfg : Structure instance of - * bmi160_acc_sig_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_sig_motion_data_src( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the threshold, skip and proof time of - * sig motion interrupt. - * - * @param[in] sig_mot_int_cfg : Structure instance of - * bmi160_acc_sig_mot_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_sig_dur_threshold( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the step detector interrupt. - * - * @param[in] step_detect_int_cfg : Structure instance of - * bmi160_acc_step_detect_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_step_detect_int( - const struct bmi160_acc_step_detect_int_cfg* step_detect_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the step detector parameter. - * - * @param[in] step_detect_int_cfg : Structure instance of - * bmi160_acc_step_detect_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_step_detect( - const struct bmi160_acc_step_detect_int_cfg* step_detect_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the single/double tap interrupt. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_tap_int( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the interrupt PIN setting for - * tap interrupt. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] tap_int_cfg : Structure instance of bmi160_acc_tap_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_tap_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for tap interrupt. - * - * @param[in] tap_int_cfg : Structure instance of bmi160_acc_tap_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_tap_data_src( - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the parameters of tap interrupt. - * Threshold, quite, shock, and duration. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] tap_int_cfg : Structure instance of bmi160_acc_tap_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_tap_param( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enable the external mode configuration. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_sec_if(const struct bmi160_dev* dev); - -/*! - * @brief This API configure the ODR of the auxiliary sensor. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_aux_odr(const struct bmi160_dev* dev); - -/*! - * @brief This API maps the actual burst read length set by user. - * - * @param[in] len : Pointer to store the read length. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t map_read_len(uint16_t* len, const struct bmi160_dev* dev); - -/*! - * @brief This API configure the settings of auxiliary sensor. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_aux_settg(const struct bmi160_dev* dev); - -/*! - * @brief This API extract the read data from auxiliary sensor. - * - * @param[in] map_len : burst read value. - * @param[in] reg_addr : Address of register to read. - * @param[in] aux_data : Pointer to store the read data. - * @param[in] len : length to read the data. - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t extract_aux_read( - uint16_t map_len, - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the orient interrupt. - * - * @param[in] orient_int_cfg : Structure instance of bmi160_acc_orient_int_cfg. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_orient_int( - const struct bmi160_acc_orient_int_cfg* orient_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the necessary setting of orientation interrupt. - * - * @param[in] orient_int_cfg : Structure instance of bmi160_acc_orient_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_orient_int_settg( - const struct bmi160_acc_orient_int_cfg* orient_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the flat interrupt. - * - * @param[in] flat_int : Structure instance of bmi160_acc_flat_detect_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_flat_int( - const struct bmi160_acc_flat_detect_int_cfg* flat_int, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the necessary setting of flat interrupt. - * - * @param[in] flat_int : Structure instance of bmi160_acc_flat_detect_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_flat_int_settg( - const struct bmi160_acc_flat_detect_int_cfg* flat_int, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the Low-g interrupt. - * - * @param[in] low_g_int : Structure instance of bmi160_acc_low_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_low_g_int( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of data(filter & pre-filter) for low-g interrupt. - * - * @param[in] low_g_int : Structure instance of bmi160_acc_low_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_low_g_data_src( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the necessary setting of low-g interrupt. - * - * @param[in] low_g_int : Structure instance of bmi160_acc_low_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_low_g_int_settg( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev); - -/*! - * @brief This API enables the high-g interrupt. - * - * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_high_g_int( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for high-g interrupt. - * - * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_high_g_data_src( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the necessary setting of high-g interrupt. - * - * @param[in] high_g_int_cfg : Structure instance of bmi160_acc_high_g_int_cfg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t config_high_g_int_settg( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev); - -/*! - * @brief This API configure the behavioural setting of interrupt pin. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - config_int_out_ctrl(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API configure the mode(input enable, latch or non-latch) of interrupt pin. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - config_int_latch(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API performs the self test for accelerometer of BMI160 - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t perform_accel_self_test(struct bmi160_dev* dev); - -/*! - * @brief This API enables to perform the accel self test by setting proper - * configurations to facilitate accel self test - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_accel_self_test(struct bmi160_dev* dev); - -/*! - * @brief This API performs accel self test with positive excitation - * - * @param[in] accel_pos : Structure pointer to store accel data - * for positive excitation - * @param[in] dev : structure instance of bmi160_dev - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t accel_self_test_positive_excitation( - struct bmi160_sensor_data* accel_pos, - const struct bmi160_dev* dev); - -/*! - * @brief This API performs accel self test with negative excitation - * - * @param[in] accel_neg : Structure pointer to store accel data - * for negative excitation - * @param[in] dev : structure instance of bmi160_dev - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t accel_self_test_negative_excitation( - struct bmi160_sensor_data* accel_neg, - const struct bmi160_dev* dev); - -/*! - * @brief This API validates the accel self test results - * - * @param[in] accel_pos : Structure pointer to store accel data - * for positive excitation - * @param[in] accel_neg : Structure pointer to store accel data - * for negative excitation - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error / +ve value -> Self test fail - */ -static int8_t validate_accel_self_test( - const struct bmi160_sensor_data* accel_pos, - const struct bmi160_sensor_data* accel_neg); - -/*! - * @brief This API performs the self test for gyroscope of BMI160 - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t perform_gyro_self_test(const struct bmi160_dev* dev); - -/*! - * @brief This API enables the self test bit to trigger self test for gyro - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t enable_gyro_self_test(const struct bmi160_dev* dev); - -/*! - * @brief This API validates the self test results of gyro - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t validate_gyro_self_test(const struct bmi160_dev* dev); - -/*! - * @brief This API sets FIFO full interrupt of the sensor.This interrupt - * occurs when the FIFO is full and the next full data sample would cause - * a FIFO overflow, which may delete the old samples. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - set_fifo_full_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This enable the FIFO full interrupt engine. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - enable_fifo_full_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API sets FIFO watermark interrupt of the sensor.The FIFO - * watermark interrupt is fired, when the FIFO fill level is above a fifo - * watermark. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - set_fifo_watermark_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This enable the FIFO watermark interrupt engine. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - enable_fifo_wtm_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API is used to reset the FIFO related configurations - * in the fifo_frame structure. - * - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void reset_fifo_data_structure(const struct bmi160_dev* dev); - -/*! - * @brief This API is used to read number of bytes filled - * currently in FIFO buffer. - * - * @param[in] bytes_to_read : Number of bytes available in FIFO at the - * instant which is obtained from FIFO counter. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error. - * @retval Any non zero value -> Fail - * - */ -static int8_t get_fifo_byte_counter(uint16_t* bytes_to_read, struct bmi160_dev const* dev); - -/*! - * @brief This API is used to compute the number of bytes of accel FIFO data - * which is to be parsed in header-less mode - * - * @param[out] data_index : The start index for parsing data - * @param[out] data_read_length : Number of bytes to be parsed - * @param[in] acc_frame_count : Number of accelerometer frames to be read - * @param[in] dev : Structure instance of bmi160_dev. - * - */ -static void get_accel_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* acc_frame_count, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed. - * - * @param[in,out] acc : structure instance of sensor data - * @param[in,out] idx : Index value of number of bytes parsed - * @param[in,out] acc_idx : Index value of accelerometer data - * (x,y,z axes) frames parsed - * @param[in] frame_info : It consists of either fifo_data_enable - * parameter in header-less mode or - * frame header data in header mode - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_accel_frame( - struct bmi160_sensor_data* acc, - uint16_t* idx, - uint8_t* acc_idx, - uint8_t frame_info, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data and store it in the instance of the structure bmi160_sensor_data. - * - * @param[in,out] accel_data : structure instance of sensor data - * @param[in,out] data_start_index : Index value of number of bytes parsed - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_accel_data( - struct bmi160_sensor_data* accel_data, - uint16_t data_start_index, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data in header mode. - * - * @param[in,out] accel_data : Structure instance of sensor data - * @param[in,out] accel_length : Number of accelerometer frames - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void extract_accel_header_mode( - struct bmi160_sensor_data* accel_data, - uint8_t* accel_length, - const struct bmi160_dev* dev); - -/*! - * @brief This API computes the number of bytes of gyro FIFO data - * which is to be parsed in header-less mode - * - * @param[out] data_index : The start index for parsing data - * @param[out] data_read_length : No of bytes to be parsed from FIFO buffer - * @param[in] gyro_frame_count : Number of Gyro data frames to be read - * @param[in] dev : Structure instance of bmi160_dev. - */ -static void get_gyro_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* gyro_frame_count, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the gyroscope's data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed. - * - * @param[in,out] gyro : structure instance of sensor data - * @param[in,out] idx : Index value of number of bytes parsed - * @param[in,out] gyro_idx : Index value of gyro data - * (x,y,z axes) frames parsed - * @param[in] frame_info : It consists of either fifo_data_enable - * parameter in header-less mode or - * frame header data in header mode - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_gyro_frame( - struct bmi160_sensor_data* gyro, - uint16_t* idx, - uint8_t* gyro_idx, - uint8_t frame_info, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the gyro data from the - * FIFO data and store it in the instance of the structure bmi160_sensor_data. - * - * @param[in,out] gyro_data : structure instance of sensor data - * @param[in,out] data_start_index : Index value of number of bytes parsed - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_gyro_data( - struct bmi160_sensor_data* gyro_data, - uint16_t data_start_index, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the gyro data from the - * FIFO data in header mode. - * - * @param[in,out] gyro_data : Structure instance of sensor data - * @param[in,out] gyro_length : Number of gyro frames - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void extract_gyro_header_mode( - struct bmi160_sensor_data* gyro_data, - uint8_t* gyro_length, - const struct bmi160_dev* dev); - -/*! - * @brief This API computes the number of bytes of aux FIFO data - * which is to be parsed in header-less mode - * - * @param[out] data_index : The start index for parsing data - * @param[out] data_read_length : No of bytes to be parsed from FIFO buffer - * @param[in] aux_frame_count : Number of Aux data frames to be read - * @param[in] dev : Structure instance of bmi160_dev. - */ -static void get_aux_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* aux_frame_count, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the aux's data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed - * - * @param[in,out] aux_data : structure instance of sensor data - * @param[in,out] idx : Index value of number of bytes parsed - * @param[in,out] aux_index : Index value of gyro data - * (x,y,z axes) frames parsed - * @param[in] frame_info : It consists of either fifo_data_enable - * parameter in header-less mode or - * frame header data in header mode - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_aux_frame( - struct bmi160_aux_data* aux_data, - uint16_t* idx, - uint8_t* aux_index, - uint8_t frame_info, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the aux data from the - * FIFO data and store it in the instance of the structure bmi160_aux_data. - * - * @param[in,out] aux_data : structure instance of sensor data - * @param[in,out] data_start_index : Index value of number of bytes parsed - * @param[in] dev : structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_aux_data( - struct bmi160_aux_data* aux_data, - uint16_t data_start_index, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse the aux data from the - * FIFO data in header mode. - * - * @param[in,out] aux_data : Structure instance of sensor data - * @param[in,out] aux_length : Number of aux frames - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void extract_aux_header_mode( - struct bmi160_aux_data* aux_data, - uint8_t* aux_length, - const struct bmi160_dev* dev); - -/*! - * @brief This API checks the presence of non-valid frames in the read fifo data. - * - * @param[in,out] data_index : The index of the current data to - * be parsed from fifo data - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void check_frame_validity(uint16_t* data_index, const struct bmi160_dev* dev); - -/*! - * @brief This API is used to move the data index ahead of the - * current_frame_length parameter when unnecessary FIFO data appears while - * extracting the user specified data. - * - * @param[in,out] data_index : Index of the FIFO data which - * is to be moved ahead of the - * current_frame_length - * @param[in] current_frame_length : Number of bytes in a particular frame - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void move_next_frame( - uint16_t* data_index, - uint8_t current_frame_length, - const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse and store the sensor time from the - * FIFO data in the structure instance dev. - * - * @param[in,out] data_index : Index of the FIFO data which - * has the sensor time. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_sensortime_frame(uint16_t* data_index, const struct bmi160_dev* dev); - -/*! - * @brief This API is used to parse and store the skipped_frame_count from - * the FIFO data in the structure instance dev. - * - * @param[in,out] data_index : Index of the FIFO data which - * has the skipped frame count. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static void unpack_skipped_frame(uint16_t* data_index, const struct bmi160_dev* dev); - -/*! - * @brief This API is used to get the FOC status from the sensor - * - * @param[in,out] foc_status : Result of FOC status. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t get_foc_status(uint8_t* foc_status, struct bmi160_dev const* dev); - -/*! - * @brief This API is used to configure the offset enable bits in the sensor - * - * @param[in,out] foc_conf : Structure instance of bmi160_foc_conf which - * has the FOC and offset configurations - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - configure_offset_enable(const struct bmi160_foc_conf* foc_conf, struct bmi160_dev const* dev); - -/*! - * @brief This API is used to trigger the FOC in the sensor - * - * @param[in,out] offset : Structure instance of bmi160_offsets which - * reads and stores the offset values after FOC - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t trigger_foc(struct bmi160_offsets* offset, struct bmi160_dev const* dev); - -/*! - * @brief This API is used to map/unmap the Dataready(Accel & Gyro), FIFO full - * and FIFO watermark interrupt - * - * @param[in] int_config : Structure instance of bmi160_int_settg which - * stores the interrupt type and interrupt channel - * configurations to map/unmap the interrupt pins - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - map_hardware_interrupt(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*! - * @brief This API is used to map/unmap the Any/Sig motion, Step det/Low-g, - * Double tap, Single tap, Orientation, Flat, High-G, Nomotion interrupt pins. - * - * @param[in] int_config : Structure instance of bmi160_int_settg which - * stores the interrupt type and interrupt channel - * configurations to map/unmap the interrupt pins - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval zero -> Success / -ve value -> Error - */ -static int8_t - map_feature_interrupt(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev); - -/*********************** User function definitions ****************************/ - -/*! - * @brief This API reads the data from the given register address - * of sensor. - */ -int8_t - bmi160_get_regs(uint8_t reg_addr, uint8_t* data, uint16_t len, const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - /* Null-pointer check */ - if((dev == NULL) || (dev->read == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else if(len == 0) { - rslt = BMI160_E_READ_WRITE_LENGTH_INVALID; - } else { - /* Configuring reg_addr for SPI Interface */ - if(dev->intf == BMI160_SPI_INTF) { - reg_addr = (reg_addr | BMI160_SPI_RD_MASK); - } - - rslt = dev->read(dev->id, reg_addr, data, len); - } - - return rslt; -} - -/*! - * @brief This API writes the given data to the register address - * of sensor. - */ -int8_t - bmi160_set_regs(uint8_t reg_addr, uint8_t* data, uint16_t len, const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - uint8_t count = 0; - - /* Null-pointer check */ - if((dev == NULL) || (dev->write == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else if(len == 0) { - rslt = BMI160_E_READ_WRITE_LENGTH_INVALID; - } else { - /* Configuring reg_addr for SPI Interface */ - if(dev->intf == BMI160_SPI_INTF) { - reg_addr = (reg_addr & BMI160_SPI_WR_MASK); - } - - if((dev->prev_accel_cfg.power == BMI160_ACCEL_NORMAL_MODE) || - (dev->prev_gyro_cfg.power == BMI160_GYRO_NORMAL_MODE)) { - rslt = dev->write(dev->id, reg_addr, data, len); - - /* Kindly refer bmi160 data sheet section 3.2.4 */ - dev->delay_ms(1); - - } else { - /*Burst write is not allowed in - * suspend & low power mode */ - for(; count < len; count++) { - rslt = dev->write(dev->id, reg_addr, &data[count], 1); - reg_addr++; - - /* Kindly refer bmi160 data sheet section 3.2.4 */ - dev->delay_ms(1); - } - } - - if(rslt != BMI160_OK) { - rslt = BMI160_E_COM_FAIL; - } - } - - return rslt; -} - -/*! - * @brief This API is the entry point for sensor.It performs - * the selection of I2C/SPI read mechanism according to the - * selected interface and reads the chip-id of bmi160 sensor. - */ -int8_t bmi160_init(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data; - uint8_t try = 3; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - - /* Dummy read of 0x7F register to enable SPI Interface - * if SPI is used */ - if((rslt == BMI160_OK) && (dev->intf == BMI160_SPI_INTF)) { - rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev); - } - - if(rslt == BMI160_OK) { - /* Assign chip id as zero */ - dev->chip_id = 0; - - while((try--) && (dev->chip_id != BMI160_CHIP_ID)) { - /* Read chip_id */ - rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &dev->chip_id, 1, dev); - } - - if((rslt == BMI160_OK) && (dev->chip_id == BMI160_CHIP_ID)) { - dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED; - - /* Soft reset */ - rslt = bmi160_soft_reset(dev); - } else { - rslt = BMI160_E_DEV_NOT_FOUND; - } - } - - return rslt; -} - -/*! - * @brief This API resets and restarts the device. - * All register values are overwritten with default parameters. - */ -int8_t bmi160_soft_reset(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = BMI160_SOFT_RESET_CMD; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Reset the device */ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &data, 1, dev); - dev->delay_ms(BMI160_SOFT_RESET_DELAY_MS); - if((rslt == BMI160_OK) && (dev->intf == BMI160_SPI_INTF)) { - /* Dummy read of 0x7F register to enable SPI Interface - * if SPI is used */ - rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev); - } - - if(rslt == BMI160_OK) { - /* Update the default parameters */ - default_param_settg(dev); - } - } - - return rslt; -} - -/*! - * @brief This API configures the power mode, range and bandwidth - * of sensor. - */ -int8_t bmi160_set_sens_conf(struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = set_accel_conf(dev); - if(rslt == BMI160_OK) { - rslt = set_gyro_conf(dev); - if(rslt == BMI160_OK) { - /* write power mode for accel and gyro */ - rslt = bmi160_set_power_mode(dev); - if(rslt == BMI160_OK) { - rslt = check_invalid_settg(dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API gets accel and gyro configurations. - */ -int8_t bmi160_get_sens_conf(struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = get_accel_conf(dev); - if(rslt == BMI160_OK) { - rslt = get_gyro_conf(dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets the power mode of the sensor. - */ -int8_t bmi160_set_power_mode(struct bmi160_dev* dev) { - int8_t rslt = 0; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = set_accel_pwr(dev); - if(rslt == BMI160_OK) { - rslt = set_gyro_pwr(dev); - } - } - - return rslt; -} - -/*! - * @brief This API gets the power mode of the sensor. - */ -int8_t bmi160_get_power_mode(struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t power_mode = 0; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_get_regs(BMI160_PMU_STATUS_ADDR, &power_mode, 1, dev); - if(rslt == BMI160_OK) { - /* Power mode of the accel, gyro sensor is obtained */ - dev->gyro_cfg.power = BMI160_GET_BITS(power_mode, BMI160_GYRO_POWER_MODE); - dev->accel_cfg.power = BMI160_GET_BITS(power_mode, BMI160_ACCEL_POWER_MODE); - } - } - - return rslt; -} - -/*! - * @brief This API reads sensor data, stores it in - * the bmi160_sensor_data structure pointer passed by the user. - */ -int8_t bmi160_get_sensor_data( - uint8_t select_sensor, - struct bmi160_sensor_data* accel, - struct bmi160_sensor_data* gyro, - const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - uint8_t time_sel; - uint8_t sen_sel; - uint8_t len = 0; - - /*Extract the sensor and time select information*/ - sen_sel = select_sensor & BMI160_SEN_SEL_MASK; - time_sel = ((sen_sel & BMI160_TIME_SEL) >> 2); - sen_sel = sen_sel & (BMI160_ACCEL_SEL | BMI160_GYRO_SEL); - if(time_sel == 1) { - len = 3; - } - - /* Null-pointer check */ - if(dev != NULL) { - switch(sen_sel) { - case BMI160_ACCEL_ONLY: - - /* Null-pointer check */ - if(accel == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = get_accel_data(len, accel, dev); - } - - break; - case BMI160_GYRO_ONLY: - - /* Null-pointer check */ - if(gyro == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = get_gyro_data(len, gyro, dev); - } - - break; - case BMI160_BOTH_ACCEL_AND_GYRO: - - /* Null-pointer check */ - if((gyro == NULL) || (accel == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = get_accel_gyro_data(len, accel, gyro, dev); - } - - break; - default: - rslt = BMI160_E_INVALID_INPUT; - break; - } - } else { - rslt = BMI160_E_NULL_PTR; - } - - return rslt; -} - -/*! - * @brief This API configures the necessary interrupt based on - * the user settings in the bmi160_int_settg structure instance. - */ -int8_t bmi160_set_int_config(struct bmi160_int_settg* int_config, struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - switch(int_config->int_type) { - case BMI160_ACC_ANY_MOTION_INT: - - /*Any-motion interrupt*/ - rslt = set_accel_any_motion_int(int_config, dev); - break; - case BMI160_ACC_SIG_MOTION_INT: - - /* Significant motion interrupt */ - rslt = set_accel_sig_motion_int(int_config, dev); - break; - case BMI160_ACC_SLOW_NO_MOTION_INT: - - /* Slow or no motion interrupt */ - rslt = set_accel_no_motion_int(int_config, dev); - break; - case BMI160_ACC_DOUBLE_TAP_INT: - case BMI160_ACC_SINGLE_TAP_INT: - - /* Double tap and single tap Interrupt */ - rslt = set_accel_tap_int(int_config, dev); - break; - case BMI160_STEP_DETECT_INT: - - /* Step detector interrupt */ - rslt = set_accel_step_detect_int(int_config, dev); - break; - case BMI160_ACC_ORIENT_INT: - - /* Orientation interrupt */ - rslt = set_accel_orientation_int(int_config, dev); - break; - case BMI160_ACC_FLAT_INT: - - /* Flat detection interrupt */ - rslt = set_accel_flat_detect_int(int_config, dev); - break; - case BMI160_ACC_LOW_G_INT: - - /* Low-g interrupt */ - rslt = set_accel_low_g_int(int_config, dev); - break; - case BMI160_ACC_HIGH_G_INT: - - /* High-g interrupt */ - rslt = set_accel_high_g_int(int_config, dev); - break; - case BMI160_ACC_GYRO_DATA_RDY_INT: - - /* Data ready interrupt */ - rslt = set_accel_gyro_data_ready_int(int_config, dev); - break; - case BMI160_ACC_GYRO_FIFO_FULL_INT: - - /* Fifo full interrupt */ - rslt = set_fifo_full_int(int_config, dev); - break; - case BMI160_ACC_GYRO_FIFO_WATERMARK_INT: - - /* Fifo water-mark interrupt */ - rslt = set_fifo_watermark_int(int_config, dev); - break; - case BMI160_FIFO_TAG_INT_PIN: - - /* Fifo tagging feature support */ - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - break; - default: - break; - } - - return rslt; -} - -/*! - * @brief This API enables or disable the step counter feature. - * 1 - enable step counter (0 - disable) - */ -int8_t bmi160_set_step_counter(uint8_t step_cnt_enable, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_get_regs(BMI160_INT_STEP_CONFIG_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - if(step_cnt_enable == BMI160_ENABLE) { - data |= (uint8_t)(step_cnt_enable << 3); - } else { - data &= ~BMI160_STEP_COUNT_EN_BIT_MASK; - } - - rslt = bmi160_set_regs(BMI160_INT_STEP_CONFIG_1_ADDR, &data, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API reads the step counter value. - */ -int8_t bmi160_read_step_counter(uint16_t* step_val, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[2] = {0, 0}; - uint16_t msb = 0; - uint8_t lsb = 0; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_get_regs(BMI160_INT_STEP_CNT_0_ADDR, data, 2, dev); - if(rslt == BMI160_OK) { - lsb = data[0]; - msb = data[1] << 8; - *step_val = msb | lsb; - } - } - - return rslt; -} - -/*! - * @brief This API reads the mention no of byte of data from the given - * register address of auxiliary sensor. - */ -int8_t bmi160_aux_read( - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - uint16_t map_len = 0; - - /* Null-pointer check */ - if((dev == NULL) || (dev->read == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - if(dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) { - rslt = map_read_len(&map_len, dev); - if(rslt == BMI160_OK) { - rslt = extract_aux_read(map_len, reg_addr, aux_data, len, dev); - } - } else { - rslt = BMI160_E_INVALID_INPUT; - } - } - - return rslt; -} - -/*! - * @brief This API writes the mention no of byte of data to the given - * register address of auxiliary sensor. - */ -int8_t bmi160_aux_write( - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - uint8_t count = 0; - - /* Null-pointer check */ - if((dev == NULL) || (dev->write == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - for(; count < len; count++) { - /* set data to write */ - rslt = bmi160_set_regs(BMI160_AUX_IF_4_ADDR, aux_data, 1, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - if(rslt == BMI160_OK) { - /* set address to write */ - rslt = bmi160_set_regs(BMI160_AUX_IF_3_ADDR, ®_addr, 1, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - if(rslt == BMI160_OK && (count < len - 1)) { - aux_data++; - reg_addr++; - } - } - } - } - - return rslt; -} - -/*! - * @brief This API initialize the auxiliary sensor - * in order to access it. - */ -int8_t bmi160_aux_init(const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - if(dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) { - /* Configures the auxiliary sensor interface settings */ - rslt = config_aux_settg(dev); - } else { - rslt = BMI160_E_INVALID_INPUT; - } - } - - return rslt; -} - -/*! - * @brief This API is used to setup the auxiliary sensor of bmi160 in auto mode - * Thus enabling the auto update of 8 bytes of data from auxiliary sensor - * to BMI160 register address 0x04 to 0x0B - */ -int8_t bmi160_set_aux_auto_mode(uint8_t* data_addr, struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - if(dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) { - /* Write the aux. address to read in 0x4D of BMI160*/ - rslt = bmi160_set_regs(BMI160_AUX_IF_2_ADDR, data_addr, 1, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - if(rslt == BMI160_OK) { - /* Configure the polling ODR for - * auxiliary sensor */ - rslt = config_aux_odr(dev); - if(rslt == BMI160_OK) { - /* Disable the aux. manual mode, i.e aux. - * sensor is in auto-mode (data-mode) */ - dev->aux_cfg.manual_enable = BMI160_DISABLE; - rslt = bmi160_config_aux_mode(dev); - - /* Auxiliary sensor data is obtained - * in auto mode from this point */ - } - } - } else { - rslt = BMI160_E_INVALID_INPUT; - } - } - - return rslt; -} - -/*! - * @brief This API configures the 0x4C register and settings like - * Auxiliary sensor manual enable/ disable and aux burst read length. - */ -int8_t bmi160_config_aux_mode(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t aux_if[2] = {(uint8_t)(dev->aux_cfg.aux_i2c_addr * 2), 0}; - - rslt = bmi160_get_regs(BMI160_AUX_IF_1_ADDR, &aux_if[1], 1, dev); - if(rslt == BMI160_OK) { - /* update the Auxiliary interface to manual/auto mode */ - aux_if[1] = BMI160_SET_BITS(aux_if[1], BMI160_MANUAL_MODE_EN, dev->aux_cfg.manual_enable); - - /* update the burst read length defined by user */ - aux_if[1] = - BMI160_SET_BITS_POS_0(aux_if[1], BMI160_AUX_READ_BURST, dev->aux_cfg.aux_rd_burst_len); - - /* Set the secondary interface address and manual mode - * along with burst read length */ - rslt = bmi160_set_regs(BMI160_AUX_IF_0_ADDR, &aux_if[0], 2, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - } - - return rslt; -} - -/*! - * @brief This API is used to read the raw uncompensated auxiliary sensor - * data of 8 bytes from BMI160 register address 0x04 to 0x0B - */ -int8_t bmi160_read_aux_data_auto_mode(uint8_t* aux_data, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - if((dev->aux_cfg.aux_sensor_enable == BMI160_ENABLE) && - (dev->aux_cfg.manual_enable == BMI160_DISABLE)) { - /* Read the aux. sensor's raw data */ - rslt = bmi160_get_regs(BMI160_AUX_DATA_ADDR, aux_data, 8, dev); - } else { - rslt = BMI160_E_INVALID_INPUT; - } - } - - return rslt; -} - -/*! - * @brief This is used to perform self test of accel/gyro of the BMI160 sensor - */ -int8_t bmi160_perform_self_test(uint8_t select_sensor, struct bmi160_dev* dev) { - int8_t rslt; - int8_t self_test_rslt = 0; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Proceed if null check is fine */ - switch(select_sensor) { - case BMI160_ACCEL_ONLY: - rslt = perform_accel_self_test(dev); - break; - case BMI160_GYRO_ONLY: - - /* Set the power mode as normal mode */ - dev->gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; - rslt = bmi160_set_power_mode(dev); - - /* Perform gyro self test */ - if(rslt == BMI160_OK) { - /* Perform gyro self test */ - rslt = perform_gyro_self_test(dev); - } - - break; - default: - rslt = BMI160_E_INVALID_INPUT; - break; - } - - /* Check to ensure bus error does not occur */ - if(rslt >= BMI160_OK) { - /* Store the status of self test result */ - self_test_rslt = rslt; - - /* Perform soft reset */ - rslt = bmi160_soft_reset(dev); - } - - /* Check to ensure bus operations are success */ - if(rslt == BMI160_OK) { - /* Restore self_test_rslt as return value */ - rslt = self_test_rslt; - } - } - - return rslt; -} - -/*! - * @brief This API reads the data from fifo buffer. - */ -int8_t bmi160_get_fifo_data(struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint16_t bytes_to_read = 0; - uint16_t user_fifo_len = 0; - - /* check the bmi160 structure as NULL*/ - if((dev == NULL) || (dev->fifo->data == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - reset_fifo_data_structure(dev); - - /* get current FIFO fill-level*/ - rslt = get_fifo_byte_counter(&bytes_to_read, dev); - if(rslt == BMI160_OK) { - user_fifo_len = dev->fifo->length; - if((dev->fifo->length > bytes_to_read)) { - /* Handling the case where user requests - * more data than available in FIFO */ - dev->fifo->length = bytes_to_read; - } - - if((dev->fifo->fifo_time_enable == BMI160_FIFO_TIME_ENABLE) && - (bytes_to_read + BMI160_FIFO_BYTES_OVERREAD <= user_fifo_len)) { - /* Handling case of sensor time availability*/ - dev->fifo->length = dev->fifo->length + BMI160_FIFO_BYTES_OVERREAD; - } - - /* read only the filled bytes in the FIFO Buffer */ - rslt = bmi160_get_regs(BMI160_FIFO_DATA_ADDR, dev->fifo->data, dev->fifo->length, dev); - } - } - - return rslt; -} - -/*! - * @brief This API writes fifo_flush command to command register.This - * action clears all data in the Fifo without changing fifo configuration - * settings - */ -int8_t bmi160_set_fifo_flush(const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t data = BMI160_FIFO_FLUSH_VALUE; - uint8_t reg_addr = BMI160_COMMAND_REG_ADDR; - - /* Check the bmi160_dev structure for NULL address*/ - if(dev == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); - } - - return rslt; -} - -/*! - * @brief This API sets the FIFO configuration in the sensor. - */ -int8_t bmi160_set_fifo_config(uint8_t config, uint8_t enable, struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint8_t data = 0; - uint8_t reg_addr = BMI160_FIFO_CONFIG_1_ADDR; - uint8_t fifo_config = config & BMI160_FIFO_CONFIG_1_MASK; - - /* Check the bmi160_dev structure for NULL address*/ - if(dev == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev); - if(rslt == BMI160_OK) { - if(fifo_config > 0) { - if(enable == BMI160_ENABLE) { - data = data | fifo_config; - } else { - data = data & (~fifo_config); - } - } - - /* write fifo frame content configuration*/ - rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); - if(rslt == BMI160_OK) { - /* read fifo frame content configuration*/ - rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev); - if(rslt == BMI160_OK) { - /* extract fifo header enabled status */ - dev->fifo->fifo_header_enable = data & BMI160_FIFO_HEAD_ENABLE; - - /* extract accel/gyr/aux. data enabled status */ - dev->fifo->fifo_data_enable = data & BMI160_FIFO_M_G_A_ENABLE; - - /* extract fifo sensor time enabled status */ - dev->fifo->fifo_time_enable = data & BMI160_FIFO_TIME_ENABLE; - } - } - } - } - - return rslt; -} - -/*! @brief This API is used to configure the down sampling ratios of - * the accel and gyro data for FIFO.Also, it configures filtered or - * pre-filtered data for accel and gyro. - * - */ -int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t data = 0; - uint8_t reg_addr = BMI160_FIFO_DOWN_ADDR; - - /* Check the bmi160_dev structure for NULL address*/ - if(dev == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev); - if(rslt == BMI160_OK) { - data = data | fifo_down; - rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets the FIFO watermark level in the sensor. - * - */ -int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t data = fifo_wm; - uint8_t reg_addr = BMI160_FIFO_CONFIG_0_ADDR; - - /* Check the bmi160_dev structure for NULL address*/ - if(dev == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev); - } - - return rslt; -} - -/*! - * @brief This API parses and extracts the accelerometer frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the "accel_data" structure instance. - */ -int8_t bmi160_extract_accel( - struct bmi160_sensor_data* accel_data, - uint8_t* accel_length, - struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint16_t data_index = 0; - uint16_t data_read_length = 0; - uint8_t accel_index = 0; - uint8_t fifo_data_enable = 0; - - if(dev == NULL || dev->fifo == NULL || dev->fifo->data == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Parsing the FIFO data in header-less mode */ - if(dev->fifo->fifo_header_enable == 0) { - /* Number of bytes to be parsed from FIFO */ - get_accel_len_to_parse(&data_index, &data_read_length, accel_length, dev); - for(; data_index < data_read_length;) { - /*Check for the availability of next two bytes of FIFO data */ - check_frame_validity(&data_index, dev); - fifo_data_enable = dev->fifo->fifo_data_enable; - unpack_accel_frame(accel_data, &data_index, &accel_index, fifo_data_enable, dev); - } - - /* update number of accel data read*/ - *accel_length = accel_index; - - /*update the accel byte index*/ - dev->fifo->accel_byte_start_idx = data_index; - } else { - /* Parsing the FIFO data in header mode */ - extract_accel_header_mode(accel_data, accel_length, dev); - } - } - - return rslt; -} - -/*! - * @brief This API parses and extracts the gyro frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the "gyro_data" structure instance. - */ -int8_t bmi160_extract_gyro( - struct bmi160_sensor_data* gyro_data, - uint8_t* gyro_length, - struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint16_t data_index = 0; - uint16_t data_read_length = 0; - uint8_t gyro_index = 0; - uint8_t fifo_data_enable = 0; - - if(dev == NULL || dev->fifo->data == NULL) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Parsing the FIFO data in header-less mode */ - if(dev->fifo->fifo_header_enable == 0) { - /* Number of bytes to be parsed from FIFO */ - get_gyro_len_to_parse(&data_index, &data_read_length, gyro_length, dev); - for(; data_index < data_read_length;) { - /*Check for the availability of next two bytes of FIFO data */ - check_frame_validity(&data_index, dev); - fifo_data_enable = dev->fifo->fifo_data_enable; - unpack_gyro_frame(gyro_data, &data_index, &gyro_index, fifo_data_enable, dev); - } - - /* update number of gyro data read */ - *gyro_length = gyro_index; - - /* update the gyro byte index */ - dev->fifo->gyro_byte_start_idx = data_index; - } else { - /* Parsing the FIFO data in header mode */ - extract_gyro_header_mode(gyro_data, gyro_length, dev); - } - } - - return rslt; -} - -/*! - * @brief This API parses and extracts the aux frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the "aux_data" structure instance. - */ -int8_t bmi160_extract_aux( - struct bmi160_aux_data* aux_data, - uint8_t* aux_len, - struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint16_t data_index = 0; - uint16_t data_read_length = 0; - uint8_t aux_index = 0; - uint8_t fifo_data_enable = 0; - - if((dev == NULL) || (dev->fifo->data == NULL) || (aux_data == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Parsing the FIFO data in header-less mode */ - if(dev->fifo->fifo_header_enable == 0) { - /* Number of bytes to be parsed from FIFO */ - get_aux_len_to_parse(&data_index, &data_read_length, aux_len, dev); - for(; data_index < data_read_length;) { - /* Check for the availability of next two - * bytes of FIFO data */ - check_frame_validity(&data_index, dev); - fifo_data_enable = dev->fifo->fifo_data_enable; - unpack_aux_frame(aux_data, &data_index, &aux_index, fifo_data_enable, dev); - } - - /* update number of aux data read */ - *aux_len = aux_index; - - /* update the aux byte index */ - dev->fifo->aux_byte_start_idx = data_index; - } else { - /* Parsing the FIFO data in header mode */ - extract_aux_header_mode(aux_data, aux_len, dev); - } - } - - return rslt; -} - -/*! - * @brief This API starts the FOC of accel and gyro - * - * @note FOC should not be used in low-power mode of sensor - * - * @note Accel FOC targets values of +1g , 0g , -1g - * Gyro FOC always targets value of 0 dps - */ -int8_t bmi160_start_foc( - const struct bmi160_foc_conf* foc_conf, - struct bmi160_offsets* offset, - struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t data; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Set the offset enable bits */ - rslt = configure_offset_enable(foc_conf, dev); - if(rslt == BMI160_OK) { - /* Read the FOC config from the sensor */ - rslt = bmi160_get_regs(BMI160_FOC_CONF_ADDR, &data, 1, dev); - - /* Set the FOC config for gyro */ - data = BMI160_SET_BITS(data, BMI160_GYRO_FOC_EN, foc_conf->foc_gyr_en); - - /* Set the FOC config for accel xyz axes */ - data = BMI160_SET_BITS(data, BMI160_ACCEL_FOC_X_CONF, foc_conf->foc_acc_x); - data = BMI160_SET_BITS(data, BMI160_ACCEL_FOC_Y_CONF, foc_conf->foc_acc_y); - data = BMI160_SET_BITS_POS_0(data, BMI160_ACCEL_FOC_Z_CONF, foc_conf->foc_acc_z); - if(rslt == BMI160_OK) { - /* Set the FOC config in the sensor */ - rslt = bmi160_set_regs(BMI160_FOC_CONF_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* Procedure to trigger - * FOC and check status */ - rslt = trigger_foc(offset, dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API reads and stores the offset values of accel and gyro - */ -int8_t bmi160_get_offsets(struct bmi160_offsets* offset, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[7]; - uint8_t lsb, msb; - int16_t offset_msb, offset_lsb; - int16_t offset_data; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Read the FOC config from the sensor */ - rslt = bmi160_get_regs(BMI160_OFFSET_ADDR, data, 7, dev); - - /* Accel offsets */ - offset->off_acc_x = (int8_t)data[0]; - offset->off_acc_y = (int8_t)data[1]; - offset->off_acc_z = (int8_t)data[2]; - - /* Gyro x-axis offset */ - lsb = data[3]; - msb = BMI160_GET_BITS_POS_0(data[6], BMI160_GYRO_OFFSET_X); - offset_msb = (int16_t)(msb << 14); - offset_lsb = lsb << 6; - offset_data = offset_msb | offset_lsb; - - /* Divide by 64 to get the Right shift by 6 value */ - offset->off_gyro_x = (int16_t)(offset_data / 64); - - /* Gyro y-axis offset */ - lsb = data[4]; - msb = BMI160_GET_BITS(data[6], BMI160_GYRO_OFFSET_Y); - offset_msb = (int16_t)(msb << 14); - offset_lsb = lsb << 6; - offset_data = offset_msb | offset_lsb; - - /* Divide by 64 to get the Right shift by 6 value */ - offset->off_gyro_y = (int16_t)(offset_data / 64); - - /* Gyro z-axis offset */ - lsb = data[5]; - msb = BMI160_GET_BITS(data[6], BMI160_GYRO_OFFSET_Z); - offset_msb = (int16_t)(msb << 14); - offset_lsb = lsb << 6; - offset_data = offset_msb | offset_lsb; - - /* Divide by 64 to get the Right shift by 6 value */ - offset->off_gyro_z = (int16_t)(offset_data / 64); - } - - return rslt; -} - -/*! - * @brief This API writes the offset values of accel and gyro to - * the sensor but these values will be reset on POR or soft reset. - */ -int8_t bmi160_set_offsets( - const struct bmi160_foc_conf* foc_conf, - const struct bmi160_offsets* offset, - struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t data[7]; - uint8_t x_msb, y_msb, z_msb; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Update the accel offset */ - data[0] = (uint8_t)offset->off_acc_x; - data[1] = (uint8_t)offset->off_acc_y; - data[2] = (uint8_t)offset->off_acc_z; - - /* Update the LSB of gyro offset */ - data[3] = BMI160_GET_LSB(offset->off_gyro_x); - data[4] = BMI160_GET_LSB(offset->off_gyro_y); - data[5] = BMI160_GET_LSB(offset->off_gyro_z); - - /* Update the MSB of gyro offset */ - x_msb = BMI160_GET_BITS(offset->off_gyro_x, BMI160_GYRO_OFFSET); - y_msb = BMI160_GET_BITS(offset->off_gyro_y, BMI160_GYRO_OFFSET); - z_msb = BMI160_GET_BITS(offset->off_gyro_z, BMI160_GYRO_OFFSET); - data[6] = (uint8_t)(z_msb << 4 | y_msb << 2 | x_msb); - - /* Set the offset enable/disable for gyro and accel */ - data[6] = BMI160_SET_BITS(data[6], BMI160_GYRO_OFFSET_EN, foc_conf->gyro_off_en); - data[6] = BMI160_SET_BITS(data[6], BMI160_ACCEL_OFFSET_EN, foc_conf->acc_off_en); - - /* Set the offset config and values in the sensor */ - rslt = bmi160_set_regs(BMI160_OFFSET_ADDR, data, 7, dev); - } - - return rslt; -} - -/*! - * @brief This API writes the image registers values to NVM which is - * stored even after POR or soft reset - */ -int8_t bmi160_update_nvm(struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t data; - uint8_t cmd = BMI160_NVM_BACKUP_EN; - - /* Read the nvm_prog_en configuration */ - rslt = bmi160_get_regs(BMI160_CONF_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - data = BMI160_SET_BITS(data, BMI160_NVM_UPDATE, 1); - - /* Set the nvm_prog_en bit in the sensor */ - rslt = bmi160_set_regs(BMI160_CONF_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* Update NVM */ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &cmd, 1, dev); - if(rslt == BMI160_OK) { - /* Check for NVM ready status */ - rslt = bmi160_get_regs(BMI160_STATUS_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - data = BMI160_GET_BITS(data, BMI160_NVM_STATUS); - if(data != BMI160_ENABLE) { - /* Delay to update NVM */ - dev->delay_ms(25); - } - } - } - } - } - - return rslt; -} - -/*! - * @brief This API gets the interrupt status from the sensor. - */ -int8_t bmi160_get_int_status( - enum bmi160_int_status_sel int_status_sel, - union bmi160_int_status* int_status, - struct bmi160_dev const* dev) { - int8_t rslt = 0; - - /* To get the status of all interrupts */ - if(int_status_sel == BMI160_INT_STATUS_ALL) { - rslt = bmi160_get_regs(BMI160_INT_STATUS_ADDR, &int_status->data[0], 4, dev); - } else { - if(int_status_sel & BMI160_INT_STATUS_0) { - rslt = bmi160_get_regs(BMI160_INT_STATUS_ADDR, &int_status->data[0], 1, dev); - } - - if(int_status_sel & BMI160_INT_STATUS_1) { - rslt = bmi160_get_regs(BMI160_INT_STATUS_ADDR + 1, &int_status->data[1], 1, dev); - } - - if(int_status_sel & BMI160_INT_STATUS_2) { - rslt = bmi160_get_regs(BMI160_INT_STATUS_ADDR + 2, &int_status->data[2], 1, dev); - } - - if(int_status_sel & BMI160_INT_STATUS_3) { - rslt = bmi160_get_regs(BMI160_INT_STATUS_ADDR + 3, &int_status->data[3], 1, dev); - } - } - - return rslt; -} - -/*********************** Local function definitions ***************************/ - -/*! - * @brief This API sets the any-motion interrupt of the sensor. - * This interrupt occurs when accel values exceeds preset threshold - * for a certain period of time. - */ -static int8_t - set_accel_any_motion_int(struct bmi160_int_settg* int_config, struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg = - &(int_config->int_type_cfg.acc_any_motion_int); - rslt = enable_accel_any_motion_int(any_motion_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_any_motion_int_settg(int_config, any_motion_int_cfg, dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets tap interrupts.Interrupt is fired when - * tap movements happen. - */ -static int8_t - set_accel_tap_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_tap_int_cfg* tap_int_cfg = &(int_config->int_type_cfg.acc_tap_int); - rslt = enable_tap_int(int_config, tap_int_cfg, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_tap_int_settg(int_config, tap_int_cfg, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the data ready interrupt for both accel and gyro. - * This interrupt occurs when new accel and gyro data comes. - */ -static int8_t set_accel_gyro_data_ready_int( - const struct bmi160_int_settg* int_config, - const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - rslt = enable_data_ready_int(dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_hardware_interrupt(int_config, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the significant motion interrupt of the sensor.This - * interrupt occurs when there is change in user location. - */ -static int8_t - set_accel_sig_motion_int(struct bmi160_int_settg* int_config, struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg = - &(int_config->int_type_cfg.acc_sig_motion_int); - rslt = enable_sig_motion_int(sig_mot_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_sig_motion_int_settg(int_config, sig_mot_int_cfg, dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets the no motion/slow motion interrupt of the sensor. - * Slow motion is similar to any motion interrupt.No motion interrupt - * occurs when slope bet. two accel values falls below preset threshold - * for preset duration. - */ -static int8_t - set_accel_no_motion_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg = - &(int_config->int_type_cfg.acc_no_motion_int); - rslt = enable_no_motion_int(no_mot_int_cfg, dev); - if(rslt == BMI160_OK) { - /* Configure the INT PIN settings*/ - rslt = config_no_motion_int_settg(int_config, no_mot_int_cfg, dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets the step detection interrupt.This interrupt - * occurs when the single step causes accel values to go above - * preset threshold. - */ -static int8_t - set_accel_step_detect_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_step_detect_int_cfg* step_detect_int_cfg = - &(int_config->int_type_cfg.acc_step_detect_int); - rslt = enable_step_detect_int(step_detect_int_cfg, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_step_detect(step_detect_int_cfg, dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the orientation interrupt of the sensor.This - * interrupt occurs when there is orientation change in the sensor - * with respect to gravitational field vector g. - */ -static int8_t - set_accel_orientation_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_orient_int_cfg* orient_int_cfg = - &(int_config->int_type_cfg.acc_orient_int); - rslt = enable_orient_int(orient_int_cfg, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - /* map INT pin to orient interrupt */ - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - /* configure the - * orientation setting*/ - rslt = config_orient_int_settg(orient_int_cfg, dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the flat interrupt of the sensor.This interrupt - * occurs in case of flat orientation - */ -static int8_t - set_accel_flat_detect_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_flat_detect_int_cfg* flat_detect_int = - &(int_config->int_type_cfg.acc_flat_int); - - /* enable the flat interrupt */ - rslt = enable_flat_int(flat_detect_int, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - /* map INT pin to flat interrupt */ - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - /* configure the flat setting*/ - rslt = config_flat_int_settg(flat_detect_int, dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the low-g interrupt of the sensor.This interrupt - * occurs during free-fall. - */ -static int8_t - set_accel_low_g_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_low_g_int_cfg* low_g_int = &(int_config->int_type_cfg.acc_low_g_int); - - /* Enable the low-g interrupt*/ - rslt = enable_low_g_int(low_g_int, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - /* Map INT pin to low-g interrupt */ - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - /* configure the data source - * for low-g interrupt*/ - rslt = config_low_g_data_src(low_g_int, dev); - if(rslt == BMI160_OK) { - rslt = config_low_g_int_settg(low_g_int, dev); - } - } - } - } - } - - return rslt; -} - -/*! - * @brief This API sets the high-g interrupt of the sensor.The interrupt - * occurs if the absolute value of acceleration data of any enabled axis - * exceeds the programmed threshold and the sign of the value does not - * change for a preset duration. - */ -static int8_t - set_accel_high_g_int(struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if((rslt != BMI160_OK) || (int_config == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* updating the interrupt structure to local structure */ - struct bmi160_acc_high_g_int_cfg* high_g_int_cfg = - &(int_config->int_type_cfg.acc_high_g_int); - - /* Enable the high-g interrupt */ - rslt = enable_high_g_int(high_g_int_cfg, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - /* Map INT pin to high-g interrupt */ - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - /* configure the data source - * for high-g interrupt*/ - rslt = config_high_g_data_src(high_g_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_high_g_int_settg(high_g_int_cfg, dev); - } - } - } - } - } - - return rslt; -} - -/*! - * @brief This API configures the pins to fire the - * interrupt signal when it occurs. - */ -static int8_t - set_intr_pin_config(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - - /* configure the behavioural settings of interrupt pin */ - rslt = config_int_out_ctrl(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_int_latch(int_config, dev); - } - - return rslt; -} - -/*! - * @brief This internal API is used to validate the device structure pointer for - * null conditions. - */ -static int8_t null_ptr_check(const struct bmi160_dev* dev) { - int8_t rslt; - - if((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Device structure is fine */ - rslt = BMI160_OK; - } - - return rslt; -} - -/*! - * @brief This API sets the default configuration parameters of accel & gyro. - * Also maintain the previous state of configurations. - */ -static void default_param_settg(struct bmi160_dev* dev) { - /* Initializing accel and gyro params with - * default values */ - dev->accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; - dev->accel_cfg.odr = BMI160_ACCEL_ODR_100HZ; - dev->accel_cfg.power = BMI160_ACCEL_SUSPEND_MODE; - dev->accel_cfg.range = BMI160_ACCEL_RANGE_2G; - dev->gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE; - dev->gyro_cfg.odr = BMI160_GYRO_ODR_100HZ; - dev->gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE; - dev->gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS; - - /* To maintain the previous state of accel configuration */ - dev->prev_accel_cfg = dev->accel_cfg; - - /* To maintain the previous state of gyro configuration */ - dev->prev_gyro_cfg = dev->gyro_cfg; -} - -/*! - * @brief This API set the accel configuration. - */ -static int8_t set_accel_conf(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[2] = {0}; - - rslt = check_accel_config(data, dev); - if(rslt == BMI160_OK) { - /* Write output data rate and bandwidth */ - rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, &data[0], 1, dev); - if(rslt == BMI160_OK) { - dev->prev_accel_cfg.odr = dev->accel_cfg.odr; - dev->prev_accel_cfg.bw = dev->accel_cfg.bw; - - /* write accel range */ - rslt = bmi160_set_regs(BMI160_ACCEL_RANGE_ADDR, &data[1], 1, dev); - if(rslt == BMI160_OK) { - dev->prev_accel_cfg.range = dev->accel_cfg.range; - } - } - } - - return rslt; -} - -/*! - * @brief This API gets the accel configuration. - */ -static int8_t get_accel_conf(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[2] = {0}; - - /* Get accel configurations */ - rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 2, dev); - if(rslt == BMI160_OK) { - dev->accel_cfg.odr = (data[0] & BMI160_ACCEL_ODR_MASK); - dev->accel_cfg.bw = (data[0] & BMI160_ACCEL_BW_MASK) >> BMI160_ACCEL_BW_POS; - dev->accel_cfg.range = (data[1] & BMI160_ACCEL_RANGE_MASK); - } - - return rslt; -} - -/*! - * @brief This API check the accel configuration. - */ -static int8_t check_accel_config(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt; - - /* read accel Output data rate and bandwidth */ - rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 2, dev); - if(rslt == BMI160_OK) { - rslt = process_accel_odr(&data[0], dev); - if(rslt == BMI160_OK) { - rslt = process_accel_bw(&data[0], dev); - if(rslt == BMI160_OK) { - rslt = process_accel_range(&data[1], dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API process the accel odr. - */ -static int8_t process_accel_odr(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t odr = 0; - - if(dev->accel_cfg.odr <= BMI160_ACCEL_ODR_1600HZ) { - if(dev->accel_cfg.odr != dev->prev_accel_cfg.odr) { - odr = (uint8_t)dev->accel_cfg.odr; - temp = *data & ~BMI160_ACCEL_ODR_MASK; - - /* Adding output data rate */ - *data = temp | (odr & BMI160_ACCEL_ODR_MASK); - } - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API process the accel bandwidth. - */ -static int8_t process_accel_bw(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t bw = 0; - - if(dev->accel_cfg.bw <= BMI160_ACCEL_BW_RES_AVG128) { - if(dev->accel_cfg.bw != dev->prev_accel_cfg.bw) { - bw = (uint8_t)dev->accel_cfg.bw; - temp = *data & ~BMI160_ACCEL_BW_MASK; - - /* Adding bandwidth */ - *data = temp | ((bw << 4) & BMI160_ACCEL_BW_MASK); - } - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API process the accel range. - */ -static int8_t process_accel_range(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t range = 0; - - if(dev->accel_cfg.range <= BMI160_ACCEL_RANGE_16G) { - if(dev->accel_cfg.range != dev->prev_accel_cfg.range) { - range = (uint8_t)dev->accel_cfg.range; - temp = *data & ~BMI160_ACCEL_RANGE_MASK; - - /* Adding range */ - *data = temp | (range & BMI160_ACCEL_RANGE_MASK); - } - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API checks the invalid settings for ODR & Bw for - * Accel and Gyro. - */ -static int8_t check_invalid_settg(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - - /* read the error reg */ - rslt = bmi160_get_regs(BMI160_ERROR_REG_ADDR, &data, 1, dev); - data = data >> 1; - data = data & BMI160_ERR_REG_MASK; - if(data == 1) { - rslt = BMI160_E_ACCEL_ODR_BW_INVALID; - } else if(data == 2) { - rslt = BMI160_E_GYRO_ODR_BW_INVALID; - } else if(data == 3) { - rslt = BMI160_E_LWP_PRE_FLTR_INT_INVALID; - } else if(data == 7) { - rslt = BMI160_E_LWP_PRE_FLTR_INVALID; - } - - return rslt; -} -static int8_t set_gyro_conf(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[2] = {0}; - - rslt = check_gyro_config(data, dev); - if(rslt == BMI160_OK) { - /* Write output data rate and bandwidth */ - rslt = bmi160_set_regs(BMI160_GYRO_CONFIG_ADDR, &data[0], 1, dev); - if(rslt == BMI160_OK) { - dev->prev_gyro_cfg.odr = dev->gyro_cfg.odr; - dev->prev_gyro_cfg.bw = dev->gyro_cfg.bw; - - /* Write gyro range */ - rslt = bmi160_set_regs(BMI160_GYRO_RANGE_ADDR, &data[1], 1, dev); - if(rslt == BMI160_OK) { - dev->prev_gyro_cfg.range = dev->gyro_cfg.range; - } - } - } - - return rslt; -} - -/*! - * @brief This API gets the gyro configuration. - */ -static int8_t get_gyro_conf(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[2] = {0}; - - /* Get accel configurations */ - rslt = bmi160_get_regs(BMI160_GYRO_CONFIG_ADDR, data, 2, dev); - if(rslt == BMI160_OK) { - dev->gyro_cfg.odr = (data[0] & BMI160_GYRO_ODR_MASK); - dev->gyro_cfg.bw = (data[0] & BMI160_GYRO_BW_MASK) >> BMI160_GYRO_BW_POS; - dev->gyro_cfg.range = (data[1] & BMI160_GYRO_RANGE_MASK); - } - - return rslt; -} - -/*! - * @brief This API check the gyro configuration. - */ -static int8_t check_gyro_config(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt; - - /* read gyro Output data rate and bandwidth */ - rslt = bmi160_get_regs(BMI160_GYRO_CONFIG_ADDR, data, 2, dev); - if(rslt == BMI160_OK) { - rslt = process_gyro_odr(&data[0], dev); - if(rslt == BMI160_OK) { - rslt = process_gyro_bw(&data[0], dev); - if(rslt == BMI160_OK) { - rslt = process_gyro_range(&data[1], dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API process the gyro odr. - */ -static int8_t process_gyro_odr(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t odr = 0; - - if(dev->gyro_cfg.odr <= BMI160_GYRO_ODR_3200HZ) { - if(dev->gyro_cfg.odr != dev->prev_gyro_cfg.odr) { - odr = (uint8_t)dev->gyro_cfg.odr; - temp = (*data & ~BMI160_GYRO_ODR_MASK); - - /* Adding output data rate */ - *data = temp | (odr & BMI160_GYRO_ODR_MASK); - } - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API process the gyro bandwidth. - */ -static int8_t process_gyro_bw(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t bw = 0; - - if(dev->gyro_cfg.bw <= BMI160_GYRO_BW_NORMAL_MODE) { - bw = (uint8_t)dev->gyro_cfg.bw; - temp = *data & ~BMI160_GYRO_BW_MASK; - - /* Adding bandwidth */ - *data = temp | ((bw << 4) & BMI160_GYRO_BW_MASK); - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API process the gyro range. - */ -static int8_t process_gyro_range(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t temp = 0; - uint8_t range = 0; - - if(dev->gyro_cfg.range <= BMI160_GYRO_RANGE_125_DPS) { - if(dev->gyro_cfg.range != dev->prev_gyro_cfg.range) { - range = (uint8_t)dev->gyro_cfg.range; - temp = *data & ~BMI160_GYRO_RANGE_MASK; - - /* Adding range */ - *data = temp | (range & BMI160_GYRO_RANGE_MASK); - } - } else { - rslt = BMI160_E_OUT_OF_RANGE; - } - - return rslt; -} - -/*! - * @brief This API sets the accel power. - */ -static int8_t set_accel_pwr(struct bmi160_dev* dev) { - int8_t rslt = 0; - uint8_t data = 0; - - if((dev->accel_cfg.power >= BMI160_ACCEL_SUSPEND_MODE) && - (dev->accel_cfg.power <= BMI160_ACCEL_LOWPOWER_MODE)) { - if(dev->accel_cfg.power != dev->prev_accel_cfg.power) { - rslt = process_under_sampling(&data, dev); - if(rslt == BMI160_OK) { - /* Write accel power */ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &dev->accel_cfg.power, 1, dev); - - /* Add delay of 3.8 ms - refer data sheet table 24*/ - if(dev->prev_accel_cfg.power == BMI160_ACCEL_SUSPEND_MODE) { - dev->delay_ms(BMI160_ACCEL_DELAY_MS); - } - - dev->prev_accel_cfg.power = dev->accel_cfg.power; - } - } - } else { - rslt = BMI160_E_INVALID_CONFIG; - } - - return rslt; -} - -/*! - * @brief This API process the undersampling setting of Accel. - */ -static int8_t process_under_sampling(uint8_t* data, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t pre_filter[2] = {0}; - - rslt = bmi160_get_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev); - if(rslt == BMI160_OK) { - if(dev->accel_cfg.power == BMI160_ACCEL_LOWPOWER_MODE) { - temp = *data & ~BMI160_ACCEL_UNDERSAMPLING_MASK; - - /* Set under-sampling parameter */ - *data = temp | ((1 << 7) & BMI160_ACCEL_UNDERSAMPLING_MASK); - - /* Write data */ - rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev); - - /* Disable the pre-filter data in low power mode */ - if(rslt == BMI160_OK) { - /* Disable the Pre-filter data*/ - rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, pre_filter, 2, dev); - } - } else if(*data & BMI160_ACCEL_UNDERSAMPLING_MASK) { - temp = *data & ~BMI160_ACCEL_UNDERSAMPLING_MASK; - - /* Disable under-sampling parameter if already enabled */ - *data = temp; - - /* Write data */ - rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, data, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API sets the gyro power mode. - */ -static int8_t set_gyro_pwr(struct bmi160_dev* dev) { - int8_t rslt = 0; - - if((dev->gyro_cfg.power == BMI160_GYRO_SUSPEND_MODE) || - (dev->gyro_cfg.power == BMI160_GYRO_NORMAL_MODE) || - (dev->gyro_cfg.power == BMI160_GYRO_FASTSTARTUP_MODE)) { - if(dev->gyro_cfg.power != dev->prev_gyro_cfg.power) { - /* Write gyro power */ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &dev->gyro_cfg.power, 1, dev); - if(dev->prev_gyro_cfg.power == BMI160_GYRO_SUSPEND_MODE) { - /* Delay of 80 ms - datasheet Table 24 */ - dev->delay_ms(BMI160_GYRO_DELAY_MS); - } else if( - (dev->prev_gyro_cfg.power == BMI160_GYRO_FASTSTARTUP_MODE) && - (dev->gyro_cfg.power == BMI160_GYRO_NORMAL_MODE)) { - /* This delay is required for transition from - * fast-startup mode to normal mode - datasheet Table 3 */ - dev->delay_ms(10); - } else { - /* do nothing */ - } - - dev->prev_gyro_cfg.power = dev->gyro_cfg.power; - } - } else { - rslt = BMI160_E_INVALID_CONFIG; - } - - return rslt; -} - -/*! - * @brief This API reads accel data along with sensor time if time is requested - * by user. Kindly refer the user guide(README.md) for more info. - */ -static int8_t - get_accel_data(uint8_t len, struct bmi160_sensor_data* accel, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t idx = 0; - uint8_t data_array[9] = {0}; - uint8_t time_0 = 0; - uint16_t time_1 = 0; - uint32_t time_2 = 0; - uint8_t lsb; - uint8_t msb; - int16_t msblsb; - - /* read accel sensor data along with time if requested */ - rslt = bmi160_get_regs(BMI160_ACCEL_DATA_ADDR, data_array, 6 + len, dev); - if(rslt == BMI160_OK) { - /* Accel Data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->x = msblsb; /* Data in X axis */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->y = msblsb; /* Data in Y axis */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->z = msblsb; /* Data in Z axis */ - if(len == 3) { - time_0 = data_array[idx++]; - time_1 = (uint16_t)(data_array[idx++] << 8); - time_2 = (uint32_t)(data_array[idx++] << 16); - accel->sensortime = (uint32_t)(time_2 | time_1 | time_0); - } else { - accel->sensortime = 0; - } - } else { - rslt = BMI160_E_COM_FAIL; - } - - return rslt; -} - -/*! - * @brief This API reads accel data along with sensor time if time is requested - * by user. Kindly refer the user guide(README.md) for more info. - */ -static int8_t - get_gyro_data(uint8_t len, struct bmi160_sensor_data* gyro, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t idx = 0; - uint8_t data_array[15] = {0}; - uint8_t time_0 = 0; - uint16_t time_1 = 0; - uint32_t time_2 = 0; - uint8_t lsb; - uint8_t msb; - int16_t msblsb; - - if(len == 0) { - /* read gyro data only */ - rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 6, dev); - if(rslt == BMI160_OK) { - /* Gyro Data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->x = msblsb; /* Data in X axis */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->y = msblsb; /* Data in Y axis */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->z = msblsb; /* Data in Z axis */ - gyro->sensortime = 0; - } else { - rslt = BMI160_E_COM_FAIL; - } - } else { - /* read gyro sensor data along with time */ - rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 12 + len, dev); - if(rslt == BMI160_OK) { - /* Gyro Data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->x = msblsb; /* gyro X axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->y = msblsb; /* gyro Y axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->z = msblsb; /* gyro Z axis data */ - idx = idx + 6; - time_0 = data_array[idx++]; - time_1 = (uint16_t)(data_array[idx++] << 8); - time_2 = (uint32_t)(data_array[idx++] << 16); - gyro->sensortime = (uint32_t)(time_2 | time_1 | time_0); - } else { - rslt = BMI160_E_COM_FAIL; - } - } - - return rslt; -} - -/*! - * @brief This API reads accel and gyro data along with sensor time - * if time is requested by user. - * Kindly refer the user guide(README.md) for more info. - */ -static int8_t get_accel_gyro_data( - uint8_t len, - struct bmi160_sensor_data* accel, - struct bmi160_sensor_data* gyro, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t idx = 0; - uint8_t data_array[15] = {0}; - uint8_t time_0 = 0; - uint16_t time_1 = 0; - uint32_t time_2 = 0; - uint8_t lsb; - uint8_t msb; - int16_t msblsb; - - /* read both accel and gyro sensor data - * along with time if requested */ - rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 12 + len, dev); - if(rslt == BMI160_OK) { - /* Gyro Data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->x = msblsb; /* gyro X axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->y = msblsb; /* gyro Y axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - gyro->z = msblsb; /* gyro Z axis data */ - /* Accel Data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->x = (int16_t)msblsb; /* accel X axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->y = (int16_t)msblsb; /* accel Y axis data */ - lsb = data_array[idx++]; - msb = data_array[idx++]; - msblsb = (int16_t)((msb << 8) | lsb); - accel->z = (int16_t)msblsb; /* accel Z axis data */ - if(len == 3) { - time_0 = data_array[idx++]; - time_1 = (uint16_t)(data_array[idx++] << 8); - time_2 = (uint32_t)(data_array[idx++] << 16); - accel->sensortime = (uint32_t)(time_2 | time_1 | time_0); - gyro->sensortime = (uint32_t)(time_2 | time_1 | time_0); - } else { - accel->sensortime = 0; - gyro->sensortime = 0; - } - } else { - rslt = BMI160_E_COM_FAIL; - } - - return rslt; -} - -/*! - * @brief This API enables the any-motion interrupt for accel. - */ -static int8_t enable_accel_any_motion_int( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable any motion x, any motion y, any motion z - * in Int Enable 0 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - if(any_motion_int_cfg->anymotion_en == BMI160_ENABLE) { - temp = data & ~BMI160_ANY_MOTION_X_INT_EN_MASK; - - /* Adding Any_motion x axis */ - data = temp | (any_motion_int_cfg->anymotion_x & BMI160_ANY_MOTION_X_INT_EN_MASK); - temp = data & ~BMI160_ANY_MOTION_Y_INT_EN_MASK; - - /* Adding Any_motion y axis */ - data = temp | - ((any_motion_int_cfg->anymotion_y << 1) & BMI160_ANY_MOTION_Y_INT_EN_MASK); - temp = data & ~BMI160_ANY_MOTION_Z_INT_EN_MASK; - - /* Adding Any_motion z axis */ - data = temp | - ((any_motion_int_cfg->anymotion_z << 2) & BMI160_ANY_MOTION_Z_INT_EN_MASK); - - /* any-motion feature selected*/ - dev->any_sig_sel = BMI160_ANY_MOTION_ENABLED; - } else { - data = data & ~BMI160_ANY_MOTION_ALL_INT_EN_MASK; - - /* neither any-motion feature nor sig-motion selected */ - dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED; - } - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API disable the sig-motion interrupt. - */ -static int8_t disable_sig_motion_int(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Disabling Significant motion interrupt if enabled */ - rslt = bmi160_get_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = (data & BMI160_SIG_MOTION_SEL_MASK); - if(temp) { - temp = data & ~BMI160_SIG_MOTION_SEL_MASK; - data = temp; - - /* Write data to register */ - rslt = bmi160_set_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API is used to map/unmap the Any/Sig motion, Step det/Low-g, - * Double tap, Single tap, Orientation, Flat, High-G, Nomotion interrupt pins. - */ -static int8_t - map_feature_interrupt(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data[3] = {0, 0, 0}; - uint8_t temp[3] = {0, 0, 0}; - - rslt = bmi160_get_regs(BMI160_INT_MAP_0_ADDR, data, 3, dev); - if(rslt == BMI160_OK) { - temp[0] = data[0] & ~int_mask_lookup_table[int_config->int_type]; - temp[2] = data[2] & ~int_mask_lookup_table[int_config->int_type]; - switch(int_config->int_channel) { - case BMI160_INT_CHANNEL_NONE: - data[0] = temp[0]; - data[2] = temp[2]; - break; - case BMI160_INT_CHANNEL_1: - data[0] = temp[0] | int_mask_lookup_table[int_config->int_type]; - data[2] = temp[2]; - break; - case BMI160_INT_CHANNEL_2: - data[2] = temp[2] | int_mask_lookup_table[int_config->int_type]; - data[0] = temp[0]; - break; - case BMI160_INT_CHANNEL_BOTH: - data[0] = temp[0] | int_mask_lookup_table[int_config->int_type]; - data[2] = temp[2] | int_mask_lookup_table[int_config->int_type]; - break; - default: - rslt = BMI160_E_OUT_OF_RANGE; - } - if(rslt == BMI160_OK) { - rslt = bmi160_set_regs(BMI160_INT_MAP_0_ADDR, data, 3, dev); - } - } - - return rslt; -} - -/*! - * @brief This API is used to map/unmap the Dataready(Accel & Gyro), FIFO full - * and FIFO watermark interrupt. - */ -static int8_t map_hardware_interrupt( - const struct bmi160_int_settg* int_config, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - rslt = bmi160_get_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~int_mask_lookup_table[int_config->int_type]; - temp = temp & ~((uint8_t)(int_mask_lookup_table[int_config->int_type] << 4)); - switch(int_config->int_channel) { - case BMI160_INT_CHANNEL_NONE: - data = temp; - break; - case BMI160_INT_CHANNEL_1: - data = temp | (uint8_t)((int_mask_lookup_table[int_config->int_type]) << 4); - break; - case BMI160_INT_CHANNEL_2: - data = temp | int_mask_lookup_table[int_config->int_type]; - break; - case BMI160_INT_CHANNEL_BOTH: - data = temp | int_mask_lookup_table[int_config->int_type]; - data = data | (uint8_t)((int_mask_lookup_table[int_config->int_type]) << 4); - break; - default: - rslt = BMI160_E_OUT_OF_RANGE; - } - if(rslt == BMI160_OK) { - rslt = bmi160_set_regs(BMI160_INT_MAP_1_ADDR, &data, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for any-motion interrupt. - */ -static int8_t config_any_motion_src( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 1 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_MOTION_SRC_INT_MASK; - data = temp | ((any_motion_int_cfg->anymotion_data_src << 7) & BMI160_MOTION_SRC_INT_MASK); - - /* Write data to DATA 1 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the duration and threshold of - * any-motion interrupt. - */ -static int8_t config_any_dur_threshold( - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - uint8_t data_array[2] = {0}; - uint8_t dur; - - /* Configure Int Motion 0 register */ - rslt = bmi160_get_regs(BMI160_INT_MOTION_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* slope duration */ - dur = (uint8_t)any_motion_int_cfg->anymotion_dur; - temp = data & ~BMI160_SLOPE_INT_DUR_MASK; - data = temp | (dur & BMI160_MOTION_SRC_INT_MASK); - data_array[0] = data; - - /* add slope threshold */ - data_array[1] = any_motion_int_cfg->anymotion_thr; - - /* INT MOTION 0 and INT MOTION 1 address lie consecutively, - * hence writing data to respective registers at one go */ - - /* Writing to Int_motion 0 and - * Int_motion 1 Address simultaneously */ - rslt = bmi160_set_regs(BMI160_INT_MOTION_0_ADDR, data_array, 2, dev); - } - - return rslt; -} - -/*! - * @brief This API configure necessary setting of any-motion interrupt. - */ -static int8_t config_any_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_any_mot_int_cfg* any_motion_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = disable_sig_motion_int(dev); - if(rslt == BMI160_OK) { - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_any_motion_src(any_motion_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_any_dur_threshold(any_motion_int_cfg, dev); - } - } - } - } - - return rslt; -} - -/*! - * @brief This API enable the data ready interrupt. - */ -static int8_t enable_data_ready_int(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable data ready interrupt in Int Enable 1 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_DATA_RDY_INT_EN_MASK; - data = temp | ((1 << 4) & BMI160_DATA_RDY_INT_EN_MASK); - - /* Writing data to INT ENABLE 1 Address */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API enables the no motion/slow motion interrupt. - */ -static int8_t enable_no_motion_int( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable no motion x, no motion y, no motion z - * in Int Enable 2 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - if(no_mot_int_cfg->no_motion_x == 1) { - temp = data & ~BMI160_NO_MOTION_X_INT_EN_MASK; - - /* Adding No_motion x axis */ - data = temp | (1 & BMI160_NO_MOTION_X_INT_EN_MASK); - } - - if(no_mot_int_cfg->no_motion_y == 1) { - temp = data & ~BMI160_NO_MOTION_Y_INT_EN_MASK; - - /* Adding No_motion x axis */ - data = temp | ((1 << 1) & BMI160_NO_MOTION_Y_INT_EN_MASK); - } - - if(no_mot_int_cfg->no_motion_z == 1) { - temp = data & ~BMI160_NO_MOTION_Z_INT_EN_MASK; - - /* Adding No_motion x axis */ - data = temp | ((1 << 2) & BMI160_NO_MOTION_Z_INT_EN_MASK); - } - - /* write data to Int Enable 2 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the interrupt PIN setting for - * no motion/slow motion interrupt. - */ -static int8_t config_no_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_no_motion_data_src(no_mot_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_no_motion_dur_thr(no_mot_int_cfg, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API configure the source of interrupt for no motion. - */ -static int8_t config_no_motion_data_src( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 1 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_MOTION_SRC_INT_MASK; - data = temp | ((no_mot_int_cfg->no_motion_src << 7) & BMI160_MOTION_SRC_INT_MASK); - - /* Write data to DATA 1 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the duration and threshold of - * no motion/slow motion interrupt along with selection of no/slow motion. - */ -static int8_t config_no_motion_dur_thr( - const struct bmi160_acc_no_motion_int_cfg* no_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - uint8_t temp_1 = 0; - uint8_t reg_addr; - uint8_t data_array[2] = {0}; - - /* Configuring INT_MOTION register */ - reg_addr = BMI160_INT_MOTION_0_ADDR; - rslt = bmi160_get_regs(reg_addr, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_NO_MOTION_INT_DUR_MASK; - - /* Adding no_motion duration */ - data = temp | ((no_mot_int_cfg->no_motion_dur << 2) & BMI160_NO_MOTION_INT_DUR_MASK); - - /* Write data to NO_MOTION 0 address */ - rslt = bmi160_set_regs(reg_addr, &data, 1, dev); - if(rslt == BMI160_OK) { - reg_addr = BMI160_INT_MOTION_3_ADDR; - rslt = bmi160_get_regs(reg_addr, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_NO_MOTION_SEL_BIT_MASK; - - /* Adding no_motion_sel bit */ - temp_1 = (no_mot_int_cfg->no_motion_sel & BMI160_NO_MOTION_SEL_BIT_MASK); - data = (temp | temp_1); - data_array[1] = data; - - /* Adding no motion threshold */ - data_array[0] = no_mot_int_cfg->no_motion_thres; - reg_addr = BMI160_INT_MOTION_2_ADDR; - - /* writing data to INT_MOTION 2 and INT_MOTION 3 - * address simultaneously */ - rslt = bmi160_set_regs(reg_addr, data_array, 2, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API enables the sig-motion motion interrupt. - */ -static int8_t enable_sig_motion_int( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* For significant motion,enable any motion x,any motion y, - * any motion z in Int Enable 0 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - if(sig_mot_int_cfg->sig_en == BMI160_ENABLE) { - temp = data & ~BMI160_SIG_MOTION_INT_EN_MASK; - data = temp | (7 & BMI160_SIG_MOTION_INT_EN_MASK); - - /* sig-motion feature selected*/ - dev->any_sig_sel = BMI160_SIG_MOTION_ENABLED; - } else { - data = data & ~BMI160_SIG_MOTION_INT_EN_MASK; - - /* neither any-motion feature nor sig-motion selected */ - dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED; - } - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the interrupt PIN setting for - * significant motion interrupt. - */ -static int8_t config_sig_motion_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_sig_motion_data_src(sig_mot_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_sig_dur_threshold(sig_mot_int_cfg, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for sig motion interrupt. - */ -static int8_t config_sig_motion_data_src( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 1 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_MOTION_SRC_INT_MASK; - data = temp | ((sig_mot_int_cfg->sig_data_src << 7) & BMI160_MOTION_SRC_INT_MASK); - - /* Write data to DATA 1 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the threshold, skip and proof time of - * sig motion interrupt. - */ -static int8_t config_sig_dur_threshold( - const struct bmi160_acc_sig_mot_int_cfg* sig_mot_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data; - uint8_t temp = 0; - - /* Configuring INT_MOTION registers */ - - /* Write significant motion threshold. - * This threshold is same as any motion threshold */ - data = sig_mot_int_cfg->sig_mot_thres; - - /* Write data to INT_MOTION 1 address */ - rslt = bmi160_set_regs(BMI160_INT_MOTION_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - rslt = bmi160_get_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_SIG_MOTION_SKIP_MASK; - - /* adding skip time of sig_motion interrupt*/ - data = temp | ((sig_mot_int_cfg->sig_mot_skip << 2) & BMI160_SIG_MOTION_SKIP_MASK); - temp = data & ~BMI160_SIG_MOTION_PROOF_MASK; - - /* adding proof time of sig_motion interrupt */ - data = temp | ((sig_mot_int_cfg->sig_mot_proof << 4) & BMI160_SIG_MOTION_PROOF_MASK); - - /* configure the int_sig_mot_sel bit to select - * significant motion interrupt */ - temp = data & ~BMI160_SIG_MOTION_SEL_MASK; - data = temp | ((sig_mot_int_cfg->sig_en << 1) & BMI160_SIG_MOTION_SEL_MASK); - rslt = bmi160_set_regs(BMI160_INT_MOTION_3_ADDR, &data, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API enables the step detector interrupt. - */ -static int8_t enable_step_detect_int( - const struct bmi160_acc_step_detect_int_cfg* step_detect_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable data ready interrupt in Int Enable 2 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_STEP_DETECT_INT_EN_MASK; - data = temp | - ((step_detect_int_cfg->step_detector_en << 3) & BMI160_STEP_DETECT_INT_EN_MASK); - - /* Writing data to INT ENABLE 2 Address */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_2_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the step detector parameter. - */ -static int8_t config_step_detect( - const struct bmi160_acc_step_detect_int_cfg* step_detect_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data_array[2] = {0}; - - if(step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_NORMAL) { - /* Normal mode setting */ - data_array[0] = 0x15; - data_array[1] = 0x03; - } else if(step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_SENSITIVE) { - /* Sensitive mode setting */ - data_array[0] = 0x2D; - data_array[1] = 0x00; - } else if(step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_ROBUST) { - /* Robust mode setting */ - data_array[0] = 0x1D; - data_array[1] = 0x07; - } else if(step_detect_int_cfg->step_detector_mode == BMI160_STEP_DETECT_USER_DEFINE) { - /* Non recommended User defined setting */ - /* Configuring STEP_CONFIG register */ - rslt = bmi160_get_regs(BMI160_INT_STEP_CONFIG_0_ADDR, &data_array[0], 2, dev); - if(rslt == BMI160_OK) { - temp = data_array[0] & ~BMI160_STEP_DETECT_MIN_THRES_MASK; - - /* Adding min_threshold */ - data_array[0] = temp | ((step_detect_int_cfg->min_threshold << 3) & - BMI160_STEP_DETECT_MIN_THRES_MASK); - temp = data_array[0] & ~BMI160_STEP_DETECT_STEPTIME_MIN_MASK; - - /* Adding steptime_min */ - data_array[0] = temp | ((step_detect_int_cfg->steptime_min) & - BMI160_STEP_DETECT_STEPTIME_MIN_MASK); - temp = data_array[1] & ~BMI160_STEP_MIN_BUF_MASK; - - /* Adding steptime_min */ - data_array[1] = temp | - ((step_detect_int_cfg->step_min_buf) & BMI160_STEP_MIN_BUF_MASK); - } - } - - /* Write data to STEP_CONFIG register */ - rslt = bmi160_set_regs(BMI160_INT_STEP_CONFIG_0_ADDR, data_array, 2, dev); - - return rslt; -} - -/*! - * @brief This API enables the single/double tap interrupt. - */ -static int8_t enable_tap_int( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable single tap or double tap interrupt in Int Enable 0 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - if(int_config->int_type == BMI160_ACC_SINGLE_TAP_INT) { - temp = data & ~BMI160_SINGLE_TAP_INT_EN_MASK; - data = temp | ((tap_int_cfg->tap_en << 5) & BMI160_SINGLE_TAP_INT_EN_MASK); - } else { - temp = data & ~BMI160_DOUBLE_TAP_INT_EN_MASK; - data = temp | ((tap_int_cfg->tap_en << 4) & BMI160_DOUBLE_TAP_INT_EN_MASK); - } - - /* Write to Enable 0 Address */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the interrupt PIN setting for - * tap interrupt. - */ -static int8_t config_tap_int_settg( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_feature_interrupt(int_config, dev); - if(rslt == BMI160_OK) { - rslt = config_tap_data_src(tap_int_cfg, dev); - if(rslt == BMI160_OK) { - rslt = config_tap_param(int_config, tap_int_cfg, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for tap interrupt. - */ -static int8_t config_tap_data_src( - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 0 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_TAP_SRC_INT_MASK; - data = temp | ((tap_int_cfg->tap_data_src << 3) & BMI160_TAP_SRC_INT_MASK); - - /* Write data to Data 0 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the parameters of tap interrupt. - * Threshold, quite, shock, and duration. - */ -static int8_t config_tap_param( - const struct bmi160_int_settg* int_config, - const struct bmi160_acc_tap_int_cfg* tap_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data = 0; - uint8_t data_array[2] = {0}; - uint8_t count = 0; - uint8_t dur, shock, quiet, thres; - - /* Configure tap 0 register for tap shock,tap quiet duration - * in case of single tap interrupt */ - rslt = bmi160_get_regs(BMI160_INT_TAP_0_ADDR, data_array, 2, dev); - if(rslt == BMI160_OK) { - data = data_array[count]; - if(int_config->int_type == BMI160_ACC_DOUBLE_TAP_INT) { - dur = (uint8_t)tap_int_cfg->tap_dur; - temp = (data & ~BMI160_TAP_DUR_MASK); - - /* Add tap duration data in case of - * double tap interrupt */ - data = temp | (dur & BMI160_TAP_DUR_MASK); - } - - shock = (uint8_t)tap_int_cfg->tap_shock; - temp = data & ~BMI160_TAP_SHOCK_DUR_MASK; - data = temp | ((shock << 6) & BMI160_TAP_SHOCK_DUR_MASK); - quiet = (uint8_t)tap_int_cfg->tap_quiet; - temp = data & ~BMI160_TAP_QUIET_DUR_MASK; - data = temp | ((quiet << 7) & BMI160_TAP_QUIET_DUR_MASK); - data_array[count++] = data; - data = data_array[count]; - thres = (uint8_t)tap_int_cfg->tap_thr; - temp = data & ~BMI160_TAP_THRES_MASK; - data = temp | (thres & BMI160_TAP_THRES_MASK); - data_array[count++] = data; - - /* TAP 0 and TAP 1 address lie consecutively, - * hence writing data to respective registers at one go */ - - /* Writing to Tap 0 and Tap 1 Address simultaneously */ - rslt = bmi160_set_regs(BMI160_INT_TAP_0_ADDR, data_array, count, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the secondary interface. - */ -static int8_t config_sec_if(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t if_conf = 0; - uint8_t cmd = BMI160_AUX_NORMAL_MODE; - - /* set the aux power mode to normal*/ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &cmd, 1, dev); - if(rslt == BMI160_OK) { - /* 0.5ms delay - refer datasheet table 24*/ - dev->delay_ms(1); - rslt = bmi160_get_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev); - if_conf |= (uint8_t)(1 << 5); - if(rslt == BMI160_OK) { - /*enable the secondary interface also*/ - rslt = bmi160_set_regs(BMI160_IF_CONF_ADDR, &if_conf, 1, dev); - } - } - - return rslt; -} - -/*! - * @brief This API configure the ODR of the auxiliary sensor. - */ -static int8_t config_aux_odr(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t aux_odr; - - rslt = bmi160_get_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev); - if(rslt == BMI160_OK) { - aux_odr = (uint8_t)(dev->aux_cfg.aux_odr); - - /* Set the secondary interface ODR - * i.e polling rate of secondary sensor */ - rslt = bmi160_set_regs(BMI160_AUX_ODR_ADDR, &aux_odr, 1, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - } - - return rslt; -} - -/*! - * @brief This API maps the actual burst read length set by user. - */ -static int8_t map_read_len(uint16_t* len, const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - switch(dev->aux_cfg.aux_rd_burst_len) { - case BMI160_AUX_READ_LEN_0: - *len = 1; - break; - case BMI160_AUX_READ_LEN_1: - *len = 2; - break; - case BMI160_AUX_READ_LEN_2: - *len = 6; - break; - case BMI160_AUX_READ_LEN_3: - *len = 8; - break; - default: - rslt = BMI160_E_INVALID_INPUT; - break; - } - - return rslt; -} - -/*! - * @brief This API configure the settings of auxiliary sensor. - */ -static int8_t config_aux_settg(const struct bmi160_dev* dev) { - int8_t rslt; - - rslt = config_sec_if(dev); - if(rslt == BMI160_OK) { - /* Configures the auxiliary interface settings */ - rslt = bmi160_config_aux_mode(dev); - } - - return rslt; -} - -/*! - * @brief This API extract the read data from auxiliary sensor. - */ -static int8_t extract_aux_read( - uint16_t map_len, - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - uint8_t data[8] = { - 0, - }; - uint8_t read_addr = BMI160_AUX_DATA_ADDR; - uint8_t count = 0; - uint8_t read_count; - uint8_t read_len = (uint8_t)map_len; - - for(; count < len;) { - /* set address to read */ - rslt = bmi160_set_regs(BMI160_AUX_IF_2_ADDR, ®_addr, 1, dev); - dev->delay_ms(BMI160_AUX_COM_DELAY); - if(rslt == BMI160_OK) { - rslt = bmi160_get_regs(read_addr, data, map_len, dev); - if(rslt == BMI160_OK) { - read_count = 0; - - /* if read len is less the burst read len - * mention by user*/ - if(len < map_len) { - read_len = (uint8_t)len; - } else if((len - count) < map_len) { - read_len = (uint8_t)(len - count); - } - - for(; read_count < read_len; read_count++) { - aux_data[count + read_count] = data[read_count]; - } - - reg_addr += (uint8_t)map_len; - count += (uint8_t)map_len; - } else { - rslt = BMI160_E_COM_FAIL; - break; - } - } - } - - return rslt; -} - -/*! - * @brief This API enables the orient interrupt. - */ -static int8_t enable_orient_int( - const struct bmi160_acc_orient_int_cfg* orient_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable data ready interrupt in Int Enable 0 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_ORIENT_INT_EN_MASK; - data = temp | ((orient_int_cfg->orient_en << 6) & BMI160_ORIENT_INT_EN_MASK); - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the necessary setting of orientation interrupt. - */ -static int8_t config_orient_int_settg( - const struct bmi160_acc_orient_int_cfg* orient_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - uint8_t data_array[2] = {0, 0}; - - /* Configuring INT_ORIENT registers */ - rslt = bmi160_get_regs(BMI160_INT_ORIENT_0_ADDR, data_array, 2, dev); - if(rslt == BMI160_OK) { - data = data_array[0]; - temp = data & ~BMI160_ORIENT_MODE_MASK; - - /* Adding Orientation mode */ - data = temp | ((orient_int_cfg->orient_mode) & BMI160_ORIENT_MODE_MASK); - temp = data & ~BMI160_ORIENT_BLOCK_MASK; - - /* Adding Orientation blocking */ - data = temp | ((orient_int_cfg->orient_blocking << 2) & BMI160_ORIENT_BLOCK_MASK); - temp = data & ~BMI160_ORIENT_HYST_MASK; - - /* Adding Orientation hysteresis */ - data = temp | ((orient_int_cfg->orient_hyst << 4) & BMI160_ORIENT_HYST_MASK); - data_array[0] = data; - data = data_array[1]; - temp = data & ~BMI160_ORIENT_THETA_MASK; - - /* Adding Orientation threshold */ - data = temp | ((orient_int_cfg->orient_theta) & BMI160_ORIENT_THETA_MASK); - temp = data & ~BMI160_ORIENT_UD_ENABLE; - - /* Adding Orient_ud_en */ - data = temp | ((orient_int_cfg->orient_ud_en << 6) & BMI160_ORIENT_UD_ENABLE); - temp = data & ~BMI160_AXES_EN_MASK; - - /* Adding axes_en */ - data = temp | ((orient_int_cfg->axes_ex << 7) & BMI160_AXES_EN_MASK); - data_array[1] = data; - - /* Writing data to INT_ORIENT 0 and INT_ORIENT 1 - * registers simultaneously */ - rslt = bmi160_set_regs(BMI160_INT_ORIENT_0_ADDR, data_array, 2, dev); - } - - return rslt; -} - -/*! - * @brief This API enables the flat interrupt. - */ -static int8_t enable_flat_int( - const struct bmi160_acc_flat_detect_int_cfg* flat_int, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable flat interrupt in Int Enable 0 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_FLAT_INT_EN_MASK; - data = temp | ((flat_int->flat_en << 7) & BMI160_FLAT_INT_EN_MASK); - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the necessary setting of flat interrupt. - */ -static int8_t config_flat_int_settg( - const struct bmi160_acc_flat_detect_int_cfg* flat_int, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - uint8_t data_array[2] = {0, 0}; - - /* Configuring INT_FLAT register */ - rslt = bmi160_get_regs(BMI160_INT_FLAT_0_ADDR, data_array, 2, dev); - if(rslt == BMI160_OK) { - data = data_array[0]; - temp = data & ~BMI160_FLAT_THRES_MASK; - - /* Adding flat theta */ - data = temp | ((flat_int->flat_theta) & BMI160_FLAT_THRES_MASK); - data_array[0] = data; - data = data_array[1]; - temp = data & ~BMI160_FLAT_HOLD_TIME_MASK; - - /* Adding flat hold time */ - data = temp | ((flat_int->flat_hold_time << 4) & BMI160_FLAT_HOLD_TIME_MASK); - temp = data & ~BMI160_FLAT_HYST_MASK; - - /* Adding flat hysteresis */ - data = temp | ((flat_int->flat_hy) & BMI160_FLAT_HYST_MASK); - data_array[1] = data; - - /* Writing data to INT_FLAT 0 and INT_FLAT 1 - * registers simultaneously */ - rslt = bmi160_set_regs(BMI160_INT_FLAT_0_ADDR, data_array, 2, dev); - } - - return rslt; -} - -/*! - * @brief This API enables the Low-g interrupt. - */ -static int8_t enable_low_g_int( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable low-g interrupt in Int Enable 1 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_LOW_G_INT_EN_MASK; - data = temp | ((low_g_int->low_en << 3) & BMI160_LOW_G_INT_EN_MASK); - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for low-g interrupt. - */ -static int8_t config_low_g_data_src( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 0 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_LOW_HIGH_SRC_INT_MASK; - data = temp | ((low_g_int->low_data_src << 7) & BMI160_LOW_HIGH_SRC_INT_MASK); - - /* Write data to Data 0 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the necessary setting of low-g interrupt. - */ -static int8_t config_low_g_int_settg( - const struct bmi160_acc_low_g_int_cfg* low_g_int, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data_array[3] = {0, 0, 0}; - - /* Configuring INT_LOWHIGH register for low-g interrupt */ - rslt = bmi160_get_regs(BMI160_INT_LOWHIGH_2_ADDR, &data_array[2], 1, dev); - if(rslt == BMI160_OK) { - temp = data_array[2] & ~BMI160_LOW_G_HYST_MASK; - - /* Adding low-g hysteresis */ - data_array[2] = temp | (low_g_int->low_hyst & BMI160_LOW_G_HYST_MASK); - temp = data_array[2] & ~BMI160_LOW_G_LOW_MODE_MASK; - - /* Adding low-mode */ - data_array[2] = temp | ((low_g_int->low_mode << 2) & BMI160_LOW_G_LOW_MODE_MASK); - - /* Adding low-g threshold */ - data_array[1] = low_g_int->low_thres; - - /* Adding low-g interrupt delay */ - data_array[0] = low_g_int->low_dur; - - /* Writing data to INT_LOWHIGH 0,1,2 registers simultaneously*/ - rslt = bmi160_set_regs(BMI160_INT_LOWHIGH_0_ADDR, data_array, 3, dev); - } - - return rslt; -} - -/*! - * @brief This API enables the high-g interrupt. - */ -static int8_t enable_high_g_int( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Enable low-g interrupt in Int Enable 1 register */ - rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* Adding high-g X-axis */ - temp = data & ~BMI160_HIGH_G_X_INT_EN_MASK; - data = temp | (high_g_int_cfg->high_g_x & BMI160_HIGH_G_X_INT_EN_MASK); - - /* Adding high-g Y-axis */ - temp = data & ~BMI160_HIGH_G_Y_INT_EN_MASK; - data = temp | ((high_g_int_cfg->high_g_y << 1) & BMI160_HIGH_G_Y_INT_EN_MASK); - - /* Adding high-g Z-axis */ - temp = data & ~BMI160_HIGH_G_Z_INT_EN_MASK; - data = temp | ((high_g_int_cfg->high_g_z << 2) & BMI160_HIGH_G_Z_INT_EN_MASK); - - /* write data to Int Enable 0 register */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the source of data(filter & pre-filter) - * for high-g interrupt. - */ -static int8_t config_high_g_data_src( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - uint8_t temp = 0; - - /* Configure Int data 0 register to add source of interrupt */ - rslt = bmi160_get_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - temp = data & ~BMI160_LOW_HIGH_SRC_INT_MASK; - data = temp | ((high_g_int_cfg->high_data_src << 7) & BMI160_LOW_HIGH_SRC_INT_MASK); - - /* Write data to Data 0 address */ - rslt = bmi160_set_regs(BMI160_INT_DATA_0_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the necessary setting of high-g interrupt. - */ -static int8_t config_high_g_int_settg( - const struct bmi160_acc_high_g_int_cfg* high_g_int_cfg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data_array[3] = {0, 0, 0}; - - rslt = bmi160_get_regs(BMI160_INT_LOWHIGH_2_ADDR, &data_array[0], 1, dev); - if(rslt == BMI160_OK) { - temp = data_array[0] & ~BMI160_HIGH_G_HYST_MASK; - - /* Adding high-g hysteresis */ - data_array[0] = temp | ((high_g_int_cfg->high_hy << 6) & BMI160_HIGH_G_HYST_MASK); - - /* Adding high-g duration */ - data_array[1] = high_g_int_cfg->high_dur; - - /* Adding high-g threshold */ - data_array[2] = high_g_int_cfg->high_thres; - rslt = bmi160_set_regs(BMI160_INT_LOWHIGH_2_ADDR, data_array, 3, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the behavioural setting of interrupt pin. - */ -static int8_t - config_int_out_ctrl(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data = 0; - - /* Configuration of output interrupt signals on pins INT1 and INT2 are - * done in BMI160_INT_OUT_CTRL_ADDR register*/ - rslt = bmi160_get_regs(BMI160_INT_OUT_CTRL_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* updating the interrupt pin structure to local structure */ - const struct bmi160_int_pin_settg* intr_pin_sett = &(int_config->int_pin_settg); - - /* Configuring channel 1 */ - if(int_config->int_channel == BMI160_INT_CHANNEL_1) { - /* Output enable */ - temp = data & ~BMI160_INT1_OUTPUT_EN_MASK; - data = temp | ((intr_pin_sett->output_en << 3) & BMI160_INT1_OUTPUT_EN_MASK); - - /* Output mode */ - temp = data & ~BMI160_INT1_OUTPUT_MODE_MASK; - data = temp | ((intr_pin_sett->output_mode << 2) & BMI160_INT1_OUTPUT_MODE_MASK); - - /* Output type */ - temp = data & ~BMI160_INT1_OUTPUT_TYPE_MASK; - data = temp | ((intr_pin_sett->output_type << 1) & BMI160_INT1_OUTPUT_TYPE_MASK); - - /* edge control */ - temp = data & ~BMI160_INT1_EDGE_CTRL_MASK; - data = temp | ((intr_pin_sett->edge_ctrl) & BMI160_INT1_EDGE_CTRL_MASK); - } else { - /* Configuring channel 2 */ - /* Output enable */ - temp = data & ~BMI160_INT2_OUTPUT_EN_MASK; - data = temp | ((intr_pin_sett->output_en << 7) & BMI160_INT2_OUTPUT_EN_MASK); - - /* Output mode */ - temp = data & ~BMI160_INT2_OUTPUT_MODE_MASK; - data = temp | ((intr_pin_sett->output_mode << 6) & BMI160_INT2_OUTPUT_MODE_MASK); - - /* Output type */ - temp = data & ~BMI160_INT2_OUTPUT_TYPE_MASK; - data = temp | ((intr_pin_sett->output_type << 5) & BMI160_INT2_OUTPUT_TYPE_MASK); - - /* edge control */ - temp = data & ~BMI160_INT2_EDGE_CTRL_MASK; - data = temp | ((intr_pin_sett->edge_ctrl << 4) & BMI160_INT2_EDGE_CTRL_MASK); - } - - rslt = bmi160_set_regs(BMI160_INT_OUT_CTRL_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API configure the mode(input enable, latch or non-latch) of interrupt pin. - */ -static int8_t - config_int_latch(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t temp = 0; - uint8_t data = 0; - - /* Configuration of latch on pins INT1 and INT2 are done in - * BMI160_INT_LATCH_ADDR register*/ - rslt = bmi160_get_regs(BMI160_INT_LATCH_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* updating the interrupt pin structure to local structure */ - const struct bmi160_int_pin_settg* intr_pin_sett = &(int_config->int_pin_settg); - if(int_config->int_channel == BMI160_INT_CHANNEL_1) { - /* Configuring channel 1 */ - /* Input enable */ - temp = data & ~BMI160_INT1_INPUT_EN_MASK; - data = temp | ((intr_pin_sett->input_en << 4) & BMI160_INT1_INPUT_EN_MASK); - } else { - /* Configuring channel 2 */ - /* Input enable */ - temp = data & ~BMI160_INT2_INPUT_EN_MASK; - data = temp | ((intr_pin_sett->input_en << 5) & BMI160_INT2_INPUT_EN_MASK); - } - - /* In case of latch interrupt,update the latch duration */ - - /* Latching holds the interrupt for the amount of latch - * duration time */ - temp = data & ~BMI160_INT_LATCH_MASK; - data = temp | (intr_pin_sett->latch_dur & BMI160_INT_LATCH_MASK); - - /* OUT_CTRL_INT and LATCH_INT address lie consecutively, - * hence writing data to respective registers at one go */ - rslt = bmi160_set_regs(BMI160_INT_LATCH_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API performs the self test for accelerometer of BMI160 - */ -static int8_t perform_accel_self_test(struct bmi160_dev* dev) { - int8_t rslt; - struct bmi160_sensor_data accel_pos, accel_neg; - - /* Enable Gyro self test bit */ - rslt = enable_accel_self_test(dev); - if(rslt == BMI160_OK) { - /* Perform accel self test with positive excitation */ - rslt = accel_self_test_positive_excitation(&accel_pos, dev); - if(rslt == BMI160_OK) { - /* Perform accel self test with negative excitation */ - rslt = accel_self_test_negative_excitation(&accel_neg, dev); - if(rslt == BMI160_OK) { - /* Validate the self test result */ - rslt = validate_accel_self_test(&accel_pos, &accel_neg); - } - } - } - - return rslt; -} - -/*! - * @brief This API enables to perform the accel self test by setting proper - * configurations to facilitate accel self test - */ -static int8_t enable_accel_self_test(struct bmi160_dev* dev) { - int8_t rslt; - uint8_t reg_data; - - /* Set the Accel power mode as normal mode */ - dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; - - /* Set the sensor range configuration as 8G */ - dev->accel_cfg.range = BMI160_ACCEL_RANGE_8G; - rslt = bmi160_set_sens_conf(dev); - if(rslt == BMI160_OK) { - /* Accel configurations are set to facilitate self test - * acc_odr - 1600Hz ; acc_bwp = 2 ; acc_us = 0 */ - reg_data = BMI160_ACCEL_SELF_TEST_CONFIG; - rslt = bmi160_set_regs(BMI160_ACCEL_CONFIG_ADDR, ®_data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API performs accel self test with positive excitation - */ -static int8_t accel_self_test_positive_excitation( - struct bmi160_sensor_data* accel_pos, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t reg_data; - - /* Enable accel self test with positive self-test excitation - * and with amplitude of deflection set as high */ - reg_data = BMI160_ACCEL_SELF_TEST_POSITIVE_EN; - rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, ®_data, 1, dev); - if(rslt == BMI160_OK) { - /* Read the data after a delay of 50ms - refer datasheet 2.8.1 accel self test*/ - dev->delay_ms(BMI160_ACCEL_SELF_TEST_DELAY); - rslt = bmi160_get_sensor_data(BMI160_ACCEL_ONLY, accel_pos, NULL, dev); - } - - return rslt; -} - -/*! - * @brief This API performs accel self test with negative excitation - */ -static int8_t accel_self_test_negative_excitation( - struct bmi160_sensor_data* accel_neg, - const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t reg_data; - - /* Enable accel self test with negative self-test excitation - * and with amplitude of deflection set as high */ - reg_data = BMI160_ACCEL_SELF_TEST_NEGATIVE_EN; - rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, ®_data, 1, dev); - if(rslt == BMI160_OK) { - /* Read the data after a delay of 50ms */ - dev->delay_ms(BMI160_ACCEL_SELF_TEST_DELAY); - rslt = bmi160_get_sensor_data(BMI160_ACCEL_ONLY, accel_neg, NULL, dev); - } - - return rslt; -} - -/*! - * @brief This API validates the accel self test results - */ -static int8_t validate_accel_self_test( - const struct bmi160_sensor_data* accel_pos, - const struct bmi160_sensor_data* accel_neg) { - int8_t rslt; - - /* Validate the results of self test */ - if(((accel_neg->x - accel_pos->x) > BMI160_ACCEL_SELF_TEST_LIMIT) && - ((accel_neg->y - accel_pos->y) > BMI160_ACCEL_SELF_TEST_LIMIT) && - ((accel_neg->z - accel_pos->z) > BMI160_ACCEL_SELF_TEST_LIMIT)) { - /* Self test pass condition */ - rslt = BMI160_OK; - } else { - rslt = BMI160_W_ACCEl_SELF_TEST_FAIL; - } - - return rslt; -} - -/*! - * @brief This API performs the self test for gyroscope of BMI160 - */ -static int8_t perform_gyro_self_test(const struct bmi160_dev* dev) { - int8_t rslt; - - /* Enable Gyro self test bit */ - rslt = enable_gyro_self_test(dev); - if(rslt == BMI160_OK) { - /* Validate the gyro self test a delay of 50ms */ - dev->delay_ms(50); - - /* Validate the gyro self test results */ - rslt = validate_gyro_self_test(dev); - } - - return rslt; -} - -/*! - * @brief This API enables the self test bit to trigger self test for Gyro - */ -static int8_t enable_gyro_self_test(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t reg_data; - - /* Enable the Gyro self test bit to trigger the self test */ - rslt = bmi160_get_regs(BMI160_SELF_TEST_ADDR, ®_data, 1, dev); - if(rslt == BMI160_OK) { - reg_data = BMI160_SET_BITS(reg_data, BMI160_GYRO_SELF_TEST, 1); - rslt = bmi160_set_regs(BMI160_SELF_TEST_ADDR, ®_data, 1, dev); - if(rslt == BMI160_OK) { - /* Delay to enable gyro self test */ - dev->delay_ms(15); - } - } - - return rslt; -} - -/*! - * @brief This API validates the self test results of Gyro - */ -static int8_t validate_gyro_self_test(const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t reg_data; - - /* Validate the Gyro self test result */ - rslt = bmi160_get_regs(BMI160_STATUS_ADDR, ®_data, 1, dev); - if(rslt == BMI160_OK) { - reg_data = BMI160_GET_BITS(reg_data, BMI160_GYRO_SELF_TEST_STATUS); - if(reg_data == BMI160_ENABLE) { - /* Gyro self test success case */ - rslt = BMI160_OK; - } else { - rslt = BMI160_W_GYRO_SELF_TEST_FAIL; - } - } - - return rslt; -} - -/*! - * @brief This API sets FIFO full interrupt of the sensor.This interrupt - * occurs when the FIFO is full and the next full data sample would cause - * a FIFO overflow, which may delete the old samples. - */ -static int8_t - set_fifo_full_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - /* Null-pointer check */ - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /*enable the fifo full interrupt */ - rslt = enable_fifo_full_int(int_config, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_hardware_interrupt(int_config, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This enable the FIFO full interrupt engine. - */ -static int8_t - enable_fifo_full_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - - rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - data = BMI160_SET_BITS(data, BMI160_FIFO_FULL_INT, int_config->fifo_full_int_en); - - /* Writing data to INT ENABLE 1 Address */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API sets FIFO watermark interrupt of the sensor.The FIFO - * watermark interrupt is fired, when the FIFO fill level is above a fifo - * watermark. - */ -static int8_t set_fifo_watermark_int( - const struct bmi160_int_settg* int_config, - const struct bmi160_dev* dev) { - int8_t rslt = BMI160_OK; - - if((dev == NULL) || (dev->delay_ms == NULL)) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Enable fifo-watermark interrupt in Int Enable 1 register */ - rslt = enable_fifo_wtm_int(int_config, dev); - if(rslt == BMI160_OK) { - /* Configure Interrupt pins */ - rslt = set_intr_pin_config(int_config, dev); - if(rslt == BMI160_OK) { - rslt = map_hardware_interrupt(int_config, dev); - } - } - } - - return rslt; -} - -/*! - * @brief This enable the FIFO watermark interrupt engine. - */ -static int8_t - enable_fifo_wtm_int(const struct bmi160_int_settg* int_config, const struct bmi160_dev* dev) { - int8_t rslt; - uint8_t data = 0; - - rslt = bmi160_get_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - data = BMI160_SET_BITS(data, BMI160_FIFO_WTM_INT, int_config->fifo_wtm_int_en); - - /* Writing data to INT ENABLE 1 Address */ - rslt = bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, dev); - } - - return rslt; -} - -/*! - * @brief This API is used to reset the FIFO related configurations - * in the fifo_frame structure. - */ -static void reset_fifo_data_structure(const struct bmi160_dev* dev) { - /*Prepare for next FIFO read by resetting FIFO's - * internal data structures*/ - dev->fifo->accel_byte_start_idx = 0; - dev->fifo->gyro_byte_start_idx = 0; - dev->fifo->aux_byte_start_idx = 0; - dev->fifo->sensor_time = 0; - dev->fifo->skipped_frame_count = 0; -} - -/*! - * @brief This API is used to read fifo_byte_counter value (i.e) - * current fill-level in Fifo buffer. - */ -static int8_t get_fifo_byte_counter(uint16_t* bytes_to_read, struct bmi160_dev const* dev) { - int8_t rslt = 0; - uint8_t data[2]; - uint8_t addr = BMI160_FIFO_LENGTH_ADDR; - - rslt |= bmi160_get_regs(addr, data, 2, dev); - data[1] = data[1] & BMI160_FIFO_BYTE_COUNTER_MASK; - - /* Available data in FIFO is stored in bytes_to_read*/ - *bytes_to_read = (((uint16_t)data[1] << 8) | ((uint16_t)data[0])); - - return rslt; -} - -/*! - * @brief This API is used to compute the number of bytes of accel FIFO data - * which is to be parsed in header-less mode - */ -static void get_accel_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* acc_frame_count, - const struct bmi160_dev* dev) { - /* Data start index */ - *data_index = dev->fifo->accel_byte_start_idx; - if(dev->fifo->fifo_data_enable == BMI160_FIFO_A_ENABLE) { - *data_read_length = (*acc_frame_count) * BMI160_FIFO_A_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_G_A_ENABLE) { - *data_read_length = (*acc_frame_count) * BMI160_FIFO_GA_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_A_ENABLE) { - *data_read_length = (*acc_frame_count) * BMI160_FIFO_MA_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_A_ENABLE) { - *data_read_length = (*acc_frame_count) * BMI160_FIFO_MGA_LENGTH; - } else { - /* When accel is not enabled ,there will be no accel data. - * so we update the data index as complete */ - *data_index = dev->fifo->length; - } - - if(*data_read_length > dev->fifo->length) { - /* Handling the case where more data is requested - * than that is available*/ - *data_read_length = dev->fifo->length; - } -} - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed. - */ -static void unpack_accel_frame( - struct bmi160_sensor_data* acc, - uint16_t* idx, - uint8_t* acc_idx, - uint8_t frame_info, - const struct bmi160_dev* dev) { - switch(frame_info) { - case BMI160_FIFO_HEAD_A: - case BMI160_FIFO_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_A_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into the structure instance "acc" */ - unpack_accel_data(&acc[*acc_idx], *idx, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_A_LENGTH; - (*acc_idx)++; - break; - case BMI160_FIFO_HEAD_G_A: - case BMI160_FIFO_G_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_GA_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "acc"*/ - unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_G_LENGTH, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_GA_LENGTH; - (*acc_idx)++; - break; - case BMI160_FIFO_HEAD_M_A: - case BMI160_FIFO_M_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_MA_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "acc"*/ - unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_M_LENGTH, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_MA_LENGTH; - (*acc_idx)++; - break; - case BMI160_FIFO_HEAD_M_G_A: - case BMI160_FIFO_M_G_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_MGA_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "acc"*/ - unpack_accel_data(&acc[*acc_idx], *idx + BMI160_FIFO_MG_LENGTH, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_MGA_LENGTH; - (*acc_idx)++; - break; - case BMI160_FIFO_HEAD_M: - case BMI160_FIFO_M_ENABLE: - (*idx) = (*idx) + BMI160_FIFO_M_LENGTH; - break; - case BMI160_FIFO_HEAD_G: - case BMI160_FIFO_G_ENABLE: - (*idx) = (*idx) + BMI160_FIFO_G_LENGTH; - break; - case BMI160_FIFO_HEAD_M_G: - case BMI160_FIFO_M_G_ENABLE: - (*idx) = (*idx) + BMI160_FIFO_MG_LENGTH; - break; - default: - break; - } -} - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data and store it in the instance of the structure bmi160_sensor_data. - */ -static void unpack_accel_data( - struct bmi160_sensor_data* accel_data, - uint16_t data_start_index, - const struct bmi160_dev* dev) { - uint16_t data_lsb; - uint16_t data_msb; - - /* Accel raw x data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - accel_data->x = (int16_t)((data_msb << 8) | data_lsb); - - /* Accel raw y data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - accel_data->y = (int16_t)((data_msb << 8) | data_lsb); - - /* Accel raw z data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - accel_data->z = (int16_t)((data_msb << 8) | data_lsb); -} - -/*! - * @brief This API is used to parse the accelerometer data from the - * FIFO data in header mode. - */ -static void extract_accel_header_mode( - struct bmi160_sensor_data* accel_data, - uint8_t* accel_length, - const struct bmi160_dev* dev) { - uint8_t frame_header = 0; - uint16_t data_index; - uint8_t accel_index = 0; - - for(data_index = dev->fifo->accel_byte_start_idx; data_index < dev->fifo->length;) { - /* extracting Frame header */ - frame_header = (dev->fifo->data[data_index] & BMI160_FIFO_TAG_INTR_MASK); - - /*Index is moved to next byte where the data is starting*/ - data_index++; - switch(frame_header) { - /* Accel frame */ - case BMI160_FIFO_HEAD_A: - case BMI160_FIFO_HEAD_M_A: - case BMI160_FIFO_HEAD_G_A: - case BMI160_FIFO_HEAD_M_G_A: - unpack_accel_frame(accel_data, &data_index, &accel_index, frame_header, dev); - break; - case BMI160_FIFO_HEAD_M: - move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_G: - move_next_frame(&data_index, BMI160_FIFO_G_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_M_G: - move_next_frame(&data_index, BMI160_FIFO_MG_LENGTH, dev); - break; - - /* Sensor time frame */ - case BMI160_FIFO_HEAD_SENSOR_TIME: - unpack_sensortime_frame(&data_index, dev); - break; - - /* Skip frame */ - case BMI160_FIFO_HEAD_SKIP_FRAME: - unpack_skipped_frame(&data_index, dev); - break; - - /* Input config frame */ - case BMI160_FIFO_HEAD_INPUT_CONFIG: - move_next_frame(&data_index, 1, dev); - break; - case BMI160_FIFO_HEAD_OVER_READ: - - /* Update the data index as complete in case of Over read */ - data_index = dev->fifo->length; - break; - default: - break; - } - if(*accel_length == accel_index) { - /* Number of frames to read completed */ - break; - } - } - - /*Update number of accel data read*/ - *accel_length = accel_index; - - /*Update the accel frame index*/ - dev->fifo->accel_byte_start_idx = data_index; -} - -/*! - * @brief This API computes the number of bytes of gyro FIFO data - * which is to be parsed in header-less mode - */ -static void get_gyro_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* gyro_frame_count, - const struct bmi160_dev* dev) { - /* Data start index */ - *data_index = dev->fifo->gyro_byte_start_idx; - if(dev->fifo->fifo_data_enable == BMI160_FIFO_G_ENABLE) { - *data_read_length = (*gyro_frame_count) * BMI160_FIFO_G_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_G_A_ENABLE) { - *data_read_length = (*gyro_frame_count) * BMI160_FIFO_GA_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_ENABLE) { - *data_read_length = (*gyro_frame_count) * BMI160_FIFO_MG_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_A_ENABLE) { - *data_read_length = (*gyro_frame_count) * BMI160_FIFO_MGA_LENGTH; - } else { - /* When gyro is not enabled ,there will be no gyro data. - * so we update the data index as complete */ - *data_index = dev->fifo->length; - } - - if(*data_read_length > dev->fifo->length) { - /* Handling the case where more data is requested - * than that is available*/ - *data_read_length = dev->fifo->length; - } -} - -/*! - * @brief This API is used to parse the gyroscope's data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed. - */ -static void unpack_gyro_frame( - struct bmi160_sensor_data* gyro, - uint16_t* idx, - uint8_t* gyro_idx, - uint8_t frame_info, - const struct bmi160_dev* dev) { - switch(frame_info) { - case BMI160_FIFO_HEAD_G: - case BMI160_FIFO_G_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_G_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "gyro"*/ - unpack_gyro_data(&gyro[*gyro_idx], *idx, dev); - - /*Move the data index*/ - (*idx) = (*idx) + BMI160_FIFO_G_LENGTH; - (*gyro_idx)++; - break; - case BMI160_FIFO_HEAD_G_A: - case BMI160_FIFO_G_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_GA_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /* Unpack the data array into structure instance "gyro" */ - unpack_gyro_data(&gyro[*gyro_idx], *idx, dev); - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_GA_LENGTH; - (*gyro_idx)++; - break; - case BMI160_FIFO_HEAD_M_G_A: - case BMI160_FIFO_M_G_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_MGA_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "gyro"*/ - unpack_gyro_data(&gyro[*gyro_idx], *idx + BMI160_FIFO_M_LENGTH, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_MGA_LENGTH; - (*gyro_idx)++; - break; - case BMI160_FIFO_HEAD_M_A: - case BMI160_FIFO_M_A_ENABLE: - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_MA_LENGTH; - break; - case BMI160_FIFO_HEAD_M: - case BMI160_FIFO_M_ENABLE: - (*idx) = (*idx) + BMI160_FIFO_M_LENGTH; - break; - case BMI160_FIFO_HEAD_M_G: - case BMI160_FIFO_M_G_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_MG_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *idx = dev->fifo->length; - break; - } - - /*Unpack the data array into structure instance "gyro"*/ - unpack_gyro_data(&gyro[*gyro_idx], *idx + BMI160_FIFO_M_LENGTH, dev); - - /*Move the data index*/ - (*idx) = (*idx) + BMI160_FIFO_MG_LENGTH; - (*gyro_idx)++; - break; - case BMI160_FIFO_HEAD_A: - case BMI160_FIFO_A_ENABLE: - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_A_LENGTH; - break; - default: - break; - } -} - -/*! - * @brief This API is used to parse the gyro data from the - * FIFO data and store it in the instance of the structure bmi160_sensor_data. - */ -static void unpack_gyro_data( - struct bmi160_sensor_data* gyro_data, - uint16_t data_start_index, - const struct bmi160_dev* dev) { - uint16_t data_lsb; - uint16_t data_msb; - - /* Gyro raw x data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - gyro_data->x = (int16_t)((data_msb << 8) | data_lsb); - - /* Gyro raw y data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - gyro_data->y = (int16_t)((data_msb << 8) | data_lsb); - - /* Gyro raw z data */ - data_lsb = dev->fifo->data[data_start_index++]; - data_msb = dev->fifo->data[data_start_index++]; - gyro_data->z = (int16_t)((data_msb << 8) | data_lsb); -} - -/*! - * @brief This API is used to parse the gyro data from the - * FIFO data in header mode. - */ -static void extract_gyro_header_mode( - struct bmi160_sensor_data* gyro_data, - uint8_t* gyro_length, - const struct bmi160_dev* dev) { - uint8_t frame_header = 0; - uint16_t data_index; - uint8_t gyro_index = 0; - - for(data_index = dev->fifo->gyro_byte_start_idx; data_index < dev->fifo->length;) { - /* extracting Frame header */ - frame_header = (dev->fifo->data[data_index] & BMI160_FIFO_TAG_INTR_MASK); - - /*Index is moved to next byte where the data is starting*/ - data_index++; - switch(frame_header) { - /* GYRO frame */ - case BMI160_FIFO_HEAD_G: - case BMI160_FIFO_HEAD_G_A: - case BMI160_FIFO_HEAD_M_G: - case BMI160_FIFO_HEAD_M_G_A: - unpack_gyro_frame(gyro_data, &data_index, &gyro_index, frame_header, dev); - break; - case BMI160_FIFO_HEAD_A: - move_next_frame(&data_index, BMI160_FIFO_A_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_M: - move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_M_A: - move_next_frame(&data_index, BMI160_FIFO_M_LENGTH, dev); - break; - - /* Sensor time frame */ - case BMI160_FIFO_HEAD_SENSOR_TIME: - unpack_sensortime_frame(&data_index, dev); - break; - - /* Skip frame */ - case BMI160_FIFO_HEAD_SKIP_FRAME: - unpack_skipped_frame(&data_index, dev); - break; - - /* Input config frame */ - case BMI160_FIFO_HEAD_INPUT_CONFIG: - move_next_frame(&data_index, 1, dev); - break; - case BMI160_FIFO_HEAD_OVER_READ: - - /* Update the data index as complete in case of over read */ - data_index = dev->fifo->length; - break; - default: - break; - } - if(*gyro_length == gyro_index) { - /*Number of frames to read completed*/ - break; - } - } - - /*Update number of gyro data read*/ - *gyro_length = gyro_index; - - /*Update the gyro frame index*/ - dev->fifo->gyro_byte_start_idx = data_index; -} - -/*! - * @brief This API computes the number of bytes of aux FIFO data - * which is to be parsed in header-less mode - */ -static void get_aux_len_to_parse( - uint16_t* data_index, - uint16_t* data_read_length, - const uint8_t* aux_frame_count, - const struct bmi160_dev* dev) { - /* Data start index */ - *data_index = dev->fifo->gyro_byte_start_idx; - if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_ENABLE) { - *data_read_length = (*aux_frame_count) * BMI160_FIFO_M_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_A_ENABLE) { - *data_read_length = (*aux_frame_count) * BMI160_FIFO_MA_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_ENABLE) { - *data_read_length = (*aux_frame_count) * BMI160_FIFO_MG_LENGTH; - } else if(dev->fifo->fifo_data_enable == BMI160_FIFO_M_G_A_ENABLE) { - *data_read_length = (*aux_frame_count) * BMI160_FIFO_MGA_LENGTH; - } else { - /* When aux is not enabled ,there will be no aux data. - * so we update the data index as complete */ - *data_index = dev->fifo->length; - } - - if(*data_read_length > dev->fifo->length) { - /* Handling the case where more data is requested - * than that is available */ - *data_read_length = dev->fifo->length; - } -} - -/*! - * @brief This API is used to parse the aux's data from the - * FIFO data in both header mode and header-less mode. - * It updates the idx value which is used to store the index of - * the current data byte which is parsed - */ -static void unpack_aux_frame( - struct bmi160_aux_data* aux_data, - uint16_t* idx, - uint8_t* aux_index, - uint8_t frame_info, - const struct bmi160_dev* dev) { - switch(frame_info) { - case BMI160_FIFO_HEAD_M: - case BMI160_FIFO_M_ENABLE: - - /* Partial read, then skip the data */ - if((*idx + BMI160_FIFO_M_LENGTH) > dev->fifo->length) { - /* Update the data index as complete */ - *idx = dev->fifo->length; - break; - } - - /* Unpack the data array into structure instance */ - unpack_aux_data(&aux_data[*aux_index], *idx, dev); - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_M_LENGTH; - (*aux_index)++; - break; - case BMI160_FIFO_HEAD_M_A: - case BMI160_FIFO_M_A_ENABLE: - - /* Partial read, then skip the data */ - if((*idx + BMI160_FIFO_MA_LENGTH) > dev->fifo->length) { - /* Update the data index as complete */ - *idx = dev->fifo->length; - break; - } - - /* Unpack the data array into structure instance */ - unpack_aux_data(&aux_data[*aux_index], *idx, dev); - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_MA_LENGTH; - (*aux_index)++; - break; - case BMI160_FIFO_HEAD_M_G: - case BMI160_FIFO_M_G_ENABLE: - - /* Partial read, then skip the data */ - if((*idx + BMI160_FIFO_MG_LENGTH) > dev->fifo->length) { - /* Update the data index as complete */ - *idx = dev->fifo->length; - break; - } - - /* Unpack the data array into structure instance */ - unpack_aux_data(&aux_data[*aux_index], *idx, dev); - - /* Move the data index */ - (*idx) = (*idx) + BMI160_FIFO_MG_LENGTH; - (*aux_index)++; - break; - case BMI160_FIFO_HEAD_M_G_A: - case BMI160_FIFO_M_G_A_ENABLE: - - /*Partial read, then skip the data*/ - if((*idx + BMI160_FIFO_MGA_LENGTH) > dev->fifo->length) { - /* Update the data index as complete */ - *idx = dev->fifo->length; - break; - } - - /* Unpack the data array into structure instance */ - unpack_aux_data(&aux_data[*aux_index], *idx, dev); - - /*Move the data index*/ - *idx = *idx + BMI160_FIFO_MGA_LENGTH; - (*aux_index)++; - break; - case BMI160_FIFO_HEAD_G: - case BMI160_FIFO_G_ENABLE: - - /* Move the data index */ - (*idx) = (*idx) + BMI160_FIFO_G_LENGTH; - break; - case BMI160_FIFO_HEAD_G_A: - case BMI160_FIFO_G_A_ENABLE: - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_GA_LENGTH; - break; - case BMI160_FIFO_HEAD_A: - case BMI160_FIFO_A_ENABLE: - - /* Move the data index */ - *idx = *idx + BMI160_FIFO_A_LENGTH; - break; - default: - break; - } -} - -/*! - * @brief This API is used to parse the aux data from the - * FIFO data and store it in the instance of the structure bmi160_aux_data. - */ -static void unpack_aux_data( - struct bmi160_aux_data* aux_data, - uint16_t data_start_index, - const struct bmi160_dev* dev) { - /* Aux data bytes */ - aux_data->data[0] = dev->fifo->data[data_start_index++]; - aux_data->data[1] = dev->fifo->data[data_start_index++]; - aux_data->data[2] = dev->fifo->data[data_start_index++]; - aux_data->data[3] = dev->fifo->data[data_start_index++]; - aux_data->data[4] = dev->fifo->data[data_start_index++]; - aux_data->data[5] = dev->fifo->data[data_start_index++]; - aux_data->data[6] = dev->fifo->data[data_start_index++]; - aux_data->data[7] = dev->fifo->data[data_start_index++]; -} - -/*! - * @brief This API is used to parse the aux data from the - * FIFO data in header mode. - */ -static void extract_aux_header_mode( - struct bmi160_aux_data* aux_data, - uint8_t* aux_length, - const struct bmi160_dev* dev) { - uint8_t frame_header = 0; - uint16_t data_index; - uint8_t aux_index = 0; - - for(data_index = dev->fifo->aux_byte_start_idx; data_index < dev->fifo->length;) { - /* extracting Frame header */ - frame_header = (dev->fifo->data[data_index] & BMI160_FIFO_TAG_INTR_MASK); - - /*Index is moved to next byte where the data is starting*/ - data_index++; - switch(frame_header) { - /* Aux frame */ - case BMI160_FIFO_HEAD_M: - case BMI160_FIFO_HEAD_M_A: - case BMI160_FIFO_HEAD_M_G: - case BMI160_FIFO_HEAD_M_G_A: - unpack_aux_frame(aux_data, &data_index, &aux_index, frame_header, dev); - break; - case BMI160_FIFO_HEAD_G: - move_next_frame(&data_index, BMI160_FIFO_G_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_G_A: - move_next_frame(&data_index, BMI160_FIFO_GA_LENGTH, dev); - break; - case BMI160_FIFO_HEAD_A: - move_next_frame(&data_index, BMI160_FIFO_A_LENGTH, dev); - break; - - /* Sensor time frame */ - case BMI160_FIFO_HEAD_SENSOR_TIME: - unpack_sensortime_frame(&data_index, dev); - break; - - /* Skip frame */ - case BMI160_FIFO_HEAD_SKIP_FRAME: - unpack_skipped_frame(&data_index, dev); - break; - - /* Input config frame */ - case BMI160_FIFO_HEAD_INPUT_CONFIG: - move_next_frame(&data_index, 1, dev); - break; - case BMI160_FIFO_HEAD_OVER_READ: - - /* Update the data index as complete in case - * of over read */ - data_index = dev->fifo->length; - break; - default: - - /* Update the data index as complete in case of - * getting other headers like 0x00 */ - data_index = dev->fifo->length; - break; - } - if(*aux_length == aux_index) { - /*Number of frames to read completed*/ - break; - } - } - - /* Update number of aux data read */ - *aux_length = aux_index; - - /* Update the aux frame index */ - dev->fifo->aux_byte_start_idx = data_index; -} - -/*! - * @brief This API checks the presence of non-valid frames in the read fifo data. - */ -static void check_frame_validity(uint16_t* data_index, const struct bmi160_dev* dev) { - if((*data_index + 2) < dev->fifo->length) { - /* Check if FIFO is empty */ - if((dev->fifo->data[*data_index] == FIFO_CONFIG_MSB_CHECK) && - (dev->fifo->data[*data_index + 1] == FIFO_CONFIG_LSB_CHECK)) { - /*Update the data index as complete*/ - *data_index = dev->fifo->length; - } - } -} - -/*! - * @brief This API is used to move the data index ahead of the - * current_frame_length parameter when unnecessary FIFO data appears while - * extracting the user specified data. - */ -static void move_next_frame( - uint16_t* data_index, - uint8_t current_frame_length, - const struct bmi160_dev* dev) { - /*Partial read, then move the data index to last data*/ - if((*data_index + current_frame_length) > dev->fifo->length) { - /*Update the data index as complete*/ - *data_index = dev->fifo->length; - } else { - /*Move the data index to next frame*/ - *data_index = *data_index + current_frame_length; - } -} - -/*! - * @brief This API is used to parse and store the sensor time from the - * FIFO data in the structure instance dev. - */ -static void unpack_sensortime_frame(uint16_t* data_index, const struct bmi160_dev* dev) { - uint32_t sensor_time_byte3 = 0; - uint16_t sensor_time_byte2 = 0; - uint8_t sensor_time_byte1 = 0; - - /*Partial read, then move the data index to last data*/ - if((*data_index + BMI160_SENSOR_TIME_LENGTH) > dev->fifo->length) { - /*Update the data index as complete*/ - *data_index = dev->fifo->length; - } else { - sensor_time_byte3 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_MSB_BYTE] << 16; - sensor_time_byte2 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_XLSB_BYTE] << 8; - sensor_time_byte1 = dev->fifo->data[(*data_index)]; - - /* Sensor time */ - dev->fifo->sensor_time = - (uint32_t)(sensor_time_byte3 | sensor_time_byte2 | sensor_time_byte1); - *data_index = (*data_index) + BMI160_SENSOR_TIME_LENGTH; - } -} - -/*! - * @brief This API is used to parse and store the skipped_frame_count from - * the FIFO data in the structure instance dev. - */ -static void unpack_skipped_frame(uint16_t* data_index, const struct bmi160_dev* dev) { - /*Partial read, then move the data index to last data*/ - if(*data_index >= dev->fifo->length) { - /*Update the data index as complete*/ - *data_index = dev->fifo->length; - } else { - dev->fifo->skipped_frame_count = dev->fifo->data[*data_index]; - - /*Move the data index*/ - *data_index = (*data_index) + 1; - } -} - -/*! - * @brief This API is used to get the FOC status from the sensor - */ -static int8_t get_foc_status(uint8_t* foc_status, struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t data; - - /* Read the FOC status from sensor */ - rslt = bmi160_get_regs(BMI160_STATUS_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* Get the foc_status bit */ - *foc_status = BMI160_GET_BITS(data, BMI160_FOC_STATUS); - } - - return rslt; -} - -/*! - * @brief This API is used to configure the offset enable bits in the sensor - */ -static int8_t - configure_offset_enable(const struct bmi160_foc_conf* foc_conf, struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t data; - - /* Null-pointer check */ - rslt = null_ptr_check(dev); - if(rslt != BMI160_OK) { - rslt = BMI160_E_NULL_PTR; - } else { - /* Read the FOC config from the sensor */ - rslt = bmi160_get_regs(BMI160_OFFSET_CONF_ADDR, &data, 1, dev); - if(rslt == BMI160_OK) { - /* Set the offset enable/disable for gyro */ - data = BMI160_SET_BITS(data, BMI160_GYRO_OFFSET_EN, foc_conf->gyro_off_en); - - /* Set the offset enable/disable for accel */ - data = BMI160_SET_BITS(data, BMI160_ACCEL_OFFSET_EN, foc_conf->acc_off_en); - - /* Set the offset config in the sensor */ - rslt = bmi160_set_regs(BMI160_OFFSET_CONF_ADDR, &data, 1, dev); - } - } - - return rslt; -} - -static int8_t trigger_foc(struct bmi160_offsets* offset, struct bmi160_dev const* dev) { - int8_t rslt; - uint8_t foc_status = BMI160_ENABLE; - uint8_t cmd = BMI160_START_FOC_CMD; - uint8_t timeout = 0; - uint8_t data_array[20]; - - /* Start the FOC process */ - rslt = bmi160_set_regs(BMI160_COMMAND_REG_ADDR, &cmd, 1, dev); - if(rslt == BMI160_OK) { - /* Check the FOC status*/ - rslt = get_foc_status(&foc_status, dev); - - if((rslt != BMI160_OK) || (foc_status != BMI160_ENABLE)) { - while((foc_status != BMI160_ENABLE) && (timeout < 11)) { - /* Maximum time of 250ms is given in 10 - * steps of 25ms each - 250ms refer datasheet 2.9.1 */ - dev->delay_ms(25); - - /* Check the FOC status*/ - rslt = get_foc_status(&foc_status, dev); - timeout++; - } - - if((rslt == BMI160_OK) && (foc_status == BMI160_ENABLE)) { - /* Get offset values from sensor */ - rslt = bmi160_get_offsets(offset, dev); - } else { - /* FOC failure case */ - rslt = BMI160_E_FOC_FAILURE; - } - } - - if(rslt == BMI160_OK) { - /* Read registers 0x04-0x17 */ - rslt = bmi160_get_regs(BMI160_GYRO_DATA_ADDR, data_array, 20, dev); - } - } - - return rslt; -} diff --git a/applications/plugins/airmouse/tracking/imu/bmi160.h b/applications/plugins/airmouse/tracking/imu/bmi160.h deleted file mode 100644 index d4d98094c..000000000 --- a/applications/plugins/airmouse/tracking/imu/bmi160.h +++ /dev/null @@ -1,992 +0,0 @@ -/** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. -* -* BSD-3-Clause -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* 3. Neither the name of the copyright holder nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -* -* @file bmi160.h -* @date 2021-10-05 -* @version v3.9.2 -* -*/ - -/*! - * @defgroup bmi160 BMI160 - */ - -#ifndef BMI160_H_ -#define BMI160_H_ - -/*************************** C++ guard macro *****************************/ -#ifdef __cplusplus -extern "C" { -#endif - -#include "bmi160_defs.h" -#ifdef __KERNEL__ -#include -#else -#include -#include -#include -#endif - -/*********************** User function prototypes ************************/ - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiInit Initialization - * @brief Initialize the sensor and device structure - */ - -/*! - * \ingroup bmi160ApiInit - * \page bmi160_api_bmi160_init bmi160_init - * \code - * int8_t bmi160_init(struct bmi160_dev *dev); - * \endcode - * @details This API is the entry point for sensor.It performs - * the selection of I2C/SPI read mechanism according to the - * selected interface and reads the chip-id of bmi160 sensor. - * - * @param[in,out] dev : Structure instance of bmi160_dev - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_init(struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiRegs Registers - * @brief Read data from the given register address of sensor - */ - -/*! - * \ingroup bmi160ApiRegs - * \page bmi160_api_bmi160_get_regs bmi160_get_regs - * \code - * int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev); - * \endcode - * @details This API reads the data from the given register address of sensor. - * - * @param[in] reg_addr : Register address from where the data to be read - * @param[out] data : Pointer to data buffer to store the read data. - * @param[in] len : No of bytes of data to be read. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note For most of the registers auto address increment applies, with the - * exception of a few special registers, which trap the address. For e.g., - * Register address - 0x24(BMI160_FIFO_DATA_ADDR) - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t - bmi160_get_regs(uint8_t reg_addr, uint8_t* data, uint16_t len, const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiRegs - * \page bmi160_api_bmi160_set_regs bmi160_set_regs - * \code - * int8_t bmi160_set_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev); - * \endcode - * @details This API writes the given data to the register address - * of sensor. - * - * @param[in] reg_addr : Register address from where the data to be written. - * @param[in] data : Pointer to data buffer which is to be written - * in the sensor. - * @param[in] len : No of bytes of data to write.. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t - bmi160_set_regs(uint8_t reg_addr, uint8_t* data, uint16_t len, const struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiSoftreset Soft reset - * @brief Perform soft reset of the sensor - */ - -/*! - * \ingroup bmi160ApiSoftreset - * \page bmi160_api_bmi160_soft_reset bmi160_soft_reset - * \code - * int8_t bmi160_soft_reset(struct bmi160_dev *dev); - * \endcode - * @details This API resets and restarts the device. - * All register values are overwritten with default parameters. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_soft_reset(struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiConfig Configuration - * @brief Configuration of the sensor - */ - -/*! - * \ingroup bmi160ApiConfig - * \page bmi160_api_bmi160_set_sens_conf bmi160_set_sens_conf - * \code - * int8_t bmi160_set_sens_conf(struct bmi160_dev *dev); - * \endcode - * @details This API configures the power mode, range and bandwidth - * of sensor. - * - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_set_sens_conf(struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiConfig - * \page bmi160_api_bmi160_get_sens_conf bmi160_get_sens_conf - * \code - * int8_t bmi160_get_sens_conf(struct bmi160_dev *dev); - * \endcode - * @details This API gets accel and gyro configurations. - * - * @param[out] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_get_sens_conf(struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiPowermode Power mode - * @brief Set / Get power mode of the sensor - */ - -/*! - * \ingroup bmi160ApiPowermode - * \page bmi160_api_bmi160_set_power_mode bmi160_set_power_mode - * \code - * int8_t bmi160_set_power_mode(struct bmi160_dev *dev); - * \endcode - * @details This API sets the power mode of the sensor. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_set_power_mode(struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiPowermode - * \page bmi160_api_bmi160_get_power_mode bmi160_get_power_mode - * \code - * int8_t bmi160_get_power_mode(struct bmi160_dev *dev); - * \endcode - * @details This API gets the power mode of the sensor. - * - * @param[in] dev : Structure instance of bmi160_dev - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_get_power_mode(struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiData Sensor Data - * @brief Read sensor data - */ - -/*! - * \ingroup bmi160ApiData - * \page bmi160_api_bmi160_get_sensor_data bmi160_get_sensor_data - * \code - * int8_t bmi160_get_sensor_data(uint8_t select_sensor, - * struct bmi160_sensor_data *accel, - * struct bmi160_sensor_data *gyro, - * const struct bmi160_dev *dev); - * - * \endcode - * @details This API reads sensor data, stores it in - * the bmi160_sensor_data structure pointer passed by the user. - * The user can ask for accel data ,gyro data or both sensor - * data using bmi160_select_sensor enum - * - * @param[in] select_sensor : enum to choose accel,gyro or both sensor data - * @param[out] accel : Structure pointer to store accel data - * @param[out] gyro : Structure pointer to store gyro data - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_get_sensor_data( - uint8_t select_sensor, - struct bmi160_sensor_data* accel, - struct bmi160_sensor_data* gyro, - const struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiInt Interrupt configuration - * @brief Set interrupt configuration of the sensor - */ - -/*! - * \ingroup bmi160ApiInt - * \page bmi160_api_bmi160_set_int_config bmi160_set_int_config - * \code - * int8_t bmi160_set_int_config(struct bmi160_int_settg *int_config, struct bmi160_dev *dev); - * \endcode - * @details This API configures the necessary interrupt based on - * the user settings in the bmi160_int_settg structure instance. - * - * @param[in] int_config : Structure instance of bmi160_int_settg. - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_set_int_config(struct bmi160_int_settg* int_config, struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiStepC Step counter - * @brief Step counter operations - */ - -/*! - * \ingroup bmi160ApiStepC - * \page bmi160_api_bmi160_set_step_counter bmi160_set_step_counter - * \code - * int8_t bmi160_set_step_counter(uint8_t step_cnt_enable, const struct bmi160_dev *dev); - * \endcode - * @details This API enables the step counter feature. - * - * @param[in] step_cnt_enable : value to enable or disable - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_set_step_counter(uint8_t step_cnt_enable, const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiStepC - * \page bmi160_api_bmi160_read_step_counter bmi160_read_step_counter - * \code - * int8_t bmi160_read_step_counter(uint16_t *step_val, const struct bmi160_dev *dev); - * \endcode - * @details This API reads the step counter value. - * - * @param[in] step_val : Pointer to store the step counter value. - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_read_step_counter(uint16_t* step_val, const struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiAux Auxiliary sensor - * @brief Auxiliary sensor operations - */ - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_aux_read bmi160_aux_read - * \code - * int8_t bmi160_aux_read(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev); - * \endcode - * @details This API reads the mention no of byte of data from the given - * register address of auxiliary sensor. - * - * @param[in] reg_addr : Address of register to read. - * @param[in] aux_data : Pointer to store the read data. - * @param[in] len : No of bytes to read. - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_aux_read( - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_aux_write bmi160_aux_write - * \code - * int8_t bmi160_aux_write(uint8_t reg_addr, uint8_t *aux_data, uint16_t len, const struct bmi160_dev *dev); - * \endcode - * @details This API writes the mention no of byte of data to the given - * register address of auxiliary sensor. - * - * @param[in] reg_addr : Address of register to write. - * @param[in] aux_data : Pointer to write data. - * @param[in] len : No of bytes to write. - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_aux_write( - uint8_t reg_addr, - uint8_t* aux_data, - uint16_t len, - const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_aux_init bmi160_aux_init - * \code - * int8_t bmi160_aux_init(const struct bmi160_dev *dev); - * \endcode - * @details This API initialize the auxiliary sensor - * in order to access it. - * - * @param[in] dev : Structure instance of bmi160_dev. - * @note : Refer user guide for detailed info. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_aux_init(const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_set_aux_auto_mode bmi160_set_aux_auto_mode - * \code - * int8_t bmi160_set_aux_auto_mode(uint8_t *data_addr, struct bmi160_dev *dev); - * \endcode - * @details This API is used to setup the auxiliary sensor of bmi160 in auto mode - * Thus enabling the auto update of 8 bytes of data from auxiliary sensor - * to BMI160 register address 0x04 to 0x0B - * - * @param[in] data_addr : Starting address of aux. sensor's data register - * (BMI160 registers 0x04 to 0x0B will be updated - * with 8 bytes of data from auxiliary sensor - * starting from this register address.) - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note : Set the value of auxiliary polling rate by setting - * dev->aux_cfg.aux_odr to the required value from the table - * before calling this API - * - *@verbatim - * dev->aux_cfg.aux_odr | Auxiliary ODR (Hz) - * -----------------------|----------------------- - * BMI160_AUX_ODR_0_78HZ | 25/32 - * BMI160_AUX_ODR_1_56HZ | 25/16 - * BMI160_AUX_ODR_3_12HZ | 25/8 - * BMI160_AUX_ODR_6_25HZ | 25/4 - * BMI160_AUX_ODR_12_5HZ | 25/2 - * BMI160_AUX_ODR_25HZ | 25 - * BMI160_AUX_ODR_50HZ | 50 - * BMI160_AUX_ODR_100HZ | 100 - * BMI160_AUX_ODR_200HZ | 200 - * BMI160_AUX_ODR_400HZ | 400 - * BMI160_AUX_ODR_800HZ | 800 - *@endverbatim - * - * @note : Other values of dev->aux_cfg.aux_odr are reserved and not for use - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_set_aux_auto_mode(uint8_t* data_addr, struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_config_aux_mode bmi160_config_aux_mode - * \code - * int8_t bmi160_config_aux_mode(const struct bmi160_dev *dev); - * \endcode - * @details This API configures the 0x4C register and settings like - * Auxiliary sensor manual enable/ disable and aux burst read length. - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_config_aux_mode(const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiAux - * \page bmi160_api_bmi160_read_aux_data_auto_mode bmi160_read_aux_data_auto_mode - * \code - * int8_t bmi160_read_aux_data_auto_mode(uint8_t *aux_data, const struct bmi160_dev *dev); - * \endcode - * @details This API is used to read the raw uncompensated auxiliary sensor - * data of 8 bytes from BMI160 register address 0x04 to 0x0B - * - * @param[in] aux_data : Pointer to user array of length 8 bytes - * Ensure that the aux_data array is of - * length 8 bytes - * @param[in] dev : Structure instance of bmi160_dev - * - * @retval zero -> Success / -ve value -> Error - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_read_aux_data_auto_mode(uint8_t* aux_data, const struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiSelfTest Self test - * @brief Perform self test of the sensor - */ - -/*! - * \ingroup bmi160ApiSelfTest - * \page bmi160_api_bmi160_perform_self_test bmi160_perform_self_test - * \code - * int8_t bmi160_perform_self_test(uint8_t select_sensor, struct bmi160_dev *dev); - * \endcode - * @details This is used to perform self test of accel/gyro of the BMI160 sensor - * - * @param[in] select_sensor : enum to choose accel or gyro for self test - * @param[in] dev : Structure instance of bmi160_dev - * - * @note self test can be performed either for accel/gyro at any instant. - * - *@verbatim - * value of select_sensor | Inference - *----------------------------------|-------------------------------- - * BMI160_ACCEL_ONLY | Accel self test enabled - * BMI160_GYRO_ONLY | Gyro self test enabled - * BMI160_BOTH_ACCEL_AND_GYRO | NOT TO BE USED - *@endverbatim - * - * @note The return value of this API gives us the result of self test. - * - * @note Performing self test does soft reset of the sensor, User can - * set the desired settings after performing the self test. - * - * @return Result of API execution status - * @retval BMI160_OK Self test success - * @retval BMI160_W_GYRO_SELF_TEST_FAIL Gyro self test fail - * @retval BMI160_W_ACCEl_SELF_TEST_FAIL Accel self test fail - */ -int8_t bmi160_perform_self_test(uint8_t select_sensor, struct bmi160_dev* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiFIFO FIFO - * @brief FIFO operations of the sensor - */ - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_get_fifo_data bmi160_get_fifo_data - * \code - * int8_t bmi160_get_fifo_data(struct bmi160_dev const *dev); - * \endcode - * @details This API reads data from the fifo buffer. - * - * @note User has to allocate the FIFO buffer along with - * corresponding fifo length from his side before calling this API - * as mentioned in the readme.md - * - * @note User must specify the number of bytes to read from the FIFO in - * dev->fifo->length , It will be updated by the number of bytes actually - * read from FIFO after calling this API - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval Zero Success - * @retval Negative Error - */ -int8_t bmi160_get_fifo_data(struct bmi160_dev const* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_set_fifo_flush bmi160_set_fifo_flush - * \code - * int8_t bmi160_set_fifo_flush(const struct bmi160_dev *dev); - * \endcode - * @details This API writes fifo_flush command to command register.This - * action clears all data in the Fifo without changing fifo configuration - * settings. - * - * @param[in] dev : Structure instance of bmi160_dev - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_set_fifo_flush(const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_set_fifo_config bmi160_set_fifo_config - * \code - * int8_t bmi160_set_fifo_config(uint8_t config, uint8_t enable, struct bmi160_dev const *dev); - * \endcode - * @details This API sets the FIFO configuration in the sensor. - * - * @param[in] config : variable used to specify the FIFO - * configurations which are to be enabled or disabled in the sensor. - * - * @note : User can set either set one or more or all FIFO configurations - * by ORing the below mentioned macros. - * - *@verbatim - * config | Value - * ------------------------|--------------------------- - * BMI160_FIFO_TIME | 0x02 - * BMI160_FIFO_TAG_INT2 | 0x04 - * BMI160_FIFO_TAG_INT1 | 0x08 - * BMI160_FIFO_HEADER | 0x10 - * BMI160_FIFO_AUX | 0x20 - * BMI160_FIFO_ACCEL | 0x40 - * BMI160_FIFO_GYRO | 0x80 - *@endverbatim - * - * @param[in] enable : Parameter used to enable or disable the above - * FIFO configuration - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return status of bus communication result - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_set_fifo_config(uint8_t config, uint8_t enable, struct bmi160_dev const* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_set_fifo_down bmi160_set_fifo_down - * \code - * int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev *dev); - * \endcode - * @details This API is used to configure the down sampling ratios of - * the accel and gyro data for FIFO.Also, it configures filtered or - * pre-filtered data for the fifo for accel and gyro. - * - * @param[in] fifo_down : variable used to specify the FIFO down - * configurations which are to be enabled or disabled in the sensor. - * - * @note The user must select one among the following macros to - * select down-sampling ratio for accel - * - *@verbatim - * config | Value - * -------------------------------------|--------------------------- - * BMI160_ACCEL_FIFO_DOWN_ZERO | 0x00 - * BMI160_ACCEL_FIFO_DOWN_ONE | 0x10 - * BMI160_ACCEL_FIFO_DOWN_TWO | 0x20 - * BMI160_ACCEL_FIFO_DOWN_THREE | 0x30 - * BMI160_ACCEL_FIFO_DOWN_FOUR | 0x40 - * BMI160_ACCEL_FIFO_DOWN_FIVE | 0x50 - * BMI160_ACCEL_FIFO_DOWN_SIX | 0x60 - * BMI160_ACCEL_FIFO_DOWN_SEVEN | 0x70 - *@endverbatim - * - * @note The user must select one among the following macros to - * select down-sampling ratio for gyro - * - *@verbatim - * config | Value - * -------------------------------------|--------------------------- - * BMI160_GYRO_FIFO_DOWN_ZERO | 0x00 - * BMI160_GYRO_FIFO_DOWN_ONE | 0x01 - * BMI160_GYRO_FIFO_DOWN_TWO | 0x02 - * BMI160_GYRO_FIFO_DOWN_THREE | 0x03 - * BMI160_GYRO_FIFO_DOWN_FOUR | 0x04 - * BMI160_GYRO_FIFO_DOWN_FIVE | 0x05 - * BMI160_GYRO_FIFO_DOWN_SIX | 0x06 - * BMI160_GYRO_FIFO_DOWN_SEVEN | 0x07 - *@endverbatim - * - * @note The user can enable filtered accel data by the following macro - * - *@verbatim - * config | Value - * -------------------------------------|--------------------------- - * BMI160_ACCEL_FIFO_FILT_EN | 0x80 - *@endverbatim - * - * @note The user can enable filtered gyro data by the following macro - * - *@verbatim - * config | Value - * -------------------------------------|--------------------------- - * BMI160_GYRO_FIFO_FILT_EN | 0x08 - *@endverbatim - * - * @note : By ORing the above mentioned macros, the user can select - * the required FIFO down config settings - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return status of bus communication result - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_set_fifo_down(uint8_t fifo_down, const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_set_fifo_wm bmi160_set_fifo_wm - * \code - * int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev *dev); - * \endcode - * @details This API sets the FIFO watermark level in the sensor. - * - * @note The FIFO watermark is issued when the FIFO fill level is - * equal or above the watermark level and units of watermark is 4 bytes. - * - * @param[in] fifo_wm : Variable used to set the FIFO water mark level - * @param[in] dev : Structure instance of bmi160_dev - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_set_fifo_wm(uint8_t fifo_wm, const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_extract_accel bmi160_extract_accel - * \code - * int8_t bmi160_extract_accel(struct bmi160_sensor_data *accel_data, uint8_t *accel_length, struct bmi160_dev const - **dev); - * \endcode - * @details This API parses and extracts the accelerometer frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the "accel_data" structure instance. - * - * @note The bmi160_extract_accel API should be called only after - * reading the FIFO data by calling the bmi160_get_fifo_data() API. - * - * @param[out] accel_data : Structure instance of bmi160_sensor_data - * where the accelerometer data in FIFO is stored. - * @param[in,out] accel_length : Number of valid accelerometer frames - * (x,y,z axes data) read out from fifo. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note accel_length is updated with the number of valid accelerometer - * frames extracted from fifo (1 accel frame = 6 bytes) at the end of - * execution of this API. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_extract_accel( - struct bmi160_sensor_data* accel_data, - uint8_t* accel_length, - struct bmi160_dev const* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_extract_gyro bmi160_extract_gyro - * \code - * int8_t bmi160_extract_gyro(struct bmi160_sensor_data *gyro_data, uint8_t *gyro_length, struct bmi160_dev const *dev); - * \endcode - * @details This API parses and extracts the gyro frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the "gyro_data" structure instance. - * - * @note The bmi160_extract_gyro API should be called only after - * reading the FIFO data by calling the bmi160_get_fifo_data() API. - * - * @param[out] gyro_data : Structure instance of bmi160_sensor_data - * where the gyro data in FIFO is stored. - * @param[in,out] gyro_length : Number of valid gyro frames - * (x,y,z axes data) read out from fifo. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note gyro_length is updated with the number of valid gyro - * frames extracted from fifo (1 gyro frame = 6 bytes) at the end of - * execution of this API. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_extract_gyro( - struct bmi160_sensor_data* gyro_data, - uint8_t* gyro_length, - struct bmi160_dev const* dev); - -/*! - * \ingroup bmi160ApiFIFO - * \page bmi160_api_bmi160_extract_aux bmi160_extract_aux - * \code - * int8_t bmi160_extract_aux(struct bmi160_aux_data *aux_data, uint8_t *aux_len, struct bmi160_dev const *dev); - * \endcode - * @details This API parses and extracts the aux frames from - * FIFO data read by the "bmi160_get_fifo_data" API and stores it in - * the bmi160_aux_data structure instance. - * - * @note The bmi160_extract_aux API should be called only after - * reading the FIFO data by calling the bmi160_get_fifo_data() API. - * - * @param[out] aux_data : Structure instance of bmi160_aux_data - * where the aux data in FIFO is stored. - * @param[in,out] aux_len : Number of valid aux frames (8bytes) - * read out from FIFO. - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note aux_len is updated with the number of valid aux - * frames extracted from fifo (1 aux frame = 8 bytes) at the end of - * execution of this API. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - * - */ -int8_t bmi160_extract_aux( - struct bmi160_aux_data* aux_data, - uint8_t* aux_len, - struct bmi160_dev const* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiFOC FOC - * @brief Start FOC of accel and gyro sensors - */ - -/*! - * \ingroup bmi160ApiFOC - * \page bmi160_api_bmi160_start_foc bmi160_start_foc - * \code - * int8_t bmi160_start_foc(const struct bmi160_foc_conf *foc_conf, - * \endcode - * @details This API starts the FOC of accel and gyro - * - * @note FOC should not be used in low-power mode of sensor - * - * @note Accel FOC targets values of +1g , 0g , -1g - * Gyro FOC always targets value of 0 dps - * - * @param[in] foc_conf : Structure instance of bmi160_foc_conf which - * has the FOC configuration - * @param[in,out] offset : Structure instance to store Offset - * values read from sensor - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note Pre-requisites for triggering FOC in accel , Set the following, - * Enable the acc_off_en - * Ex : foc_conf.acc_off_en = BMI160_ENABLE; - * - * Set the desired target values of FOC to each axes (x,y,z) by using the - * following macros - * - BMI160_FOC_ACCEL_DISABLED - * - BMI160_FOC_ACCEL_POSITIVE_G - * - BMI160_FOC_ACCEL_NEGATIVE_G - * - BMI160_FOC_ACCEL_0G - * - * Ex : foc_conf.foc_acc_x = BMI160_FOC_ACCEL_0G; - * foc_conf.foc_acc_y = BMI160_FOC_ACCEL_0G; - * foc_conf.foc_acc_z = BMI160_FOC_ACCEL_POSITIVE_G; - * - * @note Pre-requisites for triggering FOC in gyro , - * Set the following parameters, - * - * Ex : foc_conf.foc_gyr_en = BMI160_ENABLE; - * foc_conf.gyro_off_en = BMI160_ENABLE; - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - */ -int8_t bmi160_start_foc( - const struct bmi160_foc_conf* foc_conf, - struct bmi160_offsets* offset, - struct bmi160_dev const* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiOffsets Offsets - * @brief Set / Get offset values of accel and gyro sensors - */ - -/*! - * \ingroup bmi160ApiOffsets - * \page bmi160_api_bmi160_get_offsets bmi160_get_offsets - * \code - * int8_t bmi160_get_offsets(struct bmi160_offsets *offset, const struct bmi160_dev *dev); - * \endcode - * @details This API reads and stores the offset values of accel and gyro - * - * @param[in,out] offset : Structure instance of bmi160_offsets in which - * the offset values are read and stored - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - */ -int8_t bmi160_get_offsets(struct bmi160_offsets* offset, const struct bmi160_dev* dev); - -/*! - * \ingroup bmi160ApiOffsets - * \page bmi160_api_bmi160_set_offsets bmi160_set_offsets - * \code - * int8_t bmi160_set_offsets(const struct bmi160_foc_conf *foc_conf, - * const struct bmi160_offsets *offset, - * struct bmi160_dev const *dev); - * \endcode - * @details This API writes the offset values of accel and gyro to - * the sensor but these values will be reset on POR or soft reset. - * - * @param[in] foc_conf : Structure instance of bmi160_foc_conf which - * has the FOC configuration - * @param[in] offset : Structure instance in which user updates offset - * values which are to be written in the sensor - * @param[in] dev : Structure instance of bmi160_dev. - * - * @note Offsets can be set by user like offset->off_acc_x = 10; - * where 1LSB = 3.9mg and for gyro 1LSB = 0.061degrees/second - * - * @note BMI160 offset values for xyz axes of accel should be within range of - * BMI160_ACCEL_MIN_OFFSET (-128) to BMI160_ACCEL_MAX_OFFSET (127) - * - * @note BMI160 offset values for xyz axes of gyro should be within range of - * BMI160_GYRO_MIN_OFFSET (-512) to BMI160_GYRO_MAX_OFFSET (511) - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - */ -int8_t bmi160_set_offsets( - const struct bmi160_foc_conf* foc_conf, - const struct bmi160_offsets* offset, - struct bmi160_dev const* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiNVM NVM - * @brief Write image registers values to NVM - */ - -/*! - * \ingroup bmi160ApiNVM - * \page bmi160_api_bmi160_update_nvm bmi160_update_nvm - * \code - * int8_t bmi160_update_nvm(struct bmi160_dev const *dev); - * \endcode - * @details This API writes the image registers values to NVM which is - * stored even after POR or soft reset - * - * @param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - */ -int8_t bmi160_update_nvm(struct bmi160_dev const* dev); - -/** - * \ingroup bmi160 - * \defgroup bmi160ApiInts Interrupt status - * @brief Read interrupt status from the sensor - */ - -/*! - * \ingroup bmi160ApiInts - * \page bmi160_api_bmi160_get_int_status bmi160_get_int_status - * \code - * int8_t bmi160_get_int_status(enum bmi160_int_status_sel int_status_sel, - * union bmi160_int_status *int_status, - * struct bmi160_dev const *dev); - * \endcode - * @details This API gets the interrupt status from the sensor. - * - * @param[in] int_status_sel : Enum variable to select either individual or all the - * interrupt status bits. - * @param[in] int_status : pointer variable to get the interrupt status - * from the sensor. - * param[in] dev : Structure instance of bmi160_dev. - * - * @return Result of API execution status - * @retval 0 -> Success - * @retval Any non zero value -> Fail - */ -int8_t bmi160_get_int_status( - enum bmi160_int_status_sel int_status_sel, - union bmi160_int_status* int_status, - struct bmi160_dev const* dev); - -/*************************** C++ guard macro *****************************/ -#ifdef __cplusplus -} -#endif - -#endif /* BMI160_H_ */ diff --git a/applications/plugins/airmouse/tracking/imu/bmi160_defs.h b/applications/plugins/airmouse/tracking/imu/bmi160_defs.h deleted file mode 100644 index 458ecaad5..000000000 --- a/applications/plugins/airmouse/tracking/imu/bmi160_defs.h +++ /dev/null @@ -1,1619 +0,0 @@ -/** -* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. -* -* BSD-3-Clause -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* 3. Neither the name of the copyright holder nor the names of its -* contributors may be used to endorse or promote products derived from -* this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -* -* @file bmi160_defs.h -* @date 2021-10-05 -* @version v3.9.2 -* -*/ - -#ifndef BMI160_DEFS_H_ -#define BMI160_DEFS_H_ - -/*************************** C types headers *****************************/ -#ifdef __KERNEL__ -#include -#include -#else -#include -#include -#endif - -/*************************** Common macros *****************************/ - -#if !defined(UINT8_C) && !defined(INT8_C) -#define INT8_C(x) S8_C(x) -#define UINT8_C(x) U8_C(x) -#endif - -#if !defined(UINT16_C) && !defined(INT16_C) -#define INT16_C(x) S16_C(x) -#define UINT16_C(x) U16_C(x) -#endif - -#if !defined(INT32_C) && !defined(UINT32_C) -#define INT32_C(x) S32_C(x) -#define UINT32_C(x) U32_C(x) -#endif - -#if !defined(INT64_C) && !defined(UINT64_C) -#define INT64_C(x) S64_C(x) -#define UINT64_C(x) U64_C(x) -#endif - -/**@}*/ -/**\name C standard macros */ -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void*)0) -#endif -#endif - -/*************************** Sensor macros *****************************/ -/* Test for an endian machine */ -#ifndef __ORDER_LITTLE_ENDIAN__ -#define __ORDER_LITTLE_ENDIAN__ 0 -#endif - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ -#endif - -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -#ifndef LITTLE_ENDIAN -#define LITTLE_ENDIAN 1 -#endif -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#ifndef BIG_ENDIAN -#define BIG_ENDIAN 1 -#endif -#else -#error "Code does not support Endian format of the processor" -#endif - -/** Mask definitions */ -#define BMI160_ACCEL_BW_MASK UINT8_C(0x70) -#define BMI160_ACCEL_ODR_MASK UINT8_C(0x0F) -#define BMI160_ACCEL_UNDERSAMPLING_MASK UINT8_C(0x80) -#define BMI160_ACCEL_RANGE_MASK UINT8_C(0x0F) -#define BMI160_GYRO_BW_MASK UINT8_C(0x30) -#define BMI160_GYRO_ODR_MASK UINT8_C(0x0F) -#define BMI160_GYRO_RANGE_MASK UINT8_C(0x07) - -#define BMI160_ACCEL_BW_POS UINT8_C(4) -#define BMI160_GYRO_BW_POS UINT8_C(4) - -/** Mask definitions for INT_EN registers */ -#define BMI160_ANY_MOTION_X_INT_EN_MASK UINT8_C(0x01) -#define BMI160_HIGH_G_X_INT_EN_MASK UINT8_C(0x01) -#define BMI160_NO_MOTION_X_INT_EN_MASK UINT8_C(0x01) -#define BMI160_ANY_MOTION_Y_INT_EN_MASK UINT8_C(0x02) -#define BMI160_HIGH_G_Y_INT_EN_MASK UINT8_C(0x02) -#define BMI160_NO_MOTION_Y_INT_EN_MASK UINT8_C(0x02) -#define BMI160_ANY_MOTION_Z_INT_EN_MASK UINT8_C(0x04) -#define BMI160_HIGH_G_Z_INT_EN_MASK UINT8_C(0x04) -#define BMI160_NO_MOTION_Z_INT_EN_MASK UINT8_C(0x04) -#define BMI160_SIG_MOTION_INT_EN_MASK UINT8_C(0x07) -#define BMI160_ANY_MOTION_ALL_INT_EN_MASK UINT8_C(0x07) -#define BMI160_STEP_DETECT_INT_EN_MASK UINT8_C(0x08) -#define BMI160_DOUBLE_TAP_INT_EN_MASK UINT8_C(0x10) -#define BMI160_SINGLE_TAP_INT_EN_MASK UINT8_C(0x20) -#define BMI160_FIFO_FULL_INT_EN_MASK UINT8_C(0x20) -#define BMI160_ORIENT_INT_EN_MASK UINT8_C(0x40) -#define BMI160_FIFO_WATERMARK_INT_EN_MASK UINT8_C(0x40) -#define BMI160_LOW_G_INT_EN_MASK UINT8_C(0x08) -#define BMI160_STEP_DETECT_EN_MASK UINT8_C(0x08) -#define BMI160_FLAT_INT_EN_MASK UINT8_C(0x80) -#define BMI160_DATA_RDY_INT_EN_MASK UINT8_C(0x10) - -/** PMU status Macros */ -#define BMI160_AUX_PMU_SUSPEND UINT8_C(0x00) -#define BMI160_AUX_PMU_NORMAL UINT8_C(0x01) -#define BMI160_AUX_PMU_LOW_POWER UINT8_C(0x02) - -#define BMI160_GYRO_PMU_SUSPEND UINT8_C(0x00) -#define BMI160_GYRO_PMU_NORMAL UINT8_C(0x01) -#define BMI160_GYRO_PMU_FSU UINT8_C(0x03) - -#define BMI160_ACCEL_PMU_SUSPEND UINT8_C(0x00) -#define BMI160_ACCEL_PMU_NORMAL UINT8_C(0x01) -#define BMI160_ACCEL_PMU_LOW_POWER UINT8_C(0x02) - -/** Mask definitions for INT_OUT_CTRL register */ -#define BMI160_INT1_EDGE_CTRL_MASK UINT8_C(0x01) -#define BMI160_INT1_OUTPUT_MODE_MASK UINT8_C(0x04) -#define BMI160_INT1_OUTPUT_TYPE_MASK UINT8_C(0x02) -#define BMI160_INT1_OUTPUT_EN_MASK UINT8_C(0x08) -#define BMI160_INT2_EDGE_CTRL_MASK UINT8_C(0x10) -#define BMI160_INT2_OUTPUT_MODE_MASK UINT8_C(0x40) -#define BMI160_INT2_OUTPUT_TYPE_MASK UINT8_C(0x20) -#define BMI160_INT2_OUTPUT_EN_MASK UINT8_C(0x80) - -/** Mask definitions for INT_LATCH register */ -#define BMI160_INT1_INPUT_EN_MASK UINT8_C(0x10) -#define BMI160_INT2_INPUT_EN_MASK UINT8_C(0x20) -#define BMI160_INT_LATCH_MASK UINT8_C(0x0F) - -/** Mask definitions for INT_MAP register */ -#define BMI160_INT1_LOW_G_MASK UINT8_C(0x01) -#define BMI160_INT1_HIGH_G_MASK UINT8_C(0x02) -#define BMI160_INT1_SLOPE_MASK UINT8_C(0x04) -#define BMI160_INT1_NO_MOTION_MASK UINT8_C(0x08) -#define BMI160_INT1_DOUBLE_TAP_MASK UINT8_C(0x10) -#define BMI160_INT1_SINGLE_TAP_MASK UINT8_C(0x20) -#define BMI160_INT1_FIFO_FULL_MASK UINT8_C(0x20) -#define BMI160_INT1_FIFO_WM_MASK UINT8_C(0x40) -#define BMI160_INT1_ORIENT_MASK UINT8_C(0x40) -#define BMI160_INT1_FLAT_MASK UINT8_C(0x80) -#define BMI160_INT1_DATA_READY_MASK UINT8_C(0x80) -#define BMI160_INT2_LOW_G_MASK UINT8_C(0x01) -#define BMI160_INT1_LOW_STEP_DETECT_MASK UINT8_C(0x01) -#define BMI160_INT2_LOW_STEP_DETECT_MASK UINT8_C(0x01) -#define BMI160_INT2_HIGH_G_MASK UINT8_C(0x02) -#define BMI160_INT2_FIFO_FULL_MASK UINT8_C(0x02) -#define BMI160_INT2_FIFO_WM_MASK UINT8_C(0x04) -#define BMI160_INT2_SLOPE_MASK UINT8_C(0x04) -#define BMI160_INT2_DATA_READY_MASK UINT8_C(0x08) -#define BMI160_INT2_NO_MOTION_MASK UINT8_C(0x08) -#define BMI160_INT2_DOUBLE_TAP_MASK UINT8_C(0x10) -#define BMI160_INT2_SINGLE_TAP_MASK UINT8_C(0x20) -#define BMI160_INT2_ORIENT_MASK UINT8_C(0x40) -#define BMI160_INT2_FLAT_MASK UINT8_C(0x80) - -/** Mask definitions for INT_DATA register */ -#define BMI160_TAP_SRC_INT_MASK UINT8_C(0x08) -#define BMI160_LOW_HIGH_SRC_INT_MASK UINT8_C(0x80) -#define BMI160_MOTION_SRC_INT_MASK UINT8_C(0x80) - -/** Mask definitions for INT_MOTION register */ -#define BMI160_SLOPE_INT_DUR_MASK UINT8_C(0x03) -#define BMI160_NO_MOTION_INT_DUR_MASK UINT8_C(0xFC) -#define BMI160_NO_MOTION_SEL_BIT_MASK UINT8_C(0x01) - -/** Mask definitions for INT_TAP register */ -#define BMI160_TAP_DUR_MASK UINT8_C(0x07) -#define BMI160_TAP_SHOCK_DUR_MASK UINT8_C(0x40) -#define BMI160_TAP_QUIET_DUR_MASK UINT8_C(0x80) -#define BMI160_TAP_THRES_MASK UINT8_C(0x1F) - -/** Mask definitions for INT_FLAT register */ -#define BMI160_FLAT_THRES_MASK UINT8_C(0x3F) -#define BMI160_FLAT_HOLD_TIME_MASK UINT8_C(0x30) -#define BMI160_FLAT_HYST_MASK UINT8_C(0x07) - -/** Mask definitions for INT_LOWHIGH register */ -#define BMI160_LOW_G_HYST_MASK UINT8_C(0x03) -#define BMI160_LOW_G_LOW_MODE_MASK UINT8_C(0x04) -#define BMI160_HIGH_G_HYST_MASK UINT8_C(0xC0) - -/** Mask definitions for INT_SIG_MOTION register */ -#define BMI160_SIG_MOTION_SEL_MASK UINT8_C(0x02) -#define BMI160_SIG_MOTION_SKIP_MASK UINT8_C(0x0C) -#define BMI160_SIG_MOTION_PROOF_MASK UINT8_C(0x30) - -/** Mask definitions for INT_ORIENT register */ -#define BMI160_ORIENT_MODE_MASK UINT8_C(0x03) -#define BMI160_ORIENT_BLOCK_MASK UINT8_C(0x0C) -#define BMI160_ORIENT_HYST_MASK UINT8_C(0xF0) -#define BMI160_ORIENT_THETA_MASK UINT8_C(0x3F) -#define BMI160_ORIENT_UD_ENABLE UINT8_C(0x40) -#define BMI160_AXES_EN_MASK UINT8_C(0x80) - -/** Mask definitions for FIFO_CONFIG register */ -#define BMI160_FIFO_GYRO UINT8_C(0x80) -#define BMI160_FIFO_ACCEL UINT8_C(0x40) -#define BMI160_FIFO_AUX UINT8_C(0x20) -#define BMI160_FIFO_TAG_INT1 UINT8_C(0x08) -#define BMI160_FIFO_TAG_INT2 UINT8_C(0x04) -#define BMI160_FIFO_TIME UINT8_C(0x02) -#define BMI160_FIFO_HEADER UINT8_C(0x10) -#define BMI160_FIFO_CONFIG_1_MASK UINT8_C(0xFE) - -/** Mask definitions for STEP_CONF register */ -#define BMI160_STEP_COUNT_EN_BIT_MASK UINT8_C(0x08) -#define BMI160_STEP_DETECT_MIN_THRES_MASK UINT8_C(0x18) -#define BMI160_STEP_DETECT_STEPTIME_MIN_MASK UINT8_C(0x07) -#define BMI160_STEP_MIN_BUF_MASK UINT8_C(0x07) - -/** Mask definition for FIFO Header Data Tag */ -#define BMI160_FIFO_TAG_INTR_MASK UINT8_C(0xFC) - -/** Fifo byte counter mask definitions */ -#define BMI160_FIFO_BYTE_COUNTER_MASK UINT8_C(0x07) - -/** Enable/disable bit value */ -#define BMI160_ENABLE UINT8_C(0x01) -#define BMI160_DISABLE UINT8_C(0x00) - -/** Latch Duration */ -#define BMI160_LATCH_DUR_NONE UINT8_C(0x00) -#define BMI160_LATCH_DUR_312_5_MICRO_SEC UINT8_C(0x01) -#define BMI160_LATCH_DUR_625_MICRO_SEC UINT8_C(0x02) -#define BMI160_LATCH_DUR_1_25_MILLI_SEC UINT8_C(0x03) -#define BMI160_LATCH_DUR_2_5_MILLI_SEC UINT8_C(0x04) -#define BMI160_LATCH_DUR_5_MILLI_SEC UINT8_C(0x05) -#define BMI160_LATCH_DUR_10_MILLI_SEC UINT8_C(0x06) -#define BMI160_LATCH_DUR_20_MILLI_SEC UINT8_C(0x07) -#define BMI160_LATCH_DUR_40_MILLI_SEC UINT8_C(0x08) -#define BMI160_LATCH_DUR_80_MILLI_SEC UINT8_C(0x09) -#define BMI160_LATCH_DUR_160_MILLI_SEC UINT8_C(0x0A) -#define BMI160_LATCH_DUR_320_MILLI_SEC UINT8_C(0x0B) -#define BMI160_LATCH_DUR_640_MILLI_SEC UINT8_C(0x0C) -#define BMI160_LATCH_DUR_1_28_SEC UINT8_C(0x0D) -#define BMI160_LATCH_DUR_2_56_SEC UINT8_C(0x0E) -#define BMI160_LATCHED UINT8_C(0x0F) - -/** BMI160 Register map */ -#define BMI160_CHIP_ID_ADDR UINT8_C(0x00) -#define BMI160_ERROR_REG_ADDR UINT8_C(0x02) -#define BMI160_PMU_STATUS_ADDR UINT8_C(0x03) -#define BMI160_AUX_DATA_ADDR UINT8_C(0x04) -#define BMI160_GYRO_DATA_ADDR UINT8_C(0x0C) -#define BMI160_ACCEL_DATA_ADDR UINT8_C(0x12) -#define BMI160_STATUS_ADDR UINT8_C(0x1B) -#define BMI160_INT_STATUS_ADDR UINT8_C(0x1C) -#define BMI160_FIFO_LENGTH_ADDR UINT8_C(0x22) -#define BMI160_FIFO_DATA_ADDR UINT8_C(0x24) -#define BMI160_ACCEL_CONFIG_ADDR UINT8_C(0x40) -#define BMI160_ACCEL_RANGE_ADDR UINT8_C(0x41) -#define BMI160_GYRO_CONFIG_ADDR UINT8_C(0x42) -#define BMI160_GYRO_RANGE_ADDR UINT8_C(0x43) -#define BMI160_AUX_ODR_ADDR UINT8_C(0x44) -#define BMI160_FIFO_DOWN_ADDR UINT8_C(0x45) -#define BMI160_FIFO_CONFIG_0_ADDR UINT8_C(0x46) -#define BMI160_FIFO_CONFIG_1_ADDR UINT8_C(0x47) -#define BMI160_AUX_IF_0_ADDR UINT8_C(0x4B) -#define BMI160_AUX_IF_1_ADDR UINT8_C(0x4C) -#define BMI160_AUX_IF_2_ADDR UINT8_C(0x4D) -#define BMI160_AUX_IF_3_ADDR UINT8_C(0x4E) -#define BMI160_AUX_IF_4_ADDR UINT8_C(0x4F) -#define BMI160_INT_ENABLE_0_ADDR UINT8_C(0x50) -#define BMI160_INT_ENABLE_1_ADDR UINT8_C(0x51) -#define BMI160_INT_ENABLE_2_ADDR UINT8_C(0x52) -#define BMI160_INT_OUT_CTRL_ADDR UINT8_C(0x53) -#define BMI160_INT_LATCH_ADDR UINT8_C(0x54) -#define BMI160_INT_MAP_0_ADDR UINT8_C(0x55) -#define BMI160_INT_MAP_1_ADDR UINT8_C(0x56) -#define BMI160_INT_MAP_2_ADDR UINT8_C(0x57) -#define BMI160_INT_DATA_0_ADDR UINT8_C(0x58) -#define BMI160_INT_DATA_1_ADDR UINT8_C(0x59) -#define BMI160_INT_LOWHIGH_0_ADDR UINT8_C(0x5A) -#define BMI160_INT_LOWHIGH_1_ADDR UINT8_C(0x5B) -#define BMI160_INT_LOWHIGH_2_ADDR UINT8_C(0x5C) -#define BMI160_INT_LOWHIGH_3_ADDR UINT8_C(0x5D) -#define BMI160_INT_LOWHIGH_4_ADDR UINT8_C(0x5E) -#define BMI160_INT_MOTION_0_ADDR UINT8_C(0x5F) -#define BMI160_INT_MOTION_1_ADDR UINT8_C(0x60) -#define BMI160_INT_MOTION_2_ADDR UINT8_C(0x61) -#define BMI160_INT_MOTION_3_ADDR UINT8_C(0x62) -#define BMI160_INT_TAP_0_ADDR UINT8_C(0x63) -#define BMI160_INT_TAP_1_ADDR UINT8_C(0x64) -#define BMI160_INT_ORIENT_0_ADDR UINT8_C(0x65) -#define BMI160_INT_ORIENT_1_ADDR UINT8_C(0x66) -#define BMI160_INT_FLAT_0_ADDR UINT8_C(0x67) -#define BMI160_INT_FLAT_1_ADDR UINT8_C(0x68) -#define BMI160_FOC_CONF_ADDR UINT8_C(0x69) -#define BMI160_CONF_ADDR UINT8_C(0x6A) - -#define BMI160_IF_CONF_ADDR UINT8_C(0x6B) -#define BMI160_SELF_TEST_ADDR UINT8_C(0x6D) -#define BMI160_OFFSET_ADDR UINT8_C(0x71) -#define BMI160_OFFSET_CONF_ADDR UINT8_C(0x77) -#define BMI160_INT_STEP_CNT_0_ADDR UINT8_C(0x78) -#define BMI160_INT_STEP_CONFIG_0_ADDR UINT8_C(0x7A) -#define BMI160_INT_STEP_CONFIG_1_ADDR UINT8_C(0x7B) -#define BMI160_COMMAND_REG_ADDR UINT8_C(0x7E) -#define BMI160_SPI_COMM_TEST_ADDR UINT8_C(0x7F) -#define BMI160_INTL_PULLUP_CONF_ADDR UINT8_C(0x85) - -/** Error code definitions */ -#define BMI160_OK INT8_C(0) -#define BMI160_E_NULL_PTR INT8_C(-1) -#define BMI160_E_COM_FAIL INT8_C(-2) -#define BMI160_E_DEV_NOT_FOUND INT8_C(-3) -#define BMI160_E_OUT_OF_RANGE INT8_C(-4) -#define BMI160_E_INVALID_INPUT INT8_C(-5) -#define BMI160_E_ACCEL_ODR_BW_INVALID INT8_C(-6) -#define BMI160_E_GYRO_ODR_BW_INVALID INT8_C(-7) -#define BMI160_E_LWP_PRE_FLTR_INT_INVALID INT8_C(-8) -#define BMI160_E_LWP_PRE_FLTR_INVALID INT8_C(-9) -#define BMI160_E_AUX_NOT_FOUND INT8_C(-10) -#define BMI160_E_FOC_FAILURE INT8_C(-11) -#define BMI160_E_READ_WRITE_LENGTH_INVALID INT8_C(-12) -#define BMI160_E_INVALID_CONFIG INT8_C(-13) - -/**\name API warning codes */ -#define BMI160_W_GYRO_SELF_TEST_FAIL INT8_C(1) -#define BMI160_W_ACCEl_SELF_TEST_FAIL INT8_C(2) - -/** BMI160 unique chip identifier */ -#define BMI160_CHIP_ID UINT8_C(0xD1) - -/** Soft reset command */ -#define BMI160_SOFT_RESET_CMD UINT8_C(0xb6) -#define BMI160_SOFT_RESET_DELAY_MS UINT8_C(1) - -/** Start FOC command */ -#define BMI160_START_FOC_CMD UINT8_C(0x03) - -/** NVM backup enabling command */ -#define BMI160_NVM_BACKUP_EN UINT8_C(0xA0) - -/* Delay in ms settings */ -#define BMI160_ACCEL_DELAY_MS UINT8_C(5) -#define BMI160_GYRO_DELAY_MS UINT8_C(80) -#define BMI160_ONE_MS_DELAY UINT8_C(1) -#define BMI160_AUX_COM_DELAY UINT8_C(10) -#define BMI160_GYRO_SELF_TEST_DELAY UINT8_C(20) -#define BMI160_ACCEL_SELF_TEST_DELAY UINT8_C(50) - -/** Self test configurations */ -#define BMI160_ACCEL_SELF_TEST_CONFIG UINT8_C(0x2C) -#define BMI160_ACCEL_SELF_TEST_POSITIVE_EN UINT8_C(0x0D) -#define BMI160_ACCEL_SELF_TEST_NEGATIVE_EN UINT8_C(0x09) -#define BMI160_ACCEL_SELF_TEST_LIMIT UINT16_C(8192) - -/** Power mode settings */ -/* Accel power mode */ -#define BMI160_ACCEL_NORMAL_MODE UINT8_C(0x11) -#define BMI160_ACCEL_LOWPOWER_MODE UINT8_C(0x12) -#define BMI160_ACCEL_SUSPEND_MODE UINT8_C(0x10) - -/* Gyro power mode */ -#define BMI160_GYRO_SUSPEND_MODE UINT8_C(0x14) -#define BMI160_GYRO_NORMAL_MODE UINT8_C(0x15) -#define BMI160_GYRO_FASTSTARTUP_MODE UINT8_C(0x17) - -/* Aux power mode */ -#define BMI160_AUX_SUSPEND_MODE UINT8_C(0x18) -#define BMI160_AUX_NORMAL_MODE UINT8_C(0x19) -#define BMI160_AUX_LOWPOWER_MODE UINT8_C(0x1A) - -/** Range settings */ -/* Accel Range */ -#define BMI160_ACCEL_RANGE_2G UINT8_C(0x03) -#define BMI160_ACCEL_RANGE_4G UINT8_C(0x05) -#define BMI160_ACCEL_RANGE_8G UINT8_C(0x08) -#define BMI160_ACCEL_RANGE_16G UINT8_C(0x0C) - -/* Gyro Range */ -#define BMI160_GYRO_RANGE_2000_DPS UINT8_C(0x00) -#define BMI160_GYRO_RANGE_1000_DPS UINT8_C(0x01) -#define BMI160_GYRO_RANGE_500_DPS UINT8_C(0x02) -#define BMI160_GYRO_RANGE_250_DPS UINT8_C(0x03) -#define BMI160_GYRO_RANGE_125_DPS UINT8_C(0x04) - -/** Bandwidth settings */ -/* Accel Bandwidth */ -#define BMI160_ACCEL_BW_OSR4_AVG1 UINT8_C(0x00) -#define BMI160_ACCEL_BW_OSR2_AVG2 UINT8_C(0x01) -#define BMI160_ACCEL_BW_NORMAL_AVG4 UINT8_C(0x02) -#define BMI160_ACCEL_BW_RES_AVG8 UINT8_C(0x03) -#define BMI160_ACCEL_BW_RES_AVG16 UINT8_C(0x04) -#define BMI160_ACCEL_BW_RES_AVG32 UINT8_C(0x05) -#define BMI160_ACCEL_BW_RES_AVG64 UINT8_C(0x06) -#define BMI160_ACCEL_BW_RES_AVG128 UINT8_C(0x07) - -#define BMI160_GYRO_BW_OSR4_MODE UINT8_C(0x00) -#define BMI160_GYRO_BW_OSR2_MODE UINT8_C(0x01) -#define BMI160_GYRO_BW_NORMAL_MODE UINT8_C(0x02) - -/* Output Data Rate settings */ -/* Accel Output data rate */ -#define BMI160_ACCEL_ODR_RESERVED UINT8_C(0x00) -#define BMI160_ACCEL_ODR_0_78HZ UINT8_C(0x01) -#define BMI160_ACCEL_ODR_1_56HZ UINT8_C(0x02) -#define BMI160_ACCEL_ODR_3_12HZ UINT8_C(0x03) -#define BMI160_ACCEL_ODR_6_25HZ UINT8_C(0x04) -#define BMI160_ACCEL_ODR_12_5HZ UINT8_C(0x05) -#define BMI160_ACCEL_ODR_25HZ UINT8_C(0x06) -#define BMI160_ACCEL_ODR_50HZ UINT8_C(0x07) -#define BMI160_ACCEL_ODR_100HZ UINT8_C(0x08) -#define BMI160_ACCEL_ODR_200HZ UINT8_C(0x09) -#define BMI160_ACCEL_ODR_400HZ UINT8_C(0x0A) -#define BMI160_ACCEL_ODR_800HZ UINT8_C(0x0B) -#define BMI160_ACCEL_ODR_1600HZ UINT8_C(0x0C) -#define BMI160_ACCEL_ODR_RESERVED0 UINT8_C(0x0D) -#define BMI160_ACCEL_ODR_RESERVED1 UINT8_C(0x0E) -#define BMI160_ACCEL_ODR_RESERVED2 UINT8_C(0x0F) - -/* Gyro Output data rate */ -#define BMI160_GYRO_ODR_RESERVED UINT8_C(0x00) -#define BMI160_GYRO_ODR_25HZ UINT8_C(0x06) -#define BMI160_GYRO_ODR_50HZ UINT8_C(0x07) -#define BMI160_GYRO_ODR_100HZ UINT8_C(0x08) -#define BMI160_GYRO_ODR_200HZ UINT8_C(0x09) -#define BMI160_GYRO_ODR_400HZ UINT8_C(0x0A) -#define BMI160_GYRO_ODR_800HZ UINT8_C(0x0B) -#define BMI160_GYRO_ODR_1600HZ UINT8_C(0x0C) -#define BMI160_GYRO_ODR_3200HZ UINT8_C(0x0D) - -/* Auxiliary sensor Output data rate */ -#define BMI160_AUX_ODR_RESERVED UINT8_C(0x00) -#define BMI160_AUX_ODR_0_78HZ UINT8_C(0x01) -#define BMI160_AUX_ODR_1_56HZ UINT8_C(0x02) -#define BMI160_AUX_ODR_3_12HZ UINT8_C(0x03) -#define BMI160_AUX_ODR_6_25HZ UINT8_C(0x04) -#define BMI160_AUX_ODR_12_5HZ UINT8_C(0x05) -#define BMI160_AUX_ODR_25HZ UINT8_C(0x06) -#define BMI160_AUX_ODR_50HZ UINT8_C(0x07) -#define BMI160_AUX_ODR_100HZ UINT8_C(0x08) -#define BMI160_AUX_ODR_200HZ UINT8_C(0x09) -#define BMI160_AUX_ODR_400HZ UINT8_C(0x0A) -#define BMI160_AUX_ODR_800HZ UINT8_C(0x0B) - -/** FIFO_CONFIG Definitions */ -#define BMI160_FIFO_TIME_ENABLE UINT8_C(0x02) -#define BMI160_FIFO_TAG_INT2_ENABLE UINT8_C(0x04) -#define BMI160_FIFO_TAG_INT1_ENABLE UINT8_C(0x08) -#define BMI160_FIFO_HEAD_ENABLE UINT8_C(0x10) -#define BMI160_FIFO_M_ENABLE UINT8_C(0x20) -#define BMI160_FIFO_A_ENABLE UINT8_C(0x40) -#define BMI160_FIFO_M_A_ENABLE UINT8_C(0x60) -#define BMI160_FIFO_G_ENABLE UINT8_C(0x80) -#define BMI160_FIFO_M_G_ENABLE UINT8_C(0xA0) -#define BMI160_FIFO_G_A_ENABLE UINT8_C(0xC0) -#define BMI160_FIFO_M_G_A_ENABLE UINT8_C(0xE0) - -/* Macro to specify the number of bytes over-read from the - * FIFO in order to get the sensor time at the end of FIFO */ -#ifndef BMI160_FIFO_BYTES_OVERREAD -#define BMI160_FIFO_BYTES_OVERREAD UINT8_C(25) -#endif - -/* Accel, gyro and aux. sensor length and also their combined - * length definitions in FIFO */ -#define BMI160_FIFO_G_LENGTH UINT8_C(6) -#define BMI160_FIFO_A_LENGTH UINT8_C(6) -#define BMI160_FIFO_M_LENGTH UINT8_C(8) -#define BMI160_FIFO_GA_LENGTH UINT8_C(12) -#define BMI160_FIFO_MA_LENGTH UINT8_C(14) -#define BMI160_FIFO_MG_LENGTH UINT8_C(14) -#define BMI160_FIFO_MGA_LENGTH UINT8_C(20) - -/** FIFO Header Data definitions */ -#define BMI160_FIFO_HEAD_SKIP_FRAME UINT8_C(0x40) -#define BMI160_FIFO_HEAD_SENSOR_TIME UINT8_C(0x44) -#define BMI160_FIFO_HEAD_INPUT_CONFIG UINT8_C(0x48) -#define BMI160_FIFO_HEAD_OVER_READ UINT8_C(0x80) -#define BMI160_FIFO_HEAD_A UINT8_C(0x84) -#define BMI160_FIFO_HEAD_G UINT8_C(0x88) -#define BMI160_FIFO_HEAD_G_A UINT8_C(0x8C) -#define BMI160_FIFO_HEAD_M UINT8_C(0x90) -#define BMI160_FIFO_HEAD_M_A UINT8_C(0x94) -#define BMI160_FIFO_HEAD_M_G UINT8_C(0x98) -#define BMI160_FIFO_HEAD_M_G_A UINT8_C(0x9C) - -/** FIFO sensor time length definitions */ -#define BMI160_SENSOR_TIME_LENGTH UINT8_C(3) - -/** FIFO DOWN selection */ -/* Accel fifo down-sampling values*/ -#define BMI160_ACCEL_FIFO_DOWN_ZERO UINT8_C(0x00) -#define BMI160_ACCEL_FIFO_DOWN_ONE UINT8_C(0x10) -#define BMI160_ACCEL_FIFO_DOWN_TWO UINT8_C(0x20) -#define BMI160_ACCEL_FIFO_DOWN_THREE UINT8_C(0x30) -#define BMI160_ACCEL_FIFO_DOWN_FOUR UINT8_C(0x40) -#define BMI160_ACCEL_FIFO_DOWN_FIVE UINT8_C(0x50) -#define BMI160_ACCEL_FIFO_DOWN_SIX UINT8_C(0x60) -#define BMI160_ACCEL_FIFO_DOWN_SEVEN UINT8_C(0x70) - -/* Gyro fifo down-smapling values*/ -#define BMI160_GYRO_FIFO_DOWN_ZERO UINT8_C(0x00) -#define BMI160_GYRO_FIFO_DOWN_ONE UINT8_C(0x01) -#define BMI160_GYRO_FIFO_DOWN_TWO UINT8_C(0x02) -#define BMI160_GYRO_FIFO_DOWN_THREE UINT8_C(0x03) -#define BMI160_GYRO_FIFO_DOWN_FOUR UINT8_C(0x04) -#define BMI160_GYRO_FIFO_DOWN_FIVE UINT8_C(0x05) -#define BMI160_GYRO_FIFO_DOWN_SIX UINT8_C(0x06) -#define BMI160_GYRO_FIFO_DOWN_SEVEN UINT8_C(0x07) - -/* Accel Fifo filter enable*/ -#define BMI160_ACCEL_FIFO_FILT_EN UINT8_C(0x80) - -/* Gyro Fifo filter enable*/ -#define BMI160_GYRO_FIFO_FILT_EN UINT8_C(0x08) - -/** Definitions to check validity of FIFO frames */ -#define FIFO_CONFIG_MSB_CHECK UINT8_C(0x80) -#define FIFO_CONFIG_LSB_CHECK UINT8_C(0x00) - -/*! BMI160 accel FOC configurations */ -#define BMI160_FOC_ACCEL_DISABLED UINT8_C(0x00) -#define BMI160_FOC_ACCEL_POSITIVE_G UINT8_C(0x01) -#define BMI160_FOC_ACCEL_NEGATIVE_G UINT8_C(0x02) -#define BMI160_FOC_ACCEL_0G UINT8_C(0x03) - -/** Array Parameter DefinItions */ -#define BMI160_SENSOR_TIME_LSB_BYTE UINT8_C(0) -#define BMI160_SENSOR_TIME_XLSB_BYTE UINT8_C(1) -#define BMI160_SENSOR_TIME_MSB_BYTE UINT8_C(2) - -/** Interface settings */ -#define BMI160_SPI_INTF UINT8_C(1) -#define BMI160_I2C_INTF UINT8_C(0) -#define BMI160_SPI_RD_MASK UINT8_C(0x80) -#define BMI160_SPI_WR_MASK UINT8_C(0x7F) - -/* Sensor & time select definition*/ -#define BMI160_ACCEL_SEL UINT8_C(0x01) -#define BMI160_GYRO_SEL UINT8_C(0x02) -#define BMI160_TIME_SEL UINT8_C(0x04) - -/* Sensor select mask*/ -#define BMI160_SEN_SEL_MASK UINT8_C(0x07) - -/* Error code mask */ -#define BMI160_ERR_REG_MASK UINT8_C(0x0F) - -/* BMI160 I2C address */ -#define BMI160_I2C_ADDR UINT8_C(0x68) - -/* BMI160 secondary IF address */ -#define BMI160_AUX_BMM150_I2C_ADDR UINT8_C(0x10) - -/** BMI160 Length definitions */ -#define BMI160_ONE UINT8_C(1) -#define BMI160_TWO UINT8_C(2) -#define BMI160_THREE UINT8_C(3) -#define BMI160_FOUR UINT8_C(4) -#define BMI160_FIVE UINT8_C(5) - -/** BMI160 fifo level Margin */ -#define BMI160_FIFO_LEVEL_MARGIN UINT8_C(16) - -/** BMI160 fifo flush Command */ -#define BMI160_FIFO_FLUSH_VALUE UINT8_C(0xB0) - -/** BMI160 offset values for xyz axes of accel */ -#define BMI160_ACCEL_MIN_OFFSET INT8_C(-128) -#define BMI160_ACCEL_MAX_OFFSET INT8_C(127) - -/** BMI160 offset values for xyz axes of gyro */ -#define BMI160_GYRO_MIN_OFFSET INT16_C(-512) -#define BMI160_GYRO_MAX_OFFSET INT16_C(511) - -/** BMI160 fifo full interrupt position and mask */ -#define BMI160_FIFO_FULL_INT_POS UINT8_C(5) -#define BMI160_FIFO_FULL_INT_MSK UINT8_C(0x20) -#define BMI160_FIFO_WTM_INT_POS UINT8_C(6) -#define BMI160_FIFO_WTM_INT_MSK UINT8_C(0x40) - -#define BMI160_FIFO_FULL_INT_PIN1_POS UINT8_C(5) -#define BMI160_FIFO_FULL_INT_PIN1_MSK UINT8_C(0x20) -#define BMI160_FIFO_FULL_INT_PIN2_POS UINT8_C(1) -#define BMI160_FIFO_FULL_INT_PIN2_MSK UINT8_C(0x02) - -#define BMI160_FIFO_WTM_INT_PIN1_POS UINT8_C(6) -#define BMI160_FIFO_WTM_INT_PIN1_MSK UINT8_C(0x40) -#define BMI160_FIFO_WTM_INT_PIN2_POS UINT8_C(2) -#define BMI160_FIFO_WTM_INT_PIN2_MSK UINT8_C(0x04) - -#define BMI160_MANUAL_MODE_EN_POS UINT8_C(7) -#define BMI160_MANUAL_MODE_EN_MSK UINT8_C(0x80) -#define BMI160_AUX_READ_BURST_POS UINT8_C(0) -#define BMI160_AUX_READ_BURST_MSK UINT8_C(0x03) - -#define BMI160_GYRO_SELF_TEST_POS UINT8_C(4) -#define BMI160_GYRO_SELF_TEST_MSK UINT8_C(0x10) -#define BMI160_GYRO_SELF_TEST_STATUS_POS UINT8_C(1) -#define BMI160_GYRO_SELF_TEST_STATUS_MSK UINT8_C(0x02) - -#define BMI160_GYRO_FOC_EN_POS UINT8_C(6) -#define BMI160_GYRO_FOC_EN_MSK UINT8_C(0x40) - -#define BMI160_ACCEL_FOC_X_CONF_POS UINT8_C(4) -#define BMI160_ACCEL_FOC_X_CONF_MSK UINT8_C(0x30) - -#define BMI160_ACCEL_FOC_Y_CONF_POS UINT8_C(2) -#define BMI160_ACCEL_FOC_Y_CONF_MSK UINT8_C(0x0C) - -#define BMI160_ACCEL_FOC_Z_CONF_MSK UINT8_C(0x03) - -#define BMI160_FOC_STATUS_POS UINT8_C(3) -#define BMI160_FOC_STATUS_MSK UINT8_C(0x08) - -#define BMI160_GYRO_OFFSET_X_MSK UINT8_C(0x03) - -#define BMI160_GYRO_OFFSET_Y_POS UINT8_C(2) -#define BMI160_GYRO_OFFSET_Y_MSK UINT8_C(0x0C) - -#define BMI160_GYRO_OFFSET_Z_POS UINT8_C(4) -#define BMI160_GYRO_OFFSET_Z_MSK UINT8_C(0x30) - -#define BMI160_GYRO_OFFSET_EN_POS UINT8_C(7) -#define BMI160_GYRO_OFFSET_EN_MSK UINT8_C(0x80) - -#define BMI160_ACCEL_OFFSET_EN_POS UINT8_C(6) -#define BMI160_ACCEL_OFFSET_EN_MSK UINT8_C(0x40) - -#define BMI160_GYRO_OFFSET_POS UINT16_C(8) -#define BMI160_GYRO_OFFSET_MSK UINT16_C(0x0300) - -#define BMI160_NVM_UPDATE_POS UINT8_C(1) -#define BMI160_NVM_UPDATE_MSK UINT8_C(0x02) - -#define BMI160_NVM_STATUS_POS UINT8_C(4) -#define BMI160_NVM_STATUS_MSK UINT8_C(0x10) - -#define BMI160_MAG_POWER_MODE_MSK UINT8_C(0x03) - -#define BMI160_ACCEL_POWER_MODE_MSK UINT8_C(0x30) -#define BMI160_ACCEL_POWER_MODE_POS UINT8_C(4) - -#define BMI160_GYRO_POWER_MODE_MSK UINT8_C(0x0C) -#define BMI160_GYRO_POWER_MODE_POS UINT8_C(2) - -/* BIT SLICE GET AND SET FUNCTIONS */ -#define BMI160_GET_BITS(regvar, bitname) ((regvar & bitname##_MSK) >> bitname##_POS) -#define BMI160_SET_BITS(regvar, bitname, val) \ - ((regvar & ~bitname##_MSK) | ((val << bitname##_POS) & bitname##_MSK)) - -#define BMI160_SET_BITS_POS_0(reg_data, bitname, data) \ - ((reg_data & ~(bitname##_MSK)) | (data & bitname##_MSK)) - -#define BMI160_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK)) - -/**\name UTILITY MACROS */ -#define BMI160_SET_LOW_BYTE UINT16_C(0x00FF) -#define BMI160_SET_HIGH_BYTE UINT16_C(0xFF00) - -#define BMI160_GET_LSB(var) (uint8_t)(var & BMI160_SET_LOW_BYTE) -#define BMI160_GET_MSB(var) (uint8_t)((var & BMI160_SET_HIGH_BYTE) >> 8) - -/*****************************************************************************/ -/* type definitions */ - -/*! - * @brief Bus communication function pointer which should be mapped to - * the platform specific read functions of the user - */ -typedef int8_t ( - *bmi160_read_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t* data, uint16_t len); - -/*! - * @brief Bus communication function pointer which should be mapped to - * the platform specific write functions of the user - */ -typedef int8_t ( - *bmi160_write_fptr_t)(uint8_t dev_addr, uint8_t reg_addr, uint8_t* read_data, uint16_t len); -typedef void (*bmi160_delay_fptr_t)(uint32_t period); - -/*************************** Data structures *********************************/ - -/*! - * @brief bmi160 interrupt status selection enum. - */ -enum bmi160_int_status_sel { - BMI160_INT_STATUS_0 = 1, - BMI160_INT_STATUS_1 = 2, - BMI160_INT_STATUS_2 = 4, - BMI160_INT_STATUS_3 = 8, - BMI160_INT_STATUS_ALL = 15 -}; - -/*! - * @brief bmi160 interrupt status bits structure - */ -struct bmi160_int_status_bits { -#ifdef LITTLE_ENDIAN - - uint32_t step : 1; - uint32_t sigmot : 1; - uint32_t anym : 1; - - /* pmu trigger will be handled later */ - uint32_t pmu_trigger_reserved : 1; - uint32_t d_tap : 1; - uint32_t s_tap : 1; - uint32_t orient : 1; - uint32_t flat_int : 1; - uint32_t reserved : 2; - uint32_t high_g : 1; - uint32_t low_g : 1; - uint32_t drdy : 1; - uint32_t ffull : 1; - uint32_t fwm : 1; - uint32_t nomo : 1; - uint32_t anym_first_x : 1; - uint32_t anym_first_y : 1; - uint32_t anym_first_z : 1; - uint32_t anym_sign : 1; - uint32_t tap_first_x : 1; - uint32_t tap_first_y : 1; - uint32_t tap_first_z : 1; - uint32_t tap_sign : 1; - uint32_t high_first_x : 1; - uint32_t high_first_y : 1; - uint32_t high_first_z : 1; - uint32_t high_sign : 1; - uint32_t orient_1_0 : 2; - uint32_t orient_2 : 1; - uint32_t flat : 1; -#else - uint32_t high_first_x : 1; - uint32_t high_first_y : 1; - uint32_t high_first_z : 1; - uint32_t high_sign : 1; - uint32_t orient_1_0 : 2; - uint32_t orient_2 : 1; - uint32_t flat : 1; - uint32_t anym_first_x : 1; - uint32_t anym_first_y : 1; - uint32_t anym_first_z : 1; - uint32_t anym_sign : 1; - uint32_t tap_first_x : 1; - uint32_t tap_first_y : 1; - uint32_t tap_first_z : 1; - uint32_t tap_sign : 1; - uint32_t reserved : 2; - uint32_t high_g : 1; - uint32_t low_g : 1; - uint32_t drdy : 1; - uint32_t ffull : 1; - uint32_t fwm : 1; - uint32_t nomo : 1; - uint32_t step : 1; - uint32_t sigmot : 1; - uint32_t anym : 1; - - /* pmu trigger will be handled later */ - uint32_t pmu_trigger_reserved : 1; - uint32_t d_tap : 1; - uint32_t s_tap : 1; - uint32_t orient : 1; - uint32_t flat_int : 1; -#endif -}; - -/*! - * @brief bmi160 interrupt status structure - */ -union bmi160_int_status { - uint8_t data[4]; - struct bmi160_int_status_bits bit; -}; - -/*! - * @brief bmi160 sensor data structure which comprises of accel data - */ -struct bmi160_sensor_data { - /*! X-axis sensor data */ - int16_t x; - - /*! Y-axis sensor data */ - int16_t y; - - /*! Z-axis sensor data */ - int16_t z; - - /*! sensor time */ - uint32_t sensortime; -}; - -/*! - * @brief bmi160 aux data structure which comprises of 8 bytes of accel data - */ -struct bmi160_aux_data { - /*! Auxiliary data */ - uint8_t data[8]; -}; - -/*! - * @brief bmi160 FOC configuration structure - */ -struct bmi160_foc_conf { - /*! Enabling FOC in gyro - * Assignable macros : - * - BMI160_ENABLE - * - BMI160_DISABLE - */ - uint8_t foc_gyr_en; - - /*! Accel FOC configurations - * Assignable macros : - * - BMI160_FOC_ACCEL_DISABLED - * - BMI160_FOC_ACCEL_POSITIVE_G - * - BMI160_FOC_ACCEL_NEGATIVE_G - * - BMI160_FOC_ACCEL_0G - */ - uint8_t foc_acc_x; - uint8_t foc_acc_y; - uint8_t foc_acc_z; - - /*! Enabling offset compensation for accel in data registers - * Assignable macros : - * - BMI160_ENABLE - * - BMI160_DISABLE - */ - uint8_t acc_off_en; - - /*! Enabling offset compensation for gyro in data registers - * Assignable macros : - * - BMI160_ENABLE - * - BMI160_DISABLE - */ - uint8_t gyro_off_en; -}; - -/*! - * @brief bmi160 accel gyro offsets - */ -struct bmi160_offsets { - /*! Accel offset for x axis */ - int8_t off_acc_x; - - /*! Accel offset for y axis */ - int8_t off_acc_y; - - /*! Accel offset for z axis */ - int8_t off_acc_z; - - /*! Gyro offset for x axis */ - int16_t off_gyro_x; - - /*! Gyro offset for y axis */ - int16_t off_gyro_y; - - /*! Gyro offset for z axis */ - int16_t off_gyro_z; -}; - -/*! - * @brief FIFO aux. sensor data structure - */ -struct bmi160_aux_fifo_data { - /*! The value of aux. sensor x LSB data */ - uint8_t aux_x_lsb; - - /*! The value of aux. sensor x MSB data */ - uint8_t aux_x_msb; - - /*! The value of aux. sensor y LSB data */ - uint8_t aux_y_lsb; - - /*! The value of aux. sensor y MSB data */ - uint8_t aux_y_msb; - - /*! The value of aux. sensor z LSB data */ - uint8_t aux_z_lsb; - - /*! The value of aux. sensor z MSB data */ - uint8_t aux_z_msb; - - /*! The value of aux. sensor r for BMM150 LSB data */ - uint8_t aux_r_y2_lsb; - - /*! The value of aux. sensor r for BMM150 MSB data */ - uint8_t aux_r_y2_msb; -}; - -/*! - * @brief bmi160 sensor select structure - */ -enum bmi160_select_sensor { BMI160_ACCEL_ONLY = 1, BMI160_GYRO_ONLY, BMI160_BOTH_ACCEL_AND_GYRO }; - -/*! - * @brief bmi160 sensor step detector mode structure - */ -enum bmi160_step_detect_mode { - BMI160_STEP_DETECT_NORMAL, - BMI160_STEP_DETECT_SENSITIVE, - BMI160_STEP_DETECT_ROBUST, - - /*! Non recommended User defined setting */ - BMI160_STEP_DETECT_USER_DEFINE -}; - -/*! - * @brief enum for auxiliary burst read selection - */ -enum bmi160_aux_read_len { - BMI160_AUX_READ_LEN_0, - BMI160_AUX_READ_LEN_1, - BMI160_AUX_READ_LEN_2, - BMI160_AUX_READ_LEN_3 -}; - -/*! - * @brief bmi160 sensor configuration structure - */ -struct bmi160_cfg { - /*! power mode */ - uint8_t power; - - /*! output data rate */ - uint8_t odr; - - /*! range */ - uint8_t range; - - /*! bandwidth */ - uint8_t bw; -}; - -/*! - * @brief Aux sensor configuration structure - */ -struct bmi160_aux_cfg { - /*! Aux sensor, 1 - enable 0 - disable */ - uint8_t aux_sensor_enable : 1; - - /*! Aux manual/auto mode status */ - uint8_t manual_enable : 1; - - /*! Aux read burst length */ - uint8_t aux_rd_burst_len : 2; - - /*! output data rate */ - uint8_t aux_odr : 4; - - /*! i2c addr of auxiliary sensor */ - uint8_t aux_i2c_addr; -}; - -/*! - * @brief bmi160 interrupt channel selection structure - */ -enum bmi160_int_channel { - /*! Un-map both channels */ - BMI160_INT_CHANNEL_NONE, - - /*! interrupt Channel 1 */ - BMI160_INT_CHANNEL_1, - - /*! interrupt Channel 2 */ - BMI160_INT_CHANNEL_2, - - /*! Map both channels */ - BMI160_INT_CHANNEL_BOTH -}; -enum bmi160_int_types { - /*! Slope/Any-motion interrupt */ - BMI160_ACC_ANY_MOTION_INT, - - /*! Significant motion interrupt */ - BMI160_ACC_SIG_MOTION_INT, - - /*! Step detector interrupt */ - BMI160_STEP_DETECT_INT, - - /*! double tap interrupt */ - BMI160_ACC_DOUBLE_TAP_INT, - - /*! single tap interrupt */ - BMI160_ACC_SINGLE_TAP_INT, - - /*! orientation interrupt */ - BMI160_ACC_ORIENT_INT, - - /*! flat interrupt */ - BMI160_ACC_FLAT_INT, - - /*! high-g interrupt */ - BMI160_ACC_HIGH_G_INT, - - /*! low-g interrupt */ - BMI160_ACC_LOW_G_INT, - - /*! slow/no-motion interrupt */ - BMI160_ACC_SLOW_NO_MOTION_INT, - - /*! data ready interrupt */ - BMI160_ACC_GYRO_DATA_RDY_INT, - - /*! fifo full interrupt */ - BMI160_ACC_GYRO_FIFO_FULL_INT, - - /*! fifo watermark interrupt */ - BMI160_ACC_GYRO_FIFO_WATERMARK_INT, - - /*! fifo tagging feature support */ - BMI160_FIFO_TAG_INT_PIN -}; - -/*! - * @brief bmi160 active state of any & sig motion interrupt. - */ -enum bmi160_any_sig_motion_active_interrupt_state { - /*! Both any & sig motion are disabled */ - BMI160_BOTH_ANY_SIG_MOTION_DISABLED = -1, - - /*! Any-motion selected */ - BMI160_ANY_MOTION_ENABLED, - - /*! Sig-motion selected */ - BMI160_SIG_MOTION_ENABLED -}; -struct bmi160_acc_tap_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! tap threshold */ - uint16_t tap_thr : 5; - - /*! tap shock */ - uint16_t tap_shock : 1; - - /*! tap quiet */ - uint16_t tap_quiet : 1; - - /*! tap duration */ - uint16_t tap_dur : 3; - - /*! data source 0- filter & 1 pre-filter*/ - uint16_t tap_data_src : 1; - - /*! tap enable, 1 - enable, 0 - disable */ - uint16_t tap_en : 1; -#else - - /*! tap enable, 1 - enable, 0 - disable */ - uint16_t tap_en : 1; - - /*! data source 0- filter & 1 pre-filter*/ - uint16_t tap_data_src : 1; - - /*! tap duration */ - uint16_t tap_dur : 3; - - /*! tap quiet */ - uint16_t tap_quiet : 1; - - /*! tap shock */ - uint16_t tap_shock : 1; - - /*! tap threshold */ - uint16_t tap_thr : 5; -#endif -}; -struct bmi160_acc_any_mot_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! 1 any-motion enable, 0 - any-motion disable */ - uint8_t anymotion_en : 1; - - /*! slope interrupt x, 1 - enable, 0 - disable */ - uint8_t anymotion_x : 1; - - /*! slope interrupt y, 1 - enable, 0 - disable */ - uint8_t anymotion_y : 1; - - /*! slope interrupt z, 1 - enable, 0 - disable */ - uint8_t anymotion_z : 1; - - /*! slope duration */ - uint8_t anymotion_dur : 2; - - /*! data source 0- filter & 1 pre-filter*/ - uint8_t anymotion_data_src : 1; - - /*! slope threshold */ - uint8_t anymotion_thr; -#else - - /*! slope threshold */ - uint8_t anymotion_thr; - - /*! data source 0- filter & 1 pre-filter*/ - uint8_t anymotion_data_src : 1; - - /*! slope duration */ - uint8_t anymotion_dur : 2; - - /*! slope interrupt z, 1 - enable, 0 - disable */ - uint8_t anymotion_z : 1; - - /*! slope interrupt y, 1 - enable, 0 - disable */ - uint8_t anymotion_y : 1; - - /*! slope interrupt x, 1 - enable, 0 - disable */ - uint8_t anymotion_x : 1; - - /*! 1 any-motion enable, 0 - any-motion disable */ - uint8_t anymotion_en : 1; -#endif -}; -struct bmi160_acc_sig_mot_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! skip time of sig-motion interrupt */ - uint8_t sig_mot_skip : 2; - - /*! proof time of sig-motion interrupt */ - uint8_t sig_mot_proof : 2; - - /*! data source 0- filter & 1 pre-filter*/ - uint8_t sig_data_src : 1; - - /*! 1 - enable sig, 0 - disable sig & enable anymotion */ - uint8_t sig_en : 1; - - /*! sig-motion threshold */ - uint8_t sig_mot_thres; -#else - - /*! sig-motion threshold */ - uint8_t sig_mot_thres; - - /*! 1 - enable sig, 0 - disable sig & enable anymotion */ - uint8_t sig_en : 1; - - /*! data source 0- filter & 1 pre-filter*/ - uint8_t sig_data_src : 1; - - /*! proof time of sig-motion interrupt */ - uint8_t sig_mot_proof : 2; - - /*! skip time of sig-motion interrupt */ - uint8_t sig_mot_skip : 2; -#endif -}; -struct bmi160_acc_step_detect_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! 1- step detector enable, 0- step detector disable */ - uint16_t step_detector_en : 1; - - /*! minimum threshold */ - uint16_t min_threshold : 2; - - /*! minimal detectable step time */ - uint16_t steptime_min : 3; - - /*! enable step counter mode setting */ - uint16_t step_detector_mode : 2; - - /*! minimum step buffer size*/ - uint16_t step_min_buf : 3; -#else - - /*! minimum step buffer size*/ - uint16_t step_min_buf : 3; - - /*! enable step counter mode setting */ - uint16_t step_detector_mode : 2; - - /*! minimal detectable step time */ - uint16_t steptime_min : 3; - - /*! minimum threshold */ - uint16_t min_threshold : 2; - - /*! 1- step detector enable, 0- step detector disable */ - uint16_t step_detector_en : 1; -#endif -}; -struct bmi160_acc_no_motion_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! no motion interrupt x */ - uint16_t no_motion_x : 1; - - /*! no motion interrupt y */ - uint16_t no_motion_y : 1; - - /*! no motion interrupt z */ - uint16_t no_motion_z : 1; - - /*! no motion duration */ - uint16_t no_motion_dur : 6; - - /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */ - uint16_t no_motion_sel : 1; - - /*! data source 0- filter & 1 pre-filter*/ - uint16_t no_motion_src : 1; - - /*! no motion threshold */ - uint8_t no_motion_thres; -#else - - /*! no motion threshold */ - uint8_t no_motion_thres; - - /*! data source 0- filter & 1 pre-filter*/ - uint16_t no_motion_src : 1; - - /*! no motion sel , 1 - enable no-motion ,0- enable slow-motion */ - uint16_t no_motion_sel : 1; - - /*! no motion duration */ - uint16_t no_motion_dur : 6; - - /* no motion interrupt z */ - uint16_t no_motion_z : 1; - - /*! no motion interrupt y */ - uint16_t no_motion_y : 1; - - /*! no motion interrupt x */ - uint16_t no_motion_x : 1; -#endif -}; -struct bmi160_acc_orient_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! thresholds for switching between the different orientations */ - uint16_t orient_mode : 2; - - /*! blocking_mode */ - uint16_t orient_blocking : 2; - - /*! Orientation interrupt hysteresis */ - uint16_t orient_hyst : 4; - - /*! Orientation interrupt theta */ - uint16_t orient_theta : 6; - - /*! Enable/disable Orientation interrupt */ - uint16_t orient_ud_en : 1; - - /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */ - uint16_t axes_ex : 1; - - /*! 1 - orient enable, 0 - orient disable */ - uint8_t orient_en : 1; -#else - - /*! 1 - orient enable, 0 - orient disable */ - uint8_t orient_en : 1; - - /*! exchange x- and z-axis in algorithm ,0 - z, 1 - x */ - uint16_t axes_ex : 1; - - /*! Enable/disable Orientation interrupt */ - uint16_t orient_ud_en : 1; - - /*! Orientation interrupt theta */ - uint16_t orient_theta : 6; - - /*! Orientation interrupt hysteresis */ - uint16_t orient_hyst : 4; - - /*! blocking_mode */ - uint16_t orient_blocking : 2; - - /*! thresholds for switching between the different orientations */ - uint16_t orient_mode : 2; -#endif -}; -struct bmi160_acc_flat_detect_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! flat threshold */ - uint16_t flat_theta : 6; - - /*! flat interrupt hysteresis */ - uint16_t flat_hy : 3; - - /*! delay time for which the flat value must remain stable for the - * flat interrupt to be generated */ - uint16_t flat_hold_time : 2; - - /*! 1 - flat enable, 0 - flat disable */ - uint16_t flat_en : 1; -#else - - /*! 1 - flat enable, 0 - flat disable */ - uint16_t flat_en : 1; - - /*! delay time for which the flat value must remain stable for the - * flat interrupt to be generated */ - uint16_t flat_hold_time : 2; - - /*! flat interrupt hysteresis */ - uint16_t flat_hy : 3; - - /*! flat threshold */ - uint16_t flat_theta : 6; -#endif -}; -struct bmi160_acc_low_g_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! low-g interrupt trigger delay */ - uint8_t low_dur; - - /*! low-g interrupt trigger threshold */ - uint8_t low_thres; - - /*! hysteresis of low-g interrupt */ - uint8_t low_hyst : 2; - - /*! 0 - single-axis mode ,1 - axis-summing mode */ - uint8_t low_mode : 1; - - /*! data source 0- filter & 1 pre-filter */ - uint8_t low_data_src : 1; - - /*! 1 - enable low-g, 0 - disable low-g */ - uint8_t low_en : 1; -#else - - /*! 1 - enable low-g, 0 - disable low-g */ - uint8_t low_en : 1; - - /*! data source 0- filter & 1 pre-filter */ - uint8_t low_data_src : 1; - - /*! 0 - single-axis mode ,1 - axis-summing mode */ - uint8_t low_mode : 1; - - /*! hysteresis of low-g interrupt */ - uint8_t low_hyst : 2; - - /*! low-g interrupt trigger threshold */ - uint8_t low_thres; - - /*! low-g interrupt trigger delay */ - uint8_t low_dur; -#endif -}; -struct bmi160_acc_high_g_int_cfg { -#ifdef LITTLE_ENDIAN - - /*! High-g interrupt x, 1 - enable, 0 - disable */ - uint8_t high_g_x : 1; - - /*! High-g interrupt y, 1 - enable, 0 - disable */ - uint8_t high_g_y : 1; - - /*! High-g interrupt z, 1 - enable, 0 - disable */ - uint8_t high_g_z : 1; - - /*! High-g hysteresis */ - uint8_t high_hy : 2; - - /*! data source 0- filter & 1 pre-filter */ - uint8_t high_data_src : 1; - - /*! High-g threshold */ - uint8_t high_thres; - - /*! High-g duration */ - uint8_t high_dur; -#else - - /*! High-g duration */ - uint8_t high_dur; - - /*! High-g threshold */ - uint8_t high_thres; - - /*! data source 0- filter & 1 pre-filter */ - uint8_t high_data_src : 1; - - /*! High-g hysteresis */ - uint8_t high_hy : 2; - - /*! High-g interrupt z, 1 - enable, 0 - disable */ - uint8_t high_g_z : 1; - - /*! High-g interrupt y, 1 - enable, 0 - disable */ - uint8_t high_g_y : 1; - - /*! High-g interrupt x, 1 - enable, 0 - disable */ - uint8_t high_g_x : 1; -#endif -}; -struct bmi160_int_pin_settg { -#ifdef LITTLE_ENDIAN - - /*! To enable either INT1 or INT2 pin as output. - * 0- output disabled ,1- output enabled */ - uint16_t output_en : 1; - - /*! 0 - push-pull 1- open drain,only valid if output_en is set 1 */ - uint16_t output_mode : 1; - - /*! 0 - active low , 1 - active high level. - * if output_en is 1,this applies to interrupts,else PMU_trigger */ - uint16_t output_type : 1; - - /*! 0 - level trigger , 1 - edge trigger */ - uint16_t edge_ctrl : 1; - - /*! To enable either INT1 or INT2 pin as input. - * 0 - input disabled ,1 - input enabled */ - uint16_t input_en : 1; - - /*! latch duration*/ - uint16_t latch_dur : 4; -#else - - /*! latch duration*/ - uint16_t latch_dur : 4; - - /*! Latched,non-latched or temporary interrupt modes */ - uint16_t input_en : 1; - - /*! 1 - edge trigger, 0 - level trigger */ - uint16_t edge_ctrl : 1; - - /*! 0 - active low , 1 - active high level. - * if output_en is 1,this applies to interrupts,else PMU_trigger */ - uint16_t output_type : 1; - - /*! 0 - push-pull , 1 - open drain,only valid if output_en is set 1 */ - uint16_t output_mode : 1; - - /*! To enable either INT1 or INT2 pin as output. - * 0 - output disabled , 1 - output enabled */ - uint16_t output_en : 1; -#endif -}; -union bmi160_int_type_cfg { - /*! Tap interrupt structure */ - struct bmi160_acc_tap_int_cfg acc_tap_int; - - /*! Slope interrupt structure */ - struct bmi160_acc_any_mot_int_cfg acc_any_motion_int; - - /*! Significant motion interrupt structure */ - struct bmi160_acc_sig_mot_int_cfg acc_sig_motion_int; - - /*! Step detector interrupt structure */ - struct bmi160_acc_step_detect_int_cfg acc_step_detect_int; - - /*! No motion interrupt structure */ - struct bmi160_acc_no_motion_int_cfg acc_no_motion_int; - - /*! Orientation interrupt structure */ - struct bmi160_acc_orient_int_cfg acc_orient_int; - - /*! Flat interrupt structure */ - struct bmi160_acc_flat_detect_int_cfg acc_flat_int; - - /*! Low-g interrupt structure */ - struct bmi160_acc_low_g_int_cfg acc_low_g_int; - - /*! High-g interrupt structure */ - struct bmi160_acc_high_g_int_cfg acc_high_g_int; -}; -struct bmi160_int_settg { - /*! Interrupt channel */ - enum bmi160_int_channel int_channel; - - /*! Select Interrupt */ - enum bmi160_int_types int_type; - - /*! Structure configuring Interrupt pins */ - struct bmi160_int_pin_settg int_pin_settg; - - /*! Union configures required interrupt */ - union bmi160_int_type_cfg int_type_cfg; - - /*! FIFO FULL INT 1-enable, 0-disable */ - uint8_t fifo_full_int_en : 1; - - /*! FIFO WTM INT 1-enable, 0-disable */ - uint8_t fifo_wtm_int_en : 1; -}; - -/*! - * @brief This structure holds the information for usage of - * FIFO by the user. - */ -struct bmi160_fifo_frame { - /*! Data buffer of user defined length is to be mapped here */ - uint8_t* data; - - /*! While calling the API "bmi160_get_fifo_data" , length stores - * number of bytes in FIFO to be read (specified by user as input) - * and after execution of the API ,number of FIFO data bytes - * available is provided as an output to user - */ - uint16_t length; - - /*! FIFO time enable */ - uint8_t fifo_time_enable; - - /*! Enabling of the FIFO header to stream in header mode */ - uint8_t fifo_header_enable; - - /*! Streaming of the Accelerometer, Gyroscope - * sensor data or both in FIFO */ - uint8_t fifo_data_enable; - - /*! Will be equal to length when no more frames are there to parse */ - uint16_t accel_byte_start_idx; - - /*! Will be equal to length when no more frames are there to parse */ - uint16_t gyro_byte_start_idx; - - /*! Will be equal to length when no more frames are there to parse */ - uint16_t aux_byte_start_idx; - - /*! Value of FIFO sensor time time */ - uint32_t sensor_time; - - /*! Value of Skipped frame counts */ - uint8_t skipped_frame_count; -}; -struct bmi160_dev { - /*! Chip Id */ - uint8_t chip_id; - - /*! Device Id */ - uint8_t id; - - /*! 0 - I2C , 1 - SPI Interface */ - uint8_t intf; - - /*! Hold active interrupts status for any and sig motion - * 0 - Any-motion enable, 1 - Sig-motion enable, - * -1 neither any-motion nor sig-motion selected */ - enum bmi160_any_sig_motion_active_interrupt_state any_sig_sel; - - /*! Structure to configure Accel sensor */ - struct bmi160_cfg accel_cfg; - - /*! Structure to hold previous/old accel config parameters. - * This is used at driver level to prevent overwriting of same - * data, hence user does not change it in the code */ - struct bmi160_cfg prev_accel_cfg; - - /*! Structure to configure Gyro sensor */ - struct bmi160_cfg gyro_cfg; - - /*! Structure to hold previous/old gyro config parameters. - * This is used at driver level to prevent overwriting of same - * data, hence user does not change it in the code */ - struct bmi160_cfg prev_gyro_cfg; - - /*! Structure to configure the auxiliary sensor */ - struct bmi160_aux_cfg aux_cfg; - - /*! Structure to hold previous/old aux config parameters. - * This is used at driver level to prevent overwriting of same - * data, hence user does not change it in the code */ - struct bmi160_aux_cfg prev_aux_cfg; - - /*! FIFO related configurations */ - struct bmi160_fifo_frame* fifo; - - /*! Read function pointer */ - bmi160_read_fptr_t read; - - /*! Write function pointer */ - bmi160_write_fptr_t write; - - /*! Delay function pointer */ - bmi160_delay_fptr_t delay_ms; - - /*! User set read/write length */ - uint16_t read_write_len; -}; - -#endif /* BMI160_DEFS_H_ */ diff --git a/applications/plugins/airmouse/tracking/imu/imu.c b/applications/plugins/airmouse/tracking/imu/imu.c deleted file mode 100644 index 5e89c9504..000000000 --- a/applications/plugins/airmouse/tracking/imu/imu.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "imu.h" -#include - -bool bmi160_begin(); -int bmi160_read(double* vec); - -bool lsm6ds3trc_begin(); -void lsm6ds3trc_end(); -int lsm6ds3trc_read(double* vec); - -bool imu_begin() { - furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); - bool ret = bmi160_begin(); // lsm6ds3trc_begin(); - furi_hal_i2c_release(&furi_hal_i2c_handle_external); - return ret; -} - -void imu_end() { - // furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); - // lsm6ds3trc_end(); - // furi_hal_i2c_release(&furi_hal_i2c_handle_external); -} - -int imu_read(double* vec) { - furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); - int ret = bmi160_read(vec); // lsm6ds3trc_read(vec); - furi_hal_i2c_release(&furi_hal_i2c_handle_external); - return ret; -} diff --git a/applications/plugins/airmouse/tracking/imu/imu.h b/applications/plugins/airmouse/tracking/imu/imu.h deleted file mode 100644 index f4c5e4b1d..000000000 --- a/applications/plugins/airmouse/tracking/imu/imu.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define ACC_DATA_READY (1 << 0) -#define GYR_DATA_READY (1 << 1) - -bool imu_begin(); -void imu_end(); -int imu_read(double* vec); - -#ifdef __cplusplus -} -#endif diff --git a/applications/plugins/airmouse/tracking/imu/imu_bmi160.c b/applications/plugins/airmouse/tracking/imu/imu_bmi160.c deleted file mode 100644 index af771302f..000000000 --- a/applications/plugins/airmouse/tracking/imu/imu_bmi160.c +++ /dev/null @@ -1,88 +0,0 @@ -#include "bmi160.h" - -#include - -#include "imu.h" - -#define TAG "BMI160" - -#define BMI160_DEV_ADDR (0x69 << 1) - -static const double DEG_TO_RAD = 0.017453292519943295769236907684886; -static const double G = 9.81; - -struct bmi160_dev bmi160dev; -struct bmi160_sensor_data bmi160_accel; -struct bmi160_sensor_data bmi160_gyro; - -int8_t bmi160_write_i2c(uint8_t dev_addr, uint8_t reg_addr, uint8_t* data, uint16_t len) { - if(furi_hal_i2c_write_mem(&furi_hal_i2c_handle_external, dev_addr, reg_addr, data, len, 50)) - return BMI160_OK; - return BMI160_E_COM_FAIL; -} - -int8_t bmi160_read_i2c(uint8_t dev_addr, uint8_t reg_addr, uint8_t* read_data, uint16_t len) { - if(furi_hal_i2c_read_mem(&furi_hal_i2c_handle_external, dev_addr, reg_addr, read_data, len, 50)) - return BMI160_OK; - return BMI160_E_COM_FAIL; -} - -bool bmi160_begin() { - FURI_LOG_I(TAG, "Init BMI160"); - - if(!furi_hal_i2c_is_device_ready(&furi_hal_i2c_handle_external, BMI160_DEV_ADDR, 50)) { - FURI_LOG_E(TAG, "Device not ready!"); - return false; - } - - FURI_LOG_I(TAG, "Device ready!"); - - bmi160dev.id = BMI160_DEV_ADDR; - bmi160dev.intf = BMI160_I2C_INTF; - bmi160dev.read = bmi160_read_i2c; - bmi160dev.write = bmi160_write_i2c; - bmi160dev.delay_ms = furi_delay_ms; - - if(bmi160_init(&bmi160dev) != BMI160_OK) { - FURI_LOG_E(TAG, "Initialization failure!"); - FURI_LOG_E(TAG, "Chip ID 0x%X", bmi160dev.chip_id); - return false; - } - - bmi160dev.accel_cfg.odr = BMI160_ACCEL_ODR_400HZ; - bmi160dev.accel_cfg.range = BMI160_ACCEL_RANGE_4G; - bmi160dev.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; - bmi160dev.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; - bmi160dev.gyro_cfg.odr = BMI160_GYRO_ODR_400HZ; - bmi160dev.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS; - bmi160dev.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE; - bmi160dev.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; - - if(bmi160_set_sens_conf(&bmi160dev) != BMI160_OK) { - FURI_LOG_E(TAG, "Initialization failure!"); - FURI_LOG_E(TAG, "Chip ID 0x%X", bmi160dev.chip_id); - return false; - } - - FURI_LOG_I(TAG, "Initialization success!"); - FURI_LOG_I(TAG, "Chip ID 0x%X", bmi160dev.chip_id); - - return true; -} - -int bmi160_read(double* vec) { - if(bmi160_get_sensor_data( - (BMI160_ACCEL_SEL | BMI160_GYRO_SEL), &bmi160_accel, &bmi160_gyro, &bmi160dev) != - BMI160_OK) { - return 0; - } - - vec[0] = ((double)bmi160_accel.x * 4 / 32768) * G; - vec[1] = ((double)bmi160_accel.y * 4 / 32768) * G; - vec[2] = ((double)bmi160_accel.z * 4 / 32768) * G; - vec[3] = ((double)bmi160_gyro.x * 2000 / 32768) * DEG_TO_RAD; - vec[4] = ((double)bmi160_gyro.y * 2000 / 32768) * DEG_TO_RAD; - vec[5] = ((double)bmi160_gyro.z * 2000 / 32768) * DEG_TO_RAD; - - return ACC_DATA_READY | GYR_DATA_READY; -} diff --git a/applications/plugins/airmouse/tracking/imu/imu_lsm6ds3trc.c b/applications/plugins/airmouse/tracking/imu/imu_lsm6ds3trc.c deleted file mode 100644 index c013fc6e6..000000000 --- a/applications/plugins/airmouse/tracking/imu/imu_lsm6ds3trc.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "lsm6ds3tr_c_reg.h" - -#include - -#include "imu.h" - -#define TAG "LSM6DS3TR-C" - -#define LSM6DS3_ADDRESS (0x6A << 1) - -static const double DEG_TO_RAD = 0.017453292519943295769236907684886; - -stmdev_ctx_t lsm6ds3trc_ctx; - -int32_t lsm6ds3trc_write_i2c(void* handle, uint8_t reg_addr, const uint8_t* data, uint16_t len) { - if(furi_hal_i2c_write_mem(handle, LSM6DS3_ADDRESS, reg_addr, (uint8_t*)data, len, 50)) - return 0; - return -1; -} - -int32_t lsm6ds3trc_read_i2c(void* handle, uint8_t reg_addr, uint8_t* read_data, uint16_t len) { - if(furi_hal_i2c_read_mem(handle, LSM6DS3_ADDRESS, reg_addr, read_data, len, 50)) return 0; - return -1; -} - -bool lsm6ds3trc_begin() { - FURI_LOG_I(TAG, "Init LSM6DS3TR-C"); - - if(!furi_hal_i2c_is_device_ready(&furi_hal_i2c_handle_external, LSM6DS3_ADDRESS, 50)) { - FURI_LOG_E(TAG, "Not ready"); - return false; - } - - lsm6ds3trc_ctx.write_reg = lsm6ds3trc_write_i2c; - lsm6ds3trc_ctx.read_reg = lsm6ds3trc_read_i2c; - lsm6ds3trc_ctx.mdelay = furi_delay_ms; - lsm6ds3trc_ctx.handle = &furi_hal_i2c_handle_external; - - uint8_t whoami; - lsm6ds3tr_c_device_id_get(&lsm6ds3trc_ctx, &whoami); - if(whoami != LSM6DS3TR_C_ID) { - FURI_LOG_I(TAG, "Unknown model: %x", (int)whoami); - return false; - } - - lsm6ds3tr_c_reset_set(&lsm6ds3trc_ctx, PROPERTY_ENABLE); - uint8_t rst = PROPERTY_ENABLE; - while(rst) lsm6ds3tr_c_reset_get(&lsm6ds3trc_ctx, &rst); - - lsm6ds3tr_c_block_data_update_set(&lsm6ds3trc_ctx, PROPERTY_ENABLE); - lsm6ds3tr_c_fifo_mode_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_BYPASS_MODE); - - lsm6ds3tr_c_xl_data_rate_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_XL_ODR_104Hz); - lsm6ds3tr_c_xl_full_scale_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_4g); - lsm6ds3tr_c_xl_lp1_bandwidth_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_XL_LP1_ODR_DIV_4); - - lsm6ds3tr_c_gy_data_rate_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_GY_ODR_104Hz); - lsm6ds3tr_c_gy_full_scale_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_2000dps); - lsm6ds3tr_c_gy_power_mode_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_GY_HIGH_PERFORMANCE); - lsm6ds3tr_c_gy_band_pass_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_LP2_ONLY); - - FURI_LOG_I(TAG, "Init OK"); - return true; -} - -void lsm6ds3trc_end() { - lsm6ds3tr_c_xl_data_rate_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_XL_ODR_OFF); - lsm6ds3tr_c_gy_data_rate_set(&lsm6ds3trc_ctx, LSM6DS3TR_C_GY_ODR_OFF); -} - -int lsm6ds3trc_read(double* vec) { - int ret = 0; - int16_t data[3]; - lsm6ds3tr_c_reg_t reg; - lsm6ds3tr_c_status_reg_get(&lsm6ds3trc_ctx, ®.status_reg); - - if(reg.status_reg.xlda) { - lsm6ds3tr_c_acceleration_raw_get(&lsm6ds3trc_ctx, data); - vec[2] = (double)lsm6ds3tr_c_from_fs2g_to_mg(data[0]) / 1000; - vec[0] = (double)lsm6ds3tr_c_from_fs2g_to_mg(data[1]) / 1000; - vec[1] = (double)lsm6ds3tr_c_from_fs2g_to_mg(data[2]) / 1000; - ret |= ACC_DATA_READY; - } - - if(reg.status_reg.gda) { - lsm6ds3tr_c_angular_rate_raw_get(&lsm6ds3trc_ctx, data); - vec[5] = (double)lsm6ds3tr_c_from_fs2000dps_to_mdps(data[0]) * DEG_TO_RAD / 1000; - vec[3] = (double)lsm6ds3tr_c_from_fs2000dps_to_mdps(data[1]) * DEG_TO_RAD / 1000; - vec[4] = (double)lsm6ds3tr_c_from_fs2000dps_to_mdps(data[2]) * DEG_TO_RAD / 1000; - ret |= GYR_DATA_READY; - } - - return ret; -} diff --git a/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.c b/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.c deleted file mode 100644 index 9f1890d2c..000000000 --- a/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.c +++ /dev/null @@ -1,7105 +0,0 @@ -/** - ****************************************************************************** - * @file lsm6ds3tr_c_reg.c - * @author Sensors Software Solution Team - * @brief LSM6DS3TR_C driver file - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#include "lsm6ds3tr_c_reg.h" - -/** - * @defgroup LSM6DS3TR_C - * @brief This file provides a set of functions needed to drive the - * lsm6ds3tr_c enanced inertial module. - * @{ - * - */ - -/** - * @defgroup LSM6DS3TR_C_interfaces_functions - * @brief This section provide a set of functions used to read and - * write a generic register of the device. - * MANDATORY: return 0 -> no Error. - * @{ - * - */ - -/** - * @brief Read generic device register - * - * @param ctx read / write interface definitions(ptr) - * @param reg register to read - * @param data pointer to buffer that store the data read(ptr) - * @param len number of consecutive register to read - * @retval interface status (MANDATORY: return 0 -> no Error) - * - */ -int32_t lsm6ds3tr_c_read_reg(stmdev_ctx_t* ctx, uint8_t reg, uint8_t* data, uint16_t len) { - int32_t ret; - - ret = ctx->read_reg(ctx->handle, reg, data, len); - - return ret; -} - -/** - * @brief Write generic device register - * - * @param ctx read / write interface definitions(ptr) - * @param reg register to write - * @param data pointer to data to write in register reg(ptr) - * @param len number of consecutive register to write - * @retval interface status (MANDATORY: return 0 -> no Error) - * - */ -int32_t lsm6ds3tr_c_write_reg(stmdev_ctx_t* ctx, uint8_t reg, uint8_t* data, uint16_t len) { - int32_t ret; - - ret = ctx->write_reg(ctx->handle, reg, data, len); - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Sensitivity - * @brief These functions convert raw-data into engineering units. - * @{ - * - */ - -float_t lsm6ds3tr_c_from_fs2g_to_mg(int16_t lsb) { - return ((float_t)lsb * 0.061f); -} - -float_t lsm6ds3tr_c_from_fs4g_to_mg(int16_t lsb) { - return ((float_t)lsb * 0.122f); -} - -float_t lsm6ds3tr_c_from_fs8g_to_mg(int16_t lsb) { - return ((float_t)lsb * 0.244f); -} - -float_t lsm6ds3tr_c_from_fs16g_to_mg(int16_t lsb) { - return ((float_t)lsb * 0.488f); -} - -float_t lsm6ds3tr_c_from_fs125dps_to_mdps(int16_t lsb) { - return ((float_t)lsb * 4.375f); -} - -float_t lsm6ds3tr_c_from_fs250dps_to_mdps(int16_t lsb) { - return ((float_t)lsb * 8.750f); -} - -float_t lsm6ds3tr_c_from_fs500dps_to_mdps(int16_t lsb) { - return ((float_t)lsb * 17.50f); -} - -float_t lsm6ds3tr_c_from_fs1000dps_to_mdps(int16_t lsb) { - return ((float_t)lsb * 35.0f); -} - -float_t lsm6ds3tr_c_from_fs2000dps_to_mdps(int16_t lsb) { - return ((float_t)lsb * 70.0f); -} - -float_t lsm6ds3tr_c_from_lsb_to_celsius(int16_t lsb) { - return (((float_t)lsb / 256.0f) + 25.0f); -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_data_generation - * @brief This section groups all the functions concerning data - * generation - * @{ - * - */ - -/** - * @brief Accelerometer full-scale selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fs_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_xl_t val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - if(ret == 0) { - ctrl1_xl.fs_xl = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - } - - return ret; -} - -/** - * @brief Accelerometer full-scale selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of fs_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_xl_t* val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - switch(ctrl1_xl.fs_xl) { - case LSM6DS3TR_C_2g: - *val = LSM6DS3TR_C_2g; - break; - - case LSM6DS3TR_C_16g: - *val = LSM6DS3TR_C_16g; - break; - - case LSM6DS3TR_C_4g: - *val = LSM6DS3TR_C_4g; - break; - - case LSM6DS3TR_C_8g: - *val = LSM6DS3TR_C_8g; - break; - - default: - *val = LSM6DS3TR_C_XL_FS_ND; - break; - } - - return ret; -} - -/** - * @brief Accelerometer data rate selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of odr_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_xl_t val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - if(ret == 0) { - ctrl1_xl.odr_xl = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - } - - return ret; -} - -/** - * @brief Accelerometer data rate selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of odr_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_xl_t* val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - switch(ctrl1_xl.odr_xl) { - case LSM6DS3TR_C_XL_ODR_OFF: - *val = LSM6DS3TR_C_XL_ODR_OFF; - break; - - case LSM6DS3TR_C_XL_ODR_12Hz5: - *val = LSM6DS3TR_C_XL_ODR_12Hz5; - break; - - case LSM6DS3TR_C_XL_ODR_26Hz: - *val = LSM6DS3TR_C_XL_ODR_26Hz; - break; - - case LSM6DS3TR_C_XL_ODR_52Hz: - *val = LSM6DS3TR_C_XL_ODR_52Hz; - break; - - case LSM6DS3TR_C_XL_ODR_104Hz: - *val = LSM6DS3TR_C_XL_ODR_104Hz; - break; - - case LSM6DS3TR_C_XL_ODR_208Hz: - *val = LSM6DS3TR_C_XL_ODR_208Hz; - break; - - case LSM6DS3TR_C_XL_ODR_416Hz: - *val = LSM6DS3TR_C_XL_ODR_416Hz; - break; - - case LSM6DS3TR_C_XL_ODR_833Hz: - *val = LSM6DS3TR_C_XL_ODR_833Hz; - break; - - case LSM6DS3TR_C_XL_ODR_1k66Hz: - *val = LSM6DS3TR_C_XL_ODR_1k66Hz; - break; - - case LSM6DS3TR_C_XL_ODR_3k33Hz: - *val = LSM6DS3TR_C_XL_ODR_3k33Hz; - break; - - case LSM6DS3TR_C_XL_ODR_6k66Hz: - *val = LSM6DS3TR_C_XL_ODR_6k66Hz; - break; - - case LSM6DS3TR_C_XL_ODR_1Hz6: - *val = LSM6DS3TR_C_XL_ODR_1Hz6; - break; - - default: - *val = LSM6DS3TR_C_XL_ODR_ND; - break; - } - - return ret; -} - -/** - * @brief Gyroscope chain full-scale selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fs_g in reg CTRL2_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_g_t val) { - lsm6ds3tr_c_ctrl2_g_t ctrl2_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - - if(ret == 0) { - ctrl2_g.fs_g = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - } - - return ret; -} - -/** - * @brief Gyroscope chain full-scale selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of fs_g in reg CTRL2_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_g_t* val) { - lsm6ds3tr_c_ctrl2_g_t ctrl2_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - - switch(ctrl2_g.fs_g) { - case LSM6DS3TR_C_250dps: - *val = LSM6DS3TR_C_250dps; - break; - - case LSM6DS3TR_C_125dps: - *val = LSM6DS3TR_C_125dps; - break; - - case LSM6DS3TR_C_500dps: - *val = LSM6DS3TR_C_500dps; - break; - - case LSM6DS3TR_C_1000dps: - *val = LSM6DS3TR_C_1000dps; - break; - - case LSM6DS3TR_C_2000dps: - *val = LSM6DS3TR_C_2000dps; - break; - - default: - *val = LSM6DS3TR_C_GY_FS_ND; - break; - } - - return ret; -} - -/** - * @brief Gyroscope data rate selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of odr_g in reg CTRL2_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_g_t val) { - lsm6ds3tr_c_ctrl2_g_t ctrl2_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - - if(ret == 0) { - ctrl2_g.odr_g = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - } - - return ret; -} - -/** - * @brief Gyroscope data rate selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of odr_g in reg CTRL2_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_g_t* val) { - lsm6ds3tr_c_ctrl2_g_t ctrl2_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G, (uint8_t*)&ctrl2_g, 1); - - switch(ctrl2_g.odr_g) { - case LSM6DS3TR_C_GY_ODR_OFF: - *val = LSM6DS3TR_C_GY_ODR_OFF; - break; - - case LSM6DS3TR_C_GY_ODR_12Hz5: - *val = LSM6DS3TR_C_GY_ODR_12Hz5; - break; - - case LSM6DS3TR_C_GY_ODR_26Hz: - *val = LSM6DS3TR_C_GY_ODR_26Hz; - break; - - case LSM6DS3TR_C_GY_ODR_52Hz: - *val = LSM6DS3TR_C_GY_ODR_52Hz; - break; - - case LSM6DS3TR_C_GY_ODR_104Hz: - *val = LSM6DS3TR_C_GY_ODR_104Hz; - break; - - case LSM6DS3TR_C_GY_ODR_208Hz: - *val = LSM6DS3TR_C_GY_ODR_208Hz; - break; - - case LSM6DS3TR_C_GY_ODR_416Hz: - *val = LSM6DS3TR_C_GY_ODR_416Hz; - break; - - case LSM6DS3TR_C_GY_ODR_833Hz: - *val = LSM6DS3TR_C_GY_ODR_833Hz; - break; - - case LSM6DS3TR_C_GY_ODR_1k66Hz: - *val = LSM6DS3TR_C_GY_ODR_1k66Hz; - break; - - case LSM6DS3TR_C_GY_ODR_3k33Hz: - *val = LSM6DS3TR_C_GY_ODR_3k33Hz; - break; - - case LSM6DS3TR_C_GY_ODR_6k66Hz: - *val = LSM6DS3TR_C_GY_ODR_6k66Hz; - break; - - default: - *val = LSM6DS3TR_C_GY_ODR_ND; - break; - } - - return ret; -} - -/** - * @brief Block data update.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of bdu in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_block_data_update_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.bdu = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Block data update.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of bdu in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_block_data_update_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - *val = ctrl3_c.bdu; - - return ret; -} - -/** - * @brief Weight of XL user offset bits of registers - * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of usr_off_w in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_offset_weight_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_usr_off_w_t val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ctrl6_c.usr_off_w = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - } - - return ret; -} - -/** - * @brief Weight of XL user offset bits of registers - * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of usr_off_w in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_offset_weight_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_usr_off_w_t* val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - switch(ctrl6_c.usr_off_w) { - case LSM6DS3TR_C_LSb_1mg: - *val = LSM6DS3TR_C_LSb_1mg; - break; - - case LSM6DS3TR_C_LSb_16mg: - *val = LSM6DS3TR_C_LSb_16mg; - break; - - default: - *val = LSM6DS3TR_C_WEIGHT_ND; - break; - } - - return ret; -} - -/** - * @brief High-performance operating mode for accelerometer[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of xl_hm_mode in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_power_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_xl_hm_mode_t val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ctrl6_c.xl_hm_mode = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - } - - return ret; -} - -/** - * @brief High-performance operating mode for accelerometer.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of xl_hm_mode in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_power_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_xl_hm_mode_t* val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - switch(ctrl6_c.xl_hm_mode) { - case LSM6DS3TR_C_XL_HIGH_PERFORMANCE: - *val = LSM6DS3TR_C_XL_HIGH_PERFORMANCE; - break; - - case LSM6DS3TR_C_XL_NORMAL: - *val = LSM6DS3TR_C_XL_NORMAL; - break; - - default: - *val = LSM6DS3TR_C_XL_PW_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Source register rounding function on WAKE_UP_SRC (1Bh), - * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and - * FUNC_SRC1 (53h) registers in the primary interface.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of rounding_status in reg CTRL7_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_rounding_on_status_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_status_t val) { - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - if(ret == 0) { - ctrl7_g.rounding_status = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - } - - return ret; -} - -/** - * @brief Source register rounding function on WAKE_UP_SRC (1Bh), - * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and - * FUNC_SRC1 (53h) registers in the primary interface.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of rounding_status in reg CTRL7_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_rounding_on_status_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_status_t* val) { - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - switch(ctrl7_g.rounding_status) { - case LSM6DS3TR_C_STAT_RND_DISABLE: - *val = LSM6DS3TR_C_STAT_RND_DISABLE; - break; - - case LSM6DS3TR_C_STAT_RND_ENABLE: - *val = LSM6DS3TR_C_STAT_RND_ENABLE; - break; - - default: - *val = LSM6DS3TR_C_STAT_RND_ND; - break; - } - - return ret; -} - -/** - * @brief High-performance operating mode disable for gyroscope.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of g_hm_mode in reg CTRL7_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_power_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_g_hm_mode_t val) { - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - if(ret == 0) { - ctrl7_g.g_hm_mode = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - } - - return ret; -} - -/** - * @brief High-performance operating mode disable for gyroscope.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of g_hm_mode in reg CTRL7_G - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_power_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_g_hm_mode_t* val) { - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - switch(ctrl7_g.g_hm_mode) { - case LSM6DS3TR_C_GY_HIGH_PERFORMANCE: - *val = LSM6DS3TR_C_GY_HIGH_PERFORMANCE; - break; - - case LSM6DS3TR_C_GY_NORMAL: - *val = LSM6DS3TR_C_GY_NORMAL; - break; - - default: - *val = LSM6DS3TR_C_GY_PW_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Read all the interrupt/status flag of the device.[get] - * - * @param ctx Read / write interface definitions - * @param val WAKE_UP_SRC, TAP_SRC, D6D_SRC, STATUS_REG, - * FUNC_SRC1, FUNC_SRC2, WRIST_TILT_IA, A_WRIST_TILT_Mask - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_all_sources_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_all_sources_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_SRC, (uint8_t*)&(val->wake_up_src), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_SRC, (uint8_t*)&(val->tap_src), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_D6D_SRC, (uint8_t*)&(val->d6d_src), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG, (uint8_t*)&(val->status_reg), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_SRC1, (uint8_t*)&(val->func_src1), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_SRC2, (uint8_t*)&(val->func_src2), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_WRIST_TILT_IA, (uint8_t*)&(val->wrist_tilt_ia), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK, (uint8_t*)&(val->a_wrist_tilt_mask), 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - - return ret; -} -/** - * @brief The STATUS_REG register is read by the primary interface[get] - * - * @param ctx Read / write interface definitions - * @param val Registers STATUS_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_status_reg_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_status_reg_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG, (uint8_t*)val, 1); - - return ret; -} - -/** - * @brief Accelerometer new data available.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of xlda in reg STATUS_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_status_reg_t status_reg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG, (uint8_t*)&status_reg, 1); - *val = status_reg.xlda; - - return ret; -} - -/** - * @brief Gyroscope new data available.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of gda in reg STATUS_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_status_reg_t status_reg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG, (uint8_t*)&status_reg, 1); - *val = status_reg.gda; - - return ret; -} - -/** - * @brief Temperature new data available.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tda in reg STATUS_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_temp_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_status_reg_t status_reg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG, (uint8_t*)&status_reg, 1); - *val = status_reg.tda; - - return ret; -} - -/** - * @brief Accelerometer axis user offset correction expressed in two’s - * complement, weight depends on USR_OFF_W in CTRL6_C. - * The value must be in the range [-127 127].[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_usr_offset_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_X_OFS_USR, buff, 3); - - return ret; -} - -/** - * @brief Accelerometer axis user offset correction xpressed in two’s - * complement, weight depends on USR_OFF_W in CTRL6_C. - * The value must be in the range [-127 127].[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_usr_offset_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_X_OFS_USR, buff, 3); - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Timestamp - * @brief This section groups all the functions that manage the - * timestamp generation. - * @{ - * - */ - -/** - * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), - * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of timer_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_timestamp_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.timer_en = val; - - if(val != 0x00U) { - ctrl10_c.func_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - } - - return ret; -} - -/** - * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h), - * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of timer_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_timestamp_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.timer_en; - - return ret; -} - -/** - * @brief Timestamp register resolution setting. - * Configuration of this bit affects - * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h), - * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h), - * STEP_TIMESTAMP_H(4Ah) and - * STEP_COUNT_DELTA(15h) registers.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of timer_hr in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_timestamp_res_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_timer_hr_t val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - if(ret == 0) { - wake_up_dur.timer_hr = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - } - - return ret; -} - -/** - * @brief Timestamp register resolution setting. - * Configuration of this bit affects - * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h), - * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h), - * STEP_TIMESTAMP_H(4Ah) and - * STEP_COUNT_DELTA(15h) registers.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of timer_hr in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_timestamp_res_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_timer_hr_t* val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - switch(wake_up_dur.timer_hr) { - case LSM6DS3TR_C_LSB_6ms4: - *val = LSM6DS3TR_C_LSB_6ms4; - break; - - case LSM6DS3TR_C_LSB_25us: - *val = LSM6DS3TR_C_LSB_25us; - break; - - default: - *val = LSM6DS3TR_C_TS_RES_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Dataoutput - * @brief This section groups all the data output functions. - * @{ - * - */ - -/** - * @brief Circular burst-mode (rounding) read from output registers - * through the primary interface.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of rounding in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_rounding_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_t val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - if(ret == 0) { - ctrl5_c.rounding = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - } - - return ret; -} - -/** - * @brief Circular burst-mode (rounding) read from output registers - * through the primary interface.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of rounding in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_rounding_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_t* val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - switch(ctrl5_c.rounding) { - case LSM6DS3TR_C_ROUND_DISABLE: - *val = LSM6DS3TR_C_ROUND_DISABLE; - break; - - case LSM6DS3TR_C_ROUND_XL: - *val = LSM6DS3TR_C_ROUND_XL; - break; - - case LSM6DS3TR_C_ROUND_GY: - *val = LSM6DS3TR_C_ROUND_GY; - break; - - case LSM6DS3TR_C_ROUND_GY_XL: - *val = LSM6DS3TR_C_ROUND_GY_XL; - break; - - case LSM6DS3TR_C_ROUND_SH1_TO_SH6: - *val = LSM6DS3TR_C_ROUND_SH1_TO_SH6; - break; - - case LSM6DS3TR_C_ROUND_XL_SH1_TO_SH6: - *val = LSM6DS3TR_C_ROUND_XL_SH1_TO_SH6; - break; - - case LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH12: - *val = LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH12; - break; - - case LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH6: - *val = LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH6; - break; - - default: - *val = LSM6DS3TR_C_ROUND_OUT_ND; - break; - } - - return ret; -} - -/** - * @brief Temperature data output register (r). L and H registers together - * express a 16-bit word in two’s complement.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_temperature_raw_get(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[2]; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUT_TEMP_L, buff, 2); - *val = (int16_t)buff[1]; - *val = (*val * 256) + (int16_t)buff[0]; - - return ret; -} - -/** - * @brief Angular rate sensor. The value is expressed as a 16-bit word in - * two’s complement.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_angular_rate_raw_get(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[6]; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUTX_L_G, buff, 6); - val[0] = (int16_t)buff[1]; - val[0] = (val[0] * 256) + (int16_t)buff[0]; - val[1] = (int16_t)buff[3]; - val[1] = (val[1] * 256) + (int16_t)buff[2]; - val[2] = (int16_t)buff[5]; - val[2] = (val[2] * 256) + (int16_t)buff[4]; - - return ret; -} - -/** - * @brief Linear acceleration output register. The value is expressed - * as a 16-bit word in two’s complement.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_acceleration_raw_get(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[6]; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUTX_L_XL, buff, 6); - val[0] = (int16_t)buff[1]; - val[0] = (val[0] * 256) + (int16_t)buff[0]; - val[1] = (int16_t)buff[3]; - val[1] = (val[1] * 256) + (int16_t)buff[2]; - val[2] = (int16_t)buff[5]; - val[2] = (val[2] * 256) + (int16_t)buff[4]; - - return ret; -} - -/** - * @brief External magnetometer raw data.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_calibrated_raw_get(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[6]; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUT_MAG_RAW_X_L, buff, 6); - val[0] = (int16_t)buff[1]; - val[0] = (val[0] * 256) + (int16_t)buff[0]; - val[1] = (int16_t)buff[3]; - val[1] = (val[1] * 256) + (int16_t)buff[2]; - val[2] = (int16_t)buff[5]; - val[2] = (val[2] * 256) + (int16_t)buff[4]; - - return ret; -} - -/** - * @brief Read data in FIFO.[get] - * - * @param ctx Read / write interface definitions - * @param buffer Data buffer to store FIFO data. - * @param len Number of data to read from FIFO. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_raw_data_get(stmdev_ctx_t* ctx, uint8_t* buffer, uint8_t len) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_DATA_OUT_L, buffer, len); - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_common - * @brief This section groups common useful functions. - * @{ - * - */ - -/** - * @brief Enable access to the embedded functions/sensor hub - * configuration registers[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of func_cfg_en in reg FUNC_CFG_ACCESS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mem_bank_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_func_cfg_en_t val) { - lsm6ds3tr_c_func_cfg_access_t func_cfg_access; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS, (uint8_t*)&func_cfg_access, 1); - - if(ret == 0) { - func_cfg_access.func_cfg_en = (uint8_t)val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS, (uint8_t*)&func_cfg_access, 1); - } - - return ret; -} - -/** - * @brief Enable access to the embedded functions/sensor hub configuration - * registers[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of func_cfg_en in reg FUNC_CFG_ACCESS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mem_bank_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_func_cfg_en_t* val) { - lsm6ds3tr_c_func_cfg_access_t func_cfg_access; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS, (uint8_t*)&func_cfg_access, 1); - - switch(func_cfg_access.func_cfg_en) { - case LSM6DS3TR_C_USER_BANK: - *val = LSM6DS3TR_C_USER_BANK; - break; - - case LSM6DS3TR_C_BANK_B: - *val = LSM6DS3TR_C_BANK_B; - break; - - default: - *val = LSM6DS3TR_C_BANK_ND; - break; - } - - return ret; -} - -/** - * @brief Data-ready pulsed / letched mode[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of drdy_pulsed in reg DRDY_PULSE_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_data_ready_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_drdy_pulsed_g_t val) { - lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - - if(ret == 0) { - drdy_pulse_cfg_g.drdy_pulsed = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - } - - return ret; -} - -/** - * @brief Data-ready pulsed / letched mode[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of drdy_pulsed in reg DRDY_PULSE_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_data_ready_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_drdy_pulsed_g_t* val) { - lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - - switch(drdy_pulse_cfg_g.drdy_pulsed) { - case LSM6DS3TR_C_DRDY_LATCHED: - *val = LSM6DS3TR_C_DRDY_LATCHED; - break; - - case LSM6DS3TR_C_DRDY_PULSED: - *val = LSM6DS3TR_C_DRDY_PULSED; - break; - - default: - *val = LSM6DS3TR_C_DRDY_ND; - break; - } - - return ret; -} - -/** - * @brief DeviceWhoamI.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_device_id_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WHO_AM_I, buff, 1); - - return ret; -} - -/** - * @brief Software reset. Restore the default values in user registers[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sw_reset in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_reset_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.sw_reset = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Software reset. Restore the default values in user registers[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sw_reset in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_reset_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - *val = ctrl3_c.sw_reset; - - return ret; -} - -/** - * @brief Big/Little Endian Data selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ble in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_data_format_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_ble_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.ble = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Big/Little Endian Data selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of ble in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_data_format_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_ble_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - switch(ctrl3_c.ble) { - case LSM6DS3TR_C_LSB_AT_LOW_ADD: - *val = LSM6DS3TR_C_LSB_AT_LOW_ADD; - break; - - case LSM6DS3TR_C_MSB_AT_LOW_ADD: - *val = LSM6DS3TR_C_MSB_AT_LOW_ADD; - break; - - default: - *val = LSM6DS3TR_C_DATA_FMT_ND; - break; - } - - return ret; -} - -/** - * @brief Register address automatically incremented during a multiple byte - * access with a serial interface.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of if_inc in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_auto_increment_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.if_inc = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Register address automatically incremented during a multiple byte - * access with a serial interface.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of if_inc in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_auto_increment_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - *val = ctrl3_c.if_inc; - - return ret; -} - -/** - * @brief Reboot memory content. Reload the calibration parameters.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of boot in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_boot_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.boot = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Reboot memory content. Reload the calibration parameters.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of boot in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_boot_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - *val = ctrl3_c.boot; - - return ret; -} - -/** - * @brief Linear acceleration sensor self-test enable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of st_xl in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_self_test_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_xl_t val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - if(ret == 0) { - ctrl5_c.st_xl = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - } - - return ret; -} - -/** - * @brief Linear acceleration sensor self-test enable.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of st_xl in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_self_test_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_xl_t* val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - switch(ctrl5_c.st_xl) { - case LSM6DS3TR_C_XL_ST_DISABLE: - *val = LSM6DS3TR_C_XL_ST_DISABLE; - break; - - case LSM6DS3TR_C_XL_ST_POSITIVE: - *val = LSM6DS3TR_C_XL_ST_POSITIVE; - break; - - case LSM6DS3TR_C_XL_ST_NEGATIVE: - *val = LSM6DS3TR_C_XL_ST_NEGATIVE; - break; - - default: - *val = LSM6DS3TR_C_XL_ST_ND; - break; - } - - return ret; -} - -/** - * @brief Angular rate sensor self-test enable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of st_g in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_self_test_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_g_t val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - if(ret == 0) { - ctrl5_c.st_g = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - } - - return ret; -} - -/** - * @brief Angular rate sensor self-test enable.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of st_g in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_self_test_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_g_t* val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - switch(ctrl5_c.st_g) { - case LSM6DS3TR_C_GY_ST_DISABLE: - *val = LSM6DS3TR_C_GY_ST_DISABLE; - break; - - case LSM6DS3TR_C_GY_ST_POSITIVE: - *val = LSM6DS3TR_C_GY_ST_POSITIVE; - break; - - case LSM6DS3TR_C_GY_ST_NEGATIVE: - *val = LSM6DS3TR_C_GY_ST_NEGATIVE; - break; - - default: - *val = LSM6DS3TR_C_GY_ST_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_filters - * @brief This section group all the functions concerning the filters - * configuration that impact both accelerometer and gyro. - * @{ - * - */ - -/** - * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends - * (XL and Gyro independently masked).[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of drdy_mask in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_filter_settling_mask_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.drdy_mask = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - return ret; -} - -/** - * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends - * (XL and Gyro independently masked).[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of drdy_mask in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_filter_settling_mask_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - *val = ctrl4_c.drdy_mask; - - return ret; -} - -/** - * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity - * functions.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of slope_fds in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_hp_path_internal_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slope_fds_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.slope_fds = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity - * functions.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of slope_fds in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_hp_path_internal_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slope_fds_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - switch(tap_cfg.slope_fds) { - case LSM6DS3TR_C_USE_SLOPE: - *val = LSM6DS3TR_C_USE_SLOPE; - break; - - case LSM6DS3TR_C_USE_HPF: - *val = LSM6DS3TR_C_USE_HPF; - break; - - default: - *val = LSM6DS3TR_C_HP_PATH_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_accelerometer_filters - * @brief This section group all the functions concerning the filters - * configuration that impact accelerometer in every mode. - * @{ - * - */ - -/** - * @brief Accelerometer analog chain bandwidth selection (only for - * accelerometer ODR ≥ 1.67 kHz).[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of bw0_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_filter_analog_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_bw0_xl_t val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - if(ret == 0) { - ctrl1_xl.bw0_xl = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - } - - return ret; -} - -/** - * @brief Accelerometer analog chain bandwidth selection (only for - * accelerometer ODR ≥ 1.67 kHz).[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of bw0_xl in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_filter_analog_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_bw0_xl_t* val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - switch(ctrl1_xl.bw0_xl) { - case LSM6DS3TR_C_XL_ANA_BW_1k5Hz: - *val = LSM6DS3TR_C_XL_ANA_BW_1k5Hz; - break; - - case LSM6DS3TR_C_XL_ANA_BW_400Hz: - *val = LSM6DS3TR_C_XL_ANA_BW_400Hz; - break; - - default: - *val = LSM6DS3TR_C_XL_ANA_BW_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_accelerometer_filters - * @brief This section group all the functions concerning the filters - * configuration that impact accelerometer. - * @{ - * - */ - -/** - * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2 is - * not used.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of lpf1_bw_sel in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_lp1_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_bw_sel_t val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - if(ret == 0) { - ctrl1_xl.lpf1_bw_sel = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - ctrl8_xl.lpf2_xl_en = 0; - ctrl8_xl.hp_slope_xl_en = 0; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - } - } - } - - return ret; -} - -/** - * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2 - * is not used.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of lpf1_bw_sel in reg CTRL1_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_lp1_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_bw_sel_t* val) { - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - if((ctrl8_xl.lpf2_xl_en != 0x00U) || (ctrl8_xl.hp_slope_xl_en != 0x00U)) { - *val = LSM6DS3TR_C_XL_LP1_NA; - } - - else { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL, (uint8_t*)&ctrl1_xl, 1); - - switch(ctrl1_xl.lpf1_bw_sel) { - case LSM6DS3TR_C_XL_LP1_ODR_DIV_2: - *val = LSM6DS3TR_C_XL_LP1_ODR_DIV_2; - break; - - case LSM6DS3TR_C_XL_LP1_ODR_DIV_4: - *val = LSM6DS3TR_C_XL_LP1_ODR_DIV_4; - break; - - default: - *val = LSM6DS3TR_C_XL_LP1_NA; - break; - } - } - } - - return ret; -} - -/** - * @brief LPF2 on outputs[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of input_composite in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_lp2_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_input_composite_t val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - ctrl8_xl.input_composite = ((uint8_t)val & 0x10U) >> 4; - ctrl8_xl.hpcf_xl = (uint8_t)val & 0x03U; - ctrl8_xl.lpf2_xl_en = 1; - ctrl8_xl.hp_slope_xl_en = 0; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - } - - return ret; -} - -/** - * @brief LPF2 on outputs[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of input_composite in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_lp2_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_input_composite_t* val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - if((ctrl8_xl.lpf2_xl_en == 0x00U) || (ctrl8_xl.hp_slope_xl_en != 0x00U)) { - *val = LSM6DS3TR_C_XL_LP_NA; - } - - else { - switch((ctrl8_xl.input_composite << 4) + ctrl8_xl.hpcf_xl) { - case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_50: - *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_50; - break; - - case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_100: - *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_100; - break; - - case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_9: - *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_9; - break; - - case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_400: - *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_400; - break; - - case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_50: - *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_50; - break; - - case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_100: - *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_100; - break; - - case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_9: - *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_9; - break; - - case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_400: - *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_400; - break; - - default: - *val = LSM6DS3TR_C_XL_LP_NA; - break; - } - } - } - - return ret; -} - -/** - * @brief Enable HP filter reference mode.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of hp_ref_mode in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_reference_mode_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - ctrl8_xl.hp_ref_mode = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - } - - return ret; -} - -/** - * @brief Enable HP filter reference mode.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of hp_ref_mode in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_reference_mode_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - *val = ctrl8_xl.hp_ref_mode; - - return ret; -} - -/** - * @brief High pass/Slope on outputs.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of hpcf_xl in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_hp_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_hpcf_xl_t val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - ctrl8_xl.input_composite = 0; - ctrl8_xl.hpcf_xl = (uint8_t)val & 0x03U; - ctrl8_xl.hp_slope_xl_en = 1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - } - - return ret; -} - -/** - * @brief High pass/Slope on outputs.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of hpcf_xl in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_xl_hp_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_hpcf_xl_t* val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ctrl8_xl.hp_slope_xl_en == 0x00U) { - *val = LSM6DS3TR_C_XL_HP_NA; - } - - switch(ctrl8_xl.hpcf_xl) { - case LSM6DS3TR_C_XL_HP_ODR_DIV_4: - *val = LSM6DS3TR_C_XL_HP_ODR_DIV_4; - break; - - case LSM6DS3TR_C_XL_HP_ODR_DIV_100: - *val = LSM6DS3TR_C_XL_HP_ODR_DIV_100; - break; - - case LSM6DS3TR_C_XL_HP_ODR_DIV_9: - *val = LSM6DS3TR_C_XL_HP_ODR_DIV_9; - break; - - case LSM6DS3TR_C_XL_HP_ODR_DIV_400: - *val = LSM6DS3TR_C_XL_HP_ODR_DIV_400; - break; - - default: - *val = LSM6DS3TR_C_XL_HP_NA; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_gyroscope_filters - * @brief This section group all the functions concerning the filters - * configuration that impact gyroscope. - * @{ - * - */ - -/** - * @brief Gyroscope low pass path bandwidth.[set] - * - * @param ctx Read / write interface definitions - * @param val gyroscope filtering chain configuration. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_band_pass_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_sel_g_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - if(ret == 0) { - ctrl7_g.hpm_g = ((uint8_t)val & 0x30U) >> 4; - ctrl7_g.hp_en_g = ((uint8_t)val & 0x80U) >> 7; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ctrl6_c.ftype = (uint8_t)val & 0x03U; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.lpf1_sel_g = ((uint8_t)val & 0x08U) >> 3; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - } - } - } - } - - return ret; -} - -/** - * @brief Gyroscope low pass path bandwidth.[get] - * - * @param ctx Read / write interface definitions - * @param val gyroscope filtering chain - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_band_pass_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_sel_g_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G, (uint8_t*)&ctrl7_g, 1); - - switch((ctrl7_g.hp_en_g << 7) + (ctrl7_g.hpm_g << 4) + (ctrl4_c.lpf1_sel_g << 3) + - ctrl6_c.ftype) { - case LSM6DS3TR_C_HP_16mHz_LP2: - *val = LSM6DS3TR_C_HP_16mHz_LP2; - break; - - case LSM6DS3TR_C_HP_65mHz_LP2: - *val = LSM6DS3TR_C_HP_65mHz_LP2; - break; - - case LSM6DS3TR_C_HP_260mHz_LP2: - *val = LSM6DS3TR_C_HP_260mHz_LP2; - break; - - case LSM6DS3TR_C_HP_1Hz04_LP2: - *val = LSM6DS3TR_C_HP_1Hz04_LP2; - break; - - case LSM6DS3TR_C_HP_DISABLE_LP1_LIGHT: - *val = LSM6DS3TR_C_HP_DISABLE_LP1_LIGHT; - break; - - case LSM6DS3TR_C_HP_DISABLE_LP1_NORMAL: - *val = LSM6DS3TR_C_HP_DISABLE_LP1_NORMAL; - break; - - case LSM6DS3TR_C_HP_DISABLE_LP_STRONG: - *val = LSM6DS3TR_C_HP_DISABLE_LP_STRONG; - break; - - case LSM6DS3TR_C_HP_DISABLE_LP1_AGGRESSIVE: - *val = LSM6DS3TR_C_HP_DISABLE_LP1_AGGRESSIVE; - break; - - case LSM6DS3TR_C_HP_16mHz_LP1_LIGHT: - *val = LSM6DS3TR_C_HP_16mHz_LP1_LIGHT; - break; - - case LSM6DS3TR_C_HP_65mHz_LP1_NORMAL: - *val = LSM6DS3TR_C_HP_65mHz_LP1_NORMAL; - break; - - case LSM6DS3TR_C_HP_260mHz_LP1_STRONG: - *val = LSM6DS3TR_C_HP_260mHz_LP1_STRONG; - break; - - case LSM6DS3TR_C_HP_1Hz04_LP1_AGGRESSIVE: - *val = LSM6DS3TR_C_HP_1Hz04_LP1_AGGRESSIVE; - break; - - default: - *val = LSM6DS3TR_C_HP_GY_BAND_NA; - break; - } - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_serial_interface - * @brief This section groups all the functions concerning serial - * interface management - * @{ - * - */ - -/** - * @brief SPI Serial Interface Mode selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sim in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_spi_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_sim_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.sim = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief SPI Serial Interface Mode selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of sim in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_spi_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_sim_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - switch(ctrl3_c.sim) { - case LSM6DS3TR_C_SPI_4_WIRE: - *val = LSM6DS3TR_C_SPI_4_WIRE; - break; - - case LSM6DS3TR_C_SPI_3_WIRE: - *val = LSM6DS3TR_C_SPI_3_WIRE; - break; - - default: - *val = LSM6DS3TR_C_SPI_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Disable / Enable I2C interface.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of i2c_disable in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_i2c_interface_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_i2c_disable_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.i2c_disable = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - return ret; -} - -/** - * @brief Disable / Enable I2C interface.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of i2c_disable in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_i2c_interface_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_i2c_disable_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - switch(ctrl4_c.i2c_disable) { - case LSM6DS3TR_C_I2C_ENABLE: - *val = LSM6DS3TR_C_I2C_ENABLE; - break; - - case LSM6DS3TR_C_I2C_DISABLE: - *val = LSM6DS3TR_C_I2C_DISABLE; - break; - - default: - *val = LSM6DS3TR_C_I2C_MODE_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_interrupt_pins - * @brief This section groups all the functions that manage - * interrupt pins - * @{ - * - */ - -/** - * @brief Select the signal that need to route on int1 pad[set] - * - * @param ctx Read / write interface definitions - * @param val configure INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1), - * MASTER_CONFIG(drdy_on_int1) - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_int1_route_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_int1_route_t val) { - lsm6ds3tr_c_master_config_t master_config; - lsm6ds3tr_c_int1_ctrl_t int1_ctrl; - lsm6ds3tr_c_md1_cfg_t md1_cfg; - lsm6ds3tr_c_md2_cfg_t md2_cfg; - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT1_CTRL, (uint8_t*)&int1_ctrl, 1); - - if(ret == 0) { - int1_ctrl.int1_drdy_xl = val.int1_drdy_xl; - int1_ctrl.int1_drdy_g = val.int1_drdy_g; - int1_ctrl.int1_boot = val.int1_boot; - int1_ctrl.int1_fth = val.int1_fth; - int1_ctrl.int1_fifo_ovr = val.int1_fifo_ovr; - int1_ctrl.int1_full_flag = val.int1_full_flag; - int1_ctrl.int1_sign_mot = val.int1_sign_mot; - int1_ctrl.int1_step_detector = val.int1_step_detector; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT1_CTRL, (uint8_t*)&int1_ctrl, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG, (uint8_t*)&md1_cfg, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG, (uint8_t*)&md2_cfg, 1); - } - - if(ret == 0) { - md1_cfg.int1_timer = val.int1_timer; - md1_cfg.int1_tilt = val.int1_tilt; - md1_cfg.int1_6d = val.int1_6d; - md1_cfg.int1_double_tap = val.int1_double_tap; - md1_cfg.int1_ff = val.int1_ff; - md1_cfg.int1_wu = val.int1_wu; - md1_cfg.int1_single_tap = val.int1_single_tap; - md1_cfg.int1_inact_state = val.int1_inact_state; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MD1_CFG, (uint8_t*)&md1_cfg, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - if(ret == 0) { - ctrl4_c.den_drdy_int1 = val.den_drdy_int1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - if(ret == 0) { - master_config.drdy_on_int1 = val.den_drdy_int1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if((val.int1_6d != 0x00U) || (val.int1_ff != 0x00U) || (val.int1_wu != 0x00U) || - (val.int1_single_tap != 0x00U) || (val.int1_double_tap != 0x00U) || - (val.int1_inact_state != 0x00U) || (md2_cfg.int2_6d != 0x00U) || - (md2_cfg.int2_ff != 0x00U) || (md2_cfg.int2_wu != 0x00U) || - (md2_cfg.int2_single_tap != 0x00U) || (md2_cfg.int2_double_tap != 0x00U) || - (md2_cfg.int2_inact_state != 0x00U)) { - tap_cfg.interrupts_enable = PROPERTY_ENABLE; - } - - else { - tap_cfg.interrupts_enable = PROPERTY_DISABLE; - } - } - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Select the signal that need to route on int1 pad[get] - * - * @param ctx Read / write interface definitions - * @param val read INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1), - * MASTER_CONFIG(drdy_on_int1) - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_int1_route_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_int1_route_t* val) { - lsm6ds3tr_c_master_config_t master_config; - lsm6ds3tr_c_int1_ctrl_t int1_ctrl; - lsm6ds3tr_c_md1_cfg_t md1_cfg; - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT1_CTRL, (uint8_t*)&int1_ctrl, 1); - - if(ret == 0) { - val->int1_drdy_xl = int1_ctrl.int1_drdy_xl; - val->int1_drdy_g = int1_ctrl.int1_drdy_g; - val->int1_boot = int1_ctrl.int1_boot; - val->int1_fth = int1_ctrl.int1_fth; - val->int1_fifo_ovr = int1_ctrl.int1_fifo_ovr; - val->int1_full_flag = int1_ctrl.int1_full_flag; - val->int1_sign_mot = int1_ctrl.int1_sign_mot; - val->int1_step_detector = int1_ctrl.int1_step_detector; - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG, (uint8_t*)&md1_cfg, 1); - - if(ret == 0) { - val->int1_timer = md1_cfg.int1_timer; - val->int1_tilt = md1_cfg.int1_tilt; - val->int1_6d = md1_cfg.int1_6d; - val->int1_double_tap = md1_cfg.int1_double_tap; - val->int1_ff = md1_cfg.int1_ff; - val->int1_wu = md1_cfg.int1_wu; - val->int1_single_tap = md1_cfg.int1_single_tap; - val->int1_inact_state = md1_cfg.int1_inact_state; - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - val->den_drdy_int1 = ctrl4_c.den_drdy_int1; - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - val->den_drdy_int1 = master_config.drdy_on_int1; - } - } - } - - return ret; -} - -/** - * @brief Select the signal that need to route on int2 pad[set] - * - * @param ctx Read / write interface definitions - * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_int2_route_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_int2_route_t val) { - lsm6ds3tr_c_int2_ctrl_t int2_ctrl; - lsm6ds3tr_c_md1_cfg_t md1_cfg; - lsm6ds3tr_c_md2_cfg_t md2_cfg; - lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT2_CTRL, (uint8_t*)&int2_ctrl, 1); - - if(ret == 0) { - int2_ctrl.int2_drdy_xl = val.int2_drdy_xl; - int2_ctrl.int2_drdy_g = val.int2_drdy_g; - int2_ctrl.int2_drdy_temp = val.int2_drdy_temp; - int2_ctrl.int2_fth = val.int2_fth; - int2_ctrl.int2_fifo_ovr = val.int2_fifo_ovr; - int2_ctrl.int2_full_flag = val.int2_full_flag; - int2_ctrl.int2_step_count_ov = val.int2_step_count_ov; - int2_ctrl.int2_step_delta = val.int2_step_delta; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT2_CTRL, (uint8_t*)&int2_ctrl, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG, (uint8_t*)&md1_cfg, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG, (uint8_t*)&md2_cfg, 1); - } - - if(ret == 0) { - md2_cfg.int2_iron = val.int2_iron; - md2_cfg.int2_tilt = val.int2_tilt; - md2_cfg.int2_6d = val.int2_6d; - md2_cfg.int2_double_tap = val.int2_double_tap; - md2_cfg.int2_ff = val.int2_ff; - md2_cfg.int2_wu = val.int2_wu; - md2_cfg.int2_single_tap = val.int2_single_tap; - md2_cfg.int2_inact_state = val.int2_inact_state; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MD2_CFG, (uint8_t*)&md2_cfg, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - } - - if(ret == 0) { - drdy_pulse_cfg_g.int2_wrist_tilt = val.int2_wrist_tilt; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - } - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if((md1_cfg.int1_6d != 0x00U) || (md1_cfg.int1_ff != 0x00U) || - (md1_cfg.int1_wu != 0x00U) || (md1_cfg.int1_single_tap != 0x00U) || - (md1_cfg.int1_double_tap != 0x00U) || (md1_cfg.int1_inact_state != 0x00U) || - (val.int2_6d != 0x00U) || (val.int2_ff != 0x00U) || (val.int2_wu != 0x00U) || - (val.int2_single_tap != 0x00U) || (val.int2_double_tap != 0x00U) || - (val.int2_inact_state != 0x00U)) { - tap_cfg.interrupts_enable = PROPERTY_ENABLE; - } - - else { - tap_cfg.interrupts_enable = PROPERTY_DISABLE; - } - } - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Select the signal that need to route on int2 pad[get] - * - * @param ctx Read / write interface definitions - * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_int2_route_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_int2_route_t* val) { - lsm6ds3tr_c_int2_ctrl_t int2_ctrl; - lsm6ds3tr_c_md2_cfg_t md2_cfg; - lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT2_CTRL, (uint8_t*)&int2_ctrl, 1); - - if(ret == 0) { - val->int2_drdy_xl = int2_ctrl.int2_drdy_xl; - val->int2_drdy_g = int2_ctrl.int2_drdy_g; - val->int2_drdy_temp = int2_ctrl.int2_drdy_temp; - val->int2_fth = int2_ctrl.int2_fth; - val->int2_fifo_ovr = int2_ctrl.int2_fifo_ovr; - val->int2_full_flag = int2_ctrl.int2_full_flag; - val->int2_step_count_ov = int2_ctrl.int2_step_count_ov; - val->int2_step_delta = int2_ctrl.int2_step_delta; - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG, (uint8_t*)&md2_cfg, 1); - - if(ret == 0) { - val->int2_iron = md2_cfg.int2_iron; - val->int2_tilt = md2_cfg.int2_tilt; - val->int2_6d = md2_cfg.int2_6d; - val->int2_double_tap = md2_cfg.int2_double_tap; - val->int2_ff = md2_cfg.int2_ff; - val->int2_wu = md2_cfg.int2_wu; - val->int2_single_tap = md2_cfg.int2_single_tap; - val->int2_inact_state = md2_cfg.int2_inact_state; - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G, (uint8_t*)&drdy_pulse_cfg_g, 1); - val->int2_wrist_tilt = drdy_pulse_cfg_g.int2_wrist_tilt; - } - } - - return ret; -} - -/** - * @brief Push-pull/open drain selection on interrupt pads.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pp_od in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pp_od_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.pp_od = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Push-pull/open drain selection on interrupt pads.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of pp_od in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pp_od_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - switch(ctrl3_c.pp_od) { - case LSM6DS3TR_C_PUSH_PULL: - *val = LSM6DS3TR_C_PUSH_PULL; - break; - - case LSM6DS3TR_C_OPEN_DRAIN: - *val = LSM6DS3TR_C_OPEN_DRAIN; - break; - - default: - *val = LSM6DS3TR_C_PIN_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Interrupt active-high/low.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of h_lactive in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_polarity_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_h_lactive_t val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - if(ret == 0) { - ctrl3_c.h_lactive = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - } - - return ret; -} - -/** - * @brief Interrupt active-high/low.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of h_lactive in reg CTRL3_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pin_polarity_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_h_lactive_t* val) { - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C, (uint8_t*)&ctrl3_c, 1); - - switch(ctrl3_c.h_lactive) { - case LSM6DS3TR_C_ACTIVE_HIGH: - *val = LSM6DS3TR_C_ACTIVE_HIGH; - break; - - case LSM6DS3TR_C_ACTIVE_LOW: - *val = LSM6DS3TR_C_ACTIVE_LOW; - break; - - default: - *val = LSM6DS3TR_C_POLARITY_ND; - break; - } - - return ret; -} - -/** - * @brief All interrupt signals become available on INT1 pin.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of int2_on_int1 in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_all_on_int1_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.int2_on_int1 = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - return ret; -} - -/** - * @brief All interrupt signals become available on INT1 pin.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of int2_on_int1 in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_all_on_int1_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - *val = ctrl4_c.int2_on_int1; - - return ret; -} - -/** - * @brief Latched/pulsed interrupt.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of lir in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_int_notification_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lir_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.lir = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Latched/pulsed interrupt.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of lir in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_int_notification_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lir_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - switch(tap_cfg.lir) { - case LSM6DS3TR_C_INT_PULSED: - *val = LSM6DS3TR_C_INT_PULSED; - break; - - case LSM6DS3TR_C_INT_LATCHED: - *val = LSM6DS3TR_C_INT_LATCHED; - break; - - default: - *val = LSM6DS3TR_C_INT_MODE; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Wake_Up_event - * @brief This section groups all the functions that manage the - * Wake Up event generation. - * @{ - * - */ - -/** - * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of wk_ths in reg WAKE_UP_THS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wkup_threshold_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_wake_up_ths_t wake_up_ths; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - - if(ret == 0) { - wake_up_ths.wk_ths = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - } - - return ret; -} - -/** - * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of wk_ths in reg WAKE_UP_THS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wkup_threshold_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_wake_up_ths_t wake_up_ths; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - *val = wake_up_ths.wk_ths; - - return ret; -} - -/** - * @brief Wake up duration event.1LSb = 1 / ODR[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of wake_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wkup_dur_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - if(ret == 0) { - wake_up_dur.wake_dur = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - } - - return ret; -} - -/** - * @brief Wake up duration event.1LSb = 1 / ODR[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of wake_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wkup_dur_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - *val = wake_up_dur.wake_dur; - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Activity/Inactivity_detection - * @brief This section groups all the functions concerning - * activity/inactivity detection. - * @{ - * - */ - -/** - * @brief Enables gyroscope Sleep mode.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sleep in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_sleep_mode_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.sleep = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - - return ret; -} - -/** - * @brief Enables gyroscope Sleep mode.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sleep in reg CTRL4_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_gy_sleep_mode_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - *val = ctrl4_c.sleep; - - return ret; -} - -/** - * @brief Enable inactivity function.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of inact_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_act_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_inact_en_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.inact_en = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Enable inactivity function.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of inact_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_act_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_inact_en_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - switch(tap_cfg.inact_en) { - case LSM6DS3TR_C_PROPERTY_DISABLE: - *val = LSM6DS3TR_C_PROPERTY_DISABLE; - break; - - case LSM6DS3TR_C_XL_12Hz5_GY_NOT_AFFECTED: - *val = LSM6DS3TR_C_XL_12Hz5_GY_NOT_AFFECTED; - break; - - case LSM6DS3TR_C_XL_12Hz5_GY_SLEEP: - *val = LSM6DS3TR_C_XL_12Hz5_GY_SLEEP; - break; - - case LSM6DS3TR_C_XL_12Hz5_GY_PD: - *val = LSM6DS3TR_C_XL_12Hz5_GY_PD; - break; - - default: - *val = LSM6DS3TR_C_ACT_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Duration to go in sleep mode.1 LSb = 512 / ODR[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sleep_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_act_sleep_dur_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - if(ret == 0) { - wake_up_dur.sleep_dur = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - } - - return ret; -} - -/** - * @brief Duration to go in sleep mode. 1 LSb = 512 / ODR[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sleep_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_act_sleep_dur_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - *val = wake_up_dur.sleep_dur; - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_tap_generator - * @brief This section groups all the functions that manage the - * tap and double tap event generation. - * @{ - * - */ - -/** - * @brief Read the tap / double tap source register.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure of registers from TAP_SRC - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_src_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_tap_src_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_SRC, (uint8_t*)val, 1); - - return ret; -} - -/** - * @brief Enable Z direction in tap recognition.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_z_en in reg TAP_CFG - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_z_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.tap_z_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Enable Z direction in tap recognition.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_z_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_z_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - *val = tap_cfg.tap_z_en; - - return ret; -} - -/** - * @brief Enable Y direction in tap recognition.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_y_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_y_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.tap_y_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Enable Y direction in tap recognition.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_y_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_y_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - *val = tap_cfg.tap_y_en; - - return ret; -} - -/** - * @brief Enable X direction in tap recognition.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_x_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_x_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - - if(ret == 0) { - tap_cfg.tap_x_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - } - - return ret; -} - -/** - * @brief Enable X direction in tap recognition.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_x_en in reg TAP_CFG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_detection_on_x_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_tap_cfg_t tap_cfg; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG, (uint8_t*)&tap_cfg, 1); - *val = tap_cfg.tap_x_en; - - return ret; -} - -/** - * @brief Threshold for tap recognition.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_ths in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_threshold_x_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - - if(ret == 0) { - tap_ths_6d.tap_ths = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - } - - return ret; -} - -/** - * @brief Threshold for tap recognition.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tap_ths in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_threshold_x_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - *val = tap_ths_6d.tap_ths; - - return ret; -} - -/** - * @brief Maximum duration is the maximum time of an overthreshold signal - * detection to be recognized as a tap event. - * The default value of these bits is 00b which corresponds to - * 4*ODR_XL time. - * If the SHOCK[1:0] bits are set to a different - * value, 1LSB corresponds to 8*ODR_XL time.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of shock in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_shock_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - - if(ret == 0) { - int_dur2.shock = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - } - - return ret; -} - -/** - * @brief Maximum duration is the maximum time of an overthreshold signal - * detection to be recognized as a tap event. - * The default value of these bits is 00b which corresponds to - * 4*ODR_XL time. - * If the SHOCK[1:0] bits are set to a different value, 1LSB - * corresponds to 8*ODR_XL time.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of shock in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_shock_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - *val = int_dur2.shock; - - return ret; -} - -/** - * @brief Quiet time is the time after the first detected tap in which there - * must not be any overthreshold event. - * The default value of these bits is 00b which corresponds to - * 2*ODR_XL time. - * If the QUIET[1:0] bits are set to a different value, 1LSB - * corresponds to 4*ODR_XL time.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of quiet in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_quiet_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - - if(ret == 0) { - int_dur2.quiet = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - } - - return ret; -} - -/** - * @brief Quiet time is the time after the first detected tap in which there - * must not be any overthreshold event. - * The default value of these bits is 00b which corresponds to - * 2*ODR_XL time. - * If the QUIET[1:0] bits are set to a different value, 1LSB - * corresponds to 4*ODR_XL time.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of quiet in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_quiet_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - *val = int_dur2.quiet; - - return ret; -} - -/** - * @brief When double tap recognition is enabled, this register expresses the - * maximum time between two consecutive detected taps to determine a - * double tap event. - * The default value of these bits is 0000b which corresponds to - * 16*ODR_XL time. - * If the DUR[3:0] bits are set to a different value,1LSB corresponds - * to 32*ODR_XL time.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dur in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_dur_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - - if(ret == 0) { - int_dur2.dur = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - } - - return ret; -} - -/** - * @brief When double tap recognition is enabled, this register expresses the - * maximum time between two consecutive detected taps to determine a - * double tap event. - * The default value of these bits is 0000b which corresponds to - * 16*ODR_XL time. - * If the DUR[3:0] bits are set to a different value,1LSB corresponds - * to 32*ODR_XL time.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dur in reg INT_DUR2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_dur_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_int_dur2_t int_dur2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2, (uint8_t*)&int_dur2, 1); - *val = int_dur2.dur; - - return ret; -} - -/** - * @brief Single/double-tap event enable/disable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of - * single_double_tap in reg WAKE_UP_THS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_single_double_tap_t val) { - lsm6ds3tr_c_wake_up_ths_t wake_up_ths; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - - if(ret == 0) { - wake_up_ths.single_double_tap = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - } - - return ret; -} - -/** - * @brief Single/double-tap event enable/disable.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of single_double_tap - * in reg WAKE_UP_THS - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tap_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_single_double_tap_t* val) { - lsm6ds3tr_c_wake_up_ths_t wake_up_ths; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS, (uint8_t*)&wake_up_ths, 1); - - switch(wake_up_ths.single_double_tap) { - case LSM6DS3TR_C_ONLY_SINGLE: - *val = LSM6DS3TR_C_ONLY_SINGLE; - break; - - case LSM6DS3TR_C_BOTH_SINGLE_DOUBLE: - *val = LSM6DS3TR_C_BOTH_SINGLE_DOUBLE; - break; - - default: - *val = LSM6DS3TR_C_TAP_MODE_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_ Six_position_detection(6D/4D) - * @brief This section groups all the functions concerning six - * position detection (6D). - * @{ - * - */ - -/** - * @brief LPF2 feed 6D function selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of low_pass_on_6d in - * reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_6d_feed_data_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_low_pass_on_6d_t val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - if(ret == 0) { - ctrl8_xl.low_pass_on_6d = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - } - - return ret; -} - -/** - * @brief LPF2 feed 6D function selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of low_pass_on_6d in reg CTRL8_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_6d_feed_data_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_low_pass_on_6d_t* val) { - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL, (uint8_t*)&ctrl8_xl, 1); - - switch(ctrl8_xl.low_pass_on_6d) { - case LSM6DS3TR_C_ODR_DIV_2_FEED: - *val = LSM6DS3TR_C_ODR_DIV_2_FEED; - break; - - case LSM6DS3TR_C_LPF2_FEED: - *val = LSM6DS3TR_C_LPF2_FEED; - break; - - default: - *val = LSM6DS3TR_C_6D_FEED_ND; - break; - } - - return ret; -} - -/** - * @brief Threshold for 4D/6D function.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sixd_ths in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_6d_threshold_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_sixd_ths_t val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - - if(ret == 0) { - tap_ths_6d.sixd_ths = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - } - - return ret; -} - -/** - * @brief Threshold for 4D/6D function.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of sixd_ths in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_6d_threshold_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_sixd_ths_t* val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - - switch(tap_ths_6d.sixd_ths) { - case LSM6DS3TR_C_DEG_80: - *val = LSM6DS3TR_C_DEG_80; - break; - - case LSM6DS3TR_C_DEG_70: - *val = LSM6DS3TR_C_DEG_70; - break; - - case LSM6DS3TR_C_DEG_60: - *val = LSM6DS3TR_C_DEG_60; - break; - - case LSM6DS3TR_C_DEG_50: - *val = LSM6DS3TR_C_DEG_50; - break; - - default: - *val = LSM6DS3TR_C_6D_TH_ND; - break; - } - - return ret; -} - -/** - * @brief 4D orientation detection enable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of d4d_en in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_4d_mode_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - - if(ret == 0) { - tap_ths_6d.d4d_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - } - - return ret; -} - -/** - * @brief 4D orientation detection enable.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of d4d_en in reg TAP_THS_6D - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_4d_mode_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D, (uint8_t*)&tap_ths_6d, 1); - *val = tap_ths_6d.d4d_en; - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_free_fall - * @brief This section group all the functions concerning the free - * fall detection. - * @{ - * - */ - -/** - * @brief Free-fall duration event. 1LSb = 1 / ODR[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ff_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_ff_dur_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - lsm6ds3tr_c_free_fall_t free_fall; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - - if(ret == 0) { - free_fall.ff_dur = (val & 0x1FU); - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - if(ret == 0) { - wake_up_dur.ff_dur = (val & 0x20U) >> 5; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - } - } - } - - return ret; -} - -/** - * @brief Free-fall duration event. 1LSb = 1 / ODR[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ff_dur in reg WAKE_UP_DUR - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_ff_dur_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - lsm6ds3tr_c_free_fall_t free_fall; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR, (uint8_t*)&wake_up_dur, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - } - - *val = (wake_up_dur.ff_dur << 5) + free_fall.ff_dur; - - return ret; -} - -/** - * @brief Free fall threshold setting.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ff_ths in reg FREE_FALL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_ff_threshold_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_ff_ths_t val) { - lsm6ds3tr_c_free_fall_t free_fall; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - - if(ret == 0) { - free_fall.ff_ths = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - } - - return ret; -} - -/** - * @brief Free fall threshold setting.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of ff_ths in reg FREE_FALL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_ff_threshold_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_ff_ths_t* val) { - lsm6ds3tr_c_free_fall_t free_fall; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL, (uint8_t*)&free_fall, 1); - - switch(free_fall.ff_ths) { - case LSM6DS3TR_C_FF_TSH_156mg: - *val = LSM6DS3TR_C_FF_TSH_156mg; - break; - - case LSM6DS3TR_C_FF_TSH_219mg: - *val = LSM6DS3TR_C_FF_TSH_219mg; - break; - - case LSM6DS3TR_C_FF_TSH_250mg: - *val = LSM6DS3TR_C_FF_TSH_250mg; - break; - - case LSM6DS3TR_C_FF_TSH_312mg: - *val = LSM6DS3TR_C_FF_TSH_312mg; - break; - - case LSM6DS3TR_C_FF_TSH_344mg: - *val = LSM6DS3TR_C_FF_TSH_344mg; - break; - - case LSM6DS3TR_C_FF_TSH_406mg: - *val = LSM6DS3TR_C_FF_TSH_406mg; - break; - - case LSM6DS3TR_C_FF_TSH_469mg: - *val = LSM6DS3TR_C_FF_TSH_469mg; - break; - - case LSM6DS3TR_C_FF_TSH_500mg: - *val = LSM6DS3TR_C_FF_TSH_500mg; - break; - - default: - *val = LSM6DS3TR_C_FF_TSH_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_fifo - * @brief This section group all the functions concerning the - * fifo usage - * @{ - * - */ - -/** - * @brief FIFO watermark level selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fth in reg FIFO_CTRL1 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_watermark_set(stmdev_ctx_t* ctx, uint16_t val) { - lsm6ds3tr_c_fifo_ctrl1_t fifo_ctrl1; - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - fifo_ctrl1.fth = (uint8_t)(0x00FFU & val); - fifo_ctrl2.fth = (uint8_t)((0x0700U & val) >> 8); - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL1, (uint8_t*)&fifo_ctrl1, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - } - } - - return ret; -} - -/** - * @brief FIFO watermark level selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fth in reg FIFO_CTRL1 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_watermark_get(stmdev_ctx_t* ctx, uint16_t* val) { - lsm6ds3tr_c_fifo_ctrl1_t fifo_ctrl1; - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL1, (uint8_t*)&fifo_ctrl1, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - } - - *val = ((uint16_t)fifo_ctrl2.fth << 8) + (uint16_t)fifo_ctrl1.fth; - - return ret; -} - -/** - * @brief FIFO data level.[get] - * - * @param ctx Read / write interface definitions - * @param val get the values of diff_fifo in reg FIFO_STATUS1 and - * FIFO_STATUS2(diff_fifo), it is recommended to set the - * BDU bit. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_data_level_get(stmdev_ctx_t* ctx, uint16_t* val) { - lsm6ds3tr_c_fifo_status1_t fifo_status1; - lsm6ds3tr_c_fifo_status2_t fifo_status2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS1, (uint8_t*)&fifo_status1, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS2, (uint8_t*)&fifo_status2, 1); - *val = ((uint16_t)fifo_status2.diff_fifo << 8) + (uint16_t)fifo_status1.diff_fifo; - } - - return ret; -} - -/** - * @brief FIFO watermark.[get] - * - * @param ctx Read / write interface definitions - * @param val get the values of watermark in reg FIFO_STATUS2 and - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_wtm_flag_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_fifo_status2_t fifo_status2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS2, (uint8_t*)&fifo_status2, 1); - *val = fifo_status2.waterm; - - return ret; -} - -/** - * @brief FIFO pattern.[get] - * - * @param ctx Read / write interface definitions - * @param val get the values of fifo_pattern in reg FIFO_STATUS3 and - * FIFO_STATUS4, it is recommended to set the BDU bit - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_pattern_get(stmdev_ctx_t* ctx, uint16_t* val) { - lsm6ds3tr_c_fifo_status3_t fifo_status3; - lsm6ds3tr_c_fifo_status4_t fifo_status4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS3, (uint8_t*)&fifo_status3, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS4, (uint8_t*)&fifo_status4, 1); - *val = ((uint16_t)fifo_status4.fifo_pattern << 8) + fifo_status3.fifo_pattern; - } - - return ret; -} - -/** - * @brief Batching of temperature data[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_temp_batch_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - fifo_ctrl2.fifo_temp_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - } - - return ret; -} - -/** - * @brief Batching of temperature data[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_temp_batch_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - *val = fifo_ctrl2.fifo_temp_en; - - return ret; -} - -/** - * @brief Trigger signal for FIFO write operation.[set] - * - * @param ctx Read / write interface definitions - * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy) - * and MASTER_CONFIG(data_valid_sel_fifo) - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_write_trigger_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_trigger_fifo_t val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - fifo_ctrl2.timer_pedo_fifo_drdy = (uint8_t)val & 0x01U; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - ret = - lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.data_valid_sel_fifo = (((uint8_t)val & 0x02U) >> 1); - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - } - } - - return ret; -} - -/** - * @brief Trigger signal for FIFO write operation.[get] - * - * @param ctx Read / write interface definitions - * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy) - * and MASTER_CONFIG(data_valid_sel_fifo) - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_write_trigger_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_trigger_fifo_t* val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - switch((fifo_ctrl2.timer_pedo_fifo_drdy << 1) + fifo_ctrl2.timer_pedo_fifo_drdy) { - case LSM6DS3TR_C_TRG_XL_GY_DRDY: - *val = LSM6DS3TR_C_TRG_XL_GY_DRDY; - break; - - case LSM6DS3TR_C_TRG_STEP_DETECT: - *val = LSM6DS3TR_C_TRG_STEP_DETECT; - break; - - case LSM6DS3TR_C_TRG_SH_DRDY: - *val = LSM6DS3TR_C_TRG_SH_DRDY; - break; - - default: - *val = LSM6DS3TR_C_TRG_SH_ND; - break; - } - } - - return ret; -} - -/** - * @brief Enable pedometer step counter and timestamp as 4th - * FIFO data set.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - - if(ret == 0) { - fifo_ctrl2.timer_pedo_fifo_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - } - - return ret; -} - -/** - * @brief Enable pedometer step counter and timestamp as 4th - * FIFO data set.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2, (uint8_t*)&fifo_ctrl2, 1); - *val = fifo_ctrl2.timer_pedo_fifo_en; - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) for - * accelerometer data.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dec_fifo_xl in reg FIFO_CTRL3 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_xl_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_xl_t val) { - lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - - if(ret == 0) { - fifo_ctrl3.dec_fifo_xl = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) for - * accelerometer data.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of dec_fifo_xl in reg FIFO_CTRL3 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_xl_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_xl_t* val) { - lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - - switch(fifo_ctrl3.dec_fifo_xl) { - case LSM6DS3TR_C_FIFO_XL_DISABLE: - *val = LSM6DS3TR_C_FIFO_XL_DISABLE; - break; - - case LSM6DS3TR_C_FIFO_XL_NO_DEC: - *val = LSM6DS3TR_C_FIFO_XL_NO_DEC; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_2: - *val = LSM6DS3TR_C_FIFO_XL_DEC_2; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_3: - *val = LSM6DS3TR_C_FIFO_XL_DEC_3; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_4: - *val = LSM6DS3TR_C_FIFO_XL_DEC_4; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_8: - *val = LSM6DS3TR_C_FIFO_XL_DEC_8; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_16: - *val = LSM6DS3TR_C_FIFO_XL_DEC_16; - break; - - case LSM6DS3TR_C_FIFO_XL_DEC_32: - *val = LSM6DS3TR_C_FIFO_XL_DEC_32; - break; - - default: - *val = LSM6DS3TR_C_FIFO_XL_DEC_ND; - break; - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) - * for gyroscope data.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dec_fifo_gyro in reg FIFO_CTRL3 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_gy_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_gyro_t val) { - lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - - if(ret == 0) { - fifo_ctrl3.dec_fifo_gyro = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) - * for gyroscope data.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of dec_fifo_gyro in reg FIFO_CTRL3 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_gy_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_gyro_t* val) { - lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3, (uint8_t*)&fifo_ctrl3, 1); - - switch(fifo_ctrl3.dec_fifo_gyro) { - case LSM6DS3TR_C_FIFO_GY_DISABLE: - *val = LSM6DS3TR_C_FIFO_GY_DISABLE; - break; - - case LSM6DS3TR_C_FIFO_GY_NO_DEC: - *val = LSM6DS3TR_C_FIFO_GY_NO_DEC; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_2: - *val = LSM6DS3TR_C_FIFO_GY_DEC_2; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_3: - *val = LSM6DS3TR_C_FIFO_GY_DEC_3; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_4: - *val = LSM6DS3TR_C_FIFO_GY_DEC_4; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_8: - *val = LSM6DS3TR_C_FIFO_GY_DEC_8; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_16: - *val = LSM6DS3TR_C_FIFO_GY_DEC_16; - break; - - case LSM6DS3TR_C_FIFO_GY_DEC_32: - *val = LSM6DS3TR_C_FIFO_GY_DEC_32; - break; - - default: - *val = LSM6DS3TR_C_FIFO_GY_DEC_ND; - break; - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) - * for third data set.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dec_ds3_fifo in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_dataset_3_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds3_fifo_t val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - if(ret == 0) { - fifo_ctrl4.dec_ds3_fifo = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) - * for third data set.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of dec_ds3_fifo in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_dataset_3_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds3_fifo_t* val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - switch(fifo_ctrl4.dec_ds3_fifo) { - case LSM6DS3TR_C_FIFO_DS3_DISABLE: - *val = LSM6DS3TR_C_FIFO_DS3_DISABLE; - break; - - case LSM6DS3TR_C_FIFO_DS3_NO_DEC: - *val = LSM6DS3TR_C_FIFO_DS3_NO_DEC; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_2: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_2; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_3: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_3; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_4: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_4; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_8: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_8; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_16: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_16; - break; - - case LSM6DS3TR_C_FIFO_DS3_DEC_32: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_32; - break; - - default: - *val = LSM6DS3TR_C_FIFO_DS3_DEC_ND; - break; - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) - * for fourth data set.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of dec_ds4_fifo in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_dataset_4_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds4_fifo_t val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - if(ret == 0) { - fifo_ctrl4.dec_ds4_fifo = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - } - - return ret; -} - -/** - * @brief Selects Batching Data Rate (writing frequency in FIFO) for - * fourth data set.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of dec_ds4_fifo in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_dataset_4_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds4_fifo_t* val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - switch(fifo_ctrl4.dec_ds4_fifo) { - case LSM6DS3TR_C_FIFO_DS4_DISABLE: - *val = LSM6DS3TR_C_FIFO_DS4_DISABLE; - break; - - case LSM6DS3TR_C_FIFO_DS4_NO_DEC: - *val = LSM6DS3TR_C_FIFO_DS4_NO_DEC; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_2: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_2; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_3: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_3; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_4: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_4; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_8: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_8; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_16: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_16; - break; - - case LSM6DS3TR_C_FIFO_DS4_DEC_32: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_32; - break; - - default: - *val = LSM6DS3TR_C_FIFO_DS4_DEC_ND; - break; - } - - return ret; -} - -/** - * @brief 8-bit data storage in FIFO.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of only_high_data in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - if(ret == 0) { - fifo_ctrl4.only_high_data = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - } - - return ret; -} - -/** - * @brief 8-bit data storage in FIFO.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of only_high_data in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - *val = fifo_ctrl4.only_high_data; - - return ret; -} - -/** - * @brief Sensing chain FIFO stop values memorization at threshold - * level.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of stop_on_fth in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_stop_on_wtm_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - - if(ret == 0) { - fifo_ctrl4.stop_on_fth = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - } - - return ret; -} - -/** - * @brief Sensing chain FIFO stop values memorization at threshold - * level.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of stop_on_fth in reg FIFO_CTRL4 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_stop_on_wtm_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4, (uint8_t*)&fifo_ctrl4, 1); - *val = fifo_ctrl4.stop_on_fth; - - return ret; -} - -/** - * @brief FIFO mode selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of fifo_mode in reg FIFO_CTRL5 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fifo_mode_t val) { - lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - - if(ret == 0) { - fifo_ctrl5.fifo_mode = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - } - - return ret; -} - -/** - * @brief FIFO mode selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of fifo_mode in reg FIFO_CTRL5 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fifo_mode_t* val) { - lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - - switch(fifo_ctrl5.fifo_mode) { - case LSM6DS3TR_C_BYPASS_MODE: - *val = LSM6DS3TR_C_BYPASS_MODE; - break; - - case LSM6DS3TR_C_FIFO_MODE: - *val = LSM6DS3TR_C_FIFO_MODE; - break; - - case LSM6DS3TR_C_STREAM_TO_FIFO_MODE: - *val = LSM6DS3TR_C_STREAM_TO_FIFO_MODE; - break; - - case LSM6DS3TR_C_BYPASS_TO_STREAM_MODE: - *val = LSM6DS3TR_C_BYPASS_TO_STREAM_MODE; - break; - - case LSM6DS3TR_C_STREAM_MODE: - *val = LSM6DS3TR_C_STREAM_MODE; - break; - - default: - *val = LSM6DS3TR_C_FIFO_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief FIFO ODR selection, setting FIFO_MODE also.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of odr_fifo in reg FIFO_CTRL5 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_fifo_t val) { - lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - - if(ret == 0) { - fifo_ctrl5.odr_fifo = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - } - - return ret; -} - -/** - * @brief FIFO ODR selection, setting FIFO_MODE also.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of odr_fifo in reg FIFO_CTRL5 - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_fifo_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_fifo_t* val) { - lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5, (uint8_t*)&fifo_ctrl5, 1); - - switch(fifo_ctrl5.odr_fifo) { - case LSM6DS3TR_C_FIFO_DISABLE: - *val = LSM6DS3TR_C_FIFO_DISABLE; - break; - - case LSM6DS3TR_C_FIFO_12Hz5: - *val = LSM6DS3TR_C_FIFO_12Hz5; - break; - - case LSM6DS3TR_C_FIFO_26Hz: - *val = LSM6DS3TR_C_FIFO_26Hz; - break; - - case LSM6DS3TR_C_FIFO_52Hz: - *val = LSM6DS3TR_C_FIFO_52Hz; - break; - - case LSM6DS3TR_C_FIFO_104Hz: - *val = LSM6DS3TR_C_FIFO_104Hz; - break; - - case LSM6DS3TR_C_FIFO_208Hz: - *val = LSM6DS3TR_C_FIFO_208Hz; - break; - - case LSM6DS3TR_C_FIFO_416Hz: - *val = LSM6DS3TR_C_FIFO_416Hz; - break; - - case LSM6DS3TR_C_FIFO_833Hz: - *val = LSM6DS3TR_C_FIFO_833Hz; - break; - - case LSM6DS3TR_C_FIFO_1k66Hz: - *val = LSM6DS3TR_C_FIFO_1k66Hz; - break; - - case LSM6DS3TR_C_FIFO_3k33Hz: - *val = LSM6DS3TR_C_FIFO_3k33Hz; - break; - - case LSM6DS3TR_C_FIFO_6k66Hz: - *val = LSM6DS3TR_C_FIFO_6k66Hz; - break; - - default: - *val = LSM6DS3TR_C_FIFO_RATE_ND; - break; - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_DEN_functionality - * @brief This section groups all the functions concerning DEN - * functionality. - * @{ - * - */ - -/** - * @brief DEN active level configuration.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_lh in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_polarity_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_lh_t val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - if(ret == 0) { - ctrl5_c.den_lh = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - } - - return ret; -} - -/** - * @brief DEN active level configuration.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of den_lh in reg CTRL5_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_polarity_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_lh_t* val) { - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C, (uint8_t*)&ctrl5_c, 1); - - switch(ctrl5_c.den_lh) { - case LSM6DS3TR_C_DEN_ACT_LOW: - *val = LSM6DS3TR_C_DEN_ACT_LOW; - break; - - case LSM6DS3TR_C_DEN_ACT_HIGH: - *val = LSM6DS3TR_C_DEN_ACT_HIGH; - break; - - default: - *val = LSM6DS3TR_C_DEN_POL_ND; - break; - } - - return ret; -} - -/** - * @brief DEN functionality marking mode[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_mode in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_mode_t val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - if(ret == 0) { - ctrl6_c.den_mode = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - } - - return ret; -} - -/** - * @brief DEN functionality marking mode[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_mode in reg CTRL6_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_mode_t* val) { - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C, (uint8_t*)&ctrl6_c, 1); - - switch(ctrl6_c.den_mode) { - case LSM6DS3TR_C_DEN_DISABLE: - *val = LSM6DS3TR_C_DEN_DISABLE; - break; - - case LSM6DS3TR_C_LEVEL_LETCHED: - *val = LSM6DS3TR_C_LEVEL_LETCHED; - break; - - case LSM6DS3TR_C_LEVEL_TRIGGER: - *val = LSM6DS3TR_C_LEVEL_TRIGGER; - break; - - case LSM6DS3TR_C_EDGE_TRIGGER: - *val = LSM6DS3TR_C_EDGE_TRIGGER; - break; - - default: - *val = LSM6DS3TR_C_DEN_MODE_ND; - break; - } - - return ret; -} - -/** - * @brief Extend DEN functionality to accelerometer sensor.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_xl_g in reg CTRL9_XL - * and den_xl_en in CTRL4_C. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_enable_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_xl_en_t val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ctrl9_xl.den_xl_g = (uint8_t)val & 0x01U; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ctrl4_c.den_xl_en = (uint8_t)val & 0x02U; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - } - } - } - - return ret; -} - -/** - * @brief Extend DEN functionality to accelerometer sensor. [get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of den_xl_g in reg CTRL9_XL - * and den_xl_en in CTRL4_C. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_enable_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_xl_en_t* val) { - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C, (uint8_t*)&ctrl4_c, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - switch((ctrl4_c.den_xl_en << 1) + ctrl9_xl.den_xl_g) { - case LSM6DS3TR_C_STAMP_IN_GY_DATA: - *val = LSM6DS3TR_C_STAMP_IN_GY_DATA; - break; - - case LSM6DS3TR_C_STAMP_IN_XL_DATA: - *val = LSM6DS3TR_C_STAMP_IN_XL_DATA; - break; - - case LSM6DS3TR_C_STAMP_IN_GY_XL_DATA: - *val = LSM6DS3TR_C_STAMP_IN_GY_XL_DATA; - break; - - default: - *val = LSM6DS3TR_C_DEN_STAMP_ND; - break; - } - } - - return ret; -} - -/** - * @brief DEN value stored in LSB of Z-axis.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_z in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_z_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ctrl9_xl.den_z = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - } - - return ret; -} - -/** - * @brief DEN value stored in LSB of Z-axis.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_z in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_z_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - *val = ctrl9_xl.den_z; - - return ret; -} - -/** - * @brief DEN value stored in LSB of Y-axis.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_y in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_y_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ctrl9_xl.den_y = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - } - - return ret; -} - -/** - * @brief DEN value stored in LSB of Y-axis.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_y in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_y_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - *val = ctrl9_xl.den_y; - - return ret; -} - -/** - * @brief DEN value stored in LSB of X-axis.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_x in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_x_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ctrl9_xl.den_x = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - } - - return ret; -} - -/** - * @brief DEN value stored in LSB of X-axis.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of den_x in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_den_mark_axis_x_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - *val = ctrl9_xl.den_x; - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Pedometer - * @brief This section groups all the functions that manage pedometer. - * @{ - * - */ - -/** - * @brief Reset pedometer step counter.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pedo_rst_step in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_step_reset_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.pedo_rst_step = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - - return ret; -} - -/** - * @brief Reset pedometer step counter.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pedo_rst_step in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_step_reset_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.pedo_rst_step; - - return ret; -} - -/** - * @brief Enable pedometer algorithm.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pedo_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_sens_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.pedo_en = val; - - if(val != 0x00U) { - ctrl10_c.func_en = val; - } - - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - - return ret; -} - -/** - * @brief pedo_sens: Enable pedometer algorithm.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pedo_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_sens_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.pedo_en; - - return ret; -} - -/** - * @brief Minimum threshold to detect a peak. Default is 10h.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ths_min in reg - * CONFIG_PEDO_THS_MIN - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_threshold_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - config_pedo_ths_min.ths_min = val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Minimum threshold to detect a peak. Default is 10h.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of ths_min in reg CONFIG_PEDO_THS_MIN - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_threshold_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - *val = config_pedo_ths_min.ths_min; - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief pedo_full_scale: Pedometer data range.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pedo_fs in - * reg CONFIG_PEDO_THS_MIN - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pedo_fs_t val) { - lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - config_pedo_ths_min.pedo_fs = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Pedometer data range.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of pedo_fs in - * reg CONFIG_PEDO_THS_MIN - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pedo_fs_t* val) { - lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN, (uint8_t*)&config_pedo_ths_min, 1); - - if(ret == 0) { - switch(config_pedo_ths_min.pedo_fs) { - case LSM6DS3TR_C_PEDO_AT_2g: - *val = LSM6DS3TR_C_PEDO_AT_2g; - break; - - case LSM6DS3TR_C_PEDO_AT_4g: - *val = LSM6DS3TR_C_PEDO_AT_4g; - break; - - default: - *val = LSM6DS3TR_C_PEDO_FS_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Pedometer debounce configuration register (r/w).[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of deb_step in reg PEDO_DEB_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_debounce_steps_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - pedo_deb_reg.deb_step = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Pedometer debounce configuration register (r/w).[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of deb_step in reg PEDO_DEB_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_debounce_steps_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - *val = pedo_deb_reg.deb_step; - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Debounce time. If the time between two consecutive steps is - * greater than DEB_TIME*80ms, the debouncer is reactivated. - * Default value: 01101[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of deb_time in reg PEDO_DEB_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_timeout_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - pedo_deb_reg.deb_time = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Debounce time. If the time between two consecutive steps is - * greater than DEB_TIME*80ms, the debouncer is reactivated. - * Default value: 01101[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of deb_time in reg PEDO_DEB_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_timeout_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG, (uint8_t*)&pedo_deb_reg, 1); - - if(ret == 0) { - *val = pedo_deb_reg.deb_time; - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Time period register for step detection on delta time (r/w).[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_steps_period_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_STEP_COUNT_DELTA, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Time period register for step detection on delta time (r/w).[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_pedo_steps_period_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STEP_COUNT_DELTA, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_significant_motion - * @brief This section groups all the functions that manage the - * significant motion detection. - * @{ - * - */ - -/** - * @brief Enable significant motion detection function.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sign_motion_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_motion_sens_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.sign_motion_en = val; - - if(val != 0x00U) { - ctrl10_c.func_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - } - - return ret; -} - -/** - * @brief Enable significant motion detection function.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of sign_motion_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_motion_sens_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.sign_motion_en; - - return ret; -} - -/** - * @brief Significant motion threshold.[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that store significant motion threshold. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_motion_threshold_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SM_THS, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Significant motion threshold.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that store significant motion threshold. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_motion_threshold_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SM_THS, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_tilt_detection - * @brief This section groups all the functions that manage the tilt - * event detection. - * @{ - * - */ - -/** - * @brief Enable tilt calculation.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tilt_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_sens_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.tilt_en = val; - - if(val != 0x00U) { - ctrl10_c.func_en = val; - } - - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - - return ret; -} - -/** - * @brief Enable tilt calculation.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tilt_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_sens_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.tilt_en; - - return ret; -} - -/** - * @brief Enable tilt calculation.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tilt_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wrist_tilt_sens_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.wrist_tilt_en = val; - - if(val != 0x00U) { - ctrl10_c.func_en = val; - } - - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - - return ret; -} - -/** - * @brief Enable tilt calculation.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tilt_en in reg CTRL10_C - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_wrist_tilt_sens_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - *val = ctrl10_c.wrist_tilt_en; - - return ret; -} - -/** - * @brief Absolute Wrist Tilt latency register (r/w). - * Absolute wrist tilt latency parameters. - * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_latency_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_LAT, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Absolute Wrist Tilt latency register (r/w). - * Absolute wrist tilt latency parameters. - * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_latency_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_LAT, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Absolute Wrist Tilt threshold register(r/w). - * Absolute wrist tilt threshold parameters. - * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_threshold_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_THS, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Absolute Wrist Tilt threshold register(r/w). - * Absolute wrist tilt threshold parameters. - * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_threshold_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_THS, buff, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Absolute Wrist Tilt mask register (r/w).[set] - * - * @param ctx Read / write interface definitions - * @param val Registers A_WRIST_TILT_MASK - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_src_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_a_wrist_tilt_mask_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK, (uint8_t*)val, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Absolute Wrist Tilt mask register (r/w).[get] - * - * @param ctx Read / write interface definitions - * @param val Registers A_WRIST_TILT_MASK - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_tilt_src_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_a_wrist_tilt_mask_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK, (uint8_t*)val, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_ magnetometer_sensor - * @brief This section groups all the functions that manage additional - * magnetometer sensor. - * @{ - * - */ - -/** - * @brief Enable soft-iron correction algorithm for magnetometer.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of soft_en in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_soft_iron_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - - if(ret == 0) { - ctrl9_xl.soft_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - } - - return ret; -} - -/** - * @brief Enable soft-iron correction algorithm for magnetometer.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of soft_en in reg CTRL9_XL - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_soft_iron_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL, (uint8_t*)&ctrl9_xl, 1); - *val = ctrl9_xl.soft_en; - - return ret; -} - -/** - * @brief Enable hard-iron correction algorithm for magnetometer.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of iron_en in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_hard_iron_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_master_config_t master_config; - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.iron_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - if(val != 0x00U) { - ctrl10_c.func_en = val; - } - - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - } - } - - return ret; -} - -/** - * @brief Enable hard-iron correction algorithm for magnetometer.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of iron_en in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_hard_iron_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - *val = master_config.iron_en; - - return ret; -} - -/** - * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format. - * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_soft_iron_mat_set(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MAG_SI_XX, buff, 9); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format. - * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_soft_iron_mat_get(stmdev_ctx_t* ctx, uint8_t* buff) { - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MAG_SI_XX, buff, 9); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Offset for hard-iron compensation register (r/w). The value is - * expressed as a 16-bit word in two’s complement.[set] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that contains data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_offset_set(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[6]; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - buff[1] = (uint8_t)((uint16_t)val[0] / 256U); - buff[0] = (uint8_t)((uint16_t)val[0] - (buff[1] * 256U)); - buff[3] = (uint8_t)((uint16_t)val[1] / 256U); - buff[2] = (uint8_t)((uint16_t)val[1] - (buff[3] * 256U)); - buff[5] = (uint8_t)((uint16_t)val[2] / 256U); - buff[4] = (uint8_t)((uint16_t)val[2] - (buff[5] * 256U)); - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MAG_OFFX_L, buff, 6); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Offset for hard-iron compensation register(r/w). - * The value is expressed as a 16-bit word in two’s complement.[get] - * - * @param ctx Read / write interface definitions - * @param buff Buffer that stores data read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_mag_offset_get(stmdev_ctx_t* ctx, int16_t* val) { - uint8_t buff[6]; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MAG_OFFX_L, buff, 6); - - if(ret == 0) { - val[0] = (int16_t)buff[1]; - val[0] = (val[0] * 256) + (int16_t)buff[0]; - val[1] = (int16_t)buff[3]; - val[1] = (val[1] * 256) + (int16_t)buff[2]; - val[2] = (int16_t)buff[5]; - val[2] = (val[2] * 256) + (int16_t)buff[4]; - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @defgroup LSM6DS3TR_C_Sensor_hub - * @brief This section groups all the functions that manage the sensor - * hub functionality. - * @{ - * - */ - -/** - * @brief Enable function.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values func_en - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_func_en_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - - if(ret == 0) { - ctrl10_c.func_en = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C, (uint8_t*)&ctrl10_c, 1); - } - - return ret; -} - -/** - * @brief Sensor synchronization time frame with the step of 500 ms and - * full range of 5s. Unsigned 8-bit.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_sync_sens_frame_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_sensor_sync_time_frame_t sensor_sync_time_frame; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME, (uint8_t*)&sensor_sync_time_frame, 1); - - if(ret == 0) { - sensor_sync_time_frame.tph = val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME, (uint8_t*)&sensor_sync_time_frame, 1); - } - - return ret; -} - -/** - * @brief Sensor synchronization time frame with the step of 500 ms and - * full range of 5s. Unsigned 8-bit.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_sync_sens_frame_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_sensor_sync_time_frame_t sensor_sync_time_frame; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME, (uint8_t*)&sensor_sync_time_frame, 1); - *val = sensor_sync_time_frame.tph; - - return ret; -} - -/** - * @brief Resolution ratio of error code for sensor synchronization.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of rr in reg SENSOR_SYNC_RES_RATIO - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_sync_sens_ratio_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rr_t val) { - lsm6ds3tr_c_sensor_sync_res_ratio_t sensor_sync_res_ratio; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO, (uint8_t*)&sensor_sync_res_ratio, 1); - - if(ret == 0) { - sensor_sync_res_ratio.rr = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO, (uint8_t*)&sensor_sync_res_ratio, 1); - } - - return ret; -} - -/** - * @brief Resolution ratio of error code for sensor synchronization.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of rr in reg SENSOR_SYNC_RES_RATIO - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_sync_sens_ratio_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rr_t* val) { - lsm6ds3tr_c_sensor_sync_res_ratio_t sensor_sync_res_ratio; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO, (uint8_t*)&sensor_sync_res_ratio, 1); - - switch(sensor_sync_res_ratio.rr) { - case LSM6DS3TR_C_RES_RATIO_2_11: - *val = LSM6DS3TR_C_RES_RATIO_2_11; - break; - - case LSM6DS3TR_C_RES_RATIO_2_12: - *val = LSM6DS3TR_C_RES_RATIO_2_12; - break; - - case LSM6DS3TR_C_RES_RATIO_2_13: - *val = LSM6DS3TR_C_RES_RATIO_2_13; - break; - - case LSM6DS3TR_C_RES_RATIO_2_14: - *val = LSM6DS3TR_C_RES_RATIO_2_14; - break; - - default: - *val = LSM6DS3TR_C_RES_RATIO_ND; - break; - } - - return ret; -} - -/** - * @brief Sensor hub I2C master enable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of master_on in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_master_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.master_on = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - return ret; -} - -/** - * @brief Sensor hub I2C master enable.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of master_on in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_master_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - *val = master_config.master_on; - - return ret; -} - -/** - * @brief I2C interface pass-through.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pass_through_mode in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_pass_through_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.pass_through_mode = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - return ret; -} - -/** - * @brief I2C interface pass-through.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pass_through_mode in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_pass_through_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - *val = master_config.pass_through_mode; - - return ret; -} - -/** - * @brief Master I2C pull-up enable/disable.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of pull_up_en in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_pin_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pull_up_en_t val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.pull_up_en = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - return ret; -} - -/** - * @brief Master I2C pull-up enable/disable.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of pull_up_en in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_pin_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pull_up_en_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - switch(master_config.pull_up_en) { - case LSM6DS3TR_C_EXT_PULL_UP: - *val = LSM6DS3TR_C_EXT_PULL_UP; - break; - - case LSM6DS3TR_C_INTERNAL_PULL_UP: - *val = LSM6DS3TR_C_INTERNAL_PULL_UP; - break; - - default: - *val = LSM6DS3TR_C_SH_PIN_MODE; - break; - } - - return ret; -} - -/** - * @brief Sensor hub trigger signal selection.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of start_config in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_syncro_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_start_config_t val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.start_config = (uint8_t)val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - return ret; -} - -/** - * @brief Sensor hub trigger signal selection.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of start_config in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_syncro_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_start_config_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - switch(master_config.start_config) { - case LSM6DS3TR_C_XL_GY_DRDY: - *val = LSM6DS3TR_C_XL_GY_DRDY; - break; - - case LSM6DS3TR_C_EXT_ON_INT2_PIN: - *val = LSM6DS3TR_C_EXT_ON_INT2_PIN; - break; - - default: - *val = LSM6DS3TR_C_SH_SYNCRO_ND; - break; - } - - return ret; -} - -/** - * @brief Manage the Master DRDY signal on INT1 pad.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_drdy_on_int1_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - - if(ret == 0) { - master_config.drdy_on_int1 = val; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - } - - return ret; -} - -/** - * @brief Manage the Master DRDY signal on INT1 pad.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_drdy_on_int1_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_master_config_t master_config; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG, (uint8_t*)&master_config, 1); - *val = master_config.drdy_on_int1; - - return ret; -} - -/** - * @brief Sensor hub output registers.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure of registers from SENSORHUB1_REG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_read_data_raw_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_emb_sh_read_t* val) { - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSORHUB1_REG, (uint8_t*)&(val->sh_byte_1), 12); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENSORHUB13_REG, (uint8_t*)&(val->sh_byte_13), 6); - } - - return ret; -} - -/** - * @brief Master command code used for stamping for sensor sync.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of master_cmd_code in - * reg MASTER_CMD_CODE - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_cmd_sens_sync_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_master_cmd_code_t master_cmd_code; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE, (uint8_t*)&master_cmd_code, 1); - - if(ret == 0) { - master_cmd_code.master_cmd_code = val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE, (uint8_t*)&master_cmd_code, 1); - } - - return ret; -} - -/** - * @brief Master command code used for stamping for sensor sync.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of master_cmd_code in - * reg MASTER_CMD_CODE - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_cmd_sens_sync_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_master_cmd_code_t master_cmd_code; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE, (uint8_t*)&master_cmd_code, 1); - *val = master_cmd_code.master_cmd_code; - - return ret; -} - -/** - * @brief Error code used for sensor synchronization.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of error_code in - * reg SENS_SYNC_SPI_ERROR_CODE. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_spi_sync_error_set(stmdev_ctx_t* ctx, uint8_t val) { - lsm6ds3tr_c_sens_sync_spi_error_code_t sens_sync_spi_error_code; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE, (uint8_t*)&sens_sync_spi_error_code, 1); - - if(ret == 0) { - sens_sync_spi_error_code.error_code = val; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE, (uint8_t*)&sens_sync_spi_error_code, 1); - } - - return ret; -} - -/** - * @brief Error code used for sensor synchronization.[get] - * - * @param ctx Read / write interface definitions - * @param val Change the values of error_code in - * reg SENS_SYNC_SPI_ERROR_CODE. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_spi_sync_error_get(stmdev_ctx_t* ctx, uint8_t* val) { - lsm6ds3tr_c_sens_sync_spi_error_code_t sens_sync_spi_error_code; - int32_t ret; - - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE, (uint8_t*)&sens_sync_spi_error_code, 1); - *val = sens_sync_spi_error_code.error_code; - - return ret; -} - -/** - * @brief Number of external sensors to be read by the sensor hub.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of aux_sens_on in reg SLAVE0_CONFIG. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_num_of_dev_connected_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_aux_sens_on_t val) { - lsm6ds3tr_c_slave0_config_t slave0_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - slave0_config.aux_sens_on = (uint8_t)val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Number of external sensors to be read by the sensor hub.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of aux_sens_on in reg SLAVE0_CONFIG. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t - lsm6ds3tr_c_sh_num_of_dev_connected_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_aux_sens_on_t* val) { - lsm6ds3tr_c_slave0_config_t slave0_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - switch(slave0_config.aux_sens_on) { - case LSM6DS3TR_C_SLV_0: - *val = LSM6DS3TR_C_SLV_0; - break; - - case LSM6DS3TR_C_SLV_0_1: - *val = LSM6DS3TR_C_SLV_0_1; - break; - - case LSM6DS3TR_C_SLV_0_1_2: - *val = LSM6DS3TR_C_SLV_0_1_2; - break; - - case LSM6DS3TR_C_SLV_0_1_2_3: - *val = LSM6DS3TR_C_SLV_0_1_2_3; - break; - - default: - *val = LSM6DS3TR_C_SLV_EN_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Configure slave 0 for perform a write.[set] - * - * @param ctx Read / write interface definitions - * @param val Structure that contain: - * - uint8_t slv_add; 8 bit i2c device address - * - uint8_t slv_subadd; 8 bit register device address - * - uint8_t slv_data; 8 bit data to write - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_cfg_write(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_write_t* val) { - lsm6ds3tr_c_slv0_add_t slv0_add; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - slv0_add.slave0_add = val->slv0_add; - slv0_add.rw_0 = 0; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_ADD, (uint8_t*)&slv0_add, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_SUBADD, &(val->slv0_subadd), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_DATAWRITE_SRC_MODE_SUB_SLV0, &(val->slv0_data), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - } - - return ret; -} - -/** - * @brief Configure slave 0 for perform a read.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure that contain: - * - uint8_t slv_add; 8 bit i2c device address - * - uint8_t slv_subadd; 8 bit register device address - * - uint8_t slv_len; num of bit to read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slv0_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val) { - lsm6ds3tr_c_slave0_config_t slave0_config; - lsm6ds3tr_c_slv0_add_t slv0_add; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - slv0_add.slave0_add = val->slv_add; - slv0_add.rw_0 = 1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_ADD, (uint8_t*)&slv0_add, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_SUBADD, &(val->slv_subadd), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - slave0_config.slave0_numop = val->slv_len; - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - } - } - - return ret; -} - -/** - * @brief Configure slave 1 for perform a read.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure that contain: - * - uint8_t slv_add; 8 bit i2c device address - * - uint8_t slv_subadd; 8 bit register device address - * - uint8_t slv_len; num of bit to read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slv1_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val) { - lsm6ds3tr_c_slave1_config_t slave1_config; - lsm6ds3tr_c_slv1_add_t slv1_add; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - slv1_add.slave1_add = val->slv_add; - slv1_add.r_1 = 1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV1_ADD, (uint8_t*)&slv1_add, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV1_SUBADD, &(val->slv_subadd), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - slave1_config.slave1_numop = val->slv_len; - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - } - } - - return ret; -} - -/** - * @brief Configure slave 2 for perform a read.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure that contain: - * - uint8_t slv_add; 8 bit i2c device address - * - uint8_t slv_subadd; 8 bit register device address - * - uint8_t slv_len; num of bit to read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slv2_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val) { - lsm6ds3tr_c_slv2_add_t slv2_add; - lsm6ds3tr_c_slave2_config_t slave2_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - slv2_add.slave2_add = val->slv_add; - slv2_add.r_2 = 1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV2_ADD, (uint8_t*)&slv2_add, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV2_SUBADD, &(val->slv_subadd), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SLAVE2_CONFIG, (uint8_t*)&slave2_config, 1); - - if(ret == 0) { - slave2_config.slave2_numop = val->slv_len; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SLAVE2_CONFIG, (uint8_t*)&slave2_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - } - } - - return ret; -} - -/** - * @brief Configure slave 3 for perform a read.[get] - * - * @param ctx Read / write interface definitions - * @param val Structure that contain: - * - uint8_t slv_add; 8 bit i2c device address - * - uint8_t slv_subadd; 8 bit register device address - * - uint8_t slv_len; num of bit to read - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slv3_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val) { - lsm6ds3tr_c_slave3_config_t slave3_config; - lsm6ds3tr_c_slv3_add_t slv3_add; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - slv3_add.slave3_add = val->slv_add; - slv3_add.r_3 = 1; - ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV3_ADD, (uint8_t*)&slv3_add, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SLV3_SUBADD, (uint8_t*)&(val->slv_subadd), 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg( - ctx, LSM6DS3TR_C_SLAVE3_CONFIG, (uint8_t*)&slave3_config, 1); - - if(ret == 0) { - slave3_config.slave3_numop = val->slv_len; - ret = lsm6ds3tr_c_write_reg( - ctx, LSM6DS3TR_C_SLAVE3_CONFIG, (uint8_t*)&slave3_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 0 starting from the - * sensor hub trigger.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of slave0_rate in reg SLAVE0_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_0_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave0_rate_t val) { - lsm6ds3tr_c_slave0_config_t slave0_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - slave0_config.slave0_rate = (uint8_t)val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 0 starting from the - * sensor hub trigger.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of slave0_rate in reg SLAVE0_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_0_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave0_rate_t* val) { - lsm6ds3tr_c_slave0_config_t slave0_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG, (uint8_t*)&slave0_config, 1); - - if(ret == 0) { - switch(slave0_config.slave0_rate) { - case LSM6DS3TR_C_SL0_NO_DEC: - *val = LSM6DS3TR_C_SL0_NO_DEC; - break; - - case LSM6DS3TR_C_SL0_DEC_2: - *val = LSM6DS3TR_C_SL0_DEC_2; - break; - - case LSM6DS3TR_C_SL0_DEC_4: - *val = LSM6DS3TR_C_SL0_DEC_4; - break; - - case LSM6DS3TR_C_SL0_DEC_8: - *val = LSM6DS3TR_C_SL0_DEC_8; - break; - - default: - *val = LSM6DS3TR_C_SL0_DEC_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Slave 0 write operation is performed only at the first sensor - * hub cycle. - * This is effective if the Aux_sens_on[1:0] field in - * SLAVE0_CONFIG(04h) is set to a value other than 00.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of write_once in reg SLAVE1_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_write_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_write_once_t val) { - lsm6ds3tr_c_slave1_config_t slave1_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - slave1_config.write_once = (uint8_t)val; - - if(ret == 0) { - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Slave 0 write operation is performed only at the first sensor - * hub cycle. - * This is effective if the Aux_sens_on[1:0] field in - * SLAVE0_CONFIG(04h) is set to a value other than 00.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of write_once in reg SLAVE1_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_write_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_write_once_t* val) { - lsm6ds3tr_c_slave1_config_t slave1_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - switch(slave1_config.write_once) { - case LSM6DS3TR_C_EACH_SH_CYCLE: - *val = LSM6DS3TR_C_EACH_SH_CYCLE; - break; - - case LSM6DS3TR_C_ONLY_FIRST_CYCLE: - *val = LSM6DS3TR_C_ONLY_FIRST_CYCLE; - break; - - default: - *val = LSM6DS3TR_C_SH_WR_MODE_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 1 starting from the - * sensor hub trigger.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of slave1_rate in reg SLAVE1_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_1_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave1_rate_t val) { - lsm6ds3tr_c_slave1_config_t slave1_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - slave1_config.slave1_rate = (uint8_t)val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 1 starting from the - * sensor hub trigger.[get] - * - * @param ctx Read / write interface definitions reg SLAVE1_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_1_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave1_rate_t* val) { - lsm6ds3tr_c_slave1_config_t slave1_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG, (uint8_t*)&slave1_config, 1); - - if(ret == 0) { - switch(slave1_config.slave1_rate) { - case LSM6DS3TR_C_SL1_NO_DEC: - *val = LSM6DS3TR_C_SL1_NO_DEC; - break; - - case LSM6DS3TR_C_SL1_DEC_2: - *val = LSM6DS3TR_C_SL1_DEC_2; - break; - - case LSM6DS3TR_C_SL1_DEC_4: - *val = LSM6DS3TR_C_SL1_DEC_4; - break; - - case LSM6DS3TR_C_SL1_DEC_8: - *val = LSM6DS3TR_C_SL1_DEC_8; - break; - - default: - *val = LSM6DS3TR_C_SL1_DEC_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 2 starting from the - * sensor hub trigger.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of slave2_rate in reg SLAVE2_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_2_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave2_rate_t val) { - lsm6ds3tr_c_slave2_config_t slave2_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG, (uint8_t*)&slave2_config, 1); - - if(ret == 0) { - slave2_config.slave2_rate = (uint8_t)val; - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG, (uint8_t*)&slave2_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 2 starting from the - * sensor hub trigger.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of slave2_rate in reg SLAVE2_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_2_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave2_rate_t* val) { - lsm6ds3tr_c_slave2_config_t slave2_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG, (uint8_t*)&slave2_config, 1); - - if(ret == 0) { - switch(slave2_config.slave2_rate) { - case LSM6DS3TR_C_SL2_NO_DEC: - *val = LSM6DS3TR_C_SL2_NO_DEC; - break; - - case LSM6DS3TR_C_SL2_DEC_2: - *val = LSM6DS3TR_C_SL2_DEC_2; - break; - - case LSM6DS3TR_C_SL2_DEC_4: - *val = LSM6DS3TR_C_SL2_DEC_4; - break; - - case LSM6DS3TR_C_SL2_DEC_8: - *val = LSM6DS3TR_C_SL2_DEC_8; - break; - - default: - *val = LSM6DS3TR_C_SL2_DEC_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 3 starting from the - * sensor hub trigger.[set] - * - * @param ctx Read / write interface definitions - * @param val Change the values of slave3_rate in reg SLAVE3_CONFIG - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_3_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave3_rate_t val) { - lsm6ds3tr_c_slave3_config_t slave3_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG, (uint8_t*)&slave3_config, 1); - slave3_config.slave3_rate = (uint8_t)val; - - if(ret == 0) { - ret = - lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG, (uint8_t*)&slave3_config, 1); - - if(ret == 0) { - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - } - - return ret; -} - -/** - * @brief Decimation of read operation on Slave 3 starting from the - * sensor hub trigger.[get] - * - * @param ctx Read / write interface definitions - * @param val Get the values of slave3_rate in reg SLAVE3_CONFIG. - * @retval Interface status (MANDATORY: return 0 -> no Error). - * - */ -int32_t lsm6ds3tr_c_sh_slave_3_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave3_rate_t* val) { - lsm6ds3tr_c_slave3_config_t slave3_config; - int32_t ret; - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A); - - if(ret == 0) { - ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG, (uint8_t*)&slave3_config, 1); - - if(ret == 0) { - switch(slave3_config.slave3_rate) { - case LSM6DS3TR_C_SL3_NO_DEC: - *val = LSM6DS3TR_C_SL3_NO_DEC; - break; - - case LSM6DS3TR_C_SL3_DEC_2: - *val = LSM6DS3TR_C_SL3_DEC_2; - break; - - case LSM6DS3TR_C_SL3_DEC_4: - *val = LSM6DS3TR_C_SL3_DEC_4; - break; - - case LSM6DS3TR_C_SL3_DEC_8: - *val = LSM6DS3TR_C_SL3_DEC_8; - break; - - default: - *val = LSM6DS3TR_C_SL3_DEC_ND; - break; - } - - ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK); - } - } - - return ret; -} - -/** - * @} - * - */ - -/** - * @} - * - */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.h b/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.h deleted file mode 100644 index 8cb592c0d..000000000 --- a/applications/plugins/airmouse/tracking/imu/lsm6ds3tr_c_reg.h +++ /dev/null @@ -1,2448 +0,0 @@ -/** - ****************************************************************************** - * @file lsm6ds3tr_c_reg.h - * @author Sensors Software Solution Team - * @brief This file contains all the functions prototypes for the - * lsm6ds3tr_c_reg.c driver. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef LSM6DS3TR_C_DRIVER_H -#define LSM6DS3TR_C_DRIVER_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include -#include -#include - -/** @addtogroup LSM6DS3TR_C - * @{ - * - */ - -/** @defgroup Endianness definitions - * @{ - * - */ - -#ifndef DRV_BYTE_ORDER -#ifndef __BYTE_ORDER__ - -#define DRV_LITTLE_ENDIAN 1234 -#define DRV_BIG_ENDIAN 4321 - -/** if _BYTE_ORDER is not defined, choose the endianness of your architecture - * by uncommenting the define which fits your platform endianness - */ -//#define DRV_BYTE_ORDER DRV_BIG_ENDIAN -#define DRV_BYTE_ORDER DRV_LITTLE_ENDIAN - -#else /* defined __BYTE_ORDER__ */ - -#define DRV_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ -#define DRV_BIG_ENDIAN __ORDER_BIG_ENDIAN__ -#define DRV_BYTE_ORDER __BYTE_ORDER__ - -#endif /* __BYTE_ORDER__*/ -#endif /* DRV_BYTE_ORDER */ - -/** - * @} - * - */ - -/** @defgroup STMicroelectronics sensors common types - * @{ - * - */ - -#ifndef MEMS_SHARED_TYPES -#define MEMS_SHARED_TYPES - -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} bitwise_t; - -#define PROPERTY_DISABLE (0U) -#define PROPERTY_ENABLE (1U) - -/** @addtogroup Interfaces_Functions - * @brief This section provide a set of functions used to read and - * write a generic register of the device. - * MANDATORY: return 0 -> no Error. - * @{ - * - */ - -typedef int32_t (*stmdev_write_ptr)(void*, uint8_t, const uint8_t*, uint16_t); -typedef int32_t (*stmdev_read_ptr)(void*, uint8_t, uint8_t*, uint16_t); -typedef void (*stmdev_mdelay_ptr)(uint32_t millisec); - -typedef struct { - /** Component mandatory fields **/ - stmdev_write_ptr write_reg; - stmdev_read_ptr read_reg; - /** Component optional fields **/ - stmdev_mdelay_ptr mdelay; - /** Customizable optional pointer **/ - void* handle; -} stmdev_ctx_t; - -/** - * @} - * - */ - -#endif /* MEMS_SHARED_TYPES */ - -#ifndef MEMS_UCF_SHARED_TYPES -#define MEMS_UCF_SHARED_TYPES - -/** @defgroup Generic address-data structure definition - * @brief This structure is useful to load a predefined configuration - * of a sensor. - * You can create a sensor configuration by your own or using - * Unico / Unicleo tools available on STMicroelectronics - * web site. - * - * @{ - * - */ - -typedef struct { - uint8_t address; - uint8_t data; -} ucf_line_t; - -/** - * @} - * - */ - -#endif /* MEMS_UCF_SHARED_TYPES */ - -/** - * @} - * - */ - -/** @defgroup LSM6DS3TR_C_Infos - * @{ - * - */ - -/** I2C Device Address 8 bit format if SA0=0 -> D5 if SA0=1 -> D7 **/ -#define LSM6DS3TR_C_I2C_ADD_L 0xD5U -#define LSM6DS3TR_C_I2C_ADD_H 0xD7U - -/** Device Identification (Who am I) **/ -#define LSM6DS3TR_C_ID 0x6AU - -/** - * @} - * - */ - -#define LSM6DS3TR_C_FUNC_CFG_ACCESS 0x01U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 5; - uint8_t func_cfg_en : 3; /* func_cfg_en + func_cfg_en_b */ -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t func_cfg_en : 3; /* func_cfg_en + func_cfg_en_b */ - uint8_t not_used_01 : 5; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_func_cfg_access_t; - -#define LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME 0x04U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t tph : 4; - uint8_t not_used_01 : 4; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 4; - uint8_t tph : 4; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensor_sync_time_frame_t; - -#define LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO 0x05U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t rr : 2; - uint8_t not_used_01 : 6; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 6; - uint8_t rr : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensor_sync_res_ratio_t; - -#define LSM6DS3TR_C_FIFO_CTRL1 0x06U -typedef struct { - uint8_t fth : 8; /* + FIFO_CTRL2(fth) */ -} lsm6ds3tr_c_fifo_ctrl1_t; - -#define LSM6DS3TR_C_FIFO_CTRL2 0x07U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t fth : 3; /* + FIFO_CTRL1(fth) */ - uint8_t fifo_temp_en : 1; - uint8_t not_used_01 : 2; - uint8_t timer_pedo_fifo_drdy : 1; - uint8_t timer_pedo_fifo_en : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t timer_pedo_fifo_en : 1; - uint8_t timer_pedo_fifo_drdy : 1; - uint8_t not_used_01 : 2; - uint8_t fifo_temp_en : 1; - uint8_t fth : 3; /* + FIFO_CTRL1(fth) */ -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_ctrl2_t; - -#define LSM6DS3TR_C_FIFO_CTRL3 0x08U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t dec_fifo_xl : 3; - uint8_t dec_fifo_gyro : 3; - uint8_t not_used_01 : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 2; - uint8_t dec_fifo_gyro : 3; - uint8_t dec_fifo_xl : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_ctrl3_t; - -#define LSM6DS3TR_C_FIFO_CTRL4 0x09U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t dec_ds3_fifo : 3; - uint8_t dec_ds4_fifo : 3; - uint8_t only_high_data : 1; - uint8_t stop_on_fth : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t stop_on_fth : 1; - uint8_t only_high_data : 1; - uint8_t dec_ds4_fifo : 3; - uint8_t dec_ds3_fifo : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_ctrl4_t; - -#define LSM6DS3TR_C_FIFO_CTRL5 0x0AU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t fifo_mode : 3; - uint8_t odr_fifo : 4; - uint8_t not_used_01 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 1; - uint8_t odr_fifo : 4; - uint8_t fifo_mode : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_ctrl5_t; - -#define LSM6DS3TR_C_DRDY_PULSE_CFG_G 0x0BU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t int2_wrist_tilt : 1; - uint8_t not_used_01 : 6; - uint8_t drdy_pulsed : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t drdy_pulsed : 1; - uint8_t not_used_01 : 6; - uint8_t int2_wrist_tilt : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_drdy_pulse_cfg_g_t; - -#define LSM6DS3TR_C_INT1_CTRL 0x0DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t int1_drdy_xl : 1; - uint8_t int1_drdy_g : 1; - uint8_t int1_boot : 1; - uint8_t int1_fth : 1; - uint8_t int1_fifo_ovr : 1; - uint8_t int1_full_flag : 1; - uint8_t int1_sign_mot : 1; - uint8_t int1_step_detector : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t int1_step_detector : 1; - uint8_t int1_sign_mot : 1; - uint8_t int1_full_flag : 1; - uint8_t int1_fifo_ovr : 1; - uint8_t int1_fth : 1; - uint8_t int1_boot : 1; - uint8_t int1_drdy_g : 1; - uint8_t int1_drdy_xl : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_int1_ctrl_t; - -#define LSM6DS3TR_C_INT2_CTRL 0x0EU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t int2_drdy_xl : 1; - uint8_t int2_drdy_g : 1; - uint8_t int2_drdy_temp : 1; - uint8_t int2_fth : 1; - uint8_t int2_fifo_ovr : 1; - uint8_t int2_full_flag : 1; - uint8_t int2_step_count_ov : 1; - uint8_t int2_step_delta : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t int2_step_delta : 1; - uint8_t int2_step_count_ov : 1; - uint8_t int2_full_flag : 1; - uint8_t int2_fifo_ovr : 1; - uint8_t int2_fth : 1; - uint8_t int2_drdy_temp : 1; - uint8_t int2_drdy_g : 1; - uint8_t int2_drdy_xl : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_int2_ctrl_t; - -#define LSM6DS3TR_C_WHO_AM_I 0x0FU -#define LSM6DS3TR_C_CTRL1_XL 0x10U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bw0_xl : 1; - uint8_t lpf1_bw_sel : 1; - uint8_t fs_xl : 2; - uint8_t odr_xl : 4; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t odr_xl : 4; - uint8_t fs_xl : 2; - uint8_t lpf1_bw_sel : 1; - uint8_t bw0_xl : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl1_xl_t; - -#define LSM6DS3TR_C_CTRL2_G 0x11U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 1; - uint8_t fs_g : 3; /* fs_g + fs_125 */ - uint8_t odr_g : 4; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t odr_g : 4; - uint8_t fs_g : 3; /* fs_g + fs_125 */ - uint8_t not_used_01 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl2_g_t; - -#define LSM6DS3TR_C_CTRL3_C 0x12U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t sw_reset : 1; - uint8_t ble : 1; - uint8_t if_inc : 1; - uint8_t sim : 1; - uint8_t pp_od : 1; - uint8_t h_lactive : 1; - uint8_t bdu : 1; - uint8_t boot : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t boot : 1; - uint8_t bdu : 1; - uint8_t h_lactive : 1; - uint8_t pp_od : 1; - uint8_t sim : 1; - uint8_t if_inc : 1; - uint8_t ble : 1; - uint8_t sw_reset : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl3_c_t; - -#define LSM6DS3TR_C_CTRL4_C 0x13U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 1; - uint8_t lpf1_sel_g : 1; - uint8_t i2c_disable : 1; - uint8_t drdy_mask : 1; - uint8_t den_drdy_int1 : 1; - uint8_t int2_on_int1 : 1; - uint8_t sleep : 1; - uint8_t den_xl_en : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t den_xl_en : 1; - uint8_t sleep : 1; - uint8_t int2_on_int1 : 1; - uint8_t den_drdy_int1 : 1; - uint8_t drdy_mask : 1; - uint8_t i2c_disable : 1; - uint8_t lpf1_sel_g : 1; - uint8_t not_used_01 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl4_c_t; - -#define LSM6DS3TR_C_CTRL5_C 0x14U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t st_xl : 2; - uint8_t st_g : 2; - uint8_t den_lh : 1; - uint8_t rounding : 3; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t rounding : 3; - uint8_t den_lh : 1; - uint8_t st_g : 2; - uint8_t st_xl : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl5_c_t; - -#define LSM6DS3TR_C_CTRL6_C 0x15U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t ftype : 2; - uint8_t not_used_01 : 1; - uint8_t usr_off_w : 1; - uint8_t xl_hm_mode : 1; - uint8_t den_mode : 3; /* trig_en + lvl_en + lvl2_en */ -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t den_mode : 3; /* trig_en + lvl_en + lvl2_en */ - uint8_t xl_hm_mode : 1; - uint8_t usr_off_w : 1; - uint8_t not_used_01 : 1; - uint8_t ftype : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl6_c_t; - -#define LSM6DS3TR_C_CTRL7_G 0x16U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 2; - uint8_t rounding_status : 1; - uint8_t not_used_02 : 1; - uint8_t hpm_g : 2; - uint8_t hp_en_g : 1; - uint8_t g_hm_mode : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t g_hm_mode : 1; - uint8_t hp_en_g : 1; - uint8_t hpm_g : 2; - uint8_t not_used_02 : 1; - uint8_t rounding_status : 1; - uint8_t not_used_01 : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl7_g_t; - -#define LSM6DS3TR_C_CTRL8_XL 0x17U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t low_pass_on_6d : 1; - uint8_t not_used_01 : 1; - uint8_t hp_slope_xl_en : 1; - uint8_t input_composite : 1; - uint8_t hp_ref_mode : 1; - uint8_t hpcf_xl : 2; - uint8_t lpf2_xl_en : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t lpf2_xl_en : 1; - uint8_t hpcf_xl : 2; - uint8_t hp_ref_mode : 1; - uint8_t input_composite : 1; - uint8_t hp_slope_xl_en : 1; - uint8_t not_used_01 : 1; - uint8_t low_pass_on_6d : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl8_xl_t; - -#define LSM6DS3TR_C_CTRL9_XL 0x18U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 2; - uint8_t soft_en : 1; - uint8_t not_used_02 : 1; - uint8_t den_xl_g : 1; - uint8_t den_z : 1; - uint8_t den_y : 1; - uint8_t den_x : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t den_x : 1; - uint8_t den_y : 1; - uint8_t den_z : 1; - uint8_t den_xl_g : 1; - uint8_t not_used_02 : 1; - uint8_t soft_en : 1; - uint8_t not_used_01 : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl9_xl_t; - -#define LSM6DS3TR_C_CTRL10_C 0x19U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t sign_motion_en : 1; - uint8_t pedo_rst_step : 1; - uint8_t func_en : 1; - uint8_t tilt_en : 1; - uint8_t pedo_en : 1; - uint8_t timer_en : 1; - uint8_t not_used_01 : 1; - uint8_t wrist_tilt_en : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t wrist_tilt_en : 1; - uint8_t not_used_01 : 1; - uint8_t timer_en : 1; - uint8_t pedo_en : 1; - uint8_t tilt_en : 1; - uint8_t func_en : 1; - uint8_t pedo_rst_step : 1; - uint8_t sign_motion_en : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_ctrl10_c_t; - -#define LSM6DS3TR_C_MASTER_CONFIG 0x1AU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t master_on : 1; - uint8_t iron_en : 1; - uint8_t pass_through_mode : 1; - uint8_t pull_up_en : 1; - uint8_t start_config : 1; - uint8_t not_used_01 : 1; - uint8_t data_valid_sel_fifo : 1; - uint8_t drdy_on_int1 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t drdy_on_int1 : 1; - uint8_t data_valid_sel_fifo : 1; - uint8_t not_used_01 : 1; - uint8_t start_config : 1; - uint8_t pull_up_en : 1; - uint8_t pass_through_mode : 1; - uint8_t iron_en : 1; - uint8_t master_on : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_master_config_t; - -#define LSM6DS3TR_C_WAKE_UP_SRC 0x1BU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t z_wu : 1; - uint8_t y_wu : 1; - uint8_t x_wu : 1; - uint8_t wu_ia : 1; - uint8_t sleep_state_ia : 1; - uint8_t ff_ia : 1; - uint8_t not_used_01 : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 2; - uint8_t ff_ia : 1; - uint8_t sleep_state_ia : 1; - uint8_t wu_ia : 1; - uint8_t x_wu : 1; - uint8_t y_wu : 1; - uint8_t z_wu : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_wake_up_src_t; - -#define LSM6DS3TR_C_TAP_SRC 0x1CU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t z_tap : 1; - uint8_t y_tap : 1; - uint8_t x_tap : 1; - uint8_t tap_sign : 1; - uint8_t double_tap : 1; - uint8_t single_tap : 1; - uint8_t tap_ia : 1; - uint8_t not_used_01 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 1; - uint8_t tap_ia : 1; - uint8_t single_tap : 1; - uint8_t double_tap : 1; - uint8_t tap_sign : 1; - uint8_t x_tap : 1; - uint8_t y_tap : 1; - uint8_t z_tap : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_tap_src_t; - -#define LSM6DS3TR_C_D6D_SRC 0x1DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t xl : 1; - uint8_t xh : 1; - uint8_t yl : 1; - uint8_t yh : 1; - uint8_t zl : 1; - uint8_t zh : 1; - uint8_t d6d_ia : 1; - uint8_t den_drdy : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t den_drdy : 1; - uint8_t d6d_ia : 1; - uint8_t zh : 1; - uint8_t zl : 1; - uint8_t yh : 1; - uint8_t yl : 1; - uint8_t xh : 1; - uint8_t xl : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_d6d_src_t; - -#define LSM6DS3TR_C_STATUS_REG 0x1EU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t xlda : 1; - uint8_t gda : 1; - uint8_t tda : 1; - uint8_t not_used_01 : 5; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 5; - uint8_t tda : 1; - uint8_t gda : 1; - uint8_t xlda : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_status_reg_t; - -#define LSM6DS3TR_C_OUT_TEMP_L 0x20U -#define LSM6DS3TR_C_OUT_TEMP_H 0x21U -#define LSM6DS3TR_C_OUTX_L_G 0x22U -#define LSM6DS3TR_C_OUTX_H_G 0x23U -#define LSM6DS3TR_C_OUTY_L_G 0x24U -#define LSM6DS3TR_C_OUTY_H_G 0x25U -#define LSM6DS3TR_C_OUTZ_L_G 0x26U -#define LSM6DS3TR_C_OUTZ_H_G 0x27U -#define LSM6DS3TR_C_OUTX_L_XL 0x28U -#define LSM6DS3TR_C_OUTX_H_XL 0x29U -#define LSM6DS3TR_C_OUTY_L_XL 0x2AU -#define LSM6DS3TR_C_OUTY_H_XL 0x2BU -#define LSM6DS3TR_C_OUTZ_L_XL 0x2CU -#define LSM6DS3TR_C_OUTZ_H_XL 0x2DU -#define LSM6DS3TR_C_SENSORHUB1_REG 0x2EU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub1_reg_t; - -#define LSM6DS3TR_C_SENSORHUB2_REG 0x2FU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub2_reg_t; - -#define LSM6DS3TR_C_SENSORHUB3_REG 0x30U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub3_reg_t; - -#define LSM6DS3TR_C_SENSORHUB4_REG 0x31U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub4_reg_t; - -#define LSM6DS3TR_C_SENSORHUB5_REG 0x32U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub5_reg_t; - -#define LSM6DS3TR_C_SENSORHUB6_REG 0x33U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub6_reg_t; - -#define LSM6DS3TR_C_SENSORHUB7_REG 0x34U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub7_reg_t; - -#define LSM6DS3TR_C_SENSORHUB8_REG 0x35U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub8_reg_t; - -#define LSM6DS3TR_C_SENSORHUB9_REG 0x36U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub9_reg_t; - -#define LSM6DS3TR_C_SENSORHUB10_REG 0x37U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub10_reg_t; - -#define LSM6DS3TR_C_SENSORHUB11_REG 0x38U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub11_reg_t; - -#define LSM6DS3TR_C_SENSORHUB12_REG 0x39U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub12_reg_t; - -#define LSM6DS3TR_C_FIFO_STATUS1 0x3AU -typedef struct { - uint8_t diff_fifo : 8; /* + FIFO_STATUS2(diff_fifo) */ -} lsm6ds3tr_c_fifo_status1_t; - -#define LSM6DS3TR_C_FIFO_STATUS2 0x3BU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t diff_fifo : 3; /* + FIFO_STATUS1(diff_fifo) */ - uint8_t not_used_01 : 1; - uint8_t fifo_empty : 1; - uint8_t fifo_full_smart : 1; - uint8_t over_run : 1; - uint8_t waterm : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t waterm : 1; - uint8_t over_run : 1; - uint8_t fifo_full_smart : 1; - uint8_t fifo_empty : 1; - uint8_t not_used_01 : 1; - uint8_t diff_fifo : 3; /* + FIFO_STATUS1(diff_fifo) */ -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_status2_t; - -#define LSM6DS3TR_C_FIFO_STATUS3 0x3CU -typedef struct { - uint8_t fifo_pattern : 8; /* + FIFO_STATUS4(fifo_pattern) */ -} lsm6ds3tr_c_fifo_status3_t; - -#define LSM6DS3TR_C_FIFO_STATUS4 0x3DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t fifo_pattern : 2; /* + FIFO_STATUS3(fifo_pattern) */ - uint8_t not_used_01 : 6; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_01 : 6; - uint8_t fifo_pattern : 2; /* + FIFO_STATUS3(fifo_pattern) */ -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_fifo_status4_t; - -#define LSM6DS3TR_C_FIFO_DATA_OUT_L 0x3EU -#define LSM6DS3TR_C_FIFO_DATA_OUT_H 0x3FU -#define LSM6DS3TR_C_TIMESTAMP0_REG 0x40U -#define LSM6DS3TR_C_TIMESTAMP1_REG 0x41U -#define LSM6DS3TR_C_TIMESTAMP2_REG 0x42U -#define LSM6DS3TR_C_STEP_TIMESTAMP_L 0x49U -#define LSM6DS3TR_C_STEP_TIMESTAMP_H 0x4AU -#define LSM6DS3TR_C_STEP_COUNTER_L 0x4BU -#define LSM6DS3TR_C_STEP_COUNTER_H 0x4CU - -#define LSM6DS3TR_C_SENSORHUB13_REG 0x4DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub13_reg_t; - -#define LSM6DS3TR_C_SENSORHUB14_REG 0x4EU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub14_reg_t; - -#define LSM6DS3TR_C_SENSORHUB15_REG 0x4FU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub15_reg_t; - -#define LSM6DS3TR_C_SENSORHUB16_REG 0x50U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub16_reg_t; - -#define LSM6DS3TR_C_SENSORHUB17_REG 0x51U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub17_reg_t; - -#define LSM6DS3TR_C_SENSORHUB18_REG 0x52U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t bit0 : 1; - uint8_t bit1 : 1; - uint8_t bit2 : 1; - uint8_t bit3 : 1; - uint8_t bit4 : 1; - uint8_t bit5 : 1; - uint8_t bit6 : 1; - uint8_t bit7 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t bit7 : 1; - uint8_t bit6 : 1; - uint8_t bit5 : 1; - uint8_t bit4 : 1; - uint8_t bit3 : 1; - uint8_t bit2 : 1; - uint8_t bit1 : 1; - uint8_t bit0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_sensorhub18_reg_t; - -#define LSM6DS3TR_C_FUNC_SRC1 0x53U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t sensorhub_end_op : 1; - uint8_t si_end_op : 1; - uint8_t hi_fail : 1; - uint8_t step_overflow : 1; - uint8_t step_detected : 1; - uint8_t tilt_ia : 1; - uint8_t sign_motion_ia : 1; - uint8_t step_count_delta_ia : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t step_count_delta_ia : 1; - uint8_t sign_motion_ia : 1; - uint8_t tilt_ia : 1; - uint8_t step_detected : 1; - uint8_t step_overflow : 1; - uint8_t hi_fail : 1; - uint8_t si_end_op : 1; - uint8_t sensorhub_end_op : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_func_src1_t; - -#define LSM6DS3TR_C_FUNC_SRC2 0x54U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t wrist_tilt_ia : 1; - uint8_t not_used_01 : 2; - uint8_t slave0_nack : 1; - uint8_t slave1_nack : 1; - uint8_t slave2_nack : 1; - uint8_t slave3_nack : 1; - uint8_t not_used_02 : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t not_used_02 : 1; - uint8_t slave3_nack : 1; - uint8_t slave2_nack : 1; - uint8_t slave1_nack : 1; - uint8_t slave0_nack : 1; - uint8_t not_used_01 : 2; - uint8_t wrist_tilt_ia : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_func_src2_t; - -#define LSM6DS3TR_C_WRIST_TILT_IA 0x55U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 2; - uint8_t wrist_tilt_ia_zneg : 1; - uint8_t wrist_tilt_ia_zpos : 1; - uint8_t wrist_tilt_ia_yneg : 1; - uint8_t wrist_tilt_ia_ypos : 1; - uint8_t wrist_tilt_ia_xneg : 1; - uint8_t wrist_tilt_ia_xpos : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t wrist_tilt_ia_xpos : 1; - uint8_t wrist_tilt_ia_xneg : 1; - uint8_t wrist_tilt_ia_ypos : 1; - uint8_t wrist_tilt_ia_yneg : 1; - uint8_t wrist_tilt_ia_zpos : 1; - uint8_t wrist_tilt_ia_zneg : 1; - uint8_t not_used_01 : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_wrist_tilt_ia_t; - -#define LSM6DS3TR_C_TAP_CFG 0x58U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t lir : 1; - uint8_t tap_z_en : 1; - uint8_t tap_y_en : 1; - uint8_t tap_x_en : 1; - uint8_t slope_fds : 1; - uint8_t inact_en : 2; - uint8_t interrupts_enable : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t interrupts_enable : 1; - uint8_t inact_en : 2; - uint8_t slope_fds : 1; - uint8_t tap_x_en : 1; - uint8_t tap_y_en : 1; - uint8_t tap_z_en : 1; - uint8_t lir : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_tap_cfg_t; - -#define LSM6DS3TR_C_TAP_THS_6D 0x59U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t tap_ths : 5; - uint8_t sixd_ths : 2; - uint8_t d4d_en : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t d4d_en : 1; - uint8_t sixd_ths : 2; - uint8_t tap_ths : 5; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_tap_ths_6d_t; - -#define LSM6DS3TR_C_INT_DUR2 0x5AU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t shock : 2; - uint8_t quiet : 2; - uint8_t dur : 4; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t dur : 4; - uint8_t quiet : 2; - uint8_t shock : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_int_dur2_t; - -#define LSM6DS3TR_C_WAKE_UP_THS 0x5BU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t wk_ths : 6; - uint8_t not_used_01 : 1; - uint8_t single_double_tap : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t single_double_tap : 1; - uint8_t not_used_01 : 1; - uint8_t wk_ths : 6; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_wake_up_ths_t; - -#define LSM6DS3TR_C_WAKE_UP_DUR 0x5CU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t sleep_dur : 4; - uint8_t timer_hr : 1; - uint8_t wake_dur : 2; - uint8_t ff_dur : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t ff_dur : 1; - uint8_t wake_dur : 2; - uint8_t timer_hr : 1; - uint8_t sleep_dur : 4; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_wake_up_dur_t; - -#define LSM6DS3TR_C_FREE_FALL 0x5DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t ff_ths : 3; - uint8_t ff_dur : 5; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t ff_dur : 5; - uint8_t ff_ths : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_free_fall_t; - -#define LSM6DS3TR_C_MD1_CFG 0x5EU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t int1_timer : 1; - uint8_t int1_tilt : 1; - uint8_t int1_6d : 1; - uint8_t int1_double_tap : 1; - uint8_t int1_ff : 1; - uint8_t int1_wu : 1; - uint8_t int1_single_tap : 1; - uint8_t int1_inact_state : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t int1_inact_state : 1; - uint8_t int1_single_tap : 1; - uint8_t int1_wu : 1; - uint8_t int1_ff : 1; - uint8_t int1_double_tap : 1; - uint8_t int1_6d : 1; - uint8_t int1_tilt : 1; - uint8_t int1_timer : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_md1_cfg_t; - -#define LSM6DS3TR_C_MD2_CFG 0x5FU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t int2_iron : 1; - uint8_t int2_tilt : 1; - uint8_t int2_6d : 1; - uint8_t int2_double_tap : 1; - uint8_t int2_ff : 1; - uint8_t int2_wu : 1; - uint8_t int2_single_tap : 1; - uint8_t int2_inact_state : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t int2_inact_state : 1; - uint8_t int2_single_tap : 1; - uint8_t int2_wu : 1; - uint8_t int2_ff : 1; - uint8_t int2_double_tap : 1; - uint8_t int2_6d : 1; - uint8_t int2_tilt : 1; - uint8_t int2_iron : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_md2_cfg_t; - -#define LSM6DS3TR_C_MASTER_CMD_CODE 0x60U -typedef struct { - uint8_t master_cmd_code : 8; -} lsm6ds3tr_c_master_cmd_code_t; - -#define LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE 0x61U -typedef struct { - uint8_t error_code : 8; -} lsm6ds3tr_c_sens_sync_spi_error_code_t; - -#define LSM6DS3TR_C_OUT_MAG_RAW_X_L 0x66U -#define LSM6DS3TR_C_OUT_MAG_RAW_X_H 0x67U -#define LSM6DS3TR_C_OUT_MAG_RAW_Y_L 0x68U -#define LSM6DS3TR_C_OUT_MAG_RAW_Y_H 0x69U -#define LSM6DS3TR_C_OUT_MAG_RAW_Z_L 0x6AU -#define LSM6DS3TR_C_OUT_MAG_RAW_Z_H 0x6BU -#define LSM6DS3TR_C_X_OFS_USR 0x73U -#define LSM6DS3TR_C_Y_OFS_USR 0x74U -#define LSM6DS3TR_C_Z_OFS_USR 0x75U -#define LSM6DS3TR_C_SLV0_ADD 0x02U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t rw_0 : 1; - uint8_t slave0_add : 7; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave0_add : 7; - uint8_t rw_0 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slv0_add_t; - -#define LSM6DS3TR_C_SLV0_SUBADD 0x03U -typedef struct { - uint8_t slave0_reg : 8; -} lsm6ds3tr_c_slv0_subadd_t; - -#define LSM6DS3TR_C_SLAVE0_CONFIG 0x04U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t slave0_numop : 3; - uint8_t src_mode : 1; - uint8_t aux_sens_on : 2; - uint8_t slave0_rate : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave0_rate : 2; - uint8_t aux_sens_on : 2; - uint8_t src_mode : 1; - uint8_t slave0_numop : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slave0_config_t; - -#define LSM6DS3TR_C_SLV1_ADD 0x05U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t r_1 : 1; - uint8_t slave1_add : 7; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave1_add : 7; - uint8_t r_1 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slv1_add_t; - -#define LSM6DS3TR_C_SLV1_SUBADD 0x06U -typedef struct { - uint8_t slave1_reg : 8; -} lsm6ds3tr_c_slv1_subadd_t; - -#define LSM6DS3TR_C_SLAVE1_CONFIG 0x07U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t slave1_numop : 3; - uint8_t not_used_01 : 2; - uint8_t write_once : 1; - uint8_t slave1_rate : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave1_rate : 2; - uint8_t write_once : 1; - uint8_t not_used_01 : 2; - uint8_t slave1_numop : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slave1_config_t; - -#define LSM6DS3TR_C_SLV2_ADD 0x08U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t r_2 : 1; - uint8_t slave2_add : 7; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave2_add : 7; - uint8_t r_2 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slv2_add_t; - -#define LSM6DS3TR_C_SLV2_SUBADD 0x09U -typedef struct { - uint8_t slave2_reg : 8; -} lsm6ds3tr_c_slv2_subadd_t; - -#define LSM6DS3TR_C_SLAVE2_CONFIG 0x0AU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t slave2_numop : 3; - uint8_t not_used_01 : 3; - uint8_t slave2_rate : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave2_rate : 2; - uint8_t not_used_01 : 3; - uint8_t slave2_numop : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slave2_config_t; - -#define LSM6DS3TR_C_SLV3_ADD 0x0BU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t r_3 : 1; - uint8_t slave3_add : 7; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave3_add : 7; - uint8_t r_3 : 1; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slv3_add_t; - -#define LSM6DS3TR_C_SLV3_SUBADD 0x0CU -typedef struct { - uint8_t slave3_reg : 8; -} lsm6ds3tr_c_slv3_subadd_t; - -#define LSM6DS3TR_C_SLAVE3_CONFIG 0x0DU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t slave3_numop : 3; - uint8_t not_used_01 : 3; - uint8_t slave3_rate : 2; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t slave3_rate : 2; - uint8_t not_used_01 : 3; - uint8_t slave3_numop : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_slave3_config_t; - -#define LSM6DS3TR_C_DATAWRITE_SRC_MODE_SUB_SLV0 0x0EU -typedef struct { - uint8_t slave_dataw : 8; -} lsm6ds3tr_c_datawrite_src_mode_sub_slv0_t; - -#define LSM6DS3TR_C_CONFIG_PEDO_THS_MIN 0x0FU -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t ths_min : 5; - uint8_t not_used_01 : 2; - uint8_t pedo_fs : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t pedo_fs : 1; - uint8_t not_used_01 : 2; - uint8_t ths_min : 5; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_config_pedo_ths_min_t; - -#define LSM6DS3TR_C_SM_THS 0x13U -#define LSM6DS3TR_C_PEDO_DEB_REG 0x14U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t deb_step : 3; - uint8_t deb_time : 5; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t deb_time : 5; - uint8_t deb_step : 3; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_pedo_deb_reg_t; - -#define LSM6DS3TR_C_STEP_COUNT_DELTA 0x15U -#define LSM6DS3TR_C_MAG_SI_XX 0x24U -#define LSM6DS3TR_C_MAG_SI_XY 0x25U -#define LSM6DS3TR_C_MAG_SI_XZ 0x26U -#define LSM6DS3TR_C_MAG_SI_YX 0x27U -#define LSM6DS3TR_C_MAG_SI_YY 0x28U -#define LSM6DS3TR_C_MAG_SI_YZ 0x29U -#define LSM6DS3TR_C_MAG_SI_ZX 0x2AU -#define LSM6DS3TR_C_MAG_SI_ZY 0x2BU -#define LSM6DS3TR_C_MAG_SI_ZZ 0x2CU -#define LSM6DS3TR_C_MAG_OFFX_L 0x2DU -#define LSM6DS3TR_C_MAG_OFFX_H 0x2EU -#define LSM6DS3TR_C_MAG_OFFY_L 0x2FU -#define LSM6DS3TR_C_MAG_OFFY_H 0x30U -#define LSM6DS3TR_C_MAG_OFFZ_L 0x31U -#define LSM6DS3TR_C_MAG_OFFZ_H 0x32U -#define LSM6DS3TR_C_A_WRIST_TILT_LAT 0x50U -#define LSM6DS3TR_C_A_WRIST_TILT_THS 0x54U -#define LSM6DS3TR_C_A_WRIST_TILT_MASK 0x59U -typedef struct { -#if DRV_BYTE_ORDER == DRV_LITTLE_ENDIAN - uint8_t not_used_01 : 2; - uint8_t wrist_tilt_mask_zneg : 1; - uint8_t wrist_tilt_mask_zpos : 1; - uint8_t wrist_tilt_mask_yneg : 1; - uint8_t wrist_tilt_mask_ypos : 1; - uint8_t wrist_tilt_mask_xneg : 1; - uint8_t wrist_tilt_mask_xpos : 1; -#elif DRV_BYTE_ORDER == DRV_BIG_ENDIAN - uint8_t wrist_tilt_mask_xpos : 1; - uint8_t wrist_tilt_mask_xneg : 1; - uint8_t wrist_tilt_mask_ypos : 1; - uint8_t wrist_tilt_mask_yneg : 1; - uint8_t wrist_tilt_mask_zpos : 1; - uint8_t wrist_tilt_mask_zneg : 1; - uint8_t not_used_01 : 2; -#endif /* DRV_BYTE_ORDER */ -} lsm6ds3tr_c_a_wrist_tilt_mask_t; - -/** - * @defgroup LSM6DS3TR_C_Register_Union - * @brief This union group all the registers having a bit-field - * description. - * This union is useful but it's not needed by the driver. - * - * REMOVING this union you are compliant with: - * MISRA-C 2012 [Rule 19.2] -> " Union are not allowed " - * - * @{ - * - */ -typedef union { - lsm6ds3tr_c_func_cfg_access_t func_cfg_access; - lsm6ds3tr_c_sensor_sync_time_frame_t sensor_sync_time_frame; - lsm6ds3tr_c_sensor_sync_res_ratio_t sensor_sync_res_ratio; - lsm6ds3tr_c_fifo_ctrl1_t fifo_ctrl1; - lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2; - lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3; - lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4; - lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5; - lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g; - lsm6ds3tr_c_int1_ctrl_t int1_ctrl; - lsm6ds3tr_c_int2_ctrl_t int2_ctrl; - lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl; - lsm6ds3tr_c_ctrl2_g_t ctrl2_g; - lsm6ds3tr_c_ctrl3_c_t ctrl3_c; - lsm6ds3tr_c_ctrl4_c_t ctrl4_c; - lsm6ds3tr_c_ctrl5_c_t ctrl5_c; - lsm6ds3tr_c_ctrl6_c_t ctrl6_c; - lsm6ds3tr_c_ctrl7_g_t ctrl7_g; - lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl; - lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl; - lsm6ds3tr_c_ctrl10_c_t ctrl10_c; - lsm6ds3tr_c_master_config_t master_config; - lsm6ds3tr_c_wake_up_src_t wake_up_src; - lsm6ds3tr_c_tap_src_t tap_src; - lsm6ds3tr_c_d6d_src_t d6d_src; - lsm6ds3tr_c_status_reg_t status_reg; - lsm6ds3tr_c_sensorhub1_reg_t sensorhub1_reg; - lsm6ds3tr_c_sensorhub2_reg_t sensorhub2_reg; - lsm6ds3tr_c_sensorhub3_reg_t sensorhub3_reg; - lsm6ds3tr_c_sensorhub4_reg_t sensorhub4_reg; - lsm6ds3tr_c_sensorhub5_reg_t sensorhub5_reg; - lsm6ds3tr_c_sensorhub6_reg_t sensorhub6_reg; - lsm6ds3tr_c_sensorhub7_reg_t sensorhub7_reg; - lsm6ds3tr_c_sensorhub8_reg_t sensorhub8_reg; - lsm6ds3tr_c_sensorhub9_reg_t sensorhub9_reg; - lsm6ds3tr_c_sensorhub10_reg_t sensorhub10_reg; - lsm6ds3tr_c_sensorhub11_reg_t sensorhub11_reg; - lsm6ds3tr_c_sensorhub12_reg_t sensorhub12_reg; - lsm6ds3tr_c_fifo_status1_t fifo_status1; - lsm6ds3tr_c_fifo_status2_t fifo_status2; - lsm6ds3tr_c_fifo_status3_t fifo_status3; - lsm6ds3tr_c_fifo_status4_t fifo_status4; - lsm6ds3tr_c_sensorhub13_reg_t sensorhub13_reg; - lsm6ds3tr_c_sensorhub14_reg_t sensorhub14_reg; - lsm6ds3tr_c_sensorhub15_reg_t sensorhub15_reg; - lsm6ds3tr_c_sensorhub16_reg_t sensorhub16_reg; - lsm6ds3tr_c_sensorhub17_reg_t sensorhub17_reg; - lsm6ds3tr_c_sensorhub18_reg_t sensorhub18_reg; - lsm6ds3tr_c_func_src1_t func_src1; - lsm6ds3tr_c_func_src2_t func_src2; - lsm6ds3tr_c_wrist_tilt_ia_t wrist_tilt_ia; - lsm6ds3tr_c_tap_cfg_t tap_cfg; - lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d; - lsm6ds3tr_c_int_dur2_t int_dur2; - lsm6ds3tr_c_wake_up_ths_t wake_up_ths; - lsm6ds3tr_c_wake_up_dur_t wake_up_dur; - lsm6ds3tr_c_free_fall_t free_fall; - lsm6ds3tr_c_md1_cfg_t md1_cfg; - lsm6ds3tr_c_md2_cfg_t md2_cfg; - lsm6ds3tr_c_master_cmd_code_t master_cmd_code; - lsm6ds3tr_c_sens_sync_spi_error_code_t sens_sync_spi_error_code; - lsm6ds3tr_c_slv0_add_t slv0_add; - lsm6ds3tr_c_slv0_subadd_t slv0_subadd; - lsm6ds3tr_c_slave0_config_t slave0_config; - lsm6ds3tr_c_slv1_add_t slv1_add; - lsm6ds3tr_c_slv1_subadd_t slv1_subadd; - lsm6ds3tr_c_slave1_config_t slave1_config; - lsm6ds3tr_c_slv2_add_t slv2_add; - lsm6ds3tr_c_slv2_subadd_t slv2_subadd; - lsm6ds3tr_c_slave2_config_t slave2_config; - lsm6ds3tr_c_slv3_add_t slv3_add; - lsm6ds3tr_c_slv3_subadd_t slv3_subadd; - lsm6ds3tr_c_slave3_config_t slave3_config; - lsm6ds3tr_c_datawrite_src_mode_sub_slv0_t datawrite_src_mode_sub_slv0; - lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min; - lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg; - lsm6ds3tr_c_a_wrist_tilt_mask_t a_wrist_tilt_mask; - bitwise_t bitwise; - uint8_t byte; -} lsm6ds3tr_c_reg_t; - -/** - * @} - * - */ - -int32_t lsm6ds3tr_c_read_reg(stmdev_ctx_t* ctx, uint8_t reg, uint8_t* data, uint16_t len); -int32_t lsm6ds3tr_c_write_reg(stmdev_ctx_t* ctx, uint8_t reg, uint8_t* data, uint16_t len); - -float_t lsm6ds3tr_c_from_fs2g_to_mg(int16_t lsb); -float_t lsm6ds3tr_c_from_fs4g_to_mg(int16_t lsb); -float_t lsm6ds3tr_c_from_fs8g_to_mg(int16_t lsb); -float_t lsm6ds3tr_c_from_fs16g_to_mg(int16_t lsb); - -float_t lsm6ds3tr_c_from_fs125dps_to_mdps(int16_t lsb); -float_t lsm6ds3tr_c_from_fs250dps_to_mdps(int16_t lsb); -float_t lsm6ds3tr_c_from_fs500dps_to_mdps(int16_t lsb); -float_t lsm6ds3tr_c_from_fs1000dps_to_mdps(int16_t lsb); -float_t lsm6ds3tr_c_from_fs2000dps_to_mdps(int16_t lsb); - -float_t lsm6ds3tr_c_from_lsb_to_celsius(int16_t lsb); - -typedef enum { - LSM6DS3TR_C_2g = 0, - LSM6DS3TR_C_16g = 1, - LSM6DS3TR_C_4g = 2, - LSM6DS3TR_C_8g = 3, - LSM6DS3TR_C_XL_FS_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_fs_xl_t; -int32_t lsm6ds3tr_c_xl_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_xl_t val); -int32_t lsm6ds3tr_c_xl_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_xl_t* val); - -typedef enum { - LSM6DS3TR_C_XL_ODR_OFF = 0, - LSM6DS3TR_C_XL_ODR_12Hz5 = 1, - LSM6DS3TR_C_XL_ODR_26Hz = 2, - LSM6DS3TR_C_XL_ODR_52Hz = 3, - LSM6DS3TR_C_XL_ODR_104Hz = 4, - LSM6DS3TR_C_XL_ODR_208Hz = 5, - LSM6DS3TR_C_XL_ODR_416Hz = 6, - LSM6DS3TR_C_XL_ODR_833Hz = 7, - LSM6DS3TR_C_XL_ODR_1k66Hz = 8, - LSM6DS3TR_C_XL_ODR_3k33Hz = 9, - LSM6DS3TR_C_XL_ODR_6k66Hz = 10, - LSM6DS3TR_C_XL_ODR_1Hz6 = 11, - LSM6DS3TR_C_XL_ODR_ND = 12, /* ERROR CODE */ -} lsm6ds3tr_c_odr_xl_t; -int32_t lsm6ds3tr_c_xl_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_xl_t val); -int32_t lsm6ds3tr_c_xl_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_xl_t* val); - -typedef enum { - LSM6DS3TR_C_250dps = 0, - LSM6DS3TR_C_125dps = 1, - LSM6DS3TR_C_500dps = 2, - LSM6DS3TR_C_1000dps = 4, - LSM6DS3TR_C_2000dps = 6, - LSM6DS3TR_C_GY_FS_ND = 7, /* ERROR CODE */ -} lsm6ds3tr_c_fs_g_t; -int32_t lsm6ds3tr_c_gy_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_g_t val); -int32_t lsm6ds3tr_c_gy_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fs_g_t* val); - -typedef enum { - LSM6DS3TR_C_GY_ODR_OFF = 0, - LSM6DS3TR_C_GY_ODR_12Hz5 = 1, - LSM6DS3TR_C_GY_ODR_26Hz = 2, - LSM6DS3TR_C_GY_ODR_52Hz = 3, - LSM6DS3TR_C_GY_ODR_104Hz = 4, - LSM6DS3TR_C_GY_ODR_208Hz = 5, - LSM6DS3TR_C_GY_ODR_416Hz = 6, - LSM6DS3TR_C_GY_ODR_833Hz = 7, - LSM6DS3TR_C_GY_ODR_1k66Hz = 8, - LSM6DS3TR_C_GY_ODR_3k33Hz = 9, - LSM6DS3TR_C_GY_ODR_6k66Hz = 10, - LSM6DS3TR_C_GY_ODR_ND = 11, /* ERROR CODE */ -} lsm6ds3tr_c_odr_g_t; -int32_t lsm6ds3tr_c_gy_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_g_t val); -int32_t lsm6ds3tr_c_gy_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_g_t* val); - -int32_t lsm6ds3tr_c_block_data_update_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_block_data_update_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_LSb_1mg = 0, - LSM6DS3TR_C_LSb_16mg = 1, - LSM6DS3TR_C_WEIGHT_ND = 2, -} lsm6ds3tr_c_usr_off_w_t; -int32_t lsm6ds3tr_c_xl_offset_weight_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_usr_off_w_t val); -int32_t lsm6ds3tr_c_xl_offset_weight_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_usr_off_w_t* val); - -typedef enum { - LSM6DS3TR_C_XL_HIGH_PERFORMANCE = 0, - LSM6DS3TR_C_XL_NORMAL = 1, - LSM6DS3TR_C_XL_PW_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_xl_hm_mode_t; -int32_t lsm6ds3tr_c_xl_power_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_xl_hm_mode_t val); -int32_t lsm6ds3tr_c_xl_power_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_xl_hm_mode_t* val); - -typedef enum { - LSM6DS3TR_C_STAT_RND_DISABLE = 0, - LSM6DS3TR_C_STAT_RND_ENABLE = 1, - LSM6DS3TR_C_STAT_RND_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_rounding_status_t; -int32_t lsm6ds3tr_c_rounding_on_status_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_status_t val); -int32_t lsm6ds3tr_c_rounding_on_status_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_status_t* val); - -typedef enum { - LSM6DS3TR_C_GY_HIGH_PERFORMANCE = 0, - LSM6DS3TR_C_GY_NORMAL = 1, - LSM6DS3TR_C_GY_PW_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_g_hm_mode_t; -int32_t lsm6ds3tr_c_gy_power_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_g_hm_mode_t val); -int32_t lsm6ds3tr_c_gy_power_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_g_hm_mode_t* val); - -typedef struct { - lsm6ds3tr_c_wake_up_src_t wake_up_src; - lsm6ds3tr_c_tap_src_t tap_src; - lsm6ds3tr_c_d6d_src_t d6d_src; - lsm6ds3tr_c_status_reg_t status_reg; - lsm6ds3tr_c_func_src1_t func_src1; - lsm6ds3tr_c_func_src2_t func_src2; - lsm6ds3tr_c_wrist_tilt_ia_t wrist_tilt_ia; - lsm6ds3tr_c_a_wrist_tilt_mask_t a_wrist_tilt_mask; -} lsm6ds3tr_c_all_sources_t; -int32_t lsm6ds3tr_c_all_sources_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_all_sources_t* val); - -int32_t lsm6ds3tr_c_status_reg_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_status_reg_t* val); - -int32_t lsm6ds3tr_c_xl_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_gy_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_temp_flag_data_ready_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_xl_usr_offset_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_xl_usr_offset_get(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_timestamp_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_timestamp_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_LSB_6ms4 = 0, - LSM6DS3TR_C_LSB_25us = 1, - LSM6DS3TR_C_TS_RES_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_timer_hr_t; -int32_t lsm6ds3tr_c_timestamp_res_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_timer_hr_t val); -int32_t lsm6ds3tr_c_timestamp_res_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_timer_hr_t* val); - -typedef enum { - LSM6DS3TR_C_ROUND_DISABLE = 0, - LSM6DS3TR_C_ROUND_XL = 1, - LSM6DS3TR_C_ROUND_GY = 2, - LSM6DS3TR_C_ROUND_GY_XL = 3, - LSM6DS3TR_C_ROUND_SH1_TO_SH6 = 4, - LSM6DS3TR_C_ROUND_XL_SH1_TO_SH6 = 5, - LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH12 = 6, - LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH6 = 7, - LSM6DS3TR_C_ROUND_OUT_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_rounding_t; -int32_t lsm6ds3tr_c_rounding_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_t val); -int32_t lsm6ds3tr_c_rounding_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rounding_t* val); - -int32_t lsm6ds3tr_c_temperature_raw_get(stmdev_ctx_t* ctx, int16_t* val); -int32_t lsm6ds3tr_c_angular_rate_raw_get(stmdev_ctx_t* ctx, int16_t* val); -int32_t lsm6ds3tr_c_acceleration_raw_get(stmdev_ctx_t* ctx, int16_t* val); - -int32_t lsm6ds3tr_c_mag_calibrated_raw_get(stmdev_ctx_t* ctx, int16_t* val); - -int32_t lsm6ds3tr_c_fifo_raw_data_get(stmdev_ctx_t* ctx, uint8_t* buffer, uint8_t len); - -typedef enum { - LSM6DS3TR_C_USER_BANK = 0, - LSM6DS3TR_C_BANK_A = 4, - LSM6DS3TR_C_BANK_B = 5, - LSM6DS3TR_C_BANK_ND = 6, /* ERROR CODE */ -} lsm6ds3tr_c_func_cfg_en_t; -int32_t lsm6ds3tr_c_mem_bank_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_func_cfg_en_t val); -int32_t lsm6ds3tr_c_mem_bank_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_func_cfg_en_t* val); - -typedef enum { - LSM6DS3TR_C_DRDY_LATCHED = 0, - LSM6DS3TR_C_DRDY_PULSED = 1, - LSM6DS3TR_C_DRDY_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_drdy_pulsed_g_t; -int32_t lsm6ds3tr_c_data_ready_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_drdy_pulsed_g_t val); -int32_t lsm6ds3tr_c_data_ready_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_drdy_pulsed_g_t* val); - -int32_t lsm6ds3tr_c_device_id_get(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_reset_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_reset_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_LSB_AT_LOW_ADD = 0, - LSM6DS3TR_C_MSB_AT_LOW_ADD = 1, - LSM6DS3TR_C_DATA_FMT_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_ble_t; -int32_t lsm6ds3tr_c_data_format_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_ble_t val); -int32_t lsm6ds3tr_c_data_format_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_ble_t* val); - -int32_t lsm6ds3tr_c_auto_increment_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_auto_increment_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_boot_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_boot_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_XL_ST_DISABLE = 0, - LSM6DS3TR_C_XL_ST_POSITIVE = 1, - LSM6DS3TR_C_XL_ST_NEGATIVE = 2, - LSM6DS3TR_C_XL_ST_ND = 3, /* ERROR CODE */ -} lsm6ds3tr_c_st_xl_t; -int32_t lsm6ds3tr_c_xl_self_test_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_xl_t val); -int32_t lsm6ds3tr_c_xl_self_test_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_xl_t* val); - -typedef enum { - LSM6DS3TR_C_GY_ST_DISABLE = 0, - LSM6DS3TR_C_GY_ST_POSITIVE = 1, - LSM6DS3TR_C_GY_ST_NEGATIVE = 3, - LSM6DS3TR_C_GY_ST_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_st_g_t; -int32_t lsm6ds3tr_c_gy_self_test_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_g_t val); -int32_t lsm6ds3tr_c_gy_self_test_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_st_g_t* val); - -int32_t lsm6ds3tr_c_filter_settling_mask_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_filter_settling_mask_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_USE_SLOPE = 0, - LSM6DS3TR_C_USE_HPF = 1, - LSM6DS3TR_C_HP_PATH_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_slope_fds_t; -int32_t lsm6ds3tr_c_xl_hp_path_internal_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slope_fds_t val); -int32_t lsm6ds3tr_c_xl_hp_path_internal_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slope_fds_t* val); - -typedef enum { - LSM6DS3TR_C_XL_ANA_BW_1k5Hz = 0, - LSM6DS3TR_C_XL_ANA_BW_400Hz = 1, - LSM6DS3TR_C_XL_ANA_BW_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_bw0_xl_t; -int32_t lsm6ds3tr_c_xl_filter_analog_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_bw0_xl_t val); -int32_t lsm6ds3tr_c_xl_filter_analog_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_bw0_xl_t* val); - -typedef enum { - LSM6DS3TR_C_XL_LP1_ODR_DIV_2 = 0, - LSM6DS3TR_C_XL_LP1_ODR_DIV_4 = 1, - LSM6DS3TR_C_XL_LP1_NA = 2, /* ERROR CODE */ -} lsm6ds3tr_c_lpf1_bw_sel_t; -int32_t lsm6ds3tr_c_xl_lp1_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_bw_sel_t val); -int32_t lsm6ds3tr_c_xl_lp1_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_bw_sel_t* val); - -typedef enum { - LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_50 = 0x00, - LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_100 = 0x01, - LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_9 = 0x02, - LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_400 = 0x03, - LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_50 = 0x10, - LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_100 = 0x11, - LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_9 = 0x12, - LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_400 = 0x13, - LSM6DS3TR_C_XL_LP_NA = 0x20, /* ERROR CODE */ -} lsm6ds3tr_c_input_composite_t; -int32_t lsm6ds3tr_c_xl_lp2_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_input_composite_t val); -int32_t lsm6ds3tr_c_xl_lp2_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_input_composite_t* val); - -int32_t lsm6ds3tr_c_xl_reference_mode_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_xl_reference_mode_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_XL_HP_ODR_DIV_4 = 0x00, /* Slope filter */ - LSM6DS3TR_C_XL_HP_ODR_DIV_100 = 0x01, - LSM6DS3TR_C_XL_HP_ODR_DIV_9 = 0x02, - LSM6DS3TR_C_XL_HP_ODR_DIV_400 = 0x03, - LSM6DS3TR_C_XL_HP_NA = 0x10, /* ERROR CODE */ -} lsm6ds3tr_c_hpcf_xl_t; -int32_t lsm6ds3tr_c_xl_hp_bandwidth_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_hpcf_xl_t val); -int32_t lsm6ds3tr_c_xl_hp_bandwidth_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_hpcf_xl_t* val); - -typedef enum { - LSM6DS3TR_C_LP2_ONLY = 0x00, - - LSM6DS3TR_C_HP_16mHz_LP2 = 0x80, - LSM6DS3TR_C_HP_65mHz_LP2 = 0x90, - LSM6DS3TR_C_HP_260mHz_LP2 = 0xA0, - LSM6DS3TR_C_HP_1Hz04_LP2 = 0xB0, - - LSM6DS3TR_C_HP_DISABLE_LP1_LIGHT = 0x0A, - LSM6DS3TR_C_HP_DISABLE_LP1_NORMAL = 0x09, - LSM6DS3TR_C_HP_DISABLE_LP_STRONG = 0x08, - LSM6DS3TR_C_HP_DISABLE_LP1_AGGRESSIVE = 0x0B, - - LSM6DS3TR_C_HP_16mHz_LP1_LIGHT = 0x8A, - LSM6DS3TR_C_HP_65mHz_LP1_NORMAL = 0x99, - LSM6DS3TR_C_HP_260mHz_LP1_STRONG = 0xA8, - LSM6DS3TR_C_HP_1Hz04_LP1_AGGRESSIVE = 0xBB, - - LSM6DS3TR_C_HP_GY_BAND_NA = 0xFF, /* ERROR CODE */ -} lsm6ds3tr_c_lpf1_sel_g_t; -int32_t lsm6ds3tr_c_gy_band_pass_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_sel_g_t val); -int32_t lsm6ds3tr_c_gy_band_pass_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lpf1_sel_g_t* val); - -typedef enum { - LSM6DS3TR_C_SPI_4_WIRE = 0, - LSM6DS3TR_C_SPI_3_WIRE = 1, - LSM6DS3TR_C_SPI_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_sim_t; -int32_t lsm6ds3tr_c_spi_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_sim_t val); -int32_t lsm6ds3tr_c_spi_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_sim_t* val); - -typedef enum { - LSM6DS3TR_C_I2C_ENABLE = 0, - LSM6DS3TR_C_I2C_DISABLE = 1, - LSM6DS3TR_C_I2C_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_i2c_disable_t; -int32_t lsm6ds3tr_c_i2c_interface_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_i2c_disable_t val); -int32_t lsm6ds3tr_c_i2c_interface_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_i2c_disable_t* val); - -typedef struct { - uint8_t int1_drdy_xl : 1; - uint8_t int1_drdy_g : 1; - uint8_t int1_boot : 1; - uint8_t int1_fth : 1; - uint8_t int1_fifo_ovr : 1; - uint8_t int1_full_flag : 1; - uint8_t int1_sign_mot : 1; - uint8_t int1_step_detector : 1; - uint8_t int1_timer : 1; - uint8_t int1_tilt : 1; - uint8_t int1_6d : 1; - uint8_t int1_double_tap : 1; - uint8_t int1_ff : 1; - uint8_t int1_wu : 1; - uint8_t int1_single_tap : 1; - uint8_t int1_inact_state : 1; - uint8_t den_drdy_int1 : 1; - uint8_t drdy_on_int1 : 1; -} lsm6ds3tr_c_int1_route_t; -int32_t lsm6ds3tr_c_pin_int1_route_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_int1_route_t val); -int32_t lsm6ds3tr_c_pin_int1_route_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_int1_route_t* val); - -typedef struct { - uint8_t int2_drdy_xl : 1; - uint8_t int2_drdy_g : 1; - uint8_t int2_drdy_temp : 1; - uint8_t int2_fth : 1; - uint8_t int2_fifo_ovr : 1; - uint8_t int2_full_flag : 1; - uint8_t int2_step_count_ov : 1; - uint8_t int2_step_delta : 1; - uint8_t int2_iron : 1; - uint8_t int2_tilt : 1; - uint8_t int2_6d : 1; - uint8_t int2_double_tap : 1; - uint8_t int2_ff : 1; - uint8_t int2_wu : 1; - uint8_t int2_single_tap : 1; - uint8_t int2_inact_state : 1; - uint8_t int2_wrist_tilt : 1; -} lsm6ds3tr_c_int2_route_t; -int32_t lsm6ds3tr_c_pin_int2_route_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_int2_route_t val); -int32_t lsm6ds3tr_c_pin_int2_route_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_int2_route_t* val); - -typedef enum { - LSM6DS3TR_C_PUSH_PULL = 0, - LSM6DS3TR_C_OPEN_DRAIN = 1, - LSM6DS3TR_C_PIN_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_pp_od_t; -int32_t lsm6ds3tr_c_pin_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pp_od_t val); -int32_t lsm6ds3tr_c_pin_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pp_od_t* val); - -typedef enum { - LSM6DS3TR_C_ACTIVE_HIGH = 0, - LSM6DS3TR_C_ACTIVE_LOW = 1, - LSM6DS3TR_C_POLARITY_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_h_lactive_t; -int32_t lsm6ds3tr_c_pin_polarity_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_h_lactive_t val); -int32_t lsm6ds3tr_c_pin_polarity_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_h_lactive_t* val); - -int32_t lsm6ds3tr_c_all_on_int1_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_all_on_int1_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_INT_PULSED = 0, - LSM6DS3TR_C_INT_LATCHED = 1, - LSM6DS3TR_C_INT_MODE = 2, /* ERROR CODE */ -} lsm6ds3tr_c_lir_t; -int32_t lsm6ds3tr_c_int_notification_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_lir_t val); -int32_t lsm6ds3tr_c_int_notification_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_lir_t* val); - -int32_t lsm6ds3tr_c_wkup_threshold_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_wkup_threshold_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_wkup_dur_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_wkup_dur_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_gy_sleep_mode_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_gy_sleep_mode_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_PROPERTY_DISABLE = 0, - LSM6DS3TR_C_XL_12Hz5_GY_NOT_AFFECTED = 1, - LSM6DS3TR_C_XL_12Hz5_GY_SLEEP = 2, - LSM6DS3TR_C_XL_12Hz5_GY_PD = 3, - LSM6DS3TR_C_ACT_MODE_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_inact_en_t; -int32_t lsm6ds3tr_c_act_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_inact_en_t val); -int32_t lsm6ds3tr_c_act_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_inact_en_t* val); - -int32_t lsm6ds3tr_c_act_sleep_dur_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_act_sleep_dur_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_src_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_tap_src_t* val); - -int32_t lsm6ds3tr_c_tap_detection_on_z_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_detection_on_z_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_detection_on_y_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_detection_on_y_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_detection_on_x_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_detection_on_x_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_threshold_x_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_threshold_x_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_shock_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_shock_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_quiet_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_quiet_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tap_dur_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tap_dur_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_ONLY_SINGLE = 0, - LSM6DS3TR_C_BOTH_SINGLE_DOUBLE = 1, - LSM6DS3TR_C_TAP_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_single_double_tap_t; -int32_t lsm6ds3tr_c_tap_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_single_double_tap_t val); -int32_t lsm6ds3tr_c_tap_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_single_double_tap_t* val); - -typedef enum { - LSM6DS3TR_C_ODR_DIV_2_FEED = 0, - LSM6DS3TR_C_LPF2_FEED = 1, - LSM6DS3TR_C_6D_FEED_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_low_pass_on_6d_t; -int32_t lsm6ds3tr_c_6d_feed_data_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_low_pass_on_6d_t val); -int32_t lsm6ds3tr_c_6d_feed_data_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_low_pass_on_6d_t* val); - -typedef enum { - LSM6DS3TR_C_DEG_80 = 0, - LSM6DS3TR_C_DEG_70 = 1, - LSM6DS3TR_C_DEG_60 = 2, - LSM6DS3TR_C_DEG_50 = 3, - LSM6DS3TR_C_6D_TH_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_sixd_ths_t; -int32_t lsm6ds3tr_c_6d_threshold_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_sixd_ths_t val); -int32_t lsm6ds3tr_c_6d_threshold_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_sixd_ths_t* val); - -int32_t lsm6ds3tr_c_4d_mode_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_4d_mode_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_ff_dur_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_ff_dur_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_FF_TSH_156mg = 0, - LSM6DS3TR_C_FF_TSH_219mg = 1, - LSM6DS3TR_C_FF_TSH_250mg = 2, - LSM6DS3TR_C_FF_TSH_312mg = 3, - LSM6DS3TR_C_FF_TSH_344mg = 4, - LSM6DS3TR_C_FF_TSH_406mg = 5, - LSM6DS3TR_C_FF_TSH_469mg = 6, - LSM6DS3TR_C_FF_TSH_500mg = 7, - LSM6DS3TR_C_FF_TSH_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_ff_ths_t; -int32_t lsm6ds3tr_c_ff_threshold_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_ff_ths_t val); -int32_t lsm6ds3tr_c_ff_threshold_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_ff_ths_t* val); - -int32_t lsm6ds3tr_c_fifo_watermark_set(stmdev_ctx_t* ctx, uint16_t val); -int32_t lsm6ds3tr_c_fifo_watermark_get(stmdev_ctx_t* ctx, uint16_t* val); - -int32_t lsm6ds3tr_c_fifo_data_level_get(stmdev_ctx_t* ctx, uint16_t* val); - -int32_t lsm6ds3tr_c_fifo_wtm_flag_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_fifo_pattern_get(stmdev_ctx_t* ctx, uint16_t* val); - -int32_t lsm6ds3tr_c_fifo_temp_batch_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_fifo_temp_batch_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_TRG_XL_GY_DRDY = 0, - LSM6DS3TR_C_TRG_STEP_DETECT = 1, - LSM6DS3TR_C_TRG_SH_DRDY = 2, - LSM6DS3TR_C_TRG_SH_ND = 3, /* ERROR CODE */ -} lsm6ds3tr_c_trigger_fifo_t; -int32_t lsm6ds3tr_c_fifo_write_trigger_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_trigger_fifo_t val); -int32_t lsm6ds3tr_c_fifo_write_trigger_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_trigger_fifo_t* val); - -int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_FIFO_XL_DISABLE = 0, - LSM6DS3TR_C_FIFO_XL_NO_DEC = 1, - LSM6DS3TR_C_FIFO_XL_DEC_2 = 2, - LSM6DS3TR_C_FIFO_XL_DEC_3 = 3, - LSM6DS3TR_C_FIFO_XL_DEC_4 = 4, - LSM6DS3TR_C_FIFO_XL_DEC_8 = 5, - LSM6DS3TR_C_FIFO_XL_DEC_16 = 6, - LSM6DS3TR_C_FIFO_XL_DEC_32 = 7, - LSM6DS3TR_C_FIFO_XL_DEC_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_dec_fifo_xl_t; -int32_t lsm6ds3tr_c_fifo_xl_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_xl_t val); -int32_t lsm6ds3tr_c_fifo_xl_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_xl_t* val); - -typedef enum { - LSM6DS3TR_C_FIFO_GY_DISABLE = 0, - LSM6DS3TR_C_FIFO_GY_NO_DEC = 1, - LSM6DS3TR_C_FIFO_GY_DEC_2 = 2, - LSM6DS3TR_C_FIFO_GY_DEC_3 = 3, - LSM6DS3TR_C_FIFO_GY_DEC_4 = 4, - LSM6DS3TR_C_FIFO_GY_DEC_8 = 5, - LSM6DS3TR_C_FIFO_GY_DEC_16 = 6, - LSM6DS3TR_C_FIFO_GY_DEC_32 = 7, - LSM6DS3TR_C_FIFO_GY_DEC_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_dec_fifo_gyro_t; -int32_t lsm6ds3tr_c_fifo_gy_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_gyro_t val); -int32_t lsm6ds3tr_c_fifo_gy_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_fifo_gyro_t* val); - -typedef enum { - LSM6DS3TR_C_FIFO_DS3_DISABLE = 0, - LSM6DS3TR_C_FIFO_DS3_NO_DEC = 1, - LSM6DS3TR_C_FIFO_DS3_DEC_2 = 2, - LSM6DS3TR_C_FIFO_DS3_DEC_3 = 3, - LSM6DS3TR_C_FIFO_DS3_DEC_4 = 4, - LSM6DS3TR_C_FIFO_DS3_DEC_8 = 5, - LSM6DS3TR_C_FIFO_DS3_DEC_16 = 6, - LSM6DS3TR_C_FIFO_DS3_DEC_32 = 7, - LSM6DS3TR_C_FIFO_DS3_DEC_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_dec_ds3_fifo_t; -int32_t lsm6ds3tr_c_fifo_dataset_3_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds3_fifo_t val); -int32_t lsm6ds3tr_c_fifo_dataset_3_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds3_fifo_t* val); - -typedef enum { - LSM6DS3TR_C_FIFO_DS4_DISABLE = 0, - LSM6DS3TR_C_FIFO_DS4_NO_DEC = 1, - LSM6DS3TR_C_FIFO_DS4_DEC_2 = 2, - LSM6DS3TR_C_FIFO_DS4_DEC_3 = 3, - LSM6DS3TR_C_FIFO_DS4_DEC_4 = 4, - LSM6DS3TR_C_FIFO_DS4_DEC_8 = 5, - LSM6DS3TR_C_FIFO_DS4_DEC_16 = 6, - LSM6DS3TR_C_FIFO_DS4_DEC_32 = 7, - LSM6DS3TR_C_FIFO_DS4_DEC_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_dec_ds4_fifo_t; -int32_t lsm6ds3tr_c_fifo_dataset_4_batch_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds4_fifo_t val); -int32_t lsm6ds3tr_c_fifo_dataset_4_batch_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_dec_ds4_fifo_t* val); - -int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_fifo_stop_on_wtm_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_fifo_stop_on_wtm_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_BYPASS_MODE = 0, - LSM6DS3TR_C_FIFO_MODE = 1, - LSM6DS3TR_C_STREAM_TO_FIFO_MODE = 3, - LSM6DS3TR_C_BYPASS_TO_STREAM_MODE = 4, - LSM6DS3TR_C_STREAM_MODE = 6, - LSM6DS3TR_C_FIFO_MODE_ND = 8, /* ERROR CODE */ -} lsm6ds3tr_c_fifo_mode_t; -int32_t lsm6ds3tr_c_fifo_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_fifo_mode_t val); -int32_t lsm6ds3tr_c_fifo_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_fifo_mode_t* val); - -typedef enum { - LSM6DS3TR_C_FIFO_DISABLE = 0, - LSM6DS3TR_C_FIFO_12Hz5 = 1, - LSM6DS3TR_C_FIFO_26Hz = 2, - LSM6DS3TR_C_FIFO_52Hz = 3, - LSM6DS3TR_C_FIFO_104Hz = 4, - LSM6DS3TR_C_FIFO_208Hz = 5, - LSM6DS3TR_C_FIFO_416Hz = 6, - LSM6DS3TR_C_FIFO_833Hz = 7, - LSM6DS3TR_C_FIFO_1k66Hz = 8, - LSM6DS3TR_C_FIFO_3k33Hz = 9, - LSM6DS3TR_C_FIFO_6k66Hz = 10, - LSM6DS3TR_C_FIFO_RATE_ND = 11, /* ERROR CODE */ -} lsm6ds3tr_c_odr_fifo_t; -int32_t lsm6ds3tr_c_fifo_data_rate_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_fifo_t val); -int32_t lsm6ds3tr_c_fifo_data_rate_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_odr_fifo_t* val); - -typedef enum { - LSM6DS3TR_C_DEN_ACT_LOW = 0, - LSM6DS3TR_C_DEN_ACT_HIGH = 1, - LSM6DS3TR_C_DEN_POL_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_den_lh_t; -int32_t lsm6ds3tr_c_den_polarity_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_lh_t val); -int32_t lsm6ds3tr_c_den_polarity_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_lh_t* val); - -typedef enum { - LSM6DS3TR_C_DEN_DISABLE = 0, - LSM6DS3TR_C_LEVEL_FIFO = 6, - LSM6DS3TR_C_LEVEL_LETCHED = 3, - LSM6DS3TR_C_LEVEL_TRIGGER = 2, - LSM6DS3TR_C_EDGE_TRIGGER = 4, - LSM6DS3TR_C_DEN_MODE_ND = 5, /* ERROR CODE */ -} lsm6ds3tr_c_den_mode_t; -int32_t lsm6ds3tr_c_den_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_mode_t val); -int32_t lsm6ds3tr_c_den_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_mode_t* val); - -typedef enum { - LSM6DS3TR_C_STAMP_IN_GY_DATA = 0, - LSM6DS3TR_C_STAMP_IN_XL_DATA = 1, - LSM6DS3TR_C_STAMP_IN_GY_XL_DATA = 2, - LSM6DS3TR_C_DEN_STAMP_ND = 3, /* ERROR CODE */ -} lsm6ds3tr_c_den_xl_en_t; -int32_t lsm6ds3tr_c_den_enable_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_xl_en_t val); -int32_t lsm6ds3tr_c_den_enable_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_den_xl_en_t* val); - -int32_t lsm6ds3tr_c_den_mark_axis_z_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_den_mark_axis_z_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_den_mark_axis_y_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_den_mark_axis_y_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_den_mark_axis_x_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_den_mark_axis_x_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_pedo_step_reset_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_pedo_step_reset_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_pedo_sens_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_pedo_sens_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_pedo_threshold_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_pedo_threshold_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_PEDO_AT_2g = 0, - LSM6DS3TR_C_PEDO_AT_4g = 1, - LSM6DS3TR_C_PEDO_FS_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_pedo_fs_t; -int32_t lsm6ds3tr_c_pedo_full_scale_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pedo_fs_t val); -int32_t lsm6ds3tr_c_pedo_full_scale_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pedo_fs_t* val); - -int32_t lsm6ds3tr_c_pedo_debounce_steps_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_pedo_debounce_steps_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_pedo_timeout_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_pedo_timeout_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_pedo_steps_period_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_pedo_steps_period_get(stmdev_ctx_t* ctx, uint8_t* buff); - -int32_t lsm6ds3tr_c_motion_sens_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_motion_sens_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_motion_threshold_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_motion_threshold_get(stmdev_ctx_t* ctx, uint8_t* buff); - -int32_t lsm6ds3tr_c_tilt_sens_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_tilt_sens_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_wrist_tilt_sens_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_wrist_tilt_sens_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_tilt_latency_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_tilt_latency_get(stmdev_ctx_t* ctx, uint8_t* buff); - -int32_t lsm6ds3tr_c_tilt_threshold_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_tilt_threshold_get(stmdev_ctx_t* ctx, uint8_t* buff); - -int32_t lsm6ds3tr_c_tilt_src_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_a_wrist_tilt_mask_t* val); -int32_t lsm6ds3tr_c_tilt_src_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_a_wrist_tilt_mask_t* val); - -int32_t lsm6ds3tr_c_mag_soft_iron_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_mag_soft_iron_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_mag_hard_iron_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_mag_hard_iron_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_mag_soft_iron_mat_set(stmdev_ctx_t* ctx, uint8_t* buff); -int32_t lsm6ds3tr_c_mag_soft_iron_mat_get(stmdev_ctx_t* ctx, uint8_t* buff); - -int32_t lsm6ds3tr_c_mag_offset_set(stmdev_ctx_t* ctx, int16_t* val); -int32_t lsm6ds3tr_c_mag_offset_get(stmdev_ctx_t* ctx, int16_t* val); - -int32_t lsm6ds3tr_c_func_en_set(stmdev_ctx_t* ctx, uint8_t val); - -int32_t lsm6ds3tr_c_sh_sync_sens_frame_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_sync_sens_frame_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_RES_RATIO_2_11 = 0, - LSM6DS3TR_C_RES_RATIO_2_12 = 1, - LSM6DS3TR_C_RES_RATIO_2_13 = 2, - LSM6DS3TR_C_RES_RATIO_2_14 = 3, - LSM6DS3TR_C_RES_RATIO_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_rr_t; -int32_t lsm6ds3tr_c_sh_sync_sens_ratio_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_rr_t val); -int32_t lsm6ds3tr_c_sh_sync_sens_ratio_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_rr_t* val); - -int32_t lsm6ds3tr_c_sh_master_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_master_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_sh_pass_through_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_pass_through_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_EXT_PULL_UP = 0, - LSM6DS3TR_C_INTERNAL_PULL_UP = 1, - LSM6DS3TR_C_SH_PIN_MODE = 2, /* ERROR CODE */ -} lsm6ds3tr_c_pull_up_en_t; -int32_t lsm6ds3tr_c_sh_pin_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_pull_up_en_t val); -int32_t lsm6ds3tr_c_sh_pin_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_pull_up_en_t* val); - -typedef enum { - LSM6DS3TR_C_XL_GY_DRDY = 0, - LSM6DS3TR_C_EXT_ON_INT2_PIN = 1, - LSM6DS3TR_C_SH_SYNCRO_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_start_config_t; -int32_t lsm6ds3tr_c_sh_syncro_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_start_config_t val); -int32_t lsm6ds3tr_c_sh_syncro_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_start_config_t* val); - -int32_t lsm6ds3tr_c_sh_drdy_on_int1_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_drdy_on_int1_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef struct { - lsm6ds3tr_c_sensorhub1_reg_t sh_byte_1; - lsm6ds3tr_c_sensorhub2_reg_t sh_byte_2; - lsm6ds3tr_c_sensorhub3_reg_t sh_byte_3; - lsm6ds3tr_c_sensorhub4_reg_t sh_byte_4; - lsm6ds3tr_c_sensorhub5_reg_t sh_byte_5; - lsm6ds3tr_c_sensorhub6_reg_t sh_byte_6; - lsm6ds3tr_c_sensorhub7_reg_t sh_byte_7; - lsm6ds3tr_c_sensorhub8_reg_t sh_byte_8; - lsm6ds3tr_c_sensorhub9_reg_t sh_byte_9; - lsm6ds3tr_c_sensorhub10_reg_t sh_byte_10; - lsm6ds3tr_c_sensorhub11_reg_t sh_byte_11; - lsm6ds3tr_c_sensorhub12_reg_t sh_byte_12; - lsm6ds3tr_c_sensorhub13_reg_t sh_byte_13; - lsm6ds3tr_c_sensorhub14_reg_t sh_byte_14; - lsm6ds3tr_c_sensorhub15_reg_t sh_byte_15; - lsm6ds3tr_c_sensorhub16_reg_t sh_byte_16; - lsm6ds3tr_c_sensorhub17_reg_t sh_byte_17; - lsm6ds3tr_c_sensorhub18_reg_t sh_byte_18; -} lsm6ds3tr_c_emb_sh_read_t; -int32_t lsm6ds3tr_c_sh_read_data_raw_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_emb_sh_read_t* val); - -int32_t lsm6ds3tr_c_sh_cmd_sens_sync_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_cmd_sens_sync_get(stmdev_ctx_t* ctx, uint8_t* val); - -int32_t lsm6ds3tr_c_sh_spi_sync_error_set(stmdev_ctx_t* ctx, uint8_t val); -int32_t lsm6ds3tr_c_sh_spi_sync_error_get(stmdev_ctx_t* ctx, uint8_t* val); - -typedef enum { - LSM6DS3TR_C_SLV_0 = 0, - LSM6DS3TR_C_SLV_0_1 = 1, - LSM6DS3TR_C_SLV_0_1_2 = 2, - LSM6DS3TR_C_SLV_0_1_2_3 = 3, - LSM6DS3TR_C_SLV_EN_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_aux_sens_on_t; -int32_t lsm6ds3tr_c_sh_num_of_dev_connected_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_aux_sens_on_t val); -int32_t lsm6ds3tr_c_sh_num_of_dev_connected_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_aux_sens_on_t* val); - -typedef struct { - uint8_t slv0_add; - uint8_t slv0_subadd; - uint8_t slv0_data; -} lsm6ds3tr_c_sh_cfg_write_t; -int32_t lsm6ds3tr_c_sh_cfg_write(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_write_t* val); - -typedef struct { - uint8_t slv_add; - uint8_t slv_subadd; - uint8_t slv_len; -} lsm6ds3tr_c_sh_cfg_read_t; -int32_t lsm6ds3tr_c_sh_slv0_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val); -int32_t lsm6ds3tr_c_sh_slv1_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val); -int32_t lsm6ds3tr_c_sh_slv2_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val); -int32_t lsm6ds3tr_c_sh_slv3_cfg_read(stmdev_ctx_t* ctx, lsm6ds3tr_c_sh_cfg_read_t* val); - -typedef enum { - LSM6DS3TR_C_SL0_NO_DEC = 0, - LSM6DS3TR_C_SL0_DEC_2 = 1, - LSM6DS3TR_C_SL0_DEC_4 = 2, - LSM6DS3TR_C_SL0_DEC_8 = 3, - LSM6DS3TR_C_SL0_DEC_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_slave0_rate_t; -int32_t lsm6ds3tr_c_sh_slave_0_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave0_rate_t val); -int32_t lsm6ds3tr_c_sh_slave_0_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave0_rate_t* val); - -typedef enum { - LSM6DS3TR_C_EACH_SH_CYCLE = 0, - LSM6DS3TR_C_ONLY_FIRST_CYCLE = 1, - LSM6DS3TR_C_SH_WR_MODE_ND = 2, /* ERROR CODE */ -} lsm6ds3tr_c_write_once_t; -int32_t lsm6ds3tr_c_sh_write_mode_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_write_once_t val); -int32_t lsm6ds3tr_c_sh_write_mode_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_write_once_t* val); - -typedef enum { - LSM6DS3TR_C_SL1_NO_DEC = 0, - LSM6DS3TR_C_SL1_DEC_2 = 1, - LSM6DS3TR_C_SL1_DEC_4 = 2, - LSM6DS3TR_C_SL1_DEC_8 = 3, - LSM6DS3TR_C_SL1_DEC_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_slave1_rate_t; -int32_t lsm6ds3tr_c_sh_slave_1_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave1_rate_t val); -int32_t lsm6ds3tr_c_sh_slave_1_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave1_rate_t* val); - -typedef enum { - LSM6DS3TR_C_SL2_NO_DEC = 0, - LSM6DS3TR_C_SL2_DEC_2 = 1, - LSM6DS3TR_C_SL2_DEC_4 = 2, - LSM6DS3TR_C_SL2_DEC_8 = 3, - LSM6DS3TR_C_SL2_DEC_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_slave2_rate_t; -int32_t lsm6ds3tr_c_sh_slave_2_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave2_rate_t val); -int32_t lsm6ds3tr_c_sh_slave_2_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave2_rate_t* val); - -typedef enum { - LSM6DS3TR_C_SL3_NO_DEC = 0, - LSM6DS3TR_C_SL3_DEC_2 = 1, - LSM6DS3TR_C_SL3_DEC_4 = 2, - LSM6DS3TR_C_SL3_DEC_8 = 3, - LSM6DS3TR_C_SL3_DEC_ND = 4, /* ERROR CODE */ -} lsm6ds3tr_c_slave3_rate_t; -int32_t lsm6ds3tr_c_sh_slave_3_dec_set(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave3_rate_t val); -int32_t lsm6ds3tr_c_sh_slave_3_dec_get(stmdev_ctx_t* ctx, lsm6ds3tr_c_slave3_rate_t* val); - -/** - * @} - * - */ - -#ifdef __cplusplus -} -#endif - -#endif /* LSM6DS3TR_C_DRIVER_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/applications/plugins/airmouse/tracking/main_loop.cc b/applications/plugins/airmouse/tracking/main_loop.cc deleted file mode 100644 index 492157a4d..000000000 --- a/applications/plugins/airmouse/tracking/main_loop.cc +++ /dev/null @@ -1,189 +0,0 @@ -#include "main_loop.h" - -#include -#include - -#include "imu/imu.h" -#include "orientation_tracker.h" -#include "calibration_data.h" - -#define TAG "tracker" - -static const float CURSOR_SPEED = 1024.0 / (M_PI / 4); -static const float STABILIZE_BIAS = 16.0; - -float g_yaw = 0; -float g_pitch = 0; -float g_dYaw = 0; -float g_dPitch = 0; -bool firstRead = true; -bool stabilize = true; -CalibrationData calibration; -cardboard::OrientationTracker tracker(10000000l); // 10 ms / 100 Hz -uint64_t ippms, ippms2; - -static inline float clamp(float val) -{ - while (val <= -M_PI) { - val += 2 * M_PI; - } - while (val >= M_PI) { - val -= 2 * M_PI; - } - return val; -} - -static inline float highpass(float oldVal, float newVal) -{ - if (!stabilize) { - return newVal; - } - float delta = clamp(oldVal - newVal); - float alpha = (float) std::max(0.0, 1 - std::pow(std::fabs(delta) * CURSOR_SPEED / STABILIZE_BIAS, 3.0)); - return newVal + alpha * delta; -} - -void sendCurrentState(MouseMoveCallback mouse_move) -{ - float dX = g_dYaw * CURSOR_SPEED; - float dY = g_dPitch * CURSOR_SPEED; - - // Scale the shift down to fit the protocol. - if (dX > 127) { - dY *= 127.0 / dX; - dX = 127; - } - if (dX < -127) { - dY *= -127.0 / dX; - dX = -127; - } - if (dY > 127) { - dX *= 127.0 / dY; - dY = 127; - } - if (dY < -127) { - dX *= -127.0 / dY; - dY = -127; - } - - const int8_t x = (int8_t)std::floor(dX + 0.5); - const int8_t y = (int8_t)std::floor(dY + 0.5); - - mouse_move(x, y); - - // Only subtract the part of the error that was already sent. - if (x != 0) { - g_dYaw -= x / CURSOR_SPEED; - } - if (y != 0) { - g_dPitch -= y / CURSOR_SPEED; - } -} - -void onOrientation(cardboard::Vector4& quaternion) -{ - float q1 = quaternion[0]; // X * sin(T/2) - float q2 = quaternion[1]; // Y * sin(T/2) - float q3 = quaternion[2]; // Z * sin(T/2) - float q0 = quaternion[3]; // cos(T/2) - - float yaw = std::atan2(2 * (q0 * q3 - q1 * q2), (1 - 2 * (q1 * q1 + q3 * q3))); - float pitch = std::asin(2 * (q0 * q1 + q2 * q3)); - // float roll = std::atan2(2 * (q0 * q2 - q1 * q3), (1 - 2 * (q1 * q1 + q2 * q2))); - - if (yaw == NAN || pitch == NAN) { - // NaN case, skip it - return; - } - - if (firstRead) { - g_yaw = yaw; - g_pitch = pitch; - firstRead = false; - } else { - const float newYaw = highpass(g_yaw, yaw); - const float newPitch = highpass(g_pitch, pitch); - - float dYaw = clamp(g_yaw - newYaw); - float dPitch = g_pitch - newPitch; - g_yaw = newYaw; - g_pitch = newPitch; - - // Accumulate the error locally. - g_dYaw += dYaw; - g_dPitch += dPitch; - } -} - -extern "C" { - -void calibration_begin() { - calibration.reset(); - FURI_LOG_I(TAG, "Calibrating"); -} - -bool calibration_step() { - if (calibration.isComplete()) - return true; - - double vec[6]; - if (imu_read(vec) & GYR_DATA_READY) { - cardboard::Vector3 data(vec[3], vec[4], vec[5]); - furi_delay_ms(9); // Artificially limit to ~100Hz - return calibration.add(data); - } - - return false; -} - -void calibration_end() { - CalibrationMedian store; - cardboard::Vector3 median = calibration.getMedian(); - store.x = median[0]; - store.y = median[1]; - store.z = median[2]; - CALIBRATION_DATA_SAVE(&store); -} - -void tracking_begin() { - CalibrationMedian store; - cardboard::Vector3 median = calibration.getMedian(); - if (CALIBRATION_DATA_LOAD(&store)) { - median[0] = store.x; - median[1] = store.y; - median[2] = store.z; - } - - ippms = furi_hal_cortex_instructions_per_microsecond(); - ippms2 = ippms / 2; - tracker.SetCalibration(median); - tracker.Resume(); -} - -void tracking_step(MouseMoveCallback mouse_move) { - double vec[6]; - int ret = imu_read(vec); - if (ret != 0) { - uint64_t t = (DWT->CYCCNT * 1000llu + ippms2) / ippms; - if (ret & ACC_DATA_READY) { - cardboard::AccelerometerData adata - = { .system_timestamp = t, .sensor_timestamp_ns = t, - .data = cardboard::Vector3(vec[0], vec[1], vec[2]) }; - tracker.OnAccelerometerData(adata); - } - if (ret & GYR_DATA_READY) { - cardboard::GyroscopeData gdata - = { .system_timestamp = t, .sensor_timestamp_ns = t, - .data = cardboard::Vector3(vec[3], vec[4], vec[5]) }; - cardboard::Vector4 pose = tracker.OnGyroscopeData(gdata); - onOrientation(pose); - sendCurrentState(mouse_move); - } - } -} - -void tracking_end() { - tracker.Pause(); -} - -} diff --git a/applications/plugins/airmouse/tracking/main_loop.h b/applications/plugins/airmouse/tracking/main_loop.h deleted file mode 100644 index ce0d96568..000000000 --- a/applications/plugins/airmouse/tracking/main_loop.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef bool (*MouseMoveCallback)(int8_t x, int8_t y); - -void calibration_begin(); -bool calibration_step(); -void calibration_end(); - -void tracking_begin(); -void tracking_step(MouseMoveCallback mouse_move); -void tracking_end(); - -#ifdef __cplusplus -} -#endif diff --git a/applications/plugins/airmouse/tracking/orientation_tracker.cc b/applications/plugins/airmouse/tracking/orientation_tracker.cc deleted file mode 100644 index ac20e9672..000000000 --- a/applications/plugins/airmouse/tracking/orientation_tracker.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "orientation_tracker.h" - -#include "sensors/pose_prediction.h" -#include "util/logging.h" -#include "util/vector.h" -#include "util/vectorutils.h" - -namespace cardboard { - -OrientationTracker::OrientationTracker(const long sampling_period_ns) - : sampling_period_ns_(sampling_period_ns) - , calibration_(Vector3::Zero()) - , is_tracking_(false) - , sensor_fusion_(new SensorFusionEkf()) - , latest_gyroscope_data_({ 0, 0, Vector3::Zero() }) -{ - sensor_fusion_->SetBiasEstimationEnabled(/*kGyroBiasEstimationEnabled*/ true); -} - -void OrientationTracker::SetCalibration(const Vector3& calibration) { - calibration_ = calibration; -} - -void OrientationTracker::Pause() -{ - if (!is_tracking_) { - return; - } - - // Create a gyro event with zero velocity. This effectively stops the prediction. - GyroscopeData event = latest_gyroscope_data_; - event.data = Vector3::Zero(); - - OnGyroscopeData(event); - - is_tracking_ = false; -} - -void OrientationTracker::Resume() { is_tracking_ = true; } - -Vector4 OrientationTracker::GetPose(int64_t timestamp_ns) const -{ - Rotation predicted_rotation; - const PoseState pose_state = sensor_fusion_->GetLatestPoseState(); - if (sensor_fusion_->IsFullyInitialized()) { - predicted_rotation = pose_state.sensor_from_start_rotation; - } else { - CARDBOARD_LOGI("Tracker not fully initialized yet. Using pose prediction only."); - predicted_rotation = pose_prediction::PredictPose(timestamp_ns, pose_state); - } - - return (-predicted_rotation).GetQuaternion(); -} - -void OrientationTracker::OnAccelerometerData(const AccelerometerData& event) -{ - if (!is_tracking_) { - return; - } - sensor_fusion_->ProcessAccelerometerSample(event); -} - -Vector4 OrientationTracker::OnGyroscopeData(const GyroscopeData& event) -{ - if (!is_tracking_) { - return Vector4(); - } - - const GyroscopeData data = { .system_timestamp = event.system_timestamp, - .sensor_timestamp_ns = event.sensor_timestamp_ns, - .data = event.data - calibration_ }; - - latest_gyroscope_data_ = data; - - sensor_fusion_->ProcessGyroscopeSample(data); - - return OrientationTracker::GetPose(data.sensor_timestamp_ns + sampling_period_ns_); -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/orientation_tracker.h b/applications/plugins/airmouse/tracking/orientation_tracker.h deleted file mode 100644 index fb49c9859..000000000 --- a/applications/plugins/airmouse/tracking/orientation_tracker.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include -#include -#include // NOLINT - -#include "sensors/accelerometer_data.h" -#include "sensors/gyroscope_data.h" -#include "sensors/sensor_fusion_ekf.h" -#include "util/rotation.h" - -namespace cardboard { - -// OrientationTracker encapsulates pose tracking by connecting sensors -// to SensorFusion. -// This pose tracker reports poses in display space. -class OrientationTracker { -public: - OrientationTracker(const long sampling_period_ns); - - void SetCalibration(const Vector3& calibration); - - // Pauses tracking and sensors. - void Pause(); - - // Resumes tracking ans sensors. - void Resume(); - - // Gets the predicted pose for a given timestamp. - Vector4 GetPose(int64_t timestamp_ns) const; - - // Function called when receiving AccelerometerData. - // - // @param event sensor event. - void OnAccelerometerData(const AccelerometerData& event); - - // Function called when receiving GyroscopeData. - // - // @param event sensor event. - Vector4 OnGyroscopeData(const GyroscopeData& event); - -private: - long sampling_period_ns_; - Vector3 calibration_; - - std::atomic is_tracking_; - // Sensor Fusion object that stores the internal state of the filter. - std::unique_ptr sensor_fusion_; - // Latest gyroscope data. - GyroscopeData latest_gyroscope_data_; -}; - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/accelerometer_data.h b/applications/plugins/airmouse/tracking/sensors/accelerometer_data.h deleted file mode 100644 index bdf3289af..000000000 --- a/applications/plugins/airmouse/tracking/sensors/accelerometer_data.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_ACCELEROMETER_DATA_H_ -#define CARDBOARD_SDK_SENSORS_ACCELEROMETER_DATA_H_ - -#include "../util/vector.h" - -namespace cardboard { - -struct AccelerometerData { - // System wall time. - uint64_t system_timestamp; - - // Sensor clock time in nanoseconds. - uint64_t sensor_timestamp_ns; - - // Acceleration force along the x,y,z axes in m/s^2. This follows android - // specification - // (https://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-coords). - Vector3 data; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_ACCELEROMETER_DATA_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.cc b/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.cc deleted file mode 100644 index 96f2f7346..000000000 --- a/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.cc +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "gyroscope_bias_estimator.h" - -#include -#include // NOLINT - -#include "../util/rotation.h" -#include "../util/vector.h" - -namespace { - -// Cutoff frequencies in Hertz applied to our various signals, and their -// corresponding filters. -const float kAccelerometerLowPassCutOffFrequencyHz = 1.0f; -const float kRotationVelocityBasedAccelerometerLowPassCutOffFrequencyHz = 0.15f; -const float kGyroscopeLowPassCutOffFrequencyHz = 1.0f; -const float kGyroscopeBiasLowPassCutOffFrequencyHz = 0.15f; - -// Note that MEMS IMU are not that precise. -const double kEpsilon = 1.0e-8; - -// Size of the filtering window for the mean and median filter. The larger the -// windows the larger the filter delay. -const int kFilterWindowSize = 5; - -// Threshold used to compare rotation computed from the accelerometer and the -// gyroscope bias. -const double kRatioBetweenGyroBiasAndAccel = 1.5; - -// The minimum sum of weights we need to acquire before returning a bias -// estimation. -const float kMinSumOfWeightsGyroBiasThreshold = 25.0f; - -// Amount of change in m/s^3 we allow on the smoothed accelerometer values to -// consider the phone static. -const double kAccelerometerDeltaStaticThreshold = 0.5; - -// Amount of change in radians/s^2 we allow on the smoothed gyroscope values to -// consider the phone static. -const double kGyroscopeDeltaStaticThreshold = 0.03; - -// If the gyroscope value is above this threshold, don't update the gyroscope -// bias estimation. This threshold is applied to the magnitude of gyroscope -// vectors in radians/s. -const float kGyroscopeForBiasThreshold = 0.30f; - -// Used to monitor if accelerometer and gyroscope have been static for a few -// frames. -const int kStaticFrameDetectionThreshold = 50; - -// Minimum time step between sensor updates. -const double kMinTimestep = 1; // std::chrono::nanoseconds(1); -} // namespace - -namespace cardboard { - -// A helper class to keep track of whether some signal can be considered static -// over specified number of frames. -class GyroscopeBiasEstimator::IsStaticCounter { -public: - // Initializes a counter with the number of consecutive frames we require - // the signal to be static before IsRecentlyStatic returns true. - // - // @param min_static_frames_threshold number of consecutive frames we - // require the signal to be static before IsRecentlyStatic returns true. - explicit IsStaticCounter(int min_static_frames_threshold) - : min_static_frames_threshold_(min_static_frames_threshold) - , consecutive_static_frames_(0) - { - } - - // Specifies whether the current frame is considered static. - // - // @param is_static static flag for current frame. - void AppendFrame(bool is_static) - { - if (is_static) { - ++consecutive_static_frames_; - } else { - consecutive_static_frames_ = 0; - } - } - - // Returns if static movement is assumed. - bool IsRecentlyStatic() const - { - return consecutive_static_frames_ >= min_static_frames_threshold_; - } - // Resets counter. - void Reset() { consecutive_static_frames_ = 0; } - -private: - const int min_static_frames_threshold_; - int consecutive_static_frames_; -}; - -GyroscopeBiasEstimator::GyroscopeBiasEstimator() - : accelerometer_lowpass_filter_(kAccelerometerLowPassCutOffFrequencyHz) - , simulated_gyroscope_from_accelerometer_lowpass_filter_( - kRotationVelocityBasedAccelerometerLowPassCutOffFrequencyHz) - , gyroscope_lowpass_filter_(kGyroscopeLowPassCutOffFrequencyHz) - , gyroscope_bias_lowpass_filter_(kGyroscopeBiasLowPassCutOffFrequencyHz) - , accelerometer_static_counter_(new IsStaticCounter(kStaticFrameDetectionThreshold)) - , gyroscope_static_counter_(new IsStaticCounter(kStaticFrameDetectionThreshold)) - , current_accumulated_weights_gyroscope_bias_(0.f) - , mean_filter_(kFilterWindowSize) - , median_filter_(kFilterWindowSize) - , last_mean_filtered_accelerometer_value_({ 0, 0, 0 }) -{ - Reset(); -} - -GyroscopeBiasEstimator::~GyroscopeBiasEstimator() { } - -void GyroscopeBiasEstimator::Reset() -{ - accelerometer_lowpass_filter_.Reset(); - gyroscope_lowpass_filter_.Reset(); - gyroscope_bias_lowpass_filter_.Reset(); - accelerometer_static_counter_->Reset(); - gyroscope_static_counter_->Reset(); -} - -void GyroscopeBiasEstimator::ProcessGyroscope( - const Vector3& gyroscope_sample, uint64_t timestamp_ns) -{ - // Update gyroscope and gyroscope delta low-pass filters. - gyroscope_lowpass_filter_.AddSample(gyroscope_sample, timestamp_ns); - - const auto smoothed_gyroscope_delta - = gyroscope_sample - gyroscope_lowpass_filter_.GetFilteredData(); - - gyroscope_static_counter_->AppendFrame( - Length(smoothed_gyroscope_delta) < kGyroscopeDeltaStaticThreshold); - - // Only update the bias if the gyroscope and accelerometer signals have been - // relatively static recently. - if (gyroscope_static_counter_->IsRecentlyStatic() - && accelerometer_static_counter_->IsRecentlyStatic()) { - // Reset static counter when updating the bias fails. - if (!UpdateGyroscopeBias(gyroscope_sample, timestamp_ns)) { - // Bias update fails because of large motion, thus reset the static - // counter. - gyroscope_static_counter_->AppendFrame(false); - } - } else { - // Reset weights, if not static. - current_accumulated_weights_gyroscope_bias_ = 0; - } -} - -void GyroscopeBiasEstimator::ProcessAccelerometer( - const Vector3& accelerometer_sample, uint64_t timestamp_ns) -{ - // Get current state of the filter. - const uint64_t previous_accel_timestamp_ns - = accelerometer_lowpass_filter_.GetMostRecentTimestampNs(); - const bool is_low_pass_filter_init = accelerometer_lowpass_filter_.IsInitialized(); - - // Update accel and accel delta low-pass filters. - accelerometer_lowpass_filter_.AddSample(accelerometer_sample, timestamp_ns); - - const auto smoothed_accelerometer_delta - = accelerometer_sample - accelerometer_lowpass_filter_.GetFilteredData(); - - accelerometer_static_counter_->AppendFrame( - Length(smoothed_accelerometer_delta) < kAccelerometerDeltaStaticThreshold); - - // Rotation from accel cannot be differentiated with only one sample. - if (!is_low_pass_filter_init) { - simulated_gyroscope_from_accelerometer_lowpass_filter_.AddSample({ 0, 0, 0 }, timestamp_ns); - return; - } - - // No need to update the simulated gyroscope at this point because the motion - // is too large. - if (!accelerometer_static_counter_->IsRecentlyStatic()) { - return; - } - - median_filter_.AddSample(accelerometer_lowpass_filter_.GetFilteredData()); - - // This processing can only be started if the buffer is fully initialized. - if (!median_filter_.IsValid()) { - mean_filter_.AddSample(accelerometer_lowpass_filter_.GetFilteredData()); - - // Update the last filtered accelerometer value. - last_mean_filtered_accelerometer_value_ = accelerometer_lowpass_filter_.GetFilteredData(); - return; - } - - mean_filter_.AddSample(median_filter_.GetFilteredData()); - - // Compute a mock gyroscope value from accelerometer. - const int64_t diff = timestamp_ns - previous_accel_timestamp_ns; - const double timestep = static_cast(diff); - - simulated_gyroscope_from_accelerometer_lowpass_filter_.AddSample( - ComputeAngularVelocityFromLatestAccelerometer(timestep), timestamp_ns); - last_mean_filtered_accelerometer_value_ = mean_filter_.GetFilteredData(); -} - -Vector3 GyroscopeBiasEstimator::ComputeAngularVelocityFromLatestAccelerometer(double timestep) const -{ - if (timestep < kMinTimestep) { - return { 0, 0, 0 }; - } - - const auto mean_of_median = mean_filter_.GetFilteredData(); - - // Compute an incremental rotation between the last state and the current - // state. - // - // Note that we switch to double precision here because of precision problem - // with small rotation. - const auto incremental_rotation = Rotation::RotateInto( - Vector3(last_mean_filtered_accelerometer_value_[0], - last_mean_filtered_accelerometer_value_[1], last_mean_filtered_accelerometer_value_[2]), - Vector3(mean_of_median[0], mean_of_median[1], mean_of_median[2])); - - // We use axis angle here because this is how gyroscope values are stored. - Vector3 incremental_rotation_axis; - double incremental_rotation_angle; - incremental_rotation.GetAxisAndAngle(&incremental_rotation_axis, &incremental_rotation_angle); - - incremental_rotation_axis *= incremental_rotation_angle / timestep; - - return { static_cast(incremental_rotation_axis[0]), - static_cast(incremental_rotation_axis[1]), - static_cast(incremental_rotation_axis[2]) }; -} - -bool GyroscopeBiasEstimator::UpdateGyroscopeBias( - const Vector3& gyroscope_sample, uint64_t timestamp_ns) -{ - // Gyroscope values that are too big are potentially dangerous as they could - // originate from slow and steady head rotations. - // - // Therefore we compute an update weight which: - // * favors gyroscope values that are closer to 0 - // * is set to zero if gyroscope values are greater than a threshold. - // - // This way, the gyroscope bias estimation converges faster if the phone is - // flat on a table, as opposed to held up somewhat stationary in the user's - // hands. - - // If magnitude is too big, don't update the filter at all so that we don't - // artificially increase the number of samples accumulated by the filter. - const float gyroscope_sample_norm2 = Length(gyroscope_sample); - if (gyroscope_sample_norm2 >= kGyroscopeForBiasThreshold) { - return false; - } - - float update_weight - = std::max(0.0f, 1 - gyroscope_sample_norm2 / kGyroscopeForBiasThreshold); - update_weight *= update_weight; - gyroscope_bias_lowpass_filter_.AddWeightedSample( - gyroscope_lowpass_filter_.GetFilteredData(), timestamp_ns, update_weight); - - // This counter is only partially valid as the low pass filter drops large - // samples. - current_accumulated_weights_gyroscope_bias_ += update_weight; - - return true; -} - -Vector3 GyroscopeBiasEstimator::GetGyroscopeBias() const -{ - return gyroscope_bias_lowpass_filter_.GetFilteredData(); -} - -bool GyroscopeBiasEstimator::IsCurrentEstimateValid() const -{ - // Remove any bias component along the gravity because they cannot be - // evaluated from accelerometer. - const auto current_gravity_dir = Normalized(last_mean_filtered_accelerometer_value_); - const auto gyro_bias_lowpass = gyroscope_bias_lowpass_filter_.GetFilteredData(); - - const auto off_gravity_gyro_bias - = gyro_bias_lowpass - current_gravity_dir * Dot(gyro_bias_lowpass, current_gravity_dir); - - // Checks that the current bias estimate is not correlated with the - // rotation computed from accelerometer. - const auto gyro_from_accel - = simulated_gyroscope_from_accelerometer_lowpass_filter_.GetFilteredData(); - const bool isGyroscopeBiasCorrelatedWithSimulatedGyro - = (Length(gyro_from_accel) * kRatioBetweenGyroBiasAndAccel - > (Length(off_gravity_gyro_bias) + kEpsilon)); - const bool hasEnoughSamples - = current_accumulated_weights_gyroscope_bias_ > kMinSumOfWeightsGyroBiasThreshold; - const bool areCountersStatic = gyroscope_static_counter_->IsRecentlyStatic() - && accelerometer_static_counter_->IsRecentlyStatic(); - - const bool isStatic - = hasEnoughSamples && areCountersStatic && !isGyroscopeBiasCorrelatedWithSimulatedGyro; - return isStatic; -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.h b/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.h deleted file mode 100644 index 1a46f96be..000000000 --- a/applications/plugins/airmouse/tracking/sensors/gyroscope_bias_estimator.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_GYROSCOPE_BIAS_ESTIMATOR_H_ -#define CARDBOARD_SDK_SENSORS_GYROSCOPE_BIAS_ESTIMATOR_H_ - -#include // NOLINT -#include -#include -#include -#include - -#include "lowpass_filter.h" -#include "mean_filter.h" -#include "median_filter.h" -#include "../util/vector.h" - -namespace cardboard { - -// Class that attempts to estimate the gyroscope's bias. -// Its main idea is that it averages the gyroscope values when the phone is -// considered stationary. -// Usage: A client should call the ProcessGyroscope and ProcessAccelerometer -// methods for every accelerometer and gyroscope sensor sample. This class -// expects these calls to be frequent, i.e., at least at 10 Hz. The client can -// then call GetGyroBias to retrieve the current estimate of the gyroscope bias. -// For best results, the fastest available delay option should be used when -// registering to sensors. Note that this class is not thread-safe. -// -// The filtering applied to the accelerometer to estimate a rotation -// from it follows : -// Baptiste Delporte, Laurent Perroton, Thierry Grandpierre, Jacques Trichet. -// Accelerometer and Magnetometer Based Gyroscope Emulation on Smart Sensor -// for a Virtual Reality Application. Sensor and Transducers Journal, 2012. -// -// which is a combination of a IIR filter, a median and a mean filter. -class GyroscopeBiasEstimator { -public: - GyroscopeBiasEstimator(); - virtual ~GyroscopeBiasEstimator(); - - // Updates the estimator with a gyroscope event. - // - // @param gyroscope_sample the angular speed around the x, y, z axis in - // radians/sec. - // @param timestamp_ns the nanosecond at which the event occurred. Only - // guaranteed to be comparable with timestamps from other PocessGyroscope - // invocations. - virtual void ProcessGyroscope(const Vector3& gyroscope_sample, uint64_t timestamp_ns); - - // Processes accelerometer samples to estimate if device is - // stable or not. - // - // First we filter the accelerometer. This is done with 3 filters. - // - A IIR low-pass filter - // - A median filter - // - A mean filter. - // Then a rotation is computed between consecutive filtered accelerometer - // samples. - // Finally this is converted to a velocity to emulate a gyroscope. - // - // @param accelerometer_sample the acceleration (including gravity) on the x, - // y, z axis in meters/s^2. - // @param timestamp_ns the nanosecond at which the event occurred. Only - // guaranteed to be comparable with timestamps from other - // ProcessAccelerometer invocations. - virtual void ProcessAccelerometer(const Vector3& accelerometer_sample, uint64_t timestamp_ns); - - // Returns the estimated gyroscope bias. - // - // @return Estimated gyroscope bias. A vector with zeros is returned if no - // estimate has been computed. - virtual Vector3 GetGyroscopeBias() const; - - // Resets the estimator state. - void Reset(); - - // Returns true if the current estimate returned by GetGyroscopeBias is - // correct. The device (measured using the sensors) has to be static for this - // function to return true. - virtual bool IsCurrentEstimateValid() const; - -private: - // A helper class to keep track of whether some signal can be considered - // static over specified number of frames. - class IsStaticCounter; - - // Updates gyroscope bias estimation. - // - // @return false if the current sample is too large. - bool UpdateGyroscopeBias(const Vector3& gyroscope_sample, uint64_t timestamp_ns); - - // Returns device angular velocity (rad/s) from the latest accelerometer data. - // - // @param timestep in seconds between the last two samples. - // @return rotation velocity from latest accelerometer. This can be - // interpreted as an gyroscope. - Vector3 ComputeAngularVelocityFromLatestAccelerometer(double timestep) const; - - LowpassFilter accelerometer_lowpass_filter_; - LowpassFilter simulated_gyroscope_from_accelerometer_lowpass_filter_; - LowpassFilter gyroscope_lowpass_filter_; - LowpassFilter gyroscope_bias_lowpass_filter_; - - std::unique_ptr accelerometer_static_counter_; - std::unique_ptr gyroscope_static_counter_; - - // Sum of the weight of sample used for gyroscope filtering. - float current_accumulated_weights_gyroscope_bias_; - - // Set of filters for accelerometer data to estimate a rotation - // based only on accelerometer. - MeanFilter mean_filter_; - MedianFilter median_filter_; - - // Last computed filter accelerometer value used for finite differences. - Vector3 last_mean_filtered_accelerometer_value_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_GYROSCOPE_BIAS_ESTIMATOR_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/gyroscope_data.h b/applications/plugins/airmouse/tracking/sensors/gyroscope_data.h deleted file mode 100644 index 085e85209..000000000 --- a/applications/plugins/airmouse/tracking/sensors/gyroscope_data.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_GYROSCOPE_DATA_H_ -#define CARDBOARD_SDK_SENSORS_GYROSCOPE_DATA_H_ - -#include "../util/vector.h" - -namespace cardboard { - -struct GyroscopeData { - // System wall time. - uint64_t system_timestamp; - - // Sensor clock time in nanoseconds. - uint64_t sensor_timestamp_ns; - - // Rate of rotation around the x,y,z axes in rad/s. This follows android - // specification - // (https://developer.android.com/guide/topics/sensors/sensors_overview.html#sensors-coords). - Vector3 data; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_GYROSCOPE_DATA_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/lowpass_filter.cc b/applications/plugins/airmouse/tracking/sensors/lowpass_filter.cc deleted file mode 100644 index efadfbf4e..000000000 --- a/applications/plugins/airmouse/tracking/sensors/lowpass_filter.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "lowpass_filter.h" - -#include - -namespace { - -const double kSecondsFromNanoseconds = 1.0e-9; - -// Minimum time step between sensor updates. This corresponds to 1000 Hz. -const double kMinTimestepS = 0.001f; - -// Maximum time step between sensor updates. This corresponds to 1 Hz. -const double kMaxTimestepS = 1.00f; - -} // namespace - -namespace cardboard { - -LowpassFilter::LowpassFilter(double cutoff_freq_hz) - : cutoff_time_constant_(1 / (2 * (double)M_PI * cutoff_freq_hz)) - , initialized_(false) -{ - Reset(); -} - -void LowpassFilter::AddSample(const Vector3& sample, uint64_t timestamp_ns) -{ - AddWeightedSample(sample, timestamp_ns, 1.0); -} - -void LowpassFilter::AddWeightedSample(const Vector3& sample, uint64_t timestamp_ns, double weight) -{ - if (!initialized_) { - // Initialize filter state - filtered_data_ = { sample[0], sample[1], sample[2] }; - timestamp_most_recent_update_ns_ = timestamp_ns; - initialized_ = true; - return; - } - - if (timestamp_ns < timestamp_most_recent_update_ns_) { - timestamp_most_recent_update_ns_ = timestamp_ns; - return; - } - - const double delta_s = static_cast(timestamp_ns - timestamp_most_recent_update_ns_) - * kSecondsFromNanoseconds; - if (delta_s <= kMinTimestepS || delta_s > kMaxTimestepS) { - timestamp_most_recent_update_ns_ = timestamp_ns; - return; - } - - const double weighted_delta_secs = weight * delta_s; - - const double alpha = weighted_delta_secs / (cutoff_time_constant_ + weighted_delta_secs); - - for (int i = 0; i < 3; ++i) { - filtered_data_[i] = (1 - alpha) * filtered_data_[i] + alpha * sample[i]; - } - timestamp_most_recent_update_ns_ = timestamp_ns; -} - -void LowpassFilter::Reset() -{ - initialized_ = false; - filtered_data_ = { 0, 0, 0 }; -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/lowpass_filter.h b/applications/plugins/airmouse/tracking/sensors/lowpass_filter.h deleted file mode 100644 index c4994c425..000000000 --- a/applications/plugins/airmouse/tracking/sensors/lowpass_filter.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_LOWPASS_FILTER_H_ -#define CARDBOARD_SDK_SENSORS_LOWPASS_FILTER_H_ - -#include -#include - -#include "../util/vector.h" - -namespace cardboard { - -// Implements an IIR, first order, low pass filter over vectors of the given -// dimension = 3. -// See http://en.wikipedia.org/wiki/Low-pass_filter -class LowpassFilter { -public: - // Initializes a filter with the given cutoff frequency in Hz. - explicit LowpassFilter(double cutoff_freq_hz); - - // Updates the filter with the given sample. Note that samples with - // non-monotonic timestamps and successive samples with a time steps below 1 - // ms or above 1 s are ignored. - // - // @param sample current sample data. - // @param timestamp_ns timestamp associated to this sample in nanoseconds. - void AddSample(const Vector3& sample, uint64_t timestamp_ns); - - // Updates the filter with the given weighted sample. - // - // @param sample current sample data. - // @param timestamp_ns timestamp associated to this sample in nanoseconds. - // @param weight typically a [0, 1] weight factor used when applying a new - // sample. A weight of 1 corresponds to calling AddSample. A weight of 0 - // makes the update no-op. The first initial sample is not affected by - // this. - void AddWeightedSample(const Vector3& sample, uint64_t timestamp_ns, double weight); - - // Returns the filtered value. A vector with zeros is returned if no samples - // have been added. - Vector3 GetFilteredData() const { - return filtered_data_; - } - - // Returns the most recent update timestamp in ns. - uint64_t GetMostRecentTimestampNs() const { - return timestamp_most_recent_update_ns_; - } - - // Returns true when the filter is initialized. - bool IsInitialized() const { - return initialized_; - } - - // Resets filter state. - void Reset(); - -private: - const double cutoff_time_constant_; - uint64_t timestamp_most_recent_update_ns_; - bool initialized_; - - Vector3 filtered_data_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_LOWPASS_FILTER_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/mean_filter.cc b/applications/plugins/airmouse/tracking/sensors/mean_filter.cc deleted file mode 100644 index 02fb8034c..000000000 --- a/applications/plugins/airmouse/tracking/sensors/mean_filter.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "mean_filter.h" - -namespace cardboard { - -MeanFilter::MeanFilter(size_t filter_size) - : filter_size_(filter_size) -{ -} - -void MeanFilter::AddSample(const Vector3& sample) -{ - buffer_.push_back(sample); - if (buffer_.size() > filter_size_) { - buffer_.pop_front(); - } -} - -bool MeanFilter::IsValid() const { return buffer_.size() == filter_size_; } - -Vector3 MeanFilter::GetFilteredData() const -{ - // Compute mean of the samples stored in buffer_. - Vector3 mean = Vector3::Zero(); - for (auto sample : buffer_) { - mean += sample; - } - - return mean / static_cast(filter_size_); -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/mean_filter.h b/applications/plugins/airmouse/tracking/sensors/mean_filter.h deleted file mode 100644 index 6b4956fef..000000000 --- a/applications/plugins/airmouse/tracking/sensors/mean_filter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_MEAN_FILTER_H_ -#define CARDBOARD_SDK_SENSORS_MEAN_FILTER_H_ - -#include - -#include "../util/vector.h" - -namespace cardboard { - -// Fixed window FIFO mean filter for vectors of the given dimension. -class MeanFilter { -public: - // Create a mean filter of size filter_size. - // @param filter_size size of the internal filter. - explicit MeanFilter(size_t filter_size); - - // Add sample to buffer_ if buffer_ is full it drop the oldest sample. - void AddSample(const Vector3& sample); - - // Returns true if buffer has filter_size_ sample, false otherwise. - bool IsValid() const; - - // Returns the mean of values stored in the internal buffer. - Vector3 GetFilteredData() const; - -private: - const size_t filter_size_; - std::deque buffer_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_MEAN_FILTER_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/median_filter.cc b/applications/plugins/airmouse/tracking/sensors/median_filter.cc deleted file mode 100644 index d27c19f47..000000000 --- a/applications/plugins/airmouse/tracking/sensors/median_filter.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "median_filter.h" - -#include -#include - -#include "../util/vector.h" -#include "../util/vectorutils.h" - -namespace cardboard { - -MedianFilter::MedianFilter(size_t filter_size) - : filter_size_(filter_size) -{ -} - -void MedianFilter::AddSample(const Vector3& sample) -{ - buffer_.push_back(sample); - norms_.push_back(Length(sample)); - if (buffer_.size() > filter_size_) { - buffer_.pop_front(); - norms_.pop_front(); - } -} - -bool MedianFilter::IsValid() const { return buffer_.size() == filter_size_; } - -Vector3 MedianFilter::GetFilteredData() const -{ - std::vector norms(norms_.begin(), norms_.end()); - - // Get median of value of the norms. - std::nth_element(norms.begin(), norms.begin() + filter_size_ / 2, norms.end()); - const float median_norm = norms[filter_size_ / 2]; - - // Get median value based on their norm. - auto median_it = buffer_.begin(); - for (const auto norm : norms_) { - if (norm == median_norm) { - break; - } - ++median_it; - } - - return *median_it; -} - -void MedianFilter::Reset() -{ - buffer_.clear(); - norms_.clear(); -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/median_filter.h b/applications/plugins/airmouse/tracking/sensors/median_filter.h deleted file mode 100644 index 9a8e7cfc7..000000000 --- a/applications/plugins/airmouse/tracking/sensors/median_filter.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_MEDIAN_FILTER_H_ -#define CARDBOARD_SDK_SENSORS_MEDIAN_FILTER_H_ - -#include - -#include "../util/vector.h" - -namespace cardboard { - -// Fixed window FIFO median filter for vectors of the given dimension = 3. -class MedianFilter { -public: - // Creates a median filter of size filter_size. - // @param filter_size size of the internal filter. - explicit MedianFilter(size_t filter_size); - - // Adds sample to buffer_ if buffer_ is full it drops the oldest sample. - void AddSample(const Vector3& sample); - - // Returns true if buffer has filter_size_ sample, false otherwise. - bool IsValid() const; - - // Returns the median of values store in the internal buffer. - Vector3 GetFilteredData() const; - - // Resets the filter, removing all samples that have been added. - void Reset(); - -private: - const size_t filter_size_; - std::deque buffer_; - // Contains norms of the elements stored in buffer_. - std::deque norms_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_MEDIAN_FILTER_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/pose_prediction.cc b/applications/plugins/airmouse/tracking/sensors/pose_prediction.cc deleted file mode 100644 index baaf844dd..000000000 --- a/applications/plugins/airmouse/tracking/sensors/pose_prediction.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "pose_prediction.h" - -#include // NOLINT - -#include "../util/logging.h" -#include "../util/vectorutils.h" - -namespace cardboard { - -namespace { - const double kEpsilon = 1.0e-15; -} // namespace - -namespace pose_prediction { - - Rotation GetRotationFromGyroscope(const Vector3& gyroscope_value, double timestep_s) - { - const double velocity = Length(gyroscope_value); - - // When there is no rotation data return an identity rotation. - if (velocity < kEpsilon) { - CARDBOARD_LOGI("PosePrediction::GetRotationFromGyroscope: Velocity really small, " - "returning identity rotation."); - return Rotation::Identity(); - } - // Since the gyroscope_value is a start from sensor transformation we need to - // invert it to have a sensor from start transformation, hence the minus sign. - // For more info: - // http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-gyro - return Rotation::FromAxisAndAngle(gyroscope_value / velocity, -timestep_s * velocity); - } - - Rotation PredictPose(int64_t requested_pose_timestamp, const PoseState& current_state) - { - // Subtracting unsigned numbers is bad when the result is negative. - const int64_t diff = requested_pose_timestamp - current_state.timestamp; - const double timestep_s = diff * 1.0e-9; - - const Rotation update = GetRotationFromGyroscope( - current_state.sensor_from_start_rotation_velocity, timestep_s); - return update * current_state.sensor_from_start_rotation; - } - - Rotation PredictPoseInv(int64_t requested_pose_timestamp, const PoseState& current_state) - { - // Subtracting unsigned numbers is bad when the result is negative. - const int64_t diff = requested_pose_timestamp - current_state.timestamp; - const double timestep_s = diff * 1.0e-9; - - const Rotation update = GetRotationFromGyroscope( - current_state.sensor_from_start_rotation_velocity, timestep_s); - return current_state.sensor_from_start_rotation * (-update); - } - -} // namespace pose_prediction -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/pose_prediction.h b/applications/plugins/airmouse/tracking/sensors/pose_prediction.h deleted file mode 100644 index 9ab311b33..000000000 --- a/applications/plugins/airmouse/tracking/sensors/pose_prediction.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_POSE_PREDICTION_H_ -#define CARDBOARD_SDK_SENSORS_POSE_PREDICTION_H_ - -#include - -#include "pose_state.h" -#include "../util/rotation.h" - -namespace cardboard { -namespace pose_prediction { - -// Returns a rotation matrix based on the integration of the gyroscope_value -// over the timestep_s in seconds. -// TODO(pfg): Document the space better here. -// -// @param gyroscope_value gyroscope sensor values. -// @param timestep_s integration period in seconds. -// @return Integration of the gyroscope value the rotation is from Start to -// Sensor Space. -Rotation GetRotationFromGyroscope(const Vector3& gyroscope_value, double timestep_s); - -// Gets a predicted pose for a given time in the future (e.g. rendering time) -// based on a linear prediction model. This uses the system current state -// (position, velocity, etc) from the past to extrapolate a position in the -// future. -// -// @param requested_pose_timestamp time at which you want the pose. -// @param current_state current state that stores the pose and linear model at a -// given time prior to requested_pose_timestamp_ns. -// @return pose from Start to Sensor Space. -Rotation PredictPose(int64_t requested_pose_timestamp, const PoseState& current_state); - -// Equivalent to PredictPose, but for use with poses relative to Start Space -// rather than sensor space. -Rotation PredictPoseInv(int64_t requested_pose_timestamp, const PoseState& current_state); - -} // namespace pose_prediction -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_POSE_PREDICTION_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/pose_state.h b/applications/plugins/airmouse/tracking/sensors/pose_state.h deleted file mode 100644 index f7801c9f3..000000000 --- a/applications/plugins/airmouse/tracking/sensors/pose_state.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_POSE_STATE_H_ -#define CARDBOARD_SDK_SENSORS_POSE_STATE_H_ - -#include "../util/rotation.h" -#include "../util/vector.h" - -namespace cardboard { - -enum { - kPoseStateFlagInvalid = 1U << 0, - kPoseStateFlagInitializing = 1U << 1, - kPoseStateFlagHas6DoF = 1U << 2, -}; - -// Stores a head pose pose plus derivatives. This can be used for prediction. -struct PoseState { - // System wall time. - int64_t timestamp; - - // Rotation from Sensor Space to Start Space. - Rotation sensor_from_start_rotation; - - // First derivative of the rotation. - Vector3 sensor_from_start_rotation_velocity; - - // Current gyroscope bias in rad/s. - Vector3 bias; - - // The position of the headset. - Vector3 position = Vector3(0, 0, 0); - - // In the same coordinate frame as the position. - Vector3 velocity = Vector3(0, 0, 0); - - // Flags indicating the status of the pose. - uint64_t flags = 0U; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_POSE_STATE_H_ diff --git a/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.cc b/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.cc deleted file mode 100644 index 575dde6f0..000000000 --- a/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.cc +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "sensor_fusion_ekf.h" - -#include -#include - -#include "accelerometer_data.h" -#include "gyroscope_data.h" -#include "pose_prediction.h" -#include "../util/matrixutils.h" - -namespace cardboard { - -namespace { - - const double kFiniteDifferencingEpsilon = 1.0e-7; - const double kEpsilon = 1.0e-15; - // Default gyroscope frequency. This corresponds to 100 Hz. - const double kDefaultGyroscopeTimestep_s = 0.01f; - // Maximum time between gyroscope before we start limiting the integration. - const double kMaximumGyroscopeSampleDelay_s = 0.04f; - // Compute a first-order exponential moving average of changes in accel norm per - // frame. - const double kSmoothingFactor = 0.5; - // Minimum and maximum values used for accelerometer noise covariance matrix. - // The smaller the sigma value, the more weight is given to the accelerometer - // signal. - const double kMinAccelNoiseSigma = 0.75; - const double kMaxAccelNoiseSigma = 7.0; - // Initial value for the diagonal elements of the different covariance matrices. - const double kInitialStateCovarianceValue = 25.0; - const double kInitialProcessCovarianceValue = 1.0; - // Maximum accelerometer norm change allowed before capping it covariance to a - // large value. - const double kMaxAccelNormChange = 0.15; - // Timestep IIR filtering coefficient. - const double kTimestepFilterCoeff = 0.95; - // Minimum number of sample for timestep filtering. - const int kTimestepFilterMinSamples = 10; - - // Z direction in start space. - const Vector3 kCanonicalZDirection(0.0, 0.0, 1.0); - - // Computes an axis-angle rotation from the input vector. - // angle = norm(a) - // axis = a.normalized() - // If norm(a) == 0, it returns an identity rotation. - static inline Rotation RotationFromVector(const Vector3& a) - { - const double norm_a = Length(a); - if (norm_a < kEpsilon) { - return Rotation::Identity(); - } - return Rotation::FromAxisAndAngle(a / norm_a, norm_a); - } - -} // namespace - -SensorFusionEkf::SensorFusionEkf() - : execute_reset_with_next_accelerometer_sample_(false) - , bias_estimation_enabled_(true) - , gyroscope_bias_estimate_({ 0, 0, 0 }) -{ - ResetState(); -} - -void SensorFusionEkf::Reset() { execute_reset_with_next_accelerometer_sample_ = true; } - -void SensorFusionEkf::ResetState() -{ - current_state_.sensor_from_start_rotation = Rotation::Identity(); - current_state_.sensor_from_start_rotation_velocity = Vector3::Zero(); - - current_gyroscope_sensor_timestamp_ns_ = 0; - current_accelerometer_sensor_timestamp_ns_ = 0; - - state_covariance_ = Matrix3x3::Identity() * kInitialStateCovarianceValue; - process_covariance_ = Matrix3x3::Identity() * kInitialProcessCovarianceValue; - accelerometer_measurement_covariance_ - = Matrix3x3::Identity() * kMinAccelNoiseSigma * kMinAccelNoiseSigma; - innovation_covariance_ = Matrix3x3::Identity(); - - accelerometer_measurement_jacobian_ = Matrix3x3::Zero(); - kalman_gain_ = Matrix3x3::Zero(); - innovation_ = Vector3::Zero(); - accelerometer_measurement_ = Vector3::Zero(); - prediction_ = Vector3::Zero(); - control_input_ = Vector3::Zero(); - state_update_ = Vector3::Zero(); - - moving_average_accelerometer_norm_change_ = 0.0; - - is_timestep_filter_initialized_ = false; - is_gyroscope_filter_valid_ = false; - is_aligned_with_gravity_ = false; - - // Reset biases. - gyroscope_bias_estimator_.Reset(); - gyroscope_bias_estimate_ = { 0, 0, 0 }; -} - -// Here I am doing something wrong relative to time stamps. The state timestamps -// always correspond to the gyrostamps because it would require additional -// extrapolation if I wanted to do otherwise. -PoseState SensorFusionEkf::GetLatestPoseState() const { return current_state_; } - -void SensorFusionEkf::ProcessGyroscopeSample(const GyroscopeData& sample) -{ - // Don't accept gyroscope sample when waiting for a reset. - if (execute_reset_with_next_accelerometer_sample_) { - return; - } - - // Discard outdated samples. - if (current_gyroscope_sensor_timestamp_ns_ >= sample.sensor_timestamp_ns) { - current_gyroscope_sensor_timestamp_ns_ = sample.sensor_timestamp_ns; - return; - } - - // Checks that we received at least one gyroscope sample in the past. - if (current_gyroscope_sensor_timestamp_ns_ != 0) { - double current_timestep_s = std::chrono::duration_cast>( - std::chrono::nanoseconds( - sample.sensor_timestamp_ns - current_gyroscope_sensor_timestamp_ns_)) - .count(); - if (current_timestep_s > kMaximumGyroscopeSampleDelay_s) { - if (is_gyroscope_filter_valid_) { - // Replaces the delta timestamp by the filtered estimates of the delta time. - current_timestep_s = filtered_gyroscope_timestep_s_; - } else { - current_timestep_s = kDefaultGyroscopeTimestep_s; - } - } else { - FilterGyroscopeTimestep(current_timestep_s); - } - - if (bias_estimation_enabled_) { - gyroscope_bias_estimator_.ProcessGyroscope(sample.data, sample.sensor_timestamp_ns); - - if (gyroscope_bias_estimator_.IsCurrentEstimateValid()) { - // As soon as the device is considered to be static, the bias estimator - // should have a precise estimate of the gyroscope bias. - gyroscope_bias_estimate_ = gyroscope_bias_estimator_.GetGyroscopeBias(); - } - } - - // Only integrate after receiving an accelerometer sample. - if (is_aligned_with_gravity_) { - const Rotation rotation_from_gyroscope = pose_prediction::GetRotationFromGyroscope( - { sample.data[0] - gyroscope_bias_estimate_[0], - sample.data[1] - gyroscope_bias_estimate_[1], - sample.data[2] - gyroscope_bias_estimate_[2] }, - current_timestep_s); - current_state_.sensor_from_start_rotation - = rotation_from_gyroscope * current_state_.sensor_from_start_rotation; - UpdateStateCovariance(RotationMatrixNH(rotation_from_gyroscope)); - state_covariance_ = state_covariance_ - + ((current_timestep_s * current_timestep_s) * process_covariance_); - } - } - - // Saves gyroscope event for future prediction. - current_state_.timestamp = sample.system_timestamp; - current_gyroscope_sensor_timestamp_ns_ = sample.sensor_timestamp_ns; - current_state_.sensor_from_start_rotation_velocity.Set( - sample.data[0] - gyroscope_bias_estimate_[0], sample.data[1] - gyroscope_bias_estimate_[1], - sample.data[2] - gyroscope_bias_estimate_[2]); -} - -Vector3 SensorFusionEkf::ComputeInnovation(const Rotation& pose) -{ - const Vector3 predicted_down_direction = pose * kCanonicalZDirection; - - const Rotation rotation - = Rotation::RotateInto(predicted_down_direction, accelerometer_measurement_); - Vector3 axis; - double angle; - rotation.GetAxisAndAngle(&axis, &angle); - return axis * angle; -} - -void SensorFusionEkf::ComputeMeasurementJacobian() -{ - for (int dof = 0; dof < 3; dof++) { - Vector3 delta = Vector3::Zero(); - delta[dof] = kFiniteDifferencingEpsilon; - - const Rotation epsilon_rotation = RotationFromVector(delta); - const Vector3 delta_rotation - = ComputeInnovation(epsilon_rotation * current_state_.sensor_from_start_rotation); - - const Vector3 col = (innovation_ - delta_rotation) / kFiniteDifferencingEpsilon; - accelerometer_measurement_jacobian_(0, dof) = col[0]; - accelerometer_measurement_jacobian_(1, dof) = col[1]; - accelerometer_measurement_jacobian_(2, dof) = col[2]; - } -} - -void SensorFusionEkf::ProcessAccelerometerSample(const AccelerometerData& sample) -{ - // Discard outdated samples. - if (current_accelerometer_sensor_timestamp_ns_ >= sample.sensor_timestamp_ns) { - current_accelerometer_sensor_timestamp_ns_ = sample.sensor_timestamp_ns; - return; - } - - // Call reset state if required. - if (execute_reset_with_next_accelerometer_sample_.exchange(false)) { - ResetState(); - } - - accelerometer_measurement_.Set(sample.data[0], sample.data[1], sample.data[2]); - current_accelerometer_sensor_timestamp_ns_ = sample.sensor_timestamp_ns; - - if (bias_estimation_enabled_) { - gyroscope_bias_estimator_.ProcessAccelerometer(sample.data, sample.sensor_timestamp_ns); - } - - if (!is_aligned_with_gravity_) { - // This is the first accelerometer measurement so it initializes the - // orientation estimate. - current_state_.sensor_from_start_rotation - = Rotation::RotateInto(kCanonicalZDirection, accelerometer_measurement_); - is_aligned_with_gravity_ = true; - - previous_accelerometer_norm_ = Length(accelerometer_measurement_); - return; - } - - UpdateMeasurementCovariance(); - - innovation_ = ComputeInnovation(current_state_.sensor_from_start_rotation); - ComputeMeasurementJacobian(); - - // S = H * P * H' + R - innovation_covariance_ = accelerometer_measurement_jacobian_ * state_covariance_ - * Transpose(accelerometer_measurement_jacobian_) - + accelerometer_measurement_covariance_; - - // K = P * H' * S^-1 - kalman_gain_ = state_covariance_ * Transpose(accelerometer_measurement_jacobian_) - * Inverse(innovation_covariance_); - - // x_update = K*nu - state_update_ = kalman_gain_ * innovation_; - - // P = (I - K * H) * P; - state_covariance_ = (Matrix3x3::Identity() - kalman_gain_ * accelerometer_measurement_jacobian_) - * state_covariance_; - - // Updates pose and associate covariance matrix. - const Rotation rotation_from_state_update = RotationFromVector(state_update_); - - current_state_.sensor_from_start_rotation - = rotation_from_state_update * current_state_.sensor_from_start_rotation; - UpdateStateCovariance(RotationMatrixNH(rotation_from_state_update)); -} - -void SensorFusionEkf::UpdateStateCovariance(const Matrix3x3& motion_update) -{ - state_covariance_ = motion_update * state_covariance_ * Transpose(motion_update); -} - -void SensorFusionEkf::FilterGyroscopeTimestep(double gyroscope_timestep_s) -{ - if (!is_timestep_filter_initialized_) { - // Initializes the filter. - filtered_gyroscope_timestep_s_ = gyroscope_timestep_s; - num_gyroscope_timestep_samples_ = 1; - is_timestep_filter_initialized_ = true; - return; - } - - // Computes the IIR filter response. - filtered_gyroscope_timestep_s_ = kTimestepFilterCoeff * filtered_gyroscope_timestep_s_ - + (1 - kTimestepFilterCoeff) * gyroscope_timestep_s; - ++num_gyroscope_timestep_samples_; - - if (num_gyroscope_timestep_samples_ > kTimestepFilterMinSamples) { - is_gyroscope_filter_valid_ = true; - } -} - -void SensorFusionEkf::UpdateMeasurementCovariance() -{ - const double current_accelerometer_norm = Length(accelerometer_measurement_); - // Norm change between current and previous accel readings. - const double current_accelerometer_norm_change - = std::abs(current_accelerometer_norm - previous_accelerometer_norm_); - previous_accelerometer_norm_ = current_accelerometer_norm; - - moving_average_accelerometer_norm_change_ = kSmoothingFactor * current_accelerometer_norm_change - + (1 - kSmoothingFactor) * moving_average_accelerometer_norm_change_; - - // If we hit the accel norm change threshold, we use the maximum noise sigma - // for the accel covariance. For anything below that, we use a linear - // combination between min and max sigma values. - const double norm_change_ratio - = moving_average_accelerometer_norm_change_ / kMaxAccelNormChange; - const double accelerometer_noise_sigma = std::min(kMaxAccelNoiseSigma, - kMinAccelNoiseSigma + norm_change_ratio * (kMaxAccelNoiseSigma - kMinAccelNoiseSigma)); - - // Updates the accel covariance matrix with the new sigma value. - accelerometer_measurement_covariance_ - = Matrix3x3::Identity() * accelerometer_noise_sigma * accelerometer_noise_sigma; -} - -bool SensorFusionEkf::IsBiasEstimationEnabled() const { return bias_estimation_enabled_; } - -void SensorFusionEkf::SetBiasEstimationEnabled(bool enable) -{ - if (bias_estimation_enabled_ != enable) { - bias_estimation_enabled_ = enable; - gyroscope_bias_estimate_ = { 0, 0, 0 }; - gyroscope_bias_estimator_.Reset(); - } -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.h b/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.h deleted file mode 100644 index a66fe33f4..000000000 --- a/applications/plugins/airmouse/tracking/sensors/sensor_fusion_ekf.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_SENSORS_SENSOR_FUSION_EKF_H_ -#define CARDBOARD_SDK_SENSORS_SENSOR_FUSION_EKF_H_ - -#include -#include -#include - -#include "accelerometer_data.h" -#include "gyroscope_bias_estimator.h" -#include "gyroscope_data.h" -#include "pose_state.h" -#include "../util/matrix_3x3.h" -#include "../util/rotation.h" -#include "../util/vector.h" - -namespace cardboard { - -// Sensor fusion class that implements an Extended Kalman Filter (EKF) to -// estimate a 3D rotation from a gyroscope and an accelerometer. -// This system only has one state, the pose. It does not estimate any velocity -// or acceleration. -// -// To learn more about Kalman filtering one can read this article which is a -// good introduction: https://en.wikipedia.org/wiki/Kalman_filter -class SensorFusionEkf { -public: - SensorFusionEkf(); - - // Resets the state of the sensor fusion. It sets the velocity for - // prediction to zero. The reset will happen with the next - // accelerometer sample. Gyroscope sample will be discarded until a new - // accelerometer sample arrives. - void Reset(); - - // Gets the PoseState representing the latest pose and derivatives at a - // particular timestamp as estimated by SensorFusion. - PoseState GetLatestPoseState() const; - - // Processes one gyroscope sample event. This updates the pose of the system - // and the prediction model. The gyroscope data is assumed to be in axis angle - // form. Angle = ||v|| and Axis = v / ||v||, with v = [v_x, v_y, v_z]^T. - // - // @param sample gyroscope sample data. - void ProcessGyroscopeSample(const GyroscopeData& sample); - - // Processes one accelerometer sample event. This updates the pose of the - // system. If the Accelerometer norm changes too much between sample it is not - // trusted as much. - // - // @param sample accelerometer sample data. - void ProcessAccelerometerSample(const AccelerometerData& sample); - - // Enables or disables the drift correction by estimating the gyroscope bias. - // - // @param enable Enable drift correction. - void SetBiasEstimationEnabled(bool enable); - - // Returns a boolean that indicates if bias estimation is enabled or disabled. - // - // @return true if bias estimation is enabled, false otherwise. - bool IsBiasEstimationEnabled() const; - - // Returns the current gyroscope bias estimate from GyroscopeBiasEstimator. - Vector3 GetGyroscopeBias() const { - return { - gyroscope_bias_estimate_[0], gyroscope_bias_estimate_[1], gyroscope_bias_estimate_[2]}; - } - - // Returns true after receiving the first accelerometer measurement. - bool IsFullyInitialized() const { - return is_aligned_with_gravity_; - } - -private: - // Estimates the average timestep between gyroscope event. - void FilterGyroscopeTimestep(double gyroscope_timestep); - - // Updates the state covariance with an incremental motion. It changes the - // space of the quadric. - void UpdateStateCovariance(const Matrix3x3& motion_update); - - // Computes the innovation vector of the Kalman based on the input pose. - // It uses the latest measurement vector (i.e. accelerometer data), which must - // be set prior to calling this function. - Vector3 ComputeInnovation(const Rotation& pose); - - // This computes the measurement_jacobian_ via numerical differentiation based - // on the current value of sensor_from_start_rotation_. - void ComputeMeasurementJacobian(); - - // Updates the accelerometer covariance matrix. - // - // This looks at the norm of recent accelerometer readings. If it has changed - // significantly, it means the phone receives additional acceleration than - // just gravity, and so the down vector information gravity signal is noisier. - void UpdateMeasurementCovariance(); - - // Reset all internal states. This is not thread safe. Lock should be acquired - // outside of it. This function is called in ProcessAccelerometerSample. - void ResetState(); - - // Current transformation from Sensor Space to Start Space. - // x_sensor = sensor_from_start_rotation_ * x_start; - PoseState current_state_; - - // Filtering of the gyroscope timestep started? - bool is_timestep_filter_initialized_; - // Filtered gyroscope timestep valid? - bool is_gyroscope_filter_valid_; - // Sensor fusion currently aligned with gravity? After initialization - // it will requires a couple of accelerometer data for the system to get - // aligned. - std::atomic is_aligned_with_gravity_; - - // Covariance of Kalman filter state (P in common formulation). - Matrix3x3 state_covariance_; - // Covariance of the process noise (Q in common formulation). - Matrix3x3 process_covariance_; - // Covariance of the accelerometer measurement (R in common formulation). - Matrix3x3 accelerometer_measurement_covariance_; - // Covariance of innovation (S in common formulation). - Matrix3x3 innovation_covariance_; - // Jacobian of the measurements (H in common formulation). - Matrix3x3 accelerometer_measurement_jacobian_; - // Gain of the Kalman filter (K in common formulation). - Matrix3x3 kalman_gain_; - // Parameter update a.k.a. innovation vector. (\nu in common formulation). - Vector3 innovation_; - // Measurement vector (z in common formulation). - Vector3 accelerometer_measurement_; - // Current prediction vector (g in common formulation). - Vector3 prediction_; - // Control input, currently this is only the gyroscope data (\mu in common - // formulation). - Vector3 control_input_; - // Update of the state vector. (x in common formulation). - Vector3 state_update_; - - // Sensor time of the last gyroscope processed event. - uint64_t current_gyroscope_sensor_timestamp_ns_; - // Sensor time of the last accelerometer processed event. - uint64_t current_accelerometer_sensor_timestamp_ns_; - - // Estimates of the timestep between gyroscope event in seconds. - double filtered_gyroscope_timestep_s_; - // Number of timestep samples processed so far by the filter. - uint32_t num_gyroscope_timestep_samples_; - // Norm of the accelerometer for the previous measurement. - double previous_accelerometer_norm_; - // Moving average of the accelerometer norm changes. It is computed for every - // sensor datum. - double moving_average_accelerometer_norm_change_; - - // Flag indicating if a state reset should be executed with the next - // accelerometer sample. - std::atomic execute_reset_with_next_accelerometer_sample_; - - // Flag indicating if bias estimation is enabled (enabled by default). - std::atomic bias_estimation_enabled_; - - // Bias estimator and static device detector. - GyroscopeBiasEstimator gyroscope_bias_estimator_; - - // Current bias estimate_; - Vector3 gyroscope_bias_estimate_; - - SensorFusionEkf(const SensorFusionEkf&) = delete; - SensorFusionEkf& operator=(const SensorFusionEkf&) = delete; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_SENSORS_SENSOR_FUSION_EKF_H_ diff --git a/applications/plugins/airmouse/tracking/util/logging.h b/applications/plugins/airmouse/tracking/util/logging.h deleted file mode 100644 index dee224b1c..000000000 --- a/applications/plugins/airmouse/tracking/util/logging.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_LOGGING_H_ -#define CARDBOARD_SDK_UTIL_LOGGING_H_ - -#include -#include - -#if defined(__ANDROID__) - -#include - -// Uncomment these to enable debug logging from native code - -#define CARDBOARD_LOGI(...) // __android_log_print(ANDROID_LOG_INFO, "CardboardSDK", __VA_ARGS__) -#define CARDBOARD_LOGE(...) // __android_log_print(ANDROID_LOG_ERROR, "CardboardSDK", __VA_ARGS__) - -#else - -#define CARDBOARD_LOGI(...) // FURI_LOG_I("CardboardSDK", __VA_ARGS__) -#define CARDBOARD_LOGE(...) // FURI_LOG_E("CardboardSDK", __VA_ARGS__) - -#endif - -#endif // CARDBOARD_SDK_UTIL_LOGGING_H_ diff --git a/applications/plugins/airmouse/tracking/util/matrix_3x3.cc b/applications/plugins/airmouse/tracking/util/matrix_3x3.cc deleted file mode 100644 index 9ddd847b0..000000000 --- a/applications/plugins/airmouse/tracking/util/matrix_3x3.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "matrix_3x3.h" - -namespace cardboard { - -Matrix3x3::Matrix3x3(double m00, double m01, double m02, double m10, double m11, double m12, - double m20, double m21, double m22) - : elem_ { { { m00, m01, m02 }, { m10, m11, m12 }, { m20, m21, m22 } } } -{ -} - -Matrix3x3::Matrix3x3() -{ - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - elem_[row][col] = 0; - } -} - -Matrix3x3 Matrix3x3::Zero() -{ - Matrix3x3 result; - return result; -} - -Matrix3x3 Matrix3x3::Identity() -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - result.elem_[row][row] = 1; - } - return result; -} - -void Matrix3x3::MultiplyScalar(double s) -{ - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - elem_[row][col] *= s; - } -} - -Matrix3x3 Matrix3x3::Negation() const -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result.elem_[row][col] = -elem_[row][col]; - } - return result; -} - -Matrix3x3 Matrix3x3::Scale(const Matrix3x3& m, double s) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result.elem_[row][col] = m.elem_[row][col] * s; - } - return result; -} - -Matrix3x3 Matrix3x3::Addition(const Matrix3x3& lhs, const Matrix3x3& rhs) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result.elem_[row][col] = lhs.elem_[row][col] + rhs.elem_[row][col]; - } - return result; -} - -Matrix3x3 Matrix3x3::Subtraction(const Matrix3x3& lhs, const Matrix3x3& rhs) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result.elem_[row][col] = lhs.elem_[row][col] - rhs.elem_[row][col]; - } - return result; -} - -Matrix3x3 Matrix3x3::Product(const Matrix3x3& m0, const Matrix3x3& m1) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - result.elem_[row][col] = 0; - for (int i = 0; i < 3; ++i) - result.elem_[row][col] += m0.elem_[row][i] * m1.elem_[i][col]; - } - } - return result; -} - -bool Matrix3x3::AreEqual(const Matrix3x3& m0, const Matrix3x3& m1) -{ - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) { - if (m0.elem_[row][col] != m1.elem_[row][col]) - return false; - } - } - return true; -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/util/matrix_3x3.h b/applications/plugins/airmouse/tracking/util/matrix_3x3.h deleted file mode 100644 index 81e4f2158..000000000 --- a/applications/plugins/airmouse/tracking/util/matrix_3x3.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_MATRIX_3X3_H_ -#define CARDBOARD_SDK_UTIL_MATRIX_3X3_H_ - -#include -#include // For memcpy(). -#include // NOLINT -#include // NOLINT - -namespace cardboard { - -// The Matrix3x3 class defines a square 3-dimensional matrix. Elements are -// stored in row-major order. -// TODO(b/135461889): Make this class consistent with Matrix4x4. -class Matrix3x3 { -public: - // The default constructor zero-initializes all elements. - Matrix3x3(); - - // Dimension-specific constructors that are passed individual element values. - Matrix3x3( - double m00, - double m01, - double m02, - double m10, - double m11, - double m12, - double m20, - double m21, - double m22); - - // Constructor that reads elements from a linear array of the correct size. - explicit Matrix3x3(const double array[3 * 3]); - - // Returns a Matrix3x3 containing all zeroes. - static Matrix3x3 Zero(); - - // Returns an identity Matrix3x3. - static Matrix3x3 Identity(); - - // Mutable element accessors. - double& operator()(int row, int col) { - return elem_[row][col]; - } - std::array& operator[](int row) { - return elem_[row]; - } - - // Read-only element accessors. - const double& operator()(int row, int col) const { - return elem_[row][col]; - } - const std::array& operator[](int row) const { - return elem_[row]; - } - - // Return a pointer to the data for interfacing with libraries. - double* Data() { - return &elem_[0][0]; - } - const double* Data() const { - return &elem_[0][0]; - } - - // Self-modifying multiplication operators. - void operator*=(double s) { - MultiplyScalar(s); - } - void operator*=(const Matrix3x3& m) { - *this = Product(*this, m); - } - - // Unary operators. - Matrix3x3 operator-() const { - return Negation(); - } - - // Binary scale operators. - friend Matrix3x3 operator*(const Matrix3x3& m, double s) { - return Scale(m, s); - } - friend Matrix3x3 operator*(double s, const Matrix3x3& m) { - return Scale(m, s); - } - - // Binary matrix addition. - friend Matrix3x3 operator+(const Matrix3x3& lhs, const Matrix3x3& rhs) { - return Addition(lhs, rhs); - } - - // Binary matrix subtraction. - friend Matrix3x3 operator-(const Matrix3x3& lhs, const Matrix3x3& rhs) { - return Subtraction(lhs, rhs); - } - - // Binary multiplication operator. - friend Matrix3x3 operator*(const Matrix3x3& m0, const Matrix3x3& m1) { - return Product(m0, m1); - } - - // Exact equality and inequality comparisons. - friend bool operator==(const Matrix3x3& m0, const Matrix3x3& m1) { - return AreEqual(m0, m1); - } - friend bool operator!=(const Matrix3x3& m0, const Matrix3x3& m1) { - return !AreEqual(m0, m1); - } - -private: - // These private functions implement most of the operators. - void MultiplyScalar(double s); - Matrix3x3 Negation() const; - static Matrix3x3 Addition(const Matrix3x3& lhs, const Matrix3x3& rhs); - static Matrix3x3 Subtraction(const Matrix3x3& lhs, const Matrix3x3& rhs); - static Matrix3x3 Scale(const Matrix3x3& m, double s); - static Matrix3x3 Product(const Matrix3x3& m0, const Matrix3x3& m1); - static bool AreEqual(const Matrix3x3& m0, const Matrix3x3& m1); - - std::array, 3> elem_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_MATRIX_3X3_H_ diff --git a/applications/plugins/airmouse/tracking/util/matrix_4x4.cc b/applications/plugins/airmouse/tracking/util/matrix_4x4.cc deleted file mode 100644 index 8db3cbc5b..000000000 --- a/applications/plugins/airmouse/tracking/util/matrix_4x4.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "matrix_4x4.h" - -#include -#include -#include - -namespace cardboard { - -Matrix4x4 Matrix4x4::Identity() -{ - Matrix4x4 ret; - for (int j = 0; j < 4; ++j) { - for (int i = 0; i < 4; ++i) { - ret.m[j][i] = (i == j) ? 1 : 0; - } - } - - return ret; -} - -Matrix4x4 Matrix4x4::Zeros() -{ - Matrix4x4 ret; - for (int j = 0; j < 4; ++j) { - for (int i = 0; i < 4; ++i) { - ret.m[j][i] = 0; - } - } - - return ret; -} - -Matrix4x4 Matrix4x4::Translation(float x, float y, float z) -{ - Matrix4x4 ret = Matrix4x4::Identity(); - ret.m[3][0] = x; - ret.m[3][1] = y; - ret.m[3][2] = z; - - return ret; -} - -Matrix4x4 Matrix4x4::Perspective(const std::array& fov, float zNear, float zFar) -{ - Matrix4x4 ret = Matrix4x4::Zeros(); - - const float xLeft = -std::tan(fov[0] * M_PI / 180.0f) * zNear; - const float xRight = std::tan(fov[1] * M_PI / 180.0f) * zNear; - const float yBottom = -std::tan(fov[2] * M_PI / 180.0f) * zNear; - const float yTop = std::tan(fov[3] * M_PI / 180.0f) * zNear; - - const float X = (2 * zNear) / (xRight - xLeft); - const float Y = (2 * zNear) / (yTop - yBottom); - const float A = (xRight + xLeft) / (xRight - xLeft); - const float B = (yTop + yBottom) / (yTop - yBottom); - const float C = (zNear + zFar) / (zNear - zFar); - const float D = (2 * zNear * zFar) / (zNear - zFar); - - ret.m[0][0] = X; - ret.m[2][0] = A; - ret.m[1][1] = Y; - ret.m[2][1] = B; - ret.m[2][2] = C; - ret.m[3][2] = D; - ret.m[2][3] = -1; - - return ret; -} - -void Matrix4x4::ToArray(float* array) const { std::memcpy(array, &m[0][0], 16 * sizeof(float)); } - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/util/matrix_4x4.h b/applications/plugins/airmouse/tracking/util/matrix_4x4.h deleted file mode 100644 index 9934f6be0..000000000 --- a/applications/plugins/airmouse/tracking/util/matrix_4x4.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_MATRIX_4X4_H_ -#define CARDBOARD_SDK_UTIL_MATRIX_4X4_H_ - -#include - -namespace cardboard { - -class Matrix4x4 { -public: - static Matrix4x4 Identity(); - static Matrix4x4 Zeros(); - static Matrix4x4 Translation(float x, float y, float z); - static Matrix4x4 Perspective(const std::array& fov, float zNear, float zFar); - void ToArray(float* array) const; - -private: - std::array, 4> m; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_MATRIX4X4_H_ diff --git a/applications/plugins/airmouse/tracking/util/matrixutils.cc b/applications/plugins/airmouse/tracking/util/matrixutils.cc deleted file mode 100644 index 12470beae..000000000 --- a/applications/plugins/airmouse/tracking/util/matrixutils.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "matrixutils.h" - -#include "vectorutils.h" - -namespace cardboard { - -namespace { - - // Returns true if the cofactor for a given row and column should be negated. - static bool IsCofactorNegated(int row, int col) - { - // Negated iff (row + col) is odd. - return ((row + col) & 1) != 0; - } - - static double CofactorElement3(const Matrix3x3& m, int row, int col) - { - static const int index[3][2] = { { 1, 2 }, { 0, 2 }, { 0, 1 } }; - const int i0 = index[row][0]; - const int i1 = index[row][1]; - const int j0 = index[col][0]; - const int j1 = index[col][1]; - const double cofactor = m(i0, j0) * m(i1, j1) - m(i0, j1) * m(i1, j0); - return IsCofactorNegated(row, col) ? -cofactor : cofactor; - } - - // Multiplies a matrix and some type of column vector to - // produce another column vector of the same type. - Vector3 MultiplyMatrixAndVector(const Matrix3x3& m, const Vector3& v) - { - Vector3 result = Vector3::Zero(); - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result[row] += m(row, col) * v[col]; - } - return result; - } - - // Sets the upper 3x3 of a Matrix to represent a 3D rotation. - void RotationMatrix3x3(const Rotation& r, Matrix3x3* matrix) - { - // - // Given a quaternion (a,b,c,d) where d is the scalar part, the 3x3 rotation - // matrix is: - // - // a^2 - b^2 - c^2 + d^2 2ab - 2cd 2ac + 2bd - // 2ab + 2cd -a^2 + b^2 - c^2 + d^2 2bc - 2ad - // 2ac - 2bd 2bc + 2ad -a^2 - b^2 + c^2 + d^2 - // - const Vector<4>& quat = r.GetQuaternion(); - const double aa = quat[0] * quat[0]; - const double bb = quat[1] * quat[1]; - const double cc = quat[2] * quat[2]; - const double dd = quat[3] * quat[3]; - - const double ab = quat[0] * quat[1]; - const double ac = quat[0] * quat[2]; - const double bc = quat[1] * quat[2]; - - const double ad = quat[0] * quat[3]; - const double bd = quat[1] * quat[3]; - const double cd = quat[2] * quat[3]; - - Matrix3x3& m = *matrix; - m[0][0] = aa - bb - cc + dd; - m[0][1] = 2 * ab - 2 * cd; - m[0][2] = 2 * ac + 2 * bd; - m[1][0] = 2 * ab + 2 * cd; - m[1][1] = -aa + bb - cc + dd; - m[1][2] = 2 * bc - 2 * ad; - m[2][0] = 2 * ac - 2 * bd; - m[2][1] = 2 * bc + 2 * ad; - m[2][2] = -aa - bb + cc + dd; - } - -} // anonymous namespace - -Vector3 operator*(const Matrix3x3& m, const Vector3& v) { return MultiplyMatrixAndVector(m, v); } - -Matrix3x3 CofactorMatrix(const Matrix3x3& m) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result(row, col) = CofactorElement3(m, row, col); - } - return result; -} - -Matrix3x3 AdjugateWithDeterminant(const Matrix3x3& m, double* determinant) -{ - const Matrix3x3 cofactor_matrix = CofactorMatrix(m); - if (determinant) { - *determinant = m(0, 0) * cofactor_matrix(0, 0) + m(0, 1) * cofactor_matrix(0, 1) - + m(0, 2) * cofactor_matrix(0, 2); - } - return Transpose(cofactor_matrix); -} - -// Returns the transpose of a matrix. -Matrix3x3 Transpose(const Matrix3x3& m) -{ - Matrix3x3 result; - for (int row = 0; row < 3; ++row) { - for (int col = 0; col < 3; ++col) - result(row, col) = m(col, row); - } - return result; -} - -Matrix3x3 InverseWithDeterminant(const Matrix3x3& m, double* determinant) -{ - // The inverse is the adjugate divided by the determinant. - double det; - Matrix3x3 adjugate = AdjugateWithDeterminant(m, &det); - if (determinant) - *determinant = det; - if (det == 0) - return Matrix3x3::Zero(); - else - return adjugate * (1 / det); -} - -Matrix3x3 Inverse(const Matrix3x3& m) { return InverseWithDeterminant(m, nullptr); } - -Matrix3x3 RotationMatrixNH(const Rotation& r) -{ - Matrix3x3 m; - RotationMatrix3x3(r, &m); - return m; -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/util/matrixutils.h b/applications/plugins/airmouse/tracking/util/matrixutils.h deleted file mode 100644 index 80f9b2168..000000000 --- a/applications/plugins/airmouse/tracking/util/matrixutils.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_MATRIXUTILS_H_ -#define CARDBOARD_SDK_UTIL_MATRIXUTILS_H_ - -// -// This file contains operators and free functions that define generic Matrix -// operations. -// - -#include "matrix_3x3.h" -#include "rotation.h" -#include "vector.h" - -namespace cardboard { - -// Returns the transpose of a matrix. -Matrix3x3 Transpose(const Matrix3x3& m); - -// Multiplies a Matrix and a column Vector of the same Dimension to produce -// another column Vector. -Vector3 operator*(const Matrix3x3& m, const Vector3& v); - -// Returns the determinant of the matrix. This function is defined for all the -// typedef'ed Matrix types. -double Determinant(const Matrix3x3& m); - -// Returns the adjugate of the matrix, which is defined as the transpose of the -// cofactor matrix. This function is defined for all the typedef'ed Matrix -// types. The determinant of the matrix is computed as a side effect, so it is -// returned in the determinant parameter if it is not null. -Matrix3x3 AdjugateWithDeterminant(const Matrix3x3& m, double* determinant); - -// Returns the inverse of the matrix. This function is defined for all the -// typedef'ed Matrix types. The determinant of the matrix is computed as a -// side effect, so it is returned in the determinant parameter if it is not -// null. If the determinant is 0, the returned matrix has all zeroes. -Matrix3x3 InverseWithDeterminant(const Matrix3x3& m, double* determinant); - -// Returns the inverse of the matrix. This function is defined for all the -// typedef'ed Matrix types. If the determinant of the matrix is 0, the returned -// matrix has all zeroes. -Matrix3x3 Inverse(const Matrix3x3& m); - -// Returns a 3x3 Matrix representing a 3D rotation. This creates a Matrix that -// does not work with homogeneous coordinates, so the function name ends in -// "NH". -Matrix3x3 RotationMatrixNH(const Rotation& r); - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_MATRIXUTILS_H_ diff --git a/applications/plugins/airmouse/tracking/util/rotation.cc b/applications/plugins/airmouse/tracking/util/rotation.cc deleted file mode 100644 index 5c3d09a2b..000000000 --- a/applications/plugins/airmouse/tracking/util/rotation.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "rotation.h" - -#include -#include - -#include "vectorutils.h" - -namespace cardboard { - -void Rotation::SetAxisAndAngle(const VectorType& axis, double angle) -{ - VectorType unit_axis = axis; - if (!Normalize(&unit_axis)) { - *this = Identity(); - } else { - double a = angle / 2; - const double s = sin(a); - const VectorType v(unit_axis * s); - SetQuaternion(QuaternionType(v[0], v[1], v[2], cos(a))); - } -} - -Rotation Rotation::FromRotationMatrix(const Matrix3x3& mat) -{ - static const double kOne = 1.0; - static const double kFour = 4.0; - - const double d0 = mat(0, 0), d1 = mat(1, 1), d2 = mat(2, 2); - const double ww = kOne + d0 + d1 + d2; - const double xx = kOne + d0 - d1 - d2; - const double yy = kOne - d0 + d1 - d2; - const double zz = kOne - d0 - d1 + d2; - - const double max = std::max(ww, std::max(xx, std::max(yy, zz))); - if (ww == max) { - const double w4 = sqrt(ww * kFour); - return Rotation::FromQuaternion(QuaternionType((mat(2, 1) - mat(1, 2)) / w4, - (mat(0, 2) - mat(2, 0)) / w4, (mat(1, 0) - mat(0, 1)) / w4, w4 / kFour)); - } - - if (xx == max) { - const double x4 = sqrt(xx * kFour); - return Rotation::FromQuaternion(QuaternionType(x4 / kFour, (mat(0, 1) + mat(1, 0)) / x4, - (mat(0, 2) + mat(2, 0)) / x4, (mat(2, 1) - mat(1, 2)) / x4)); - } - - if (yy == max) { - const double y4 = sqrt(yy * kFour); - return Rotation::FromQuaternion(QuaternionType((mat(0, 1) + mat(1, 0)) / y4, y4 / kFour, - (mat(1, 2) + mat(2, 1)) / y4, (mat(0, 2) - mat(2, 0)) / y4)); - } - - // zz is the largest component. - const double z4 = sqrt(zz * kFour); - return Rotation::FromQuaternion(QuaternionType((mat(0, 2) + mat(2, 0)) / z4, - (mat(1, 2) + mat(2, 1)) / z4, z4 / kFour, (mat(1, 0) - mat(0, 1)) / z4)); -} - -void Rotation::GetAxisAndAngle(VectorType* axis, double* angle) const -{ - VectorType vec(quat_[0], quat_[1], quat_[2]); - if (Normalize(&vec)) { - *angle = 2 * acos(quat_[3]); - *axis = vec; - } else { - *axis = VectorType(1, 0, 0); - *angle = 0.0; - } -} - -Rotation Rotation::RotateInto(const VectorType& from, const VectorType& to) -{ - static const double kTolerance = std::numeric_limits::epsilon() * 100; - - // Directly build the quaternion using the following technique: - // http://lolengine.net/blog/2014/02/24/quaternion-from-two-vectors-final - const double norm_u_norm_v = sqrt(LengthSquared(from) * LengthSquared(to)); - double real_part = norm_u_norm_v + Dot(from, to); - VectorType w; - if (real_part < kTolerance * norm_u_norm_v) { - // If |from| and |to| are exactly opposite, rotate 180 degrees around an - // arbitrary orthogonal axis. Axis normalization can happen later, when we - // normalize the quaternion. - real_part = 0.0; - w = (abs(from[0]) > abs(from[2])) ? VectorType(-from[1], from[0], 0) - : VectorType(0, -from[2], from[1]); - } else { - // Otherwise, build the quaternion the standard way. - w = Cross(from, to); - } - - // Build and return a normalized quaternion. - // Note that Rotation::FromQuaternion automatically performs normalization. - return Rotation::FromQuaternion(QuaternionType(w[0], w[1], w[2], real_part)); -} - -Rotation::VectorType Rotation::operator*(const Rotation::VectorType& v) const -{ - return ApplyToVector(v); -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/util/rotation.h b/applications/plugins/airmouse/tracking/util/rotation.h deleted file mode 100644 index 8730cb3b0..000000000 --- a/applications/plugins/airmouse/tracking/util/rotation.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_ROTATION_H_ -#define CARDBOARD_SDK_UTIL_ROTATION_H_ - -#include "matrix_3x3.h" -#include "vector.h" -#include "vectorutils.h" - -namespace cardboard { - -// The Rotation class represents a rotation around a 3-dimensional axis. It -// uses normalized quaternions internally to make the math robust. -class Rotation { -public: - // Convenience typedefs for vector of the correct type. - typedef Vector<3> VectorType; - typedef Vector<4> QuaternionType; - - // The default constructor creates an identity Rotation, which has no effect. - Rotation() { - quat_.Set(0, 0, 0, 1); - } - - // Returns an identity Rotation, which has no effect. - static Rotation Identity() { - return Rotation(); - } - - // Sets the Rotation from a quaternion (4D vector), which is first normalized. - void SetQuaternion(const QuaternionType& quaternion) { - quat_ = Normalized(quaternion); - } - - // Returns the Rotation as a normalized quaternion (4D vector). - const QuaternionType& GetQuaternion() const { - return quat_; - } - - // Sets the Rotation to rotate by the given angle around the given axis, - // following the right-hand rule. The axis does not need to be unit - // length. If it is zero length, this results in an identity Rotation. - void SetAxisAndAngle(const VectorType& axis, double angle); - - // Returns the right-hand rule axis and angle corresponding to the - // Rotation. If the Rotation is the identity rotation, this returns the +X - // axis and an angle of 0. - void GetAxisAndAngle(VectorType* axis, double* angle) const; - - // Convenience function that constructs and returns a Rotation given an axis - // and angle. - static Rotation FromAxisAndAngle(const VectorType& axis, double angle) { - Rotation r; - r.SetAxisAndAngle(axis, angle); - return r; - } - - // Convenience function that constructs and returns a Rotation given a - // quaternion. - static Rotation FromQuaternion(const QuaternionType& quat) { - Rotation r; - r.SetQuaternion(quat); - return r; - } - - // Convenience function that constructs and returns a Rotation given a - // rotation matrix R with $R^\top R = I && det(R) = 1$. - static Rotation FromRotationMatrix(const Matrix3x3& mat); - - // Convenience function that constructs and returns a Rotation given Euler - // angles that are applied in the order of rotate-Z by roll, rotate-X by - // pitch, rotate-Y by yaw (same as GetRollPitchYaw). - static Rotation FromRollPitchYaw(double roll, double pitch, double yaw) { - VectorType x(1, 0, 0), y(0, 1, 0), z(0, 0, 1); - return FromAxisAndAngle(z, roll) * (FromAxisAndAngle(x, pitch) * FromAxisAndAngle(y, yaw)); - } - - // Convenience function that constructs and returns a Rotation given Euler - // angles that are applied in the order of rotate-Y by yaw, rotate-X by - // pitch, rotate-Z by roll (same as GetYawPitchRoll). - static Rotation FromYawPitchRoll(double yaw, double pitch, double roll) { - VectorType x(1, 0, 0), y(0, 1, 0), z(0, 0, 1); - return FromAxisAndAngle(y, yaw) * (FromAxisAndAngle(x, pitch) * FromAxisAndAngle(z, roll)); - } - - // Constructs and returns a Rotation that rotates one vector to another along - // the shortest arc. This returns an identity rotation if either vector has - // zero length. - static Rotation RotateInto(const VectorType& from, const VectorType& to); - - // The negation operator returns the inverse rotation. - friend Rotation operator-(const Rotation& r) { - // Because we store normalized quaternions, the inverse is found by - // negating the vector part. - return Rotation(-r.quat_[0], -r.quat_[1], -r.quat_[2], r.quat_[3]); - } - - // Appends a rotation to this one. - Rotation& operator*=(const Rotation& r) { - const QuaternionType& qr = r.quat_; - QuaternionType& qt = quat_; - SetQuaternion(QuaternionType( - qr[3] * qt[0] + qr[0] * qt[3] + qr[2] * qt[1] - qr[1] * qt[2], - qr[3] * qt[1] + qr[1] * qt[3] + qr[0] * qt[2] - qr[2] * qt[0], - qr[3] * qt[2] + qr[2] * qt[3] + qr[1] * qt[0] - qr[0] * qt[1], - qr[3] * qt[3] - qr[0] * qt[0] - qr[1] * qt[1] - qr[2] * qt[2])); - return *this; - } - - // Binary multiplication operator - returns a composite Rotation. - friend const Rotation operator*(const Rotation& r0, const Rotation& r1) { - Rotation r = r0; - r *= r1; - return r; - } - - // Multiply a Rotation and a Vector to get a Vector. - VectorType operator*(const VectorType& v) const; - -private: - // Private constructor that builds a Rotation from quaternion components. - Rotation(double q0, double q1, double q2, double q3) - : quat_(q0, q1, q2, q3) { - } - - // Applies a Rotation to a Vector to rotate the Vector. Method borrowed from: - // http://blog.molecular-matters.com/2013/05/24/a-faster-quaternion-vector-multiplication/ - VectorType ApplyToVector(const VectorType& v) const { - VectorType im(quat_[0], quat_[1], quat_[2]); - VectorType temp = 2.0 * Cross(im, v); - return v + quat_[3] * temp + Cross(im, temp); - } - - // The rotation represented as a normalized quaternion. (Unit quaternions are - // required for constructing rotation matrices, so it makes sense to always - // store them that way.) The vector part is in the first 3 elements, and the - // scalar part is in the last element. - QuaternionType quat_; -}; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_ROTATION_H_ diff --git a/applications/plugins/airmouse/tracking/util/vector.h b/applications/plugins/airmouse/tracking/util/vector.h deleted file mode 100644 index 64c4f2546..000000000 --- a/applications/plugins/airmouse/tracking/util/vector.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_VECTOR_H_ -#define CARDBOARD_SDK_UTIL_VECTOR_H_ - -#include - -namespace cardboard { - -// Geometric N-dimensional Vector class. -template -class Vector { -public: - // The default constructor zero-initializes all elements. - Vector(); - - // Dimension-specific constructors that are passed individual element values. - constexpr Vector(double e0, double e1, double e2); - constexpr Vector(double e0, double e1, double e2, double e3); - - // Constructor for a Vector of dimension N from a Vector of dimension N-1 and - // a scalar of the correct type, assuming N is at least 2. - // constexpr Vector(const Vector& v, double s); - - void Set(double e0, double e1, double e2); // Only when Dimension == 3. - void Set(double e0, double e1, double e2, - double e3); // Only when Dimension == 4. - - // Mutable element accessor. - double& operator[](int index) { - return elem_[index]; - } - - // Element accessor. - double operator[](int index) const { - return elem_[index]; - } - - // Returns a Vector containing all zeroes. - static Vector Zero(); - - // Self-modifying operators. - void operator+=(const Vector& v) { - Add(v); - } - void operator-=(const Vector& v) { - Subtract(v); - } - void operator*=(double s) { - Multiply(s); - } - void operator/=(double s) { - Divide(s); - } - - // Unary negation operator. - Vector operator-() const { - return Negation(); - } - - // Binary operators. - friend Vector operator+(const Vector& v0, const Vector& v1) { - return Sum(v0, v1); - } - friend Vector operator-(const Vector& v0, const Vector& v1) { - return Difference(v0, v1); - } - friend Vector operator*(const Vector& v, double s) { - return Scale(v, s); - } - friend Vector operator*(double s, const Vector& v) { - return Scale(v, s); - } - friend Vector operator*(const Vector& v, const Vector& s) { - return Product(v, s); - } - friend Vector operator/(const Vector& v, double s) { - return Divide(v, s); - } - - // Self-modifying addition. - void Add(const Vector& v); - // Self-modifying subtraction. - void Subtract(const Vector& v); - // Self-modifying multiplication by a scalar. - void Multiply(double s); - // Self-modifying division by a scalar. - void Divide(double s); - - // Unary negation. - Vector Negation() const; - - // Binary component-wise multiplication. - static Vector Product(const Vector& v0, const Vector& v1); - // Binary component-wise addition. - static Vector Sum(const Vector& v0, const Vector& v1); - // Binary component-wise subtraction. - static Vector Difference(const Vector& v0, const Vector& v1); - // Binary multiplication by a scalar. - static Vector Scale(const Vector& v, double s); - // Binary division by a scalar. - static Vector Divide(const Vector& v, double s); - -private: - std::array elem_; -}; -//------------------------------------------------------------------------------ - -template -Vector::Vector() { - for(int i = 0; i < Dimension; i++) { - elem_[i] = 0; - } -} - -template -constexpr Vector::Vector(double e0, double e1, double e2) - : elem_{e0, e1, e2} { -} - -template -constexpr Vector::Vector(double e0, double e1, double e2, double e3) - : elem_{e0, e1, e2, e3} { -} -/* -template <> -constexpr Vector<4>::Vector(const Vector<3>& v, double s) - : elem_{v[0], v[1], v[2], s} {} -*/ -template -void Vector::Set(double e0, double e1, double e2) { - elem_[0] = e0; - elem_[1] = e1; - elem_[2] = e2; -} - -template -void Vector::Set(double e0, double e1, double e2, double e3) { - elem_[0] = e0; - elem_[1] = e1; - elem_[2] = e2; - elem_[3] = e3; -} - -template -Vector Vector::Zero() { - Vector v; - return v; -} - -template -void Vector::Add(const Vector& v) { - for(int i = 0; i < Dimension; i++) { - elem_[i] += v[i]; - } -} - -template -void Vector::Subtract(const Vector& v) { - for(int i = 0; i < Dimension; i++) { - elem_[i] -= v[i]; - } -} - -template -void Vector::Multiply(double s) { - for(int i = 0; i < Dimension; i++) { - elem_[i] *= s; - } -} - -template -void Vector::Divide(double s) { - for(int i = 0; i < Dimension; i++) { - elem_[i] /= s; - } -} - -template -Vector Vector::Negation() const { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = -elem_[i]; - } - return ret; -} - -template -Vector Vector::Product(const Vector& v0, const Vector& v1) { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = v0[i] * v1[i]; - } - return ret; -} - -template -Vector Vector::Sum(const Vector& v0, const Vector& v1) { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = v0[i] + v1[i]; - } - return ret; -} - -template -Vector Vector::Difference(const Vector& v0, const Vector& v1) { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = v0[i] - v1[i]; - } - return ret; -} - -template -Vector Vector::Scale(const Vector& v, double s) { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = v[i] * s; - } - return ret; -} - -template -Vector Vector::Divide(const Vector& v, double s) { - Vector ret; - for(int i = 0; i < Dimension; i++) { - ret.elem_[i] = v[i] / s; - } - return ret; -} - -typedef Vector<3> Vector3; -typedef Vector<4> Vector4; - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_VECTOR_H_ diff --git a/applications/plugins/airmouse/tracking/util/vectorutils.cc b/applications/plugins/airmouse/tracking/util/vectorutils.cc deleted file mode 100644 index b8f419c04..000000000 --- a/applications/plugins/airmouse/tracking/util/vectorutils.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "vectorutils.h" - -namespace cardboard { - -// Returns the dot (inner) product of two Vectors. -double Dot(const Vector<3>& v0, const Vector<3>& v1) -{ - return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; -} - -// Returns the dot (inner) product of two Vectors. -double Dot(const Vector<4>& v0, const Vector<4>& v1) -{ - return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2] + v0[3] * v1[3]; -} - -// Returns the 3-dimensional cross product of 2 Vectors. Note that this is -// defined only for 3-dimensional Vectors. -Vector<3> Cross(const Vector<3>& v0, const Vector<3>& v1) -{ - return Vector<3>(v0[1] * v1[2] - v0[2] * v1[1], v0[2] * v1[0] - v0[0] * v1[2], - v0[0] * v1[1] - v0[1] * v1[0]); -} - -} // namespace cardboard diff --git a/applications/plugins/airmouse/tracking/util/vectorutils.h b/applications/plugins/airmouse/tracking/util/vectorutils.h deleted file mode 100644 index 054236713..000000000 --- a/applications/plugins/airmouse/tracking/util/vectorutils.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2019 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef CARDBOARD_SDK_UTIL_VECTORUTILS_H_ -#define CARDBOARD_SDK_UTIL_VECTORUTILS_H_ - -// -// This file contains free functions that operate on Vector instances. -// - -#include - -#include "vector.h" - -namespace cardboard { - -// Returns the dot (inner) product of two Vectors. -double Dot(const Vector<3>& v0, const Vector<3>& v1); - -// Returns the dot (inner) product of two Vectors. -double Dot(const Vector<4>& v0, const Vector<4>& v1); - -// Returns the 3-dimensional cross product of 2 Vectors. Note that this is -// defined only for 3-dimensional Vectors. -Vector<3> Cross(const Vector<3>& v0, const Vector<3>& v1); - -// Returns the square of the length of a Vector. -template -double LengthSquared(const Vector& v) { - return Dot(v, v); -} - -// Returns the geometric length of a Vector. -template -double Length(const Vector& v) { - return sqrt(LengthSquared(v)); -} - -// the Vector untouched and returns false. -template -bool Normalize(Vector* v) { - const double len = Length(*v); - if(len == 0) { - return false; - } else { - (*v) /= len; - return true; - } -} - -// Returns a unit-length version of a Vector. If the given Vector has no -// length, this returns a Zero() Vector. -template -Vector Normalized(const Vector& v) { - Vector result = v; - if(Normalize(&result)) - return result; - else - return Vector::Zero(); -} - -} // namespace cardboard - -#endif // CARDBOARD_SDK_UTIL_VECTORUTILS_H_ diff --git a/applications/plugins/airmouse/views/bt_mouse.c b/applications/plugins/airmouse/views/bt_mouse.c deleted file mode 100644 index 1a6ea3020..000000000 --- a/applications/plugins/airmouse/views/bt_mouse.c +++ /dev/null @@ -1,157 +0,0 @@ -#include "bt_mouse.h" -#include "../tracking/main_loop.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -struct BtMouse { - View* view; - ViewDispatcher* view_dispatcher; - Bt* bt; - NotificationApp* notifications; -}; - -#define MOUSE_MOVE_SHORT 5 -#define MOUSE_MOVE_LONG 20 - -static void bt_mouse_draw_callback(Canvas* canvas, void* context) { - UNUSED(context); - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 10, "Bluetooth Mouse mode"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 0, 63, "Hold [back] to exit"); -} - -static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) { - with_view_model( - bt_mouse->view, - void* model, - { - UNUSED(model); - if(event->key == InputKeyUp) { - if(event->type == InputTypePress) { - furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_LEFT); - } else if(event->type == InputTypeRelease) { - furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_LEFT); - } - } else if(event->key == InputKeyDown) { - if(event->type == InputTypePress) { - furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_RIGHT); - } else if(event->type == InputTypeRelease) { - furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_RIGHT); - } - } else if(event->key == InputKeyOk) { - if(event->type == InputTypePress) { - furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_WHEEL); - } else if(event->type == InputTypeRelease) { - furi_hal_bt_hid_mouse_release(HID_MOUSE_BTN_WHEEL); - } - } - }, - true); -} - -static bool bt_mouse_input_callback(InputEvent* event, void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - bool consumed = false; - - if(event->type == InputTypeLong && event->key == InputKeyBack) { - furi_hal_bt_hid_mouse_release_all(); - } else { - bt_mouse_process(bt_mouse, event); - consumed = true; - } - - return consumed; -} - -void bt_mouse_connection_status_changed_callback(BtStatus status, void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - - bool connected = (status == BtStatusConnected); - if(connected) { - notification_internal_message(bt_mouse->notifications, &sequence_set_blue_255); - } else { - notification_internal_message(bt_mouse->notifications, &sequence_reset_blue); - } - - //with_view_model( - // bt_mouse->view, void * model, { model->connected = connected; }, true); -} - -void bt_mouse_enter_callback(void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - - bt_mouse->bt = furi_record_open(RECORD_BT); - bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION); - bt_set_status_changed_callback( - bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse); - furi_assert(bt_set_profile(bt_mouse->bt, BtProfileHidKeyboard)); - furi_hal_bt_start_advertising(); - - tracking_begin(); - - view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0); -} - -bool bt_mouse_custom_callback(uint32_t event, void* context) { - UNUSED(event); - furi_assert(context); - BtMouse* bt_mouse = context; - - tracking_step(furi_hal_bt_hid_mouse_move); - - view_dispatcher_send_custom_event(bt_mouse->view_dispatcher, 0); - return true; -} - -void bt_mouse_exit_callback(void* context) { - furi_assert(context); - BtMouse* bt_mouse = context; - - tracking_end(); - - notification_internal_message(bt_mouse->notifications, &sequence_reset_blue); - - furi_hal_bt_stop_advertising(); - bt_set_profile(bt_mouse->bt, BtProfileSerial); - - furi_record_close(RECORD_NOTIFICATION); - bt_mouse->notifications = NULL; - furi_record_close(RECORD_BT); - bt_mouse->bt = NULL; -} - -BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher) { - BtMouse* bt_mouse = malloc(sizeof(BtMouse)); - bt_mouse->view = view_alloc(); - bt_mouse->view_dispatcher = view_dispatcher; - view_set_context(bt_mouse->view, bt_mouse); - view_set_draw_callback(bt_mouse->view, bt_mouse_draw_callback); - view_set_input_callback(bt_mouse->view, bt_mouse_input_callback); - view_set_enter_callback(bt_mouse->view, bt_mouse_enter_callback); - view_set_custom_callback(bt_mouse->view, bt_mouse_custom_callback); - view_set_exit_callback(bt_mouse->view, bt_mouse_exit_callback); - return bt_mouse; -} - -void bt_mouse_free(BtMouse* bt_mouse) { - furi_assert(bt_mouse); - view_free(bt_mouse->view); - free(bt_mouse); -} - -View* bt_mouse_get_view(BtMouse* bt_mouse) { - furi_assert(bt_mouse); - return bt_mouse->view; -} diff --git a/applications/plugins/airmouse/views/bt_mouse.h b/applications/plugins/airmouse/views/bt_mouse.h deleted file mode 100644 index 09153d8fa..000000000 --- a/applications/plugins/airmouse/views/bt_mouse.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include -#include - -typedef struct BtMouse BtMouse; - -BtMouse* bt_mouse_alloc(ViewDispatcher* view_dispatcher); - -void bt_mouse_free(BtMouse* bt_mouse); - -View* bt_mouse_get_view(BtMouse* bt_mouse); - -void bt_mouse_set_connected_status(BtMouse* bt_mouse, bool connected); diff --git a/applications/plugins/airmouse/views/calibration.c b/applications/plugins/airmouse/views/calibration.c deleted file mode 100644 index a92f68be4..000000000 --- a/applications/plugins/airmouse/views/calibration.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "calibration.h" -#include "../tracking/main_loop.h" -#include "../air_mouse.h" - -#include -#include - -struct Calibration { - View* view; - ViewDispatcher* view_dispatcher; -}; - -static void calibration_draw_callback(Canvas* canvas, void* context) { - UNUSED(context); - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 10, "Calibrating..."); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 0, 63, "Please wait"); -} - -void calibration_enter_callback(void* context) { - furi_assert(context); - Calibration* calibration = context; - calibration_begin(); - view_dispatcher_send_custom_event(calibration->view_dispatcher, 0); -} - -bool calibration_custom_callback(uint32_t event, void* context) { - UNUSED(event); - furi_assert(context); - Calibration* calibration = context; - - if(calibration_step()) { - view_dispatcher_switch_to_view(calibration->view_dispatcher, AirMouseViewSubmenu); - } else { - view_dispatcher_send_custom_event(calibration->view_dispatcher, 0); - } - - return true; -} - -void calibration_exit_callback(void* context) { - furi_assert(context); - calibration_end(); -} - -Calibration* calibration_alloc(ViewDispatcher* view_dispatcher) { - Calibration* calibration = malloc(sizeof(Calibration)); - calibration->view = view_alloc(); - calibration->view_dispatcher = view_dispatcher; - view_set_context(calibration->view, calibration); - view_set_draw_callback(calibration->view, calibration_draw_callback); - view_set_enter_callback(calibration->view, calibration_enter_callback); - view_set_custom_callback(calibration->view, calibration_custom_callback); - view_set_exit_callback(calibration->view, calibration_exit_callback); - return calibration; -} - -void calibration_free(Calibration* calibration) { - furi_assert(calibration); - view_free(calibration->view); - free(calibration); -} - -View* calibration_get_view(Calibration* calibration) { - furi_assert(calibration); - return calibration->view; -} diff --git a/applications/plugins/airmouse/views/calibration.h b/applications/plugins/airmouse/views/calibration.h deleted file mode 100644 index da44ce0cd..000000000 --- a/applications/plugins/airmouse/views/calibration.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -typedef struct Calibration Calibration; - -Calibration* calibration_alloc(ViewDispatcher* view_dispatcher); - -void calibration_free(Calibration* calibration); - -View* calibration_get_view(Calibration* calibration); diff --git a/applications/plugins/airmouse/views/usb_mouse.c b/applications/plugins/airmouse/views/usb_mouse.c deleted file mode 100644 index 2d5f1b0a9..000000000 --- a/applications/plugins/airmouse/views/usb_mouse.c +++ /dev/null @@ -1,124 +0,0 @@ -#include "usb_mouse.h" -#include "../tracking/main_loop.h" - -#include -#include -#include -#include - -struct UsbMouse { - View* view; - ViewDispatcher* view_dispatcher; - FuriHalUsbInterface* usb_mode_prev; -}; - -static void usb_mouse_draw_callback(Canvas* canvas, void* context) { - UNUSED(context); - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 10, "USB Mouse mode"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 0, 63, "Hold [back] to exit"); -} - -static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) { - with_view_model( - usb_mouse->view, - void* model, - { - UNUSED(model); - if(event->key == InputKeyUp) { - if(event->type == InputTypePress) { - furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT); - } else if(event->type == InputTypeRelease) { - furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT); - } - } else if(event->key == InputKeyDown) { - if(event->type == InputTypePress) { - furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT); - } else if(event->type == InputTypeRelease) { - furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT); - } - } else if(event->key == InputKeyOk) { - if(event->type == InputTypePress) { - furi_hal_hid_mouse_press(HID_MOUSE_BTN_WHEEL); - } else if(event->type == InputTypeRelease) { - furi_hal_hid_mouse_release(HID_MOUSE_BTN_WHEEL); - } - } - }, - true); -} - -static bool usb_mouse_input_callback(InputEvent* event, void* context) { - furi_assert(context); - UsbMouse* usb_mouse = context; - bool consumed = false; - - if(event->type == InputTypeLong && event->key == InputKeyBack) { - // furi_hal_hid_mouse_release_all(); - } else { - usb_mouse_process(usb_mouse, event); - consumed = true; - } - - return consumed; -} - -void usb_mouse_enter_callback(void* context) { - furi_assert(context); - UsbMouse* usb_mouse = context; - - usb_mouse->usb_mode_prev = furi_hal_usb_get_config(); - furi_hal_usb_unlock(); - furi_check(furi_hal_usb_set_config(&usb_hid, NULL) == true); - - tracking_begin(); - - view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0); -} - -bool usb_mouse_custom_callback(uint32_t event, void* context) { - UNUSED(event); - furi_assert(context); - UsbMouse* usb_mouse = context; - - tracking_step(furi_hal_hid_mouse_move); - furi_delay_ms(1); // Magic! Removing this will break the buttons - - view_dispatcher_send_custom_event(usb_mouse->view_dispatcher, 0); - return true; -} - -void usb_mouse_exit_callback(void* context) { - furi_assert(context); - UsbMouse* usb_mouse = context; - - tracking_end(); - - furi_hal_usb_set_config(usb_mouse->usb_mode_prev, NULL); -} - -UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher) { - UsbMouse* usb_mouse = malloc(sizeof(UsbMouse)); - usb_mouse->view = view_alloc(); - usb_mouse->view_dispatcher = view_dispatcher; - view_set_context(usb_mouse->view, usb_mouse); - view_set_draw_callback(usb_mouse->view, usb_mouse_draw_callback); - view_set_input_callback(usb_mouse->view, usb_mouse_input_callback); - view_set_enter_callback(usb_mouse->view, usb_mouse_enter_callback); - view_set_custom_callback(usb_mouse->view, usb_mouse_custom_callback); - view_set_exit_callback(usb_mouse->view, usb_mouse_exit_callback); - return usb_mouse; -} - -void usb_mouse_free(UsbMouse* usb_mouse) { - furi_assert(usb_mouse); - view_free(usb_mouse->view); - free(usb_mouse); -} - -View* usb_mouse_get_view(UsbMouse* usb_mouse) { - furi_assert(usb_mouse); - return usb_mouse->view; -} diff --git a/applications/plugins/airmouse/views/usb_mouse.h b/applications/plugins/airmouse/views/usb_mouse.h deleted file mode 100644 index 5ce589a69..000000000 --- a/applications/plugins/airmouse/views/usb_mouse.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -typedef struct UsbMouse UsbMouse; - -UsbMouse* usb_mouse_alloc(ViewDispatcher* view_dispatcher); - -void usb_mouse_free(UsbMouse* usb_mouse); - -View* usb_mouse_get_view(UsbMouse* usb_mouse); diff --git a/applications/plugins/am2320_temp_sensor/application.fam b/applications/plugins/am2320_temp_sensor/application.fam deleted file mode 100644 index f7b6dfbf2..000000000 --- a/applications/plugins/am2320_temp_sensor/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="AM2320_temp_sensor", - name="[AM2320] Temp. Sensor", - apptype=FlipperAppType.EXTERNAL, - entry_point="am_temperature_sensor_app", - cdefines=["APP_AM_TEMPERATURE_SENSOR"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=90, - fap_icon="temperature_sensor.png", - fap_category="GPIO", -) diff --git a/applications/plugins/am2320_temp_sensor/temperature_sensor.c b/applications/plugins/am2320_temp_sensor/temperature_sensor.c deleted file mode 100644 index 212014e22..000000000 --- a/applications/plugins/am2320_temp_sensor/temperature_sensor.c +++ /dev/null @@ -1,336 +0,0 @@ -/* Flipper Plugin to read the values from a AM2320/AM2321 Sensor */ -/* Created by @xMasterX, original app (was used as template) by Mywk - https://github.com/Mywk */ -/* Lib used as reference: https://github.com/Gozem/am2320/blob/master/am2321.c*/ -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#define TS_DEFAULT_VALUE 0xFFFF - -#define AM2320_ADDRESS (0x5C << 1) - -#define DATA_BUFFER_SIZE 8 - -// External I2C BUS -#define I2C_BUS &furi_hal_i2c_handle_external - -typedef enum { - TSSInitializing, - TSSNoSensor, - TSSPendingUpdate, -} TSStatus; - -typedef enum { - TSEventTypeTick, - TSEventTypeInput, -} TSEventType; - -typedef struct { - TSEventType type; - InputEvent input; -} TSEvent; - -extern const NotificationSequence sequence_blink_red_100; -extern const NotificationSequence sequence_blink_blue_100; - -static TSStatus temperature_sensor_current_status = TSSInitializing; - -// Temperature and Humidity data buffers, ready to print -char ts_data_buffer_temperature_c[DATA_BUFFER_SIZE]; -char ts_data_buffer_temperature_f[DATA_BUFFER_SIZE]; -char ts_data_buffer_relative_humidity[DATA_BUFFER_SIZE]; -char ts_data_buffer_absolute_humidity[DATA_BUFFER_SIZE]; - -// CRC16 calculation -static uint16_t get_crc16(const uint8_t* buf, size_t len) { - uint16_t crc = 0xFFFF; - - while(len--) { - crc ^= (uint16_t)*buf++; - for(unsigned i = 0; i < 8; i++) { - if(crc & 0x0001) { - crc >>= 1; - crc ^= 0xA001; - } else { - crc >>= 1; - } - } - } - - return crc; -} -// Combine bytes -static uint16_t combine_bytes(uint8_t msb, uint8_t lsb) { - return ((uint16_t)msb << 8) | (uint16_t)lsb; -} - -// Executes an I2C wake up, sends command and reads result -// true if fetch was successful, false otherwise -static bool temperature_sensor_get_data(uint8_t* buffer, uint8_t size) { - uint32_t timeout = furi_ms_to_ticks(100); - uint8_t cmdbuffer[3] = {0, 0, 0}; - bool ret = false; - - // Aquire I2C bus - furi_hal_i2c_acquire(I2C_BUS); - - // Wake UP AM2320 (sensor goes to sleep to not warm up and affect the humidity sensor) - furi_hal_i2c_is_device_ready(I2C_BUS, (uint8_t)AM2320_ADDRESS, timeout); - // Check if device woken up then we do next stuff - if(furi_hal_i2c_is_device_ready(I2C_BUS, (uint8_t)AM2320_ADDRESS, timeout)) { - // Wait a bit - furi_delay_us(1000); - - // Prepare command: Addr 0x03, start register = 0x00, number of registers to read = 0x04 - cmdbuffer[0] = 0x03; - cmdbuffer[1] = 0x00; - cmdbuffer[2] = 0x04; - - // Transmit command to read registers - ret = furi_hal_i2c_tx(I2C_BUS, (uint8_t)AM2320_ADDRESS, cmdbuffer, 3, timeout); - - // Wait a bit - furi_delay_us(1600); - if(ret) { - /* - * Read out 8 bytes of data - * Byte 0: Should be Modbus function code 0x03 - * Byte 1: Should be number of registers to read (0x04) - * Byte 2: Humidity msb - * Byte 3: Humidity lsb - * Byte 4: Temperature msb - * Byte 5: Temperature lsb - * Byte 6: CRC lsb byte - * Byte 7: CRC msb byte - */ - ret = furi_hal_i2c_rx(I2C_BUS, (uint8_t)AM2320_ADDRESS, buffer, size, timeout); - } - } - // Release i2c bus - furi_hal_i2c_release(I2C_BUS); - - return ret; -} - -// Fetches temperature and humidity from sensor -// Temperature and humidity must be preallocated -// true if fetch was successful, false otherwise -static bool temperature_sensor_fetch_info(double* temperature, double* humidity) { - *humidity = (float)0; - bool ret = false; - - uint8_t buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - - // Fetch data from sensor - ret = temperature_sensor_get_data(buffer, 8); - - // If we got no result - if(!ret) return false; - - if(buffer[0] != 0x03) return false; // must be 0x03 modbus reply - if(buffer[1] != 0x04) return false; // must be 0x04 number of registers reply - - // Check CRC16 sum, if not correct - return false - uint16_t crcdata = get_crc16(buffer, 6); - uint16_t crcread = combine_bytes(buffer[7], buffer[6]); - if(crcdata != crcread) return false; - - // Combine bytes for temp and humidity - uint16_t temp16 = combine_bytes(buffer[4], buffer[5]); - uint16_t humi16 = combine_bytes(buffer[2], buffer[3]); - - /* Temperature resolution is 16Bit, - * temperature highest bit (Bit15) is equal to 1 indicates a - * negative temperature, the temperature highest bit (Bit15) - * is equal to 0 indicates a positive temperature; - * temperature in addition to the most significant bit (Bit14 ~ Bit0) - * indicates the temperature sensor string value. - * Temperature sensor value is a string of 10 times the - * actual temperature value. - */ - if(temp16 & 0x8000) { - temp16 = -(temp16 & 0x7FFF); - } - - // Prepare output data - *temperature = (float)temp16 / 10.0; - *humidity = (float)humi16 / 10.0; - - return true; -} - -// Draw callback - -static void temperature_sensor_draw_callback(Canvas* canvas, void* ctx) { - UNUSED(ctx); - - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 10, "AM2320/AM2321 Sensor"); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 2, 62, "Press back to exit."); - - switch(temperature_sensor_current_status) { - case TSSInitializing: - canvas_draw_str(canvas, 2, 30, "Initializing.."); - break; - case TSSNoSensor: - canvas_draw_str(canvas, 2, 30, "No sensor found!"); - break; - case TSSPendingUpdate: { - canvas_draw_str(canvas, 3, 24, "Temperature"); - canvas_draw_str(canvas, 68, 24, "Humidity"); - - // Draw vertical lines - canvas_draw_line(canvas, 61, 16, 61, 50); - canvas_draw_line(canvas, 62, 16, 62, 50); - - // Draw horizontal line - canvas_draw_line(canvas, 2, 27, 122, 27); - - // Draw temperature and humidity values - canvas_draw_str(canvas, 8, 38, ts_data_buffer_temperature_c); - canvas_draw_str(canvas, 42, 38, "C"); - canvas_draw_str(canvas, 8, 48, ts_data_buffer_temperature_f); - canvas_draw_str(canvas, 42, 48, "F"); - canvas_draw_str(canvas, 68, 38, ts_data_buffer_relative_humidity); - canvas_draw_str(canvas, 100, 38, "%"); - canvas_draw_str(canvas, 68, 48, ts_data_buffer_absolute_humidity); - canvas_draw_str(canvas, 100, 48, "g/m3"); - - } break; - default: - break; - } -} - -// Input callback - -static void temperature_sensor_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); - FuriMessageQueue* event_queue = ctx; - - TSEvent event = {.type = TSEventTypeInput, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -// Timer callback - -static void temperature_sensor_timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - TSEvent event = {.type = TSEventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -// App entry point - -int32_t am_temperature_sensor_app(void* p) { - UNUSED(p); - - furi_hal_power_suppress_charge_enter(); - // Declare our variables and assign variables a default value - TSEvent tsEvent; - bool sensorFound = false; - double celsius, fahrenheit, rel_humidity, abs_humidity = TS_DEFAULT_VALUE; - - // Used for absolute humidity calculation - double vapour_pressure = 0; - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(TSEvent)); - - // Register callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, temperature_sensor_draw_callback, NULL); - view_port_input_callback_set(view_port, temperature_sensor_input_callback, event_queue); - - // Create timer and register its callback - FuriTimer* timer = - furi_timer_alloc(temperature_sensor_timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, furi_kernel_get_tick_frequency()); - - // Register viewport - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - // Used to notify the user by blinking red (error) or blue (fetch successful) - NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION); - - while(1) { - furi_check(furi_message_queue_get(event_queue, &tsEvent, FuriWaitForever) == FuriStatusOk); - - // Handle events - if(tsEvent.type == TSEventTypeInput) { - // Exit on back key - if(tsEvent.input.key == - InputKeyBack) // We dont check for type here, we can check the type of keypress like: (event.input.type == InputTypeShort) - break; - - } else if(tsEvent.type == TSEventTypeTick) { - // Update sensor data - // Fetch data and set the sensor current status accordingly - sensorFound = temperature_sensor_fetch_info(&celsius, &rel_humidity); - temperature_sensor_current_status = (sensorFound ? TSSPendingUpdate : TSSNoSensor); - - if(sensorFound) { - // Blink blue - notification_message(notifications, &sequence_blink_blue_100); - - if(celsius != TS_DEFAULT_VALUE && rel_humidity != TS_DEFAULT_VALUE) { - // Convert celsius to fahrenheit - fahrenheit = (celsius * 9 / 5) + 32; - - // Calculate absolute humidity - For more info refer to https://github.com/Mywk/FlipperTemperatureSensor/issues/1 - // Calculate saturation vapour pressure first - vapour_pressure = - (double)6.11 * - pow(10, (double)(((double)7.5 * celsius) / ((double)237.3 + celsius))); - // Then the vapour pressure in Pa - vapour_pressure = vapour_pressure * rel_humidity; - // Calculate absolute humidity - abs_humidity = - (double)2.16679 * (double)(vapour_pressure / ((double)273.15 + celsius)); - - // Fill our buffers here, not on the canvas draw callback - snprintf(ts_data_buffer_temperature_c, DATA_BUFFER_SIZE, "%.2f", celsius); - snprintf(ts_data_buffer_temperature_f, DATA_BUFFER_SIZE, "%.2f", fahrenheit); - snprintf( - ts_data_buffer_relative_humidity, DATA_BUFFER_SIZE, "%.2f", rel_humidity); - snprintf( - ts_data_buffer_absolute_humidity, DATA_BUFFER_SIZE, "%.2f", abs_humidity); - } - - } else { - // Reset our variables to their default values - celsius = fahrenheit = rel_humidity = abs_humidity = TS_DEFAULT_VALUE; - - // Blink red - notification_message(notifications, &sequence_blink_red_100); - } - } - - uint32_t wait_ticks = furi_ms_to_ticks(!sensorFound ? 100 : 500); - furi_delay_tick(wait_ticks); - } - - furi_hal_power_suppress_charge_exit(); - // Dobby is freee (free our variables, Flipper will crash if we don't do this!) - furi_timer_free(timer); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - furi_message_queue_free(event_queue); - - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_GUI); - - return 0; -} diff --git a/applications/plugins/am2320_temp_sensor/temperature_sensor.png b/applications/plugins/am2320_temp_sensor/temperature_sensor.png deleted file mode 100644 index b6fe6d7fe..000000000 Binary files a/applications/plugins/am2320_temp_sensor/temperature_sensor.png and /dev/null differ diff --git a/applications/plugins/badapple/application.fam b/applications/plugins/badapple/application.fam deleted file mode 100644 index 7653a543e..000000000 --- a/applications/plugins/badapple/application.fam +++ /dev/null @@ -1,9 +0,0 @@ -App( - appid="BadApple", - name="Bad Apple", - apptype=FlipperAppType.EXTERNAL, - entry_point="bad_apple_main", - requires=["gui"], - stack_size=1 * 1024, - fap_category="Misc" -) diff --git a/applications/plugins/badapple/bad_apple.c b/applications/plugins/badapple/bad_apple.c deleted file mode 100644 index 325d6ea55..000000000 --- a/applications/plugins/badapple/bad_apple.c +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "bad_apple.h" -#include "video_player.h" - -#define TAG "badapple" - -typedef enum { - BadAppleEventTypeInput, - BadAppleEventTypeTick, -} BadAppleEventType; - -typedef struct { - BadAppleEventType type; - InputEvent* input; -} BadAppleEvent; - -// Screen is 128x64 px -static void app_draw_callback(Canvas* canvas, void* ctx) { - BadAppleCtx* inst = ctx; - - canvas_clear(canvas); - canvas_draw_xbm(canvas, VIDEO_X, VIDEO_Y, VIDEO_WIDTH, SCREEN_HEIGHT, inst->framebuffer); - canvas_draw_box(canvas, 0, 0, VIDEO_X, SCREEN_HEIGHT); - canvas_draw_box( - canvas, VIDEO_X + VIDEO_WIDTH, 0, SCREEN_WIDTH - VIDEO_WIDTH - VIDEO_X, SCREEN_HEIGHT); -} - -static void app_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); - - FuriMessageQueue* event_queue = ctx; - BadAppleEvent event = {.type = BadAppleEventTypeInput, .input = input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -BadAppleCtx* bad_apple_ctx_alloc(void) { - BadAppleCtx* inst = malloc(sizeof(BadAppleCtx)); - memset(inst, 0, sizeof(BadAppleCtx)); - - if(inst) { - inst->storage = furi_record_open(RECORD_STORAGE); - inst->video_file = storage_file_alloc(inst->storage); - inst->file_buffer_offset = sizeof(inst->file_buffer); - } - - return inst; -} - -void bad_apple_ctx_free(BadAppleCtx* inst) { - if(inst) { - storage_file_free(inst->video_file); - furi_record_close(RECORD_STORAGE); - free(inst); - } -} - -void bad_apple_load_next_video_chunk(BadAppleCtx* inst) { - size_t bytes_to_read = sizeof(inst->file_buffer); - uint8_t* buf_ptr = inst->file_buffer; - while(bytes_to_read > 0) { - uint16_t curr_bytes_to_read = bytes_to_read > (UINT16_MAX / 2 + 1) ? (UINT16_MAX / 2 + 1) : - bytes_to_read; - uint16_t read = storage_file_read(inst->video_file, buf_ptr, curr_bytes_to_read); - bytes_to_read -= read; - buf_ptr += read; - if(read == 0) break; - } - inst->file_buffer_offset = 0; -} - -uint8_t bad_apple_read_byte(BadAppleCtx* inst) { - if(inst->file_buffer_offset >= sizeof(inst->file_buffer)) { - bad_apple_load_next_video_chunk(inst); - } - return inst->file_buffer[inst->file_buffer_offset++]; -} - -void bad_apple_timer_isr(void* ctx) { - FuriMessageQueue* event_queue = ctx; - BadAppleEvent event = {.type = BadAppleEventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); - LL_TIM_ClearFlag_UPDATE(TIM2); -} - -void bad_apple_timer_setup(BadAppleCtx* inst, void* ctx) { - UNUSED(inst); - - LL_TIM_InitTypeDef tim_init = { - .Prescaler = 63999, - .CounterMode = LL_TIM_COUNTERMODE_UP, - .Autoreload = 30, - }; - - LL_TIM_Init(TIM2, &tim_init); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - LL_TIM_DisableCounter(TIM2); - LL_TIM_SetCounter(TIM2, 0); - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, bad_apple_timer_isr, ctx); - LL_TIM_EnableIT_UPDATE(TIM2); -} - -void bad_apple_timer_deinit(void) { - LL_TIM_DisableCounter(TIM2); - LL_TIM_DisableIT_UPDATE(TIM2); - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL); - LL_TIM_DeInit(TIM2); -} - -int32_t bad_apple_main(void* p) { - UNUSED(p); - BadAppleCtx* ctx = bad_apple_ctx_alloc(); - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(BadAppleEvent)); - - // Configure view port - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, app_draw_callback, ctx); - view_port_input_callback_set(view_port, app_input_callback, event_queue); - - // Register view port in GUI - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - - // Frame rate: 32 FPS - bad_apple_timer_setup(ctx, event_queue); - - bool is_opened = storage_file_open(ctx->video_file, VIDEO_PATH, FSAM_READ, FSOM_OPEN_EXISTING); - if(is_opened) { - BadAppleEvent event; - notification_message(notification, &sequence_display_backlight_enforce_on); - - bool running = true; - LL_TIM_EnableCounter(TIM2); - while(running) { - if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) { - if(event.type == BadAppleEventTypeInput) { - InputEvent* input_event = event.input; - if(input_event->type == InputTypeLong) { - if(input_event->key == InputKeyBack) { - running = false; - } - } - } else if(event.type == BadAppleEventTypeTick) { - // FURI_LOG_D(TAG, "Update frame"); - if(!vp_play_frame(ctx)) { - running = false; - } - } - } - view_port_update(view_port); - } - LL_TIM_DisableCounter(TIM2); - notification_message(notification, &sequence_display_backlight_enforce_auto); - storage_file_close(ctx->video_file); - } - - furi_record_close(RECORD_NOTIFICATION); - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - furi_message_queue_free(event_queue); - - furi_record_close(RECORD_GUI); - bad_apple_timer_deinit(); - bad_apple_ctx_free(ctx); - - return 0; -} diff --git a/applications/plugins/badapple/bad_apple.h b/applications/plugins/badapple/bad_apple.h deleted file mode 100644 index de842b8d7..000000000 --- a/applications/plugins/badapple/bad_apple.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -#include - -#include - -#define SCREEN_WIDTH 128 -#define SCREEN_HEIGHT 64 -#define VIDEO_WIDTH 104 -#define VIDEO_HEIGHT 80 -#define FILE_BUFFER_SIZE (1024 * 64) -#define VIDEO_PATH EXT_PATH("apps_data/bad_apple/video.bin") -#define VIDEO_X ((SCREEN_WIDTH - VIDEO_WIDTH) / 2) -#define VIDEO_Y 0 - -typedef struct { - uint8_t framebuffer[VIDEO_HEIGHT * VIDEO_WIDTH / 8]; - uint8_t file_buffer[FILE_BUFFER_SIZE]; - uint32_t file_buffer_offset; - uint32_t frame_write_offset; // bit index - Storage* storage; - File* video_file; -} BadAppleCtx; - -uint8_t bad_apple_read_byte(BadAppleCtx* inst); diff --git a/applications/plugins/badapple/video_player.c b/applications/plugins/badapple/video_player.c deleted file mode 100644 index 945837d6b..000000000 --- a/applications/plugins/badapple/video_player.c +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include - -#include "bad_apple.h" -#include "video_player.h" - -#define TAG "video_player" - -static void vp_decode_rle(BadAppleCtx* ctx); -static void vp_decode_delta(BadAppleCtx* ctx); - -int vp_play_frame(BadAppleCtx* ctx) { - // Check frame type - // FURI_LOG_D(TAG, "Buffer offset: %04lx", ctx->file_buffer_offset); - uint8_t b = bad_apple_read_byte(ctx); - // FURI_LOG_D(TAG, "Frame byte: %02x", b); - switch(b) { - case 1: // PFrame (delta) - vp_decode_delta(ctx); - break; - case 2: // IFrame (rle) - vp_decode_rle(ctx); - break; - case 3: // DFrame (duplicate) - break; - case 4: // next page (not supported) - case 5: // end - default: - return 0; - } - - return 1; -} - -static inline void vp_write_pixel(BadAppleCtx* ctx, bool color) { - if(color) { - // White - ctx->framebuffer[ctx->frame_write_offset / 8] &= ~(1 << (ctx->frame_write_offset % 8)); - } else { - // Black - ctx->framebuffer[ctx->frame_write_offset / 8] |= (1 << (ctx->frame_write_offset % 8)); - } - ++ctx->frame_write_offset; -} - -static inline void vp_set_rect_fast(BadAppleCtx* ctx, int x, int y) { - ctx->frame_write_offset = y * VIDEO_WIDTH + x; -} - -static void vp_decode_rle(BadAppleCtx* ctx) { - int i = 0; - int repeat_byte = bad_apple_read_byte(ctx); - - // Set rect to video area - vp_set_rect_fast(ctx, 0, 0); - - while(i < VIDEO_WIDTH * VIDEO_HEIGHT) { - int count; - unsigned pixels; - int j; - int b = bad_apple_read_byte(ctx); - - if(b == repeat_byte) { - count = bad_apple_read_byte(ctx); - if(count == 0) count = 256; - pixels = bad_apple_read_byte(ctx); - } else { - count = 1; - pixels = (unsigned)b; - } - - for(j = 0; j < count; ++j) { - bool out_color; - int k; - unsigned loop_pixels = pixels; - - for(k = 0; k < 8; ++k) { - if(loop_pixels & 0x80) - out_color = COLOR_WHITE; - else - out_color = COLOR_BLACK; - - vp_write_pixel(ctx, out_color); - loop_pixels <<= 1; - ++i; - } - } - } -} - -static void vp_decode_delta(BadAppleCtx* ctx) { - int frame_header[(VIDEO_HEIGHT + 7) / 8]; - uint i; - int fh_byte = 0; - int fh_index = 0; - - for(i = 0; i < sizeof(frame_header) / sizeof(frame_header[0]); ++i) { - frame_header[i] = bad_apple_read_byte(ctx); - } - - for(i = 0; i < VIDEO_HEIGHT; ++i) { - if(i % 8 == 0) fh_byte = frame_header[fh_index++]; - - if(fh_byte & 0x80) { - int j; - int sl_byte = 0; - - for(j = 0; j < VIDEO_WIDTH;) { - if(j % (8 * 8) == 0) sl_byte = bad_apple_read_byte(ctx); - - if(sl_byte & 0x80) { - unsigned out_color; - int k; - unsigned pixel_group = bad_apple_read_byte(ctx); - - // Note: this needs to be revised for screen width not multiple of 8 - vp_set_rect_fast(ctx, j, i); - - for(k = 0; k < 8 && j < VIDEO_WIDTH; ++k, ++j) { - if(pixel_group & 0x80) - out_color = COLOR_WHITE; - else - out_color = COLOR_BLACK; - - vp_write_pixel(ctx, out_color); - pixel_group <<= 1; - } - } else { - j += 8; - } - sl_byte <<= 1; - } - } - fh_byte <<= 1; - } -} diff --git a/applications/plugins/badapple/video_player.h b/applications/plugins/badapple/video_player.h deleted file mode 100644 index c81a6c2e8..000000000 --- a/applications/plugins/badapple/video_player.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#define COLOR_WHITE true -#define COLOR_BLACK false - -int vp_play_frame(BadAppleCtx* ctx); diff --git a/applications/plugins/bpmtapper/LICENSE b/applications/plugins/bpmtapper/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/bpmtapper/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/bpmtapper/README.md b/applications/plugins/bpmtapper/README.md deleted file mode 100644 index 8e88863ee..000000000 --- a/applications/plugins/bpmtapper/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# BPM Tapper - -A BPM Tapper for the Flipper Zero. - -![screenshot](img/screenshot.png) - -Hit any button other than back repeatedly. Calculates based on the average of the last 8 inputs. - -## Compiling - -``` -./fbt firmware_bpm_tapper -``` - diff --git a/applications/plugins/bpmtapper/application.fam b/applications/plugins/bpmtapper/application.fam deleted file mode 100644 index 93c4179c5..000000000 --- a/applications/plugins/bpmtapper/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="BPM_Tapper", - name="BPM Tapper", - apptype=FlipperAppType.EXTERNAL, - entry_point="bpm_tapper_app", - cdefines=["APP_BPM_TAPPER"], - requires=["gui"], - stack_size=2 * 1024, - fap_icon="bpm_10px.png", - fap_category="Music", - fap_icon_assets="icons", - order=15, -) diff --git a/applications/plugins/bpmtapper/bpm.c b/applications/plugins/bpmtapper/bpm.c deleted file mode 100644 index cee83a6a4..000000000 --- a/applications/plugins/bpmtapper/bpm.c +++ /dev/null @@ -1,262 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "BPM_Tapper_icons.h" - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -//QUEUE - -struct node { - int interval; - struct node* next; -}; -typedef struct node node; - -typedef struct { - int size; - int max_size; - node* front; - node* rear; -} queue; - -static void init_queue(queue* q) { - q->size = 0; - q->max_size = 8; - q->front = NULL; - q->rear = NULL; -} - -static void queue_remove(queue* q) { - node* tmp; - tmp = q->front; - q->front = q->front->next; - q->size--; - free(tmp); -} - -static void queue_add(queue* q, int value) { - node* tmp = malloc(sizeof(node)); - tmp->interval = value; - tmp->next = NULL; - if(q->size == q->max_size) { - queue_remove(q); - } - // check if empty - if(q->rear == NULL) { - q->front = tmp; - q->rear = tmp; - } else { - q->rear->next = tmp; - q->rear = tmp; - } - q->size++; -} - -static float queue_avg(queue* q) { - float avg = 0.0; - if(q->size == 0) { - return avg; - } else { - node* tmp; - float sum = 0.0; - tmp = q->front; - while(tmp != NULL) { - sum = sum + tmp->interval; - tmp = tmp->next; - } - avg = sum / q->size; - FURI_LOG_D("BPM-Tapper", "Sum: %.2f Avg: %.2f", (double)sum, (double)avg); - return avg; - } -} - -// TOO SLOW! -//uint64_t dolphin_state_timestamp() { -// FuriHalRtcDateTime datetime; -// furi_hal_rtc_get_datetime(&datetime); -// return furi_hal_rtc_datetime_to_timestamp(&datetime); -//} -// -typedef struct { - int taps; - double bpm; - uint32_t last_stamp; - uint32_t interval; - queue* tap_queue; -} BPMTapper; - -static void show_hello() { - // BEGIN HELLO DIALOG - DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); - DialogMessage* message = dialog_message_alloc(); - - const char* header_text = "BPM Tapper"; - const char* message_text = "Tap center to start"; - - dialog_message_set_header(message, header_text, 63, 3, AlignCenter, AlignTop); - dialog_message_set_text(message, message_text, 0, 17, AlignLeft, AlignTop); - dialog_message_set_buttons(message, NULL, "Tap", NULL); - - dialog_message_set_icon(message, &I_DolphinCommon_56x48, 72, 17); - - dialog_message_show(dialogs, message); - - dialog_message_free(message); - furi_record_close(RECORD_DIALOGS); - // END HELLO DIALOG -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void render_callback(Canvas* const canvas, void* ctx) { - FuriString* tempStr; - - const BPMTapper* bpm_state = acquire_mutex((ValueMutex*)ctx, 25); - if(bpm_state == NULL) { - return; - } - // border - //canvas_draw_frame(canvas, 0, 0, 128, 64); - canvas_set_font(canvas, FontPrimary); - - tempStr = furi_string_alloc(); - - furi_string_printf(tempStr, "Taps: %d", bpm_state->taps); - canvas_draw_str_aligned(canvas, 5, 10, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - furi_string_printf(tempStr, "Queue: %d", bpm_state->tap_queue->size); - canvas_draw_str_aligned(canvas, 70, 10, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - furi_string_printf(tempStr, "Interval: %ldms", bpm_state->interval); - canvas_draw_str_aligned(canvas, 5, 20, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - furi_string_printf(tempStr, "x2 %.2f /2 %.2f", bpm_state->bpm * 2, bpm_state->bpm / 2); - canvas_draw_str_aligned( - canvas, 64, 60, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - furi_string_printf(tempStr, "%.2f", bpm_state->bpm); - canvas_set_font(canvas, FontBigNumbers); - canvas_draw_str_aligned( - canvas, 64, 40, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - furi_string_free(tempStr); - - release_mutex((ValueMutex*)ctx, bpm_state); -} - -static void bpm_state_init(BPMTapper* const plugin_state) { - plugin_state->taps = 0; - plugin_state->bpm = 120.0; - plugin_state->last_stamp = 0; // furi_get_tick(); - plugin_state->interval = 0; - queue* q; - q = malloc(sizeof(queue)); - init_queue(q); - plugin_state->tap_queue = q; -} - -int32_t bpm_tapper_app(void* p) { - UNUSED(p); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - BPMTapper* bpm_state = malloc(sizeof(BPMTapper)); - // setup - bpm_state_init(bpm_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, bpm_state, sizeof(bpm_state))) { - FURI_LOG_E("BPM-Tapper", "cannot create mutex\r\n"); - free(bpm_state); - return 255; - } - show_hello(); - - // BEGIN IMPLEMENTATION - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - BPMTapper* bpm_state = (BPMTapper*)acquire_mutex_block(&state_mutex); - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - case InputKeyDown: - case InputKeyRight: - case InputKeyLeft: - case InputKeyOk: - bpm_state->taps++; - uint32_t new_stamp = furi_get_tick(); - if(bpm_state->last_stamp == 0) { - bpm_state->last_stamp = new_stamp; - break; - } - bpm_state->interval = new_stamp - bpm_state->last_stamp; - bpm_state->last_stamp = new_stamp; - queue_add(bpm_state->tap_queue, bpm_state->interval); - float avg = queue_avg(bpm_state->tap_queue); - float bps = 1.0 / (avg / 1000.0); - bpm_state->bpm = bps * 60.0; - break; - case InputKeyBack: - // Exit the plugin - processing = false; - break; - default: - break; - } - } - } - } else { - FURI_LOG_D("BPM-Tapper", "FuriMessageQueue: event timeout"); - // event timeout - } - view_port_update(view_port); - release_mutex(&state_mutex, bpm_state); - } - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - queue* q = bpm_state->tap_queue; - free(q); - free(bpm_state); - - return 0; -} diff --git a/applications/plugins/bpmtapper/bpm_10px.png b/applications/plugins/bpmtapper/bpm_10px.png deleted file mode 100644 index ebf27486c..000000000 Binary files a/applications/plugins/bpmtapper/bpm_10px.png and /dev/null differ diff --git a/applications/plugins/bpmtapper/icons/DolphinCommon_56x48.png b/applications/plugins/bpmtapper/icons/DolphinCommon_56x48.png deleted file mode 100644 index 089aaed83..000000000 Binary files a/applications/plugins/bpmtapper/icons/DolphinCommon_56x48.png and /dev/null differ diff --git a/applications/plugins/bpmtapper/img/screenshot.png b/applications/plugins/bpmtapper/img/screenshot.png deleted file mode 100644 index fbba2aad9..000000000 Binary files a/applications/plugins/bpmtapper/img/screenshot.png and /dev/null differ diff --git a/applications/plugins/chess/application.fam b/applications/plugins/chess/application.fam deleted file mode 100644 index 7bf1d30e6..000000000 --- a/applications/plugins/chess/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="zBroken_Chess", - name="Chess", - apptype=FlipperAppType.EXTERNAL, - entry_point="chess_app", - cdefines=["APP_CHESS"], - requires=["storage","gui"], - stack_size= 4 * 1024, - order=500, - fap_icon="chessIcon.png", - fap_category="Games", -) diff --git a/applications/plugins/chess/chessIcon.png b/applications/plugins/chess/chessIcon.png deleted file mode 100644 index d98ebb1d4..000000000 Binary files a/applications/plugins/chess/chessIcon.png and /dev/null differ diff --git a/applications/plugins/chess/chess_app.c b/applications/plugins/chess/chess_app.c deleted file mode 100644 index a3f118f2c..000000000 --- a/applications/plugins/chess/chess_app.c +++ /dev/null @@ -1,686 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include "fast_chess.h" - -static bool flag = true; -static bool should_exit = false; -// static bool ai_should_make_move = false; -static bool thinking = false; -static bool should_update_screen = true; -static uint32_t anim = 0; -static char white_move_str[8] = "", black_move_str[8] = ""; // last moves - -static NotificationApp* notification; - -const uint8_t _I_Chess_0[] = { - 0x01, 0x00, 0x2a, 0x01, 0x80, 0x7f, 0xc0, 0x2c, 0x0f, 0xf0, 0x7f, 0x83, 0xfc, 0x1f, 0xe0, 0xff, - 0x07, 0xf8, 0x3f, 0xc1, 0xde, 0x0f, 0xf0, 0x7f, 0x83, 0xfc, 0x1f, 0xe0, 0xff, 0x07, 0xf8, 0x3f, - 0xc2, 0x1e, 0x0f, 0xf0, 0x7f, 0x80, 0x07, 0x00, 0x0f, 0xf1, 0x7f, 0xc0, 0x41, 0xf8, 0x1e, 0x18, - 0x0f, 0xf2, 0xfe, 0x1f, 0xb8, 0x0e, 0x0a, 0x07, 0x80, 0x81, 0x83, 0xea, 0x05, 0x62, 0x01, 0x8c, - 0x30, 0x7d, 0x50, 0x48, 0x80, 0x0c, 0x66, 0x00, 0xfa, 0x84, 0x42, 0x00, 0x63, 0x40, 0x07, 0xd4, - 0x42, 0x08, 0x54, 0x24, 0xf5, 0xc0, 0x8f, 0xd9, 0x70, 0x3f, 0xa2, 0x7a, 0xb0, 0x69, 0xee, 0x57, - 0xa0, 0x3e, 0xa8, 0x0b, 0xfc, 0xc0, 0x4f, 0xc1, 0xe5, 0x3c, 0x07, 0xcd, 0x03, 0x81, 0x41, 0x06, - 0x0f, 0x0c, 0x1f, 0x32, 0x08, 0x04, 0x98, 0x46, 0x31, 0xf3, 0x10, 0x83, 0xdd, 0x58, 0x33, 0x88, - 0x07, 0x02, 0xfe, 0x82, 0x10, 0x7c, 0x88, 0x47, 0x81, 0x73, 0x07, 0xcf, 0x42, 0x07, 0xc0, 0x80, - 0x78, 0x3e, 0x2b, 0x21, 0x07, 0xbf, 0xc2, 0x1f, 0x00, 0x81, 0x83, 0xef, 0xc1, 0x1f, 0x7e, 0x0f, - 0x83, 0xff, 0x04, 0x47, 0xc7, 0x82, 0x7e, 0x42, 0x10, 0x7d, 0x96, 0xc4, 0x06, 0x71, 0x60, 0x7c, - 0x3e, 0x48, 0x1e, 0x52, 0xa5, 0xfc, 0xff, 0xd1, 0x62, 0x8f, 0x1a, 0xa8, 0x3e, 0x7f, 0xd0, 0x31, - 0x19, 0x07, 0xeb, 0xf9, 0x07, 0x80, 0x58, 0x2c, 0x01, 0xfa, 0xfc, 0x20, 0x06, 0x21, 0x80, 0x0f, - 0xd7, 0xc1, 0x00, 0x20, 0x01, 0xaa, 0xa3, 0xe1, 0x00, 0x60, 0x01, 0x95, 0x03, 0xe7, 0x80, 0x24, - 0x38, 0xa0, 0x3e, 0x7f, 0x1c, 0x73, 0x00, 0x9d, 0x8c, 0x02, 0xdc, 0x0d, 0x7c, 0x04, 0xa0, 0x2e, - 0xe1, 0x07, 0xc5, 0xc2, 0xeb, 0x00, 0x9f, 0x40, 0x12, 0x42, 0x0f, 0x8d, 0xc4, 0x69, 0x22, 0x3c, - 0x11, 0x7d, 0x5e, 0x20, 0xa0, 0x41, 0x30, 0x98, 0x3d, 0xf1, 0x1f, 0xff, 0xfa, 0x00, 0xcb, 0xd1, - 0x10, 0x2e, 0x18, 0x3e, 0xa4, 0x00, 0xfe, 0xa0, 0x03, 0xfb, 0x00, 0x6b, 0x20, 0x7d, 0xc0, 0x21, - 0xc0, 0xfe, 0xf8, 0x3f, 0xc4, 0x1f, 0x90, 0x0f, 0xe0, 0x40, 0xc1, 0xf6, 0x05, 0x30, -}; -const uint8_t* const _I_Chess[] = {_I_Chess_0}; - -const uint8_t _I_Chess_Selection1_0[] = { - 0x00, - 0x55, - 0x80, - 0x01, - 0x80, - 0x01, - 0x80, - 0x01, - 0xAA, -}; -const uint8_t* const _I_Chess_Selection1[] = {_I_Chess_Selection1_0}; - -const uint8_t _I_Chess_Selection2_0[] = { - 0x00, - 0xAA, - 0x01, - 0x80, - 0x01, - 0x80, - 0x01, - 0x80, - 0x55, -}; -const uint8_t* const _I_Chess_Selection2[] = {_I_Chess_Selection2_0}; - -const uint8_t _I_Chess_bb_0[] = { - 0x00, - 0x0C, - 0x1A, - 0x3D, - 0x1E, - 0x0C, - 0x3F, -}; -const uint8_t* const _I_Chess_bb[] = {_I_Chess_bb_0}; - -const uint8_t _I_Chess_bw_0[] = { - 0x00, - 0x0C, - 0x16, - 0x23, - 0x16, - 0x0C, - 0x3F, -}; -const uint8_t* const _I_Chess_bw[] = {_I_Chess_bw_0}; - -const uint8_t _I_Chess_kb_0[] = { - 0x00, - 0x0C, - 0x2D, - 0x21, - 0x12, - 0x0C, - 0x3F, -}; -const uint8_t* const _I_Chess_kb[] = {_I_Chess_kb_0}; - -const uint8_t _I_Chess_kw_0[] = { - 0x00, - 0x0C, - 0x21, - 0x21, - 0x12, - 0x0C, - 0x3F, -}; -const uint8_t* const _I_Chess_kw[] = {_I_Chess_kw_0}; - -const uint8_t _I_Chess_nb_0[] = { - 0x00, - 0x06, - 0x0F, - 0x1F, - 0x2E, - 0x0E, - 0x3F, -}; -const uint8_t* const _I_Chess_nb[] = {_I_Chess_nb_0}; - -const uint8_t _I_Chess_nw_0[] = { - 0x00, - 0x06, - 0x09, - 0x11, - 0x2A, - 0x0A, - 0x3F, -}; -const uint8_t* const _I_Chess_nw[] = {_I_Chess_nw_0}; - -const uint8_t _I_Chess_old_0[] = { - 0x01, 0x00, 0x35, 0x01, 0x80, 0x7f, 0xc0, 0x2c, 0x0f, 0xf0, 0x7f, 0x83, 0xfc, 0x1f, 0xe0, 0xff, - 0x07, 0xf8, 0x3f, 0xc0, 0x03, 0x80, 0x0f, 0x70, 0x3f, 0xe0, 0x10, 0x11, 0x77, 0x40, 0x7f, 0x97, - 0xf0, 0xfd, 0xc0, 0x70, 0x50, 0x3c, 0x04, 0x0c, 0x1f, 0x50, 0x2b, 0x10, 0x0c, 0x61, 0x80, 0xfa, - 0x82, 0x44, 0x00, 0x63, 0x30, 0x07, 0xd4, 0x22, 0x10, 0x03, 0x1a, 0x00, 0x3e, 0xa2, 0x10, 0x42, - 0xa1, 0x90, 0x2d, 0x01, 0x97, 0x03, 0xfa, 0x03, 0xe7, 0x01, 0x83, 0x5f, 0xf8, 0x3f, 0xa8, 0x00, - 0xfc, 0xc0, 0x4f, 0xc1, 0xe5, 0x3c, 0x07, 0xcd, 0x03, 0x81, 0x41, 0x06, 0x0f, 0x0c, 0x1f, 0x32, - 0x08, 0x04, 0x98, 0x46, 0x31, 0xf8, 0x08, 0xfa, 0x15, 0x83, 0x38, 0x80, 0x70, 0x2f, 0xf0, 0x20, - 0x7d, 0x08, 0x47, 0x81, 0x73, 0x07, 0xcf, 0x42, 0x07, 0xc0, 0x80, 0x78, 0x3e, 0x30, 0x40, 0x7c, - 0x7c, 0x21, 0xf0, 0x08, 0x18, 0x3e, 0xfc, 0x11, 0xf7, 0xe0, 0xf8, 0x3f, 0xe0, 0xfa, 0x9f, 0x90, - 0x84, 0x1f, 0x65, 0xb1, 0x01, 0x9c, 0x59, 0x9d, 0x21, 0x34, 0x95, 0x2f, 0xe7, 0xfe, 0xee, 0x14, - 0x78, 0xd5, 0x41, 0xf3, 0xfe, 0x81, 0x88, 0xc8, 0x3f, 0x5f, 0xc8, 0x3c, 0x02, 0xc1, 0x60, 0x0f, - 0xd7, 0xe1, 0x00, 0x31, 0x0c, 0x00, 0x7e, 0xbe, 0x08, 0x01, 0x00, 0x08, 0x7e, 0x90, 0x04, 0x00, - 0x10, 0xfd, 0x70, 0x00, 0x65, 0x00, 0x8a, 0x0f, 0xeb, 0x8e, 0x60, 0x13, 0xa9, 0x07, 0xa3, 0x5f, - 0x01, 0x28, 0x0c, 0x08, 0x1f, 0x37, 0x0b, 0xac, 0x02, 0x7d, 0x00, 0x49, 0x08, 0x3e, 0x37, 0x11, - 0xa4, 0x88, 0xf0, 0x45, 0xf5, 0x78, 0x82, 0x81, 0x44, 0xc2, 0x40, 0xf8, 0xc4, 0x7f, 0xff, 0xe8, - 0x03, 0x07, 0xc4, 0x40, 0x18, 0x40, 0xfb, 0x90, 0x03, 0xfa, 0x80, 0x0f, 0x50, 0x84, 0x60, 0x0d, - 0x62, 0x20, 0xd8, 0x70, 0x3f, 0xbe, 0x0f, 0xf1, 0x07, 0xe4, 0x03, 0xf8, 0x10, 0x40, 0x7d, 0x01, - 0x0c, 0x1f, 0x77, 0xf2, 0x91, 0x83, 0xeb, 0x7e, 0x1f, 0xdf, 0xa5, 0x7c, 0x1d, 0x90, 0x0d, 0x54, - 0xa8, 0x1f, 0xb5, 0x68, 0xa8, 0x7f, 0xa1, 0x40, 0xfd, 0xaa, 0xc1, 0x41, 0xfb, 0xa1, 0x81, 0x03, - 0xf5, 0xa0, 0x80, 0xff, 0x07, 0xce, 0x01, 0x9c, 0x80, -}; -const uint8_t* const _I_Chess_old[] = {_I_Chess_old_0}; - -const uint8_t _I_Chess_pb_0[] = { - 0x00, - 0x00, - 0x0C, - 0x1E, - 0x1E, - 0x0C, - 0x1E, -}; -const uint8_t* const _I_Chess_pb[] = {_I_Chess_pb_0}; - -const uint8_t _I_Chess_pw_0[] = { - 0x00, - 0x00, - 0x0C, - 0x12, - 0x12, - 0x0C, - 0x1E, -}; -const uint8_t* const _I_Chess_pw[] = {_I_Chess_pw_0}; - -const uint8_t _I_Chess_qb_0[] = { - 0x00, - 0x2D, - 0x2D, - 0x2D, - 0x1E, - 0x1E, - 0x3F, -}; -const uint8_t* const _I_Chess_qb[] = {_I_Chess_qb_0}; - -const uint8_t _I_Chess_qw_0[] = { - 0x00, - 0x2D, - 0x2D, - 0x2D, - 0x1E, - 0x1E, - 0x3F, -}; -const uint8_t* const _I_Chess_qw[] = {_I_Chess_qw_0}; - -const uint8_t _I_Chess_rb_0[] = { - 0x00, - 0x2D, - 0x2D, - 0x1E, - 0x1E, - 0x1E, - 0x3F, -}; -const uint8_t* const _I_Chess_rb[] = {_I_Chess_rb_0}; - -const uint8_t _I_Chess_rw_0[] = { - 0x00, - 0x2D, - 0x2D, - 0x12, - 0x12, - 0x12, - 0x3F, -}; -const uint8_t* const _I_Chess_rw[] = {_I_Chess_rw_0}; - -const Icon I_Chess_Selection2 = - {.width = 8, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_Selection2}; -const Icon I_Chess_old = - {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_old}; -const Icon I_Chess_Selection1 = - {.width = 8, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_Selection1}; -const Icon I_Chess = - {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess}; -const Icon I_Chess_kb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_kb}; -const Icon I_Chess_rw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_rw}; -const Icon I_Chess_rb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_rb}; -const Icon I_Chess_kw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_kw}; -const Icon I_Chess_qb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_qb}; -const Icon I_Chess_qw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_qw}; -const Icon I_Chess_pw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_pw}; -const Icon I_Chess_pb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_pb}; -const Icon I_Chess_nb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_nb}; -const Icon I_Chess_bw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_bw}; -const Icon I_Chess_bb = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_bb}; -const Icon I_Chess_nw = - {.width = 6, .height = 6, .frame_count = 1, .frame_rate = 0, .frames = _I_Chess_nw}; - -typedef struct { - uint8_t col, row; -} _Position; - -typedef struct { - enum { - None = 0, - Pawn, - King, - Queen, - Bishop, - Knight, - Rook, - } type; - enum { White, Black } side; -} Piece; - -static const _Position PosNone = {.col = 255, .row = 255}; -// static Piece board[8][8]; // col, row -static _Position sel, move_from = PosNone, move_to = PosNone; - -Game* game; - -// uint8_t sel_col = 0, sel_row = 0; - -// static enum { -// SelectingFrom, -// SelectingTo -// } state = SelectingFrom; - -// static void reset_board() { -// memset(board, 0, sizeof(board)); - -// board[0][0].type = Rook; -// board[1][0].type = Knight; -// board[2][0].type = Bishop; -// board[3][0].type = Queen; -// board[4][0].type = King; -// board[5][0].type = Bishop; -// board[6][0].type = Knight; -// board[7][0].type = Rook; - -// board[0][1].type = Pawn; -// board[1][1].type = Pawn; -// board[2][1].type = Pawn; -// board[3][1].type = Pawn; -// board[4][1].type = Pawn; -// board[5][1].type = Pawn; -// board[6][1].type = Pawn; -// board[7][1].type = Pawn; - -// board[0][7].type = Rook; board[0][7].side = Black; -// board[1][7].type = Knight; board[1][7].side = Black; -// board[2][7].type = Bishop; board[2][7].side = Black; -// board[3][7].type = Queen; board[3][7].side = Black; -// board[4][7].type = King; board[4][7].side = Black; -// board[5][7].type = Bishop; board[5][7].side = Black; -// board[6][7].type = Knight; board[6][7].side = Black; -// board[7][7].type = Rook; board[7][7].side = Black; - -// board[0][6].type = Pawn; board[0][6].side = Black; -// board[1][6].type = Pawn; board[1][6].side = Black; -// board[2][6].type = Pawn; board[2][6].side = Black; -// board[3][6].type = Pawn; board[3][6].side = Black; -// board[4][6].type = Pawn; board[4][6].side = Black; -// board[5][6].type = Pawn; board[5][6].side = Black; -// board[6][6].type = Pawn; board[6][6].side = Black; -// board[7][6].type = Pawn; board[7][6].side = Black; -// } - -// static const Icon* get_icon(const Piece* piece) { -// if (piece->side == White) { -// switch (piece->type) { -// case Pawn: return &I_Chess_pw; -// case King: return &I_Chess_kw; -// case Queen: return &I_Chess_qw; -// case Bishop: return &I_Chess_bw; -// case Knight: return &I_Chess_nw; -// case Rook: return &I_Chess_rw; -// default: return NULL; -// } -// } else { -// switch (piece->type) { -// case Pawn: return &I_Chess_pb; -// case King: return &I_Chess_kb; -// case Queen: return &I_Chess_qb; -// case Bishop: return &I_Chess_bb; -// case Knight: return &I_Chess_nb; -// case Rook: return &I_Chess_rb; -// default: return NULL; -// } -// } -// } - -static void notify_click() { - // static const NotificationSequence sequence = { - // &message_click, - // &message_delay_1, - // &message_sound_off, - // NULL, - // }; - - // notification_message_block(notification, &sequence); - notification_message(notification, &sequence_single_vibro); -} -static const Icon* _get_icon(uint8_t file, uint8_t rank) { - char piece = getPieceChar((FILES_BB[file] & RANKS_BB[7 - rank]), &(game->position.board)); - switch(piece) { - case 'P': - return &I_Chess_pw; - case 'K': - return &I_Chess_kw; - case 'Q': - return &I_Chess_qw; - case 'B': - return &I_Chess_bw; - case 'N': - return &I_Chess_nw; - case 'R': - return &I_Chess_rw; - case 'p': - return &I_Chess_pb; - case 'k': - return &I_Chess_kb; - case 'q': - return &I_Chess_qb; - case 'b': - return &I_Chess_bb; - case 'n': - return &I_Chess_nb; - case 'r': - return &I_Chess_rb; - default: - return NULL; - } -} - -static int get_position(uint8_t file, uint8_t rank) { - return 8 * rank + file; -} - -static int get_rank(int position) { - return (int)(position / 8); -} - -static int get_file(int position) { - return position % 8; -} - -static void make_move(uint8_t file1, uint8_t rank1, uint8_t file2, uint8_t rank2) { - int from = get_position(file1, rank1); - int to = get_position(file2, rank2); - Move move = generateMove(from, to); - if(!isLegalMove(&game->position, move)) { - return; - } - makeMove(game, move); - move2str(white_move_str, game, game->moveListLen - 1); - notify_click(); - black_move_str[0] = 0; - anim = furi_get_tick(); - thinking = true; -} - -static int32_t make_ai_move(void* context) { - UNUSED(context); - // thinking = true; - int depth = 1; - Move move; - Node node = - iterativeDeepeningAlphaBeta(&(game->position), (char)depth, INT32_MIN, INT32_MAX, FALSE); - move = node.move; - makeMove(game, move); - move2str(black_move_str, game, game->moveListLen - 1); - notify_click(); - thinking = false; - anim = furi_get_tick(); - return 0; -} - -static FuriThread* worker_thread = NULL; - -static int32_t ai_thread(void* context) { - while(true) { - if(should_exit) break; - if(thinking) make_ai_move(context); - furi_delay_ms(100); - } - return 0; -} - -static void run_ai_thread() { - if(worker_thread == NULL) { - worker_thread = furi_thread_alloc(); - } - - furi_thread_set_name(worker_thread, "ChessEngine"); - furi_thread_set_stack_size(worker_thread, 7000); - // furi_thread_set_context(thread, bad_usb); - furi_thread_set_callback(worker_thread, ai_thread); - furi_thread_start(worker_thread); - - // furi_thread_join(worker_thread); - // furi_thread_free(worker_thread); -} - -static void chess_draw_callback(Canvas* canvas, void* ctx) { - UNUSED(ctx); - should_update_screen = false; - canvas_clear(canvas); - - // canvas_set_color(canvas, flag ? ColorBlack : ColorWhite); - - canvas_draw_icon(canvas, 0, 0, &I_Chess); - - if(!thinking) { - canvas_set_color(canvas, (sel.col + sel.row) % 2 != 0 ? ColorBlack : ColorWhite); - canvas_draw_icon( - canvas, - sel.col * 8, - (7 - sel.row) * 8, - flag ? &I_Chess_Selection1 : &I_Chess_Selection2); - - if(move_from.col != 255) { - canvas_set_color( - canvas, (move_from.col + move_from.row) % 2 != 0 ? ColorBlack : ColorWhite); - canvas_draw_icon( - canvas, - move_from.col * 8, - (7 - move_from.row) * 8, - flag ? &I_Chess_Selection1 : &I_Chess_Selection2); - } - } - - // print moves - if(game->moveListLen > 0) { - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - - // int num = game->moveListLen; - - // char white_str[8], black_str[8] = "..."; - - // if (num == 0) { - // } else if (num % 2 == 0) { - // // white move - // move2str(white_str, game, game->moveListLen - 2); - // move2str(black_str, game, game->moveListLen - 1); - // } else { - // move2str(white_str, game, game->moveListLen - 1); - // } - - char str[28]; - snprintf( - str, 28, "%d. %s %s", (game->moveListLen + 1) / 2, white_move_str, black_move_str); - canvas_draw_str(canvas, 75, 12, str); - } - - Move last_move = getLastMove(game); - - for(uint8_t row = 0; row < 8; row++) { - for(uint8_t col = 0; col < 8; col++) { - bool white_field = (row + col) % 2 != 0; - - // if (!white_field) { - // canvas_draw_box(canvas, col * 8, row * 8, 8, 8); - // } - const Icon* icon = _get_icon(col, row); - if(icon != NULL) { - int x = col * 8; - int y = row * 8; - - int dt = furi_get_tick() - anim; - if(anim && dt >= 300) { - anim = 0; - } - - if(anim && last_move && get_file(getTo(last_move)) == col && - get_rank(getTo(last_move)) == (7 - row)) { - // moving piece - uint8_t from_x = get_file(getFrom(last_move)) * 8; - uint8_t from_y = (7 - get_rank(getFrom(last_move))) * 8; - x = from_x + (x - from_x) * dt / 300; - y = from_y + (y - from_y) * dt / 300; - } - - canvas_set_color(canvas, white_field ? ColorWhite : ColorBlack); - canvas_draw_icon(canvas, x + 1, y + 1, icon); - } - - // if (board[col][7 - row].type != None) { - // canvas_set_color(canvas, white_field ? ColorWhite : ColorBlack); - // canvas_draw_icon(canvas, col * 8 + 1, row * 8 + 1, get_icon(&board[col][7 - row])); - // } - } - } - - // for (uint8_t i = 0; i < 4; i++) { - // canvas_draw_dot(canvas, sel_col * 8, sel_row * 8); - // canvas_draw_dot(canvas, sel_col * 8 + 2, sel_row * 8); - // canvas_draw_dot(canvas, sel_col * 8, sel_row * 8); - // canvas_draw_dot(canvas, sel_col * 8, sel_row * 8); - // } - - // canvas_draw_disc(canvas, GUI_DISPLAY_WIDTH / 2 - 40, GUI_DISPLAY_HEIGHT / 2, 15); - // canvas_set_color(canvas, flag ? ColorBlack : ColorWhite); - // canvas_draw_disc(canvas, GUI_DISPLAY_WIDTH / 2, GUI_DISPLAY_HEIGHT / 2, 15); -} - -static void chess_input_callback(InputEvent* event, void* ctx) { - UNUSED(ctx); - if(event->type == InputTypeShort) { - if(event->key == InputKeyLeft) { - sel.col = (sel.col == 0) ? 0 : sel.col - 1; - } else if(event->key == InputKeyRight) { - sel.col++; - } else if(event->key == InputKeyDown) { - sel.row = (sel.row == 0) ? 0 : sel.row - 1; - } else if(event->key == InputKeyUp) { - sel.row++; - } else if(event->key == InputKeyOk) { - if(move_from.col == 255) { - move_from = sel; - } else if(move_to.col == 255) { - move_to = sel; - make_move(move_from.col, move_from.row, move_to.col, move_to.row); - // thinking = true; - // ai_should_make_move = true; - // make_ai_move_threaded(); - // Piece piece = board[move_from.col][move_from.row]; - // board[move_from.col][move_from.row].type = None; - // board[move_to.col][move_to.row] = piece; - move_from = PosNone; - move_to = PosNone; - } - } else if(event->key == InputKeyBack) { - should_exit = true; - } - sel.col = CLAMP(sel.col, 7, 0); - sel.row = CLAMP(sel.row, 7, 0); - } -} - -static void setup_engine() { - // int depth = 1; // DEFAULT_AI_DEPTH; - - getInitialGame(game); - - // Move move; - // Node node = iterativeDeepeningAlphaBeta(&(game.position), (char) depth, INT32_MIN, INT32_MAX, FALSE); - // move = node.move; - - // node = iterativeDeepeningAlphaBeta(&(game.position), (char) 2, INT32_MIN, INT32_MAX, FALSE); - - // node = iterativeDeepeningAlphaBeta(&(game.position), (char) 3, INT32_MIN, INT32_MAX, FALSE); - - // printf("%d\n", move); -} - -// void test_engine() { -// FuriThread* thread; // - -// thread = furi_thread_alloc(); -// furi_thread_set_name(thread, "ChessEngine"); -// furi_thread_set_stack_size(thread, 20000); -// // furi_thread_set_context(thread, bad_usb); -// furi_thread_set_callback(thread, setup_engine); - -// furi_thread_start(thread); - -// furi_thread_join(thread); - -// furi_thread_free(thread); -// } - -int32_t chess_app(void* p) { - UNUSED(p); - // Configure view port - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, chess_draw_callback, NULL); - view_port_input_callback_set(view_port, chess_input_callback, NULL); - - // Register view port in GUI - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - notification = furi_record_open(RECORD_NOTIFICATION); - - should_exit = false; - - game = malloc(sizeof(Game)); - - setup_engine(); - run_ai_thread(); - - // test_engine(); - - while(!should_exit) { - furi_delay_ms(100); - if(!thinking) { - flag = !flag; - should_update_screen = true; - } - if(anim) { - should_update_screen = true; - } - if(should_update_screen) { - view_port_update(view_port); - } - // flag = true; - // delay(40); - // flag = false; - // view_port_update(view_port); - // delay(80); - } - - furi_thread_join(worker_thread); - furi_thread_free(worker_thread); - worker_thread = NULL; - - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - - furi_record_close(RECORD_GUI); - - free(game); - - return 0; -} diff --git a/applications/plugins/chess/fast_chess.c b/applications/plugins/chess/fast_chess.c deleted file mode 100644 index d9d42e42c..000000000 --- a/applications/plugins/chess/fast_chess.c +++ /dev/null @@ -1,2978 +0,0 @@ -/* - ============================================================================ - Name : fast-chess.c - Author : Frederico Jordan - Version : - Copyright : Copyright (c) 2016 Frederico Jordan - Description : Simple chess game! - ============================================================================ - */ - -#include -#include -#include -#include -#include -#include - -#include "fast_chess.h" - -char FILES[8] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; -char RANKS[8] = {'1', '2', '3', '4', '5', '6', '7', '8'}; - -Bitboard FILES_BB[8] = {FILE_A, FILE_B, FILE_C, FILE_D, FILE_E, FILE_F, FILE_G, FILE_H}; -Bitboard RANKS_BB[8] = {RANK_1, RANK_2, RANK_3, RANK_4, RANK_5, RANK_6, RANK_7, RANK_8}; - -char INITIAL_FEN[] = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; - -Board EMPTY_BOARD = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -Board INITIAL_BOARD = { - FILE_E & RANK_1, // whiteKing; - FILE_D& RANK_1, // whiteQueens; - (FILE_A | FILE_H) & RANK_1, // whiteRooks; - (FILE_B | FILE_G) & RANK_1, // whiteKnights; - (FILE_C | FILE_F) & RANK_1, // whiteBishops; - RANK_2, // whitePawns; - - FILE_E& RANK_8, // blackKing; - FILE_D& RANK_8, // blackQueens; - (FILE_A | FILE_H) & RANK_8, // blackRooks; - (FILE_B | FILE_G) & RANK_8, // blackKnights; - (FILE_C | FILE_F) & RANK_8, // blackBishops; - RANK_7, // blackPawns; -}; - -int PIECE_VALUES[] = { - 0, // EMPTY - 100, // PAWN - 300, // KNIGHT - 300, // BISHOP - 500, // ROOK - 900, // QUEEN - 42000 // KING -}; - -int PAWN_BONUS[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, -40, 0, 0, 0, - 1, 2, 3, -10, -10, 3, 2, 1, 2, 4, 6, 8, 8, 6, 4, 2, - 3, 6, 9, 12, 12, 9, 6, 3, 4, 8, 12, 16, 16, 12, 8, 4, - 5, 10, 15, 20, 20, 15, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0}; - -int KNIGHT_BONUS[] = {-10, -30, -10, -10, -10, -10, -30, -10, -10, 0, 0, 0, 0, - 0, 0, -10, -10, 0, 5, 5, 5, 5, 0, -10, -10, 0, - 5, 10, 10, 5, 0, -10, -10, 0, 5, 10, 10, 5, 0, - -10, -10, 0, 5, 5, 5, 5, 0, -10, -10, 0, 0, 0, - 0, 0, 0, -10, -10, -10, -10, -10, -10, -10, -10, -10}; - -int BISHOP_BONUS[] = {-10, -10, -20, -10, -10, -20, -10, -10, -10, 0, 0, 0, 0, - 0, 0, -10, -10, 0, 5, 5, 5, 5, 0, -10, -10, 0, - 5, 10, 10, 5, 0, -10, -10, 0, 5, 10, 10, 5, 0, - -10, -10, 0, 5, 5, 5, 5, 0, -10, -10, 0, 0, 0, - 0, 0, 0, -10, -10, -10, -10, -10, -10, -10, -10, -10}; - -int KING_BONUS[] = {0, 20, 40, -20, 0, -20, 40, 20, -20, -20, -20, -20, -20, - -20, -20, -20, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40, -40}; - -int KING_ENDGAME_BONUS[] = {0, 10, 20, 30, 30, 20, 10, 0, 10, 20, 30, 40, 40, 30, 20, 10, - 20, 30, 40, 50, 50, 40, 30, 20, 30, 40, 50, 60, 60, 50, 40, 30, - 30, 40, 50, 60, 60, 50, 40, 30, 20, 30, 40, 50, 50, 40, 30, 20, - 10, 20, 30, 40, 40, 30, 20, 10, 0, 10, 20, 30, 30, 20, 10, 0}; - -int FLIP_VERTICAL[] = {56, 57, 58, 59, 60, 61, 62, 63, 48, 49, 50, 51, 52, 53, 54, 55, - 40, 41, 42, 43, 44, 45, 46, 47, 32, 33, 34, 35, 36, 37, 38, 39, - 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, - 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}; - -void getInitialGame(Game* game) { - game->position.board = INITIAL_BOARD; - game->position.toMove = WHITE; - game->position.epSquare = -1; - game->position.castlingRights = CASTLE_KINGSIDE_WHITE | CASTLE_QUEENSIDE_WHITE | - CASTLE_KINGSIDE_BLACK | CASTLE_QUEENSIDE_BLACK; - game->position.halfmoveClock = 0; - game->position.fullmoveNumber = 1; - - game->moveListLen = 0; - memset(game->moveList, 0, MAX_PLYS_PER_GAME * sizeof(int)); - memset(game->positionHistory, 0, MAX_PLYS_PER_GAME * MAX_FEN_LEN * sizeof(char)); - memcpy(game->positionHistory[0], INITIAL_FEN, sizeof(INITIAL_FEN)); -} - -void getFenGame(Game* game, char fen[]) { - int fenLen = loadFen(&(game->position), fen); - - game->moveListLen = 0; - memset(game->moveList, 0, MAX_PLYS_PER_GAME * sizeof(int)); - memset(game->positionHistory, 0, MAX_PLYS_PER_GAME * MAX_FEN_LEN * sizeof(char)); - memcpy(game->positionHistory[0], fen, fenLen); -} - -void insertPiece(Board* board, Bitboard position, char pieceCode) { - switch(pieceCode) { - case 'P': - board->whitePawns |= position; - break; - case 'N': - board->whiteKnights |= position; - break; - case 'B': - board->whiteBishops |= position; - break; - case 'R': - board->whiteRooks |= position; - break; - case 'Q': - board->whiteQueens |= position; - break; - case 'K': - board->whiteKing |= position; - break; - - case 'p': - board->blackPawns |= position; - break; - case 'n': - board->blackKnights |= position; - break; - case 'b': - board->blackBishops |= position; - break; - case 'r': - board->blackRooks |= position; - break; - case 'q': - board->blackQueens |= position; - break; - case 'k': - board->blackKing |= position; - break; - } -} - -int loadFen(Position* position, char fen[]) { - // ===== BOARD ===== - position->board = EMPTY_BOARD; - - int rank = 7; - int boardPos = rank * 8; - char* charPos = fen; - - char pieceCode = *(charPos); - - while(pieceCode != ' ') { - if(pieceCode == '/') { - rank--; - boardPos = rank * 8; - } else if(isdigit(pieceCode)) { - int emptySquares = atoi(charPos); - boardPos += emptySquares; - } else { - insertPiece(&(position->board), index2bb(boardPos++), pieceCode); - } - - pieceCode = *(++charPos); - } - - // ===== TO MOVE ===== - char* nextFenField = strchr(fen, ' ') + 1; - - if(*nextFenField == 'b') { - position->toMove = BLACK; - } else { - position->toMove = WHITE; - } - - // ===== CASTLING RIGHTS ===== - nextFenField = strchr(nextFenField, ' ') + 1; - - position->castlingRights = 0; - if(strchr(nextFenField, 'K')) position->castlingRights |= CASTLE_KINGSIDE_WHITE; - if(strchr(nextFenField, 'Q')) position->castlingRights |= CASTLE_QUEENSIDE_WHITE; - if(strchr(nextFenField, 'k')) position->castlingRights |= CASTLE_KINGSIDE_BLACK; - if(strchr(nextFenField, 'q')) position->castlingRights |= CASTLE_QUEENSIDE_BLACK; - - // ===== EN PASSANT ===== - nextFenField = strchr(nextFenField, ' ') + 1; - - if(*nextFenField == '-') { - position->epSquare = -1; - } else { - position->epSquare = str2index(nextFenField); - } - - // ===== HALF MOVE CLOCK ===== - if(!strchr(nextFenField, ' ')) { - position->halfmoveClock = 0; - position->fullmoveNumber = 1; - return 1 + nextFenField - fen; - } - nextFenField = strchr(nextFenField, ' ') + 1; - - position->halfmoveClock = atoi(nextFenField); - - // ===== FULL MOVE NUMBER ===== - if(!strchr(nextFenField, ' ')) { - position->fullmoveNumber = 1; - return 1 + nextFenField - fen; - } - nextFenField = strchr(nextFenField, ' ') + 1; - - position->fullmoveNumber = atoi(nextFenField); - - return 1 + nextFenField - fen; -} - -int toFen(char* fen, Position* position) { - int charCount = toMinFen(fen, position); - fen[charCount - 1] = ' '; - - // ===== HALF MOVE CLOCK ===== - snprintf(&fen[charCount++], sizeof(&fen[charCount++]), "%d", position->halfmoveClock); - if(position->halfmoveClock >= 10) { - charCount++; - if(position->halfmoveClock >= 100) { - charCount++; - } - } - fen[charCount++] = ' '; - - // ===== FULL MOVE NUMBER ===== - snprintf(&fen[charCount++], sizeof(&fen[charCount++]), "%d", position->fullmoveNumber); - if(position->fullmoveNumber >= 10) { - charCount++; - if(position->fullmoveNumber >= 100) { - charCount++; - } - } - fen[charCount++] = '\0'; - - return charCount; -} - -int toMinFen(char* fen, Position* position) { - int charCount = 0; - - // ===== BOARD ===== - int rank = 7; - int file = 0; - int* emptyCount = 0; - - Bitboard empties = getEmptySquares(&(position->board)); - Bitboard bb; - - while(rank >= 0) { - bb = index2bb(8 * rank + file); - - if(bb & empties) { - emptyCount++; - } else { - if(emptyCount != 0) { - snprintf(&fen[charCount++], 2, "%ls", emptyCount); - emptyCount = 0; - } - fen[charCount++] = bb2char(bb, &(position->board)); - } - - file++; - if(file > 7) { - if(emptyCount != 0) { - snprintf(&fen[charCount++], 2, "%ls", emptyCount); - emptyCount = 0; - } - file = 0; - rank--; - fen[charCount++] = '/'; - } - } - fen[charCount - 1] = ' '; - - // ===== TO MOVE ===== - if(position->toMove == BLACK) { - fen[charCount++] = 'b'; - } else { - fen[charCount++] = 'w'; - } - fen[charCount++] = ' '; - - // ===== CASTLING RIGHTS ===== - if(position->castlingRights == 0) { - fen[charCount++] = '-'; - } else { - if(position->castlingRights & CASTLE_KINGSIDE_WHITE) { - fen[charCount++] = 'K'; - } - if(position->castlingRights & CASTLE_QUEENSIDE_WHITE) { - fen[charCount++] = 'Q'; - } - if(position->castlingRights & CASTLE_KINGSIDE_BLACK) { - fen[charCount++] = 'k'; - } - if(position->castlingRights & CASTLE_QUEENSIDE_BLACK) { - fen[charCount++] = 'q'; - } - } - fen[charCount++] = ' '; - - // ===== EN PASSANT ===== - if(position->epSquare == -1) { - fen[charCount++] = '-'; - } else { - fen[charCount++] = getFile(position->epSquare); - fen[charCount++] = getRank(position->epSquare); - } - fen[charCount++] = '\0'; - - return charCount; -} - -void getMovelistGame(Game* game, char moves[]) { - getInitialGame(game); - - for(int i = 0; i < strlen(moves) - 3; i += 5) { - makeMove(game, parseMove(&moves[i])); - if(moves[i + 5] == ' ') i++; // FIXME Queening - } -} - -// ========= UTILITY ========= - -BOOL fromInitial(Game* game) { - if(strcmp(game->positionHistory[0], INITIAL_FEN) == 0) - return TRUE; - else - return FALSE; -} - -Bitboard index2bb(int index) { - Bitboard bb = 1; - return bb << index; -} - -int str2index(char* str) { - int i, file_num = 0, rank_num = 0; - for(i = 0; i < 8; i++) { - if(str[0] == FILES[i]) file_num = i; - if(str[1] == RANKS[i]) rank_num = i; - } - return 8 * rank_num + file_num; -} - -Bitboard str2bb(char* str) { - return index2bb(str2index(str)); -} - -BOOL isSet(Bitboard bb, int index) { - if(bb & index2bb(index)) - return TRUE; - else - return FALSE; -} - -Bitboard lsb(Bitboard bb) { - int i; - for(i = 0; i < NUM_SQUARES; i++) { - Bitboard bit = index2bb(i); - if(bb & bit) return bit; - } - return 0; -} - -Bitboard msb(Bitboard bb) { - int i; - for(i = 0; i < NUM_SQUARES; i++) { - Bitboard bit = index2bb(63 - i); - if(bb & bit) return bit; - } - return 0; -} - -int bb2index(Bitboard bb) { - int i; - for(i = 0; i < NUM_SQUARES; i++) { - Bitboard bit = index2bb(i); - if(bb & bit) return i; - } - return -1; -} - -char* movelist2str(Game* game) { - char* movestr = NULL; - - if(game->moveListLen == 0) { - movestr = (char*)malloc(sizeof(char)); - movestr[0] = 0; - return movestr; - } - - movestr = (char*)malloc(5 * game->moveListLen); - - int i; - for(i = 0; i < game->moveListLen; i++) { - int leaving = getFrom(game->moveList[i]); - int arriving = getTo(game->moveList[i]); - movestr[5 * i] = getFile(leaving); - movestr[5 * i + 1] = getRank(leaving); - movestr[5 * i + 2] = getFile(arriving); - movestr[5 * i + 3] = getRank(arriving); - movestr[5 * i + 4] = ' '; - } - - movestr[5 * game->moveListLen - 1] = 0; - - return movestr; -} - -Move getLastMove(Game* game) { - if(game->moveListLen == 0) - return 0; - else - return game->moveList[game->moveListLen - 1]; -} - -BOOL startsWith(const char* str, const char* pre) { - size_t lenpre = strlen(pre), lenstr = strlen(str); - - if(lenpre > lenstr) return FALSE; - - return strncmp(pre, str, lenpre) == 0 ? TRUE : FALSE; -} - -int countBookOccurrences(Game* game) { - FILE* fp = fopen("book.txt", "r"); - - if(fp == NULL) return 0; - - char* moveList = movelist2str(game); - char* line = (char*)malloc(sizeof(char) * MAX_BOOK_ENTRY_LEN); - int charPos = 0, occurrences = 0; - - while(TRUE) { - char ch = getc(fp); - line[charPos++] = ch; - - if(ch == '\n' || ch == EOF) { - line[charPos - 1] = '\0'; - - if(startsWith(line, moveList) && strlen(line) > strlen(moveList) + 4) { - occurrences++; - } - - if(ch == EOF) break; - - charPos = 0; - } - } - - fclose(fp); - free(line); - free(moveList); - - return occurrences; -} - -Move getBookMove(Game* game) { - Move move = 0; - int moveNum = rand() % countBookOccurrences(game); - - FILE* fp = fopen("book.txt", "r"); - - if(fp == NULL) return 0; - - char* moveList = movelist2str(game); - char* line = (char*)malloc(sizeof(char) * MAX_BOOK_ENTRY_LEN); - int charPos = 0, occurrences = 0; - - while(TRUE) { - char ch = getc(fp); - line[charPos++] = ch; - - if(ch == '\n') { - line[charPos] = '\0'; - - if(startsWith(line, moveList)) { - if(occurrences == moveNum) { - int ind = game->moveListLen * 5; - move = parseMove(&line[ind]); - break; - } - occurrences++; - } - - charPos = 0; - } - } - - fclose(fp); - free(line); - free(moveList); - - return move; -} - -char getFile(int position) { - int file = position % 8; - return FILES[file]; -} - -char getRank(int position) { - int rank = (int)(position / 8); - return RANKS[rank]; -} - -Move generateMove(int leavingSquare, int arrivingSquare) { - int leaving = (leavingSquare << 8); - int arriving = arrivingSquare; - return (Move)(leaving + arriving); -} - -int getFrom(Move move) { - return (move >> 8) & 0xFF; -} - -int getTo(Move move) { - return move & 0xFF; -} - -int bb2piece(Bitboard position, Board* board) { - if(position & board->whitePawns) return WHITE | PAWN; - if(position & board->whiteKnights) return WHITE | KNIGHT; - if(position & board->whiteBishops) return WHITE | BISHOP; - if(position & board->whiteRooks) return WHITE | ROOK; - if(position & board->whiteQueens) return WHITE | QUEEN; - if(position & board->whiteKing) return WHITE | KING; - if(position & board->blackPawns) return BLACK | PAWN; - if(position & board->blackKnights) return BLACK | KNIGHT; - if(position & board->blackBishops) return BLACK | BISHOP; - if(position & board->blackRooks) return BLACK | ROOK; - if(position & board->blackQueens) return BLACK | QUEEN; - if(position & board->blackKing) return BLACK | KING; - - return EMPTY; -} - -char bb2char(Bitboard position, Board* board) { - if(position & board->whitePawns) return 'P'; - if(position & board->whiteKnights) return 'N'; - if(position & board->whiteBishops) return 'B'; - if(position & board->whiteRooks) return 'R'; - if(position & board->whiteQueens) return 'Q'; - if(position & board->whiteKing) return 'K'; - if(position & board->blackPawns) return 'p'; - if(position & board->blackKnights) return 'n'; - if(position & board->blackBishops) return 'b'; - if(position & board->blackRooks) return 'r'; - if(position & board->blackQueens) return 'q'; - if(position & board->blackKing) return 'k'; - - return '?'; -} - -char* bb2str(Bitboard position, Board* board) { - if((position & board->whitePawns) | (position & board->blackPawns)) return "Pawn"; - if((position & board->whiteKnights) | (position & board->blackKnights)) return "Knight"; - if((position & board->whiteBishops) | (position & board->blackBishops)) return "Bishop"; - if((position & board->whiteRooks) | (position & board->blackRooks)) return "Rook"; - if((position & board->whiteQueens) | (position & board->blackQueens)) return "Queen"; - if((position & board->whiteKing) | (position & board->blackKing)) return "King"; - - return "?"; -} - -void printBitboard(Bitboard bitboard) { - int rank, file; - - printf("\n"); - for(rank = 0; rank < 8; rank++) { - printf("%d", 8 - rank); - for(file = 0; file < 8; file++) { - if(bitboard >> (file + (7 - rank) * 8) & 1) { - printf(" #"); - } else { - printf(" ."); - } - } - printf("\n"); - } - printf(" a b c d e f g h\n"); - fflush(stdout); -} - -char getPieceChar(Bitboard position, Board* board) { - if(position & board->whiteKing) return 'K'; - if(position & board->whiteQueens) return 'Q'; - if(position & board->whiteRooks) return 'R'; - if(position & board->whiteKnights) return 'N'; - if(position & board->whiteBishops) return 'B'; - if(position & board->whitePawns) return 'P'; - if(position & board->blackKing) return 'k'; - if(position & board->blackQueens) return 'q'; - if(position & board->blackRooks) return 'r'; - if(position & board->blackKnights) return 'n'; - if(position & board->blackBishops) return 'b'; - if(position & board->blackPawns) return 'p'; - return '.'; -} - -void printBoard(Board* board) { - int rank, file; - - printf("\n"); - for(rank = 0; rank < 8; rank++) { - printf("%d", 8 - rank); - for(file = 0; file < 8; file++) { - printf(" %c", getPieceChar((FILES_BB[file] & RANKS_BB[7 - rank]), board)); - } - printf("\n"); - } - printf(" a b c d e f g h\n"); - - fflush(stdout); -} - -void printGame(Game* game) { - // printf("Game -> %p (%lu)", game, sizeof(*game)); - // printBoard(&(game->position.board)); - // printf("board -> %p (%lu)\n", &(game->position.board), sizeof(game->position.board)); - // printf("toMove = %d -> %p (%lu)\n", game->position.toMove, &game->position.toMove, sizeof(game->position.toMove)); - // printf("ep = %d -> %p (%lu)\n", game->position.epSquare, &game->position.epSquare, sizeof(game->position.epSquare)); - // printf("castle rights = %d -> %p (%lu)\n", game->position.castlingRights, &game->position.castlingRights, sizeof(game->position.castlingRights)); - // printf("half clock = %d -> %p (%lu)\n", game->position.halfmoveClock, &game->position.halfmoveClock, sizeof(game->position.halfmoveClock)); - // printf("full num = %d -> %p (%lu)\n", game->position.fullmoveNumber, &game->position.fullmoveNumber, sizeof(game->position.fullmoveNumber)); - - // printf("moveListLen = %d -> %p (%lu)\n", game->moveListLen, &game->moveListLen, sizeof(game->moveListLen)); - // printf("moveList -> %p (%lu)\n", game->moveList, sizeof(game->moveList)); - // printf("positionHistory -> %p (%lu)\n", game->positionHistory, sizeof(game->positionHistory)); - // fflush(stdout); -} - -Bitboard not(Bitboard bb) { - return ~bb & ALL_SQUARES; -} - -char opponent(char color) { - switch(color) { - case WHITE: - return BLACK; - case BLACK: - return WHITE; - } - return -1; -} - -int countBits(Bitboard bb) { - int bitCount = 0; - Bitboard position = 1; - - for(int i = 0; i < NUM_SQUARES; i++) { - if(position & bb) { - bitCount++; - } - position = position << 1; - } - - return bitCount; -} - -void sortNodes(Node* sortedNodes, Node* nodes, int len, char color) { - Node nodeBuffer[len]; - - int i, j; - BOOL sorted; - for(i = 0; i < len; i++) { - sorted = FALSE; - - for(j = 0; j < i; j++) { - if((color == WHITE && nodes[i].score > sortedNodes[j].score) || - (color == BLACK && nodes[i].score < sortedNodes[j].score)) { - sorted = TRUE; - memcpy(nodeBuffer, &sortedNodes[j], (i - j) * sizeof(Node)); - memcpy(&sortedNodes[j + 1], nodeBuffer, (i - j) * sizeof(Node)); - sortedNodes[j] = nodes[i]; - break; - } - } - - if(sorted == FALSE) { - sortedNodes[i] = nodes[i]; - } - } -} - -void printMove(Move move) { - printf( - "%c%c to %c%c", - getFile(getFrom(move)), - getRank(getFrom(move)), - getFile(getTo(move)), - getRank(getTo(move))); -} - -void printFullMove(Move move, Board* board) { - Bitboard leavingBB = index2bb(getFrom(move)); - printf("%s from ", bb2str(leavingBB, board)); - printMove(move); -} - -void printLegalMoves(Position* position) { - int i; - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = legalMoves(moves, position, position->toMove); - for(i = 0; i < moveCount; i++) { - printf("%2d. ", i + 1); - printFullMove(moves[i], &(position->board)); - // printMove(moves[i]); - printf("\n"); - } - fflush(stdout); -} - -void printNode(Node node) { - printMove(node.move); - printf(": %d", node.score); -} - -void getTimestamp(char* timestamp) { - time_t timer; - struct tm* tm_info; - - time(&timer); - tm_info = localtime(&timer); - - strftime(timestamp, 20, "%Y-%m-%d_%H.%M.%S", tm_info); -} - -void dumpContent(Game* game) { - char* movelist = movelist2str(game); - - char filename[50]; - sprintf(filename, "chess_game_"); - getTimestamp(&filename[strlen(filename)]); - sprintf(&filename[strlen(filename)], ".txt"); - - FILE* file = fopen(filename, "w+"); - - fprintf(file, "movelist = %s\nposition history:\n", movelist); - - int i; - for(i = 0; i < game->moveListLen + 1; i++) fprintf(file, "%s\n", game->positionHistory[i]); - - free(movelist); - fclose(file); - - printf("Dumped game content to: %s\n", filename); - fflush(stdout); -} - -void dumpPGN(Game* game, char color, BOOL hasAI) { - char filename[50]; - sprintf(filename, "chess_game_"); - getTimestamp(&filename[strlen(filename)]); - sprintf(&filename[strlen(filename)], ".pgn"); - - FILE* file = fopen(filename, "w+"); - - char date[12]; - time_t timer; - struct tm* tm_info; - time(&timer); - tm_info = localtime(&timer); - strftime(date, 11, "%Y.%m.%d", tm_info); - - fprintf(file, "[Event \"Casual Game\"]\n"); - fprintf(file, "[Site \"?\"]\n"); - fprintf(file, "[Date \"%s\"]\n", date); - fprintf(file, "[Round \"-\"]\n"); - - if(hasAI) { - if(color == WHITE) { - fprintf(file, "[White \"%s\"]\n", HUMAN_NAME); - fprintf(file, "[Black \"%s\"]\n", ENGINE_NAME); - } else { - fprintf(file, "[White \"%s\"]\n", ENGINE_NAME); - fprintf(file, "[Black \"%s\"]\n", HUMAN_NAME); - } - } else { - fprintf(file, "[White \"Unknown Human Player\"]\n"); - fprintf(file, "[Black \"Unknown Human Player\"]\n"); - } - - if(hasGameEnded(&game->position)) { - if(endNodeEvaluation(&game->position) == winScore(WHITE)) { - fprintf(file, "[Result \"1-0\"]\n"); - } else if(endNodeEvaluation(&game->position) == winScore(BLACK)) { - fprintf(file, "[Result \"0-1\"]\n"); - } else if(endNodeEvaluation(&game->position) == 0) { - fprintf(file, "[Result \"1/2-1/2\"]\n"); - } - } else { - fprintf(file, "[Result \"*\"]\n"); - } - - if(strcmp(game->positionHistory[0], INITIAL_FEN) == 0) { - fprintf(file, "[Variant \"Standard\"]\n"); - } else { - fprintf(file, "[Variant \"From Position\"]\n"); - fprintf(file, "[FEN \"%s\"]\n", game->positionHistory[0]); - } - - fprintf(file, "[PlyCount \"%d\"]\n\n", game->moveListLen); - - int i; - char ply[8]; - for(i = 0; i < game->moveListLen; i++) { - if(i % 2 == 0) fprintf(file, "%d. ", 1 + (i / 2)); - move2str(ply, game, i); - fprintf(file, "%s ", ply); - } - - fclose(file); - - printf("Dumped game pgn to: %s\n", filename); - fflush(stdout); -} - -void move2str(char* str, Game* game, int moveNumber) { - Position posBefore, posAfter; - loadFen(&posBefore, game->positionHistory[moveNumber]); - loadFen(&posAfter, game->positionHistory[moveNumber + 1]); - Move move = game->moveList[moveNumber]; - int leavingSquare = getFrom(move); - int arrivingSquare = getTo(move); - - Bitboard leavingBB = index2bb(leavingSquare); - Bitboard arrivingBB = index2bb(arrivingSquare); - - int length = 0; - if((leavingBB & (posBefore.board.whiteKing | posBefore.board.blackKing)) && - abs(leavingSquare - arrivingSquare) == 2) { // if castling - if(arrivingBB & FILE_G) { - sprintf(str, "O-O"); - length += 3; - } else if(arrivingBB & FILE_C) { - sprintf(str, "O-O-O"); - length += 5; - } - } else { // if not castling - if(leavingBB & (posBefore.board.whitePawns | posBefore.board.blackPawns)) { - if(arrivingBB & getOccupiedSquares(&(posBefore.board))) { - str[length++] = getFile(leavingSquare); - } - } else { - str[length++] = bb2char(leavingBB, &(posBefore.board)); - } - - if(isAmbiguous(&posBefore, move)) { - if(countBits(getTwinPieces(leavingBB, &(posBefore.board)) & fileFilter(leavingBB)) == - 1) { - str[length++] = getFile(leavingSquare); - } else { - str[length++] = getRank(leavingSquare); - } - } - - if(bb2piece(arrivingBB, &(posBefore.board)) != EMPTY) { - str[length++] = 'x'; - } - - str[length++] = getFile(arrivingSquare); - str[length++] = getRank(arrivingSquare); - } - - if(isCheckmate(&posAfter)) { - str[length++] = '#'; - } else if(isCheck(&(posAfter.board), posAfter.toMove)) { - str[length++] = '+'; - } - - str[length++] = 0; -} - -BOOL isAmbiguous(Position* position, Move move) { - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = legalMoves(moves, position, position->toMove); - Bitboard targetBB = index2bb(getTo(move)); - Bitboard attackerBB = index2bb(getFrom(move)); - int attackerPiece = bb2piece(attackerBB, &(position->board)); - - int attackerCount = 0; - for(int i = 0; i < moveCount; i++) { - Bitboard tgtBB = index2bb(getTo(moves[i])); - Bitboard atkBB = index2bb(getFrom(moves[i])); - - if(attackerPiece == bb2piece(atkBB, &(position->board)) && (targetBB & tgtBB)) { - attackerCount++; - } - } - - return attackerCount > 1; -} - -unsigned long hashPosition(Position* position) { - char fen[MAX_FEN_LEN]; - toMinFen(fen, position); - - unsigned long hash = 5381; - int c, i = 0; - - while((c = fen[i++])) { - hash = ((hash << 5) + hash) + c; - } - - return hash; -} - -void writeToHashFile(Position* position, int evaluation, int depth) { - FILE* fp = fopen("hashfile", "a"); - - if(fp == NULL) return; - - char fen[MAX_FEN_LEN]; - toMinFen(fen, position); - - fprintf(fp, "%08lx %d %d %s\n", hashPosition(position), depth, evaluation, fen); - fclose(fp); -} - -// ====== BOARD FILTERS ====== - -Bitboard getColoredPieces(Board* board, char color) { - if(color == WHITE) { - return board->whiteKing | board->whiteQueens | board->whiteRooks | board->whiteKnights | - board->whiteBishops | board->whitePawns; - } else { - return board->blackKing | board->blackQueens | board->blackRooks | board->blackKnights | - board->blackBishops | board->blackPawns; - } -} - -Bitboard getEmptySquares(Board* board) { - return not(getOccupiedSquares(board)); -} - -Bitboard getOccupiedSquares(Board* board) { - return getColoredPieces(board, WHITE) | getColoredPieces(board, BLACK); -} - -Bitboard getTwinPieces(Bitboard position, Board* board) { - if(position & board->whiteKing) return board->whiteKing; - if(position & board->whiteQueens) return board->whiteQueens; - if(position & board->whiteRooks) return board->whiteRooks; - if(position & board->whiteKnights) return board->whiteKnights; - if(position & board->whiteBishops) return board->whiteBishops; - if(position & board->whitePawns) return board->whitePawns; - - if(position & board->blackKing) return board->blackKing; - if(position & board->blackQueens) return board->blackQueens; - if(position & board->blackRooks) return board->blackRooks; - if(position & board->blackKnights) return board->blackKnights; - if(position & board->blackBishops) return board->blackBishops; - if(position & board->blackPawns) return board->blackPawns; - - return position; -} - -Bitboard fileFilter(Bitboard positions) { - Bitboard filter = 0; - int i; - - for(i = 0; i < 8; i++) - if(positions & FILES_BB[i]) filter |= FILES_BB[i]; - return filter; -} - -Bitboard rankFilter(Bitboard positions) { - Bitboard filter = 0; - int i; - - for(i = 0; i < 8; i++) - if(positions & RANKS_BB[i]) filter |= RANKS_BB[i]; - return filter; -} - -// ======= DIRECTIONS ======== - -Bitboard east(Bitboard bb) { - return (bb << 1) & 0xfefefefefefefefe; // not(FILE_A) -} - -Bitboard west(Bitboard bb) { - return (bb >> 1) & 0x7f7f7f7f7f7f7f7f; // not(FILE_H) -} - -Bitboard north(Bitboard bb) { - return (bb << 8) & 0xffffffffffffff00; // not(RANK_1) -} - -Bitboard south(Bitboard bb) { - return (bb >> 8) & 0x00ffffffffffffff; // not(RANK_8) -} - -Bitboard NE(Bitboard bb) { - return (bb << 9) & 0xfefefefefefefe00; // not(RANK_1 | FILE_A) -} - -Bitboard NW(Bitboard bb) { - return (bb << 7) & 0x7f7f7f7f7f7f7f00; // not(RANK_1 | FILE_H) -} - -Bitboard SE(Bitboard bb) { - return (bb >> 7) & 0x00fefefefefefefe; // not(RANK_8 | FILE_A) -} - -Bitboard SW(Bitboard bb) { - return (bb >> 9) & 0x007f7f7f7f7f7f7f; // not(RANK_8 | FILE_H) -} - -Bitboard WNW(Bitboard moving_piece) { - return (moving_piece << 6) & 0x3f3f3f3f3f3f3f00; // not(RANK_1 | FILE_G | FILE_H) -} - -Bitboard ENE(Bitboard moving_piece) { - return (moving_piece << 10) & 0xfcfcfcfcfcfcfc00; // not(RANK_1 | FILE_A | FILE_B) -} - -Bitboard NNW(Bitboard moving_piece) { - return (moving_piece << 15) & 0x7f7f7f7f7f7f0000; // not(RANK_1 | RANK_2 | FILE_H) -} - -Bitboard NNE(Bitboard moving_piece) { - return (moving_piece << 17) & 0xfefefefefefe0000; // not(RANK_1 | RANK_2 | FILE_A) -} - -Bitboard ESE(Bitboard moving_piece) { - return (moving_piece >> 6) & 0x00fcfcfcfcfcfcfc; // not(RANK_8| FILE_A | FILE_B) -} - -Bitboard WSW(Bitboard moving_piece) { - return (moving_piece >> 10) & 0x003f3f3f3f3f3f3f; // not(RANK_8 | FILE_G | FILE_H) -} - -Bitboard SSE(Bitboard moving_piece) { - return (moving_piece >> 15) & 0x0000fefefefefefe; // not(RANK_7 | RANK_8 | FILE_A) -} - -Bitboard SSW(Bitboard moving_piece) { - return (moving_piece >> 17) & 0x00007f7f7f7f7f7f; // not(RANK_7 | RANK_8 | FILE_H) -} - -// ========== PAWN =========== - -Bitboard getPawns(Board* board) { - return board->whitePawns | board->blackPawns; -} - -Bitboard pawnSimplePushes(Bitboard moving_piece, Board* board, char color) { - switch(color) { - case WHITE: - return north(moving_piece) & getEmptySquares(board); - case BLACK: - return south(moving_piece) & getEmptySquares(board); - } - return 0; -} - -Bitboard pawnDoublePushes(Bitboard moving_piece, Board* board, char color) { - switch(color) { - case WHITE: - return north(pawnSimplePushes(moving_piece, board, color)) & - (getEmptySquares(board) & RANK_4); - case BLACK: - return south(pawnSimplePushes(moving_piece, board, color)) & - (getEmptySquares(board) & RANK_5); - } - return 0; -} - -Bitboard pawnPushes(Bitboard moving_piece, Board* board, char color) { - return pawnSimplePushes(moving_piece, board, color) | - pawnDoublePushes(moving_piece, board, color); -} - -Bitboard pawnEastAttacks(Bitboard moving_piece, Board* board, char color) { - switch(color) { - case WHITE: - return NE(moving_piece); - case BLACK: - return SE(moving_piece); - } - return 0; -} - -Bitboard pawnWestAttacks(Bitboard moving_piece, Board* board, char color) { - switch(color) { - case WHITE: - return NW(moving_piece); - case BLACK: - return SW(moving_piece); - } - return 0; -} - -Bitboard pawnAttacks(Bitboard moving_piece, Board* board, char color) { - return pawnEastAttacks(moving_piece, board, color) | - pawnWestAttacks(moving_piece, board, color); -} - -Bitboard pawnSimpleCaptures(Bitboard moving_piece, Board* board, char color) { - return pawnAttacks(moving_piece, board, color) & getColoredPieces(board, opponent(color)); -} - -Bitboard pawnEpCaptures(Bitboard moving_piece, Position* position, char color) { - if(position->epSquare == -1) return 0; - - Bitboard valid_ep_square = 0; - - switch(color) { - case WHITE: - valid_ep_square = index2bb(position->epSquare) & RANK_6; - break; - case BLACK: - valid_ep_square = index2bb(position->epSquare) & RANK_3; - break; - } - - return pawnAttacks(moving_piece, &(position->board), color) & valid_ep_square; -} - -Bitboard pawnCaptures(Bitboard moving_piece, Position* position, char color) { - return pawnSimpleCaptures(moving_piece, &(position->board), color) | - pawnEpCaptures(moving_piece, position, color); -} - -Bitboard pawnMoves(Bitboard moving_piece, Position* position, char color) { - return pawnPushes(moving_piece, &(position->board), color) | - pawnCaptures(moving_piece, position, color); -} - -BOOL isDoublePush(int leaving, int arriving) { - if((index2bb(leaving) & RANK_2) && (index2bb(arriving) & RANK_4)) return TRUE; - if((index2bb(leaving) & RANK_7) && (index2bb(arriving) & RANK_5)) return TRUE; - return FALSE; -} - -char getEpSquare(int leaving) { - if(index2bb(leaving) & RANK_2) return leaving + 8; - if(index2bb(leaving) & RANK_7) return leaving - 8; - return -1; -} - -BOOL isDoubledPawn(Bitboard position, Board* board, char color) { - if(color == WHITE) { - if(countBits(board->whitePawns & fileFilter(position)) > 1) return TRUE; - } else { - if(countBits(board->blackPawns & fileFilter(position)) > 1) return TRUE; - } - - return FALSE; -} - -BOOL isIsolatedPawn(Bitboard position, Board* board, char color) { - Bitboard sideFiles = fileFilter(east(position) | west(position)); - - if(color == WHITE) { - if(countBits(board->whitePawns & sideFiles) == 0) return TRUE; - } else { - if(countBits(board->blackPawns & sideFiles) == 0) return TRUE; - } - - return FALSE; -} - -BOOL isBackwardsPawn(Bitboard position, Board* board, char color) { - Bitboard squaresFilter = east(position) | west(position); - - if(color == BLACK) { - squaresFilter |= northRay(squaresFilter); - if(countBits(board->blackPawns & squaresFilter) == 0) return TRUE; - } else { - squaresFilter |= southRay(squaresFilter); - if(countBits(board->whitePawns & squaresFilter) == 0) return TRUE; - } - - return FALSE; -} - -BOOL isPassedPawn(Bitboard position, Board* board, char color) { - Bitboard squaresFilter = 0; - - if(color == BLACK) { - squaresFilter |= southRay(east(position)) | southRay(west(position)) | southRay(position); - if(countBits(board->whitePawns & squaresFilter) == 0) return TRUE; - } else { - squaresFilter |= northRay(east(position)) | northRay(west(position)) | northRay(position); - if(countBits(board->blackPawns & squaresFilter) == 0) return TRUE; - } - - return FALSE; -} - -BOOL isOpenFile(Bitboard position, Board* board) { - if(countBits(getPawns(board) & fileFilter(position)) == 0) return TRUE; - return FALSE; -} - -BOOL isSemiOpenFile(Bitboard position, Board* board) { - if(countBits(getPawns(board) & fileFilter(position)) == 1) return TRUE; - return FALSE; -} - -// ========== KNIGHT ========= - -Bitboard getKnights(Board* board) { - return board->whiteKnights | board->blackKnights; -} - -Bitboard knightAttacks(Bitboard moving_piece) { - return NNE(moving_piece) | ENE(moving_piece) | NNW(moving_piece) | WNW(moving_piece) | - SSE(moving_piece) | ESE(moving_piece) | SSW(moving_piece) | WSW(moving_piece); -} - -Bitboard knightMoves(Bitboard moving_piece, Board* board, char color) { - return knightAttacks(moving_piece) & not(getColoredPieces(board, color)); -} - -Bitboard knightFill(Bitboard moving_piece, int jumps) { - Bitboard fill = moving_piece; - int i; - for(i = 0; i < jumps; i++) { - fill |= knightAttacks(fill); - } - return fill; -} - -int knightDistance(Bitboard leaving_square, Bitboard arriving_square) { - Bitboard fill = leaving_square; - int dist = 0; - - while((fill & arriving_square) == 0) { - dist++; - fill |= knightAttacks(fill); - } - return dist; -} - -// ========== KING =========== - -Bitboard getKing(Board* board, char color) { - if(color == WHITE) { - return board->whiteKing; - } else { - return board->blackKing; - } -} - -Bitboard kingAttacks(Bitboard moving_piece) { - Bitboard kingAtks = moving_piece | east(moving_piece) | west(moving_piece); - kingAtks |= north(kingAtks) | south(kingAtks); - return kingAtks & not(moving_piece); -} - -Bitboard kingMoves(Bitboard moving_piece, Board* board, char color) { - return kingAttacks(moving_piece) & not(getColoredPieces(board, color)); -} - -BOOL canCastleKingside(Position* position, char color) { - Bitboard emptyPositions = getEmptySquares(&(position->board)); - - switch(color) { - case WHITE: - if((position->castlingRights & CASTLE_KINGSIDE_WHITE) && - (FILE_E & RANK_1 & position->board.whiteKing) && (FILE_F & RANK_1 & emptyPositions) && - (FILE_G & RANK_1 & emptyPositions) && (FILE_H & RANK_1 & position->board.whiteRooks) && - (!isAttacked((FILE_E & RANK_1), &(position->board), opponent(color))) && - (!isAttacked((FILE_F & RANK_1), &(position->board), opponent(color))) && - (!isAttacked((FILE_G & RANK_1), &(position->board), opponent(color)))) - return TRUE; - else - return FALSE; - - case BLACK: - if((position->castlingRights & CASTLE_KINGSIDE_BLACK) && - (FILE_E & RANK_8 & position->board.blackKing) && (FILE_F & RANK_8 & emptyPositions) && - (FILE_G & RANK_8 & emptyPositions) && (FILE_H & RANK_8 & position->board.blackRooks) && - (!isAttacked((FILE_E & RANK_8), &(position->board), opponent(color))) && - (!isAttacked((FILE_F & RANK_8), &(position->board), opponent(color))) && - (!isAttacked((FILE_G & RANK_8), &(position->board), opponent(color)))) - return TRUE; - else - return FALSE; - } - return FALSE; -} - -BOOL canCastleQueenside(Position* position, char color) { - Bitboard emptyPositions = getEmptySquares(&(position->board)); - - switch(color) { - case WHITE: - if((position->castlingRights & CASTLE_QUEENSIDE_WHITE) && - (FILE_A & RANK_1 & position->board.whiteRooks) && (FILE_B & RANK_1 & emptyPositions) && - (FILE_C & RANK_1 & emptyPositions) && (FILE_D & RANK_1 & emptyPositions) && - (FILE_E & RANK_1 & position->board.whiteKing) && - (!isAttacked((FILE_C & RANK_1), &(position->board), opponent(color))) && - (!isAttacked((FILE_D & RANK_1), &(position->board), opponent(color))) && - (!isAttacked((FILE_E & RANK_1), &(position->board), opponent(color)))) - return TRUE; - else - return FALSE; - - case BLACK: - if((position->castlingRights & CASTLE_QUEENSIDE_BLACK) && - (FILE_A & RANK_8 & position->board.blackRooks) && (FILE_B & RANK_8 & emptyPositions) && - (FILE_C & RANK_8 & emptyPositions) && (FILE_D & RANK_8 & emptyPositions) && - (FILE_E & RANK_8 & position->board.blackKing) && - (!isAttacked((FILE_C & RANK_8), &(position->board), opponent(color))) && - (!isAttacked((FILE_D & RANK_8), &(position->board), opponent(color))) && - (!isAttacked((FILE_E & RANK_8), &(position->board), opponent(color)))) - return TRUE; - else - return FALSE; - } - return FALSE; -} - -char removeCastlingRights(char original_rights, char removed_rights) { - return (char)(original_rights & ~(removed_rights)); -} - -// ========== BISHOP ========= - -Bitboard getBishops(Board* board) { - return board->whiteBishops | board->blackBishops; -} - -Bitboard NE_ray(Bitboard bb) { - int i; - Bitboard ray = NE(bb); - - for(i = 0; i < 6; i++) { - ray |= NE(ray); - } - - return ray & ALL_SQUARES; -} - -Bitboard SE_ray(Bitboard bb) { - int i; - Bitboard ray = SE(bb); - - for(i = 0; i < 6; i++) { - ray |= SE(ray); - } - - return ray & ALL_SQUARES; -} - -Bitboard NW_ray(Bitboard bb) { - int i; - Bitboard ray = NW(bb); - - for(i = 0; i < 6; i++) { - ray |= NW(ray); - } - - return ray & ALL_SQUARES; -} - -Bitboard SW_ray(Bitboard bb) { - int i; - Bitboard ray = SW(bb); - - for(i = 0; i < 6; i++) { - ray |= SW(ray); - } - - return ray & ALL_SQUARES; -} - -Bitboard NE_attack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = lsb(NE_ray(single_piece) & getOccupiedSquares(board)); - if(blocker) { - return NE_ray(single_piece) ^ NE_ray(blocker); - } else { - return NE_ray(single_piece); - } -} - -Bitboard NW_attack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = lsb(NW_ray(single_piece) & getOccupiedSquares(board)); - if(blocker) { - return NW_ray(single_piece) ^ NW_ray(blocker); - } else { - return NW_ray(single_piece); - } -} - -Bitboard SE_attack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = msb(SE_ray(single_piece) & getOccupiedSquares(board)); - if(blocker) { - return SE_ray(single_piece) ^ SE_ray(blocker); - } else { - return SE_ray(single_piece); - } -} - -Bitboard SW_attack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = msb(SW_ray(single_piece) & getOccupiedSquares(board)); - if(blocker) { - return SW_ray(single_piece) ^ SW_ray(blocker); - } else { - return SW_ray(single_piece); - } -} - -Bitboard diagonalAttacks(Bitboard single_piece, Board* board, char color) { - return NE_attack(single_piece, board, color) | SW_attack(single_piece, board, color); -} - -Bitboard antiDiagonalAttacks(Bitboard single_piece, Board* board, char color) { - return NW_attack(single_piece, board, color) | SE_attack(single_piece, board, color); -} - -Bitboard bishopAttacks(Bitboard moving_pieces, Board* board, char color) { - return diagonalAttacks(moving_pieces, board, color) | - antiDiagonalAttacks(moving_pieces, board, color); -} - -Bitboard bishopMoves(Bitboard moving_piece, Board* board, char color) { - return bishopAttacks(moving_piece, board, color) & not(getColoredPieces(board, color)); -} - -// ========== ROOK =========== - -Bitboard getRooks(Board* board) { - return board->whiteRooks | board->blackRooks; -} - -Bitboard northRay(Bitboard moving_pieces) { - Bitboard ray_atks = north(moving_pieces); - - int i; - for(i = 0; i < 6; i++) { - ray_atks |= north(ray_atks); - } - - return ray_atks & ALL_SQUARES; -} - -Bitboard southRay(Bitboard moving_pieces) { - Bitboard ray_atks = south(moving_pieces); - - int i; - for(i = 0; i < 6; i++) { - ray_atks |= south(ray_atks); - } - - return ray_atks & ALL_SQUARES; -} - -Bitboard eastRay(Bitboard moving_pieces) { - Bitboard ray_atks = east(moving_pieces); - - int i; - for(i = 0; i < 6; i++) { - ray_atks |= east(ray_atks); - } - - return ray_atks & ALL_SQUARES; -} - -Bitboard westRay(Bitboard moving_pieces) { - Bitboard ray_atks = west(moving_pieces); - - int i; - for(i = 0; i < 6; i++) { - ray_atks |= west(ray_atks); - } - - return ray_atks & ALL_SQUARES; -} - -Bitboard northAttack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = lsb(northRay(single_piece) & getOccupiedSquares(board)); - - if(blocker) - return northRay(single_piece) ^ northRay(blocker); - else - return northRay(single_piece); -} - -Bitboard southAttack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = msb(southRay(single_piece) & getOccupiedSquares(board)); - - if(blocker) - return southRay(single_piece) ^ southRay(blocker); - else - return southRay(single_piece); -} - -Bitboard fileAttacks(Bitboard single_piece, Board* board, char color) { - return northAttack(single_piece, board, color) | southAttack(single_piece, board, color); -} - -Bitboard eastAttack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = lsb(eastRay(single_piece) & getOccupiedSquares(board)); - - if(blocker) - return eastRay(single_piece) ^ eastRay(blocker); - else - return eastRay(single_piece); -} - -Bitboard westAttack(Bitboard single_piece, Board* board, char color) { - Bitboard blocker = msb(westRay(single_piece) & getOccupiedSquares(board)); - - if(blocker) - return westRay(single_piece) ^ westRay(blocker); - else - return westRay(single_piece); -} - -Bitboard rankAttacks(Bitboard single_piece, Board* board, char color) { - return eastAttack(single_piece, board, color) | westAttack(single_piece, board, color); -} - -Bitboard rookAttacks(Bitboard moving_piece, Board* board, char color) { - return fileAttacks(moving_piece, board, color) | rankAttacks(moving_piece, board, color); -} - -Bitboard rookMoves(Bitboard moving_piece, Board* board, char color) { - return rookAttacks(moving_piece, board, color) & not(getColoredPieces(board, color)); -} - -// ========== QUEEN ========== - -Bitboard getQueens(Board* board) { - return board->whiteQueens | board->blackQueens; -} - -Bitboard queenAttacks(Bitboard moving_piece, Board* board, char color) { - return rookAttacks(moving_piece, board, color) | bishopAttacks(moving_piece, board, color); -} - -Bitboard queenMoves(Bitboard moving_piece, Board* board, char color) { - return rookMoves(moving_piece, board, color) | bishopMoves(moving_piece, board, color); -} - -// ======== MAKE MOVE ======== - -void clearPositions(Board* board, Bitboard positions) { - board->whiteKing = board->whiteKing & not(positions); - board->whiteQueens = board->whiteQueens & not(positions); - board->whiteRooks = board->whiteRooks & not(positions); - board->whiteKnights = board->whiteKnights & not(positions); - board->whiteBishops = board->whiteBishops & not(positions); - board->whitePawns = board->whitePawns & not(positions); - board->blackKing = board->blackKing & not(positions); - board->blackQueens = board->blackQueens & not(positions); - board->blackRooks = board->blackRooks & not(positions); - board->blackKnights = board->blackKnights & not(positions); - board->blackBishops = board->blackBishops & not(positions); - board->blackPawns = board->blackPawns & not(positions); -} - -void movePiece(Board* board, Move move) { - Bitboard leaving = index2bb(getFrom(move)); - Bitboard arriving = index2bb(getTo(move)); - - if(leaving & board->whiteKing) { - clearPositions(board, arriving | leaving); - board->whiteKing = arriving; - } else if(leaving & board->whiteQueens) { - clearPositions(board, arriving | leaving); - board->whiteQueens = board->whiteQueens | arriving; - } else if(leaving & board->whiteRooks) { - clearPositions(board, arriving | leaving); - board->whiteRooks = board->whiteRooks | arriving; - } else if(leaving & board->whiteKnights) { - clearPositions(board, arriving | leaving); - board->whiteKnights = board->whiteKnights | arriving; - } else if(leaving & board->whiteBishops) { - clearPositions(board, arriving | leaving); - board->whiteBishops = board->whiteBishops | arriving; - } else if(leaving & board->whitePawns) { - clearPositions(board, arriving | leaving); - board->whitePawns = board->whitePawns | arriving; - } else if(leaving & board->blackKing) { - clearPositions(board, arriving | leaving); - board->blackKing = arriving; - } else if(leaving & board->blackQueens) { - clearPositions(board, arriving | leaving); - board->blackQueens = board->blackQueens | arriving; - } else if(leaving & board->blackRooks) { - clearPositions(board, arriving | leaving); - board->blackRooks = board->blackRooks | arriving; - } else if(leaving & board->blackKnights) { - clearPositions(board, arriving | leaving); - board->blackKnights = board->blackKnights | arriving; - } else if(leaving & board->blackBishops) { - clearPositions(board, arriving | leaving); - board->blackBishops = board->blackBishops | arriving; - } else if(leaving & board->blackPawns) { - clearPositions(board, arriving | leaving); - board->blackPawns = board->blackPawns | arriving; - } -} - -void updatePosition(Position* newPosition, Position* position, Move move) { - memcpy(newPosition, position, sizeof(Position)); - int leavingSquare = getFrom(move); - int arrivingSquare = getTo(move); - Bitboard leavingBB = index2bb(leavingSquare); - Bitboard arrivingBB = index2bb(arrivingSquare); - - // ===== MOVE PIECE ===== - movePiece(&(newPosition->board), move); - - // ===== TO MOVE ===== - newPosition->toMove = opponent(position->toMove); - - // ===== MOVE COUNTS ===== - newPosition->halfmoveClock += 1; - if(position->toMove == BLACK) { - newPosition->fullmoveNumber += 1; - } - - if(arrivingBB & getOccupiedSquares(&(position->board))) { - newPosition->halfmoveClock = 0; - } - - // ===== PAWNS ===== - newPosition->epSquare = -1; - if((leavingBB & position->board.whitePawns) | (leavingBB & position->board.blackPawns)) { - newPosition->halfmoveClock = 0; - - if(arrivingSquare == position->epSquare) { - if(index2bb(position->epSquare) & RANK_3) { - clearPositions(&(newPosition->board), index2bb((int)(position->epSquare + 8))); - } - - if(index2bb(position->epSquare) & RANK_6) { - clearPositions(&(newPosition->board), index2bb((int)(position->epSquare - 8))); - } - } - - if(isDoublePush(leavingSquare, arrivingSquare)) { - newPosition->epSquare = getEpSquare(leavingSquare); - } - - if(arrivingBB & (RANK_1 | RANK_8)) { - clearPositions(&(newPosition->board), arrivingBB); - - if(position->toMove == WHITE) { - newPosition->board.whiteQueens = newPosition->board.whiteQueens | arrivingBB; - } else { - newPosition->board.blackQueens = newPosition->board.blackQueens | arrivingBB; - } - } - } - - // ===== CASTLING ===== - if(leavingSquare == str2index("a1")) { - newPosition->castlingRights = - removeCastlingRights(newPosition->castlingRights, CASTLE_QUEENSIDE_WHITE); - } else if(leavingSquare == str2index("h1")) { - newPosition->castlingRights = - removeCastlingRights(newPosition->castlingRights, CASTLE_KINGSIDE_WHITE); - } else if(leavingSquare == str2index("a8")) { - newPosition->castlingRights = - removeCastlingRights(newPosition->castlingRights, CASTLE_QUEENSIDE_BLACK); - } else if(leavingSquare == str2index("h8")) { - newPosition->castlingRights = - removeCastlingRights(newPosition->castlingRights, CASTLE_KINGSIDE_BLACK); - } - - if(leavingBB & position->board.whiteKing) { - newPosition->castlingRights = removeCastlingRights( - newPosition->castlingRights, (CASTLE_KINGSIDE_WHITE | CASTLE_QUEENSIDE_WHITE)); - if(leavingSquare == str2index("e1")) { - if(arrivingSquare == str2index("g1")) - movePiece(&(newPosition->board), generateMove(str2index("h1"), str2index("f1"))); - - if(arrivingSquare == str2index("c1")) - movePiece(&(newPosition->board), generateMove(str2index("a1"), str2index("d1"))); - } - } else if(leavingBB & position->board.blackKing) { - newPosition->castlingRights = removeCastlingRights( - newPosition->castlingRights, CASTLE_KINGSIDE_BLACK | CASTLE_QUEENSIDE_BLACK); - if(leavingSquare == str2index("e8")) { - if(arrivingSquare == str2index("g8")) - movePiece(&(newPosition->board), generateMove(str2index("h8"), str2index("f8"))); - - if(arrivingSquare == str2index("c8")) - movePiece(&(newPosition->board), generateMove(str2index("a8"), str2index("d8"))); - } - } -} - -void makeMove(Game* game, Move move) { - Position newPosition; - updatePosition(&newPosition, &(game->position), move); - memcpy(&(game->position), &newPosition, sizeof(Position)); - - game->moveListLen += 1; - - // ===== MOVE LIST ===== - game->moveList[game->moveListLen - 1] = move; - - // ===== POSITION HISTORY ===== - toFen(game->positionHistory[game->moveListLen], &game->position); -} - -void unmakeMove(Game* game) { - Position newPosition; - if(game->moveListLen >= 1) { - loadFen(&newPosition, game->positionHistory[game->moveListLen - 1]); - memcpy(&(game->position), &newPosition, sizeof(Position)); - - game->moveList[game->moveListLen - 1] = 0; - memset(game->positionHistory[game->moveListLen], 0, MAX_FEN_LEN * sizeof(char)); - - game->moveListLen -= 1; - } else { // return to initial game - loadFen(&newPosition, game->positionHistory[0]); - memcpy(&(game->position), &newPosition, sizeof(Position)); - - game->moveListLen = 0; - memset(game->moveList, 0, MAX_PLYS_PER_GAME * sizeof(int)); - memset(&game->positionHistory[1], 0, (MAX_PLYS_PER_GAME - 1) * MAX_FEN_LEN * sizeof(char)); - } -} - -// ======== MOVE GEN ========= - -Bitboard getMoves(Bitboard movingPiece, Position* position, char color) { - if((movingPiece & position->board.whitePawns) | (movingPiece & position->board.blackPawns)) - return pawnMoves(movingPiece, position, color); - if((movingPiece & position->board.whiteKnights) | (movingPiece & position->board.blackKnights)) - return knightMoves(movingPiece, &(position->board), color); - if((movingPiece & position->board.whiteBishops) | (movingPiece & position->board.blackBishops)) - return bishopMoves(movingPiece, &(position->board), color); - if((movingPiece & position->board.whiteRooks) | (movingPiece & position->board.blackRooks)) - return rookMoves(movingPiece, &(position->board), color); - if((movingPiece & position->board.whiteQueens) | (movingPiece & position->board.blackQueens)) - return queenMoves(movingPiece, &(position->board), color); - if((movingPiece & position->board.whiteKing) | (movingPiece & position->board.blackKing)) - return kingMoves(movingPiece, &(position->board), color); - - return 0; -} - -int pseudoLegalMoves(Move* moves, Position* position, char color) { - int leavingSquare, arrivingSquare, moveCount = 0; - Bitboard leavingBB = 1; - Bitboard attackers = getColoredPieces(&(position->board), color); - - for(leavingSquare = 0; leavingSquare < NUM_SQUARES; leavingSquare++) { - if(leavingBB & attackers) { - Bitboard targets = getMoves(leavingBB, position, color); - - for(arrivingSquare = 0; arrivingSquare < NUM_SQUARES; arrivingSquare++) { - if(isSet(targets, arrivingSquare)) { - moves[moveCount++] = generateMove(leavingSquare, arrivingSquare); - } - } - - if((leavingBB & position->board.whiteKing) | (leavingBB & position->board.blackKing)) { - if(canCastleKingside(position, color)) { - moves[moveCount++] = generateMove(leavingSquare, leavingSquare + 2); - } - if(canCastleQueenside(position, color)) { - moves[moveCount++] = generateMove(leavingSquare, leavingSquare - 2); - } - } - } - leavingBB <<= 1; - } - - return moveCount; -} - -Bitboard getAttacks(Bitboard movingPiece, Board* board, char color) { - if((movingPiece & board->whitePawns) | (movingPiece & board->blackPawns)) - return pawnAttacks(movingPiece, board, color); - if((movingPiece & board->whiteKnights) | (movingPiece & board->blackKnights)) - return knightAttacks(movingPiece); - if((movingPiece & board->whiteBishops) | (movingPiece & board->blackBishops)) - return bishopAttacks(movingPiece, board, color); - if((movingPiece & board->whiteRooks) | (movingPiece & board->blackRooks)) - return rookAttacks(movingPiece, board, color); - if((movingPiece & board->whiteQueens) | (movingPiece & board->blackQueens)) - return queenAttacks(movingPiece, board, color); - if((movingPiece & board->whiteKing) | (movingPiece & board->blackKing)) - return kingAttacks(movingPiece); - - return 0; -} - -int countAttacks(Bitboard target, Board* board, char color) { - int i, attackCount = 0; - - Bitboard attackers = getColoredPieces(board, color); - Bitboard position = 1; - - for(i = 0; i < NUM_SQUARES; i++) { - if(position & attackers) { - if(getAttacks(position, board, color) & target) { - attackCount += 1; - } - } - position = position << 1; - } - - return attackCount; -} - -BOOL isAttacked(Bitboard target, Board* board, char color) { - int i = 0; - - Bitboard attackers = getColoredPieces(board, color); - Bitboard position = 1; - - for(i = 0; i < NUM_SQUARES; i++) { - if(position & attackers) { - if(getAttacks(position, board, color) & target) { - return TRUE; - } - } - position = position << 1; - } - - return FALSE; -} - -BOOL isCheck(Board* board, char color) { - return isAttacked(getKing(board, color), board, opponent(color)); -} - -BOOL isLegalMove(Position* position, Move move) { - Position newPosition; - updatePosition(&newPosition, position, move); - if(isCheck(&(newPosition.board), position->toMove)) return FALSE; - return TRUE; -} - -int legalMoves(Move* legalMoves, Position* position, char color) { - int i, legalCount = 0; - - Move pseudoMoves[MAX_BRANCHING_FACTOR]; - int pseudoCount = pseudoLegalMoves(pseudoMoves, position, color); - - for(i = 0; i < pseudoCount; i++) { - if(isLegalMove(position, pseudoMoves[i])) { - legalMoves[legalCount++] = pseudoMoves[i]; - } - } - - return legalCount; -} - -int legalMovesCount(Position* position, char color) { - int i, legalCount = 0; - - Move pseudoMoves[MAX_BRANCHING_FACTOR]; - int pseudoCount = pseudoLegalMoves(pseudoMoves, position, color); - - for(i = 0; i < pseudoCount; i++) { - if(isLegalMove(position, pseudoMoves[i])) { - legalCount++; - } - } - - return legalCount; -} - -int staticOrderLegalMoves(Move* orderedLegalMoves, Position* position, char color) { - Move moves[MAX_BRANCHING_FACTOR]; - int legalCount = legalMoves(moves, position, color); - - Position newPosition; - Node nodes[legalCount], orderedNodes[legalCount]; - - int i; - for(i = 0; i < legalCount; i++) { - updatePosition(&newPosition, position, moves[i]); - nodes[i] = (Node){.move = moves[i], .score = staticEvaluation(&newPosition)}; - } - - sortNodes(orderedNodes, nodes, legalCount, color); - - for(i = 0; i < legalCount; i++) { - orderedLegalMoves[i] = orderedNodes[i].move; - } - - return legalCount; -} - -int legalCaptures(Move* legalCaptures, Position* position, char color) { - int i, captureCount = 0; - - Move moves[MAX_BRANCHING_FACTOR]; - int legalCount = legalMoves(moves, position, color); - - for(i = 0; i < legalCount; i++) { - int arrivingSquare = getTo(moves[i]); - if(index2bb(arrivingSquare) & getColoredPieces(&(position->board), opponent(color))) { - legalCaptures[captureCount++] = moves[i]; - } - } - - return captureCount; -} - -// ====== GAME CONTROL ======= - -BOOL isCheckmate(Position* position) { - if(isCheck(&(position->board), position->toMove) && - legalMovesCount(position, position->toMove) == 0) - return TRUE; - else - return FALSE; -} - -BOOL isStalemate(Position* position) { - if(!isCheck(&(position->board), position->toMove) && - legalMovesCount(position, position->toMove) == 0) - return TRUE; - else - return FALSE; -} - -BOOL hasInsufficientMaterial(Board* board) { - int pieceCount = countBits(getOccupiedSquares(board)); - - if(pieceCount <= 3) { - if(pieceCount == 2 || getKnights(board) != 0 || getBishops(board) != 0) return TRUE; - } - - return FALSE; -} - -BOOL isEndgame(Board* board) { - if(countBits(getOccupiedSquares(board)) <= ENDGAME_PIECE_COUNT) return TRUE; - return FALSE; -} - -BOOL isOver75MovesRule(Position* position) { - if(position->halfmoveClock >= 150) - return TRUE; - else - return FALSE; -} - -BOOL hasGameEnded(Position* position) { - if(isCheckmate(position) || isStalemate(position) || - hasInsufficientMaterial(&(position->board)) || isOver75MovesRule(position)) - return TRUE; - else - return FALSE; -} - -void printOutcome(Position* position) { - if(isCheckmate(position) && position->toMove == BLACK) printf("WHITE wins!\n"); - if(isCheckmate(position) && position->toMove == WHITE) printf("BLACK wins!\n"); - if(isStalemate(position)) printf("Draw by stalemate!\n"); - if(hasInsufficientMaterial(&(position->board))) printf("Draw by insufficient material!\n"); - if(isOver75MovesRule(position)) printf("Draw by 75 move rule!\n"); - fflush(stdout); -} - -// ========== EVAL =========== - -int winScore(char color) { - if(color == WHITE) return 10 * PIECE_VALUES[KING]; - if(color == BLACK) return -10 * PIECE_VALUES[KING]; - return 0; -} - -int materialSum(Board* board, char color) { - if(color == WHITE) { - return PIECE_VALUES[PAWN] * countBits(board->whitePawns) + - PIECE_VALUES[KNIGHT] * countBits(board->whiteKnights) + - PIECE_VALUES[BISHOP] * countBits(board->whiteBishops) + - PIECE_VALUES[ROOK] * countBits(board->whiteRooks) + - PIECE_VALUES[QUEEN] * countBits(board->whiteQueens); - } else { - return PIECE_VALUES[PAWN] * countBits(board->blackPawns) + - PIECE_VALUES[KNIGHT] * countBits(board->blackKnights) + - PIECE_VALUES[BISHOP] * countBits(board->blackBishops) + - PIECE_VALUES[ROOK] * countBits(board->blackRooks) + - PIECE_VALUES[QUEEN] * countBits(board->blackQueens); - } -} - -int materialBalance(Board* board) { - return materialSum(board, WHITE) - materialSum(board, BLACK); -} - -int positionalBonus(Board* board, char color) { - int bonus = 0; - Bitboard positionBB; - Bitboard coloredPieces = getColoredPieces(board, color); - - int i; - for(i = 0; i < NUM_SQUARES; i++) { - positionBB = index2bb(i); - - if(positionBB & coloredPieces) { - if((positionBB & board->whitePawns) | (positionBB & board->blackPawns)) { - if(color == WHITE) { - bonus += PAWN_BONUS[i]; - } else { - bonus += PAWN_BONUS[FLIP_VERTICAL[i]]; - } - - if(isDoubledPawn(positionBB, board, color)) { - bonus -= DOUBLED_PAWN_PENALTY / 2; - } - if(isPassedPawn(positionBB, board, color)) { - bonus += PASSED_PAWN_BONUS; - } - - if(isIsolatedPawn(positionBB, board, color)) { - bonus -= ISOLATED_PAWN_PENALTY; - } else if(isBackwardsPawn(positionBB, board, color)) { - bonus -= BACKWARDS_PAWN_PENALTY; - } - } else if((positionBB & board->whiteKnights) | (positionBB & board->blackKnights)) { - if(color == WHITE) { - bonus += KNIGHT_BONUS[i]; - } else { - bonus += KNIGHT_BONUS[FLIP_VERTICAL[i]]; - } - } else if((positionBB & board->whiteBishops) | (positionBB & board->blackBishops)) { - if(color == WHITE) { - bonus += BISHOP_BONUS[i]; - } else { - bonus += BISHOP_BONUS[FLIP_VERTICAL[i]]; - } - } else if((positionBB & board->whiteRooks) | (positionBB & board->blackRooks)) { - if(isOpenFile(positionBB, board)) { - bonus += ROOK_OPEN_FILE_BONUS; - } else if(isSemiOpenFile(positionBB, board)) { - bonus += ROOK_SEMI_OPEN_FILE_BONUS; - } - - if(color == WHITE) { - if(positionBB & RANK_7) { - bonus += ROOK_ON_SEVENTH_BONUS; - } - } else { - if(positionBB & RANK_2) { - bonus += ROOK_ON_SEVENTH_BONUS; - } - } - } else if((positionBB & board->whiteKing) | (positionBB & board->blackKing)) { - if(isEndgame(board)) { - if(color == WHITE) { - bonus += KING_ENDGAME_BONUS[i]; - } else { - bonus += KING_ENDGAME_BONUS[FLIP_VERTICAL[i]]; - } - } else { - if(color == WHITE) { - bonus += KING_BONUS[i]; - } else { - bonus += KING_BONUS[FLIP_VERTICAL[i]]; - } - } - } - } - } - - return bonus; -} - -int positionalBalance(Board* board) { - return positionalBonus(board, WHITE) - positionalBonus(board, BLACK); -} - -int endNodeEvaluation(Position* position) { - if(isCheckmate(position)) { - return winScore(opponent(position->toMove)); - } - if(isStalemate(position) || hasInsufficientMaterial(&(position->board)) || - isOver75MovesRule(position)) { - return 0; - } - return 0; -} - -int staticEvaluation(Position* position) { - if(hasGameEnded(position)) - return endNodeEvaluation(position); - else - return materialBalance(&(position->board)) + positionalBalance(&(position->board)); -} - -int getPieceValue(Bitboard position, Board* board) { - if((position & board->whitePawns) | (position & board->blackPawns)) return PIECE_VALUES[PAWN]; - if((position & board->whiteKnights) | (position & board->blackKnights)) - return PIECE_VALUES[KNIGHT]; - if((position & board->whiteBishops) | (position & board->blackBishops)) - return PIECE_VALUES[BISHOP]; - if((position & board->whiteRooks) | (position & board->blackRooks)) return PIECE_VALUES[ROOK]; - if((position & board->whiteQueens) | (position & board->blackQueens)) - return PIECE_VALUES[QUEEN]; - if((position & board->whiteKing) | (position & board->blackKing)) return PIECE_VALUES[KING]; - return 0; -} - -int getCaptureSequence(Move* captures, Position* position, int targetSquare) { - Move allCaptures[MAX_BRANCHING_FACTOR], targetCaptures[MAX_ATTACKING_PIECES]; - int captureCount = legalCaptures(allCaptures, position, position->toMove); - int i, j, targetCount = 0; - - for(i = 0; i < captureCount; i++) { - if(getTo(allCaptures[i]) == targetSquare) { - targetCaptures[targetCount++] = allCaptures[i]; - } - } - - Move captureBuffer[targetCount]; - - BOOL sorted; - for(i = 0; i < targetCount; i++) { - sorted = FALSE; - int pieceValue = getPieceValue(index2bb(getFrom(targetCaptures[i])), &(position->board)); - - for(j = 0; j < i; j++) { - int sortedPieceValue = - getPieceValue(index2bb(getFrom(captures[j])), &(position->board)); - - if(pieceValue < sortedPieceValue) { - sorted = TRUE; - memcpy(captureBuffer, &captures[j], (i - j) * sizeof(Move)); - memcpy(&captures[j + 1], captureBuffer, (i - j) * sizeof(Move)); - captures[j] = targetCaptures[i]; - break; - } - } - - if(sorted == FALSE) { - captures[i] = targetCaptures[i]; - } - } - - return targetCount; -} - -int staticExchangeEvaluation(Position* position, int targetSquare) { - Move captures[MAX_ATTACKING_PIECES]; - int attackCount = getCaptureSequence(captures, position, targetSquare); - int value = 0; - - if(attackCount > 0) { - Position newPosition; - updatePosition(&newPosition, position, captures[0]); - int pieceValue = getPieceValue(index2bb(targetSquare), &(position->board)); - value = pieceValue - staticExchangeEvaluation(&newPosition, targetSquare); - } - - return value > 0 ? value : 0; -} - -int quiescenceEvaluation(Position* position) { - int staticScore = staticEvaluation(position); - - if(hasGameEnded(position)) return staticScore; - - Move captures[MAX_BRANCHING_FACTOR]; - int captureCount = legalCaptures(captures, position, position->toMove); - - if(captureCount == 0) { - return staticScore; - } else { - Position newPosition; - int i, bestScore = staticScore; - - for(i = 0; i < captureCount; i++) { - if(staticExchangeEvaluation(position, getTo(captures[i])) <= 0) continue; - - updatePosition(&newPosition, position, captures[i]); - int score = quiescenceEvaluation(&newPosition); - - if((position->toMove == WHITE && score > bestScore) || - (position->toMove == BLACK && score < bestScore)) { - bestScore = score; - } - } - - return bestScore; - } -} - -// ========= SEARCH ========== - -Node staticSearch(Position* position) { - int bestScore = position->toMove == WHITE ? INT32_MIN : INT32_MAX; - Move bestMove = 0; - - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = legalMoves(moves, position, position->toMove); - - Position newPosition; - int i; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, moves[i]); - int score = staticEvaluation(&newPosition); - - if(score == winScore(position->toMove)) { - return (Node){.move = moves[i], .score = score}; - } - - if((position->toMove == WHITE && score > bestScore) || - (position->toMove == BLACK && score < bestScore)) { - bestScore = score; - bestMove = moves[i]; - } - } - - return (Node){.move = bestMove, .score = bestScore}; -} - -Node quiescenceSearch(Position* position) { - int bestScore = position->toMove == WHITE ? INT32_MIN : INT32_MAX; - Move bestMove = 0; - - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = legalMoves(moves, position, position->toMove); - - Position newPosition; - int i; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, moves[i]); - int score = quiescenceEvaluation(&newPosition); - - if(score == winScore(position->toMove)) { - return (Node){.move = moves[i], .score = score}; - } - - if((position->toMove == WHITE && score > bestScore) || - (position->toMove == BLACK && score < bestScore)) { - bestScore = score; - bestMove = moves[i]; - } - } - - return (Node){.move = bestMove, .score = bestScore}; -} - -Node alphaBeta(Position* position, char depth, int alpha, int beta) { - if(hasGameEnded(position)) return (Node){.score = endNodeEvaluation(position)}; - - if(depth == 1) return staticSearch(position); - - // Mate in 1 - Node staticNode = staticSearch(position); - if(staticNode.score == winScore(position->toMove)) return staticNode; - - Move bestMove = 0; - - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = staticOrderLegalMoves(moves, position, position->toMove); - - Position newPosition; - int i; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, moves[i]); - - int score = alphaBeta(&newPosition, depth - 1, alpha, beta).score; - - if(score == winScore(position->toMove)) { - return (Node){.move = moves[i], .score = score}; - } - - if(position->toMove == WHITE && score > alpha) { - alpha = score; - bestMove = moves[i]; - } else if(position->toMove == BLACK && score < beta) { - beta = score; - bestMove = moves[i]; - } - - if(alpha > beta) { - break; - } - } - - return (Node){.move = bestMove, .score = position->toMove == WHITE ? alpha : beta}; -} - -int alphaBetaNodes(Node* sortedNodes, Position* position, char depth) { - Node nodes[MAX_BRANCHING_FACTOR]; - Move moves[MAX_BRANCHING_FACTOR]; - int moveCount = legalMoves(moves, position, position->toMove); - - Position newPosition; - int i; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, moves[i]); - - nodes[i].move = moves[i]; - nodes[i].score = depth > 1 ? - alphaBeta(&newPosition, depth - 1, INT32_MIN, INT32_MAX).score : - staticEvaluation(&newPosition); - } - - sortNodes(sortedNodes, nodes, moveCount, position->toMove); - - return moveCount; -} - -Node iterativeDeepeningAlphaBeta(Position* position, char depth, int alpha, int beta, BOOL verbose) { - if(hasGameEnded(position)) return (Node){.score = endNodeEvaluation(position)}; - - if(depth == 1) return quiescenceSearch(position); - // return staticSearch(position); - - // Mate in 1 - Node staticNode = staticSearch(position); - if(staticNode.score == winScore(position->toMove)) return staticNode; - - Move bestMove = 0; - - if(verbose) { - printf("Ordering moves...\n"); - fflush(stdout); - } - - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - Position newPosition; - int i; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, nodes[i].move); - - if(verbose) { - printf("(Move %2d/%d) ", i + 1, moveCount); - printFullMove(nodes[i].move, &(position->board)); - printf(" = "); - fflush(stdout); - } - - int score = iterativeDeepeningAlphaBeta(&newPosition, depth - 1, alpha, beta, FALSE).score; - - if(verbose) { - printf("%.2f\n", (double)score / (double)100.00); - fflush(stdout); - } - - if(score == winScore(position->toMove)) { - return (Node){.move = nodes[i].move, .score = score}; - } - - if(position->toMove == WHITE && score > alpha) { - alpha = score; - bestMove = nodes[i].move; - } else if(position->toMove == BLACK && score < beta) { - beta = score; - bestMove = nodes[i].move; - } - - if(alpha > beta) { - break; - } - } - - return (Node){.move = bestMove, .score = position->toMove == WHITE ? alpha : beta}; -} - -Node pIDAB(Position* position, char depth, int* p_alpha, int* p_beta) { - if(hasGameEnded(position)) return (Node){.score = endNodeEvaluation(position)}; - - if(depth == 1) return quiescenceSearch(position); - - // Mate in 1 - Node staticNode = staticSearch(position); - if(staticNode.score == winScore(position->toMove)) return staticNode; - - Move bestMove = 0; - - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - Position newPosition; - int i; - int alpha = *p_alpha; - int beta = *p_beta; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, nodes[i].move); - - int score = iterativeDeepeningAlphaBeta(&newPosition, depth - 1, alpha, beta, FALSE).score; - - if(score == winScore(position->toMove)) { - return (Node){.move = nodes[i].move, .score = score}; - } - - if(position->toMove == WHITE && score > alpha) { - alpha = score; - bestMove = nodes[i].move; - } else if(position->toMove == BLACK && score < beta) { - beta = score; - bestMove = nodes[i].move; - } - - if(alpha > beta || alpha > *p_beta || *p_alpha > beta) { - break; - } - } - - return (Node){.move = bestMove, .score = position->toMove == WHITE ? alpha : beta}; -} - -Node pIDABhashed(Position* position, char depth, int* p_alpha, int* p_beta) { - if(hasGameEnded(position)) { - int score = endNodeEvaluation(position); - writeToHashFile(position, score, 0); - return (Node){.score = score}; - } - - if(depth <= 1) { - Node quie = quiescenceSearch(position); - writeToHashFile(position, quie.score, depth); - return quie; - } - - // Mate in 1 - Node staticNode = staticSearch(position); - if(staticNode.score == winScore(position->toMove)) { - writeToHashFile(position, staticNode.score, 1); - return staticNode; - } - - Move bestMove = 0; - - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - Position newPosition; - int i; - int alpha = *p_alpha; - int beta = *p_beta; - for(i = 0; i < moveCount; i++) { - updatePosition(&newPosition, position, nodes[i].move); - - int score = iterativeDeepeningAlphaBeta(&newPosition, depth - 1, alpha, beta, FALSE).score; - writeToHashFile(&newPosition, score, depth - 1); - - if(score == winScore(position->toMove)) { - return (Node){.move = nodes[i].move, .score = score}; - } - - if(position->toMove == WHITE && score > alpha) { - alpha = score; - bestMove = nodes[i].move; - } else if(position->toMove == BLACK && score < beta) { - beta = score; - bestMove = nodes[i].move; - } - - if(alpha > beta || alpha > *p_beta || *p_alpha > beta) { - break; - } - } - - writeToHashFile(position, position->toMove == WHITE ? alpha : beta, depth); - return (Node){.move = bestMove, .score = position->toMove == WHITE ? alpha : beta}; -} - -// Parallel processing currently only implemented for Windows -#ifdef _WIN32 - -DWORD WINAPI evaluatePositionThreadFunction(LPVOID lpParam) { - ThreadInfo* tInfo = (ThreadInfo*)lpParam; - Position* pos = &tInfo->pos; - - Node node = pIDAB(pos, tInfo->depth, tInfo->alpha, tInfo->beta); - - if(pos->toMove == BLACK && node.score > *tInfo->alpha) { - *tInfo->alpha = node.score; - } else if(pos->toMove == WHITE && node.score < *tInfo->beta) { - *tInfo->beta = node.score; - } - - if(tInfo->verbose) { - printf("-"); - fflush(stdout); - } - - return node.score; -} - -DWORD WINAPI evaluatePositionThreadFunctionHashed(LPVOID lpParam) { - ThreadInfo* tInfo = (ThreadInfo*)lpParam; - Position* pos = &tInfo->pos; - - Node node = pIDABhashed(pos, tInfo->depth, tInfo->alpha, tInfo->beta); - - if(pos->toMove == BLACK && node.score > *tInfo->alpha) { - *tInfo->alpha = node.score; - } else if(pos->toMove == WHITE && node.score < *tInfo->beta) { - *tInfo->beta = node.score; - } - - if(tInfo->verbose) { - printf("-"); - fflush(stdout); - } - - return node.score; -} - -Node idabThreaded(Position* position, int depth, BOOL verbose) { - if(hasGameEnded(position)) return (Node){.score = endNodeEvaluation(position)}; - - if(depth <= 1) return quiescenceSearch(position); - - int i; - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - if(moveCount == 1) { - return nodes[0]; - } - - if(verbose) { - printf("Analyzing %d possible moves with base depth %d:\n[", moveCount, depth); - for(i = 0; i < moveCount; i++) printf(" "); - printf("]\r["); - fflush(stdout); - } - - HANDLE threadHandles[MAX_BRANCHING_FACTOR]; - ThreadInfo threadInfo[MAX_BRANCHING_FACTOR]; - int alpha = INT32_MIN; - int beta = INT32_MAX; - - for(i = 0; i < moveCount; i++) { - threadInfo[i].depth = depth - 1; - updatePosition(&threadInfo[i].pos, position, nodes[i].move); - threadInfo[i].alpha = α - threadInfo[i].beta = β - threadInfo[i].verbose = verbose; - - threadHandles[i] = - CreateThread(NULL, 0, evaluatePositionThreadFunction, (LPVOID)&threadInfo[i], 0, NULL); - - if(threadHandles[i] == NULL) { - // printf("Error launching process on move #%d!\n", i); - printf("!"); - fflush(stdout); - } - } - - WaitForMultipleObjects((DWORD)moveCount, threadHandles, TRUE, INFINITE); - if(verbose) { - printf("]\n"); - fflush(stdout); - } - - Move bestMove = 0; - int bestMoveScore = position->toMove == WHITE ? INT32_MIN : INT32_MAX; - long unsigned int retVal; - int score; - for(i = 0; i < moveCount; i++) { - GetExitCodeThread(threadHandles[i], &retVal); - score = (int)retVal; - - if((position->toMove == WHITE && score > bestMoveScore) || - (position->toMove == BLACK && score < bestMoveScore)) { - bestMove = nodes[i].move; - bestMoveScore = score; - } - - if(CloseHandle(threadHandles[i]) == 0) { - // printf("Error on closing thread #%d!\n", i); - printf("x"); - fflush(stdout); - } - } - - return (Node){.move = bestMove, .score = bestMoveScore}; -} - -Node idabThreadedBestFirst(Position* position, int depth, BOOL verbose) { - if(hasGameEnded(position)) return (Node){.score = endNodeEvaluation(position)}; - - if(depth <= 1) return quiescenceSearch(position); - - int i; - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - if(moveCount == 1) { - return nodes[0]; - } - - Position firstPos; - updatePosition(&firstPos, position, nodes[0].move); - Node firstReply = idabThreaded(&firstPos, depth - 1, FALSE); - - if(firstReply.score == winScore(position->toMove)) { - if(verbose) { - printf("Playing checkmate move: "); - printFullMove(nodes[0].move, position->board); - printf(".\n"); - } - return (Node){.move = nodes[0].move, .score = firstReply.score}; - } - - if(verbose) { - printf("Move "); - printFullMove(nodes[0].move, position->board); - printf(" had score of %+.2f.\n", firstReply.score / 100.0); - printf( - "Analyzing other %d possible moves with minimum depth of %d plies:\n[", - moveCount - 1, - depth); - for(i = 0; i < moveCount - 1; i++) printf(" "); - printf("]\r["); - fflush(stdout); - } - - HANDLE threadHandles[MAX_BRANCHING_FACTOR]; - ThreadInfo threadInfo[MAX_BRANCHING_FACTOR]; - int alpha = INT32_MIN; - int beta = INT32_MAX; - - if(position->toMove == WHITE) { - alpha = firstReply.score; - } else { - beta = firstReply.score; - } - - for(i = 0; i < moveCount - 1; i++) { - threadInfo[i].depth = depth - 1; - updatePosition(&threadInfo[i].pos, position, nodes[i + 1].move); - threadInfo[i].alpha = α - threadInfo[i].beta = β - threadInfo[i].verbose = verbose; - - threadHandles[i] = - CreateThread(NULL, 0, evaluatePositionThreadFunction, (LPVOID)&threadInfo[i], 0, NULL); - - if(threadHandles[i] == NULL) { - // printf("Error launching process on move #%d!\n", i); - printf("!"); - fflush(stdout); - } - } - - WaitForMultipleObjects((DWORD)moveCount - 1, threadHandles, TRUE, INFINITE); - if(verbose) { - printf("] Done!\n"); - fflush(stdout); - } - - Move bestMove = nodes[0].move; - int bestMoveScore = firstReply.score; - long unsigned int retVal; - int score; - for(i = 0; i < moveCount - 1; i++) { - GetExitCodeThread(threadHandles[i], &retVal); - score = (int)retVal; - - if((position->toMove == WHITE && score > bestMoveScore) || - (position->toMove == BLACK && score < bestMoveScore)) { - bestMove = nodes[i + 1].move; - bestMoveScore = score; - } - - if(CloseHandle(threadHandles[i]) == 0) { - // printf("Error on closing thread #%d!\n", i); - printf("x"); - fflush(stdout); - } - } - - return (Node){.move = bestMove, .score = bestMoveScore}; -} - -Node idabThreadedBestFirstHashed(Position* position, int depth, BOOL verbose) { - if(hasGameEnded(position)) { - int score = endNodeEvaluation(position); - writeToHashFile(position, score, 0); - return (Node){.score = score}; - } - - if(depth <= 1) { - Node quie = quiescenceSearch(position); - writeToHashFile(position, quie.score, depth); - return quie; - } - - int i; - Node nodes[MAX_BRANCHING_FACTOR]; - int moveCount = alphaBetaNodes(nodes, position, depth - 1); - - if(moveCount == 1) { - return nodes[0]; - } - - Position firstPos; - updatePosition(&firstPos, position, nodes[0].move); - Node firstReply = idabThreaded(&firstPos, depth - 1, FALSE); - - if(firstReply.score == winScore(position->toMove)) { - if(verbose) { - printf("Playing checkmate move: "); - printFullMove(nodes[0].move, position->board); - printf(".\n"); - } - writeToHashFile(position, firstReply.score, depth); - return (Node){.move = nodes[0].move, .score = firstReply.score}; - } - - if(verbose) { - printf("Move "); - printFullMove(nodes[0].move, position->board); - printf(" had score of %+.2f.\n", firstReply.score / 100.0); - printf( - "Analyzing other %d possible moves with minimum depth of %d plies:\n[", - moveCount - 1, - depth); - for(i = 0; i < moveCount - 1; i++) printf(" "); - printf("]\r["); - fflush(stdout); - } - - HANDLE threadHandles[MAX_BRANCHING_FACTOR]; - ThreadInfo threadInfo[MAX_BRANCHING_FACTOR]; - int alpha = INT32_MIN; - int beta = INT32_MAX; - - if(position->toMove == WHITE) { - alpha = firstReply.score; - } else { - beta = firstReply.score; - } - - for(i = 0; i < moveCount - 1; i++) { - threadInfo[i].depth = depth - 1; - updatePosition(&threadInfo[i].pos, position, nodes[i + 1].move); - threadInfo[i].alpha = α - threadInfo[i].beta = β - threadInfo[i].verbose = verbose; - - threadHandles[i] = CreateThread( - NULL, 0, evaluatePositionThreadFunctionHashed, (LPVOID)&threadInfo[i], 0, NULL); - - if(threadHandles[i] == NULL) { - // printf("Error launching process on move #%d!\n", i); - printf("!"); - fflush(stdout); - } - } - - WaitForMultipleObjects((DWORD)moveCount - 1, threadHandles, TRUE, INFINITE); - if(verbose) { - printf("] Done!\n"); - fflush(stdout); - } - - Move bestMove = nodes[0].move; - int bestMoveScore = firstReply.score; - long unsigned int retVal; - int score; - for(i = 0; i < moveCount - 1; i++) { - GetExitCodeThread(threadHandles[i], &retVal); - score = (int)retVal; - - writeToHashFile(&threadInfo[i].pos, score, depth - 1); - - if((position->toMove == WHITE && score > bestMoveScore) || - (position->toMove == BLACK && score < bestMoveScore)) { - bestMove = nodes[i + 1].move; - bestMoveScore = score; - } - - if(CloseHandle(threadHandles[i]) == 0) { - // printf("Error on closing thread #%d!\n", i); - printf("x"); - fflush(stdout); - } - } - - writeToHashFile(position, bestMoveScore, depth); - return (Node){.move = bestMove, .score = bestMoveScore}; -} - -#endif /* _WIN32 */ - -Move getRandomMove(Position* position) { - Move moves[MAX_BRANCHING_FACTOR]; - int totalMoves = legalMoves(moves, position, position->toMove); - int chosenMove = rand() % totalMoves; - return moves[chosenMove]; -} - -Move getAIMove(Game* game, int depth) { - printf("--- AI ---\n"); - fflush(stdout); - - if(fromInitial(game) && countBookOccurrences(game) > 0) { - printf("There are %d available book continuations.\n", countBookOccurrences(game)); - fflush(stdout); - Move bookMove = getBookMove(game); - printf("CHOSEN book move: "); - printFullMove(bookMove, &(game->position.board)); - printf(".\n"); - fflush(stdout); - return bookMove; - } - - time_t startTime, endTime; - startTime = time(NULL); - - // Move move = getRandomMove(&game->position); - // Move move = simpleEvaluation(&game->position).move; - // Move move = minimax(&game->position, AI_DEPTH).move; - // Node node = alphaBeta(&game->position, depth, INT32_MIN, INT32_MAX, TRUE); - // Node node = iterativeDeepeningAlphaBeta(&game->position, depth, INT32_MIN, INT32_MAX, TRUE); - // Node node = idabThreaded(&game->position, depth, TRUE); - // Node node = idabThreadedBestFirst(&game->position, depth, TRUE); - // Node node = idabThreadedBestFirstHashed(&game->position, depth, TRUE); - -#ifdef _WIN32 - Node node = idabThreadedBestFirst(&game->position, depth, TRUE); -#else - Node node = iterativeDeepeningAlphaBeta(&game->position, depth, INT32_MIN, INT32_MAX, TRUE); -#endif - - endTime = time(NULL); - - printf("CHOSEN move: "); - printFullMove(node.move, &(game->position.board)); - printf( - " in %d seconds [%+.2f, %+.2f]\n", - (int)(endTime - startTime), - (double)staticEvaluation(&game->position) / (double)100.0, - (double)node.score / (double)100.0); - fflush(stdout); - - return node.move; -} - -Move parseMove(char* move) { - int pos1 = str2index(&move[0]); - int pos2 = str2index(&move[2]); - return generateMove(pos1, pos2); -} - -Move getPlayerMove() { - char input[100]; - fgets(input, 100, stdin); - return parseMove(input); -} - -Move suggestMove(char fen[], int depth) { - Game game; - getFenGame(&game, fen); - return getAIMove(&game, depth); -} - -// ===== PLAY LOOP (TEXT) ==== - -void playTextWhite(int depth) { - printf("Playing as WHITE!\n"); - fflush(stdout); - - Game game; - getInitialGame(&game); - - while(TRUE) { - printBoard(&(game.position.board)); - if(hasGameEnded(&game.position)) break; - - makeMove(&game, getPlayerMove()); - - printBoard(&(game.position.board)); - if(hasGameEnded(&game.position)) break; - - makeMove(&game, getAIMove(&game, depth)); - } - printOutcome(&game.position); -} - -void playTextBlack(int depth) { - printf("Playing as BLACK!\n"); - fflush(stdout); - - Game game; - getInitialGame(&game); - - while(TRUE) { - printBoard(&(game.position.board)); - if(hasGameEnded(&game.position)) break; - - makeMove(&game, getAIMove(&game, depth)); - - printBoard(&(game.position.board)); - if(hasGameEnded(&game.position)) break; - - makeMove(&game, getPlayerMove()); - } - printOutcome(&game.position); -} - -void playTextAs(char color, int depth) { - if(color == WHITE) playTextWhite(depth); - if(color == BLACK) playTextBlack(depth); -} - -void playTextRandomColor(int depth) { - char colors[] = {WHITE, BLACK}; - char color = colors[rand() % 2]; - playTextAs(color, depth); -} - -// =========================== - -/* -int main(int argc, char *argv[]) { - srand(time(NULL)); - - int opt; - int FEN_MODE = 0, MOVES_MODE = 1, mode = FEN_MODE; - int depth = DEFAULT_AI_DEPTH; - - while ((opt = getopt(argc, argv, "fmd:v")) != -1) { - switch (opt) { - case 'f': mode = FEN_MODE; break; - case 'm': mode = MOVES_MODE; break; - case 'd': depth = atoi(optarg); break; - case 'v': printf(ENGINE_VERSION); exit(0); - default: - fprintf(stderr, "Usage: %s [-d depth] [-f fen] [-m move_list]\n", argv[0]); - exit(EXIT_FAILURE); - } - } - - Game game; - if (argc > optind) { - if (mode == FEN_MODE) { - getFenGame(&game, argv[optind]); - } else if (mode == MOVES_MODE) { - getMovelistGame(&game, argv[optind]); - } - } else { - getInitialGame(&game); - } - - Move move; - if ( mode == MOVES_MODE && countBookOccurrences(&game) > 0 ) { - move = getBookMove(&game); - } else { - Node node = iterativeDeepeningAlphaBeta(&(game.position), (char) depth, INT32_MIN, INT32_MAX, FALSE); - move = node.move; - } - - printf("%c%c%c%c", getFile(getFrom(move)), getRank(getFrom(move)), getFile(getTo(move)), getRank(getTo(move))); - - return EXIT_SUCCESS; -} -// */ diff --git a/applications/plugins/chess/fast_chess.h b/applications/plugins/chess/fast_chess.h deleted file mode 100644 index b56a32cb2..000000000 --- a/applications/plugins/chess/fast_chess.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * fast-chess.h - * - * Created on: 20 de set de 2016 - * Author: fvj - */ - -#ifndef FAST_CHESS_H_ -#define FAST_CHESS_H_ - -#ifdef _WIN32 -#include -#endif - -#include - -#define ENGINE_VERSION "v1.8.1" - -#define ENGINE_NAME "github.com/fredericojordan/fast-chess " ENGINE_VERSION -#define HUMAN_NAME "Unknown Human Player" - -#define NUM_SQUARES (64) -#define ENDGAME_PIECE_COUNT (7) - -#define COLOR_MASK (1 << 3) -#define WHITE (0) -#define BLACK (1 << 3) - -#define PIECE_MASK (0x7) -#define EMPTY (0) -#define PAWN (1) -#define KNIGHT (2) -#define BISHOP (3) -#define ROOK (4) -#define QUEEN (5) -#define KING (6) - -#define ALL_SQUARES (0xFFFFFFFFFFFFFFFF) -#define FILE_A (0x0101010101010101) -#define FILE_B (0x0202020202020202) -#define FILE_C (0x0404040404040404) -#define FILE_D (0x0808080808080808) -#define FILE_E (0x1010101010101010) -#define FILE_F (0x2020202020202020) -#define FILE_G (0x4040404040404040) -#define FILE_H (0x8080808080808080) -#define RANK_1 (0x00000000000000FF) -#define RANK_2 (0x000000000000FF00) -#define RANK_3 (0x0000000000FF0000) -#define RANK_4 (0x00000000FF000000) -#define RANK_5 (0x000000FF00000000) -#define RANK_6 (0x0000FF0000000000) -#define RANK_7 (0x00FF000000000000) -#define RANK_8 (0xFF00000000000000) -#define DIAG_A1H8 (0x8040201008040201) -#define ANTI_DIAG_H1A8 (0x0102040810204080) -#define LIGHT_SQUARES (0x55AA55AA55AA55AA) -#define DARK_SQUARES (0xAA55AA55AA55AA55) - -#define CASTLE_KINGSIDE_WHITE (1 << 0) -#define CASTLE_QUEENSIDE_WHITE (1 << 1) -#define CASTLE_KINGSIDE_BLACK (1 << 2) -#define CASTLE_QUEENSIDE_BLACK (1 << 3) - -#define BOOL char - -#ifndef FALSE -#define TRUE (1) -#define FALSE (0) -#endif - -typedef uint_fast64_t Bitboard; -typedef int Move; - -#define MAX_BOOK_ENTRY_LEN (300) -#define MAX_PLYS_PER_GAME (1024) -#define MAX_FEN_LEN (100) -// #define MAX_BRANCHING_FACTOR (218) /* R6R/3Q4/1Q4Q1/4Q3/2Q4Q/Q4Q2/pp1Q4/kBNN1KB1 w - - 0 1 3Q4/1Q4Q1/4Q3/2Q4R/Q4Q2/3Q4/1Q4Rp/1K1BBNNk w - - 0 1 */ -#define MAX_BRANCHING_FACTOR (100) // okalachev -#define MAX_ATTACKING_PIECES (12) - -#define DEFAULT_AI_DEPTH (3) - -typedef struct { - Bitboard whiteKing; - Bitboard whiteQueens; - Bitboard whiteRooks; - Bitboard whiteKnights; - Bitboard whiteBishops; - Bitboard whitePawns; - - Bitboard blackKing; - Bitboard blackQueens; - Bitboard blackRooks; - Bitboard blackKnights; - Bitboard blackBishops; - Bitboard blackPawns; -} Board; - -typedef struct { - Board board; - char toMove; - char epSquare; - char castlingRights; - unsigned int halfmoveClock; - unsigned int fullmoveNumber; -} Position; - -typedef struct { - Position position; - - unsigned int moveListLen; - Move moveList[MAX_PLYS_PER_GAME]; - char positionHistory[MAX_PLYS_PER_GAME][MAX_FEN_LEN]; -} Game; - -typedef struct { - Move move; - int score; -} Node; - -typedef struct { - int depth; - Position pos; - int* alpha; - int* beta; - BOOL verbose; -} ThreadInfo; - -extern char FILES[8]; -extern char RANKS[8]; - -extern Bitboard FILES_BB[8]; -extern Bitboard RANKS_BB[8]; - -extern char INITIAL_FEN[]; -extern Board INITIAL_BOARD; -extern int PIECE_VALUES[]; - -#define DOUBLED_PAWN_PENALTY (10) -#define ISOLATED_PAWN_PENALTY (20) -#define BACKWARDS_PAWN_PENALTY (8) -#define PASSED_PAWN_BONUS (20) -#define ROOK_SEMI_OPEN_FILE_BONUS (10) -#define ROOK_OPEN_FILE_BONUS (15) -#define ROOK_ON_SEVENTH_BONUS (20) - -extern int PAWN_BONUS[]; -extern int KNIGHT_BONUS[]; -extern int BISHOP_BONUS[]; -extern int KING_BONUS[]; -extern int KING_ENDGAME_BONUS[]; -extern int FLIP_VERTICAL[]; - -void getInitialGame(Game* game); -void getFenGame(Game* game, char fen[]); -void insertPiece(Board* board, Bitboard position, char pieceCode); -int loadFen(Position* position, char fen[]); -int toFen(char* fen, Position* position); -int toMinFen(char* fen, Position* position); -void getMovelistGame(Game* game, char moves[]); - -// ========= UTILITY ========= - -BOOL fromInitial(Game* game); -Bitboard index2bb(int index); -int str2index(char* str); -Bitboard str2bb(char* str); -BOOL isSet(Bitboard bb, int index); -Bitboard lsb(Bitboard bb); -Bitboard msb(Bitboard bb); -int bb2index(Bitboard bb); -char* movelist2str(Game* game); -Move getLastMove(Game* game); -BOOL startsWith(const char* str, const char* pre); -int countBookOccurrences(Game* game); -Move getBookMove(Game* game); -char getFile(int position); -char getRank(int position); -Move generateMove(int leavingSquare, int arrivingSquare); -int getFrom(Move move); -int getTo(Move move); -int char2piece(char pieceCode); -int bb2piece(Bitboard position, Board* board); -char bb2char(Bitboard position, Board* board); -char* bb2str(Bitboard position, Board* board); -void printBitboard(Bitboard bitboard); -char getPieceChar(Bitboard position, Board* board); -void printBoard(Board* board); -void printGame(Game* game); -Bitboard not(Bitboard bb); -char opponent(char color); -int countBits(Bitboard bb); -void sortNodes(Node* sortedNodes, Node* nodes, int len, char color); -void printMove(Move move); -void printFullMove(Move move, Board* board); -void printLegalMoves(Position* position); -void printNode(Node node); -void getTimestamp(char* timestamp); -void dumpContent(Game* game); -void dumpPGN(Game* game, char color, BOOL hasAI); -void move2str(char* str, Game* game, int moveNumber); -BOOL isAmbiguous(Position* posBefore, Move move); -unsigned long hashPosition(Position* position); -void writeToHashFile(Position* position, int evaluation, int depth); - -// ====== BOARD FILTERS ====== - -Bitboard getColoredPieces(Board* board, char color); -Bitboard getEmptySquares(Board* board); -Bitboard getOccupiedSquares(Board* board); -Bitboard getTwinPieces(Bitboard position, Board* board); -Bitboard fileFilter(Bitboard positions); -Bitboard rankFilter(Bitboard positions); - -// ======= DIRECTIONS ======== - -Bitboard east(Bitboard bb); -Bitboard west(Bitboard bb); -Bitboard north(Bitboard bb); -Bitboard south(Bitboard bb); -Bitboard NE(Bitboard bb); -Bitboard NW(Bitboard bb); -Bitboard SE(Bitboard bb); -Bitboard SW(Bitboard bb); -Bitboard WNW(Bitboard moving_piece); -Bitboard ENE(Bitboard moving_piece); -Bitboard NNW(Bitboard moving_piece); -Bitboard NNE(Bitboard moving_piece); -Bitboard ESE(Bitboard moving_piece); -Bitboard WSW(Bitboard moving_piece); -Bitboard SSE(Bitboard moving_piece); -Bitboard SSW(Bitboard moving_piece); - -// ========== PAWN =========== - -Bitboard getPawns(Board* board); -Bitboard pawnSimplePushes(Bitboard moving_piece, Board* board, char color); -Bitboard pawnDoublePushes(Bitboard moving_piece, Board* board, char color); -Bitboard pawnPushes(Bitboard moving_piece, Board* board, char color); -Bitboard pawnEastAttacks(Bitboard moving_piece, Board* board, char color); -Bitboard pawnWestAttacks(Bitboard moving_piece, Board* board, char color); -Bitboard pawnAttacks(Bitboard moving_piece, Board* board, char color); -Bitboard pawnSimpleCaptures(Bitboard moving_piece, Board* board, char color); -Bitboard pawnEpCaptures(Bitboard moving_piece, Position* position, char color); -Bitboard pawnCaptures(Bitboard moving_piece, Position* position, char color); -Bitboard pawnMoves(Bitboard moving_piece, Position* position, char color); -BOOL isDoublePush(int leaving, int arriving); -char getEpSquare(int leaving); -BOOL isDoubledPawn(Bitboard position, Board* board, char color); -BOOL isIsolatedPawn(Bitboard position, Board* board, char color); -BOOL isBackwardsPawn(Bitboard position, Board* board, char color); -BOOL isPassedPawn(Bitboard position, Board* board, char color); -BOOL isOpenFile(Bitboard position, Board* board); -BOOL isSemiOpenFile(Bitboard position, Board* board); - -// ========== KNIGHT ========= - -Bitboard getKnights(Board* board); -Bitboard knightAttacks(Bitboard moving_piece); -Bitboard knightMoves(Bitboard moving_piece, Board* board, char color); - -// ========== KING =========== - -Bitboard getKing(Board* board, char color); -Bitboard kingAttacks(Bitboard moving_piece); -Bitboard kingMoves(Bitboard moving_piece, Board* board, char color); -BOOL canCastleKingside(Position* position, char color); -BOOL canCastleQueenside(Position* position, char color); -char removeCastlingRights(char original_rights, char removed_rights); - -// ========== BISHOP ========= - -Bitboard getBishops(Board* board); -Bitboard NE_ray(Bitboard bb); -Bitboard SE_ray(Bitboard bb); -Bitboard NW_ray(Bitboard bb); -Bitboard SW_ray(Bitboard bb); -Bitboard NE_attack(Bitboard single_piece, Board* board, char color); -Bitboard NW_attack(Bitboard single_piece, Board* board, char color); -Bitboard SE_attack(Bitboard single_piece, Board* board, char color); -Bitboard SW_attack(Bitboard single_piece, Board* board, char color); -Bitboard diagonalAttacks(Bitboard single_piece, Board* board, char color); -Bitboard antiDiagonalAttacks(Bitboard single_piece, Board* board, char color); -Bitboard bishopAttacks(Bitboard moving_pieces, Board* board, char color); -Bitboard bishopMoves(Bitboard moving_piece, Board* board, char color); - -// ========== ROOK =========== - -Bitboard getRooks(Board* board); -Bitboard northRay(Bitboard moving_pieces); -Bitboard southRay(Bitboard moving_pieces); -Bitboard eastRay(Bitboard moving_pieces); -Bitboard westRay(Bitboard moving_pieces); -Bitboard northAttack(Bitboard single_piece, Board* board, char color); -Bitboard southAttack(Bitboard single_piece, Board* board, char color); -Bitboard fileAttacks(Bitboard single_piece, Board* board, char color); -Bitboard eastAttack(Bitboard single_piece, Board* board, char color); -Bitboard westAttack(Bitboard single_piece, Board* board, char color); -Bitboard rankAttacks(Bitboard single_piece, Board* board, char color); -Bitboard rookAttacks(Bitboard moving_piece, Board* board, char color); -Bitboard rookMoves(Bitboard moving_piece, Board* board, char color); - -// ========== QUEEN ========== - -Bitboard getQueens(Board* board); -Bitboard queenAttacks(Bitboard moving_piece, Board* board, char color); -Bitboard queenMoves(Bitboard moving_piece, Board* board, char color); - -// ======== MAKE MOVE ======== - -void clearPositions(Board* board, Bitboard positions); -void movePiece(Board* board, Move move); -void updatePosition(Position* newPosition, Position* position, Move move); -void makeMove(Game* game, Move move); -void unmakeMove(Game* game); - -// ======== MOVE GEN ========= - -Bitboard getMoves(Bitboard movingPiece, Position* position, char color); -int pseudoLegalMoves(Move* moves, Position* position, char color); -Bitboard getAttacks(Bitboard movingPiece, Board* board, char color); -int countAttacks(Bitboard target, Board* board, char color); -BOOL isAttacked(Bitboard target, Board* board, char color); -BOOL isCheck(Board* board, char color); -BOOL isLegalMove(Position* position, Move move); -int legalMoves(Move* legalMoves, Position* position, char color); -int legalMovesCount(Position* position, char color); -int staticOrderLegalMoves(Move* orderedLegalMoves, Position* position, char color); -int legalCaptures(Move* legalCaptures, Position* position, char color); - -// ====== GAME CONTROL ======= - -BOOL isCheckmate(Position* position); -BOOL isStalemate(Position* position); -BOOL hasInsufficientMaterial(Board* board); -BOOL isEndgame(Board* board); -BOOL isOver75MovesRule(Position* position); -BOOL hasGameEnded(Position* position); -void printOutcome(Position* position); - -// ========== EVAL =========== - -int winScore(char color); -int materialSum(Board* board, char color); -int materialBalance(Board* board); -int positionalBonus(Board* board, char color); -int positionalBalance(Board* board); -int endNodeEvaluation(Position* position); -int staticEvaluation(Position* position); -int getCaptureSequence(Move* captures, Position* position, int targetSquare); -int staticExchangeEvaluation(Position* position, int targetSquare); -int quiescenceEvaluation(Position* position); - -// ========= SEARCH ========== - -Node staticSearch(Position* position); -Node quiescenceSearch(Position* position); -Node alphaBeta(Position* position, char depth, int alpha, int beta); -int alphaBetaNodes(Node* nodes, Position* position, char depth); -Node iterativeDeepeningAlphaBeta(Position* position, char depth, int alpha, int beta, BOOL verbose); -Node pIDAB(Position* position, char depth, int* p_alpha, int* p_beta); -Node pIDABhashed(Position* position, char depth, int* p_alpha, int* p_beta); -Move getRandomMove(Position* position); -Move getAIMove(Game* game, int depth); -Move parseMove(char* move); -Move getPlayerMove(); -Move suggestMove(char fen[], int depth); - -// Parallel processing currently only implemented for Windows -#ifdef _WIN32 -DWORD WINAPI evaluatePositionThreadFunction(LPVOID lpParam); -DWORD WINAPI evaluatePositionThreadFunctionHashed(LPVOID lpParam); -Node idabThreaded(Position* position, int depth, BOOL verbose); -Node idabThreadedBestFirst(Position* position, int depth, BOOL verbose); -Node idabThreadedBestFirstHashed(Position* position, int depth, BOOL verbose); -#endif - -// ===== PLAY LOOP (TEXT) ==== - -void playTextWhite(int depth); -void playTextBlack(int depth); -void playTextAs(char color, int depth); -void playTextRandomColor(int depth); - -// =========================== - -#endif /* FAST_CHESS_H_ */ \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/DHT.c b/applications/plugins/dht_temp_sensor/DHT.c deleted file mode 100644 index 63a189ce1..000000000 --- a/applications/plugins/dht_temp_sensor/DHT.c +++ /dev/null @@ -1,169 +0,0 @@ -#include "DHT.h" - -#define lineDown() furi_hal_gpio_write(sensor->GPIO, false) -#define lineUp() furi_hal_gpio_write(sensor->GPIO, true) -#define getLine() furi_hal_gpio_read(sensor->GPIO) -#define Delay(d) furi_delay_ms(d) - -DHT_data DHT_getData(DHT_sensor* sensor) { - DHT_data data = {-128.0f, -128.0f}; - -#if DHT_POLLING_CONTROL == 1 - /* Ограничение по частоте опроса датчика */ - //Определение интервала опроса в зависимости от датчика - uint16_t pollingInterval; - if(sensor->type == DHT11) { - pollingInterval = DHT_POLLING_INTERVAL_DHT11; - } else { - pollingInterval = DHT_POLLING_INTERVAL_DHT22; - } - - //Если интервал маленький, то возврат последнего удачного значения - if((furi_get_tick() - sensor->lastPollingTime < pollingInterval) && - sensor->lastPollingTime != 0) { - data.hum = sensor->lastHum; - data.temp = sensor->lastTemp; - return data; - } - sensor->lastPollingTime = furi_get_tick() + 1; -#endif - - //Опускание линии данных на 18 мс - lineDown(); -#ifdef DHT_IRQ_CONTROL - //Выключение прерываний, чтобы ничто не мешало обработке данных - __disable_irq(); -#endif - Delay(18); - - //Подъём линии - lineUp(); - - /* Ожидание ответа от датчика */ - uint16_t timeout = 0; - while(!getLine()) { - timeout++; - if(timeout > DHT_TIMEOUT) { -#ifdef DHT_IRQ_CONTROL - __enable_irq(); -#endif - //Если датчик не отозвался, значит его точно нет - //Обнуление последнего удачного значения, чтобы - //не получать фантомные значения - sensor->lastHum = -128.0f; - sensor->lastTemp = -128.0f; - - return data; - } - } - //Ожидание спада - while(getLine()) { - timeout++; - if(timeout > DHT_TIMEOUT) { -#ifdef DHT_IRQ_CONTROL - __enable_irq(); -#endif - //Если датчик не отозвался, значит его точно нет - //Обнуление последнего удачного значения, чтобы - //не получать фантомные значения - sensor->lastHum = -128.0f; - sensor->lastTemp = -128.0f; - - return data; - } - } - timeout = 0; - //Ожидание подъёма - while(!getLine()) { - timeout++; - if(timeout > DHT_TIMEOUT) { - if(timeout > DHT_TIMEOUT) { -#ifdef DHT_IRQ_CONTROL - __enable_irq(); -#endif - //Если датчик не отозвался, значит его точно нет - //Обнуление последнего удачного значения, чтобы - //не получать фантомные значения - sensor->lastHum = -128.0f; - sensor->lastTemp = -128.0f; - - return data; - } - } - } - timeout = 0; - //Ожидание спада - while(getLine()) { - timeout++; - if(timeout > DHT_TIMEOUT) { -#ifdef DHT_IRQ_CONTROL - __enable_irq(); -#endif - //Если датчик не отозвался, значит его точно нет - //Обнуление последнего удачного значения, чтобы - //не получать фантомные значения - sensor->lastHum = -128.0f; - sensor->lastTemp = -128.0f; - return data; - } - } - - /* Чтение ответа от датчика */ - uint8_t rawData[5] = {0, 0, 0, 0, 0}; - for(uint8_t a = 0; a < 5; a++) { - for(uint8_t b = 7; b != 255; b--) { - uint16_t hT = 0, lT = 0; - //Пока линия в низком уровне, инкремент переменной lT - while(!getLine() && lT != 65535) lT++; - //Пока линия в высоком уровне, инкремент переменной hT - timeout = 0; - while(getLine() && hT != 65535) hT++; - //Если hT больше lT, то пришла единица - if(hT > lT) rawData[a] |= (1 << b); - } - } -#ifdef DHT_IRQ_CONTROL - //Включение прерываний после приёма данных - __enable_irq(); -#endif - /* Проверка целостности данных */ - if((uint8_t)(rawData[0] + rawData[1] + rawData[2] + rawData[3]) == rawData[4]) { - //Если контрольная сумма совпадает, то конвертация и возврат полученных значений - if(sensor->type == DHT22) { - data.hum = (float)(((uint16_t)rawData[0] << 8) | rawData[1]) * 0.1f; - //Проверка на отрицательность температуры - if(!(rawData[2] & (1 << 7))) { - data.temp = (float)(((uint16_t)rawData[2] << 8) | rawData[3]) * 0.1f; - } else { - rawData[2] &= ~(1 << 7); - data.temp = (float)(((uint16_t)rawData[2] << 8) | rawData[3]) * -0.1f; - } - } - if(sensor->type == DHT11) { - data.hum = (float)rawData[0]; - data.temp = (float)rawData[2]; - //DHT11 производства ASAIR имеют дробную часть в температуре - //А ещё температуру измеряет от -20 до +60 *С - //Вот прикол, да? - if(rawData[3] != 0) { - //Проверка знака - if(!(rawData[3] & (1 << 7))) { - //Добавление положительной дробной части - data.temp += rawData[3] * 0.1f; - } else { - //А тут делаем отрицательное значение - rawData[3] &= ~(1 << 7); - data.temp += rawData[3] * 0.1f; - data.temp *= -1; - } - } - } - } - -#if DHT_POLLING_CONTROL == 1 - sensor->lastHum = data.hum; - sensor->lastTemp = data.temp; -#endif - - return data; -} \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/DHT.h b/applications/plugins/dht_temp_sensor/DHT.h deleted file mode 100644 index 409847d8b..000000000 --- a/applications/plugins/dht_temp_sensor/DHT.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef DHT_H_ -#define DHT_H_ - -#include - -/* Настройки */ -#define DHT_TIMEOUT 65534 //Количество итераций, после которых функция вернёт пустые значения -#define DHT_POLLING_CONTROL 1 //Включение проверки частоты опроса датчика -#define DHT_POLLING_INTERVAL_DHT11 \ - 2000 //Интервал опроса DHT11 (0.5 Гц по даташиту). Можно поставить 1500, будет работать -//Костыль, временно 2 секунды для датчика AM2302 -#define DHT_POLLING_INTERVAL_DHT22 2000 //Интервал опроса DHT22 (1 Гц по даташиту) -#define DHT_IRQ_CONTROL //Выключать прерывания во время обмена данных с датчиком -/* Структура возвращаемых датчиком данных */ -typedef struct { - float hum; - float temp; -} DHT_data; - -/* Тип используемого датчика */ -typedef enum { DHT11, DHT22 } DHT_type; - -/* Структура объекта датчика */ -typedef struct { - char name[11]; - const GpioPin* GPIO; //Пин датчика - DHT_type type; //Тип датчика (DHT11 или DHT22) - -//Контроль частоты опроса датчика. Значения не заполнять! -#if DHT_POLLING_CONTROL == 1 - uint32_t lastPollingTime; //Время последнего опроса датчика - float lastTemp; //Последнее значение температуры - float lastHum; //Последнее значение влажности -#endif -} DHT_sensor; - -/* Прототипы функций */ -DHT_data DHT_getData(DHT_sensor* sensor); //Получить данные с датчика - -#endif diff --git a/applications/plugins/dht_temp_sensor/application.fam b/applications/plugins/dht_temp_sensor/application.fam deleted file mode 100644 index fe91415b3..000000000 --- a/applications/plugins/dht_temp_sensor/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="DHT_Monitor", - name="[DHT] Temp. Monitor", - apptype=FlipperAppType.EXTERNAL, - entry_point="quenon_dht_mon_app", - cdefines=["QUENON_DHT_MON"], - requires=[ - "gui", - ], - fap_category="GPIO", - fap_icon="icon.png", - stack_size=2 * 1024, -) \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/icon.png b/applications/plugins/dht_temp_sensor/icon.png deleted file mode 100644 index 0e87c26c2..000000000 Binary files a/applications/plugins/dht_temp_sensor/icon.png and /dev/null differ diff --git a/applications/plugins/dht_temp_sensor/quenon_dht_mon.c b/applications/plugins/dht_temp_sensor/quenon_dht_mon.c deleted file mode 100644 index e2a1aba8b..000000000 --- a/applications/plugins/dht_temp_sensor/quenon_dht_mon.c +++ /dev/null @@ -1,469 +0,0 @@ -#include "quenon_dht_mon.h" -#include - -//Порты ввода/вывода, которые не были обозначены в общем списке -const GpioPin SWC_10 = {.pin = LL_GPIO_PIN_14, .port = GPIOA}; -const GpioPin SIO_12 = {.pin = LL_GPIO_PIN_13, .port = GPIOA}; -const GpioPin TX_13 = {.pin = LL_GPIO_PIN_6, .port = GPIOB}; -const GpioPin RX_14 = {.pin = LL_GPIO_PIN_7, .port = GPIOB}; - -//Количество доступных портов ввода/вывода -#define GPIO_ITEMS (sizeof(gpio_item) / sizeof(GpioItem)) - -//Перечень достуных портов ввода/вывода -static const GpioItem gpio_item[] = { - {2, "2 (A7)", &gpio_ext_pa7}, - {3, "3 (A6)", &gpio_ext_pa6}, - {4, "4 (A4)", &gpio_ext_pa4}, - {5, "5 (B3)", &gpio_ext_pb3}, - {6, "6 (B2)", &gpio_ext_pb2}, - {7, "7 (C3)", &gpio_ext_pc3}, - {10, " 10(SWC) ", &SWC_10}, - {12, "12 (SIO)", &SIO_12}, - {13, "13 (TX)", &TX_13}, - {14, "14 (RX)", &RX_14}, - {15, "15 (C1)", &gpio_ext_pc1}, - {16, "16 (C0)", &gpio_ext_pc0}, - {17, "17 (1W)", &ibutton_gpio}}; - -//Данные плагина -static PluginData* app; - -uint8_t DHTMon_GPIO_to_int(const GpioPin* gpio) { - if(gpio == NULL) return 255; - for(uint8_t i = 0; i < GPIO_ITEMS; i++) { - if(gpio_item[i].pin->pin == gpio->pin && gpio_item[i].pin->port == gpio->port) { - return gpio_item[i].num; - } - } - return 255; -} - -const GpioPin* DHTMon_GPIO_form_int(uint8_t name) { - for(uint8_t i = 0; i < GPIO_ITEMS; i++) { - if(gpio_item[i].num == name) { - return gpio_item[i].pin; - } - } - return NULL; -} - -const GpioPin* DHTMon_GPIO_from_index(uint8_t index) { - if(index > GPIO_ITEMS) return NULL; - return gpio_item[index].pin; -} - -uint8_t DHTMon_GPIO_to_index(const GpioPin* gpio) { - if(gpio == NULL) return 255; - for(uint8_t i = 0; i < GPIO_ITEMS; i++) { - if(gpio_item[i].pin->pin == gpio->pin && gpio_item[i].pin->port == gpio->port) { - return i; - } - } - return 255; -} - -const char* DHTMon_GPIO_getName(const GpioPin* gpio) { - if(gpio == NULL) return NULL; - for(uint8_t i = 0; i < GPIO_ITEMS; i++) { - if(gpio_item[i].pin->pin == gpio->pin && gpio_item[i].pin->port == gpio->port) { - return gpio_item[i].name; - } - } - return NULL; -} - -void DHTMon_sensors_init(void) { - //Включение 5V если на порту 1 FZ его нет - if(furi_hal_power_is_otg_enabled() != true) { - furi_hal_power_enable_otg(); - } - - //Настройка GPIO загруженных датчиков - for(uint8_t i = 0; i < app->sensors_count; i++) { - //Высокий уровень по умолчанию - furi_hal_gpio_write(app->sensors[i].GPIO, true); - //Режим работы - OpenDrain, подтяжка включается на всякий случай - furi_hal_gpio_init( - app->sensors[i].GPIO, //Порт FZ - GpioModeOutputOpenDrain, //Режим работы - открытый сток - GpioPullUp, //Принудительная подтяжка линии данных к питанию - GpioSpeedVeryHigh); //Скорость работы - максимальная - } -} - -void DHTMon_sensors_deinit(void) { - //Возврат исходного состояния 5V - if(app->last_OTG_State != true) { - furi_hal_power_disable_otg(); - } - - //Перевод портов GPIO в состояние по умолчанию - for(uint8_t i = 0; i < app->sensors_count; i++) { - furi_hal_gpio_init( - app->sensors[i].GPIO, //Порт FZ - GpioModeAnalog, //Режим работы - аналог - GpioPullNo, //Отключение подтяжки - GpioSpeedLow); //Скорость работы - низкая - //Установка низкого уровня - furi_hal_gpio_write(app->sensors[i].GPIO, false); - } -} - -bool DHTMon_sensor_check(DHT_sensor* sensor) { - /* Проверка имени */ - //1) Строка должна быть длиной от 1 до 10 символов - //2) Первый символ строки должен быть только 0-9, A-Z, a-z и _ - if(strlen(sensor->name) == 0 || strlen(sensor->name) > 10 || - (!(sensor->name[0] >= '0' && sensor->name[0] <= '9') && - !(sensor->name[0] >= 'A' && sensor->name[0] <= 'Z') && - !(sensor->name[0] >= 'a' && sensor->name[0] <= 'z') && !(sensor->name[0] == '_'))) { - FURI_LOG_D(APP_NAME, "Sensor [%s] name check failed\r\n", sensor->name); - return false; - } - //Проверка GPIO - if(DHTMon_GPIO_to_int(sensor->GPIO) == 255) { - FURI_LOG_D( - APP_NAME, - "Sensor [%s] GPIO check failed: %d\r\n", - sensor->name, - DHTMon_GPIO_to_int(sensor->GPIO)); - return false; - } - //Проверка типа датчика - if(sensor->type != DHT11 && sensor->type != DHT22) { - FURI_LOG_D(APP_NAME, "Sensor [%s] type check failed: %d\r\n", sensor->name, sensor->type); - return false; - } - - //Возврат истины если всё ок - FURI_LOG_D(APP_NAME, "Sensor [%s] all checks passed\r\n", sensor->name); - return true; -} - -void DHTMon_sensor_delete(DHT_sensor* sensor) { - if(sensor == NULL) return; - //Делаем параметры датчика неверными - sensor->name[0] = '\0'; - sensor->type = 255; - //Теперь сохраняем текущие датчики. Сохранятор не сохранит неисправный датчик - DHTMon_sensors_save(); - //Перезагружаемся с SD-карты - DHTMon_sensors_reload(); -} - -uint8_t DHTMon_sensors_save(void) { - //Выделение памяти для потока - app->file_stream = file_stream_alloc(app->storage); - uint8_t savedSensorsCount = 0; - //Переменная пути к файлу - FuriString* filepath = furi_string_alloc(); - //Составление пути к файлу - furi_string_printf(filepath, "%s/%s", APP_PATH_FOLDER, APP_FILENAME); - - //Открытие потока. Если поток открылся, то выполнение сохранения датчиков - if(file_stream_open( - app->file_stream, furi_string_get_cstr(filepath), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS)) { - const char template[] = - "#DHT monitor sensors file\n#Name - name of sensor. Up to 10 sumbols\n#Type - type of sensor. DHT11 - 0, DHT22 - 1\n#GPIO - connection port. May being 2-7, 10, 12-17\n#Name Type GPIO\n"; - stream_write(app->file_stream, (uint8_t*)template, strlen(template)); - //Сохранение датчиков - for(uint8_t i = 0; i < app->sensors_count; i++) { - //Если параметры датчика верны, то сохраняемся - if(DHTMon_sensor_check(&app->sensors[i])) { - stream_write_format( - app->file_stream, - "%s %d %d\n", - app->sensors[i].name, - app->sensors[i].type, - DHTMon_GPIO_to_int(app->sensors[i].GPIO)); - savedSensorsCount++; - } - } - } else { - //TODO: печать ошибки на экран - FURI_LOG_E(APP_NAME, "cannot create sensors file\r\n"); - } - stream_free(app->file_stream); - - return savedSensorsCount; -} - -bool DHTMon_sensors_load(void) { - //Обнуление количества датчиков - app->sensors_count = -1; - //Очистка предыдущих датчиков - memset(app->sensors, 0, sizeof(app->sensors)); - - //Открытие файла на SD-карте - //Выделение памяти для потока - app->file_stream = file_stream_alloc(app->storage); - //Переменная пути к файлу - FuriString* filepath = furi_string_alloc(); - //Составление пути к файлу - furi_string_printf(filepath, "%s/%s", APP_PATH_FOLDER, APP_FILENAME); - //Открытие потока к файлу - if(!file_stream_open( - app->file_stream, furi_string_get_cstr(filepath), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) { - //Если файл отсутствует, то создание болванки - FURI_LOG_W(APP_NAME, "Missing sensors file. Creating new file\r\n"); - app->sensors_count = 0; - stream_free(app->file_stream); - DHTMon_sensors_save(); - return false; - } - //Вычисление размера файла - size_t file_size = stream_size(app->file_stream); - if(file_size == (size_t)0) { - //Выход если файл пустой - FURI_LOG_W(APP_NAME, "Sensors file is empty\r\n"); - app->sensors_count = 0; - stream_free(app->file_stream); - return false; - } - - //Выделение памяти под загрузку файла - uint8_t* file_buf = malloc(file_size); - //Опустошение буфера файла - memset(file_buf, 0, file_size); - //Загрузка файла - if(stream_read(app->file_stream, file_buf, file_size) != file_size) { - //Выход при ошибке чтения - FURI_LOG_E(APP_NAME, "Error reading sensor file\r\n"); - app->sensors_count = 0; - stream_free(app->file_stream); - return false; - } - //Построчное чтение файла - //Указатель на начало строки - FuriString* file = furi_string_alloc_set_str((char*)file_buf); - //Сколько байт до конца строки - size_t line_end = 0; - while(line_end != STRING_FAILURE && app->sensors_count < MAX_SENSORS) { - if(((char*)(file_buf + line_end))[1] != '#') { - DHT_sensor s = {0}; - int type, port; - char name[11] = {0}; - sscanf(((char*)(file_buf + line_end)), "%s %d %d", name, &type, &port); - s.type = type; - s.GPIO = DHTMon_GPIO_form_int(port); - - name[10] = '\0'; - strcpy(s.name, name); - //Если данные корректны, то - if(DHTMon_sensor_check(&s) == true) { - //Установка нуля при первом датчике - if(app->sensors_count == -1) app->sensors_count = 0; - //Добавление датчика в общий список - app->sensors[app->sensors_count] = s; - //Увеличение количества загруженных датчиков - app->sensors_count++; - } - } - line_end = furi_string_search_char(file, '\n', line_end + 1); - } - stream_free(app->file_stream); - free(file_buf); - - //Обнуление количества датчиков если ни один из них не был загружен - if(app->sensors_count == -1) app->sensors_count = 0; - - //Инициализация портов датчиков если таковые есть - if(app->sensors_count > 0) { - DHTMon_sensors_init(); - return true; - } else { - return false; - } - return false; -} - -bool DHTMon_sensors_reload(void) { - DHTMon_sensors_deinit(); - return DHTMon_sensors_load(); -} - -/** - * @brief Обработчик отрисовки экрана - * - * @param canvas Указатель на холст - * @param ctx Данные плагина - */ -static void render_callback(Canvas* const canvas, void* ctx) { - PluginData* app = acquire_mutex((ValueMutex*)ctx, 25); - if(app == NULL) { - return; - } - //Вызов отрисовки главного экрана - scene_main(canvas, app); - - release_mutex((ValueMutex*)ctx, app); -} - -/** - * @brief Обработчик нажатия кнопок главного экрана - * - * @param input_event Указатель на событие - * @param event_queue Указатель на очередь событий - */ -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -/** - * @brief Выделение места под переменные плагина - * - * @return true Если всё прошло успешно - * @return false Если в процессе загрузки произошла ошибка - */ -static bool DHTMon_alloc(void) { - //Выделение места под данные плагина - app = malloc(sizeof(PluginData)); - //Выделение места под очередь событий - app->event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - //Обнуление количества датчиков - app->sensors_count = -1; - - //Инициализация мутекса - if(!init_mutex(&app->state_mutex, app, sizeof(PluginData))) { - FURI_LOG_E(APP_NAME, "cannot create mutex\r\n"); - return false; - } - - // Set system callbacks - app->view_port = view_port_alloc(); - view_port_draw_callback_set(app->view_port, render_callback, &app->state_mutex); - view_port_input_callback_set(app->view_port, input_callback, app->event_queue); - - // Open GUI and register view_port - app->gui = furi_record_open(RECORD_GUI); - gui_add_view_port(app->gui, app->view_port, GuiLayerFullscreen); - - app->view_dispatcher = view_dispatcher_alloc(); - - sensorActions_sceneCreate(app); - sensorEdit_sceneCreate(app); - - app->widget = widget_alloc(); - view_dispatcher_add_view(app->view_dispatcher, WIDGET_VIEW, widget_get_view(app->widget)); - - app->text_input = text_input_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, TEXTINPUT_VIEW, text_input_get_view(app->text_input)); - - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - //Уведомления - app->notifications = furi_record_open(RECORD_NOTIFICATION); - - //Подготовка хранилища - app->storage = furi_record_open(RECORD_STORAGE); - storage_common_mkdir(app->storage, APP_PATH_FOLDER); - app->file_stream = file_stream_alloc(app->storage); - - return true; -} - -/** - * @brief Освыбождение памяти после работы приложения - */ -static void DHTMon_free(void) { - //Автоматическое управление подсветкой - notification_message(app->notifications, &sequence_display_backlight_enforce_auto); - - furi_record_close(RECORD_STORAGE); - furi_record_close(RECORD_NOTIFICATION); - - text_input_free(app->text_input); - widget_free(app->widget); - sensorEdit_sceneRemove(); - sensorActions_screneRemove(); - view_dispatcher_free(app->view_dispatcher); - - furi_record_close(RECORD_GUI); - - view_port_enabled_set(app->view_port, false); - gui_remove_view_port(app->gui, app->view_port); - - view_port_free(app->view_port); - furi_message_queue_free(app->event_queue); - delete_mutex(&app->state_mutex); - - free(app); -} - -/** - * @brief Точка входа в приложение - * - * @return Код ошибки - */ -int32_t quenon_dht_mon_app() { - if(!DHTMon_alloc()) { - DHTMon_free(); - return 255; - } - //Постоянное свечение подсветки - notification_message(app->notifications, &sequence_display_backlight_enforce_on); - //Сохранение состояния наличия 5V на порту 1 FZ - app->last_OTG_State = furi_hal_power_is_otg_enabled(); - - //Загрузка датчиков с SD-карты - DHTMon_sensors_load(); - - app->currentSensorEdit = &app->sensors[0]; - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(app->event_queue, &event, 100); - - acquire_mutex_block(&app->state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - break; - case InputKeyLeft: - break; - case InputKeyMAX: - break; - case InputKeyOk: - view_port_update(app->view_port); - release_mutex(&app->state_mutex, app); - mainMenu_scene(app); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } else { - FURI_LOG_D(APP_NAME, "FuriMessageQueue: event timeout"); - // event timeout - } - - view_port_update(app->view_port); - release_mutex(&app->state_mutex, app); - } - //Освобождение памяти и деинициализация - DHTMon_sensors_deinit(); - DHTMon_free(); - - return 0; -} -//TODO: Обработка ошибок -//TODO: Пропуск использованных портов в меню добавления датчиков \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/quenon_dht_mon.h b/applications/plugins/dht_temp_sensor/quenon_dht_mon.h deleted file mode 100644 index 4e888f6c1..000000000 --- a/applications/plugins/dht_temp_sensor/quenon_dht_mon.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef QUENON_DHT_MON -#define QUENON_DHT_MON - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "DHT.h" - -#define APP_NAME "DHT_monitor" -#define APP_PATH_FOLDER "/ext/dht_monitor" -#define APP_FILENAME "sensors.txt" -#define MAX_SENSORS 5 - -// //Виды менюшек -typedef enum { - MAIN_MENU_VIEW, - ADDSENSOR_MENU_VIEW, - TEXTINPUT_VIEW, - SENSOR_ACTIONS_VIEW, - WIDGET_VIEW, -} MENU_VIEWS; - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - const uint8_t num; - const char* name; - const GpioPin* pin; -} GpioItem; - -//Структура с данными плагина -typedef struct { - //Очередь сообщений - FuriMessageQueue* event_queue; - //Мутекс - ValueMutex state_mutex; - //Вьюпорт - ViewPort* view_port; - //GUI - Gui* gui; - NotificationApp* notifications; - ViewDispatcher* view_dispatcher; - View* view; - TextInput* text_input; - VariableItem* item; - Widget* widget; - - char txtbuff[30]; //Буффер для печати строк на экране - bool last_OTG_State; //Состояние OTG до запуска приложения - Storage* storage; //Хранилище датчиков - Stream* file_stream; //Поток файла с датчиками - int8_t sensors_count; // Количество загруженных датчиков - DHT_sensor sensors[MAX_SENSORS]; //Сохранённые датчики - DHT_data data; //Инфа из датчика - DHT_sensor* currentSensorEdit; //Указатель на редактируемый датчик - -} PluginData; - -/* ================== Работа с GPIO ================== */ -/** - * @brief Конвертация GPIO в его номер на корпусе FZ - * - * @param gpio Указатель на преобразовываемый GPIO - * @return Номер порта на корпусе FZ - */ -uint8_t DHTMon_GPIO_to_int(const GpioPin* gpio); -/** - * @brief Конвертация номера порта на корпусе FZ в GPIO - * - * @param name Номер порта на корпусе FZ - * @return Указатель на GPIO при успехе, NULL при ошибке - */ -const GpioPin* DHTMon_GPIO_form_int(uint8_t name); -/** - * @brief Преобразование порядкового номера порта в GPIO - * - * @param index Индекс порта от 0 до GPIO_ITEMS-1 - * @return Указатель на GPIO при успехе, NULL при ошибке - */ -const GpioPin* DHTMon_GPIO_from_index(uint8_t index); -/** - * @brief Преобразование GPIO в порядковый номер порта - * - * @param gpio Указатель на GPIO - * @return index при успехе, 255 при ошибке - */ -uint8_t DHTMon_GPIO_to_index(const GpioPin* gpio); - -/** - * @brief Получить имя GPIO в виде строки - * - * @param gpio Искомый порт - * @return char* Указатель на строку с именем порта - */ -const char* DHTMon_GPIO_getName(const GpioPin* gpio); - -/* ================== Работа с датчиками ================== */ -/** - * @brief Инициализация портов ввода/вывода датчиков - */ -void DHTMon_sensors_init(void); -/** - * @brief Функция деинициализации портов ввода/вывода датчиков - */ -void DHTMon_sensors_deinit(void); -/** - * @brief Проверка корректности параметров датчика - * - * @param sensor Указатель на проверяемый датчик - * @return true Параметры датчика корректные - * @return false Параметры датчика некорректные - */ -bool DHTMon_sensor_check(DHT_sensor* sensor); -/** - * @brief Удаление датчика из списка и перезагрузка - * - * @param sensor Указатель на удаляемый датчик - */ -void DHTMon_sensor_delete(DHT_sensor* sensor); -/** - * @brief Сохранение датчиков на SD-карту - * - * @return Количество сохранённых датчиков - */ -uint8_t DHTMon_sensors_save(void); -/** - * @brief Загрузка датчиков с SD-карты - * - * @return true Был загружен хотя бы 1 датчик - * @return false Датчики отсутствуют - */ -bool DHTMon_sensors_load(void); -/** - * @brief Перезагрузка датчиков с SD-карты - * - * @return true Когда был загружен хотя бы 1 датчик - * @return false Ни один из датчиков не был загружен - */ -bool DHTMon_sensors_reload(void); - -void scene_main(Canvas* const canvas, PluginData* app); -void mainMenu_scene(PluginData* app); - -void sensorEdit_sceneCreate(PluginData* app); -void sensorEdit_scene(PluginData* app); -void sensorEdit_sceneRemove(void); - -void sensorActions_sceneCreate(PluginData* app); -void sensorActions_scene(PluginData* app); -void sensorActions_screneRemove(void); -#endif \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/scenes/DHTMon_mainMenu_scene.c b/applications/plugins/dht_temp_sensor/scenes/DHTMon_mainMenu_scene.c deleted file mode 100644 index 26ac9ca89..000000000 --- a/applications/plugins/dht_temp_sensor/scenes/DHTMon_mainMenu_scene.c +++ /dev/null @@ -1,157 +0,0 @@ -#include "../quenon_dht_mon.h" -//Текущий вид -static View* view; -//Список -static VariableItemList* variable_item_list; - -/** - * @brief Функция обработки нажатия кнопки "Назад" - * - * @param context Указатель на данные приложения - * @return ID вида в который нужно переключиться - */ -static uint32_t actions_exitCallback(void* context) { - PluginData* app = context; - UNUSED(app); - //Возвращаем ID вида, в который нужно вернуться - return VIEW_NONE; -} -/** - * @brief Функция обработки нажатия средней кнопки - * - * @param context Указатель на данные приложения - * @param index На каком элементе списка была нажата кнопка - */ -static void enterCallback(void* context, uint32_t index) { - PluginData* app = context; - if((uint8_t)index < (uint8_t)app->sensors_count) { - app->currentSensorEdit = &app->sensors[index]; - sensorActions_scene(app); - } - if((uint8_t)index == (uint8_t)app->sensors_count) { - app->currentSensorEdit = &app->sensors[app->sensors_count++]; - strcpy(app->currentSensorEdit->name, "NewSensor"); - app->currentSensorEdit->GPIO = DHTMon_GPIO_from_index(0); - app->currentSensorEdit->type = DHT11; - sensorEdit_scene(app); - } -} - -/** - * @brief Создание списка действий с указанным датчиком - * - * @param app Указатель на данные плагина - */ -void mainMenu_scene(PluginData* app) { - variable_item_list = variable_item_list_alloc(); - //Сброс всех элементов меню - variable_item_list_reset(variable_item_list); - //Добавление названий датчиков в качестве элементов списка - for(uint8_t i = 0; i < app->sensors_count; i++) { - variable_item_list_add(variable_item_list, app->sensors[i].name, 1, NULL, NULL); - } - if(app->sensors_count < (uint8_t)MAX_SENSORS) { - variable_item_list_add(variable_item_list, " + Add new sensor +", 1, NULL, NULL); - } - - //Добавление колбека на нажатие средней кнопки - variable_item_list_set_enter_callback(variable_item_list, enterCallback, app); - - //Создание вида из списка - view = variable_item_list_get_view(variable_item_list); - //Добавление колбека на нажатие кнопки "Назад" - view_set_previous_callback(view, actions_exitCallback); - //Добавление вида в диспетчер - view_dispatcher_add_view(app->view_dispatcher, MAIN_MENU_VIEW, view); - - view_dispatcher_enable_queue(app->view_dispatcher); - - //Переключение на наш вид - view_dispatcher_switch_to_view(app->view_dispatcher, MAIN_MENU_VIEW); - - //Запуск диспетчера - view_dispatcher_run(app->view_dispatcher); - - //Очистка списка элементов - variable_item_list_free(variable_item_list); - //Удаление вида после обработки - view_dispatcher_remove_view(app->view_dispatcher, MAIN_MENU_VIEW); -} - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -// static VariableItemList* variable_item_list; -// /* ============== Главное меню ============== */ -// static uint32_t mainMenu_exitCallback(void* context) { -// UNUSED(context); -// variable_item_list_free(variable_item_list); -// DHT_sensors_reload(); -// return VIEW_NONE; -// } -// static void mainMenu_enterCallback(void* context, uint32_t index) { -// PluginData* app = context; -// if((uint8_t)index == (uint8_t)app->sensors_count) { -// addSensor_scene(app); -// view_dispatcher_run(app->view_dispatcher); -// } -// } -// void mainMenu_scene(PluginData* app) { -// variable_item_list = variable_item_list_alloc(); -// variable_item_list_reset(variable_item_list); -// for(uint8_t i = 0; i < app->sensors_count; i++) { -// variable_item_list_add(variable_item_list, app->sensors[i].name, 1, NULL, NULL); -// } -// variable_item_list_add(variable_item_list, "+ Add new sensor +", 1, NULL, NULL); - -// app->view = variable_item_list_get_view(variable_item_list); -// app->view_dispatcher = view_dispatcher_alloc(); - -// view_dispatcher_enable_queue(app->view_dispatcher); -// view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); -// view_dispatcher_add_view(app->view_dispatcher, MAIN_MENU_VIEW, app->view); -// view_dispatcher_switch_to_view(app->view_dispatcher, MAIN_MENU_VIEW); - -// variable_item_list_set_enter_callback(variable_item_list, mainMenu_enterCallback, app); -// view_set_previous_callback(app->view, mainMenu_exitCallback); -// } \ No newline at end of file diff --git a/applications/plugins/dht_temp_sensor/scenes/DHTMon_main_scene.c b/applications/plugins/dht_temp_sensor/scenes/DHTMon_main_scene.c deleted file mode 100644 index aab343752..000000000 --- a/applications/plugins/dht_temp_sensor/scenes/DHTMon_main_scene.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "../quenon_dht_mon.h" - -/* ============== Главный экран ============== */ -void scene_main(Canvas* const canvas, PluginData* app) { - //Рисование бара - canvas_draw_box(canvas, 0, 0, 128, 14); - canvas_set_color(canvas, ColorWhite); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 32, 11, "DHT Monitor"); - - canvas_set_color(canvas, ColorBlack); - if(app->sensors_count > 0) { - if(!furi_hal_power_is_otg_enabled()) { - furi_hal_power_enable_otg(); - } - for(uint8_t i = 0; i < app->sensors_count; i++) { - app->data = DHT_getData(&app->sensors[i]); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 24 + 10 * i, app->sensors[i].name); - - canvas_set_font(canvas, FontSecondary); - if(app->data.hum == -128.0f && app->data.temp == -128.0f) { - canvas_draw_str(canvas, 96, 24 + 10 * i, "timeout"); - } else { - snprintf( - app->txtbuff, - sizeof(app->txtbuff), - "%2.1f*C/%d%%", - (double)app->data.temp, - (int8_t)app->data.hum); - canvas_draw_str(canvas, 64, 24 + 10 * i, app->txtbuff); - } - } - } else { - canvas_set_font(canvas, FontSecondary); - if(app->sensors_count == 0) canvas_draw_str(canvas, 0, 24, "Sensors not found"); - if(app->sensors_count == -1) canvas_draw_str(canvas, 0, 24, "Loading..."); - } -} diff --git a/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorActions_scene.c b/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorActions_scene.c deleted file mode 100644 index ae7674f70..000000000 --- a/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorActions_scene.c +++ /dev/null @@ -1,194 +0,0 @@ -#include "../quenon_dht_mon.h" - -//Текущий вид -static View* view; -//Список -static VariableItemList* variable_item_list; - -/* ================== Информация о датчике ================== */ -/** - * @brief Функция обработки нажатия кнопки "Назад" - * - * @param context Указатель на данные приложения - * @return ID вида в который нужно переключиться - */ -static uint32_t infoWidget_exitCallback(void* context) { - PluginData* app = context; - UNUSED(app); - //Возвращаем ID вида, в который нужно вернуться - return SENSOR_ACTIONS_VIEW; -} -/** - * @brief Обработчик нажатий на кнопку в виджете - * - * @param result Какая из кнопок была нажата - * @param type Тип нажатия - * @param context Указатель на данные плагина - */ -static void infoWidget_callback(GuiButtonType result, InputType type, void* context) { - PluginData* app = context; - //Коротко нажата левая кнопка (Back) - if(result == GuiButtonTypeLeft && type == InputTypeShort) { - view_dispatcher_switch_to_view(app->view_dispatcher, SENSOR_ACTIONS_VIEW); - } -} -/** - * @brief Создание виджета информации о датчике - * - * @param app Указатель на данные плагина - */ -static void sensorInfo_widget(PluginData* app) { - //Очистка виджета - widget_reset(app->widget); - //Добавление кнопок - widget_add_button_element(app->widget, GuiButtonTypeLeft, "Back", infoWidget_callback, app); - - char str[32]; - snprintf(str, sizeof(str), "\e#%s\e#", app->currentSensorEdit->name); - widget_add_text_box_element(app->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, str, false); - snprintf(str, sizeof(str), "\e#Type:\e# %s", app->currentSensorEdit->type ? "DHT22" : "DHT11"); - widget_add_text_box_element(app->widget, 0, 0, 128, 47, AlignLeft, AlignCenter, str, false); - snprintf( - str, sizeof(str), "\e#GPIO:\e# %s", DHTMon_GPIO_getName(app->currentSensorEdit->GPIO)); - widget_add_text_box_element(app->widget, 0, 0, 128, 72, AlignLeft, AlignCenter, str, false); - view_set_previous_callback(widget_get_view(app->widget), infoWidget_exitCallback); - view_dispatcher_switch_to_view(app->view_dispatcher, WIDGET_VIEW); -} - -/* ================== Подтверждение удаления ================== */ -/** - * @brief Функция обработки нажатия кнопки "Назад" - * - * @param context Указатель на данные приложения - * @return ID вида в который нужно переключиться - */ -static uint32_t deleteWidget_exitCallback(void* context) { - PluginData* app = context; - UNUSED(app); - //Возвращаем ID вида, в который нужно вернуться - return SENSOR_ACTIONS_VIEW; -} -/** - * @brief Обработчик нажатий на кнопку в виджете - * - * @param result Какая из кнопок была нажата - * @param type Тип нажатия - * @param context Указатель на данные плагина - */ -static void deleteWidget_callback(GuiButtonType result, InputType type, void* context) { - PluginData* app = context; - //Коротко нажата левая кнопка (Cancel) - if(result == GuiButtonTypeLeft && type == InputTypeShort) { - view_dispatcher_switch_to_view(app->view_dispatcher, SENSOR_ACTIONS_VIEW); - } - //Коротко нажата правая кнопка (Delete) - if(result == GuiButtonTypeRight && type == InputTypeShort) { - //Удаление датчика - DHTMon_sensor_delete(app->currentSensorEdit); - //Выход из меню - view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_NONE); - } -} -/** - * @brief Создание виджета удаления датчика - * - * @param app Указатель на данные плагина - */ -static void sensorDelete_widget(PluginData* app) { - //Очистка виджета - widget_reset(app->widget); - //Добавление кнопок - widget_add_button_element( - app->widget, GuiButtonTypeLeft, "Cancel", deleteWidget_callback, app); - widget_add_button_element( - app->widget, GuiButtonTypeRight, "Delete", deleteWidget_callback, app); - - char delete_str[32]; - snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", app->currentSensorEdit->name); - widget_add_text_box_element( - app->widget, 0, 0, 128, 23, AlignCenter, AlignCenter, delete_str, false); - snprintf( - delete_str, - sizeof(delete_str), - "\e#Type:\e# %s", - app->currentSensorEdit->type ? "DHT22" : "DHT11"); - widget_add_text_box_element( - app->widget, 0, 0, 128, 47, AlignLeft, AlignCenter, delete_str, false); - snprintf( - delete_str, - sizeof(delete_str), - "\e#GPIO:\e# %s", - DHTMon_GPIO_getName(app->currentSensorEdit->GPIO)); - widget_add_text_box_element( - app->widget, 0, 0, 128, 72, AlignLeft, AlignCenter, delete_str, false); - view_set_previous_callback(widget_get_view(app->widget), deleteWidget_exitCallback); - view_dispatcher_switch_to_view(app->view_dispatcher, WIDGET_VIEW); -} - -/* ================== Меню действий ================== */ -/** - * @brief Функция обработки нажатия средней кнопки - * - * @param context Указатель на данные приложения - * @param index На каком элементе списка была нажата кнопка - */ -static void enterCallback(void* context, uint32_t index) { - PluginData* app = context; - if(index == 0) { - sensorInfo_widget(app); - } - if(index == 1) { - sensorEdit_scene(app); - } - if(index == 2) { - sensorDelete_widget(app); - } -} - -/** - * @brief Функция обработки нажатия кнопки "Назад" - * - * @param context Указатель на данные приложения - * @return ID вида в который нужно переключиться - */ -static uint32_t actions_exitCallback(void* context) { - PluginData* app = context; - UNUSED(app); - //Возвращаем ID вида, в который нужно вернуться - return MAIN_MENU_VIEW; -} - -/** - * @brief Создание списка действий с указанным датчиком - * - * @param app Указатель на данные плагина - */ -void sensorActions_sceneCreate(PluginData* app) { - variable_item_list = variable_item_list_alloc(); - //Сброс всех элементов меню - variable_item_list_reset(variable_item_list); - //Добавление элементов в список - variable_item_list_add(variable_item_list, "Info", 0, NULL, NULL); - variable_item_list_add(variable_item_list, "Edit", 0, NULL, NULL); - variable_item_list_add(variable_item_list, "Delete", 0, NULL, NULL); - - //Добавление колбека на нажатие средней кнопки - variable_item_list_set_enter_callback(variable_item_list, enterCallback, app); - - //Создание вида из списка - view = variable_item_list_get_view(variable_item_list); - //Добавление колбека на нажатие кнопки "Назад" - view_set_previous_callback(view, actions_exitCallback); - //Добавление вида в диспетчер - view_dispatcher_add_view(app->view_dispatcher, SENSOR_ACTIONS_VIEW, view); -} -void sensorActions_scene(PluginData* app) { - //Сброс выбранного пункта в ноль - variable_item_list_set_selected_item(variable_item_list, 0); - //Переключение на наш вид - view_dispatcher_switch_to_view(app->view_dispatcher, SENSOR_ACTIONS_VIEW); -} - -void sensorActions_screneRemove(void) { - variable_item_list_free(variable_item_list); -} diff --git a/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorEdit_scene.c b/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorEdit_scene.c deleted file mode 100644 index 5decac3d1..000000000 --- a/applications/plugins/dht_temp_sensor/scenes/DHTMon_sensorEdit_scene.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "../quenon_dht_mon.h" - -static VariableItem* nameItem; -static VariableItemList* variable_item_list; - -static const char* const sensorsTypes[2] = { - "DHT11", - "DHT22", -}; - -// /* ============== Добавление датчика ============== */ -static uint32_t addSensor_exitCallback(void* context) { - UNUSED(context); - DHTMon_sensors_reload(); - return VIEW_NONE; -} - -static void addSensor_sensorTypeChanged(VariableItem* item) { - uint8_t index = variable_item_get_current_value_index(item); - PluginData* app = variable_item_get_context(item); - variable_item_set_current_value_text(item, sensorsTypes[index]); - app->currentSensorEdit->type = index; -} - -static void addSensor_GPIOChanged(VariableItem* item) { - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text(item, DHTMon_GPIO_getName(DHTMon_GPIO_from_index(index))); - PluginData* app = variable_item_get_context(item); - app->currentSensorEdit->GPIO = DHTMon_GPIO_from_index(index); -} - -static void addSensor_sensorNameChanged(void* context) { - PluginData* app = context; - variable_item_set_current_value_text(nameItem, app->currentSensorEdit->name); - view_dispatcher_switch_to_view(app->view_dispatcher, ADDSENSOR_MENU_VIEW); -} -static void addSensor_sensorNameChange(PluginData* app) { - text_input_set_header_text(app->text_input, "Sensor name"); - //По неясной мне причине в длину строки входит терминатор. Поэтому при длине 10 приходится указывать 11 - text_input_set_result_callback( - app->text_input, addSensor_sensorNameChanged, app, app->currentSensorEdit->name, 11, true); - view_dispatcher_switch_to_view(app->view_dispatcher, TEXTINPUT_VIEW); -} - -static void addSensor_enterCallback(void* context, uint32_t index) { - PluginData* app = context; - if(index == 0) { - addSensor_sensorNameChange(app); - } - if(index == 3) { - //Сохранение датчика - DHTMon_sensors_save(); - DHTMon_sensors_reload(); - view_dispatcher_switch_to_view(app->view_dispatcher, VIEW_NONE); - } -} - -void sensorEdit_sceneCreate(PluginData* app) { - variable_item_list = variable_item_list_alloc(); - - variable_item_list_reset(variable_item_list); - - variable_item_list_set_enter_callback(variable_item_list, addSensor_enterCallback, app); - - app->view = variable_item_list_get_view(variable_item_list); - - view_set_previous_callback(app->view, addSensor_exitCallback); - - view_dispatcher_add_view(app->view_dispatcher, ADDSENSOR_MENU_VIEW, app->view); -} -void sensorEdit_scene(PluginData* app) { - //Очистка списка - variable_item_list_reset(variable_item_list); - - //Имя редактируемого датчика - nameItem = variable_item_list_add(variable_item_list, "Name: ", 1, NULL, NULL); - variable_item_set_current_value_index(nameItem, 0); - variable_item_set_current_value_text(nameItem, app->currentSensorEdit->name); - - //Тип датчика - app->item = - variable_item_list_add(variable_item_list, "Type:", 2, addSensor_sensorTypeChanged, app); - - variable_item_set_current_value_index(app->item, app->currentSensorEdit->type); - variable_item_set_current_value_text(app->item, sensorsTypes[app->currentSensorEdit->type]); - - //GPIO - app->item = - variable_item_list_add(variable_item_list, "GPIO:", 13, addSensor_GPIOChanged, app); - variable_item_set_current_value_index( - app->item, DHTMon_GPIO_to_index(app->currentSensorEdit->GPIO)); - variable_item_set_current_value_text( - app->item, DHTMon_GPIO_getName(app->currentSensorEdit->GPIO)); - variable_item_list_add(variable_item_list, "Save", 1, NULL, app); - - //Сброс выбранного пункта в ноль - variable_item_list_set_selected_item(variable_item_list, 0); - - view_dispatcher_switch_to_view(app->view_dispatcher, ADDSENSOR_MENU_VIEW); -} -void sensorEdit_sceneRemove(void) { - variable_item_list_free(variable_item_list); -} \ No newline at end of file diff --git a/applications/plugins/dice2/LICENSE.md b/applications/plugins/dice2/LICENSE.md deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/dice2/LICENSE.md +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/dice2/README.md b/applications/plugins/dice2/README.md deleted file mode 100644 index 43ac42ee8..000000000 --- a/applications/plugins/dice2/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Flipper Zero DnD Dice - -
-
- -**DnD Dice** is a dice rolling application for your **Flipper Zero**. - -Dice types: Coin, d4, d6, d8, d10, d12, d20, d100 - -## Screenshots - -
-
-
- -## Compiling - -1. Clone the [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware) repository or another firmware that you use (for example [unleashed-firmware](https://github.com/DarkFlippers/unleashed-firmware)). -2. Create a symbolic link in `applications_user` named **dice**, pointing to this repository. -3. Compile by command `./fbt fap_dice_dnd_app` -4. Copy `build/f7-firmware-D/.extapps/dice_dnd_app.fap` to **apps/Games** on the SD card or by [qFlipper](https://flipperzero.one/update) app. diff --git a/applications/plugins/dice2/application.fam b/applications/plugins/dice2/application.fam deleted file mode 100644 index e8ec7ccd2..000000000 --- a/applications/plugins/dice2/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="DND_Dice_app", - name="DnD Dice [Ka3u6y6a]", - apptype=FlipperAppType.EXTERNAL, - entry_point="dice_dnd_app", - cdefines=["APP_DICE"], - requires=["gui"], - stack_size=1 * 1024, - order=90, - fap_icon="icon.png", - fap_category="Games", - fap_icon_assets="assets", -) \ No newline at end of file diff --git a/applications/plugins/dice2/assets/coin_1.png b/applications/plugins/dice2/assets/coin_1.png deleted file mode 100644 index 6f56f9644..000000000 Binary files a/applications/plugins/dice2/assets/coin_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_2.png b/applications/plugins/dice2/assets/coin_2.png deleted file mode 100644 index 08c5872d9..000000000 Binary files a/applications/plugins/dice2/assets/coin_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_3.png b/applications/plugins/dice2/assets/coin_3.png deleted file mode 100644 index c757caa66..000000000 Binary files a/applications/plugins/dice2/assets/coin_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_4.png b/applications/plugins/dice2/assets/coin_4.png deleted file mode 100644 index 508184d14..000000000 Binary files a/applications/plugins/dice2/assets/coin_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_5.png b/applications/plugins/dice2/assets/coin_5.png deleted file mode 100644 index 85831d239..000000000 Binary files a/applications/plugins/dice2/assets/coin_5.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_6.png b/applications/plugins/dice2/assets/coin_6.png deleted file mode 100644 index 17cdbf105..000000000 Binary files a/applications/plugins/dice2/assets/coin_6.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/coin_7.png b/applications/plugins/dice2/assets/coin_7.png deleted file mode 100644 index 82f828a94..000000000 Binary files a/applications/plugins/dice2/assets/coin_7.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d100_1.png b/applications/plugins/dice2/assets/d100_1.png deleted file mode 100644 index a7f2c18b0..000000000 Binary files a/applications/plugins/dice2/assets/d100_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d100_2.png b/applications/plugins/dice2/assets/d100_2.png deleted file mode 100644 index 783486976..000000000 Binary files a/applications/plugins/dice2/assets/d100_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d100_3.png b/applications/plugins/dice2/assets/d100_3.png deleted file mode 100644 index 92d5a5c0c..000000000 Binary files a/applications/plugins/dice2/assets/d100_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d100_4.png b/applications/plugins/dice2/assets/d100_4.png deleted file mode 100644 index 324b7f633..000000000 Binary files a/applications/plugins/dice2/assets/d100_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d10_1.png b/applications/plugins/dice2/assets/d10_1.png deleted file mode 100644 index d742026c9..000000000 Binary files a/applications/plugins/dice2/assets/d10_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d10_2.png b/applications/plugins/dice2/assets/d10_2.png deleted file mode 100644 index 0d9ca60ef..000000000 Binary files a/applications/plugins/dice2/assets/d10_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d10_3.png b/applications/plugins/dice2/assets/d10_3.png deleted file mode 100644 index ab67316c6..000000000 Binary files a/applications/plugins/dice2/assets/d10_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d10_4.png b/applications/plugins/dice2/assets/d10_4.png deleted file mode 100644 index e89b03f3a..000000000 Binary files a/applications/plugins/dice2/assets/d10_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d12_1.png b/applications/plugins/dice2/assets/d12_1.png deleted file mode 100644 index 053ead3cd..000000000 Binary files a/applications/plugins/dice2/assets/d12_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d12_2.png b/applications/plugins/dice2/assets/d12_2.png deleted file mode 100644 index 752abaf33..000000000 Binary files a/applications/plugins/dice2/assets/d12_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d12_3.png b/applications/plugins/dice2/assets/d12_3.png deleted file mode 100644 index 711d18514..000000000 Binary files a/applications/plugins/dice2/assets/d12_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d12_4.png b/applications/plugins/dice2/assets/d12_4.png deleted file mode 100644 index dff920c42..000000000 Binary files a/applications/plugins/dice2/assets/d12_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d20_1.png b/applications/plugins/dice2/assets/d20_1.png deleted file mode 100644 index 593adbad9..000000000 Binary files a/applications/plugins/dice2/assets/d20_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d20_2.png b/applications/plugins/dice2/assets/d20_2.png deleted file mode 100644 index b8d11952d..000000000 Binary files a/applications/plugins/dice2/assets/d20_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d20_3.png b/applications/plugins/dice2/assets/d20_3.png deleted file mode 100644 index bea6e8ffc..000000000 Binary files a/applications/plugins/dice2/assets/d20_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d20_4.png b/applications/plugins/dice2/assets/d20_4.png deleted file mode 100644 index 1fa19dc4c..000000000 Binary files a/applications/plugins/dice2/assets/d20_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d4_1.png b/applications/plugins/dice2/assets/d4_1.png deleted file mode 100644 index 8007cdca5..000000000 Binary files a/applications/plugins/dice2/assets/d4_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d4_2.png b/applications/plugins/dice2/assets/d4_2.png deleted file mode 100644 index 8757c56e3..000000000 Binary files a/applications/plugins/dice2/assets/d4_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d4_3.png b/applications/plugins/dice2/assets/d4_3.png deleted file mode 100644 index 8d1687ac8..000000000 Binary files a/applications/plugins/dice2/assets/d4_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d6_1.png b/applications/plugins/dice2/assets/d6_1.png deleted file mode 100644 index f3b2ba293..000000000 Binary files a/applications/plugins/dice2/assets/d6_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d6_2.png b/applications/plugins/dice2/assets/d6_2.png deleted file mode 100644 index 257c87a0d..000000000 Binary files a/applications/plugins/dice2/assets/d6_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d6_3.png b/applications/plugins/dice2/assets/d6_3.png deleted file mode 100644 index 882be3a67..000000000 Binary files a/applications/plugins/dice2/assets/d6_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d6_4.png b/applications/plugins/dice2/assets/d6_4.png deleted file mode 100644 index ac7928e2c..000000000 Binary files a/applications/plugins/dice2/assets/d6_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d8_1.png b/applications/plugins/dice2/assets/d8_1.png deleted file mode 100644 index b4c3b692e..000000000 Binary files a/applications/plugins/dice2/assets/d8_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d8_2.png b/applications/plugins/dice2/assets/d8_2.png deleted file mode 100644 index 705416e49..000000000 Binary files a/applications/plugins/dice2/assets/d8_2.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d8_3.png b/applications/plugins/dice2/assets/d8_3.png deleted file mode 100644 index 4c95fdcbf..000000000 Binary files a/applications/plugins/dice2/assets/d8_3.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/d8_4.png b/applications/plugins/dice2/assets/d8_4.png deleted file mode 100644 index a5f7fe838..000000000 Binary files a/applications/plugins/dice2/assets/d8_4.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_back.png b/applications/plugins/dice2/assets/ui_button_back.png deleted file mode 100644 index 2c22d19c6..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_back.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_down.png b/applications/plugins/dice2/assets/ui_button_down.png deleted file mode 100644 index 2954bb6a6..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_down.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_exit.png b/applications/plugins/dice2/assets/ui_button_exit.png deleted file mode 100644 index 22f357913..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_exit.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_left.png b/applications/plugins/dice2/assets/ui_button_left.png deleted file mode 100644 index 0b4655d43..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_left.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_right.png b/applications/plugins/dice2/assets/ui_button_right.png deleted file mode 100644 index 8e1c74c1c..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_right.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_roll.png b/applications/plugins/dice2/assets/ui_button_roll.png deleted file mode 100644 index f20d7f565..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_roll.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_button_up.png b/applications/plugins/dice2/assets/ui_button_up.png deleted file mode 100644 index 1be79328b..000000000 Binary files a/applications/plugins/dice2/assets/ui_button_up.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_count.png b/applications/plugins/dice2/assets/ui_count.png deleted file mode 100644 index a408de025..000000000 Binary files a/applications/plugins/dice2/assets/ui_count.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_count_1.png b/applications/plugins/dice2/assets/ui_count_1.png deleted file mode 100644 index ec61bde96..000000000 Binary files a/applications/plugins/dice2/assets/ui_count_1.png and /dev/null differ diff --git a/applications/plugins/dice2/assets/ui_result_border.png b/applications/plugins/dice2/assets/ui_result_border.png deleted file mode 100644 index 576402050..000000000 Binary files a/applications/plugins/dice2/assets/ui_result_border.png and /dev/null differ diff --git a/applications/plugins/dice2/constants.h b/applications/plugins/dice2/constants.h deleted file mode 100644 index 3f263433d..000000000 --- a/applications/plugins/dice2/constants.h +++ /dev/null @@ -1,159 +0,0 @@ -#include -#include "DND_Dice_app_icons.h" - -#define TAG "DiceApp" - -#define DICE_TYPES 8 - -#define MAX_DICE_COUNT 10 -#define MAX_COIN_FRAMES 9 -#define MAX_DICE_FRAMES 4 - -#define DICE_X 45 -#define DICE_Y 6 -#define DICE_Y_T 0 - -#define DICE_GAP 44 - -#define RESULT_BORDER_X 44 -#define RESULT_OFFSET 20 - -#define SWIPE_DIST 11 - -const Icon* coin_heads_start[] = {&I_coin_1, &I_coin_2}; -const Icon* coin_heads_end[] = {&I_coin_7, &I_coin_1}; -const Icon* coin_tails_start[] = {&I_coin_5, &I_coin_6}; -const Icon* coin_tails_end[] = {&I_coin_4, &I_coin_5}; -const Icon* coin_frames[] = { - &I_coin_1, - &I_coin_2, - &I_coin_3, - &I_coin_4, - &I_coin_5, - &I_coin_6, - &I_coin_3, - &I_coin_7, - &I_coin_1, -}; - -const int8_t result_frame_pos_y[] = {-30, -20, -10, 0}; -const Icon* dice_frames[] = { - &I_d4_1, &I_d4_2, &I_d4_3, &I_d4_1, // d4 - &I_d6_1, &I_d6_2, &I_d6_3, &I_d6_4, // d6 - &I_d8_1, &I_d8_2, &I_d8_3, &I_d8_4, // d8 - &I_d10_1, &I_d10_2, &I_d10_3, &I_d10_4, // d10 - &I_d12_1, &I_d12_2, &I_d12_3, &I_d12_4, // d12 - &I_d20_1, &I_d20_2, &I_d20_3, &I_d20_4, // d20 - &I_d100_1, &I_d100_2, &I_d100_3, &I_d100_4, // d100 -}; - -typedef struct { - uint8_t type; - int x; - int y; - char* name; -} Dice; - -const uint8_t screen_pos[] = {}; - -static const Dice dice_types[] = { - {2, 0, 0, "Coin"}, - {4, 0, 0, "d4"}, - {6, 0, 0, "d6"}, - {8, 0, 0, "d8"}, - {10, 0, 0, "d10"}, - {12, 0, 0, "d12"}, - {20, 0, 0, "d20"}, - {100, 0, 0, "d100"}, -}; - -typedef enum { EventTypeTick, EventTypeKey } EventType; -typedef enum { - SelectState, - SwipeLeftState, - SwipeRightState, - AnimState, - AnimResultState, - ResultState -} AppState; - -typedef struct { - EventType type; - InputEvent input; -} AppEvent; - -typedef struct { - AppState app_state; - uint16_t roll_result; - uint8_t rolled_dices[MAX_DICE_COUNT]; - uint8_t anim_frame; - uint8_t dice_index; - uint8_t dice_count; - int8_t result_pos; - Dice dices[DICE_TYPES]; -} State; - -void init(State* const state) { - state->app_state = SelectState; - state->roll_result = 0; - state->dice_index = 0; - state->anim_frame = 0; - state->dice_count = 1; - - for(uint8_t i = 0; i < DICE_TYPES; i++) { - state->dices[i] = dice_types[i]; - state->dices[i].x = DICE_X + (i * DICE_GAP); - state->dices[i].y = i == 0 ? DICE_Y_T : DICE_Y; - } -} - -void coin_set_start(uint16_t type) { - if(type == 1) { - coin_frames[0] = coin_heads_start[0]; - coin_frames[1] = coin_heads_start[1]; - } else { - coin_frames[0] = coin_tails_start[0]; - coin_frames[1] = coin_tails_start[1]; - } -} - -void coin_set_end(uint16_t type) { - if(type == 1) { - coin_frames[MAX_COIN_FRAMES - 2] = coin_heads_end[0]; - coin_frames[MAX_COIN_FRAMES - 1] = coin_heads_end[1]; - } else { - coin_frames[MAX_COIN_FRAMES - 2] = coin_tails_end[0]; - coin_frames[MAX_COIN_FRAMES - 1] = coin_tails_end[1]; - } -} - -bool isResultVisible(AppState state, uint8_t dice_index) { - return (state == ResultState || state == AnimResultState) && dice_index != 0; -} - -bool isDiceNameVisible(AppState state) { - return state != SwipeLeftState && state != SwipeRightState; -} - -bool isDiceButtonsVisible(AppState state) { - return isDiceNameVisible(state) && state != AnimResultState && state != ResultState && - state != AnimState; -} - -bool isOneDice(uint8_t dice_index) { - return dice_index == 0 || dice_index == 7; -} - -bool isDiceSettingsDisabled(AppState state, uint8_t dice_index) { - return isOneDice(dice_index) || state == ResultState || state == AnimResultState || - state == AnimState; -} - -bool isAnimState(AppState state) { - return state == SwipeLeftState || state == SwipeRightState || state == AnimResultState || - state == AnimState; -} - -bool isMenuState(AppState state) { - return state == SwipeLeftState || state == SwipeRightState || state == SelectState; -} \ No newline at end of file diff --git a/applications/plugins/dice2/dice_app.c b/applications/plugins/dice2/dice_app.c deleted file mode 100644 index 5e06c4aad..000000000 --- a/applications/plugins/dice2/dice_app.c +++ /dev/null @@ -1,333 +0,0 @@ -#include -#include -#include -#include "constants.h" - -const Icon* draw_dice_frame; - -static void update(State* const state) { - if(state->app_state == SwipeLeftState) { - for(uint8_t i = 0; i < DICE_TYPES; i++) { - state->dices[i].x -= SWIPE_DIST; - state->dices[i].y = DICE_Y; - } - - if(state->dices[state->dice_index].x == DICE_X) { - state->app_state = SelectState; - state->dices[state->dice_index].y = DICE_Y_T; - } - - } else if(state->app_state == SwipeRightState) { - for(uint8_t i = 0; i < DICE_TYPES; i++) { - state->dices[i].x += SWIPE_DIST; - state->dices[i].y = DICE_Y; - } - - if(state->dices[state->dice_index].x == DICE_X) { - state->app_state = SelectState; - state->dices[state->dice_index].y = DICE_Y_T; - } - } else if(state->app_state == AnimState) { - state->anim_frame += 1; - - if(state->dice_index == 0) { - if(state->anim_frame == 3) coin_set_start(state->roll_result); // change coin anim - - if(state->anim_frame >= MAX_COIN_FRAMES) { - state->anim_frame = 0; - state->app_state = AnimResultState; - } - } else { - if(state->anim_frame >= MAX_DICE_FRAMES) { - state->anim_frame = 0; - state->app_state = AnimResultState; - } - } - } else if(state->app_state == AnimResultState) { - if(state->dice_index == 0) { // no extra animations for coin - state->anim_frame = 0; - state->app_state = ResultState; - return; - } - - state->result_pos = result_frame_pos_y[state->anim_frame]; - state->anim_frame += 1; - - // end animation - if(state->result_pos == 0) { - state->anim_frame = 0; - state->app_state = ResultState; - } - } -} - -static void roll(State* const state) { - state->roll_result = 0; - state->result_pos = result_frame_pos_y[0]; - - for(uint8_t i = 0; i < MAX_DICE_COUNT; i++) { - if(i < state->dice_count) { - state->rolled_dices[i] = (rand() % dice_types[state->dice_index].type) + 1; - state->roll_result += state->rolled_dices[i]; - } else { - state->rolled_dices[i] = 0; - } - } - - if(state->dice_index == 0) coin_set_end(state->roll_result); // change coin anim - - state->app_state = AnimState; -} - -static void draw_ui(const State* state, Canvas* canvas) { - canvas_set_font(canvas, FontSecondary); - - FuriString* count = furi_string_alloc(); - furi_string_printf(count, "%01d", state->dice_count); - - // dice name - if(isDiceNameVisible(state->app_state)) { - canvas_draw_str_aligned( - canvas, 63, 50, AlignCenter, AlignBottom, dice_types[state->dice_index].name); - } - // dice arrow buttons - if(isDiceButtonsVisible(state->app_state)) { - if(state->dice_index > 0) canvas_draw_icon(canvas, 45, 44, &I_ui_button_left); - if(state->dice_index < DICE_TYPES - 1) - canvas_draw_icon(canvas, 78, 44, &I_ui_button_right); - } - - // dice count settings - if(isDiceSettingsDisabled(state->app_state, state->dice_index)) - canvas_draw_icon(canvas, 48, 51, &I_ui_count_1); - else - canvas_draw_icon(canvas, 48, 51, &I_ui_count); - canvas_draw_str_aligned(canvas, 58, 61, AlignCenter, AlignBottom, furi_string_get_cstr(count)); - - // buttons - if(isAnimState(state->app_state) == false) canvas_draw_icon(canvas, 92, 54, &I_ui_button_roll); - - if(state->app_state != AnimResultState && state->app_state != ResultState) { - canvas_draw_icon(canvas, 0, 54, &I_ui_button_exit); - } else { - canvas_draw_icon(canvas, 0, 54, &I_ui_button_back); - } - - furi_string_free(count); -} - -static void draw_dice(const State* state, Canvas* canvas) { - if(isMenuState(state->app_state) == false) { // draw only selected dice - if(state->dice_index == 0) { // coin - draw_dice_frame = coin_frames[state->anim_frame]; - } else { // dices - draw_dice_frame = - dice_frames[(state->dice_index - 1) * MAX_DICE_FRAMES + state->anim_frame]; - } - - canvas_draw_icon( - canvas, - state->dices[state->dice_index].x, - state->dices[state->dice_index].y, - draw_dice_frame); - return; - } - - for(uint8_t i = 0; i < DICE_TYPES; i++) { - if(state->app_state == ResultState && state->dice_index == i && state->dice_index != 0) - continue; // draw results except coin - if(state->dices[i].x > 128 || state->dices[i].x < -35) continue; // outside the screen - - if(i == 0) { // coin - draw_dice_frame = coin_frames[0]; - } else { // dices - draw_dice_frame = dice_frames[(i - 1) * MAX_DICE_FRAMES]; - } - - canvas_draw_icon(canvas, state->dices[i].x, state->dices[i].y, draw_dice_frame); - } -} - -static void draw_results(const State* state, Canvas* canvas) { - canvas_set_font(canvas, FontPrimary); - - FuriString* sum = furi_string_alloc(); - furi_string_printf(sum, "%01d", state->roll_result); - - // ui frame - if(state->app_state == AnimResultState) - canvas_draw_icon(canvas, RESULT_BORDER_X, state->result_pos, &I_ui_result_border); - else - canvas_draw_icon( - canvas, RESULT_BORDER_X, result_frame_pos_y[MAX_DICE_FRAMES - 1], &I_ui_result_border); - - // result text - canvas_draw_str_aligned( - canvas, - 64, - state->result_pos + RESULT_OFFSET, - AlignCenter, - AlignCenter, - furi_string_get_cstr(sum)); - - if(state->app_state == ResultState && isOneDice(state->dice_index) == false) { - canvas_set_font(canvas, FontSecondary); - - FuriString* dices = furi_string_alloc(); - for(uint8_t i = 0; i < state->dice_count; i++) { - furi_string_cat_printf(dices, "%01d", state->rolled_dices[i]); - - if(i != state->dice_count - 1) furi_string_cat_printf(dices, "%s", ", "); - } - - canvas_draw_str_aligned( - canvas, 63, 37, AlignCenter, AlignCenter, furi_string_get_cstr(dices)); - furi_string_free(dices); - } - - furi_string_free(sum); -} - -static void draw_callback(Canvas* canvas, void* ctx) { - const State* state = acquire_mutex((ValueMutex*)ctx, 25); - if(state == NULL) { - return; - } - - canvas_clear(canvas); - - draw_ui(state, canvas); - - if(isResultVisible(state->app_state, state->dice_index)) { - draw_results(state, canvas); - } else { - draw_dice(state, canvas); - } - - release_mutex((ValueMutex*)ctx, state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - AppEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - AppEvent event = {.type = EventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -int32_t dice_dnd_app(void* p) { - UNUSED(p); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(AppEvent)); - - FURI_LOG_E(TAG, ">>> Started...\r\n"); - State* state = malloc(sizeof(State)); - init(state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, state, sizeof(State))) { - FURI_LOG_E(TAG, "cannot create mutex\r\n"); - free(state); - return 255; - } - - // Set callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, draw_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - FuriTimer* timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, furi_kernel_get_tick_frequency() * 0.2); - - // Create GUI, register view port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - AppEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - State* state = (State*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // timer evetn - if(event.type == EventTypeTick) { - update(state); - } - // button events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - // dice type - if(isDiceButtonsVisible(state->app_state)) { - if(event.input.key == InputKeyRight) { - if(state->dice_index < DICE_TYPES - 1) { - state->dice_index += 1; - state->app_state = SwipeLeftState; - } - } else if(event.input.key == InputKeyLeft) { - if(state->dice_index > 0) { - state->dice_index -= 1; - state->app_state = SwipeRightState; - } - } - - if(isOneDice(state->dice_index)) state->dice_count = 1; - } - // dice count - if(isDiceSettingsDisabled(state->app_state, state->dice_index) == false && - isAnimState(state->app_state) == false) { - if(event.input.key == InputKeyUp) { - if(state->dice_index != 0) { - state->dice_count += 1; - if(state->dice_count > MAX_DICE_COUNT) { - state->dice_count = MAX_DICE_COUNT; - } - } - } else if(event.input.key == InputKeyDown) { - state->dice_count -= 1; - if(state->dice_count < 1) { - state->dice_count = 1; - } - } - } - // roll - if(event.input.key == InputKeyOk && isAnimState(state->app_state) == false) { - roll(state); - } - // back to dice select state or quit from app - if(event.input.key == InputKeyBack) { - if(state->app_state == ResultState || - state->app_state == AnimResultState) { - state->anim_frame = 0; - state->app_state = SelectState; - } else { - processing = false; - } - } - } - } - } else { - FURI_LOG_D(TAG, "osMessageQueue: event timeout"); - } - - view_port_update(view_port); - release_mutex(&state_mutex, state); - } - - // Clear - free(state); - furi_timer_free(timer); - furi_message_queue_free(event_queue); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - delete_mutex(&state_mutex); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/dice2/icon.png b/applications/plugins/dice2/icon.png deleted file mode 100644 index 840088565..000000000 Binary files a/applications/plugins/dice2/icon.png and /dev/null differ diff --git a/applications/plugins/dice2/sources/coin.pixil b/applications/plugins/dice2/sources/coin.pixil deleted file mode 100644 index 838aeafc0..000000000 --- a/applications/plugins/dice2/sources/coin.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAFlJREFUWEft1MEJACAMBEGv/6IvFeRxhoDC+hYMm0HZ9nnkiGGaTVCmI0oZyqTfF2Ywg5m0AGbSYvwzYzOS1iuuP5C4YZixmST37V3WxJpSO5jBDGbSAl+YKXbCj5ghLqGvAAAAAElFTkSuQmCC","edit":false,"name":"Layer 1","opacity":"1","active":true,"unqid":"zdzpbp","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAf5JREFUWEftVkFywjAMVAZooP//apukScYdq7ariJXsAAcO4UICtrxerVbq6I0+3RthoQOMlY1nmAkNKd4Vf9fidLgEkffH36znjDn+/0lE369gJoPYHBpCCF3XUQiBuvhA8fH/WYGMOEwCWpiRIO4Y2AmGwVqAamDyRvTdIJmyRIJ4CAxipOhlnucqmMvlwiBOpxOt65pTpNO9QYyChmEY6Ha76QD8Po5juF6v+baterRYdsGgkpXptKrJY0qKXq8rsZFm+LBYEcuyUKKaf0pR9B5LA1D4XGqRXi48/phgSoBcJeIaFvA9RcCHW7HRLbNnuJ5glChKYWYV+pNkx6K8UJ9u8SgrmdicHdcYkTBdYxItAbKq1IlaRAGY9FKk8UowUuQ6xUjkstT/NC1uYtm+vIlZll5dO/qSXtUExhKlpruC564nucxI1VsjgU5FreIkQJ0q7ch37XyTqth/zuczNKgaDeB/dMGNkdZKlgNM0xT6vvd6Uc34aJ7nkBunMYjBQScC+CGivrGM9UDlkSbZ+UqTn9ubpC48n/D0oAGVdKzryiOFdF74oiIsRBR36Y7L744zIyCWhWzW1nKNOnWt1LUvofEBnlsDA11VsIJmHwYjhnKUdqirFjCWA7fs1Sx+pOJ4GowWbKvVtIDmWM0LW09+Zt0BxmLvYMZi5hdntuIk2wS1xwAAAABJRU5ErkJggg==","edit":false,"name":"Layer 2 Copy","opacity":"1","active":true,"unqid":"","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAmlJREFUWEelWOt6qDAIs+//0O5rV1hIA9Rz9mdOsYQQLm48//bzXr42Lu2W2RfjAOB9azxjHEe3vlqD53ncKwMQDleEjV3qswOzgODhCoA9r56tNPyxJf1WYAIQdETgjjPebaDeqQBlYCSQTieZWA2AYDD4V2CugIxMMBuRsWMAbwBJMFUE00kHxAAIWxWoY2AwboyRoPMEjKrzwbb7b6841s8BBlmBa7cjB6razNYAhnetqoj9ZSPBcH73AYrFdQ/1IVK4Hs/7XGX7vuNAByFFXfnuZhjAFOmcZzsYZAdTFcB8SNE6HIVKTc2jBZ0wcG+mG1AYIEZnaOlJtAGMpUpVWQXGunsLxmg1B5TvtD9R47OKYqbm+1y5mhkUXAYm6SHmxH+DnevGxDwZQREfmgGD0CfUvGHdUFN2jeyADp1dgdlUc9PCxtZNe88WMwNpvEsTCMtzyxpCbVQjgsBgb8O0/RYjIk1KW4nPq/rrtlj5uAGD7PCWkI2JbJvwZm16gf6UM2OpglFw9BZuesnYWOPCRAzV0zc9c0DIefh5Y8SZA++mS5uBEatsZIbYCA6RBSjVLB1c1nbWZIjP9eme7jOQSw84afu8y1Q6yvbqeoXgbU98fvDED4HdrJ3VCrEChx7DAuNPFtTR/wDx1iEHXqF4zzeWJDdALALQ2rokzTiQcAEHhi9IrCqhIwUuiJqrBgPdhk5INWPCfoOVpiIndgIg/piz/YVLsQSDFPNnUvdBp+zVVEdAN9PXGRIUZ33G72OTyxgJvaM5UWqIZ0s2ACuNfEkT26bCroDBIW0WWgPB2u1/rb6wv2x/ACDUeEL6Qq7OAAAAAElFTkSuQmCC","edit":false,"name":"Background","opacity":"1","active":false,"unqid":"u6oba5","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAfZJREFUWEftVl1vgzAMNCoM2P//qxtQiDw5JZkxdj5YH6qpeULCdu7OziUNvNBqXggL/AswWKFoMeHiQACQAEpyeQ7FfwDA3SJypSAgIjZNQ7mmQogIewztHeKS++XAaEUkW4uozM3mpcBsAHADiEN+KM7U4cw5sFCb8vg+pkoWGI1VKlb7x2vEb+cc3m7E0a9DnlWEhqzfEyQzzt7/I5V85cccycXz+fcXAHxyQEXJy7Jg3/cyVgNpzQWu6wpd14WhV1uobRDk8wXati1hnLMdbW74afQ4LLap1oSBtYiUDDGvEfeypvwKGHmqZO0U8cfIMRpy+muY17ZJKlMMJmdWORUD0OzclChjmZbqFQmJqsCoQ7U7be3GZ7M5epG3Jna/maeJLkIKtE4bB5ZroSZUNErmkcnNvKsKQ9VaGj1JsQnNiX28Vdu8U0idbduCa/Jjm3NtUw1f5Lddp9anLjjNvFJeYinB2629fyIG8yaepgnGceRtiEzmecZhGLida2rk3P1kCRYY2ZaQGJnRvZVb4WKkJ4NzThI77Z0Cox31E6gcoP0/v61Nk8yBsRSKQMPJ4L6hecj+DpZPiAOXEjAhQX39VYLRvCsCqgEjQclToj2YpCnSy+7bau0VMBqop9T/C5jC2S0Pe4N5Sk/LBb8W+W6TpdsPAVbkJHCu0MYAAAAASUVORK5CYII=","edit":false,"name":"Layer 2","opacity":"1","active":false,"unqid":"","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAKFJREFUWEftVVsKwCAMa+9/6I4Oiw/cap2Cg+zHQWuaJXEyHfTwQVwIZJ7cgDJQJnpSkRlkBpmJKjCSGVkFOonD5dEWkcyHuaq5+Lo5sqcclkb1yViRiJSdEq7WNJiMvPa/vVu9Xe0Lt5BJytzES8KfyCjjiOSuh50G16YZ0IV7YiFdOLgLhYty5Ke32wUXHzbBJjckTQMyg8wgM1EFfpGZCziRWCSDveGOAAAAAElFTkSuQmCC","edit":false,"name":"Layer 4","opacity":"1","active":false,"unqid":"","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":5,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAfhJREFUWEftl91uwjAMhR21HbC9/6sOOkCZ0tWVe+q/VprEBVyh4iZfju3jUOiFPuWFWOgNY2XjiDI1kdoj64Zp+iSibyKSALxRe2Z9Z95dUFEwQ6w2rbXWUqZHhb/XWqn8PUTIKS6hphvEi24U2AnDgCGUR4wwmVqRAkiVtINtxLJgZHpq13X0fD6nk93v9xBqGAYPylRIg9EUwTgPqNxut3o+n2V6GKBer1e6XC4qUGYTWbyySxDIiuN3tAOs9ldhWmdM6HPLQIdkGgMBpn1aivu+b+uqrS9hFnJoU5RUdpd2atd7vLU3MIZfyE2t1KLHtHdU8HmPjToIs5gYG5pIl6XIZg3Io/fe6jcsOu10Vo1EIwLfW9nF7Morh49gcBxoYNaM8mKlfSw1mYGJ5koW5uWUwUZQ0yQrXys4z1v2KINtrxYwwyy2DWPfAsTnZlxr58fjQfPcUie55hkr+uaawzBYXRZafPOacRzpdDrhGhtwDabd7L7mvIQnb3cbGB2eFfB+IxF94KXLmtrTlaHrOlXOLKigwrpKTW11wDmbowrs4JplcF22i1Gvyed5iOWw6qlABW0qhwYaGRp2GYn7r1UbljrRIcJbeyuyH+OvSuQ98vfMoUMYa9h5IFqKMvG7YVKLHg1KyXd08b3vvWHMNtwr5X/G/wLO/uskz2jgOQAAAABJRU5ErkJggg==","edit":false,"name":"Layer 2 Copy Copy","opacity":"1","active":false,"unqid":"","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":6,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAkBJREFUWEetl1t2wyAMRO39L9o9pkgZDSMJ2vQrTQRcRk/u629/z+aye9NumJ0YB4DnqXnue9m6Pas1uK7LT2UAceC4YWOXntnBDBDcXAHY79Vvww0fteS5FUwAwYMIbtnjmQZqTQWUwUiQBKKNJQMQCobzFUwLMiW3ta/98tnUsWzaAZIwzQ3w8J3MZViPwQnoDAzjquBN7o+jx4Xh/xLmNZ62A2j+7xnH8bPAoCrw+bXDDXGdKjit4qT+sJcwiX+34ysrppxlU2XnWG5oBl36QjEc8kNQZwq+seIqvhcGmN/l4HS3NUPKmrEZxg8GDMRSCHBa40B0hoahwPXMnJUYYQKLSm+xJkuQGmZu7rckV3AWyVqTXMBsGWx1E/jSM8g2RbcJl6kiyK4dW2GaYxAvMVPBFPXlWBmrOS3M9EFQpim1xzCWjVswnHbfDGCMR6jKZ6mdqGO1Q8bMEukwXnAVPqozGzAMtizBKrwNgxNe0xjb3oSZx80SJkDtJjNQjTILZCr1WR/zzi1G2QhDamCr93j48ghhGbtUYCtIPPyElmBFq0n1qlWo/esRgqc98fz499hZjRBBGdFV+cmCMKiEjxQu6YwGHty6Sc/bUDFAo8zpMwWyxGMPv2NVxm/C9+EFiQrxAbb25BFHlT0wZO+mRSHMNJZfVNnwFT/m+FXAGaKSY1EopMjhw79SZAcGvDCeJzyzbmU3ztSZIkcwGBsIlTxrQh3ZUeQExlkUlAV1BgbyVfE5zFqDKtu2/HRwxg9BIkRCZQ/enQAAAABJRU5ErkJggg==","edit":false,"name":"Background Copy","opacity":"1","active":false,"unqid":"u6oba5","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":7,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAfpJREFUWEftV9tugzAMdQQM2P7/VwcUUKakJHKMHZuqk3hon6piHx8f36iDG33cjbjAh4xUjavK+AtlvYqtlukLAB4AgElYglDSFh+VTBAiAUdA7713rortDptkZE6khsqBFMSEkknBVV+JDOcYfsP2XP9IqmCVdgBouUQ4MjHIvu/QNE14rmZkaGqciIhHyQTDXwD4OQJwahQ+Qg9hJbjvCwCE4SiwODKF87quvuu6pJCoJAI+JbAsC/R9TzGoHdsDXOCTI1IufKW9dErSew/btkHXdcn+VC4ORApMW0PaJRb/ZFPY0l3ASUkz5/qVNqhWTkwm41vIWLanhUxaoDjholQWMrdRxrBCoolVmYRXLVMGRHsjbtMoy/MWWbc118DSvmIbOB/EEN89o6sLT9jOml/MER3bnCR7awghrIrlPnEq5jVQwT5JH52O6iSFaE9Y++j0+hG2edu2rCrVDFBEOnFUqWRas8PEcDLV2yTtAu6GSQq5eZ79MAz44ucTME0TjOPIDoRlQnzTNPGVIkxUkFqr03F/sGLsKFOc2nal90MlQcDppq1d/uh6hYy4i8KYCivBpAhtOkl5euYjOF2MChkt6RxbO4Lfx5sfLlHx8nUg0XNgTbYQQSPDKWbpnVdwTf+btOF52/OXMnhbdGb8/gv7Mu5HGUmyP5KE6CQNV8vwAAAAAElFTkSuQmCC","edit":false,"name":"Layer 2 Copy","opacity":"1","active":false,"unqid":"","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":1,"unqid":"rs6rne","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAdFJREFUWEftV9uqg0AMXKko6v//quL9ECESY25r+1AO7UuL7mYnM5NkW+z7vqcv+RQ/MIoS/4OZoihcp+XaMZsZCgIPg2fab0QM7/u+T23bqkmEwSCICAALmMWWC4aCsBiIgqQxOEUmGNwofbuGIQsAKI8h7VfBSIxQv8zz7OIpy/IA8Xq90rquh6+43DSICAY2DMOQmqa5BICNEHAcx1TX9RlYQsW9obFsgpFKlgbWqsmiifqJr7vE5uOA0rgsSwKq4aPRqxlSMz6CkeJdZJLKl/aJm/tJf9GYofKgzDS5yzPKjJfNRV8BiCQhHhzpPTdmaBlaPrD6hceg2q+QmU+ywqWVgEvyncy8C0bzAZeJGpj3nTAYr+RzJX3EjGZKnqHXjrlUJhhKp2YwLgUty3fAnJVmlTbMH5wvOQdLwKQEb31N6sC8J0zTlKqqUmdR5EaH3dxkXQIDB8MwtCqBlm+059B1XdcdNz9zNklzyDss8h5l3rbtuFJIsqv3GfAK3kGsQfnEuJr/3Jse3+iVOi15bzDexob3j9I6XGqEfBTksOpeyHmm0mGaVDwRrEp1vceM1jM8r+SAPhN+AiYKJHddWKbcwE/W/8B81MBPJIjs+QPyMEG2lHD1VgAAAABJRU5ErkJggg==","width":"35","height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAdFJREFUWEftV9uqg0AMXKko6v//quL9ECESY25r+1AO7UuL7mYnM5NkW+z7vqcv+RQ/MIoS/4OZoihcp+XaMZsZCgIPg2fab0QM7/u+T23bqkmEwSCICAALmMWWC4aCsBiIgqQxOEUmGNwofbuGIQsAKI8h7VfBSIxQv8zz7OIpy/IA8Xq90rquh6+43DSICAY2DMOQmqa5BICNEHAcx1TX9RlYQsW9obFsgpFKlgbWqsmiifqJr7vE5uOA0rgsSwKq4aPRqxlSMz6CkeJdZJLKl/aJm/tJf9GYofKgzDS5yzPKjJfNRV8BiCQhHhzpPTdmaBlaPrD6hceg2q+QmU+ywqWVgEvyncy8C0bzAZeJGpj3nTAYr+RzJX3EjGZKnqHXjrlUJhhKp2YwLgUty3fAnJVmlTbMH5wvOQdLwKQEb31N6sC8J0zTlKqqUmdR5EaH3dxkXQIDB8MwtCqBlm+059B1XdcdNz9zNklzyDss8h5l3rbtuFJIsqv3GfAK3kGsQfnEuJr/3Jse3+iVOi15bzDexob3j9I6XGqEfBTksOpeyHmm0mGaVDwRrEp1vceM1jM8r+SAPhN+AiYKJHddWKbcwE/W/8B81MBPJIjs+QPyMEG2lHD1VgAAAABJRU5ErkJggg==","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d10.pixil b/applications/plugins/dice2/sources/d10.pixil deleted file mode 100644 index 3356c453c..000000000 --- a/applications/plugins/dice2/sources/d10.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAEpJREFUWEft1MENACAIADHZf2kn8HE/TOoE5KjMWfRm0SzHMK9tKKNM/anMMMNMLcBMLebOMMNMLcBMLebOMMNMLcBMLebOfGHmAm5UACTjh/FnAAAAAElFTkSuQmCC","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"vbd6q","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAhVJREFUWEftV9GOwjAMW7f//+R2p+Sa4npJ2wEPCIF04hgjcRzHzdJ5nuf2Ia/0AxN04ruZSSlNFRjJNGRmJWiU1UuG8W6BWfmhAZF7Jbi9y/X0H0Bng4pq171CXGY8Viiw9UJsQRPQuyKxOMbErMgLGPtBznk7jqMrYJV+LylcC9lxwQgQezEgRDcCZ9+VUqQoZTLnfO773rUU44VgBISBGgHi3iNA0w7co/lQX1Mw9Qalk9sVTkIdadCHaUk1bbq6DQYB4P+SyP4kAzDWKpbrVezeRD3HjAUspWifvYnw9EMj3m7B8V9uU/WJ5h0iQANDE+HI5eErkhzF+1SbDIy1xwGDHtO8r7ZH1xH2FwKFt3YFhabH4w2m18A4Rtg2EgRUwWhi/A0PwxCMeQIFYWbQgbuqPQdG7S2D8aqowdn+sVUXZiKT9EQ8PLWZUgCjWKt/UL5exA0prBZ8sLZ7orUTT2NkSbQk7atC7VoWgG9aQXFbzKEDYyVecAODVs8epJ9L2VI9k0xI7EFLmuEKIgGHq8EDCD55XKZwGYxH6Wg18E5p2nM0JC9d3cE6elTh5NGy5DDUnVW8gEXjPXw6GG1mEbDq3O6J/1ZmeEw9Rmjk2/hjB6IibzGzopluVFPq4ke79dRnPLPyvIGSdwef9yFazlTds2ftSMRR1lGyGdJbYCzYKwlHgKZgZtW88/sfmIjNj2LmD0cIcLZmv4arAAAAAElFTkSuQmCC","edit":false,"name":"Layer 1","opacity":"1","active":false,"unqid":"syuab","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjJJREFUWEfVl9u2gyAMRKX+/yerXaEMaxgSQHseevpSeyHsJDNB0/ZDr/RDLNv/gbmu64oql1L680SGAQ3G23PAmNmfgt6CMYhZQWagI9gQBi3SzUebzUANxFuPSg5hOLhWBUHpPznWRGedBEvcvPYWDCIBwAHizZrYDOkk+Rym9D1vrEDHcWz7vgPE3GjXcGU6juN6vV5Ve48rE1VEgCoItRZATSst3hTGE68G1org83meTWVEaxmKv1uC8VxUvmtaoLMoQ53nlj6t4qHZVYwSijWDDZwMNtNE6XktvVZSgKCtPEC5olyV0E0rMDS8cvZe29Q1LHys4WndWZuz9CpD46C6tQTkz43TAohGvG5lWAMDGLUsYnVAPHh4+qqThjCkjZqlI+AKEVSsm0W3NIPKGAxe+76jpJxAN9DK/zvrFrtrUuttKpN0s0DmHpkzWX/UAm/QsairNtkceoK75wf1cwSjh15UkeY4EKc2+3cwPPLtmisDV8j5U1z6KZTMkgqCysr7HIbFi3ZhLlgwa5vnEk2EDskIag3GRGvB7JQt193sYKDgEE1yXCjUOgwcxTAqFEc4tV3lN96w6kqPgm7ORLaOAIJbyG628E3cIwGzVgAz2hyagoh1DYwguhq3SYNp0OCmu7ldiO51HF3FMPCod9qOtMJ25mTkxqqG8PTSaYYHxspjxxMtoZ3eg577dDB63Ji5aSWJ5crMNhv9fieJ5cp8A/TN2vAh7pugT9f+FMwbzj9NQl0XLG4AAAAASUVORK5CYII=","edit":false,"name":"Layer 2","opacity":"1","active":false,"unqid":"n3umw","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAj5JREFUWEfNVwGOwyAMK93/n8yYwhHOMQnQ3k7qpGnayoLjOCak40Gv9CAsx/PBlFLKLmMppa8l5AYSMDt7XMA85OYlsQXG23QHbMSuxmNAKzDyvJdMgjQQSUsp3/X3FVOYQPuP2X8AwyWCLGqiFESAKmD8rEth/UCSx84MTGeFAekm8snZ8q5czpzz8Xq9vMTG1lZmBMD7/ZY/VsA553KeZw2iG1zVkgDRlwDiUoXMwEJs864VZmVlBQpEQCg7d8GgkI14sWSzEkF5TPmxo7aZ4U7CUrWAlUFlQJ7rW39XrdxlpretZo1i9oSN7OBz0d95npVVJ5EfLTK1KGDI2IiYgrlxuLUbmMGTwjKhkSHQWSdBMCP0lmQNKeAVTFSiISOHwhpTAkhbc0urGzsGp4x3MKu2DsHMdEE66ZuCE2PcDka7rnnX4DFLMJGXOIC4RP2YgC40zbA8m0i8XdvotBviVSCNjH64TsU71QyamXPa4tmioGvJtAmoHGa9x8qyTDAedAsoOZcjFnONKYD+BMabT6C97flEgBwWh25iM5xOekFbmzOptfDyFI/KSqAHw/2lv9l00Cne4daHJ+y6YBgzzRAN8QMYRc+GRoddElfGIckD1JUNF4hIvEbA0bjZNmFzq5jR6DxGvgZGA5HHmOGKN4vG09UgbrwB/QFVv3Mdmd0I+P/eEG72wy/Ufu6tUsRHp3sUwp2FZjfQ21fT1RXYY3Um3sGBwxQvPpgB/RdmLuLbWn67TFvRLy56FJgPoS1QQmVa3RoAAAAASUVORK5CYII=","edit":false,"name":"Layer 3","opacity":"1","active":false,"unqid":"syuab","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAiVJREFUWEfdl9uOwyAMRHP5/09OUxkxaBhsQ6OtVO0+dUuCj8djQ/fth/72H2LZ/j/Mfd93pPi+76EAj5XJAhqIF9MYH8HMgkUBWZEavH21DOMFTxTtAiQl6ZZQvUidViaDiaRdqH/xCAVTNZbUCWHYg04mg0EVRN5/DmMbvV6v7TxPg0VgfC4JXNd1n+dZgmQg6q3MN4MyTl0NpoCQIfFesxpK7IFx+T+CQaZ1g6aMgpgyx3EUZQIQTUBVHMZKpww29hQgE+/3dd3bcXSzhDKGkjWvMluGrvI6qnsKHcVSq6wKImUtILZP9VzxEytnn6NSuTBIY9aqznoBsff/DMabnACM/AEI8tpQJuwbDb+0TNkZQ2vc/uXrOg4GAzsl6+IveWbSMUUBggCQq4yUbw4j7W0DbrM2ViNWAMCoKh2M7YE/G5aeiQdlpL3d1ndmEQO5ypgilpBBLcEgFWm/dhxg0CUKdfOEpzZgMhMPU5BnDUG1ZuKukdZue+Hc4nWFIXXbe1OYSpF2iNd1FtySgYpcnsjEIYxAsOHCw1FrxMdAhSlJRb5ZUYafCS9RCqL/o5vMvE9hOpDZvSUakgCbtXdaJlyy9KoA82lwvt01x8uJDVWWDZxMXPeeK9O3Vcg7aLHonU+DMjxrnKExXKR4SM58M7vxLcGsyD8D4fWlU5skdH+2eEp9AsHPTm96DLMaJPu5urpHM/unL3zzedcz3wyY7f1TMG9hxkxC7RN4kQAAAABJRU5ErkJggg==","edit":false,"name":"Layer 4","opacity":"1","active":true,"unqid":"n3umw","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":4,"unqid":"rbcl7d","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAiVJREFUWEfdl9uOwyAMRHP5/09OUxkxaBhsQ6OtVO0+dUuCj8djQ/fth/72H2LZ/j/Mfd93pPi+76EAj5XJAhqIF9MYH8HMgkUBWZEavH21DOMFTxTtAiQl6ZZQvUidViaDiaRdqH/xCAVTNZbUCWHYg04mg0EVRN5/DmMbvV6v7TxPg0VgfC4JXNd1n+dZgmQg6q3MN4MyTl0NpoCQIfFesxpK7IFx+T+CQaZ1g6aMgpgyx3EUZQIQTUBVHMZKpww29hQgE+/3dd3bcXSzhDKGkjWvMluGrvI6qnsKHcVSq6wKImUtILZP9VzxEytnn6NSuTBIY9aqznoBsff/DMabnACM/AEI8tpQJuwbDb+0TNkZQ2vc/uXrOg4GAzsl6+IveWbSMUUBggCQq4yUbw4j7W0DbrM2ViNWAMCoKh2M7YE/G5aeiQdlpL3d1ndmEQO5ypgilpBBLcEgFWm/dhxg0CUKdfOEpzZgMhMPU5BnDUG1ZuKukdZue+Hc4nWFIXXbe1OYSpF2iNd1FtySgYpcnsjEIYxAsOHCw1FrxMdAhSlJRb5ZUYafCS9RCqL/o5vMvE9hOpDZvSUakgCbtXdaJlyy9KoA82lwvt01x8uJDVWWDZxMXPeeK9O3Vcg7aLHonU+DMjxrnKExXKR4SM58M7vxLcGsyD8D4fWlU5skdH+2eEp9AsHPTm96DLMaJPu5urpHM/unL3zzedcz3wyY7f1TMG9hxkxC7RN4kQAAAABJRU5ErkJggg==","width":"35","height":"35","old_width":"35","old_height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAn9JREFUWEfNmFGOwyAMRCG5y+b+x0nvQlmZYjQMNmSjrpT+VGkbPDyPbdIYQvgJIbye8B7D5/UIQSLmEUJEx7+QyTnnSnx4izG6AG6TmQUUBZ+Y/Us0xhgPz6MumZzz6e1OP7cC4j01ePuoXq/JWDtdBZMok4wMdPS3XqoaGSHhoZ3kX5EXj0AwpsHXZqoaMiGDYnDHxk6GFLIQuv9SqkwystD7/Q77vssONLD8VgiUDaSUzn3fS5CZEDbzzMQDGVgYU1CEgCH1vtMTopT/YmKXTF2skWEhQmbbtkIGA8M1b4ApDlXVkdGFLAJg4iOndIZt66oFyralUlLMZDStVr/p+oyaGNFzjlkIlWsRIutUzxU/ccq8ftOh4vJelarxfREiu78gZihvl8ykzK0KOrRjg9fkWIKmb5SMIinD2iTj9Qj1DRHB8pef6HV5t9IEvuniX/LMpGKG8q+C2+cshtLXpcr1DC6SUgpSxkbvaP2miugaI5KRNfQlzdIy8UCGyrspJ09glbAgTVXnGSEiGxJRIMYnIybC8q4zSQ9Khza6CSE+SzfPqBglbpl4OM9oeeNNUFld1ZCRW8pTSll3r6RZjGXioSUTGU0zemEoVx6G2mdkE7oRTI9nYpcMVEWZ2tCJ3eEII6ObWXJRxZRyJ980IFfIoMmaMIsGi8FrrSZJn2filWc6Iatzy0rgqrxdMpoaNR4H8ubWLFWQrjZScHqbZCYd1zznwgjotFiCjZHie0aOlLPDOR+ksEnOPGOR5bP1QAYbH+8Cg115jPHEXZra+qTnkeHFcbqvqBhemp9n9E+A1aMrERqK4O6fCV9b6K4AvM/0zDcWvvMH1KPI/AIAOS/9S+9jJwAAAABJRU5ErkJggg==","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d100.pixil b/applications/plugins/dice2/sources/d100.pixil deleted file mode 100644 index c4fd81342..000000000 --- a/applications/plugins/dice2/sources/d100.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAExJREFUWEft1LERACAMAzGy/9DOBCncUYgJuI/OkyTvkzc+c1xCmYuoMsq088UMM8y0BZhpi9kZZphpCzDTFrMzzDDTFmCmLWZnrmIL7qWLmCXUhAcAAAAASUVORK5CYII=","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"1exvb","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAArBJREFUWEfNWMF2wjAMa+n/fzJ0zyEyiiKn5W2H9bIBia3IsmLYt3/07L/AclZ7z/Pc9n3/Ova3G0oAfwHsFpjzPE86aOwJUNXfCVcwFc8VW5dgCEhL3kuwPZ/P7TgOAAKAnYFTudq+K0BLMMJICwYwCA4Ur9crGTmOA+sGsFeASjDmhAMYrUUwFU8AYdDu/4ohC6YCIgmx14oaDAI0v64YmsCoRhBMT87MxGePxwOaSGY6A7bRHKABjDLCUUITKEG8zwA0GzqPEvKS1JECUmYa5UoxRWqBHBMCaEro6AnQbJAJRsoTJ2/AiA13omzpfgjnRxOOSj/MzCREMMDObvylectQh89NwK2dgu8xcgvYUTCDsVHJMqgEGkyuR9+DVTDqEqv+BjBVBzkwRPGqtRNQrOfkWiLopnVePw3fNYOA2dJF3G4v31dtuTM9B67lITAAl/V3rfktM647XbdOYLjNIMrFbZ3gsQ9akWSsq9Sk1Y0wY93SeAhKkA0AK8DaLuAGRBOrbyV7WiZ2YXVZYSk1geDuPlo5d3wW10iaHwvYjQycKB3u7SOtY4SJ9hL3WPzPV0gkD8D83nCQThGcc3BZN8aKqBsqLZEBmNdIBYRbmzWghopxseoynfZUd5VhDoNajKTTdVC1c0NOy7Vj4CmrDmA3Nub3iV4MVGXZKq+owMRB3NzMY4Sb9PTCTG9gdpTBYnZJQaNryPUh1/zWMA1XSOjatCqVXhkFO9b8esx3e+pGdl62/qu273py44QttU55Fkxy1wVr6J8GMoCGQJkp3o91DkgJRgERe0MbayItY99X7Zmq4gScuauS8TdLPm23CvfVt8WsGEHCJZgFQww475aCmVtAlmViYbMl6xWh5uU6Lk9+8TPJJTMVqDss3AVxu0yFZ7x/jlg8Vz9/uK0/fGymIjAHw4EAAAAASUVORK5CYII=","edit":false,"name":"Layer 1","opacity":"1","active":false,"unqid":"oo532f","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAArJJREFUWEe1mFt2wjAMRDHsf8khPVItdTwaOaGn5QuSWL4ePcN4/PJznue5WzrGGJ+a/nhBbGAw3X7G+e8wAsAOwwot1z4Bu6VMA2EiGciA+/E97AYoX5cevIQhEKWEGfbrU4XcCH9HiO3ct4VBEJA7N4XNCiTGd8TWFVALI6R/HMfxeL1eRWKliMsFCRXP7IAkDMdIGDIY+yAQGF9glWpXQAVGuMaCIU+pygu6QX2PmPKIn7aUQguMAkED4B9cl6lN7sIsi6XLNQZiZTxVsXaQay6zCWPljopYh+QJ4xg3QZaA5mAOZSmg81CoDsO4jGH9/X6X7AnA5/OZEFA7cvmmNQXIAmQ2tsrgkQ3CAOYa1SSz6mKGiVLb1qRSto/jOOemWVkDREidfXN+KUAZuT/nLtU64efDeNKl10SZ34Dg4c9ZGEuzjPWdah5rBHPZY6gxIoivBZhopLJiLwvH+K4/QpmlyEGs+OFU48S+1WWg6lWLpJ0yaJBkVYXMIS3Wok1wD0NYTHWuSUoZN2wPmnGEEf5O19jzEfgIw4eBBMkyYkkt3WQXub5wb1LpjQAM0/Qr9xL2KldmN8+CXzNDKEh9fRyAO7tqshPuXtHjngK1sQBhrBj4FYxSNWKqVOAu2BQQ5azHwA0XZx2MhlxgcLLjiZ8Dl9I9U55AVM3CwdyTpGuUS+xw9+Xf2CLMqAKJzfBeY9c9VIarkvuzp4CRbqYplTYusOvx+tyvwkRmIRAZjAO0L26mAicA1quwje7BIConiqEEg5ZH0jQAU4ga2EH9ZTxFRbYwSqE4iZ08qjOPFhwPVKPQrHwX5xl4UQkV2myUryiboM/MUopcKgOx4vLyGCnglmapwHYgJZu6dMC5WL0liiBPUzQ6bD2xvclw/AfR7v8ZXHv3v5qPYNpC8kc3vgArjLsiNA/itgAAAABJRU5ErkJggg==","edit":false,"name":"Layer 2","opacity":"1","active":false,"unqid":"oo532f","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAqNJREFUWEell9uSgzAMQ6H9/0+m3bEbZ2RFduiWl90Bkhxk+dLz+Of1fr/f3dLzPM9vt/5qAQNU5zHnXbBbMAjBAHZw3AsIfAfBdlBbmADpVLBnCgTDBM/LM1sYBAEFbI0/Cgj468+O4+C/zrUDKmEKReIQ3rxTplqznC1hWBE7GcI019h7qM51Xcfz+XSw4Y9pN1Zx7JnOX2Cq0MTBKl0xhCLjpjKF2SdDgilAlpAEEPkmhUNAn/BB03eokAoTFzNeKOG6bLLwPR6PCDWeGYng95b4h+uHR6TE9M4UoSvKtt/wVGnoREnptxzCxYxM3bYH2ywMzh8ThmeYFJKgicxAr0CGbb0yak+CQaAEw8aqwiCU84+5rkuqYmk+LgdGZWR1Hje9au7SF5RyYRACDnYF4sL7r9fLaxDeS5kJMH4AAkUWEAQaPymCdSRUNAAGtcyyy55FlvlagkH1qv9xzfQch2oA+McxEGycsxVhoIx/OuHaBrAJhkKzVhgQtIMpqCp2DKiUKRthiu1niOtUdT9FeFT45FyEBo4U5B6CqU2jhFtDjAwJlPdDVVJLGUbz7gubzrBiBw5TwrsBw/6ayth6dTjuNVsJ7DK/sFOGaoUqBylEXFsYDqDSBL8ULmpwzi36iwOhNEWbmKFTgGYF1ShTVeUqGl8iMs0z8E6/quYaHiH8C9n9XBewGBaDeqofZcEag3yIsgxX/LMjNuoq6eLeIXgx4yygEqbLrOg3qq8opbphi0I9BVGTXoo9hoyA2lbSFbrqJ4uEIYWShyo/sXKiPHg0KxAs6dJjaqTAiomLzFNx8c+VuN+BbGGUhwJGzbM8gmD13oHcguGQFX2Iu3lS+g7IbRhqGVXZqEIdvy6360oDb1d+uvXPALjBLzA3eL975Q81aKYi/zu6FwAAAABJRU5ErkJggg==","edit":false,"name":"Layer 3","opacity":"1","active":false,"unqid":"oo532f","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAp5JREFUWEe9l8uWgzAMQ0v7/59M6bEbe2RFDtDFdDPTB/hGVuSwPX58HcdxrC7dtm27e+vLF3DxrhYz3oE6hUEIBrDC+Jl6H+pcgVrCBEhXcN/3x+v1sntkyxjIYEKtM6AWhkC8YKfEgJIWiWuuAEkYAeIL5Gpc6P1+m1IPg7PX8/n0v6HsGdAEo1pj9xsgCRQFrXi80LwIMNrj166ACgyC8I2jOBgyVz5gWTnZ2hVQwjSKuMr23Y+xUXyGnlMKFZjVrrH+w/e5g0yx8IaRh2+wdd19B1wy+D9ClVAji8KqJhD2BAKBAux/bKNzJIxaNcuKKwxFEISqlYXgrhKtb2HSo+gVBFM7KQJw3/cDdtgEhBsA4NfKsLwdDCnk9++AusGZtSI/uhinvIhiHm6jcP6PK+1UjWtoQ3j+ZJjhVrMbDROmybDnEf92jf3OXgNO+gRVhhbPMw2TVSWoyhmcRWpYRrCFuRuY2ECZzFPMr6I9kpYMjKHIUZDK8naXxxH0DBpskbi+ADBpkZtVgfd5e5VZxTMIgrI2obURjNooPBizLZC89Rw0yHP2dNRCNW4xDt0CAi3ittW2MgwFkTzDwM5qPRfG51nVZM3pOJi8wOYevirzzX5D2z3r81CFUVJhMEfwfNINOhWSi1UfaoRQFzL0fHLbStWZQ+0yguxU9M8bkLimHiHCN6hO6/hvb/6Cqj6rTSbmrS1OAjMMA1EbJMAdFZXq/OiCK/Fu8DmYzzk8vW0mKV9ha9hffMILG0wwJ0CycGdmHKg4p7qHOQnTeShXMD/TZ5hRO8phvlNkqQzkiRtVnWnImMvdBL9tFx+zoomH78djy2OxDDkhvcFPqXymyCVlkFI8Oyk1ymdXIW7DnIDl13cBSqAue/TPX34AQUDBIiqR4IkAAAAASUVORK5CYII=","edit":false,"name":"Layer 4","opacity":"1","active":true,"unqid":"oo532f","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":1,"unqid":"vr50fd","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjVJREFUWEfNWEFywkAMa+D/T4Z0nEEdRZHshR5aTiQhu7JsyV62fd/3r3/y2T4Fs22bDeE3sb0FRgHUxnzPXb9D+hKYtOHj8fi63W4toAKzytYIpoAg4sREgbrf7zFtWGNiqQXDi7gaYZC10fP5PEAVuPoUa/XBuxNDEYymhhet79iQGeHNFMAKIAtGaa1rbA6q6x4i1/ShTjjFnKLE0AWMU4yyMuU+gWHQDtAJzKpqeFEoCgBRN7ju5K+ALJiUe6WdgXBNMCCslTzqtBccmBebvqOAVS1aF1MRX54rGKZXZYmXnZLAkrKSVGTVmphRerVOCig8BQy5unFKUwH87FVgOgm6lLHjOvftAuEUXwTDYBhx0Y2+o4sDQN2v34ElJ111cXbnCEYbWio+RAbndc2S10pg6n0Ff0g79R12WzYyLmBmrWMmFfbJj1KaHECOGIunVpCU2LqzY0aj1XaAWgHVrj24NGuXtzXjouj6iNbBVG/KIoLhwezYrzO9rpYcINeZtVc5Fk8+MzETTeo1Bepzljs/06aKfS9gUsFNjc5F6nqUayGX1sNHFXViO3O8jihJ0qtAtJgPMvTc1JndZPNu9GApu+8Mvh07p1GiU9xUh5b1dKJ0KXPDFXsNq09d2o0MWm9LRxU7e9DxNo0J3FBVOdYop7O2G466EZLZczXWqW88Ub7bY5ya1KEToCUwCuikADK+5MquWD9Kk27MRpXSpWY2GSOeLzNzqfy//n9mNcJPf/cNbqwfxYQm5T8AAAAASUVORK5CYII=","width":"35","height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjVJREFUWEfNWEFywkAMa+D/T4Z0nEEdRZHshR5aTiQhu7JsyV62fd/3r3/y2T4Fs22bDeE3sb0FRgHUxnzPXb9D+hKYtOHj8fi63W4toAKzytYIpoAg4sREgbrf7zFtWGNiqQXDi7gaYZC10fP5PEAVuPoUa/XBuxNDEYymhhet79iQGeHNFMAKIAtGaa1rbA6q6x4i1/ShTjjFnKLE0AWMU4yyMuU+gWHQDtAJzKpqeFEoCgBRN7ju5K+ALJiUe6WdgXBNMCCslTzqtBccmBebvqOAVS1aF1MRX54rGKZXZYmXnZLAkrKSVGTVmphRerVOCig8BQy5unFKUwH87FVgOgm6lLHjOvftAuEUXwTDYBhx0Y2+o4sDQN2v34ElJ111cXbnCEYbWio+RAbndc2S10pg6n0Ff0g79R12WzYyLmBmrWMmFfbJj1KaHECOGIunVpCU2LqzY0aj1XaAWgHVrj24NGuXtzXjouj6iNbBVG/KIoLhwezYrzO9rpYcINeZtVc5Fk8+MzETTeo1Bepzljs/06aKfS9gUsFNjc5F6nqUayGX1sNHFXViO3O8jihJ0qtAtJgPMvTc1JndZPNu9GApu+8Mvh07p1GiU9xUh5b1dKJ0KXPDFXsNq09d2o0MWm9LRxU7e9DxNo0J3FBVOdYop7O2G466EZLZczXWqW88Ub7bY5ya1KEToCUwCuikADK+5MquWD9Kk27MRpXSpWY2GSOeLzNzqfy//n9mNcJPf/cNbqwfxYQm5T8AAAAASUVORK5CYII=","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d12.pixil b/applications/plugins/dice2/sources/d12.pixil deleted file mode 100644 index 70e25c5ae..000000000 --- a/applications/plugins/dice2/sources/d12.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAFpJREFUWEftlDEKAEAIw67/f3TvBQ4tCA5xVzSGyrbfkVK7jCRNN9Qz28YNmDUZltkgMM3kTZBJfcMZnMGZlADOpMTIGZzBmZQAzqTEyBmcwZmUAM6kxE7lzAeBa4+YB9sR7AAAAABJRU5ErkJggg==","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"4anbk4","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjZJREFUWEfNmEuSwzAIRMf3P7SnrBFU0zQIezXZJLEt8fi1SK6ff/S6vrLc931Xa6/r+rTveJEyrmwqxincCMZATsa7+xOgIwyDoOfbwJOuZ5/1jhE0OFtzAmphKpBtxAC4dNZ1AFj3J0AlzABk2cCoGIRF7C2QhKlqhDa3tdhVfo1BLHxdhBKMiggWZtPRqdNFzbQpCzAVyAPwUTrcOBTviqSKkMOI1KTOeBMVC9PjBDgTUstAAQa8907B3NPiUoGxxQEm1BOm0KKmYLBlQ/tyAReqXLY2SoJFa78vjgRDD3mIJyCQmgTEdfcGxhV1GwgiRirsXaTUmerFdektzJJRyu2K5uSsQuFTe6CTZc0g8bK8u8E+CxiMIkZQpgq7zFq8hVELGpggdtxxlRLbMdIWMAmSixPApFRhXRxOedScJIiVzkhvGYj1vwMpUm5wfWsLQ35JzSkTENxz1E18umI0VEtjzvdIEVJL0UyH6VH0uIDZI3E/HR/FHmnsGBWwGhs4PcJrOXaC0tt5FuBla2ORKcOHlJ1AUhmWOrNvuOJyi3ff2Qqd/mspPKOmwdhNBqO859O2ilDR+pwamaK1VmkF10t1tuDZldrk70I4KuB7P+lBSy9PKqD9nJ87NMmhEYQJn6uhfPzrQE15PPuAQyFQRWcm2xJG1Q8WMGtIBYVEYtZJmS1hEIjTpoyIUWM9NoFw54rCC5fV72c0NPhDoHX6FQwX9yRS+5kRxCcYBaUie/q3ocrGL7FUikLdy+7AAAAAAElFTkSuQmCC","edit":false,"name":"Layer 1","opacity":"1","active":false,"unqid":"a2sj1t","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAi9JREFUWEfVV9FuAzEI6/3/R98UFpBxDEmr09Ttpes1CY4xhrteX/R3fRGW1/8Dc9/37Qxe10f4jzZtFzkQBDGwje/+OYAC3sj89bvJL7KNtV0Ah6WADG4gmM/8TARxBKgEMxipUuIs+O/IirOBrA2cJwx1zIROOLinhcHCOg9un2K/jFuBWYCwgFkvBOxyZhGI2JPiL2AwPUR1aEbppao2SmGytXl+YEhgGiCSblVBGK3THOpt6iybXkftRrTLjdnZC7HbMmeI02RaAfriO5RuVeJ4Vtrne1k/+Hyw04GxtRNclHmhARMspSgqChkHL7ItYJ4JTKogwBkecQoExBxaw6D+O4HMYCp794OK8o4yhiDYEqJtcPrZDFOelblx32Ehiv6z6Ez0ssS2p64VnRLevHJpCcwONlT2rcEM2InWDJelsHnDOQ/ivvM8M5XLYloKkEvpc9VQ04yOHnSL8mvnFWViwuhkNTmjmKLwEThk26mV3W8Gq9Q0lc+4n73Vm7iy0JX9QLwY+1LlwBLMPIhbApKx2DwBirXMVtebSjBKO1TOEhDrpQIJvS88dPmHDsM+o0bGElA1/bF7K7+Skx6pfATGMdIup8wNLhSNE6yA28YS+2QGVqaGzxad8AgqqvWtGdimaOrcQQY2uGLGTQP5E28HO0AGrhiyu3FEad2edWnyYO37k5h70qBVsCsBbcHM29tNP3zPxjG2ZOWImXb3wz8eMfNwzM8181dARpwfC5kXQnaygo4AAAAASUVORK5CYII=","edit":false,"name":"Layer 2","opacity":"1","active":false,"unqid":"a2sj1t","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjxJREFUWEfNV0GSwzAIa/7/aO/YaxghC3A7PXRP3YSAIiRwntcP/T0/hOX1MZgxxnie9PGP8r79UAZijLFIRoBw7arOVdAswiCwuAKC7Z/3n4JGi23BVO3YRSZQZ8SAeYHYyrJeejNjQhVRoGbHZg7VuowlCYaAzJh/QbyW4K1GYGN2ARjCZwJzkOcw8gEmAWLJQxHORtpYoE0q+Htr8NBRANMAMWZWLkuIgLAwtCdlc8c4hgyMXbf2tEBYS+ywzPqoH24TakMN54ORncx1hILNnEWC18ywUElsKRBDjcWTlq1Q0k8L5mhLpRFzGceoOScAX4EJbSqG2UqG4q8Y4rmzX8TnBhYNdlT0K01M3fCAU4CokNm+ZkbtncItanAqfSlDoByOI4RbGRXfAHE2aUtLQMLiJTPHlKUEcudwS9ny7C4ailozyhENmLAqmJ3sqEF7LAXj0zfZLW8zQ/uJ3Ze3SWxe3y07qYNhm7KDmNHdyqmllcPyuSZJ4oe1WcgKENtE6YXPPFdtYma4VSi8sJBsd/yjPc48sFrC2agcerQ7Qn+VdZPhEXSV2PlYyt15xib9mpa8ErIphtf5OWshMOXh2Rk4oG6+kVpMrBcFJIxikTFMUDW0OhT8DQX/SxLSrwOwodcsrMruzARcEtCBWZrBqYzWhjmxZseODUOTZlFZ7wZMCghOhkGzxefMV8AcgPYbh72EH27IyBZw++JtAE9oFu3lIeqqzlVQ4Rr8lFlh4nh6XeM6sLPxN+7/AbQmAUIHBi45AAAAAElFTkSuQmCC","edit":false,"name":"Layer 3","opacity":"1","active":false,"unqid":"a2sj1t","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjJJREFUWEftV9FuxDAIu/z/R2dqLlDjGJKe9nCTtpdNbQaOMYa21xf9tC/C8vqbYHrvvbXPsPfeRwHaJsCT6COiBYbg1/Mrjr/Pcl7/WwE6BZMlasjYTIYyxPgYQ+Y9AfPm+L69sTB+GwAohYHBc/asBLQDg0BCQCxZUpYAmi5klwvNXIHhWwxtDCpuMRpY1xIBs/ioK2Q05M/ALEmce+ooFLQ4g2Cw1FhKZ0eBOeqKnVkCQwxosHi95+5iMKp9R15mQOmkOBPykGf5uwUMdoX6e+pFCXC5CJwNJUILQHYkmHnrpXWnYQUhB1OZeqpYFBbgF8vAmJm5qcFtvKOUbqx8GSDBimtncUi0dmtlEBuPg0AMtL13iz2jkikrCH3qbooGRcqXQWwuAXifVeRNVRNKMBiI2zAzt6VNZ9YgamNY6Wz4KLz4NWawJDTlAzMk5ghGzQ/zBB6ISgNXt/EUR1dWwLAxnBlKmj0fGFCURHnYa5LxkK4jZVJeESqfgXey48j6lSTuHRiZsRJsHJhdeDtKcF6pkbAww3MoMzHWzO7/lFfxsEwHmFghXR5qbajGAo4XA42XtL14WSHUV8BJewqxSk/KhqSavCOmWrJZPyjY5LYWK3hLsgmOM0c7MJvTtH9cQRczw6TVpA7lrYYFWnrybRQ8h8X+9Ptpx4xh5c8VZNU9ULEhui7NeQpmyMLGhXJg6g4fsH6bg0/cJ2AQ0EF130eoE8t8T8Ecg/jk4D+YjLUfNgMXQvU7QCMAAAAASUVORK5CYII=","edit":false,"name":"Layer 4","opacity":"1","active":true,"unqid":"a2sj1t","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":4,"unqid":"d602vs","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAadJREFUWEftV9ESwjAIs///0fPmyY5lSWC9TX3QF7XtSggQ2FiWZXn8yGfMghljDOXD9J2zD95B5ilmDBkWWzcT2mACCF68rq9reV+BrkC1wChDcXm1v9KmnMmUlmDQULDAvtFosBYGK0AWDHs4hwCZyV4i2HUPw4mJJsEgEPQysxCG3JpisgwT8x6pjv8sKZkjyEx2YLsbdeaKqmAJiw5SpjMYlyOspDHm6kyHvZcDCCYnJfsdXncNM6ZVIlMwWchy4ikgVelWFbg5rZjZZXlS2VJF3/3TMce0axcmRWdmQ4kYVoZrHViFO7vBjOoxXaXtAHKN9mUHwTDhwhzCM0wzVHnb8H2TGazWHTOqfzBmlPQzRlgV0gb8iWqqtGYjgYG5UmeUqjPhm1bgM9XDhjCa4LO9qaooNYJkrTro1h1d2wFRRXJolJ2ZBYXLdXM2CbpprzXpKWrZjOI8d3IgmVFduKM3CCYnupsgSzCY8arbOvC5+2OTxL3yVcUBQmVVnleMbM5037XVWMBYwQlANdIpZlSVsRDgWjWM5fOtMHWMXnHmD0ax+AT6o7S2HI0/tgAAAABJRU5ErkJggg==","width":"35","height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAbFJREFUWEftV1sSgzAITC7T+5+nl7GjLRlcdwEz9vFRf2wTDcsCC/ZlWZb2I1efBdN77621W2vtjvfpM2dffAeZp5h5knH+qmZCGYwBwYPX9XXN7yvQGagSGGXIDs/2Vy6VM57nFAwaMhbYHY0aa2YwAxSCYS/7ECAz3ksEu+5hODH7JBgEgl56FsxQtKaYTMPEvEeq7T9LSuYIMuMdGGejzlxRFSxh0UHKtAcT5QgraYy5eqbC3uYAgvFJyX6b11XDjGmVyBSMFzKfeApIVrpZBQ6nFTO7LHcqm6roq2VEzDHt2oVJ0enZUCKGlRG1DqzCnV1jRvWYqtJWAEWNdrODYJhwYQ7hM0wzVHmH4fsmM1itO2ZU/2DMKOlnjLAqpA34E9WUac0ggYG5UmeUqjPhm1bgM9XDhjCa4LO9KasoNYJ4rTro1ju6dgREFcmhUVZmFhSuqJuzSTCa9kqTnqKWzSiR55EcSGZUF67oDYLxiR5NkCkYzHjVbSPwvvtjk8S99FMlAoTKqjzPGBnOVL+11VjAWMEJQDXSKWZUlbEQ4Fo2jPnnS2GqGL3imT8YxeIDSbO3tqGpQPgAAAAASUVORK5CYII=","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d20.pixil b/applications/plugins/dice2/sources/d20.pixil deleted file mode 100644 index 4e2baeb61..000000000 --- a/applications/plugins/dice2/sources/d20.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAExJREFUWEft1LERACAMAzGy/9DOBCncUYgJuI/OkyTvkzc+c1xCmYuoMsq088UMM8y0BZhpi9kZZphpCzDTFrMzzDDTFmCmLWZnrmIL7qWLmCXUhAcAAAAASUVORK5CYII=","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"epa8u","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAjNJREFUWEfNWNFy5CAMK///0WlhYo8QkoHcy+1LO9mAZVmyYdvPf/Rp/4LleZ6H17fWPu/5aSGCwNiI7QuoKzAOBLPzFdQRmB2ICM4VugVVgtmB6IywbJRkTkFJMDtNRMAe5P2/75PLnIZ3oCYwOxCdCQFkkowo2QCKLzlQCSaAKHf0Z8BClgZZ6TiRHQUc98ASh/MmMJh1ZKKAwLMpa8p4SYD3CkAlGBamKo3od1O5qjXMvgXDVEYEztp1blVOLBnuRwyPOo9P10x8qRar4Ce2rtYdgwlAkSm4pKmZVM04Z4ojzaA9mXY3i1DwXFqhkcT+7j8qJMuEqlfAkCXqIcmac+GVZoC60NL4y+5wQu+vov6UDgXbNTPORagh1fSw+VECS0/aChiZqUpUOG4plTLD21uGF8o+w4tflib6UbA0MLNNqJIbLfkyUdZyZKD40dY440jo2NJSh1tmXK2N5XHyB+0p/ihHsBvuI+3trS0YymCQkX0G61O8bIAjZjBYOERphw5SHBQdlEcM7mPbQYmIidpFyNxLWNDQGKOkis21A4tWPjagw5d1FjsohK4Ob0ezSTU87is8QLEdkFZCzONUwB+rmaKRTaMBN6z6RoyFBcH7gK0vD+TudE/9hHsFn40dhikxvHkuvN3cEMpo5ks6MU7x7SWuElzEOWHQsCnjfr5Rnp6JwzGQgI1ZggFX5SWM2cARoZxyAiLfuan7yd37hgmOfcSMyHj5kWjZ+FZQfxv8AsTOxkLIDDsGAAAAAElFTkSuQmCC","edit":false,"name":"Layer 1","opacity":"1","active":false,"unqid":"c2f8it","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAiFJREFUWEfVV0FuwzAMa/7/6Aw2LIGmSMUbcuh6aZHFNk2RlHZ9vuhzfRGWz/8Bc9/3PZi7rncwr+3GfnJDe4oCEptxacfe42/8He/h2eu934N5YgTBPQFBsIvtAkgiPGHFAWWA42AozyTLsVPAdECi1vgOH6TcqRhU7EgwfGu6yRT10PX6DmwFR+zDenLsbGCcewDMADLWIKD5W5UH0TmBo7MKGL6NqjkAmutdaVHUJ9pJMLxhc5MUobMuPlfijezi3NnAICu4ADQkmTAlmuVs9FKcZcGIcl0PTsPNMwSVbvhZOAs1swkx6o0LBXMJkN8LRljcwbgAufWIBKPKRQIMR00wFAUbQBBxuhCBos03ZlyANZqYe0HuSJvD4RbQ7MdAV4otnnFjJB2lmFVIsqMce2iOopkSoz7QMoH/ygzpp2qmU38kMeiEAc39VWbhwa5xtsw0EY8HyhTnkYEZVzOOzBlaWNyhNIVR4NpAl9ijRx2BAceU2YQsn/dg+4KFt7viRGB7E95+gY6OnY2RA0y5T7UDZjZIsV2bS4UREO7BQYY1EEBFdnHWJIajeQYHKbJxNkOlBy6NahF2nlmLOd5ZJ3K4UpY+iQl8R46drAW4IQORgxXb+GTKm2eaxHX/vMkxQh1+EnIlexQYVy53KIrVdXznoLZMsKiww9aF2+coYUTK+SMrIh92gByTJ8955j0u08nmb7/TMvP2YU/7fRWYH/oqWEIZZe9qAAAAAElFTkSuQmCC","edit":false,"name":"Layer 2","opacity":"1","active":false,"unqid":"c2f8it","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAhpJREFUWEfNV9uuwyAMW///ozuBSGSMDeE8HG0v2yraGF8S+nx+6PP8EJbPFZj3fd8A/zz+Vlj2eXYLiYkSmBOIKM51b0FtwZxA4Mao8LTnKigLJoBcsNwBVEA56RYwN2zszO9A7ViawNywgT5pvxuDzjsKNKxNDAuYU0qC4gY81jIYLF59XruHZcroxgNHIVyXSiIb/WGDHQSAssQal+gtGEFlBxtMKMMCeATd6xgbaJli/dhZLAq28r/yiPDQg1KGCnENNnQGQ4sTkCiQ0iLI4S3cSPudAP8KJrw1ecU92Ow85RXeOjMzTNYWSlbUzlBmEfNJtjIz4PpEjeZTPYISgkafkoimJ2/qaJP22eapr1hDkxTJrmmOXiblBU7KKIYSJjE8BlzyoBeVPdPrqm47otoTMnzVv5nV3Yy6kon13UR3YoY7MZsZmyZOgaUD08Kl29JAZKk6ixxfN1RLzHDLFwlYzi5BDc8lN0xLnrkpvDvPtA68Y0m1DymTma6ydmEqL/eRh67SJI+S7C2u6FJER5MYNf2yPULsEsBsMBD2iTpqwD3bpjd1XD67qAMVPlgMykykYat27HRjgZKzND30nBkBuGEPRkV0XJtmjDM5M+kiD9etTIH4+BorEpGjoNIe1LsTG3jy4ukdqhpr8oqtuQUDMbRMiUNUbqgKIiXbdVHRO47yiRiXNqz6TAmbk++WiaU/lar/06IvOzpSQih7Kx4AAAAASUVORK5CYII=","edit":false,"name":"Layer 3","opacity":"1","active":false,"unqid":"c2f8it","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAidJREFUWEfVV9GOwzAMWv//o3uKVWeYgNNKfdjt5XTr4hDAOD0+P/Q5fgjL5/+AOc/zHMwdxzuYr3KjnizY7jLA4DooFuqO/8fz6++olfiL+qbGsrcF41jpACWCHZMAvoJ2BkZWFICdfCRJyJ0fJ5dkBlkhKWzziQ0SwMFyp8TXgSYGC4Z1VtSb04d3LtTFR1yD5VrAsFeSGTSsohxkSzAMKkp0ckkwcIJZEH3DHkLagXpkZ9qFdUZ2Cpiug6CFo5Xxo1qX/DAWbL2zgDG6ls1ROjKj6piCm6UC+b9JqFhxDGCHpVfwtxumKq3f8KxgXBGWRCQvMpIjBA1cpHXTYMr0JOSaQMt6QfSYQWqkbMGklqJTZlakiZMG1XXDqNfzYMjJJ9KzTM+y+JqsU1/2CeRKMW1OZMW0OMQctnE5AITLxpyibzNDKvQGRhnypET7YlJgNPyCDLqJn4eWBp5xacJNSQYSWBAok/JmAdP4QIYezy1ez13n5lx2nk1gtRC+W2aWkWPpLPRd2sCC4UTFBQ/TNtjkAYszjp6vF+Nd+HExLggZIyc+zKIJNuOgvc9Q7C85ZQJtuVzdmdjBukjCuOKTnhhOyxWCwqz4JPdwV098bbl1B1bJyYcwl6+o390ItmCygDIvekRFwS6jjMdi2a33JpUn2FnNmFAuwJe+8tyCYXYUI2xwvowpeSkIn4HppJDHbr7sgLQyPd3ojd+3Mr2xwZMaPwXmDyLsWEINgQlHAAAAAElFTkSuQmCC","edit":false,"name":"Layer 4","opacity":"1","active":true,"unqid":"c2f8it","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":"0","unqid":"unboeg","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAbJJREFUWEftV8tyg0AM6/7/R9OhE2eMVg9TesihuSRhwCvLsmzWcRzH14d81j8YUYkRM2utPylkUkQE04FUsLp2/j9/9+vsQBaDZXcLzBkgATrvSUwqhiyYzkA/BAGxLPuBCO7XYHopXMZ4gEqkgNNyqtbGOjMgLPsCXyVFTXUWtwQSGBZcBayD+zfTmWKHaga7BQMyzaQyKWFf2GXMMMFh1p2d1LrTUm3MKCBYGuc/qjS95KzUFoyj3pmdY8o1wgVMorvqjs6rZoWKpwBRMMxlmemhKNVYmNrEG4xzWyXe1HVdO2lM/LBd3YRgWNZdJyz4pL1d3A1Md050UQUGjXFSUuZdVsCsdCp7ZYxuwG7u3k0vTVfUSFyWXksZS4CuIujAd0zPlYeJV825NzAFRk1fNQSVTvA6Gw0STDc2VW+1OKmVgpkl7V43KGldXztvsvzUYWMwLhO3yzhbGPnSdLlimeJMcnp4BAa1M7Fz9kwHnAbxo7cDB3Bijhuz6V07tTJbJ9iKoLR2YW4Cph7A1u1AcG7dKU/dG98ok1aQavc/jo/EzJ3Dnt47YubpIdPnPwrMN5+zjLYb9TyVAAAAAElFTkSuQmCC","width":"35","height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAbJJREFUWEftV8tyg0AM6/7/R9OhE2eMVg9TesihuSRhwCvLsmzWcRzH14d81j8YUYkRM2utPylkUkQE04FUsLp2/j9/9+vsQBaDZXcLzBkgATrvSUwqhiyYzkA/BAGxLPuBCO7XYHopXMZ4gEqkgNNyqtbGOjMgLPsCXyVFTXUWtwQSGBZcBayD+zfTmWKHaga7BQMyzaQyKWFf2GXMMMFh1p2d1LrTUm3MKCBYGuc/qjS95KzUFoyj3pmdY8o1wgVMorvqjs6rZoWKpwBRMMxlmemhKNVYmNrEG4xzWyXe1HVdO2lM/LBd3YRgWNZdJyz4pL1d3A1Md050UQUGjXFSUuZdVsCsdCp7ZYxuwG7u3k0vTVfUSFyWXksZS4CuIujAd0zPlYeJV825NzAFRk1fNQSVTvA6Gw0STDc2VW+1OKmVgpkl7V43KGldXztvsvzUYWMwLhO3yzhbGPnSdLlimeJMcnp4BAa1M7Fz9kwHnAbxo7cDB3Bijhuz6V07tTJbJ9iKoLR2YW4Cph7A1u1AcG7dKU/dG98ok1aQavc/jo/EzJ3Dnt47YubpIdPnPwrMN5+zjLYb9TyVAAAAAElFTkSuQmCC","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d6.pixil b/applications/plugins/dice2/sources/d6.pixil deleted file mode 100644 index 4d9d44d7b..000000000 --- a/applications/plugins/dice2/sources/d6.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAExJREFUWEft1LERACAMAzGy/9DOBCncUYgJuI/OkyTvkzc+c1xCmYuoMsq088UMM8y0BZhpi9kZZphpCzDTFrMzzDDTFmCmLWZnrmIL7qWLmCXUhAcAAAAASUVORK5CYII=","edit":false,"name":"Background","opacity":1,"active":true,"unqid":"ynvcrq","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAgxJREFUWEfNmNGOQyEIROv/f/RtrhEyjoOgfek+bVLF4wAjbfv80V/7heV5nkftb61dxb3ahBB8LvKdQh3BRBAGgGA3UCWYDIJTdQu1hckgVGmQIs5ZUUrCHEJgDC/oG6gFxkA2UvfbBo3UP8v24n4s8gmGQbLbjUBTe7974ID+GYMbLBR+51hgeCHdtAHwu1f6jMV91yqV8BIIz2lack63VzAIZf/juiWtDGhKKhgPrtJE0kpl2HeiOC9UpowB7jqj3xxU8z0VECiPnvWtMllrn75nu7pJYawws27iNubO2bX4gCilaWlXUyM6ANWq+ky1Zl6YSu1MnULPg3TmEddqpaxMD6bqJ0ofqLNchDztHAYNTpld1DnWZeTGmMk7GLZ8OMCt3nKPBc3rBolZgqWnniayc3ZazyIUYlRDk5Hi+mpr+y1I325SBkot6jD8WFoMXv8TDD+Cu+ADQL3qx2nyDZZveKVDZdQIYe1spniUJkyBcFlveRF0KkhWBou67MBYuDwAWdXi3BPdlHtZzDFpN/lkBo7q8wk/C6pmhpqVWSmGUYqwd6gZd9PakxNv5ho9dqrD1CMZtaoo9mkG3owT8wwcvUU8GginValNITid4Ze4kwELnwMs2kTl5ez0620FSsHcfMVNYaA23EnFdM+CTG9U0F3LnjJMBgWRJxs4+VnkGEZBKVlOIGz/F/AshkJzdMK+AAAAAElFTkSuQmCC","edit":false,"name":"Layer 1","opacity":1,"active":false,"unqid":"eiymk","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAi5JREFUWEfdWMF2wzAIS/7/o9NnD5iQBU7THva2YxZjIYQgPY8/9Hd+guW6rkudP8/zUdxHhz5JoDvbgvHMHyYq73UyFXslGAVkBPIgVYnazK16GAffb8EAI+M918c5gLzLFjByVOxIMMgKatQBYODjOCKGYsuYnIkYI5MMxU4Jhi92OvE5MeevpA6DSwPrOKfYWcAoVvDwuJGCzUeGRLa6YCTYsXjzvARTlAOzQaqDNNNV0hc8s+r84FXsJDAVK6h4FiJoAkFwU+E98xoq98oMdgkf8GxYiMauX+CAsGzMfqmdpRMqPTSsxcWdoXmNVAO4yBOYXadw64puwqwrCUz2VLkXMIU5hQZ4NhYJhNiTw8L8VF6VhFUYE3dLmFenq24sKCOdDQaHEnXjn4Xtx3PKTrKxm/BY6q+C2V28+X9mhsrEzISPeHlUmZ4AMnZ+wXhJCkNCm58gcVZxue4AEmdWMMiO8g0GokywsYClK93XhpOXptdM7WCmGZiJHF7UlPATmJ1DclmEv6Quo5kVLscJIPt3B6Wy/DTFUWtCMwub20HZseMXqN1EuGmsqL5CYIPcWiFw4RB6WJjAoLheMjO87Yl9SS9Xih27NPlOMQqWnaaadTQSejBMZeMrM1D36dKtDVa+GkzDzsREYpVLvYEPcywYcrb3YJwd0sBb301qQoOGUuguq+QNdqp9fzMG4tvJNcjvb4N/83t7t5ZuwdwZet9653+A2f0K8eQHoxeuA2tCWhaNlwAAAABJRU5ErkJggg==","edit":false,"name":"Layer 2","opacity":1,"active":false,"unqid":"eiymk","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAh9JREFUWEfNmEuSwyAQQ8f3P7SnIIgSQg0NmcVkk8SB9EP9tZ+ff/R6vmF53/d1+5/nufrfo01svBmcYJjvFCoFIxBWzALBgtxALWEiCPVOgRDjHfgEysJkIWBRYfg6PmegBpgMhHMFYPCbUy4DNcEs/M6xUvbV4EWsaMwExif3cZCrm7oBI3VdC/VYBVUGkOXdqaXXADTBQGIpFdadDMHKGDcNSirkEoZAnqKEqxftunVTA+sHCNSsgLzWKtNgAKKxUr9HMALSiyIrTmtyMBKQXeYSBkkYgEzB3k6XVybIjkF6FzORMpR5gPsbGLjIpTZgeA2nOfW0a5hdNvRAhhtRh9p3rknXynCs1IxUVZCmGmNGGc7MApdXhk7IVbOkeYdyRU3LQltTQfC5qXYNw3MLgng3y6AE9MNQvbpSxkHUuNXec9DTsP9IGXeyqdFxRWS3cX/S61d1xjTLcIhaGQ8Gr70yyJjVKVWN1ffNKLpuB1on3Kmks3NAD+kbjaJsI9sorUuCEWNopq5LG5en3BQGLoEMVZQDUtw8NFiFlH716cD06p12t5HTW/7DFbidyp9KOpB8BqlJGQnmYYRYgNgyEIyhHiZbK4I72wqwmnu5BJSKzJOkuqkP3FkoUfekMk+2pwvQ9vQeivYN6phiGNoMfziBGvKaHkBk7iKHvdlqulPq25v+KZsyYKsnEqdKqL2tmyLA6EER1p8+myn7fgE8c4RCu8Kc0wAAAABJRU5ErkJggg==","edit":false,"name":"Layer 3","opacity":1,"active":false,"unqid":"eiymk","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAiZJREFUWEfNWFEWwiAMc/c/9Hwg4YWQdgx+9EcdUEJI2ur1+aPXdYLlvu/brb+uayvu1qKTA2RrUzA4+eZBh31BYsZaCMYAOWGxXucToBQMGGFprLJU1jQWBl1lgCwYZoUWM+0ZS50FPQx/d9cVgpGFFUhgnjpGwbvJSgxdw88U0AQmYiVgqOJQfbUr6gcomwZz6nOAsmAMK1gUObOPM2g9gBtjVgcwGSskxrIGoqyfdRN3xTiFspaC0UCifptxsUHCCg5t9TRd04JWekDoBGIEa0Yrg4AjU1gwmRXFMaqd8MRavzLmu2aaqjlLTmI1Nu36cVrQAyj7mndYwJqyl+vhg0tYZ4MrWWvlqgYwWVJ7Qubop/DKYHchz5mYedo0GzcW5zQwJEFNCTWJU/Dhmt6AcsLPCiW7r+nq95aBWanQLsuS5RE+FHp0Ta0W/vTGQJyWdNy1G1EcKZbVwYOAA2tzgQtLR8HeKLBXrUZBBxBaG2CiiU5DUomXUr6rZchHQ9IDraIDrezl9LY0tOerzZW6qwfFQOkteFLFpyI3LEGgtpXg+UExrXsstRDKhLYQbxhhUWs/vNpcQfFR+kn14q5fmvyZGfa22o/bBkFkc9WT1WHntO0EoKBb61ZnQFGNi37q8PUsgQmctVwlTDlwxXKIN2kGo5p3llG0iWCL4yCHIa9ozBSMpvO3gHR+9mtysvbpZqfrQ2ZOA++s3wYT/VEEEDt/GH0BxdBvQrBEJaEAAAAASUVORK5CYII=","edit":false,"name":"Layer 4","opacity":1,"active":true,"unqid":"eiymk","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":4,"unqid":"m1fr0o","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAY1JREFUWEftWNEOwkAI8/7/o2dmhmFcW3rTGB/mk0bkSoF259i2bXv8yWvcYEgnLGbGGB830pmGFkwAcZIxxG4OCQYlcVkK8DVeFdWCQUllwqOle0wtpmOIgsk/7JLk9uyxuYAKPH9f2yrBoKSKdqcAVRgEU5Oy/kdlDHT9nWJsz0XBqAMU2DoriEnGzgSGHfRCTvQmADgMyXmqdrAygCjWKQZt2tSm1VWMmekKqNu2f65sQjBqWJG+OBs0rfCx/lPx0SbGimNKna6grUPsvAdYiZEDCM2KYi3OO8VUZpyDWcyKSMLhZ21aAYVa3BnlMhimKxkoUlnYAmKgsE0haq5LZ6BMN6pQtqKYRW9FL5jGxJY4D1p0tXMVqlJ0CCsCbagqGHpTpxsrJpqZ6gTyJ0bJBn568EL3po72KwLHGDr5FgOT5bq+r3PTbQnaVOhz7Eap2EG0uwvAHqwm11ZW362su+rKAy9dVRyrYMqsimrBuIwogFWtqSB2/0I4/uQw5RTV3rXdg74Rd4NhLD4BqUiGtstfWkUAAAAASUVORK5CYII=","width":"35","height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAY1JREFUWEftWNEOwkAI8/7/o2dmhmFcW3rTGB/mk0bkSoF259i2bXv8yWvcYEgnLGbGGB830pmGFkwAcZIxxG4OCQYlcVkK8DVeFdWCQUllwqOle0wtpmOIgsk/7JLk9uyxuYAKPH9f2yrBoKSKdqcAVRgEU5Oy/kdlDHT9nWJsz0XBqAMU2DoriEnGzgSGHfRCTvQmADgMyXmqdrAygCjWKQZt2tSm1VWMmekKqNu2f65sQjBqWJG+OBs0rfCx/lPx0SbGimNKna6grUPsvAdYiZEDCM2KYi3OO8VUZpyDWcyKSMLhZ21aAYVa3BnlMhimKxkoUlnYAmKgsE0haq5LZ6BMN6pQtqKYRW9FL5jGxJY4D1p0tXMVqlJ0CCsCbagqGHpTpxsrJpqZ6gTyJ0bJBn568EL3po72KwLHGDr5FgOT5bq+r3PTbQnaVOhz7Eap2EG0uwvAHqwm11ZW362su+rKAy9dVRyrYMqsimrBuIwogFWtqSB2/0I4/uQw5RTV3rXdg74Rd4NhLD4BqUiGtstfWkUAAAAASUVORK5CYII=","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/d8.pixil b/applications/plugins/dice2/sources/d8.pixil deleted file mode 100644 index 4f7ff440e..000000000 --- a/applications/plugins/dice2/sources/d8.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"35","height":"35","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAFtJREFUWEftlEEOACAIw9z/Hz0foBwWTdCknomQUibbHo88MUyxCchUikIGMml84QzO4ExKAGdSYkvOSGrLnrbGO2oMwzUdX1P6wc16BEbg1CecwRmcSQl84cwEPw2PmDu06wcAAAAASUVORK5CYII=","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"f9mfzy5","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAhRJREFUWEfNmFtu7DAMQ5v9LzqFDUugGephX1yg/ZlM09jHFPVIn59//Hnf9+Ulnud5bpa9esg2MhDc29hugK5hFAhAzstToCuYQpEJMhT67zCRImidEbabcB0pI0DG8x8Pm4dOgdowDAJhcBhSxMPV9U8Jg8cWJ0Z/eDaDIkdAKUzgDw8NK7HUYoC2f0KYBGQmy8hc84tS7EadFIY3sTislJ2V19TgT7u3/NIKl4QZqmT+sA3o9LyWwzJQVH8+MAgyQgHfZ1iUGqgC9qQifJ+9t18QyDzQWtyaoQMxFJ4+ClFVfxyGFUGTmlkjAMwiVCaqRQTrDBIGFkdlMGRu3LW5KaY+LfswxWX/CmFAdgylzy4ILMK7bRYlBLeL0DNcJxKPzDVsQ0xxaANbXYqyK80mBOJrGuY2haEeoYX8Wqw1n5cwqlCJ09jzn7GTTayIMLOs7pRFj9NUhc/qkZTBHB6MxTiEhTBk4NmqsDHebqxUT5VBQ1LqenpWvmALQOPdBjJsDe2uHRU2gN1GvuBthVvKtn8IY+qYrCpMa0MvjFwsaQzZQCDtPeIpjAgXFjPMRpVRYZNVIDK12ZjRa0mhSjV8SRFKZThcBkshqZRpjZ4tGAWUVeSbkbMVJqqmUwFRPfF1ZZuBTt6d2spAeDagbAA7ATlWpgE0I0otpH3g9h92sgzNHaVv2kaym9W9P/P/mQr05v4vDlEtQnsbdYsAAAAASUVORK5CYII=","edit":false,"name":"Layer 1","opacity":"1","active":false,"unqid":"rly08e","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":2,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAchJREFUWEfNmNtygzAQQ8P/fzQdezAjhGSv3DwkL02L8R6kvZgenx/6HDss53me7b7jeN9+XWrX4r3jGxpEgxmxRnCE2wWKYYwqbZ+u1vjsAG3BKFUGBLqTAkUwqAoEUmpsKRTDoCqr76llZRinCiewUuxK+s42q7IIxinB+dKAZmsdUAlmpUoLjIq47yuFyjDqSZvqomkO9oc6lT60hJlU0HFHBSIu+6EaN+TLykf8EswqV1gdo2K3kq7VYVJVEIrzCMsc1MpgXK6osbAq821lZqrgCGKLuM+o32NleDJDAvbEvXpFG45jSPafNI9kZZVhsEKE793j4DzTJzn3nTKMOq+oCmAbCRwT86XOAORO/CrtVQVdYA+FqIrGnn0r1XcimEpfmQ08tpqtimHc9BXtv/QnVfYlm9D/UqRwUTmB3WE7jGeXR+NgVrbfAnJnYzkoK60ek9JBugnuTnx2as+AOKdUN1Z9yFXRfVKcSa9KFKcvHTfdWLhDrF5dlucZbP94WlO9Ax8MGx6ttTFLMKDG6x3b9KPHG+ZKkZJNykJnnXrnriqyDcMqsXVslasc9aCRTTtKJf8a+TeMUgqqLNo/WvytDuz2+QMl8/wzbBarJwAAAABJRU5ErkJggg==","edit":false,"name":"Layer 2","opacity":"1","active":true,"unqid":"tqny2","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":3,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAgdJREFUWEfNmEF2AyEMQ8v9Dz15UOwnhAyGySLdpZ2BH1kWpuXv8ud5nodfLaWUy+Xaa1cvGwjubWxvgI5hFIip8RboCsYUgc29Om+AjmBQFbQMW+UWKA3D5WH/dqC6XjP2DVAKJgKpAFSqUp8VZUzts31oBYLGjXxE5VzudwTDhq2fWR37XY8Nz6JM2ZYwB+Vp5SLf2NppoBBmVx5UxdSBrmrewTTGMkbBuIRZ5Am/53sLU7PJTcVpbwmj8oTBFt8aS2ZHTluyK+KtzwpNMKo8ycRlCAfp4NJDCDTAbHwyZAgqs+kqhLJQHMLRgCaYhE+qzLwoL95YqTSuDHTe4B+H2fmk0mO6CmUaEG5E5el8/02mumuACVRxCAw9au3hW9tmDBaEpjNMMGosYBXsM3XDEG4qmSNFfD04X6YDToyVu6lyKpUaNaKjQZaJdxTj7vAI5geND1PgkbHHdVAZlhE/nwIK37hq/W/rBKac8fNFnCXTzQAVAU+hHcLknTyjvMNjADzjQgFoCJgdtrbHgQEJ02GmTK3NZbqeZ8R1BLvE05Z8JBMW1dzdqY7mGTE8hercXPCOJz1uY1BHHgeZ8oQGFi3cjLkbIzZD1fJLp2F6yw5AdkdXUZDtHBXlKeIFkLXzMDidlAah0jArhfqC1zfJozIh/U/9FyJQ6Opuzb45KpMy3Td/9wFxxy9CEK7yBQAAAABJRU5ErkJggg==","edit":false,"name":"Layer 3","opacity":"1","active":false,"unqid":"rly08e","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":4,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAcZJREFUWEfNWFsOwzAIW+5/6E6JAmLU5pF10vYzqXk5xmDa8fqj3zjBcl3XNdeNcV++h+ZYe+/2Ag9EDrfg5rOfgwkYmZdabM3fKTtlZhAQy4oAkeicsFMCEwGx0jCMHLGTgmGh2TfXsDhG7PP0DGU1yqYIiAjWC/gbdihqlDXs9kQvbXYgGJa+Ewy5eeV5Gq7bhAiIS9sVKRDmleJAU2dgfPGUjS0rFpgFtIud3GlV6WrdgcwgbaDbMvGfZhYFY2n24UHF7gl2yswg4XqzdOFoa6fEDNMKMWa7Z0s7J2CGyzgxSf2f4yLkTmalYDwrM52b/UyZnVAzUV2xgEDqr303Q8y/bmenAgZNkxY7vbJJJdNUreFO3WmDMT6U+lrXs0LN+M0ih6+M+fLgW9MSmMpBnTliEWUwzHs6h6K5UVuauva3h6P1zDjTfqbi1M6XNJWR5iIHDzPCuy/wno+qaw8HxTJtJdL0ZN3/bqymGS5A6GVOwLkxembYfbFXlOS1VqNWBaGMZgIlPiTh+dAHYTFtN8tgxGNY75I8LwNRj8nYYYDsum5IYA2qADFCvH0KeQJEK0yOAf3aYFK5FQ5GwCObdNiN5r4BawL8M515sSoAAAAASUVORK5CYII=","edit":false,"name":"Layer 4","opacity":"1","active":false,"unqid":"tqny2","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":2,"unqid":"jv591w","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAYNJREFUWEfNmEsSwjAMQ8n9D12mzIQxqmXJbhew4VvyoihSYB3Hcbz+5LbuwKy1LtO4M7cxzAaJg2evdUS/DXMOdgKhShOFRjCVAhGqCzSG2QNlg0+B2jBRFfV4+8VVaAQTVUEDZ4ptXykzt2CYEnsQpZRSqA2TqXJCOK8rhWwYpUpUB5eKPcdla8Ewr8QvxW2/VXNyyIJxVam8g+GY+ceGcVRBhVgWRY/9XKOKUqnCAg5N/YgybKecX161duadCNReJkeVXZLxXu2s0TJVqihl4vvotzaMUgVnTweAQKz6iu4mJ1WrrsF8cYIvhXFVUcXHlorVAoVh7esAZJ9h7S5zhq3/FOTSQcFHFoxq2ClYeWRlCZwF2hQAr2PnmrKbqqh3lGMNziYlizIDyjwVt3Jm1mp5vpmlihKPBVloIUhWkpaSLkwGVW1//GGnzr+fTOrCYCdVZ5Yq+jPfjGAqlRissxNvwTA/dRVpG9iaWfiLxPHIJZknnnHAJp95ZJkmA2fXvAFTp/+nAJYHZgAAAABJRU5ErkJggg==","width":"35","height":"35","old_width":"35","old_height":"35"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACMA/sfR5H8Fkddasdmnacvx//8745jkhasdASD945kjknhj/AAAjCAYAAAAe2bNZAAAAAXNSR0IArs4c6QAAAYNJREFUWEfNmEsSwjAMQ8n9D12mzIQxqmXJbhew4VvyoihSYB3Hcbz+5LbuwKy1LtO4M7cxzAaJg2evdUS/DXMOdgKhShOFRjCVAhGqCzSG2QNlg0+B2jBRFfV4+8VVaAQTVUEDZ4ptXykzt2CYEnsQpZRSqA2TqXJCOK8rhWwYpUpUB5eKPcdla8Ewr8QvxW2/VXNyyIJxVam8g+GY+ceGcVRBhVgWRY/9XKOKUqnCAg5N/YgybKecX161duadCNReJkeVXZLxXu2s0TJVqihl4vvotzaMUgVnTweAQKz6iu4mJ1WrrsF8cYIvhXFVUcXHlorVAoVh7esAZJ9h7S5zhq3/FOTSQcFHFoxq2ClYeWRlCZwF2hQAr2PnmrKbqqh3lGMNziYlizIDyjwVt3Jm1mp5vpmlihKPBVloIUhWkpaSLkwGVW1//GGnzr+fTOrCYCdVZ5Yq+jPfjGAqlRissxNvwTA/dRVpG9iaWfiLxPHIJZknnnHAJp95ZJkmA2fXvAFTp/+nAJYHZgAAAABJRU5ErkJggg==","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/flipper-screen.png b/applications/plugins/dice2/sources/flipper-screen.png deleted file mode 100644 index af759a20f..000000000 Binary files a/applications/plugins/dice2/sources/flipper-screen.png and /dev/null differ diff --git a/applications/plugins/dice2/sources/main-screen.png b/applications/plugins/dice2/sources/main-screen.png deleted file mode 100644 index 20a4e9c2c..000000000 Binary files a/applications/plugins/dice2/sources/main-screen.png and /dev/null differ diff --git a/applications/plugins/dice2/sources/result_border.pixil b/applications/plugins/dice2/sources/result_border.pixil deleted file mode 100644 index afe25bf07..000000000 --- a/applications/plugins/dice2/sources/result_border.pixil +++ /dev/null @@ -1 +0,0 @@ -{"application":"pixil","version":"2.6.1","website":"pixilart.com","author":"https://www.pixilart.com","contact":"support@pixilart.com","width":"40","height":"30","colors":{"default":["000000","ffffff","f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688","4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B","ffebee","ffcdd2","ef9a9a","e57373","ef5350","e53935","d32f2f","c62828","b71c1c","ff8a80","ff5252","ff1744","d50000","fce4ec","f8bbd0","f48fb1","f06292","ec407a","e91e63","d81b60","c2185b","ad1457","880e4f","ff80ab","ff4081","f50057","c51162","f3e5f5","e1bee7","ce93d8","ba68c8","ab47bc","9c27b0","8e24aa","7b1fa2","6a1b9a","4a148c","ea80fc","e040fb","d500f9","aa00ff","ede7f6","d1c4e9","b39ddb","9575cd","7e57c2","673ab7","5e35b1","512da8","4527a0","311b92","b388ff","7c4dff","651fff","6200ea","e8eaf6","c5cae9","9fa8da","7986cb","5c6bc0","3f51b5","3949ab","303f9f","283593","1a237e","8c9eff","536dfe","3d5afe","304ffe","e3f2fd","bbdefb","90caf9","64b5f6","42a5f5","2196f3","1e88e5","1976d2","1565c0","0d47a1","82b1ff","448aff","2979ff","2962ff","e1f5fe","b3e5fc","81d4fa","4fc3f7","29b6f6","03a9f4","039be5","0288d1","0277bd","01579b","80d8ff","40c4ff","00b0ff","0091ea","e0f7fa","b2ebf2","80deea","4dd0e1","26c6da","00bcd4","00acc1","0097a7","00838f","006064","84ffff","18ffff","00e5ff","00b8d4","e0f2f1","b2dfdb","80cbc4","4db6ac","26a69a","009688","00897b","00796b","00695c","004d40","a7ffeb","64ffda","1de9b6","00bfa5","e8f5e9","c8e6c9","a5d6a7","81c784","66bb6a","4caf50","43a047","388e3c","2e7d32","1b5e20","b9f6ca","69f0ae","00e676","00c853","f1f8e9","dcedc8","c5e1a5","aed581","9ccc65","8bc34a","7cb342","689f38","558b2f","33691e","ccff90","b2ff59","76ff03","64dd17","f9fbe7","f0f4c3","e6ee9c","dce775","d4e157","cddc39","c0ca33","afb42b","9e9d24","827717","f4ff81","eeff41","c6ff00","aeea00","fffde7","fff9c4","fff59d","fff176","ffee58","ffeb3b","fdd835","fbc02d","f9a825","f57f17","ffff8d","ffff00","ffea00","ffd600","fff8e1","ffecb3","ffe082","ffd54f","ffca28","ffc107","ffb300","ffa000","ff8f00","ff6f00","ffe57f","ffd740","ffc400","ffab00","fff3e0","ffe0b2","ffcc80","ffb74d","ffa726","ff9800","fb8c00","f57c00","ef6c00","e65100","ffd180","ffab40","ff9100","ff6d00","fbe9e7","ffccbc","ffab91","ff8a65","ff7043","ff5722","f4511e","e64a19","d84315","bf360c","ff9e80","ff6e40","ff3d00","dd2c00","efebe9","d7ccc8","bcaaa4","a1887f","8d6e63","795548","6d4c41","5d4037","4e342e","3e2723","fafafa","f5f5f5","eeeeee","e0e0e0","bdbdbd","9e9e9e","757575","616161","424242","212121","eceff1","cfd8dc","b0bec5","90a4ae","78909c","607d8b","546e7a","455a64","37474f","263238"],"simple":["ffffff","d4d4d4","a1a1a1","787878","545454","303030","000000","edc5c5","e68383","ff0000","de2424","ad3636","823737","592b2b","f5d2ee","eb8dd7","f700b9","bf1f97","9c277f","732761","4f2445","e2bcf7","bf79e8","9d00ff","8330ba","6d3096","502c69","351b47","c5c3f0","736feb","0905f7","2e2eb0","2d2d80","252554","090936","c7e2ed","6ac3e6","00bbff","279ac4","347c96","2d5b6b","103947","bbf0d9","6febb3","00ff88","2eb878","349166","2b694c","0c3d25","c2edc0","76ed70","0dff00","36c72c","408c3b","315c2e","144511","d6edbb","b5eb73","8cff00","89c93a","6f8f44","4b632a","2a400c","f1f2bf","eef069","ffff00","baba30","91913f","5e5e2b","3b3b09","ffdeb8","f2ae61","ff8400","c48037","85623d","573e25","3d2309","fcbbae","ff8066","ff2b00","cc553d","9c5b4e","61372e","36130b"],"common":["000000","FFFFFF","7F7F7F","a1a1a1","C3C3C3","c40424","880015","B97A57","dba88c","ED1C24","f75b63","f26f9b","FF7F27","f7ab79","FFC90E","FFF200","cfc532","EFE4B0","1ee656","0c6624","22B14C","B5E61D","5487ff","00A2E8","99D9EA","3F48CC","7f86e3","7092BE","720899","cd55cf","A349A4","C8BFE7","ffffff"],"skin tones":["ffe0bd","ffdbac","ffcd94","eac086","e0ac69","f1c27d","ffad60","c68642","8d5524","896347","765339","613D24","4C2D17","391E0B","351606","2D1304","180A01","090300"]},"frames":[{"name":"","speed":100,"layers":[{"id":0,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAeCAYAAABe3VzdAAAAAXNSR0IArs4c6QAAAExJREFUWEft0rENADAIBDHYf2gyxDUpnP6kyPze3c3Hb30wXodgBByCBKtA7W2QYBWovQ0SrAK1t0GCVaD2NkiwCtTeBglWgdp/v8EHgvp3pxVCCEMAAAAASUVORK5CYII=","edit":false,"name":"Background","opacity":"1","active":true,"unqid":"q5hq79","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}},{"id":1,"src":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAeCAYAAABe3VzdAAAAAXNSR0IArs4c6QAAAMxJREFUWEftl9EOgCAIRfH/P7omC4clOsQcLXxpK4UjKNwStMcBAAkA6ClMW/K66ytDSGMHHPkWfX0W0H2K3QPmsxFnkN1O9SVxn2KXgBnK08ASSHWwByfVSu2GZuwkamc8cr3iPYowQa+wgb7ugBbDI3jN95IdDugFjvfnKoIBqMnx1cm2aT4lW5l+7BKlATgbAeu6SPF/IsiFg3XXq9Zju4tWZwjnI4Ke0txUM7RZi2h4RQ/SL6aUjRkl3LI1YwcVdaW/DGdm9VJkOwHIXkgOkN1G8QAAAABJRU5ErkJggg==","edit":false,"name":"Layer 1","opacity":"1","active":true,"unqid":"d3rvnh","options":{"blend":"source-over","locked":false,"filter":{"brightness":"100%","contrast":"100%","grayscale":"0%","blur":0,"dropshadow_x":0,"dropshadow_y":0,"dropshadow_blur":0,"dropshadow_alpha":1}}}],"active":true,"selectedLayer":1,"unqid":"h9fxa","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAeCAYAAABe3VzdAAAAAXNSR0IArs4c6QAAANFJREFUWEftllkOgDAIROH+h66BSNMqaheXMcEfo1Z8zGCBU0qJNgczk9y28/b5nddX32IPUADegLNEz771T8Ar2T+3GB4wavBg1/BKx/1J4C2GBBQopMP6h1p8Buc0Gs2jN6GRONrNiKhqdUeBWtQ16Dti5C5TAs4EbkmgdU3pTlYQBa7sz1pKpmAAtvq7rjObVUE09UqbA7DT2Wq52BwKhoIzCsy+m2tQAqFtNdU+GIADXu8URFLRnWYsyZlafGQehJ+obVLoHeEHyqrrFXNyAfXA6dp8XWGDAAAAAElFTkSuQmCC","width":"40","height":"30"}],"currentFrame":0,"name":"Untitled","preview":"data:image/pngp98kjasdnasd983/24kasdjasdbase64,iVBORw0KGgoAAAANSUhEUgAAACgA/sfR5H8Fkddasdmnacvx/AAAeCAYAAABe3VzdAAAAAXNSR0IArs4c6QAAANFJREFUWEftllkOgDAIROH+h66BSNMqaheXMcEfo1Z8zGCBU0qJNgczk9y28/b5nddX32IPUADegLNEz771T8Ar2T+3GB4wavBg1/BKx/1J4C2GBBQopMP6h1p8Buc0Gs2jN6GRONrNiKhqdUeBWtQ16Dti5C5TAs4EbkmgdU3pTlYQBa7sz1pKpmAAtvq7rjObVUE09UqbA7DT2Wq52BwKhoIzCsy+m2tQAqFtNdU+GIADXu8URFLRnWYsyZlafGQehJ+obVLoHeEHyqrrFXNyAfXA6dp8XWGDAAAAAElFTkSuQmCC","palette_id":false} \ No newline at end of file diff --git a/applications/plugins/dice2/sources/roll-screen.png b/applications/plugins/dice2/sources/roll-screen.png deleted file mode 100644 index a1f13cec1..000000000 Binary files a/applications/plugins/dice2/sources/roll-screen.png and /dev/null differ diff --git a/applications/plugins/dtmf_dolphin/LICENSE b/applications/plugins/dtmf_dolphin/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/dtmf_dolphin/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/dtmf_dolphin/README.md b/applications/plugins/dtmf_dolphin/README.md deleted file mode 100644 index 5c9561f4b..000000000 --- a/applications/plugins/dtmf_dolphin/README.md +++ /dev/null @@ -1,16 +0,0 @@ -![Image](assets/dialer.jpg) - -## DTMF Dolphin - -DTMF (Dual-Tone Multi-Frequency) dialer, Bluebox, and Redbox. - -Now in a release-ready state for both Dialer, Bluebox, and Redbox (US/UK) functionality! - -Please note that using the current tone output method, the 2600 tone is scaled about 33 Hz higher than it should be. This is a limitation of the current sample rate. - -### Educational Links: - -* http://www.phrack.org/issues/25/7.html#article -* https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling -* https://en.wikipedia.org/wiki/Blue_box -* https://en.wikipedia.org/wiki/Red_box_(phreaking) diff --git a/applications/plugins/dtmf_dolphin/application.fam b/applications/plugins/dtmf_dolphin/application.fam deleted file mode 100644 index 98fbe7363..000000000 --- a/applications/plugins/dtmf_dolphin/application.fam +++ /dev/null @@ -1,16 +0,0 @@ -App( - appid="DTMF_Dolphin", - name="DTMF Dolphin", - apptype=FlipperAppType.EXTERNAL, - entry_point="dtmf_dolphin_app", - cdefines=["DTMF_DOLPHIN"], - requires=[ - "storage", - "gui", - "dialogs", - ], - fap_icon="phone.png", - stack_size=8 * 1024, - order=20, - fap_category="Tools", -) diff --git a/applications/plugins/dtmf_dolphin/assets/dialer.jpg b/applications/plugins/dtmf_dolphin/assets/dialer.jpg deleted file mode 100644 index ff6fad7a8..000000000 Binary files a/applications/plugins/dtmf_dolphin/assets/dialer.jpg and /dev/null differ diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin.c b/applications/plugins/dtmf_dolphin/dtmf_dolphin.c deleted file mode 100644 index c1b10defa..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "dtmf_dolphin_i.h" - -#include -#include - -static bool dtmf_dolphin_app_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - DTMFDolphinApp* app = context; - return scene_manager_handle_custom_event(app->scene_manager, event); -} - -static bool dtmf_dolphin_app_back_event_callback(void* context) { - furi_assert(context); - DTMFDolphinApp* app = context; - return scene_manager_handle_back_event(app->scene_manager); -} - -static void dtmf_dolphin_app_tick_event_callback(void* context) { - furi_assert(context); - DTMFDolphinApp* app = context; - - scene_manager_handle_tick_event(app->scene_manager); -} - -static DTMFDolphinApp* app_alloc() { - DTMFDolphinApp* app = malloc(sizeof(DTMFDolphinApp)); - - app->gui = furi_record_open(RECORD_GUI); - app->view_dispatcher = view_dispatcher_alloc(); - app->scene_manager = scene_manager_alloc(&dtmf_dolphin_scene_handlers, app); - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - - view_dispatcher_set_custom_event_callback( - app->view_dispatcher, dtmf_dolphin_app_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - app->view_dispatcher, dtmf_dolphin_app_back_event_callback); - view_dispatcher_set_tick_event_callback( - app->view_dispatcher, dtmf_dolphin_app_tick_event_callback, 100); - - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - app->main_menu_list = variable_item_list_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - DTMFDolphinViewMainMenu, - variable_item_list_get_view(app->main_menu_list)); - - app->dtmf_dolphin_dialer = dtmf_dolphin_dialer_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - DTMFDolphinViewDialer, - dtmf_dolphin_dialer_get_view(app->dtmf_dolphin_dialer)); - - app->notification = furi_record_open(RECORD_NOTIFICATION); - notification_message(app->notification, &sequence_display_backlight_enforce_on); - - scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneStart); - - return app; -} - -static void app_free(DTMFDolphinApp* app) { - furi_assert(app); - view_dispatcher_remove_view(app->view_dispatcher, DTMFDolphinViewMainMenu); - view_dispatcher_remove_view(app->view_dispatcher, DTMFDolphinViewDialer); - variable_item_list_free(app->main_menu_list); - - dtmf_dolphin_dialer_free(app->dtmf_dolphin_dialer); - - view_dispatcher_free(app->view_dispatcher); - scene_manager_free(app->scene_manager); - - notification_message(app->notification, &sequence_display_backlight_enforce_auto); - - furi_record_close(RECORD_GUI); - furi_record_close(RECORD_NOTIFICATION); - free(app); -} - -int32_t dtmf_dolphin_app(void* p) { - UNUSED(p); - DTMFDolphinApp* app = app_alloc(); - - view_dispatcher_run(app->view_dispatcher); - - app_free(app); - return 0; -} \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.c b/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.c deleted file mode 100644 index 4b84ceb97..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.c +++ /dev/null @@ -1,265 +0,0 @@ -#include "dtmf_dolphin_audio.h" - -DTMFDolphinAudio* current_player; - -static void dtmf_dolphin_audio_dma_isr(void* ctx) { - FuriMessageQueue* event_queue = ctx; - - if(LL_DMA_IsActiveFlag_HT1(DMA1)) { - LL_DMA_ClearFlag_HT1(DMA1); - - DTMFDolphinCustomEvent event = {.type = DTMFDolphinEventDMAHalfTransfer}; - furi_message_queue_put(event_queue, &event, 0); - } - - if(LL_DMA_IsActiveFlag_TC1(DMA1)) { - LL_DMA_ClearFlag_TC1(DMA1); - - DTMFDolphinCustomEvent event = {.type = DTMFDolphinEventDMAFullTransfer}; - furi_message_queue_put(event_queue, &event, 0); - } -} - -void dtmf_dolphin_audio_clear_samples(DTMFDolphinAudio* player) { - for(size_t i = 0; i < player->buffer_length; i++) { - player->sample_buffer[i] = 0; - } -} - -DTMFDolphinOsc* dtmf_dolphin_osc_alloc() { - DTMFDolphinOsc* osc = malloc(sizeof(DTMFDolphinOsc)); - osc->cached_freq = 0; - osc->offset = 0; - osc->period = 0; - osc->lookup_table = NULL; - return osc; -} - -DTMFDolphinPulseFilter* dtmf_dolphin_pulse_filter_alloc() { - DTMFDolphinPulseFilter* pf = malloc(sizeof(DTMFDolphinPulseFilter)); - pf->duration = 0; - pf->period = 0; - pf->offset = 0; - pf->lookup_table = NULL; - return pf; -} - -DTMFDolphinAudio* dtmf_dolphin_audio_alloc() { - DTMFDolphinAudio* player = malloc(sizeof(DTMFDolphinAudio)); - player->buffer_length = SAMPLE_BUFFER_LENGTH; - player->half_buffer_length = SAMPLE_BUFFER_LENGTH / 2; - player->sample_buffer = malloc(sizeof(uint16_t) * player->buffer_length); - player->osc1 = dtmf_dolphin_osc_alloc(); - player->osc2 = dtmf_dolphin_osc_alloc(); - player->volume = 1.0f; - player->queue = furi_message_queue_alloc(10, sizeof(DTMFDolphinCustomEvent)); - player->filter = dtmf_dolphin_pulse_filter_alloc(); - player->playing = false; - dtmf_dolphin_audio_clear_samples(player); - - return player; -} - -size_t calc_waveform_period(float freq) { - if(!freq) { - return 0; - } - // DMA Rate calculation, thanks to Dr_Zlo - float dma_rate = CPU_CLOCK_FREQ / 2 / DTMF_DOLPHIN_HAL_DMA_PRESCALER / - (DTMF_DOLPHIN_HAL_DMA_AUTORELOAD + 1); - - // Using a constant scaling modifier, which likely represents - // the combined system overhead and isr latency. - return (uint16_t)dma_rate * 2 / freq * 0.801923; -} - -void osc_generate_lookup_table(DTMFDolphinOsc* osc, float freq) { - if(osc->lookup_table != NULL) { - free(osc->lookup_table); - } - osc->offset = 0; - osc->cached_freq = freq; - osc->period = calc_waveform_period(freq); - if(!osc->period) { - osc->lookup_table = NULL; - return; - } - osc->lookup_table = malloc(sizeof(float) * osc->period); - - for(size_t i = 0; i < osc->period; i++) { - osc->lookup_table[i] = sin(i * PERIOD_2_PI / osc->period) + 1; - } -} - -void filter_generate_lookup_table( - DTMFDolphinPulseFilter* pf, - uint16_t pulses, - uint16_t pulse_ms, - uint16_t gap_ms) { - if(pf->lookup_table != NULL) { - free(pf->lookup_table); - } - pf->offset = 0; - - uint16_t gap_period = calc_waveform_period(1000 / (float)gap_ms); - uint16_t pulse_period = calc_waveform_period(1000 / (float)pulse_ms); - pf->period = pulse_period + gap_period; - - if(!pf->period) { - pf->lookup_table = NULL; - return; - } - pf->duration = pf->period * pulses; - pf->lookup_table = malloc(sizeof(bool) * pf->duration); - - for(size_t i = 0; i < pf->duration; i++) { - pf->lookup_table[i] = i % pf->period < pulse_period; - } -} - -float sample_frame(DTMFDolphinOsc* osc) { - float frame = 0.0; - - if(osc->period) { - frame = osc->lookup_table[osc->offset]; - osc->offset = (osc->offset + 1) % osc->period; - } - - return frame; -} - -bool sample_filter(DTMFDolphinPulseFilter* pf) { - bool frame = true; - - if(pf->duration) { - if(pf->offset < pf->duration) { - frame = pf->lookup_table[pf->offset]; - pf->offset = pf->offset + 1; - } else { - frame = false; - } - } - - return frame; -} - -void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc) { - if(osc->lookup_table != NULL) { - free(osc->lookup_table); - } - free(osc); -} - -void dtmf_dolphin_filter_free(DTMFDolphinPulseFilter* pf) { - if(pf->lookup_table != NULL) { - free(pf->lookup_table); - } - free(pf); -} - -void dtmf_dolphin_audio_free(DTMFDolphinAudio* player) { - furi_message_queue_free(player->queue); - dtmf_dolphin_osc_free(player->osc1); - dtmf_dolphin_osc_free(player->osc2); - dtmf_dolphin_filter_free(player->filter); - free(player->sample_buffer); - free(player); - current_player = NULL; -} - -bool generate_waveform(DTMFDolphinAudio* player, uint16_t buffer_index) { - uint16_t* sample_buffer_start = &player->sample_buffer[buffer_index]; - - for(size_t i = 0; i < player->half_buffer_length; i++) { - float data = 0; - if(player->osc2->period) { - data = (sample_frame(player->osc1) / 2) + (sample_frame(player->osc2) / 2); - } else { - data = (sample_frame(player->osc1)); - } - data *= sample_filter(player->filter) ? player->volume : 0.0; - data *= UINT8_MAX / 2; // scale -128..127 - data += UINT8_MAX / 2; // to unsigned - - if(data < 0) { - data = 0; - } - - if(data > 255) { - data = 255; - } - - sample_buffer_start[i] = data; - } - - return true; -} - -bool dtmf_dolphin_audio_play_tones( - float freq1, - float freq2, - uint16_t pulses, - uint16_t pulse_ms, - uint16_t gap_ms) { - if(current_player != NULL && current_player->playing) { - // Cannot start playing while still playing something else - return false; - } - current_player = dtmf_dolphin_audio_alloc(); - - osc_generate_lookup_table(current_player->osc1, freq1); - osc_generate_lookup_table(current_player->osc2, freq2); - filter_generate_lookup_table(current_player->filter, pulses, pulse_ms, gap_ms); - - generate_waveform(current_player, 0); - generate_waveform(current_player, current_player->half_buffer_length); - - dtmf_dolphin_speaker_init(); - dtmf_dolphin_dma_init((uint32_t)current_player->sample_buffer, current_player->buffer_length); - - furi_hal_interrupt_set_isr( - FuriHalInterruptIdDma1Ch1, dtmf_dolphin_audio_dma_isr, current_player->queue); - - dtmf_dolphin_dma_start(); - dtmf_dolphin_speaker_start(); - current_player->playing = true; - return true; -} - -bool dtmf_dolphin_audio_stop_tones() { - if(current_player != NULL && !current_player->playing) { - // Can't stop a player that isn't playing. - return false; - } - while(current_player->filter->offset > 0 && - current_player->filter->offset < current_player->filter->duration) { - // run remaining ticks if needed to complete filter sequence - dtmf_dolphin_audio_handle_tick(); - } - dtmf_dolphin_speaker_stop(); - dtmf_dolphin_dma_stop(); - - furi_hal_interrupt_set_isr(FuriHalInterruptIdDma1Ch1, NULL, NULL); - - dtmf_dolphin_audio_free(current_player); - - return true; -} - -bool dtmf_dolphin_audio_handle_tick() { - bool handled = false; - - if(current_player) { - DTMFDolphinCustomEvent event; - if(furi_message_queue_get(current_player->queue, &event, 250) == FuriStatusOk) { - if(event.type == DTMFDolphinEventDMAHalfTransfer) { - generate_waveform(current_player, 0); - handled = true; - } else if(event.type == DTMFDolphinEventDMAFullTransfer) { - generate_waveform(current_player, current_player->half_buffer_length); - handled = true; - } - } - } - return handled; -} \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.h b/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.h deleted file mode 100644 index 2dd1d6eb6..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_audio.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -// #include "dtmf_dolphin_i.h" -#include "dtmf_dolphin_event.h" -#include "dtmf_dolphin_hal.h" - -#define SAMPLE_BUFFER_LENGTH 8192 -#define PERIOD_2_PI 6.2832 -#define CPU_CLOCK_FREQ 64000000 - -typedef struct { - float cached_freq; - size_t period; - float* lookup_table; - uint16_t offset; -} DTMFDolphinOsc; - -typedef struct { - float duration; - size_t period; - bool* lookup_table; - uint16_t offset; -} DTMFDolphinPulseFilter; - -typedef struct { - size_t buffer_length; - size_t half_buffer_length; - uint8_t* buffer_buffer; - uint16_t* sample_buffer; - float volume; - FuriMessageQueue* queue; - DTMFDolphinOsc* osc1; - DTMFDolphinOsc* osc2; - DTMFDolphinPulseFilter* filter; - bool playing; -} DTMFDolphinAudio; - -DTMFDolphinOsc* dtmf_dolphin_osc_alloc(); - -DTMFDolphinAudio* dtmf_dolphin_audio_alloc(); - -void dtmf_dolphin_audio_free(DTMFDolphinAudio* player); - -void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc); - -bool dtmf_dolphin_audio_play_tones( - float freq1, - float freq2, - uint16_t pulses, - uint16_t pulse_ms, - uint16_t gap_ms); - -bool dtmf_dolphin_audio_stop_tones(); - -bool dtmf_dolphin_audio_handle_tick(); diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.c b/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.c deleted file mode 100644 index 72386b83d..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.c +++ /dev/null @@ -1,220 +0,0 @@ -#include "dtmf_dolphin_data.h" - -typedef struct { - const uint8_t row; - const uint8_t col; - const uint8_t span; -} DTMFDolphinTonePos; - -typedef struct { - const char* name; - const float frequency_1; - const float frequency_2; - const DTMFDolphinTonePos pos; - const uint16_t pulses; // for Redbox - const uint16_t pulse_ms; // for Redbox - const uint16_t gap_duration; // for Redbox -} DTMFDolphinTones; - -typedef struct { - const char* name; - DTMFDolphinToneSection block; - uint8_t tone_count; - DTMFDolphinTones tones[DTMF_DOLPHIN_MAX_TONE_COUNT]; -} DTMFDolphinSceneData; - -DTMFDolphinSceneData DTMFDolphinSceneDataDialer = { - .name = "Dialer", - .block = DTMF_DOLPHIN_TONE_BLOCK_DIALER, - .tone_count = 16, - .tones = { - {"1", 697.0, 1209.0, {0, 0, 1}, 0, 0, 0}, - {"2", 697.0, 1336.0, {0, 1, 1}, 0, 0, 0}, - {"3", 697.0, 1477.0, {0, 2, 1}, 0, 0, 0}, - {"A", 697.0, 1633.0, {0, 3, 1}, 0, 0, 0}, - {"4", 770.0, 1209.0, {1, 0, 1}, 0, 0, 0}, - {"5", 770.0, 1336.0, {1, 1, 1}, 0, 0, 0}, - {"6", 770.0, 1477.0, {1, 2, 1}, 0, 0, 0}, - {"B", 770.0, 1633.0, {1, 3, 1}, 0, 0, 0}, - {"7", 852.0, 1209.0, {2, 0, 1}, 0, 0, 0}, - {"8", 852.0, 1336.0, {2, 1, 1}, 0, 0, 0}, - {"9", 852.0, 1477.0, {2, 2, 1}, 0, 0, 0}, - {"C", 852.0, 1633.0, {2, 3, 1}, 0, 0, 0}, - {"*", 941.0, 1209.0, {3, 0, 1}, 0, 0, 0}, - {"0", 941.0, 1336.0, {3, 1, 1}, 0, 0, 0}, - {"#", 941.0, 1477.0, {3, 2, 1}, 0, 0, 0}, - {"D", 941.0, 1633.0, {3, 3, 1}, 0, 0, 0}, - }}; - -DTMFDolphinSceneData DTMFDolphinSceneDataBluebox = { - .name = "Bluebox", - .block = DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX, - .tone_count = 13, - .tones = { - {"1", 700.0, 900.0, {0, 0, 1}, 0, 0, 0}, - {"2", 700.0, 1100.0, {0, 1, 1}, 0, 0, 0}, - {"3", 900.0, 1100.0, {0, 2, 1}, 0, 0, 0}, - {"4", 700.0, 1300.0, {1, 0, 1}, 0, 0, 0}, - {"5", 900.0, 1300.0, {1, 1, 1}, 0, 0, 0}, - {"6", 1100.0, 1300.0, {1, 2, 1}, 0, 0, 0}, - {"7", 700.0, 1500.0, {2, 0, 1}, 0, 0, 0}, - {"8", 900.0, 1500.0, {2, 1, 1}, 0, 0, 0}, - {"9", 1100.0, 1500.0, {2, 2, 1}, 0, 0, 0}, - {"0", 1300.0, 1500.0, {3, 1, 1}, 0, 0, 0}, - {"KP", 1100.0, 1700.0, {0, 3, 2}, 0, 0, 0}, - {"ST", 1500.0, 1700.0, {1, 3, 2}, 0, 0, 0}, - {"2600", 2600.0, 0.0, {3, 2, 3}, 0, 0, 0}, - }}; - -DTMFDolphinSceneData DTMFDolphinSceneDataRedboxUS = { - .name = "Redbox (US)", - .block = DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US, - .tone_count = 4, - .tones = { - {"Nickel", 1700.0, 2200.0, {0, 0, 5}, 1, 66, 0}, - {"Dime", 1700.0, 2200.0, {1, 0, 5}, 2, 66, 66}, - {"Quarter", 1700.0, 2200.0, {2, 0, 5}, 5, 33, 33}, - {"Dollar", 1700.0, 2200.0, {3, 0, 5}, 1, 650, 0}, - }}; - -DTMFDolphinSceneData DTMFDolphinSceneDataRedboxCA = { - .name = "Redbox (CA)", - .block = DTMF_DOLPHIN_TONE_BLOCK_REDBOX_CA, - .tone_count = 3, - .tones = { - {"Nickel", 2200.0, 0.0, {0, 0, 5}, 1, 66, 0}, - {"Dime", 2200.0, 0.0, {1, 0, 5}, 2, 66, 66}, - {"Quarter", 2200.0, 0.0, {2, 0, 5}, 5, 33, 33}, - }}; - -DTMFDolphinSceneData DTMFDolphinSceneDataRedboxUK = { - .name = "Redbox (UK)", - .block = DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK, - .tone_count = 2, - .tones = { - {"10p", 1000.0, 0.0, {0, 0, 5}, 1, 200, 0}, - {"50p", 1000.0, 0.0, {1, 0, 5}, 1, 350, 0}, - }}; - -DTMFDolphinSceneData DTMFDolphinSceneDataMisc = { - .name = "Misc", - .block = DTMF_DOLPHIN_TONE_BLOCK_MISC, - .tone_count = 3, - .tones = { - {"CCITT 11", 700.0, 1700.0, {0, 0, 5}, 0, 0, 0}, - {"CCITT 12", 900.0, 1700.0, {1, 0, 5}, 0, 0, 0}, - {"CCITT KP2", 1300.0, 1700.0, {2, 0, 5}, 0, 0, 0}, - }}; - -DTMFDolphinToneSection current_section; -DTMFDolphinSceneData* current_scene_data; - -void dtmf_dolphin_data_set_current_section(DTMFDolphinToneSection section) { - current_section = section; - - switch(current_section) { - case DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX: - current_scene_data = &DTMFDolphinSceneDataBluebox; - break; - case DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US: - current_scene_data = &DTMFDolphinSceneDataRedboxUS; - break; - case DTMF_DOLPHIN_TONE_BLOCK_REDBOX_CA: - current_scene_data = &DTMFDolphinSceneDataRedboxCA; - break; - case DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK: - current_scene_data = &DTMFDolphinSceneDataRedboxUK; - break; - case DTMF_DOLPHIN_TONE_BLOCK_MISC: - current_scene_data = &DTMFDolphinSceneDataMisc; - break; - default: // DTMF_DOLPHIN_TONE_BLOCK_DIALER: - current_scene_data = &DTMFDolphinSceneDataDialer; - break; - } -} - -DTMFDolphinToneSection dtmf_dolphin_data_get_current_section() { - return current_section; -} - -DTMFDolphinSceneData* dtmf_dolphin_data_get_current_scene_data() { - return current_scene_data; -} - -bool dtmf_dolphin_data_get_tone_frequencies(float* freq1, float* freq2, uint8_t row, uint8_t col) { - for(size_t i = 0; i < current_scene_data->tone_count; i++) { - DTMFDolphinTones tones = current_scene_data->tones[i]; - if(tones.pos.row == row && tones.pos.col == col) { - freq1[0] = tones.frequency_1; - freq2[0] = tones.frequency_2; - return true; - } - } - return false; -} - -bool dtmf_dolphin_data_get_filter_data( - uint16_t* pulses, - uint16_t* pulse_ms, - uint16_t* gap_ms, - uint8_t row, - uint8_t col) { - for(size_t i = 0; i < current_scene_data->tone_count; i++) { - DTMFDolphinTones tones = current_scene_data->tones[i]; - if(tones.pos.row == row && tones.pos.col == col) { - pulses[0] = tones.pulses; - pulse_ms[0] = tones.pulse_ms; - gap_ms[0] = tones.gap_duration; - return true; - } - } - return false; -} - -const char* dtmf_dolphin_data_get_tone_name(uint8_t row, uint8_t col) { - for(size_t i = 0; i < current_scene_data->tone_count; i++) { - DTMFDolphinTones tones = current_scene_data->tones[i]; - if(tones.pos.row == row && tones.pos.col == col) { - return tones.name; - } - } - return NULL; -} - -const char* dtmf_dolphin_data_get_current_section_name() { - if(current_scene_data) { - return current_scene_data->name; - } - return NULL; -} - -void dtmf_dolphin_tone_get_max_pos(uint8_t* max_rows, uint8_t* max_cols, uint8_t* max_span) { - max_rows[0] = 0; - max_cols[0] = 0; - max_span[0] = 0; - uint8_t tmp_rowspan[5] = {0, 0, 0, 0, 0}; - for(size_t i = 0; i < current_scene_data->tone_count; i++) { - DTMFDolphinTones tones = current_scene_data->tones[i]; - if(tones.pos.row > max_rows[0]) { - max_rows[0] = tones.pos.row; - } - if(tones.pos.col > max_cols[0]) { - max_cols[0] = tones.pos.col; - } - tmp_rowspan[tones.pos.row] += tones.pos.span; - if(tmp_rowspan[tones.pos.row] > max_span[0]) max_span[0] = tmp_rowspan[tones.pos.row]; - } - max_rows[0]++; - max_cols[0]++; -} - -uint8_t dtmf_dolphin_get_tone_span(uint8_t row, uint8_t col) { - for(size_t i = 0; i < current_scene_data->tone_count; i++) { - DTMFDolphinTones tones = current_scene_data->tones[i]; - if(tones.pos.row == row && tones.pos.col == col) { - return tones.pos.span; - } - } - return 0; -} diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.h b/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.h deleted file mode 100644 index 56ceaf03d..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_data.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include -#include - -#define DTMF_DOLPHIN_MAX_TONE_COUNT 16 - -typedef enum { - DTMF_DOLPHIN_TONE_BLOCK_DIALER, - DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX, - DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US, - DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK, - DTMF_DOLPHIN_TONE_BLOCK_REDBOX_CA, - DTMF_DOLPHIN_TONE_BLOCK_MISC, -} DTMFDolphinToneSection; - -void dtmf_dolphin_data_set_current_section(DTMFDolphinToneSection section); - -DTMFDolphinToneSection dtmf_dolphin_data_get_current_section(); - -bool dtmf_dolphin_data_get_tone_frequencies(float* freq1, float* freq2, uint8_t row, uint8_t col); - -bool dtmf_dolphin_data_get_filter_data( - uint16_t* pulses, - uint16_t* pulse_ms, - uint16_t* gap_ms, - uint8_t row, - uint8_t col); - -const char* dtmf_dolphin_data_get_tone_name(uint8_t row, uint8_t col); - -const char* dtmf_dolphin_data_get_current_section_name(); - -void dtmf_dolphin_tone_get_max_pos(uint8_t* max_rows, uint8_t* max_cols, uint8_t* max_span); - -uint8_t dtmf_dolphin_get_tone_span(uint8_t row, uint8_t col); \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_event.h b/applications/plugins/dtmf_dolphin/dtmf_dolphin_event.h deleted file mode 100644 index 525d0eb04..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_event.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -typedef enum { - DTMFDolphinEventVolumeUp = 0, - DTMFDolphinEventVolumeDown, - DTMFDolphinDialerOkCB, - DTMFDolphinEventStartDialer, - DTMFDolphinEventStartBluebox, - DTMFDolphinEventStartRedboxUS, - DTMFDolphinEventStartRedboxUK, - DTMFDolphinEventStartRedboxCA, - DTMFDolphinEventStartMisc, - DTMFDolphinEventPlayTones, - DTMFDolphinEventStopTones, - DTMFDolphinEventDMAHalfTransfer, - DTMFDolphinEventDMAFullTransfer, -} DTMFDolphinEvent; - -typedef struct { - DTMFDolphinEvent type; -} DTMFDolphinCustomEvent; \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.c b/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.c deleted file mode 100644 index b556c7145..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "dtmf_dolphin_hal.h" - -void dtmf_dolphin_speaker_init() { - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - TIM_InitStruct.Prescaler = DTMF_DOLPHIN_HAL_DMA_PRESCALER; - TIM_InitStruct.Autoreload = DTMF_DOLPHIN_HAL_DMA_AUTORELOAD; - LL_TIM_Init(FURI_HAL_SPEAKER_TIMER, &TIM_InitStruct); - - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_ENABLE; - TIM_OC_InitStruct.CompareValue = 127; - LL_TIM_OC_Init(FURI_HAL_SPEAKER_TIMER, FURI_HAL_SPEAKER_CHANNEL, &TIM_OC_InitStruct); -} - -void dtmf_dolphin_speaker_start() { - LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER); - LL_TIM_EnableCounter(FURI_HAL_SPEAKER_TIMER); -} - -void dtmf_dolphin_speaker_stop() { - LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER); - LL_TIM_DisableCounter(FURI_HAL_SPEAKER_TIMER); -} - -void dtmf_dolphin_dma_init(uint32_t address, size_t size) { - uint32_t dma_dst = (uint32_t) & (FURI_HAL_SPEAKER_TIMER->CCR1); - - LL_DMA_ConfigAddresses(DMA_INSTANCE, address, dma_dst, LL_DMA_DIRECTION_MEMORY_TO_PERIPH); - LL_DMA_SetDataLength(DMA_INSTANCE, size); - - LL_DMA_SetPeriphRequest(DMA_INSTANCE, LL_DMAMUX_REQ_TIM16_UP); - LL_DMA_SetDataTransferDirection(DMA_INSTANCE, LL_DMA_DIRECTION_MEMORY_TO_PERIPH); - LL_DMA_SetChannelPriorityLevel(DMA_INSTANCE, LL_DMA_PRIORITY_VERYHIGH); - LL_DMA_SetMode(DMA_INSTANCE, LL_DMA_MODE_CIRCULAR); - LL_DMA_SetPeriphIncMode(DMA_INSTANCE, LL_DMA_PERIPH_NOINCREMENT); - LL_DMA_SetMemoryIncMode(DMA_INSTANCE, LL_DMA_MEMORY_INCREMENT); - LL_DMA_SetPeriphSize(DMA_INSTANCE, LL_DMA_PDATAALIGN_HALFWORD); - LL_DMA_SetMemorySize(DMA_INSTANCE, LL_DMA_MDATAALIGN_HALFWORD); - - LL_DMA_EnableIT_TC(DMA_INSTANCE); - LL_DMA_EnableIT_HT(DMA_INSTANCE); -} - -void dtmf_dolphin_dma_start() { - LL_DMA_EnableChannel(DMA_INSTANCE); - LL_TIM_EnableDMAReq_UPDATE(FURI_HAL_SPEAKER_TIMER); -} - -void dtmf_dolphin_dma_stop() { - LL_DMA_DisableChannel(DMA_INSTANCE); -} diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.h b/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.h deleted file mode 100644 index 5b426f6a0..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_hal.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -#define FURI_HAL_SPEAKER_TIMER TIM16 -#define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1 -#define DMA_INSTANCE DMA1, LL_DMA_CHANNEL_1 - -#define DTMF_DOLPHIN_HAL_DMA_PRESCALER 4 -#define DTMF_DOLPHIN_HAL_DMA_AUTORELOAD 255 - -#ifdef __cplusplus -extern "C" { -#endif - -void dtmf_dolphin_speaker_init(); - -void dtmf_dolphin_speaker_start(); - -void dtmf_dolphin_speaker_stop(); - -void dtmf_dolphin_dma_init(uint32_t address, size_t size); - -void dtmf_dolphin_dma_start(); - -void dtmf_dolphin_dma_stop(); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/dtmf_dolphin_i.h b/applications/plugins/dtmf_dolphin/dtmf_dolphin_i.h deleted file mode 100644 index f8ae1530f..000000000 --- a/applications/plugins/dtmf_dolphin/dtmf_dolphin_i.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include "scenes/dtmf_dolphin_scene.h" - -#include -#include -#include -// #include -// #include -#include -#include -#include - -#include "dtmf_dolphin_event.h" - -#include "views/dtmf_dolphin_dialer.h" - -#define TAG "DTMFDolphin" - -enum DTMFDolphinSceneState { - DTMFDolphinSceneStateDialer, - DTMFDolphinSceneStateBluebox, - DTMFDolphinSceneStateRedboxUS, - DTMFDolphinSceneStateRedboxUK, - DTMFDolphinSceneStateRedboxCA, - DTMFDolphinSceneStateMisc, -}; - -typedef struct { - ViewDispatcher* view_dispatcher; - SceneManager* scene_manager; - VariableItemList* main_menu_list; - DTMFDolphinDialer* dtmf_dolphin_dialer; - - Gui* gui; - // ButtonPanel* dialer_button_panel; - // ButtonPanel* bluebox_button_panel; - // ButtonPanel* redbox_button_panel; - NotificationApp* notification; -} DTMFDolphinApp; - -typedef enum { DTMFDolphinViewMainMenu, DTMFDolphinViewDialer } DTMFDolphinView; diff --git a/applications/plugins/dtmf_dolphin/phone.png b/applications/plugins/dtmf_dolphin/phone.png deleted file mode 100644 index 443f847c3..000000000 Binary files a/applications/plugins/dtmf_dolphin/phone.png and /dev/null differ diff --git a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.c b/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.c deleted file mode 100644 index bfb8da1da..000000000 --- a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "dtmf_dolphin_scene.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const dtmf_dolphin_scene_on_enter_handlers[])(void*) = { -#include "dtmf_dolphin_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const dtmf_dolphin_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "dtmf_dolphin_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const dtmf_dolphin_scene_on_exit_handlers[])(void* context) = { -#include "dtmf_dolphin_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers dtmf_dolphin_scene_handlers = { - .on_enter_handlers = dtmf_dolphin_scene_on_enter_handlers, - .on_event_handlers = dtmf_dolphin_scene_on_event_handlers, - .on_exit_handlers = dtmf_dolphin_scene_on_exit_handlers, - .scene_num = DTMFDolphinSceneNum, -}; diff --git a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.h b/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.h deleted file mode 100644 index e45dc68ae..000000000 --- a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) DTMFDolphinScene##id, -typedef enum { -#include "dtmf_dolphin_scene_config.h" - DTMFDolphinSceneNum, -} DTMFDolphinScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers dtmf_dolphin_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "dtmf_dolphin_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "dtmf_dolphin_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "dtmf_dolphin_scene_config.h" -#undef ADD_SCENE diff --git a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_config.h b/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_config.h deleted file mode 100644 index b6dab07dc..000000000 --- a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_config.h +++ /dev/null @@ -1,2 +0,0 @@ -ADD_SCENE(dtmf_dolphin, start, Start) -ADD_SCENE(dtmf_dolphin, dialer, Dialer) \ No newline at end of file diff --git a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_dialer.c b/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_dialer.c deleted file mode 100644 index 06da595e0..000000000 --- a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_dialer.c +++ /dev/null @@ -1,49 +0,0 @@ -#include "../dtmf_dolphin_i.h" -// #include "../dtmf_dolphin_data.h" -// #include "../dtmf_dolphin_audio.h" - -void dtmf_dolphin_scene_dialer_on_enter(void* context) { - DTMFDolphinApp* app = context; - DTMFDolphinScene scene_id = DTMFDolphinSceneDialer; - enum DTMFDolphinSceneState state = scene_manager_get_scene_state(app->scene_manager, scene_id); - - switch(state) { - case DTMFDolphinSceneStateBluebox: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_BLUEBOX); - break; - case DTMFDolphinSceneStateRedboxUS: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_US); - break; - case DTMFDolphinSceneStateRedboxUK: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_UK); - break; - case DTMFDolphinSceneStateRedboxCA: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_REDBOX_CA); - break; - case DTMFDolphinSceneStateMisc: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_MISC); - break; - default: - dtmf_dolphin_data_set_current_section(DTMF_DOLPHIN_TONE_BLOCK_DIALER); - break; - } - - view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewDialer); -} - -bool dtmf_dolphin_scene_dialer_on_event(void* context, SceneManagerEvent event) { - DTMFDolphinApp* app = context; - UNUSED(app); - UNUSED(event); - bool consumed = false; - - // if(event.type == SceneManagerEventTypeTick) { - // consumed = true; - // } - - return consumed; -} - -void dtmf_dolphin_scene_dialer_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_start.c b/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_start.c deleted file mode 100644 index 484e9e8eb..000000000 --- a/applications/plugins/dtmf_dolphin/scenes/dtmf_dolphin_scene_start.c +++ /dev/null @@ -1,94 +0,0 @@ -#include "../dtmf_dolphin_i.h" - -static void dtmf_dolphin_scene_start_main_menu_enter_callback(void* context, uint32_t index) { - DTMFDolphinApp* app = context; - uint8_t cust_event = 255; - switch(index) { - case 0: - cust_event = DTMFDolphinEventStartDialer; - break; - case 1: - cust_event = DTMFDolphinEventStartBluebox; - break; - case 2: - cust_event = DTMFDolphinEventStartRedboxUS; - break; - case 3: - cust_event = DTMFDolphinEventStartRedboxUK; - break; - case 4: - cust_event = DTMFDolphinEventStartRedboxCA; - break; - case 5: - cust_event = DTMFDolphinEventStartMisc; - break; - default: - return; - } - - view_dispatcher_send_custom_event(app->view_dispatcher, cust_event); -} - -void dtmf_dolphin_scene_start_on_enter(void* context) { - DTMFDolphinApp* app = context; - VariableItemList* var_item_list = app->main_menu_list; - - // VariableItem* item; - variable_item_list_set_enter_callback( - var_item_list, dtmf_dolphin_scene_start_main_menu_enter_callback, app); - - variable_item_list_add(var_item_list, "Dialer", 0, NULL, context); - variable_item_list_add(var_item_list, "Bluebox", 0, NULL, context); - variable_item_list_add(var_item_list, "Redbox (US)", 0, NULL, context); - variable_item_list_add(var_item_list, "Redbox (UK)", 0, NULL, context); - variable_item_list_add(var_item_list, "Redbox (CA)", 0, NULL, context); - variable_item_list_add(var_item_list, "Misc", 0, NULL, context); - - variable_item_list_set_selected_item( - var_item_list, scene_manager_get_scene_state(app->scene_manager, DTMFDolphinSceneStart)); - - view_dispatcher_switch_to_view(app->view_dispatcher, DTMFDolphinViewMainMenu); -} - -bool dtmf_dolphin_scene_start_on_event(void* context, SceneManagerEvent event) { - DTMFDolphinApp* app = context; - UNUSED(app); - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - uint8_t sc_state; - - switch(event.event) { - case DTMFDolphinEventStartDialer: - sc_state = DTMFDolphinSceneStateDialer; - break; - case DTMFDolphinEventStartBluebox: - sc_state = DTMFDolphinSceneStateBluebox; - break; - case DTMFDolphinEventStartRedboxUS: - sc_state = DTMFDolphinSceneStateRedboxUS; - break; - case DTMFDolphinEventStartRedboxUK: - sc_state = DTMFDolphinSceneStateRedboxUK; - break; - case DTMFDolphinEventStartRedboxCA: - sc_state = DTMFDolphinSceneStateRedboxCA; - break; - case DTMFDolphinEventStartMisc: - sc_state = DTMFDolphinSceneStateMisc; - break; - default: - return consumed; - } - scene_manager_set_scene_state(app->scene_manager, DTMFDolphinSceneDialer, sc_state); - scene_manager_next_scene(app->scene_manager, DTMFDolphinSceneDialer); - - consumed = true; - } - return consumed; -} - -void dtmf_dolphin_scene_start_on_exit(void* context) { - DTMFDolphinApp* app = context; - variable_item_list_reset(app->main_menu_list); -} diff --git a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_common.h b/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_common.h deleted file mode 100644 index f2f4838d6..000000000 --- a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_common.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "../dtmf_dolphin_event.h" -#include "../dtmf_dolphin_data.h" -#include "../dtmf_dolphin_audio.h" - -#define DTMF_DOLPHIN_NUMPAD_X 1 -#define DTMF_DOLPHIN_NUMPAD_Y 14 -#define DTMF_DOLPHIN_BUTTON_WIDTH 13 -#define DTMF_DOLPHIN_BUTTON_HEIGHT 13 -#define DTMF_DOLPHIN_BUTTON_PADDING 1 // all sides diff --git a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.c b/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.c deleted file mode 100644 index bdffa2313..000000000 --- a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.c +++ /dev/null @@ -1,350 +0,0 @@ -#include "dtmf_dolphin_dialer.h" - -#include - -typedef struct DTMFDolphinDialer { - View* view; - DTMFDolphinDialerOkCallback callback; - void* context; -} DTMFDolphinDialer; - -typedef struct { - DTMFDolphinToneSection section; - uint8_t row; - uint8_t col; - float freq1; - float freq2; - bool playing; - uint16_t pulses; - uint16_t pulse_ms; - uint16_t gap_ms; -} DTMFDolphinDialerModel; - -static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer); -static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dialer); -static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer); -static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_dialer); -static bool - dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_dialer, InputEvent* event); - -void draw_button(Canvas* canvas, uint8_t row, uint8_t col, bool invert) { - uint8_t left = DTMF_DOLPHIN_NUMPAD_X + // ((col + 1) * DTMF_DOLPHIN_BUTTON_PADDING) + - (col * DTMF_DOLPHIN_BUTTON_WIDTH); - // (col * DTMF_DOLPHIN_BUTTON_PADDING); - uint8_t top = DTMF_DOLPHIN_NUMPAD_Y + // ((row + 1) * DTMF_DOLPHIN_BUTTON_PADDING) + - (row * DTMF_DOLPHIN_BUTTON_HEIGHT); - // (row * DTMF_DOLPHIN_BUTTON_PADDING); - - uint8_t span = dtmf_dolphin_get_tone_span(row, col); - - if(span == 0) { - return; - } - - canvas_set_color(canvas, ColorBlack); - - if(invert) - canvas_draw_rbox( - canvas, - left, - top, - (DTMF_DOLPHIN_BUTTON_WIDTH * span) - (DTMF_DOLPHIN_BUTTON_PADDING * 2), - DTMF_DOLPHIN_BUTTON_HEIGHT - (DTMF_DOLPHIN_BUTTON_PADDING * 2), - 2); - else - canvas_draw_rframe( - canvas, - left, - top, - (DTMF_DOLPHIN_BUTTON_WIDTH * span) - (DTMF_DOLPHIN_BUTTON_PADDING * 2), - DTMF_DOLPHIN_BUTTON_HEIGHT - (DTMF_DOLPHIN_BUTTON_PADDING * 2), - 2); - - if(invert) canvas_invert_color(canvas); - - canvas_set_font(canvas, FontSecondary); - // canvas_set_color(canvas, invert ? ColorWhite : ColorBlack); - canvas_draw_str_aligned( - canvas, - left - 1 + (int)((DTMF_DOLPHIN_BUTTON_WIDTH * span) / 2), - top + (int)(DTMF_DOLPHIN_BUTTON_HEIGHT / 2), - AlignCenter, - AlignCenter, - dtmf_dolphin_data_get_tone_name(row, col)); - - if(invert) canvas_invert_color(canvas); -} - -void draw_dialer(Canvas* canvas, void* _model) { - DTMFDolphinDialerModel* model = _model; - uint8_t max_rows; - uint8_t max_cols; - uint8_t max_span; - dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span); - - canvas_set_font(canvas, FontSecondary); - - for(int r = 0; r < max_rows; r++) { - for(int c = 0; c < max_cols; c++) { - if(model->row == r && model->col == c) - draw_button(canvas, r, c, true); - else - draw_button(canvas, r, c, false); - } - } -} - -void update_frequencies(DTMFDolphinDialerModel* model) { - dtmf_dolphin_data_get_tone_frequencies(&model->freq1, &model->freq2, model->row, model->col); - dtmf_dolphin_data_get_filter_data( - &model->pulses, &model->pulse_ms, &model->gap_ms, model->row, model->col); -} - -static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) { - DTMFDolphinDialerModel* model = _model; - if(model->playing) { - // Leverage the prioritized draw callback to handle - // the DMA so that it doesn't skip. - dtmf_dolphin_audio_handle_tick(); - // Don't do any drawing if audio is playing. - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned( - canvas, - canvas_width(canvas) / 2, - canvas_height(canvas) / 2, - AlignCenter, - AlignCenter, - "Playing Tones"); - return; - } - update_frequencies(model); - uint8_t max_rows = 0; - uint8_t max_cols = 0; - uint8_t max_span = 0; - dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span); - - canvas_set_font(canvas, FontPrimary); - elements_multiline_text(canvas, 2, 10, dtmf_dolphin_data_get_current_section_name()); - canvas_draw_line( - canvas, - (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 1, - 0, - (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 1, - canvas_height(canvas)); - elements_multiline_text(canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 10, "Detail"); - canvas_draw_line( - canvas, 0, DTMF_DOLPHIN_NUMPAD_Y - 3, canvas_width(canvas), DTMF_DOLPHIN_NUMPAD_Y - 3); - // elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Dialer Mode"); - - draw_dialer(canvas, model); - - FuriString* output = furi_string_alloc(); - - if(model->freq1 && model->freq2) { - furi_string_cat_printf( - output, - "Dual Tone\nF1: %u Hz\nF2: %u Hz\n", - (unsigned int)model->freq1, - (unsigned int)model->freq2); - } else if(model->freq1) { - furi_string_cat_printf(output, "Single Tone\nF: %u Hz\n", (unsigned int)model->freq1); - } - - canvas_set_font(canvas, FontSecondary); - canvas_set_color(canvas, ColorBlack); - if(model->pulse_ms) { - furi_string_cat_printf(output, "P: %u * %u ms\n", model->pulses, model->pulse_ms); - } - if(model->gap_ms) { - furi_string_cat_printf(output, "Gaps: %u ms\n", model->gap_ms); - } - elements_multiline_text( - canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 21, furi_string_get_cstr(output)); - - furi_string_free(output); -} - -static bool dtmf_dolphin_dialer_input_callback(InputEvent* event, void* context) { - furi_assert(context); - DTMFDolphinDialer* dtmf_dolphin_dialer = context; - bool consumed = false; - - if(event->type == InputTypeShort) { - if(event->key == InputKeyRight) { - consumed = dtmf_dolphin_dialer_process_right(dtmf_dolphin_dialer); - } else if(event->key == InputKeyLeft) { - consumed = dtmf_dolphin_dialer_process_left(dtmf_dolphin_dialer); - } else if(event->key == InputKeyUp) { - consumed = dtmf_dolphin_dialer_process_up(dtmf_dolphin_dialer); - } else if(event->key == InputKeyDown) { - consumed = dtmf_dolphin_dialer_process_down(dtmf_dolphin_dialer); - } - - } else if(event->key == InputKeyOk) { - consumed = dtmf_dolphin_dialer_process_ok(dtmf_dolphin_dialer, event); - } - - return consumed; -} - -static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer) { - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - uint8_t span = 0; - uint8_t cursor = model->row; - while(span == 0 && cursor > 0) { - cursor--; - span = dtmf_dolphin_get_tone_span(cursor, model->col); - } - if(span != 0) { - model->row = cursor; - } - }, - true); - return true; -} - -static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dialer) { - uint8_t max_rows = 0; - uint8_t max_cols = 0; - uint8_t max_span = 0; - dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span); - - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - uint8_t span = 0; - uint8_t cursor = model->row; - while(span == 0 && cursor < max_rows - 1) { - cursor++; - span = dtmf_dolphin_get_tone_span(cursor, model->col); - } - if(span != 0) { - model->row = cursor; - } - }, - true); - return true; -} - -static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer) { - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - uint8_t span = 0; - uint8_t cursor = model->col; - while(span == 0 && cursor > 0) { - cursor--; - span = dtmf_dolphin_get_tone_span(model->row, cursor); - } - if(span != 0) { - model->col = cursor; - } - }, - true); - return true; -} - -static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_dialer) { - uint8_t max_rows = 0; - uint8_t max_cols = 0; - uint8_t max_span = 0; - dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span); - - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - uint8_t span = 0; - uint8_t cursor = model->col; - while(span == 0 && cursor < max_cols - 1) { - cursor++; - span = dtmf_dolphin_get_tone_span(model->row, cursor); - } - if(span != 0) { - model->col = cursor; - } - }, - true); - return true; -} - -static bool - dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_dialer, InputEvent* event) { - bool consumed = false; - - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - if(event->type == InputTypePress) { - model->playing = dtmf_dolphin_audio_play_tones( - model->freq1, model->freq2, model->pulses, model->pulse_ms, model->gap_ms); - } else if(event->type == InputTypeRelease) { - model->playing = !dtmf_dolphin_audio_stop_tones(); - } - }, - true); - - return consumed; -} - -static void dtmf_dolphin_dialer_enter_callback(void* context) { - furi_assert(context); - DTMFDolphinDialer* dtmf_dolphin_dialer = context; - - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - model->col = 0; - model->row = 0; - model->section = 0; - model->freq1 = 0.0; - model->freq2 = 0.0; - model->playing = false; - }, - true); -} - -DTMFDolphinDialer* dtmf_dolphin_dialer_alloc() { - DTMFDolphinDialer* dtmf_dolphin_dialer = malloc(sizeof(DTMFDolphinDialer)); - - dtmf_dolphin_dialer->view = view_alloc(); - view_allocate_model( - dtmf_dolphin_dialer->view, ViewModelTypeLocking, sizeof(DTMFDolphinDialerModel)); - - with_view_model( - dtmf_dolphin_dialer->view, - DTMFDolphinDialerModel * model, - { - model->col = 0; - model->row = 0; - model->section = 0; - model->freq1 = 0.0; - model->freq2 = 0.0; - model->playing = false; - }, - true); - - view_set_context(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer); - view_set_draw_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_draw_callback); - view_set_input_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_input_callback); - view_set_enter_callback(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer_enter_callback); - return dtmf_dolphin_dialer; -} - -void dtmf_dolphin_dialer_free(DTMFDolphinDialer* dtmf_dolphin_dialer) { - furi_assert(dtmf_dolphin_dialer); - view_free(dtmf_dolphin_dialer->view); - free(dtmf_dolphin_dialer); -} - -View* dtmf_dolphin_dialer_get_view(DTMFDolphinDialer* dtmf_dolphin_dialer) { - furi_assert(dtmf_dolphin_dialer); - return dtmf_dolphin_dialer->view; -} diff --git a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.h b/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.h deleted file mode 100644 index 1929afbc5..000000000 --- a/applications/plugins/dtmf_dolphin/views/dtmf_dolphin_dialer.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include "dtmf_dolphin_common.h" - -typedef struct DTMFDolphinDialer DTMFDolphinDialer; -typedef void (*DTMFDolphinDialerOkCallback)(InputType type, void* context); - -DTMFDolphinDialer* dtmf_dolphin_dialer_alloc(); - -void dtmf_dolphin_dialer_free(DTMFDolphinDialer* dtmf_dolphin_dialer); - -View* dtmf_dolphin_dialer_get_view(DTMFDolphinDialer* dtmf_dolphin_dialer); - -void dtmf_dolphin_dialer_set_ok_callback( - DTMFDolphinDialer* dtmf_dolphin_dialer, - DTMFDolphinDialerOkCallback callback, - void* context); diff --git a/applications/plugins/flashlight/LICENSE b/applications/plugins/flashlight/LICENSE deleted file mode 100644 index 28d693a7c..000000000 --- a/applications/plugins/flashlight/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 MX - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/flashlight/README.md b/applications/plugins/flashlight/README.md deleted file mode 100644 index a40cb2d5a..000000000 --- a/applications/plugins/flashlight/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Flashlight Plugin for Flipper Zero - -Simple Flashlight special for @Svaarich by @xMasterX - -Enables 3.3v on pin 7/C3 and leaves it on when you exit app - -**Connect LED to (+ -> 7/C3) | (GND -> GND)** diff --git a/applications/plugins/flashlight/application.fam b/applications/plugins/flashlight/application.fam deleted file mode 100644 index d6d5aa791..000000000 --- a/applications/plugins/flashlight/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="Flashlight", - name="Flashlight", - apptype=FlipperAppType.EXTERNAL, - entry_point="flashlight_app", - cdefines=["APP_FLASHLIGHT"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=20, - fap_icon="flash10px.png", - fap_category="GPIO", -) \ No newline at end of file diff --git a/applications/plugins/flashlight/flash10px.png b/applications/plugins/flashlight/flash10px.png deleted file mode 100644 index 963a9ab5f..000000000 Binary files a/applications/plugins/flashlight/flash10px.png and /dev/null differ diff --git a/applications/plugins/flashlight/flashlight.c b/applications/plugins/flashlight/flashlight.c deleted file mode 100644 index 9c5f600f7..000000000 --- a/applications/plugins/flashlight/flashlight.c +++ /dev/null @@ -1,130 +0,0 @@ -// by @xMasterX - -#include -#include -#include -#include -#include -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - bool is_on; -} PluginState; - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, 64, 2, AlignCenter, AlignTop, "Flashlight"); - - canvas_set_font(canvas, FontSecondary); - - if(!plugin_state->is_on) { - elements_multiline_text_aligned( - canvas, 64, 28, AlignCenter, AlignTop, "Press OK button turn on"); - } else { - elements_multiline_text_aligned(canvas, 64, 28, AlignCenter, AlignTop, "Light is on!"); - elements_multiline_text_aligned( - canvas, 64, 40, AlignCenter, AlignTop, "Press OK button to off"); - } - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void flash_toggle(PluginState* const plugin_state) { - furi_hal_gpio_write(&gpio_ext_pc3, false); - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - - if(plugin_state->is_on) { - furi_hal_gpio_write(&gpio_ext_pc3, false); - plugin_state->is_on = false; - } else { - furi_hal_gpio_write(&gpio_ext_pc3, true); - plugin_state->is_on = true; - } -} - -int32_t flashlight_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - PluginState* plugin_state = malloc(sizeof(PluginState)); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - FURI_LOG_E("flashlight", "cannot create mutex\r\n"); - furi_message_queue_free(event_queue); - free(plugin_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - case InputKeyDown: - case InputKeyRight: - case InputKeyLeft: - break; - case InputKeyOk: - flash_toggle(plugin_state); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/game15/README.md b/applications/plugins/game15/README.md deleted file mode 100644 index b1710c919..000000000 --- a/applications/plugins/game15/README.md +++ /dev/null @@ -1,13 +0,0 @@ - -# Game "15" for Flipper Zero - -[Original link](https://github.com/x27/flipperzero-game15) - -Logic game [Wikipedia](https://en.wikipedia.org/wiki/15_puzzle) - -![Game screen](images/Game15.png) - -![Restore game](images/Game15Restore.png) - -![Popoup](images/Game15Popup.png) - diff --git a/applications/plugins/game15/application.fam b/applications/plugins/game15/application.fam deleted file mode 100644 index dc3a0da0b..000000000 --- a/applications/plugins/game15/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="Game15", - name="Game 15", - apptype=FlipperAppType.EXTERNAL, - entry_point="game15_app", - cdefines=["APP_GAME15"], - requires=["gui"], - stack_size=1 * 1024, - fap_icon="game15_10px.png", - order=30, - fap_category="Games", -) diff --git a/applications/plugins/game15/game15.c b/applications/plugins/game15/game15.c deleted file mode 100644 index d9b059466..000000000 --- a/applications/plugins/game15/game15.c +++ /dev/null @@ -1,468 +0,0 @@ -#include -#include -#include -#include -#include - -#include "sandbox.h" - -#define FPS 20 -#define CELL_WIDTH 10 -#define CELL_HEIGHT 8 -#define MOVE_TICKS 5 -#define KEY_STACK_SIZE 16 -#define SAVING_DIRECTORY "/ext/apps/Games" -#define SAVING_FILENAME SAVING_DIRECTORY "/game15.save" -#define POPUP_MENU_ITEMS 2 - -typedef enum { - DirectionNone, - DirectionUp, - DirectionDown, - DirectionLeft, - DirectionRight -} direction_e; - -typedef enum { ScenePlay, SceneWin, ScenePopup } scene_e; - -typedef struct { - uint8_t cell_index; - uint8_t zero_index; - uint8_t move_direction; - uint8_t move_ticks; -} moving_cell_t; - -typedef struct { - uint16_t top_record; - scene_e scene; - uint16_t move_count; - uint32_t tick_count; - uint8_t board[16]; -} game_state_t; - -static game_state_t game_state; -static NotificationApp* notification; -static moving_cell_t moving_cell; -static uint8_t loaded_saving_ticks; -static uint8_t popup_menu_selected_item; - -static const char* popup_menu_strings[] = {"Continue", "Reset"}; - -static uint8_t keys[KEY_STACK_SIZE]; -static uint8_t key_stack_head = 0; - -static const uint8_t pic_cells[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x30, 0xfc, 0x38, 0xfc, 0x30, 0xfc, 0x30, 0xfc, 0x30, 0xfc, 0x30, 0xfc, 0x30, 0xfc, 0x30, 0xfc, - 0x78, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x60, 0xfc, 0x30, 0xfc, 0x18, 0xfc, 0x0c, 0xfc, 0xfc, 0xfc, - 0x78, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x60, 0xfc, 0xc0, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x78, 0xfc, - 0x70, 0xfc, 0x78, 0xfc, 0x68, 0xfc, 0x6c, 0xfc, 0x6c, 0xfc, 0xec, 0xfc, 0xfc, 0xfc, 0x60, 0xfc, - 0xfc, 0xfc, 0x0c, 0xfc, 0x0c, 0xfc, 0x7c, 0xfc, 0xc0, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x78, 0xfc, - 0x78, 0xfc, 0x0c, 0xfc, 0x0c, 0xfc, 0x7c, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x78, 0xfc, - 0xfc, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, - 0x78, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x78, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0x78, 0xfc, - 0x78, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0xcc, 0xfc, 0xf8, 0xfc, 0xc0, 0xfc, 0xc0, 0xfc, 0x78, 0xfc, - 0xe6, 0xfd, 0x37, 0xff, 0x36, 0xff, 0x36, 0xff, 0x36, 0xff, 0x36, 0xff, 0x36, 0xff, 0xe6, 0xfd, - 0x8c, 0xfd, 0xce, 0xfd, 0x8c, 0xfd, 0x8c, 0xfd, 0x8c, 0xfd, 0x8c, 0xfd, 0x8c, 0xfd, 0x8c, 0xfd, - 0xe6, 0xfd, 0x37, 0xff, 0x36, 0xff, 0x86, 0xfd, 0xc6, 0xfc, 0x66, 0xfc, 0x36, 0xfc, 0xf6, 0xff, - 0xe6, 0xfd, 0x37, 0xff, 0x36, 0xff, 0x86, 0xfd, 0x06, 0xff, 0x36, 0xff, 0x36, 0xff, 0xe6, 0xfd, - 0xc6, 0xfd, 0xe7, 0xfd, 0xa6, 0xfd, 0xb6, 0xfd, 0xb6, 0xfd, 0xb6, 0xff, 0xf6, 0xff, 0x86, 0xfd, - 0xf6, 0xff, 0x37, 0xfc, 0x36, 0xfc, 0xf6, 0xfd, 0x06, 0xff, 0x36, 0xff, 0x36, 0xff, 0xe6, 0xfd, -}; - -static const uint8_t pic_digits[] = { - 0xf0, 0xf2, 0xf2, 0xf2, 0xf2, 0xf0, 0xf9, 0xf8, 0xf9, 0xf9, 0xf9, 0xf0, 0xf0, 0xf2, 0xf3, - 0xf1, 0xfc, 0xf0, 0xf0, 0xf3, 0xf1, 0xf3, 0xf2, 0xf0, 0xf3, 0xf1, 0xf2, 0xf2, 0xf0, 0xf3, - 0xf0, 0xfc, 0xf0, 0xf3, 0xf2, 0xf0, 0x00, 0x0c, 0x00, 0x02, 0x02, 0x00, 0x00, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x00, 0x03, 0x03, 0x00, -}; - -static const uint8_t pic_top[] = {11, 4, 0x88, 0xf8, 0xad, 0xfa, 0xad, 0xf8, 0x8d, 0xfe}; -static const uint8_t pic_move[] = - {17, 4, 0x2e, 0x2a, 0xfe, 0xa4, 0xaa, 0xff, 0xaa, 0x2a, 0xff, 0x2e, 0x36, 0xfe}; -static const uint8_t pic_time[] = {15, 4, 0xa8, 0x8b, 0x2d, 0xe9, 0xad, 0xca, 0xad, 0x8b}; - -static const uint8_t pic_puzzled[] = { - 0xff, 0xcf, 0x00, 0xf3, 0xff, 0xfc, 0x3f, 0x03, 0xc0, 0xff, 0xf3, 0x0f, 0xdc, 0xff, 0xcf, - 0x00, 0xf3, 0xff, 0xfc, 0x3f, 0x03, 0xc0, 0xff, 0xf3, 0x0f, 0xdc, 0x03, 0xcc, 0x00, 0x03, - 0x38, 0x00, 0x0e, 0x03, 0xc0, 0x00, 0x30, 0x30, 0xdc, 0x03, 0xcc, 0x00, 0x03, 0x1c, 0x00, - 0x07, 0x03, 0xc0, 0x00, 0x30, 0x30, 0xdc, 0xff, 0xcf, 0x00, 0x03, 0x0e, 0x80, 0x03, 0x03, - 0xc0, 0xff, 0x33, 0xc0, 0xdc, 0xff, 0xcf, 0x00, 0x03, 0x07, 0xc0, 0x01, 0x03, 0xc0, 0xff, - 0x33, 0xc0, 0xdc, 0x03, 0xc0, 0x00, 0x83, 0x03, 0xe0, 0x00, 0x03, 0xc0, 0x00, 0x30, 0xc0, - 0xd0, 0x03, 0xc0, 0x00, 0xc3, 0x01, 0x70, 0x00, 0x03, 0xc0, 0x00, 0x30, 0xc0, 0xd0, 0x03, - 0xc0, 0xff, 0xf3, 0xff, 0xfc, 0x3f, 0xff, 0xcf, 0xff, 0xf3, 0xff, 0xdc, 0x03, 0xc0, 0xff, - 0xf3, 0xff, 0xfc, 0x3f, 0xff, 0xcf, 0xff, 0xf3, 0xff, 0xdc}; - -static void key_stack_init() { - key_stack_head = 0; -} - -static uint8_t key_stack_pop() { - return keys[--key_stack_head]; -} - -static bool key_stack_is_empty() { - return key_stack_head == 0; -} - -static int key_stack_push(uint8_t value) { - if(key_stack_head != KEY_STACK_SIZE) { - keys[key_stack_head] = value; - key_stack_head++; - return key_stack_head; - } else - return -1; -} - -static bool storage_game_state_load() { - Storage* storage = furi_record_open(RECORD_STORAGE); - File* file = storage_file_alloc(storage); - - uint16_t bytes_readed = 0; - if(storage_file_open(file, SAVING_FILENAME, FSAM_READ, FSOM_OPEN_EXISTING)) - bytes_readed = storage_file_read(file, &game_state, sizeof(game_state_t)); - storage_file_close(file); - storage_file_free(file); - furi_record_close(RECORD_STORAGE); - return bytes_readed == sizeof(game_state_t); -} - -static void storage_game_state_save() { - Storage* storage = furi_record_open(RECORD_STORAGE); - - if(storage_common_stat(storage, SAVING_DIRECTORY, NULL) == FSE_NOT_EXIST) { - if(!storage_simply_mkdir(storage, SAVING_DIRECTORY)) { - return; - } - } - - File* file = storage_file_alloc(storage); - if(storage_file_open(file, SAVING_FILENAME, FSAM_WRITE, FSOM_CREATE_ALWAYS)) { - storage_file_write(file, &game_state, sizeof(game_state_t)); - } - storage_file_close(file); - storage_file_free(file); - furi_record_close(RECORD_STORAGE); -} - -static void set_moving_cell_by_direction(direction_e direction) { - moving_cell.move_direction = DirectionNone; - moving_cell.zero_index = 0xff; - - for(int i = 0; i < 16; i++) { - if(!game_state.board[i]) { - moving_cell.zero_index = i; - break; - } - } - if(moving_cell.zero_index == 0xff) return; - - uint8_t x = moving_cell.zero_index % 4; - uint8_t y = moving_cell.zero_index / 4; - - moving_cell.cell_index = moving_cell.zero_index; - - if(direction == DirectionUp && y < 3) - moving_cell.cell_index += 4; - else if(direction == DirectionDown && y > 0) - moving_cell.cell_index -= 4; - else if(direction == DirectionLeft && x < 3) - moving_cell.cell_index++; - else if(direction == DirectionRight && x > 0) - moving_cell.cell_index--; - else - return; - - moving_cell.move_ticks = 0; - moving_cell.move_direction = direction; -} - -static bool is_board_has_solution() { - uint8_t i, j, inv = 0; - for(i = 0; i < 16; ++i) - if(game_state.board[i]) - for(j = 0; j < i; ++j) - if(game_state.board[j] > game_state.board[i]) ++inv; - for(i = 0; i < 16; ++i) - if(game_state.board[i] == 0) inv += 1 + i / 4; - - return inv % 2 == 0; -} - -static void board_init() { - for(int i = 0; i < 16; i++) { - game_state.board[i] = (i + 1) % 16; - } - - do { - for(int i = 15; i >= 1; i--) { - int j = rand() % (i + 1); - uint8_t tmp = game_state.board[j]; - game_state.board[j] = game_state.board[i]; - game_state.board[i] = tmp; - } - } while(!is_board_has_solution()); -} - -static void game_init() { - game_state.scene = ScenePlay; - game_state.move_count = 0; - game_state.tick_count = 0; - moving_cell.move_direction = DirectionNone; - board_init(); - key_stack_init(); - popup_menu_selected_item = 0; -} - -static bool is_board_solved() { - for(int i = 0; i < 16; i++) - if(((i + 1) % 16) != game_state.board[i]) return false; - return true; -} - -static void game_tick() { - switch(game_state.scene) { - case ScenePlay: - game_state.tick_count++; - if(loaded_saving_ticks) loaded_saving_ticks--; - if(moving_cell.move_direction == DirectionNone && !key_stack_is_empty()) { - set_moving_cell_by_direction(key_stack_pop()); - if(moving_cell.move_direction == DirectionNone) { - notification_message(notification, &sequence_single_vibro); - key_stack_init(); - } - } - - if(moving_cell.move_direction != DirectionNone) { - moving_cell.move_ticks++; - if(moving_cell.move_ticks == MOVE_TICKS) { - game_state.board[moving_cell.zero_index] = - game_state.board[moving_cell.cell_index]; - game_state.board[moving_cell.cell_index] = 0; - moving_cell.move_direction = DirectionNone; - game_state.move_count++; - } - if(is_board_solved()) { - notification_message(notification, &sequence_double_vibro); - if(game_state.move_count < game_state.top_record || game_state.top_record == 0) { - game_state.top_record = game_state.move_count; - storage_game_state_save(); - } - game_state.scene = SceneWin; - } - } - break; - - case SceneWin: - if(!key_stack_is_empty()) game_init(); - break; - - case ScenePopup: - if(!key_stack_is_empty()) { - switch(key_stack_pop()) { - case DirectionDown: - popup_menu_selected_item++; - popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; - break; - case DirectionUp: - popup_menu_selected_item--; - popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; - break; - case DirectionNone: - if(popup_menu_selected_item == 0) { - game_state.scene = ScenePlay; - notification_message(notification, &sequence_single_vibro); - } else if(popup_menu_selected_item == 1) { - notification_message(notification, &sequence_single_vibro); - game_init(); - } - break; - } - } - break; - } -} - -static void draw_cell(Canvas* canvas, uint8_t x, uint8_t y, uint8_t cell_number) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, x, y, 18, 14, 1); - canvas_set_color(canvas, ColorBlack); - canvas_draw_xbm(canvas, x + 4, y + 3, CELL_WIDTH, CELL_HEIGHT, pic_cells + cell_number * 16); -} - -static void board_draw(Canvas* canvas) { - for(int i = 0; i < 16; i++) { - if(game_state.board[i]) { - if(moving_cell.move_direction == DirectionNone || moving_cell.cell_index != i) - draw_cell(canvas, (i % 4) * 20 + 7, (i / 4) * 16 + 1, game_state.board[i]); - if(moving_cell.move_direction != DirectionNone && moving_cell.cell_index == i) { - uint8_t from_x = (moving_cell.cell_index % 4) * 20 + 7; - uint8_t from_y = (moving_cell.cell_index / 4) * 16 + 1; - uint8_t to_x = (moving_cell.zero_index % 4) * 20 + 7; - uint8_t to_y = (moving_cell.zero_index / 4) * 16 + 1; - int now_x = from_x + (to_x - from_x) * moving_cell.move_ticks / MOVE_TICKS; - int now_y = from_y + (to_y - from_y) * moving_cell.move_ticks / MOVE_TICKS; - draw_cell(canvas, now_x, now_y, game_state.board[i]); - } - } - } -} - -static void number_draw(Canvas* canvas, uint8_t y, uint32_t value) { - uint8_t x = 121; - while(true) { - uint8_t digit = value % 10; - canvas_draw_xbm(canvas, x, y, 4, 6, pic_digits + digit * 6); - x -= 5; - value = value / 10; - if(!value) break; - } -} - -static void plate_draw( - Canvas* canvas, - uint8_t y, - const uint8_t* header, - uint32_t value, - bool dont_draw_zero_value) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_rbox(canvas, 92, y, 35, 19, 2); - canvas_set_color(canvas, ColorBlack); - canvas_draw_xbm(canvas, 95, y + 3, header[0], header[1], &header[2]); - if((!value && !dont_draw_zero_value) || value) number_draw(canvas, y + 10, value); -} - -static void info_draw(Canvas* canvas) { - plate_draw(canvas, 1, pic_top, game_state.top_record, true); - plate_draw(canvas, 22, pic_move, game_state.move_count, false); - plate_draw(canvas, 43, pic_time, game_state.tick_count / FPS, false); -} - -static void gray_screen(Canvas* const canvas) { - canvas_set_color(canvas, ColorWhite); - for(int x = 0; x < 128; x += 2) { - for(int y = 0; y < 64; y++) { - canvas_draw_dot(canvas, x + (y % 2 == 1 ? 0 : 1), y); - } - } -} - -static void render_callback(Canvas* const canvas) { - canvas_set_color(canvas, ColorWhite); - canvas_draw_box(canvas, 0, 0, 128, 64); - - if(game_state.scene == ScenePlay || game_state.scene == SceneWin || - game_state.scene == ScenePopup) { - canvas_set_color(canvas, ColorBlack); - board_draw(canvas); - info_draw(canvas); - - if(loaded_saving_ticks && game_state.scene != ScenePopup) { - canvas_set_color(canvas, ColorWhite); - canvas_draw_rbox(canvas, 20, 24, 88, 16, 4); - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 20, 24, 88, 16, 4); - canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "Restore game ..."); - } - } - - if(game_state.scene == SceneWin) { - gray_screen(canvas); - canvas_draw_box(canvas, 7, 20, 114, 24); - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 8, 21, 112, 22); - canvas_set_color(canvas, ColorWhite); - canvas_draw_box(canvas, 10, 23, 108, 18); - canvas_set_color(canvas, ColorBlack); - canvas_draw_xbm(canvas, 14, 27, 100, 10, pic_puzzled); - } else if(game_state.scene == ScenePopup) { - gray_screen(canvas); - canvas_set_color(canvas, ColorWhite); - canvas_draw_rbox(canvas, 28, 16, 72, 32, 4); - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 28, 16, 72, 32, 4); - - for(int i = 0; i < POPUP_MENU_ITEMS; i++) { - if(i == popup_menu_selected_item) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 34, 20 + 12 * i, 60, 12); - } - - canvas_set_color(canvas, i == popup_menu_selected_item ? ColorWhite : ColorBlack); - canvas_draw_str_aligned( - canvas, 64, 26 + 12 * i, AlignCenter, AlignCenter, popup_menu_strings[i]); - } - } -} - -static void game_event_handler(GameEvent const event) { - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - key_stack_push(DirectionUp); - break; - case InputKeyDown: - key_stack_push(DirectionDown); - break; - case InputKeyRight: - key_stack_push(DirectionRight); - break; - case InputKeyLeft: - key_stack_push(DirectionLeft); - break; - case InputKeyOk: - if(game_state.scene == ScenePlay) { - game_state.scene = ScenePopup; - key_stack_init(); - } else - key_stack_push(DirectionNone); - break; - case InputKeyBack: - if(game_state.scene == ScenePopup) { - game_state.scene = ScenePlay; - } else { - storage_game_state_save(); - sandbox_loop_exit(); - } - break; - default: - break; - } - } - } else if(event.type == EventTypeTick) { - game_tick(); - } -} - -static void game_alloc() { - key_stack_init(); - notification = furi_record_open(RECORD_NOTIFICATION); - notification_message_block(notification, &sequence_display_backlight_enforce_on); -} - -static void game_free() { - notification_message_block(notification, &sequence_display_backlight_enforce_auto); - furi_record_close(RECORD_NOTIFICATION); -} - -int32_t game15_app() { - game_alloc(); - game_init(); - - loaded_saving_ticks = 0; - if(storage_game_state_load()) { - if(game_state.scene != ScenePlay) - game_init(); - else - loaded_saving_ticks = FPS; - } else - game_init(); - - sandbox_init( - FPS, (SandboxRenderCallback)render_callback, (SandboxEventHandler)game_event_handler); - sandbox_loop(); - sandbox_free(); - game_free(); - return 0; -} diff --git a/applications/plugins/game15/game15_10px.png b/applications/plugins/game15/game15_10px.png deleted file mode 100644 index 16c4f1038..000000000 Binary files a/applications/plugins/game15/game15_10px.png and /dev/null differ diff --git a/applications/plugins/game15/images/Game15.png b/applications/plugins/game15/images/Game15.png deleted file mode 100644 index f13c2907b..000000000 Binary files a/applications/plugins/game15/images/Game15.png and /dev/null differ diff --git a/applications/plugins/game15/images/Game15Popup.png b/applications/plugins/game15/images/Game15Popup.png deleted file mode 100644 index 1df14729f..000000000 Binary files a/applications/plugins/game15/images/Game15Popup.png and /dev/null differ diff --git a/applications/plugins/game15/images/Game15Restore.png b/applications/plugins/game15/images/Game15Restore.png deleted file mode 100644 index 05aac27f6..000000000 Binary files a/applications/plugins/game15/images/Game15Restore.png and /dev/null differ diff --git a/applications/plugins/game15/sandbox.c b/applications/plugins/game15/sandbox.c deleted file mode 100644 index e3b759fc8..000000000 --- a/applications/plugins/game15/sandbox.c +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include -#include "sandbox.h" - -FuriMessageQueue* sandbox_event_queue; -FuriMutex** sandbox_mutex; -ViewPort* sandbox_view_port; -Gui* sandbox_gui; -FuriTimer* sandbox_timer; -bool sandbox_loop_processing; -SandboxRenderCallback sandbox_user_render_callback; -SandboxEventHandler sandbox_user_event_handler; - -static void sandbox_render_callback(Canvas* const canvas, void* context) { - UNUSED(context); - if(furi_mutex_acquire(sandbox_mutex, 25) != FuriStatusOk) return; - - if(sandbox_user_render_callback) sandbox_user_render_callback(canvas); - - furi_mutex_release(sandbox_mutex); -} - -static void sandbox_input_callback(InputEvent* input_event, void* context) { - UNUSED(context); - GameEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(sandbox_event_queue, &event, FuriWaitForever); -} - -static void sandbox_timer_callback(void* context) { - UNUSED(context); - GameEvent event = {.type = EventTypeTick}; - furi_message_queue_put(sandbox_event_queue, &event, 0); -} - -void sandbox_loop() { - sandbox_loop_processing = true; - while(sandbox_loop_processing) { - GameEvent event; - FuriStatus event_status = furi_message_queue_get(sandbox_event_queue, &event, 100); - if(event_status != FuriStatusOk) { - // timeout - continue; - } - - furi_mutex_acquire(sandbox_mutex, FuriWaitForever); - - if(sandbox_user_event_handler) sandbox_user_event_handler(event); - - view_port_update(sandbox_view_port); - furi_mutex_release(sandbox_mutex); - } -} - -void sandbox_loop_exit() { - sandbox_loop_processing = false; -} - -void sandbox_init( - uint8_t fps, - SandboxRenderCallback u_render_callback, - SandboxEventHandler u_event_handler) { - sandbox_user_render_callback = u_render_callback; - sandbox_user_event_handler = u_event_handler; - - sandbox_event_queue = furi_message_queue_alloc(8, sizeof(GameEvent)); - sandbox_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - sandbox_view_port = view_port_alloc(); - view_port_draw_callback_set(sandbox_view_port, sandbox_render_callback, NULL); - view_port_input_callback_set(sandbox_view_port, sandbox_input_callback, NULL); - - sandbox_gui = furi_record_open(RECORD_GUI); - gui_add_view_port(sandbox_gui, sandbox_view_port, GuiLayerFullscreen); - - if(fps > 0) { - sandbox_timer = furi_timer_alloc(sandbox_timer_callback, FuriTimerTypePeriodic, NULL); - furi_timer_start(sandbox_timer, furi_kernel_get_tick_frequency() / fps); - } else - sandbox_timer = NULL; -} - -void sandbox_free() { - if(sandbox_timer) furi_timer_free(sandbox_timer); - - gui_remove_view_port(sandbox_gui, sandbox_view_port); - view_port_enabled_set(sandbox_view_port, false); - view_port_free(sandbox_view_port); - - if(furi_mutex_acquire(sandbox_mutex, FuriWaitForever) == FuriStatusOk) { - furi_mutex_free(sandbox_mutex); - } - furi_message_queue_free(sandbox_event_queue); -} diff --git a/applications/plugins/game15/sandbox.h b/applications/plugins/game15/sandbox.h deleted file mode 100644 index ea7dff37b..000000000 --- a/applications/plugins/game15/sandbox.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} GameEvent; - -typedef void (*SandboxRenderCallback)(Canvas* canvas); -typedef void (*SandboxEventHandler)(GameEvent event); - -void sandbox_init( - uint8_t fps, - SandboxRenderCallback render_callback, - SandboxEventHandler event_handler); -void sandbox_loop(); -void sandbox_loop_exit(); -void sandbox_free(); diff --git a/applications/plugins/gps_nmea_uart/LICENSE b/applications/plugins/gps_nmea_uart/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/gps_nmea_uart/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/gps_nmea_uart/README.md b/applications/plugins/gps_nmea_uart/README.md deleted file mode 100644 index 3f7a5ef3d..000000000 --- a/applications/plugins/gps_nmea_uart/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# GPS for Flipper Zero - -A simple Flipper Zero application for NMEA 0183 serial GPS modules, such as the - -[Original link](https://github.com/ezod/flipperzero-gps) -[Adafruit Ultimate GPS Breakout]. - -[Original link](https://github.com/ezod/flipperzero-gps) - -![ui](ui.png) - -Heavy lifting (NMEA parsing) provided by [minmea], which is included in this -repository. - -## Hardware Setup - -Connect the GPS module to power and the USART using GPIO pins 9 (3.3V), 11 -(GND), 13 (TX), and 14 (RX), as appropriate. - -![wiring](wiring.png) - - -## Contributing - -This project was a learning exercise and is more or less "complete" from my -perspective, but I will happily accept pull requests that improve and enhance -the functionality for others. - -Currently, the app only parses RMC and GGA sentences, and displays a subset of -the data that fits on the screen. The UART is also hard-coded to 9600 baud. -These limitations are largely driven by the GPS module I have to work with. A -more elaborate UI with scrolling or multiple screens, as well as a configurable -baud rate, may be useful for other GPS modules. - -[Adafruit Ultimate GPS Breakout]: https://www.adafruit.com/product/746 -[minmea]: https://github.com/kosma/minmea -[flipperzero-firmware]: https://github.com/flipperdevices/flipperzero-firmware -[qFlipper]: https://flipperzero.one/update diff --git a/applications/plugins/gps_nmea_uart/application.fam b/applications/plugins/gps_nmea_uart/application.fam deleted file mode 100644 index 138fb3f29..000000000 --- a/applications/plugins/gps_nmea_uart/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="NMEA_GPS", - name="[NMEA] GPS", - apptype=FlipperAppType.EXTERNAL, - entry_point="gps_app", - cdefines=["APP_GPS"], - requires=["gui"], - stack_size=1 * 1024, - order=35, - fap_icon="gps_10px.png", - fap_category="GPIO", -) diff --git a/applications/plugins/gps_nmea_uart/gps.c b/applications/plugins/gps_nmea_uart/gps.c deleted file mode 100644 index 62053cede..000000000 --- a/applications/plugins/gps_nmea_uart/gps.c +++ /dev/null @@ -1,133 +0,0 @@ -#include "gps_uart.h" - -#include -#include -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -static void render_callback(Canvas* const canvas, void* context) { - const GpsUart* gps_uart = acquire_mutex((ValueMutex*)context, 25); - if(gps_uart == NULL) { - return; - } - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 32, 8, AlignCenter, AlignBottom, "Latitude"); - canvas_draw_str_aligned(canvas, 96, 8, AlignCenter, AlignBottom, "Longitude"); - canvas_draw_str_aligned(canvas, 21, 30, AlignCenter, AlignBottom, "Course"); - canvas_draw_str_aligned(canvas, 64, 30, AlignCenter, AlignBottom, "Speed"); - canvas_draw_str_aligned(canvas, 107, 30, AlignCenter, AlignBottom, "Altitude"); - canvas_draw_str_aligned(canvas, 32, 52, AlignCenter, AlignBottom, "Satellites"); - canvas_draw_str_aligned(canvas, 96, 52, AlignCenter, AlignBottom, "Last Fix"); - - canvas_set_font(canvas, FontSecondary); - char buffer[64]; - snprintf(buffer, 64, "%f", (double)gps_uart->status.latitude); - canvas_draw_str_aligned(canvas, 32, 18, AlignCenter, AlignBottom, buffer); - snprintf(buffer, 64, "%f", (double)gps_uart->status.longitude); - canvas_draw_str_aligned(canvas, 96, 18, AlignCenter, AlignBottom, buffer); - snprintf(buffer, 64, "%.1f", (double)gps_uart->status.course); - canvas_draw_str_aligned(canvas, 21, 40, AlignCenter, AlignBottom, buffer); - snprintf(buffer, 64, "%.2f kn", (double)gps_uart->status.speed); - canvas_draw_str_aligned(canvas, 64, 40, AlignCenter, AlignBottom, buffer); - snprintf( - buffer, - 64, - "%.1f %c", - (double)gps_uart->status.altitude, - tolower(gps_uart->status.altitude_units)); - canvas_draw_str_aligned(canvas, 107, 40, AlignCenter, AlignBottom, buffer); - snprintf(buffer, 64, "%d", gps_uart->status.satellites_tracked); - canvas_draw_str_aligned(canvas, 32, 62, AlignCenter, AlignBottom, buffer); - snprintf( - buffer, - 64, - "%02d:%02d:%02d UTC", - gps_uart->status.time_hours, - gps_uart->status.time_minutes, - gps_uart->status.time_seconds); - canvas_draw_str_aligned(canvas, 96, 62, AlignCenter, AlignBottom, buffer); - - release_mutex((ValueMutex*)context, gps_uart); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -int32_t gps_app(void* p) { - UNUSED(p); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - GpsUart* gps_uart = gps_uart_enable(); - - ValueMutex gps_uart_mutex; - if(!init_mutex(&gps_uart_mutex, gps_uart, sizeof(GpsUart))) { - FURI_LOG_E("GPS", "cannot create mutex\r\n"); - free(gps_uart); - return 255; - } - - // set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &gps_uart_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - GpsUart* gps_uart = (GpsUart*)acquire_mutex_block(&gps_uart_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - case InputKeyDown: - case InputKeyRight: - case InputKeyLeft: - case InputKeyOk: - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&gps_uart_mutex, gps_uart); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&gps_uart_mutex); - gps_uart_disable(gps_uart); - - return 0; -} diff --git a/applications/plugins/gps_nmea_uart/gps_10px.png b/applications/plugins/gps_nmea_uart/gps_10px.png deleted file mode 100644 index 841787a2a..000000000 Binary files a/applications/plugins/gps_nmea_uart/gps_10px.png and /dev/null differ diff --git a/applications/plugins/gps_nmea_uart/gps_uart.c b/applications/plugins/gps_nmea_uart/gps_uart.c deleted file mode 100644 index 52ba660bc..000000000 --- a/applications/plugins/gps_nmea_uart/gps_uart.c +++ /dev/null @@ -1,173 +0,0 @@ -#include - -#include "minmea.h" -#include "gps_uart.h" - -typedef enum { - WorkerEvtStop = (1 << 0), - WorkerEvtRxDone = (1 << 1), -} WorkerEvtFlags; - -#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone) - -static void gps_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) { - GpsUart* gps_uart = (GpsUart*)context; - - if(ev == UartIrqEventRXNE) { - furi_stream_buffer_send(gps_uart->rx_stream, &data, 1, 0); - furi_thread_flags_set(furi_thread_get_id(gps_uart->thread), WorkerEvtRxDone); - } -} - -static void gps_uart_serial_init(GpsUart* gps_uart) { - furi_hal_console_disable(); - furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, gps_uart_on_irq_cb, gps_uart); - furi_hal_uart_set_br(FuriHalUartIdUSART1, GPS_BAUDRATE); -} - -static void gps_uart_serial_deinit(GpsUart* gps_uart) { - UNUSED(gps_uart); - furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, NULL, NULL); - furi_hal_console_enable(); -} - -static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) { - switch(minmea_sentence_id(line, false)) { - case MINMEA_SENTENCE_RMC: { - struct minmea_sentence_rmc frame; - if(minmea_parse_rmc(&frame, line)) { - gps_uart->status.valid = frame.valid; - gps_uart->status.latitude = minmea_tocoord(&frame.latitude); - gps_uart->status.longitude = minmea_tocoord(&frame.longitude); - gps_uart->status.speed = minmea_tofloat(&frame.speed); - gps_uart->status.course = minmea_tofloat(&frame.course); - gps_uart->status.time_hours = frame.time.hours; - gps_uart->status.time_minutes = frame.time.minutes; - gps_uart->status.time_seconds = frame.time.seconds; - - notification_message_block(gps_uart->notifications, &sequence_blink_green_10); - } - } break; - - case MINMEA_SENTENCE_GGA: { - struct minmea_sentence_gga frame; - if(minmea_parse_gga(&frame, line)) { - gps_uart->status.latitude = minmea_tocoord(&frame.latitude); - gps_uart->status.longitude = minmea_tocoord(&frame.longitude); - gps_uart->status.altitude = minmea_tofloat(&frame.altitude); - gps_uart->status.altitude_units = frame.altitude_units; - gps_uart->status.fix_quality = frame.fix_quality; - gps_uart->status.satellites_tracked = frame.satellites_tracked; - gps_uart->status.time_hours = frame.time.hours; - gps_uart->status.time_minutes = frame.time.minutes; - gps_uart->status.time_seconds = frame.time.seconds; - - notification_message_block(gps_uart->notifications, &sequence_blink_magenta_10); - } - } break; - - default: - break; - } -} - -static int32_t gps_uart_worker(void* context) { - GpsUart* gps_uart = (GpsUart*)context; - - gps_uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE * 5, 1); - size_t rx_offset = 0; - - gps_uart_serial_init(gps_uart); - - while(1) { - uint32_t events = - furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever); - furi_check((events & FuriFlagError) == 0); - - if(events & WorkerEvtStop) { - break; - } - - if(events & WorkerEvtRxDone) { - size_t len = 0; - do { - len = furi_stream_buffer_receive( - gps_uart->rx_stream, - gps_uart->rx_buf + rx_offset, - RX_BUF_SIZE - 1 - rx_offset, - 0); - if(len > 0) { - rx_offset += len; - gps_uart->rx_buf[rx_offset] = '\0'; - - char* line_current = (char*)gps_uart->rx_buf; - while(1) { - while(*line_current == '\0' && - line_current < (char*)gps_uart->rx_buf + rx_offset - 1) { - line_current++; - } - - char* newline = strchr(line_current, '\n'); - if(newline) { - *newline = '\0'; - gps_uart_parse_nmea(gps_uart, line_current); - line_current = newline + 1; - } else { - if(line_current > (char*)gps_uart->rx_buf) { - rx_offset = 0; - while(*line_current) { - gps_uart->rx_buf[rx_offset++] = *(line_current++); - } - } - break; - } - } - } - } while(len > 0); - } - } - - gps_uart_serial_deinit(gps_uart); - furi_stream_buffer_free(gps_uart->rx_stream); - - return 0; -} - -GpsUart* gps_uart_enable() { - GpsUart* gps_uart = malloc(sizeof(GpsUart)); - - gps_uart->status.valid = false; - gps_uart->status.latitude = 0.0; - gps_uart->status.longitude = 0.0; - gps_uart->status.speed = 0.0; - gps_uart->status.course = 0.0; - gps_uart->status.altitude = 0.0; - gps_uart->status.altitude_units = ' '; - gps_uart->status.fix_quality = 0; - gps_uart->status.satellites_tracked = 0; - gps_uart->status.time_hours = 0; - gps_uart->status.time_minutes = 0; - gps_uart->status.time_seconds = 0; - - gps_uart->notifications = furi_record_open(RECORD_NOTIFICATION); - - gps_uart->thread = furi_thread_alloc(); - furi_thread_set_name(gps_uart->thread, "GpsUartWorker"); - furi_thread_set_stack_size(gps_uart->thread, 1024); - furi_thread_set_context(gps_uart->thread, gps_uart); - furi_thread_set_callback(gps_uart->thread, gps_uart_worker); - - furi_thread_start(gps_uart->thread); - return gps_uart; -} - -void gps_uart_disable(GpsUart* gps_uart) { - furi_assert(gps_uart); - furi_thread_flags_set(furi_thread_get_id(gps_uart->thread), WorkerEvtStop); - furi_thread_join(gps_uart->thread); - furi_thread_free(gps_uart->thread); - - furi_record_close(RECORD_NOTIFICATION); - - free(gps_uart); -} diff --git a/applications/plugins/gps_nmea_uart/gps_uart.h b/applications/plugins/gps_nmea_uart/gps_uart.h deleted file mode 100644 index d6aafae9f..000000000 --- a/applications/plugins/gps_nmea_uart/gps_uart.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include - -#define GPS_BAUDRATE 9600 -#define RX_BUF_SIZE 1024 - -typedef struct { - bool valid; - float latitude; - float longitude; - float speed; - float course; - float altitude; - char altitude_units; - int fix_quality; - int satellites_tracked; - int time_hours; - int time_minutes; - int time_seconds; -} GpsStatus; - -typedef struct { - FuriThread* thread; - FuriStreamBuffer* rx_stream; - uint8_t rx_buf[RX_BUF_SIZE]; - - NotificationApp* notifications; - - GpsStatus status; -} GpsUart; - -GpsUart* gps_uart_enable(); - -void gps_uart_disable(GpsUart* gps_uart); diff --git a/applications/plugins/gps_nmea_uart/minmea.c b/applications/plugins/gps_nmea_uart/minmea.c deleted file mode 100644 index 1b7a84b1c..000000000 --- a/applications/plugins/gps_nmea_uart/minmea.c +++ /dev/null @@ -1,640 +0,0 @@ -/* - * Copyright © 2014 Kosma Moczek - * This program is free software. It comes without any warranty, to the extent - * permitted by applicable law. You can redistribute it and/or modify it under - * the terms of the Do What The Fuck You Want To Public License, Version 2, as - * published by Sam Hocevar. See the COPYING file for more details. - */ - -#include "minmea.h" - -#include -#include -#include - -#define boolstr(s) ((s) ? "true" : "false") - -static int hex2int(char c) { - if(c >= '0' && c <= '9') return c - '0'; - if(c >= 'A' && c <= 'F') return c - 'A' + 10; - if(c >= 'a' && c <= 'f') return c - 'a' + 10; - return -1; -} - -uint8_t minmea_checksum(const char* sentence) { - // Support senteces with or without the starting dollar sign. - if(*sentence == '$') sentence++; - - uint8_t checksum = 0x00; - - // The optional checksum is an XOR of all bytes between "$" and "*". - while(*sentence && *sentence != '*') checksum ^= *sentence++; - - return checksum; -} - -bool minmea_check(const char* sentence, bool strict) { - uint8_t checksum = 0x00; - - // A valid sentence starts with "$". - if(*sentence++ != '$') return false; - - // The optional checksum is an XOR of all bytes between "$" and "*". - while(*sentence && *sentence != '*' && isprint((unsigned char)*sentence)) - checksum ^= *sentence++; - - // If checksum is present... - if(*sentence == '*') { - // Extract checksum. - sentence++; - int upper = hex2int(*sentence++); - if(upper == -1) return false; - int lower = hex2int(*sentence++); - if(lower == -1) return false; - int expected = upper << 4 | lower; - - // Check for checksum mismatch. - if(checksum != expected) return false; - } else if(strict) { - // Discard non-checksummed frames in strict mode. - return false; - } - - // The only stuff allowed at this point is a newline. - while(*sentence == '\r' || *sentence == '\n') { - sentence++; - } - - if(*sentence) { - return false; - } - - return true; -} - -bool minmea_scan(const char* sentence, const char* format, ...) { - bool result = false; - bool optional = false; - - if(sentence == NULL) return false; - - va_list ap; - va_start(ap, format); - - const char* field = sentence; -#define next_field() \ - do { \ - /* Progress to the next field. */ \ - while(minmea_isfield(*sentence)) sentence++; \ - /* Make sure there is a field there. */ \ - if(*sentence == ',') { \ - sentence++; \ - field = sentence; \ - } else { \ - field = NULL; \ - } \ - } while(0) - - while(*format) { - char type = *format++; - - if(type == ';') { - // All further fields are optional. - optional = true; - continue; - } - - if(!field && !optional) { - // Field requested but we ran out if input. Bail out. - goto parse_error; - } - - switch(type) { - case 'c': { // Single character field (char). - char value = '\0'; - - if(field && minmea_isfield(*field)) value = *field; - - *va_arg(ap, char*) = value; - } break; - - case 'd': { // Single character direction field (int). - int value = 0; - - if(field && minmea_isfield(*field)) { - switch(*field) { - case 'N': - case 'E': - value = 1; - break; - case 'S': - case 'W': - value = -1; - break; - default: - goto parse_error; - } - } - - *va_arg(ap, int*) = value; - } break; - - case 'f': { // Fractional value with scale (struct minmea_float). - int sign = 0; - int_least32_t value = -1; - int_least32_t scale = 0; - - if(field) { - while(minmea_isfield(*field)) { - if(*field == '+' && !sign && value == -1) { - sign = 1; - } else if(*field == '-' && !sign && value == -1) { - sign = -1; - } else if(isdigit((unsigned char)*field)) { - int digit = *field - '0'; - if(value == -1) value = 0; - if(value > (INT_LEAST32_MAX - digit) / 10) { - /* we ran out of bits, what do we do? */ - if(scale) { - /* truncate extra precision */ - break; - } else { - /* integer overflow. bail out. */ - goto parse_error; - } - } - value = (10 * value) + digit; - if(scale) scale *= 10; - } else if(*field == '.' && scale == 0) { - scale = 1; - } else if(*field == ' ') { - /* Allow spaces at the start of the field. Not NMEA - * conformant, but some modules do this. */ - if(sign != 0 || value != -1 || scale != 0) goto parse_error; - } else { - goto parse_error; - } - field++; - } - } - - if((sign || scale) && value == -1) goto parse_error; - - if(value == -1) { - /* No digits were scanned. */ - value = 0; - scale = 0; - } else if(scale == 0) { - /* No decimal point. */ - scale = 1; - } - if(sign) value *= sign; - - *va_arg(ap, struct minmea_float*) = (struct minmea_float){value, scale}; - } break; - - case 'i': { // Integer value, default 0 (int). - int value = 0; - - if(field) { - char* endptr; - value = strtol(field, &endptr, 10); - if(minmea_isfield(*endptr)) goto parse_error; - } - - *va_arg(ap, int*) = value; - } break; - - case 's': { // String value (char *). - char* buf = va_arg(ap, char*); - - if(field) { - while(minmea_isfield(*field)) *buf++ = *field++; - } - - *buf = '\0'; - } break; - - case 't': { // NMEA talker+sentence identifier (char *). - // This field is always mandatory. - if(!field) goto parse_error; - - if(field[0] != '$') goto parse_error; - for(int f = 0; f < 5; f++) - if(!minmea_isfield(field[1 + f])) goto parse_error; - - char* buf = va_arg(ap, char*); - memcpy(buf, field + 1, 5); - buf[5] = '\0'; - } break; - - case 'D': { // Date (int, int, int), -1 if empty. - struct minmea_date* date = va_arg(ap, struct minmea_date*); - - int d = -1, m = -1, y = -1; - - if(field && minmea_isfield(*field)) { - // Always six digits. - for(int f = 0; f < 6; f++) - if(!isdigit((unsigned char)field[f])) goto parse_error; - - char dArr[] = {field[0], field[1], '\0'}; - char mArr[] = {field[2], field[3], '\0'}; - char yArr[] = {field[4], field[5], '\0'}; - d = strtol(dArr, NULL, 10); - m = strtol(mArr, NULL, 10); - y = strtol(yArr, NULL, 10); - } - - date->day = d; - date->month = m; - date->year = y; - } break; - - case 'T': { // Time (int, int, int, int), -1 if empty. - struct minmea_time* time_ = va_arg(ap, struct minmea_time*); - - int h = -1, i = -1, s = -1, u = -1; - - if(field && minmea_isfield(*field)) { - // Minimum required: integer time. - for(int f = 0; f < 6; f++) - if(!isdigit((unsigned char)field[f])) goto parse_error; - - char hArr[] = {field[0], field[1], '\0'}; - char iArr[] = {field[2], field[3], '\0'}; - char sArr[] = {field[4], field[5], '\0'}; - h = strtol(hArr, NULL, 10); - i = strtol(iArr, NULL, 10); - s = strtol(sArr, NULL, 10); - field += 6; - - // Extra: fractional time. Saved as microseconds. - if(*field++ == '.') { - uint32_t value = 0; - uint32_t scale = 1000000LU; - while(isdigit((unsigned char)*field) && scale > 1) { - value = (value * 10) + (*field++ - '0'); - scale /= 10; - } - u = value * scale; - } else { - u = 0; - } - } - - time_->hours = h; - time_->minutes = i; - time_->seconds = s; - time_->microseconds = u; - } break; - - case '_': { // Ignore the field. - } break; - - default: { // Unknown. - goto parse_error; - } - } - - next_field(); - } - - result = true; - -parse_error: - va_end(ap); - return result; -} - -bool minmea_talker_id(char talker[3], const char* sentence) { - char type[6]; - if(!minmea_scan(sentence, "t", type)) return false; - - talker[0] = type[0]; - talker[1] = type[1]; - talker[2] = '\0'; - - return true; -} - -enum minmea_sentence_id minmea_sentence_id(const char* sentence, bool strict) { - if(!minmea_check(sentence, strict)) return MINMEA_INVALID; - - char type[6]; - if(!minmea_scan(sentence, "t", type)) return MINMEA_INVALID; - - if(!strcmp(type + 2, "GBS")) return MINMEA_SENTENCE_GBS; - if(!strcmp(type + 2, "GGA")) return MINMEA_SENTENCE_GGA; - if(!strcmp(type + 2, "GLL")) return MINMEA_SENTENCE_GLL; - if(!strcmp(type + 2, "GSA")) return MINMEA_SENTENCE_GSA; - if(!strcmp(type + 2, "GST")) return MINMEA_SENTENCE_GST; - if(!strcmp(type + 2, "GSV")) return MINMEA_SENTENCE_GSV; - if(!strcmp(type + 2, "RMC")) return MINMEA_SENTENCE_RMC; - if(!strcmp(type + 2, "VTG")) return MINMEA_SENTENCE_VTG; - if(!strcmp(type + 2, "ZDA")) return MINMEA_SENTENCE_ZDA; - - return MINMEA_UNKNOWN; -} - -bool minmea_parse_gbs(struct minmea_sentence_gbs* frame, const char* sentence) { - // $GNGBS,170556.00,3.0,2.9,8.3,,,,*5C - char type[6]; - if(!minmea_scan( - sentence, - "tTfffifff", - type, - &frame->time, - &frame->err_latitude, - &frame->err_longitude, - &frame->err_altitude, - &frame->svid, - &frame->prob, - &frame->bias, - &frame->stddev)) - return false; - if(strcmp(type + 2, "GBS")) return false; - - return true; -} - -bool minmea_parse_rmc(struct minmea_sentence_rmc* frame, const char* sentence) { - // $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62 - char type[6]; - char validity; - int latitude_direction; - int longitude_direction; - int variation_direction; - if(!minmea_scan( - sentence, - "tTcfdfdffDfd", - type, - &frame->time, - &validity, - &frame->latitude, - &latitude_direction, - &frame->longitude, - &longitude_direction, - &frame->speed, - &frame->course, - &frame->date, - &frame->variation, - &variation_direction)) - return false; - if(strcmp(type + 2, "RMC")) return false; - - frame->valid = (validity == 'A'); - frame->latitude.value *= latitude_direction; - frame->longitude.value *= longitude_direction; - frame->variation.value *= variation_direction; - - return true; -} - -bool minmea_parse_gga(struct minmea_sentence_gga* frame, const char* sentence) { - // $GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 - char type[6]; - int latitude_direction; - int longitude_direction; - - if(!minmea_scan( - sentence, - "tTfdfdiiffcfcf_", - type, - &frame->time, - &frame->latitude, - &latitude_direction, - &frame->longitude, - &longitude_direction, - &frame->fix_quality, - &frame->satellites_tracked, - &frame->hdop, - &frame->altitude, - &frame->altitude_units, - &frame->height, - &frame->height_units, - &frame->dgps_age)) - return false; - if(strcmp(type + 2, "GGA")) return false; - - frame->latitude.value *= latitude_direction; - frame->longitude.value *= longitude_direction; - - return true; -} - -bool minmea_parse_gsa(struct minmea_sentence_gsa* frame, const char* sentence) { - // $GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39 - char type[6]; - - if(!minmea_scan( - sentence, - "tciiiiiiiiiiiiifff", - type, - &frame->mode, - &frame->fix_type, - &frame->sats[0], - &frame->sats[1], - &frame->sats[2], - &frame->sats[3], - &frame->sats[4], - &frame->sats[5], - &frame->sats[6], - &frame->sats[7], - &frame->sats[8], - &frame->sats[9], - &frame->sats[10], - &frame->sats[11], - &frame->pdop, - &frame->hdop, - &frame->vdop)) - return false; - if(strcmp(type + 2, "GSA")) return false; - - return true; -} - -bool minmea_parse_gll(struct minmea_sentence_gll* frame, const char* sentence) { - // $GPGLL,3723.2475,N,12158.3416,W,161229.487,A,A*41$; - char type[6]; - int latitude_direction; - int longitude_direction; - - if(!minmea_scan( - sentence, - "tfdfdTc;c", - type, - &frame->latitude, - &latitude_direction, - &frame->longitude, - &longitude_direction, - &frame->time, - &frame->status, - &frame->mode)) - return false; - if(strcmp(type + 2, "GLL")) return false; - - frame->latitude.value *= latitude_direction; - frame->longitude.value *= longitude_direction; - - return true; -} - -bool minmea_parse_gst(struct minmea_sentence_gst* frame, const char* sentence) { - // $GPGST,024603.00,3.2,6.6,4.7,47.3,5.8,5.6,22.0*58 - char type[6]; - - if(!minmea_scan( - sentence, - "tTfffffff", - type, - &frame->time, - &frame->rms_deviation, - &frame->semi_major_deviation, - &frame->semi_minor_deviation, - &frame->semi_major_orientation, - &frame->latitude_error_deviation, - &frame->longitude_error_deviation, - &frame->altitude_error_deviation)) - return false; - if(strcmp(type + 2, "GST")) return false; - - return true; -} - -bool minmea_parse_gsv(struct minmea_sentence_gsv* frame, const char* sentence) { - // $GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74 - // $GPGSV,3,3,11,22,42,067,42,24,14,311,43,27,05,244,00,,,,*4D - // $GPGSV,4,2,11,08,51,203,30,09,45,215,28*75 - // $GPGSV,4,4,13,39,31,170,27*40 - // $GPGSV,4,4,13*7B - char type[6]; - - if(!minmea_scan( - sentence, - "tiii;iiiiiiiiiiiiiiii", - type, - &frame->total_msgs, - &frame->msg_nr, - &frame->total_sats, - &frame->sats[0].nr, - &frame->sats[0].elevation, - &frame->sats[0].azimuth, - &frame->sats[0].snr, - &frame->sats[1].nr, - &frame->sats[1].elevation, - &frame->sats[1].azimuth, - &frame->sats[1].snr, - &frame->sats[2].nr, - &frame->sats[2].elevation, - &frame->sats[2].azimuth, - &frame->sats[2].snr, - &frame->sats[3].nr, - &frame->sats[3].elevation, - &frame->sats[3].azimuth, - &frame->sats[3].snr)) { - return false; - } - if(strcmp(type + 2, "GSV")) return false; - - return true; -} - -bool minmea_parse_vtg(struct minmea_sentence_vtg* frame, const char* sentence) { - // $GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48 - // $GPVTG,156.1,T,140.9,M,0.0,N,0.0,K*41 - // $GPVTG,096.5,T,083.5,M,0.0,N,0.0,K,D*22 - // $GPVTG,188.36,T,,M,0.820,N,1.519,K,A*3F - char type[6]; - char c_true, c_magnetic, c_knots, c_kph, c_faa_mode; - - if(!minmea_scan( - sentence, - "t;fcfcfcfcc", - type, - &frame->true_track_degrees, - &c_true, - &frame->magnetic_track_degrees, - &c_magnetic, - &frame->speed_knots, - &c_knots, - &frame->speed_kph, - &c_kph, - &c_faa_mode)) - return false; - if(strcmp(type + 2, "VTG")) return false; - // values are only valid with the accompanying characters - if(c_true != 'T') frame->true_track_degrees.scale = 0; - if(c_magnetic != 'M') frame->magnetic_track_degrees.scale = 0; - if(c_knots != 'N') frame->speed_knots.scale = 0; - if(c_kph != 'K') frame->speed_kph.scale = 0; - frame->faa_mode = (enum minmea_faa_mode)c_faa_mode; - - return true; -} - -bool minmea_parse_zda(struct minmea_sentence_zda* frame, const char* sentence) { - // $GPZDA,201530.00,04,07,2002,00,00*60 - char type[6]; - - if(!minmea_scan( - sentence, - "tTiiiii", - type, - &frame->time, - &frame->date.day, - &frame->date.month, - &frame->date.year, - &frame->hour_offset, - &frame->minute_offset)) - return false; - if(strcmp(type + 2, "ZDA")) return false; - - // check offsets - if(abs(frame->hour_offset) > 13 || frame->minute_offset > 59 || frame->minute_offset < 0) - return false; - - return true; -} - -int minmea_getdatetime( - struct tm* tm, - const struct minmea_date* date, - const struct minmea_time* time_) { - if(date->year == -1 || time_->hours == -1) return -1; - - memset(tm, 0, sizeof(*tm)); - if(date->year < 80) { - tm->tm_year = 2000 + date->year - 1900; // 2000-2079 - } else if(date->year >= 1900) { - tm->tm_year = date->year - 1900; // 4 digit year, use directly - } else { - tm->tm_year = date->year; // 1980-1999 - } - tm->tm_mon = date->month - 1; - tm->tm_mday = date->day; - tm->tm_hour = time_->hours; - tm->tm_min = time_->minutes; - tm->tm_sec = time_->seconds; - - return 0; -} - -int minmea_gettime( - struct timespec* ts, - const struct minmea_date* date, - const struct minmea_time* time_) { - struct tm tm; - if(minmea_getdatetime(&tm, date, time_)) return -1; - - time_t timestamp = mktime(&tm); /* See README.md if your system lacks timegm(). */ - if(timestamp != (time_t)-1) { - ts->tv_sec = timestamp; - ts->tv_nsec = time_->microseconds * 1000; - return 0; - } else { - return -1; - } -} - -/* vim: set ts=4 sw=4 et: */ diff --git a/applications/plugins/gps_nmea_uart/minmea.h b/applications/plugins/gps_nmea_uart/minmea.h deleted file mode 100644 index 88eec4ae9..000000000 --- a/applications/plugins/gps_nmea_uart/minmea.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright © 2014 Kosma Moczek - * This program is free software. It comes without any warranty, to the extent - * permitted by applicable law. You can redistribute it and/or modify it under - * the terms of the Do What The Fuck You Want To Public License, Version 2, as - * published by Sam Hocevar. See the COPYING file for more details. - */ - -#ifndef MINMEA_H -#define MINMEA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#ifdef MINMEA_INCLUDE_COMPAT -#include -#endif - -#ifndef MINMEA_MAX_SENTENCE_LENGTH -#define MINMEA_MAX_SENTENCE_LENGTH 80 -#endif - -enum minmea_sentence_id { - MINMEA_INVALID = -1, - MINMEA_UNKNOWN = 0, - MINMEA_SENTENCE_GBS, - MINMEA_SENTENCE_GGA, - MINMEA_SENTENCE_GLL, - MINMEA_SENTENCE_GSA, - MINMEA_SENTENCE_GST, - MINMEA_SENTENCE_GSV, - MINMEA_SENTENCE_RMC, - MINMEA_SENTENCE_VTG, - MINMEA_SENTENCE_ZDA, -}; - -struct minmea_float { - int_least32_t value; - int_least32_t scale; -}; - -struct minmea_date { - int day; - int month; - int year; -}; - -struct minmea_time { - int hours; - int minutes; - int seconds; - int microseconds; -}; - -struct minmea_sentence_gbs { - struct minmea_time time; - struct minmea_float err_latitude; - struct minmea_float err_longitude; - struct minmea_float err_altitude; - int svid; - struct minmea_float prob; - struct minmea_float bias; - struct minmea_float stddev; -}; - -struct minmea_sentence_rmc { - struct minmea_time time; - bool valid; - struct minmea_float latitude; - struct minmea_float longitude; - struct minmea_float speed; - struct minmea_float course; - struct minmea_date date; - struct minmea_float variation; -}; - -struct minmea_sentence_gga { - struct minmea_time time; - struct minmea_float latitude; - struct minmea_float longitude; - int fix_quality; - int satellites_tracked; - struct minmea_float hdop; - struct minmea_float altitude; - char altitude_units; - struct minmea_float height; - char height_units; - struct minmea_float dgps_age; -}; - -enum minmea_gll_status { - MINMEA_GLL_STATUS_DATA_VALID = 'A', - MINMEA_GLL_STATUS_DATA_NOT_VALID = 'V', -}; - -// FAA mode added to some fields in NMEA 2.3. -enum minmea_faa_mode { - MINMEA_FAA_MODE_AUTONOMOUS = 'A', - MINMEA_FAA_MODE_DIFFERENTIAL = 'D', - MINMEA_FAA_MODE_ESTIMATED = 'E', - MINMEA_FAA_MODE_MANUAL = 'M', - MINMEA_FAA_MODE_SIMULATED = 'S', - MINMEA_FAA_MODE_NOT_VALID = 'N', - MINMEA_FAA_MODE_PRECISE = 'P', -}; - -struct minmea_sentence_gll { - struct minmea_float latitude; - struct minmea_float longitude; - struct minmea_time time; - char status; - char mode; -}; - -struct minmea_sentence_gst { - struct minmea_time time; - struct minmea_float rms_deviation; - struct minmea_float semi_major_deviation; - struct minmea_float semi_minor_deviation; - struct minmea_float semi_major_orientation; - struct minmea_float latitude_error_deviation; - struct minmea_float longitude_error_deviation; - struct minmea_float altitude_error_deviation; -}; - -enum minmea_gsa_mode { - MINMEA_GPGSA_MODE_AUTO = 'A', - MINMEA_GPGSA_MODE_FORCED = 'M', -}; - -enum minmea_gsa_fix_type { - MINMEA_GPGSA_FIX_NONE = 1, - MINMEA_GPGSA_FIX_2D = 2, - MINMEA_GPGSA_FIX_3D = 3, -}; - -struct minmea_sentence_gsa { - char mode; - int fix_type; - int sats[12]; - struct minmea_float pdop; - struct minmea_float hdop; - struct minmea_float vdop; -}; - -struct minmea_sat_info { - int nr; - int elevation; - int azimuth; - int snr; -}; - -struct minmea_sentence_gsv { - int total_msgs; - int msg_nr; - int total_sats; - struct minmea_sat_info sats[4]; -}; - -struct minmea_sentence_vtg { - struct minmea_float true_track_degrees; - struct minmea_float magnetic_track_degrees; - struct minmea_float speed_knots; - struct minmea_float speed_kph; - enum minmea_faa_mode faa_mode; -}; - -struct minmea_sentence_zda { - struct minmea_time time; - struct minmea_date date; - int hour_offset; - int minute_offset; -}; - -/** - * Calculate raw sentence checksum. Does not check sentence integrity. - */ -uint8_t minmea_checksum(const char* sentence); - -/** - * Check sentence validity and checksum. Returns true for valid sentences. - */ -bool minmea_check(const char* sentence, bool strict); - -/** - * Determine talker identifier. - */ -bool minmea_talker_id(char talker[3], const char* sentence); - -/** - * Determine sentence identifier. - */ -enum minmea_sentence_id minmea_sentence_id(const char* sentence, bool strict); - -/** - * Scanf-like processor for NMEA sentences. Supports the following formats: - * c - single character (char *) - * d - direction, returned as 1/-1, default 0 (int *) - * f - fractional, returned as value + scale (struct minmea_float *) - * i - decimal, default zero (int *) - * s - string (char *) - * t - talker identifier and type (char *) - * D - date (struct minmea_date *) - * T - time stamp (struct minmea_time *) - * _ - ignore this field - * ; - following fields are optional - * Returns true on success. See library source code for details. - */ -bool minmea_scan(const char* sentence, const char* format, ...); - -/* - * Parse a specific type of sentence. Return true on success. - */ -bool minmea_parse_gbs(struct minmea_sentence_gbs* frame, const char* sentence); -bool minmea_parse_rmc(struct minmea_sentence_rmc* frame, const char* sentence); -bool minmea_parse_gga(struct minmea_sentence_gga* frame, const char* sentence); -bool minmea_parse_gsa(struct minmea_sentence_gsa* frame, const char* sentence); -bool minmea_parse_gll(struct minmea_sentence_gll* frame, const char* sentence); -bool minmea_parse_gst(struct minmea_sentence_gst* frame, const char* sentence); -bool minmea_parse_gsv(struct minmea_sentence_gsv* frame, const char* sentence); -bool minmea_parse_vtg(struct minmea_sentence_vtg* frame, const char* sentence); -bool minmea_parse_zda(struct minmea_sentence_zda* frame, const char* sentence); - -/** - * Convert GPS UTC date/time representation to a UNIX calendar time. - */ -int minmea_getdatetime( - struct tm* tm, - const struct minmea_date* date, - const struct minmea_time* time_); - -/** - * Convert GPS UTC date/time representation to a UNIX timestamp. - */ -int minmea_gettime( - struct timespec* ts, - const struct minmea_date* date, - const struct minmea_time* time_); - -/** - * Rescale a fixed-point value to a different scale. Rounds towards zero. - */ -static inline int_least32_t minmea_rescale(const struct minmea_float* f, int_least32_t new_scale) { - if(f->scale == 0) return 0; - if(f->scale == new_scale) return f->value; - if(f->scale > new_scale) - return (f->value + ((f->value > 0) - (f->value < 0)) * f->scale / new_scale / 2) / - (f->scale / new_scale); - else - return f->value * (new_scale / f->scale); -} - -/** - * Convert a fixed-point value to a floating-point value. - * Returns NaN for "unknown" values. - */ -static inline float minmea_tofloat(const struct minmea_float* f) { - if(f->scale == 0) return NAN; - return (float)f->value / (float)f->scale; -} - -/** - * Convert a raw coordinate to a floating point DD.DDD... value. - * Returns NaN for "unknown" values. - */ -static inline float minmea_tocoord(const struct minmea_float* f) { - if(f->scale == 0) return NAN; - if(f->scale > (INT_LEAST32_MAX / 100)) return NAN; - if(f->scale < (INT_LEAST32_MIN / 100)) return NAN; - int_least32_t degrees = f->value / (f->scale * 100); - int_least32_t minutes = f->value % (f->scale * 100); - return (float)degrees + (float)minutes / (60 * f->scale); -} - -/** - * Check whether a character belongs to the set of characters allowed in a - * sentence data field. - */ -static inline bool minmea_isfield(char c) { - return isprint((unsigned char)c) && c != ',' && c != '*'; -} - -#ifdef __cplusplus -} -#endif - -#endif /* MINMEA_H */ - -/* vim: set ts=4 sw=4 et: */ diff --git a/applications/plugins/gps_nmea_uart/ui.png b/applications/plugins/gps_nmea_uart/ui.png deleted file mode 100644 index 8e5214574..000000000 Binary files a/applications/plugins/gps_nmea_uart/ui.png and /dev/null differ diff --git a/applications/plugins/gps_nmea_uart/wiring.png b/applications/plugins/gps_nmea_uart/wiring.png deleted file mode 100644 index 74b4a4401..000000000 Binary files a/applications/plugins/gps_nmea_uart/wiring.png and /dev/null differ diff --git a/applications/plugins/hc_sr04/README.md b/applications/plugins/hc_sr04/README.md deleted file mode 100644 index 2fb3b8ce4..000000000 --- a/applications/plugins/hc_sr04/README.md +++ /dev/null @@ -1 +0,0 @@ -## (5V -> VCC) / (GND -> GND) / (13|TX -> Trig) / (14|RX -> Echo) \ No newline at end of file diff --git a/applications/plugins/hc_sr04/application.fam b/applications/plugins/hc_sr04/application.fam deleted file mode 100644 index da91a0864..000000000 --- a/applications/plugins/hc_sr04/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="HC_SR04_Dist_Sensor", - name="[HC-SR] Dist. Sensor", - apptype=FlipperAppType.EXTERNAL, - entry_point="hc_sr04_app", - cdefines=["APP_HC_SR04"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=20, - fap_icon="dist_sensor10px.png", - fap_category="GPIO", -) \ No newline at end of file diff --git a/applications/plugins/hc_sr04/dist_sensor10px.png b/applications/plugins/hc_sr04/dist_sensor10px.png deleted file mode 100644 index af9aa7358..000000000 Binary files a/applications/plugins/hc_sr04/dist_sensor10px.png and /dev/null differ diff --git a/applications/plugins/hc_sr04/hc_sr04.c b/applications/plugins/hc_sr04/hc_sr04.c deleted file mode 100644 index dbbf4f3ec..000000000 --- a/applications/plugins/hc_sr04/hc_sr04.c +++ /dev/null @@ -1,273 +0,0 @@ -// insired by -// https://github.com/esphome/esphome/blob/ac0d921413c3884752193fe568fa82853f0f99e9/esphome/components/ultrasonic/ultrasonic_sensor.cpp -// Ported and modified by @xMasterX - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - NotificationApp* notification; - bool have_5v; - bool measurement_made; - uint32_t echo; // ms - float distance; // meters -} PluginState; - -const NotificationSequence sequence_done = { - &message_display_backlight_on, - &message_green_255, - &message_note_c5, - &message_delay_50, - &message_sound_off, - NULL, -}; - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - // border around the edge of the screen - // canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned( - canvas, 64, 2, AlignCenter, AlignTop, "HC-SR04 Ultrasonic\nDistance Sensor"); - - canvas_set_font(canvas, FontSecondary); - - if(!plugin_state->have_5v) { - elements_multiline_text_aligned( - canvas, - 4, - 28, - AlignLeft, - AlignTop, - "5V on GPIO must be\nenabled, or USB must\nbe connected."); - } else { - if(!plugin_state->measurement_made) { - elements_multiline_text_aligned( - canvas, 64, 28, AlignCenter, AlignTop, "Press OK button to measure"); - elements_multiline_text_aligned( - canvas, 64, 40, AlignCenter, AlignTop, "13/TX -> Trig\n14/RX -> Echo"); - } else { - elements_multiline_text_aligned(canvas, 4, 28, AlignLeft, AlignTop, "Readout:"); - - FuriString* str_buf; - str_buf = furi_string_alloc(); - furi_string_printf(str_buf, "Echo: %ld ms", plugin_state->echo); - - canvas_draw_str_aligned( - canvas, 8, 38, AlignLeft, AlignTop, furi_string_get_cstr(str_buf)); - furi_string_printf(str_buf, "Distance: %02f m", (double)plugin_state->distance); - canvas_draw_str_aligned( - canvas, 8, 48, AlignLeft, AlignTop, furi_string_get_cstr(str_buf)); - - furi_string_free(str_buf); - } - } - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void hc_sr04_state_init(PluginState* const plugin_state) { - plugin_state->echo = -1; - plugin_state->distance = -1; - plugin_state->measurement_made = false; - - furi_hal_power_suppress_charge_enter(); - - plugin_state->have_5v = false; - if(furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging()) { - plugin_state->have_5v = true; - } else { - furi_hal_power_enable_otg(); - plugin_state->have_5v = true; - } -} - -float hc_sr04_ms_to_m(uint32_t ms) { - const float speed_sound_m_per_s = 343.0f; - const float time_s = ms / 1e3f; - const float total_dist = time_s * speed_sound_m_per_s; - return total_dist / 2.0f; -} - -static void hc_sr04_measure(PluginState* const plugin_state) { - //plugin_state->echo = 1; - //return; - - if(!plugin_state->have_5v) { - if(furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging()) { - plugin_state->have_5v = true; - } else { - return; - } - } - - //furi_hal_light_set(LightRed, 0xFF); - notification_message(plugin_state->notification, &sequence_blink_start_yellow); - - const uint32_t timeout_ms = 2000; - // Pin 13 / TX -> Trig - furi_hal_gpio_write(&gpio_usart_tx, false); - furi_hal_gpio_init(&gpio_usart_tx, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - - // Pin 14 / RX -> Echo - furi_hal_gpio_write(&gpio_usart_rx, false); - furi_hal_gpio_init(&gpio_usart_rx, GpioModeInput, GpioPullNo, GpioSpeedVeryHigh); - - //FURI_CRITICAL_ENTER(); - // 10 ms pulse on TX - furi_hal_gpio_write(&gpio_usart_tx, true); - furi_delay_ms(10); - furi_hal_gpio_write(&gpio_usart_tx, false); - - // TODO change from furi_get_tick(), which returns ms, - // to DWT->CYCCNT, which is a more precise counter with - // us precision (see furi_hal_cortex_delay_us) - - const uint32_t start = furi_get_tick(); - - while(furi_get_tick() - start < timeout_ms && furi_hal_gpio_read(&gpio_usart_rx)) - ; - while(furi_get_tick() - start < timeout_ms && !furi_hal_gpio_read(&gpio_usart_rx)) - ; - - const uint32_t pulse_start = furi_get_tick(); - - while(furi_get_tick() - start < timeout_ms && furi_hal_gpio_read(&gpio_usart_rx)) - ; - - const uint32_t pulse_end = furi_get_tick(); - //FURI_CRITICAL_EXIT(); - - plugin_state->echo = pulse_end - pulse_start; - plugin_state->distance = hc_sr04_ms_to_m(pulse_end - pulse_start); - plugin_state->measurement_made = true; - - //furi_hal_light_set(LightRed, 0x00); - notification_message(plugin_state->notification, &sequence_blink_stop); - notification_message(plugin_state->notification, &sequence_done); -} - -int32_t hc_sr04_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - PluginState* plugin_state = malloc(sizeof(PluginState)); - - hc_sr04_state_init(plugin_state); - - furi_hal_console_disable(); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - FURI_LOG_E("hc_sr04", "cannot create mutex\r\n"); - if(furi_hal_power_is_otg_enabled()) { - furi_hal_power_disable_otg(); - } - furi_hal_console_enable(); - furi_hal_power_suppress_charge_exit(); - furi_message_queue_free(event_queue); - free(plugin_state); - return 255; - } - - plugin_state->notification = furi_record_open(RECORD_NOTIFICATION); - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - case InputKeyDown: - case InputKeyRight: - case InputKeyLeft: - break; - case InputKeyOk: - hc_sr04_measure(plugin_state); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - if(furi_hal_power_is_otg_enabled()) { - furi_hal_power_disable_otg(); - } - furi_hal_power_suppress_charge_exit(); - - // Return TX / RX back to usart mode - furi_hal_gpio_init_ex( - &gpio_usart_tx, - GpioModeAltFunctionPushPull, - GpioPullUp, - GpioSpeedVeryHigh, - GpioAltFn7USART1); - furi_hal_gpio_init_ex( - &gpio_usart_rx, - GpioModeAltFunctionPushPull, - GpioPullUp, - GpioSpeedVeryHigh, - GpioAltFn7USART1); - furi_hal_console_enable(); - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - furi_record_close(RECORD_NOTIFICATION); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/htu21d_temp_sensor/Readme.md b/applications/plugins/htu21d_temp_sensor/Readme.md deleted file mode 100644 index 45c332306..000000000 --- a/applications/plugins/htu21d_temp_sensor/Readme.md +++ /dev/null @@ -1,65 +0,0 @@ -[Original link](https://github.com/Mywk/FlipperTemperatureSensor) - -# Flipper Temperature Sensor - -## Supported sensors - -> HTU2xD, SHT2x, SI702x, SI700x, SI701x, AM2320 - -## What is this? - -A small app for the [Flipper Zero](https://flipperzero.one) that reads the [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) signal from a few temperature sensors and displays the current temperature and humidity. - -I'm using a [Sparkfun HTU21D sensor](https://learn.sparkfun.com/tutorials/htu21d-humidity-sensor-hookup-guide), also tested with a clone and with the Si7021 variant. - -![Flipper Temperature Sensor](images/Flipper.png) - -![App](images/App.png) - -
- -# How to Connect the HTU21D sensor -![Connection](images/Connection.png) - - -# How to install - -If you have the FAP loader, just copy the fap file from the Releases into your Flipper apps folder and you should be able to launch it from the menu. - -If you don't have the FAP loader you will have to bake this application together with your firmware (aka compile it all together). - -# FAQ - -## The app says the sensor is not found! - -1- Are the four connectors correctly soldered? - -2- Are the SCL and SDA connections correct? Re-check the "How to Connect the sensor" above. - -3- For the HTU21D, on the sensor board, there should be three contacts in the center, for it to work correctly they must be soldered together (basically drop a blob of solder to connect the three of them). Without the solder it looks like this: - -![Sensor](images/Sensor.png) - -## Which Flipper versions was this app tested on? - -Version 1.2 -- RM11221439-0.71.2 -- unlshd-015 -- 0.71.1 - -Version 1.1 -- RM10302252-0.70.1 -- unlshd-012 -- 0.68.2-1007-RM -- 0.68.1 -- 0.67.2 - -## I can't build the app together with the firmware? - -In the *application.fam*, don't forget to change the apptype, it should not be EXTERNAL but APP. - -# How to compile - -Place the temperature_sensor folder in the applications_user folder and compile using FBT. - -Please refer to the [Flipper Build Tool documentation](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/fbt.md). \ No newline at end of file diff --git a/applications/plugins/htu21d_temp_sensor/application.fam b/applications/plugins/htu21d_temp_sensor/application.fam deleted file mode 100644 index 5807d7f51..000000000 --- a/applications/plugins/htu21d_temp_sensor/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="HTU_Temperature_Sensor", - name="[HTU/+] Temperature Sensor", - apptype=FlipperAppType.EXTERNAL, - entry_point="temperature_sensor_app", - cdefines=["APP_TEMPERATURE_SENSOR"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=90, - fap_icon="temperature_sensor.png", - fap_category="GPIO", -) diff --git a/applications/plugins/htu21d_temp_sensor/docs/App.png b/applications/plugins/htu21d_temp_sensor/docs/App.png deleted file mode 100644 index a0373bdbd..000000000 Binary files a/applications/plugins/htu21d_temp_sensor/docs/App.png and /dev/null differ diff --git a/applications/plugins/htu21d_temp_sensor/docs/Connection.png b/applications/plugins/htu21d_temp_sensor/docs/Connection.png deleted file mode 100644 index b38f5c250..000000000 Binary files a/applications/plugins/htu21d_temp_sensor/docs/Connection.png and /dev/null differ diff --git a/applications/plugins/htu21d_temp_sensor/docs/Flipper.png b/applications/plugins/htu21d_temp_sensor/docs/Flipper.png deleted file mode 100644 index c85319593..000000000 Binary files a/applications/plugins/htu21d_temp_sensor/docs/Flipper.png and /dev/null differ diff --git a/applications/plugins/htu21d_temp_sensor/temperature_sensor.c b/applications/plugins/htu21d_temp_sensor/temperature_sensor.c deleted file mode 100644 index b04e40a7d..000000000 --- a/applications/plugins/htu21d_temp_sensor/temperature_sensor.c +++ /dev/null @@ -1,387 +0,0 @@ -/* Flipper App to read the values from a HTU2XD, SHT2X, SI702X, SI700X, SI701X or AM2320 Sensor */ -/* Created by Mywk - https://github.com/Mywk - https://mywk.net */ -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#define TS_DEFAULT_VALUE 0xFFFF - -#define TS_AVAILABLE_SENSORS 2 - -// HTU2XD, SHT2X, SI702X, SI700X address -#define HTU2XD_SHT2X_SI702X_SI700X_ADDRESS (0x40 << 1) -// SI701X ADDRESS -#define SI701X_ADDRESS (0x41 << 1) - -// HTU2XD, SHT2X, SI702X, SI700X commands -#define HTU21D_CMD_TEMPERATURE 0xE3 -#define HTU21D_CMD_HUMIDITY 0xE5 - -// AM2320 address -#define AM2320_ADDRESS (0x5C << 1) - -// Used for the temperature and humidity buffers -#define DATA_BUFFER_SIZE 8 - -// External I2C BUS -#define I2C_BUS &furi_hal_i2c_handle_external - -// Typedef enums to make everything easier to read - -typedef enum { TSSCmdNone, TSSCmdTemperature, TSSCmdHumidity } TSSCmdType; - -typedef enum { - TSSInitializing, - TSSNoSensor, - TSSPendingUpdate, -} TSStatus; - -typedef enum { - TSEventTypeTick, - TSEventTypeInput, -} TSEventType; - -typedef struct { - TSEventType type; - InputEvent input; -} TSEvent; - -// Possible return values for sensor_cmd -typedef enum { - TSCmdRet_Error, - TSCmdRet_HTU2XD_SHT2X_SI702X_SI700X, - TSCmdRet_SI701X, - TSCmdRet_AM2320, -} TSCmdRet; - -// External NotificationSequence RGB -extern const NotificationSequence sequence_blink_red_100; -extern const NotificationSequence sequence_blink_green_100; -extern const NotificationSequence sequence_blink_blue_100; - -// Current status of the temperature sensor app -static TSStatus temperature_sensor_current_status = TSSInitializing; - -// We keep track of the last cmd return -static TSCmdRet temperature_sensor_last_cmd_ret = TSCmdRet_Error; - -// Temperature and Humidity data buffers, ready to print -char ts_data_buffer_temperature_c[DATA_BUFFER_SIZE]; -char ts_data_buffer_temperature_f[DATA_BUFFER_SIZE]; -char ts_data_buffer_relative_humidity[DATA_BUFFER_SIZE]; -char ts_data_buffer_absolute_humidity[DATA_BUFFER_SIZE]; - -// -// Executes an I2C cmd (trx) -// -// -// CRC -// -// -// true if fetch was successful, false otherwise -// -static TSCmdRet temperature_sensor_cmd(TSSCmdType cmd, uint8_t* buffer) { - uint32_t timeout = furi_ms_to_ticks(100); - TSCmdRet ret = TSCmdRet_Error; - - // Aquire I2C and check if device is ready, then release - furi_hal_i2c_acquire(I2C_BUS); - - // Check if HTU2XD, SHT2X, SI702X, SI700X sensor is available - uint8_t isAddress40 = - furi_hal_i2c_is_device_ready(I2C_BUS, HTU2XD_SHT2X_SI702X_SI700X_ADDRESS, timeout); - uint8_t isAddress41 = 0; - - // Check if SI701X sensor is available if necessary - if(!isAddress40) isAddress41 = furi_hal_i2c_is_device_ready(I2C_BUS, SI701X_ADDRESS, timeout); - - if(isAddress40 || isAddress41) { - uint8_t address = isAddress40 ? HTU2XD_SHT2X_SI702X_SI700X_ADDRESS : SI701X_ADDRESS; - - // Better safe than sorry delay - furi_delay_ms(15); - - // Extra delay for the SI70XX - if(isAddress41) furi_delay_ms(50); - - // Transmit either the temperature or the humidity command depending on TSSCmdType - uint8_t c = (cmd == TSSCmdTemperature) ? HTU21D_CMD_TEMPERATURE : HTU21D_CMD_HUMIDITY; - if(furi_hal_i2c_tx(I2C_BUS, address, &c, 1, timeout)) { - // Receive data (2 bytes) - if(furi_hal_i2c_rx(I2C_BUS, address, buffer, 2, timeout + 50)) - ret = isAddress40 ? TSCmdRet_HTU2XD_SHT2X_SI702X_SI700X : TSCmdRet_SI701X; - } - } else { - // The AM2320 goes to sleep after a period of inactivity, wake it up (check AM2320 datasheet for more info) - furi_hal_i2c_is_device_ready(I2C_BUS, AM2320_ADDRESS, timeout); - furi_delay_ms(30); - - // Check if it's really available - if(furi_hal_i2c_is_device_ready(I2C_BUS, AM2320_ADDRESS, timeout)) { - // {Address, Register, Len} - const uint8_t request[3] = {0x03, 0x00, 0x04}; - - if(furi_hal_i2c_tx(I2C_BUS, AM2320_ADDRESS, request, 3, timeout)) { - // 6 bytes - usually 8 but we currently don't check the CRC - if(furi_hal_i2c_rx(I2C_BUS, (uint8_t)AM2320_ADDRESS, buffer, 6, timeout)) - ret = TSCmdRet_AM2320; - } - } - } - - furi_hal_i2c_release(I2C_BUS); - - temperature_sensor_last_cmd_ret = ret; - return ret; -} - -// -// Fetches temperature and humidity from sensor -// -// -// temperature in C -// humidity in relative humidity -// -// -// Temperature and humidity must be preallocated -// -// -// CRC -// -// -// true if fetch was successful, false otherwise -// -static bool temperature_sensor_fetch_data(double* temperature, double* humidity) { - bool ret = false; - - uint16_t adc_raw; - - uint8_t buffer[DATA_BUFFER_SIZE] = {0x00}; - - // Check if the sensor is the HTU21D by attempting to fetch the temperature - TSCmdRet cmdRet = temperature_sensor_cmd(TSSCmdTemperature, buffer); - if(cmdRet == TSCmdRet_HTU2XD_SHT2X_SI702X_SI700X || cmdRet == TSCmdRet_SI701X) { - // Calculate temperature - adc_raw = ((uint16_t)(buffer[0] << 8) | (buffer[1])); - *temperature = (float)(adc_raw * 175.72 / 65536.00) - 46.85; - - // Fetch humidity - if(temperature_sensor_cmd(TSSCmdHumidity, buffer)) { - // Calculate humidity - adc_raw = ((uint16_t)(buffer[0] << 8) | (buffer[1])); - *humidity = (float)(adc_raw * 125.0 / 65536.00) - 6.0; - - ret = true; - } - } else if(cmdRet == TSCmdRet_AM2320) { - // The AM2320 returns all the data immediately so we just process it all - // Note: CRC isn't currently present in the buffer - - // Temperature - float temp = (((buffer[4] & 0x7F) << 8) + buffer[5]) / 10; - *temperature = ((buffer[4] & 0x80) >> 7) == 1 ? temp * (-1) : temp; - - // Humidity - temp = ((buffer[2] << 8) + buffer[3]) / 10; - *humidity = temp; - - ret = true; - } - - return ret; -} - -// -// Draw callback -// -static void temperature_sensor_draw_callback(Canvas* canvas, void* ctx) { - UNUSED(ctx); - - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - - // Update title accordingly (this could be improved by checking the hardware id) - switch(temperature_sensor_last_cmd_ret) { - case TSCmdRet_Error: - canvas_draw_str(canvas, 2, 10, "Temperature Sensor"); - break; - - case TSCmdRet_HTU2XD_SHT2X_SI702X_SI700X: - canvas_draw_str(canvas, 2, 10, "HTU/SHT/SI70 Sensor"); - break; - - case TSCmdRet_SI701X: - canvas_draw_str(canvas, 2, 10, "SI701X Sensor"); - break; - - case TSCmdRet_AM2320: - canvas_draw_str(canvas, 2, 10, "AM2320 Sensor"); - break; - - default: - break; - } - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 2, 62, "Press back to exit."); - - switch(temperature_sensor_current_status) { - case TSSInitializing: - canvas_draw_str(canvas, 2, 30, "Initializing.."); - break; - case TSSNoSensor: - canvas_draw_str(canvas, 2, 30, "No sensor found!"); - break; - case TSSPendingUpdate: { - canvas_draw_str(canvas, 3, 24, "Temperature"); - canvas_draw_str(canvas, 68, 24, "Humidity"); - - // Draw vertical lines - canvas_draw_line(canvas, 61, 16, 61, 50); - canvas_draw_line(canvas, 62, 16, 62, 50); - - // Draw horizontal line - canvas_draw_line(canvas, 2, 27, 122, 27); - - // Draw temperature and humidity values - canvas_draw_str(canvas, 8, 38, ts_data_buffer_temperature_c); - canvas_draw_str(canvas, 42, 38, "C"); - canvas_draw_str(canvas, 8, 48, ts_data_buffer_temperature_f); - canvas_draw_str(canvas, 42, 48, "F"); - canvas_draw_str(canvas, 68, 38, ts_data_buffer_relative_humidity); - canvas_draw_str(canvas, 100, 38, "%"); - canvas_draw_str(canvas, 68, 48, ts_data_buffer_absolute_humidity); - canvas_draw_str(canvas, 100, 48, "g/m3"); - } break; - default: - break; - } -} - -// -// Input callback -// -static void temperature_sensor_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); - FuriMessageQueue* event_queue = ctx; - - TSEvent event = {.type = TSEventTypeInput, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -// -// Timer callback -// -static void temperature_sensor_timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - TSEvent event = {.type = TSEventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -// -// App entry point -// -int32_t temperature_sensor_app(void* p) { - UNUSED(p); - - // Declare our variables and assign variables a default value - TSEvent tsEvent; - bool sensorFound = false; - double celsius, fahrenheit, rel_humidity, abs_humidity = TS_DEFAULT_VALUE; - - // Used for absolute humidity calculation - double vapour_pressure = 0; - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(TSEvent)); - - // Register callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, temperature_sensor_draw_callback, NULL); - view_port_input_callback_set(view_port, temperature_sensor_input_callback, event_queue); - - // Create timer and register its callback - FuriTimer* timer = - furi_timer_alloc(temperature_sensor_timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, furi_kernel_get_tick_frequency()); - - // Register viewport - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - // Used to notify the user by blinking red (error) or blue (fetch successful) - NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION); - - while(1) { - furi_check(furi_message_queue_get(event_queue, &tsEvent, FuriWaitForever) == FuriStatusOk); - - // Handle events - if(tsEvent.type == TSEventTypeInput) { - // Exit on back key - if(tsEvent.input.key == - InputKeyBack) // We dont check for type here, we can check the type of keypress like: (event.input.type == InputTypeShort) - break; - } else if(tsEvent.type == TSEventTypeTick) { - // Update sensor data - // Fetch data and set the sensor current status accordingly - sensorFound = temperature_sensor_fetch_data(&celsius, &rel_humidity); - temperature_sensor_current_status = (sensorFound ? TSSPendingUpdate : TSSNoSensor); - - if(sensorFound) { - // Blink blue - notification_message(notifications, &sequence_blink_blue_100); - - if(celsius != TS_DEFAULT_VALUE && rel_humidity != TS_DEFAULT_VALUE) { - // Convert celsius to fahrenheit - fahrenheit = (celsius * 9 / 5) + 32; - - // Calculate absolute humidity - For more info refer to https://github.com/Mywk/FlipperTemperatureSensor/issues/1 - // Calculate saturation vapour pressure first - vapour_pressure = - (double)6.11 * - pow(10, (double)(((double)7.5 * celsius) / ((double)237.3 + celsius))); - // Then the vapour pressure in Pa - vapour_pressure = vapour_pressure * rel_humidity; - // Calculate absolute humidity - abs_humidity = - (double)2.16679 * (double)(vapour_pressure / ((double)273.15 + celsius)); - - // Fill our buffers here, not on the canvas draw callback - snprintf(ts_data_buffer_temperature_c, DATA_BUFFER_SIZE, "%.2f", celsius); - snprintf(ts_data_buffer_temperature_f, DATA_BUFFER_SIZE, "%.2f", fahrenheit); - snprintf( - ts_data_buffer_relative_humidity, DATA_BUFFER_SIZE, "%.2f", rel_humidity); - snprintf( - ts_data_buffer_absolute_humidity, DATA_BUFFER_SIZE, "%.2f", abs_humidity); - } - } else { - // Reset our variables to their default values - celsius = fahrenheit = rel_humidity = abs_humidity = TS_DEFAULT_VALUE; - - // Blink red - notification_message(notifications, &sequence_blink_red_100); - } - } - - furi_delay_ms(!sensorFound ? 100 : 500); - } - - // Dobby is freee (free our variables, Flipper will crash if we don't do this!) - furi_timer_free(timer); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - furi_message_queue_free(event_queue); - - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_GUI); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/htu21d_temp_sensor/temperature_sensor.png b/applications/plugins/htu21d_temp_sensor/temperature_sensor.png deleted file mode 100644 index b6fe6d7fe..000000000 Binary files a/applications/plugins/htu21d_temp_sensor/temperature_sensor.png and /dev/null differ diff --git a/applications/plugins/ifttt/application.fam b/applications/plugins/ifttt/application.fam deleted file mode 100644 index 495627429..000000000 --- a/applications/plugins/ifttt/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="ESP8266_IFTTT_Virtual_Button", - name="[ESP8266] IFTTT Virtual Button", - apptype=FlipperAppType.EXTERNAL, - entry_point="ifttt_virtual_button_app", - cdefines=["APP_IFTTT_VIRTUAL_BUTTON"], - requires=[ - "gui", - ], - stack_size=2 * 1024, - order=20, - fap_icon="icon.png", - fap_category="GPIO", -) \ No newline at end of file diff --git a/applications/plugins/ifttt/icon.png b/applications/plugins/ifttt/icon.png deleted file mode 100644 index f6d586b38..000000000 Binary files a/applications/plugins/ifttt/icon.png and /dev/null differ diff --git a/applications/plugins/ifttt/ifttt_virtual_button.c b/applications/plugins/ifttt/ifttt_virtual_button.c deleted file mode 100644 index e23b8715d..000000000 --- a/applications/plugins/ifttt/ifttt_virtual_button.c +++ /dev/null @@ -1,251 +0,0 @@ -#include "ifttt_virtual_button.h" - -#define IFTTT_FOLDER "/ext/ifttt" -#define IFTTT_CONFIG_FOLDER "/ext/ifttt/config" -const char* CONFIG_FILE_PATH = "/ext/ifttt/config/config.settings"; - -#define FLIPPERZERO_SERIAL_BAUD 115200 -typedef enum ESerialCommand { ESerialCommand_Config } ESerialCommand; - -Settings save_settings(Settings settings) { - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* file = flipper_format_file_alloc(storage); - if(flipper_format_file_open_existing(file, CONFIG_FILE_PATH)) { - flipper_format_update_string_cstr(file, CONF_SSID, settings.save_ssid); - flipper_format_update_string_cstr(file, CONF_PASSWORD, settings.save_password); - flipper_format_update_string_cstr(file, CONF_KEY, settings.save_key); - flipper_format_update_string_cstr(file, CONF_EVENT, settings.save_event); - } else { - } - flipper_format_file_close(file); - flipper_format_free(file); - furi_record_close(RECORD_STORAGE); - return settings; -} - -void save_settings_file(FlipperFormat* file, Settings* settings) { - flipper_format_write_header_cstr(file, CONFIG_FILE_HEADER, CONFIG_FILE_VERSION); - flipper_format_write_comment_cstr(file, "Enter here the SSID of the wifi network"); - flipper_format_write_string_cstr(file, CONF_SSID, settings->save_ssid); - flipper_format_write_comment_cstr(file, "Enter here the PASSWORD of the wifi network"); - flipper_format_write_string_cstr(file, CONF_PASSWORD, settings->save_password); - flipper_format_write_comment_cstr(file, "Enter here the WEBHOOKS of your IFTTT account"); - flipper_format_write_string_cstr(file, CONF_KEY, settings->save_key); - flipper_format_write_comment_cstr(file, "Enter here the EVENT name of your trigger"); - flipper_format_write_string_cstr(file, CONF_EVENT, settings->save_event); -} - -Settings* load_settings() { - Settings* settings = malloc(sizeof(Settings)); - - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* file = flipper_format_file_alloc(storage); - - FuriString* string_value; - string_value = furi_string_alloc(); - FuriString* text_ssid_value; - text_ssid_value = furi_string_alloc(); - FuriString* text_password_value; - text_password_value = furi_string_alloc(); - FuriString* text_key_value; - text_key_value = furi_string_alloc(); - FuriString* text_event_value; - text_event_value = furi_string_alloc(); - - if(storage_common_stat(storage, CONFIG_FILE_PATH, NULL) != FSE_OK) { - if(!flipper_format_file_open_new(file, CONFIG_FILE_PATH)) { - flipper_format_file_close(file); - } else { - settings->save_ssid = malloc(1); - settings->save_password = malloc(1); - settings->save_key = malloc(1); - settings->save_event = malloc(1); - - settings->save_ssid[0] = '\0'; - settings->save_password[0] = '\0'; - settings->save_key[0] = '\0'; - settings->save_event[0] = '\0'; - - save_settings_file(file, settings); - flipper_format_file_close(file); - } - } else { - if(!flipper_format_file_open_existing(file, CONFIG_FILE_PATH)) { - flipper_format_file_close(file); - } else { - uint32_t value; - if(!flipper_format_read_header(file, string_value, &value)) { - } else { - if(flipper_format_read_string(file, CONF_SSID, text_ssid_value)) { - settings->save_ssid = malloc(furi_string_size(text_ssid_value) + 1); - strcpy(settings->save_ssid, furi_string_get_cstr(text_ssid_value)); - } - if(flipper_format_read_string(file, CONF_PASSWORD, text_password_value)) { - settings->save_password = malloc(furi_string_size(text_password_value) + 1); - strcpy(settings->save_password, furi_string_get_cstr(text_password_value)); - } - if(flipper_format_read_string(file, CONF_KEY, text_key_value)) { - settings->save_key = malloc(furi_string_size(text_key_value) + 1); - strcpy(settings->save_key, furi_string_get_cstr(text_key_value)); - } - if(flipper_format_read_string(file, CONF_EVENT, text_event_value)) { - settings->save_event = malloc(furi_string_size(text_event_value) + 1); - strcpy(settings->save_event, furi_string_get_cstr(text_event_value)); - } - } - flipper_format_file_close(file); - } - } - - furi_string_free(text_ssid_value); - furi_string_free(text_password_value); - furi_string_free(text_key_value); - furi_string_free(text_event_value); - flipper_format_free(file); - furi_record_close(RECORD_STORAGE); - return settings; -} - -void send_serial_command_config(ESerialCommand command, Settings* settings) { - uint8_t data[1] = {0}; - - char config_tmp[100]; - strcpy(config_tmp, "config,"); - strcat(config_tmp, settings->save_key); - char config_tmp2[5]; - strcpy(config_tmp2, config_tmp); - strcat(config_tmp2, ","); - char config_tmp3[100]; - strcpy(config_tmp3, config_tmp2); - strcat(config_tmp3, settings->save_ssid); - char config_tmp4[5]; - strcpy(config_tmp4, config_tmp3); - strcat(config_tmp4, ","); - char config_tmp5[100]; - strcpy(config_tmp5, config_tmp4); - strcat(config_tmp5, settings->save_password); - char config_tmp6[5]; - strcpy(config_tmp6, config_tmp5); - strcat(config_tmp6, ","); - char config[350]; - strcpy(config, config_tmp6); - strcat(config, settings->save_event); - - int length = strlen(config); - for(int i = 0; i < length; i++) { - switch(command) { - case ESerialCommand_Config: - data[0] = config[i]; - break; - default: - return; - }; - - furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1); - } -} - -static bool ifttt_virtual_button_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - VirtualButtonApp* app = context; - return scene_manager_handle_custom_event(app->scene_manager, event); -} - -static bool ifttt_virtual_button_back_event_callback(void* context) { - furi_assert(context); - VirtualButtonApp* app = context; - return scene_manager_handle_back_event(app->scene_manager); -} - -static void ifttt_virtual_button_tick_event_callback(void* context) { - furi_assert(context); - VirtualButtonApp* app = context; - scene_manager_handle_tick_event(app->scene_manager); -} - -VirtualButtonApp* ifttt_virtual_button_app_alloc(uint32_t first_scene) { - VirtualButtonApp* app = malloc(sizeof(VirtualButtonApp)); - - // Records - app->gui = furi_record_open(RECORD_GUI); - app->power = furi_record_open(RECORD_POWER); - - // View dispatcher - app->view_dispatcher = view_dispatcher_alloc(); - app->scene_manager = scene_manager_alloc(&virtual_button_scene_handlers, app); - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - view_dispatcher_set_custom_event_callback( - app->view_dispatcher, ifttt_virtual_button_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - app->view_dispatcher, ifttt_virtual_button_back_event_callback); - view_dispatcher_set_tick_event_callback( - app->view_dispatcher, ifttt_virtual_button_tick_event_callback, 2000); - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - // Views - app->sen_view = send_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, VirtualButtonAppViewSendView, send_view_get_view(app->sen_view)); - - app->abou_view = about_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, VirtualButtonAppViewAboutView, about_view_get_view(app->abou_view)); - - app->submenu = submenu_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, VirtualButtonAppViewSubmenu, submenu_get_view(app->submenu)); - app->dialog = dialog_ex_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, VirtualButtonAppViewDialog, dialog_ex_get_view(app->dialog)); - - // Set first scene - scene_manager_next_scene(app->scene_manager, first_scene); - return app; -} - -void ifttt_virtual_button_app_free(VirtualButtonApp* app) { - furi_assert(app); - - free(app->settings.save_ssid); - free(app->settings.save_password); - free(app->settings.save_key); - - // Views - view_dispatcher_remove_view(app->view_dispatcher, VirtualButtonAppViewSendView); - send_view_free(app->sen_view); - view_dispatcher_remove_view(app->view_dispatcher, VirtualButtonAppViewAboutView); - about_view_free(app->abou_view); - view_dispatcher_remove_view(app->view_dispatcher, VirtualButtonAppViewSubmenu); - submenu_free(app->submenu); - view_dispatcher_remove_view(app->view_dispatcher, VirtualButtonAppViewDialog); - dialog_ex_free(app->dialog); - // View dispatcher - view_dispatcher_free(app->view_dispatcher); - scene_manager_free(app->scene_manager); - // Records - furi_record_close(RECORD_POWER); - furi_record_close(RECORD_GUI); - - free(app); -} - -int32_t ifttt_virtual_button_app(void* p) { - UNUSED(p); - - Storage* storage = furi_record_open(RECORD_STORAGE); - if(!storage_simply_mkdir(storage, IFTTT_FOLDER)) { - } - if(!storage_simply_mkdir(storage, IFTTT_CONFIG_FOLDER)) { - } - furi_record_close(RECORD_STORAGE); - - uint32_t first_scene = VirtualButtonAppSceneStart; - VirtualButtonApp* app = ifttt_virtual_button_app_alloc(first_scene); - memcpy(&app->settings, load_settings(), sizeof(Settings)); - send_serial_command_config(ESerialCommand_Config, &(app->settings)); - - view_dispatcher_run(app->view_dispatcher); - ifttt_virtual_button_app_free(app); - return 0; -} \ No newline at end of file diff --git a/applications/plugins/ifttt/ifttt_virtual_button.h b/applications/plugins/ifttt/ifttt_virtual_button.h deleted file mode 100644 index 563f5cd95..000000000 --- a/applications/plugins/ifttt/ifttt_virtual_button.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include "views/send_view.h" -#include "views/about_view.h" -#include -#include -#include -#include -#include -#include -#include "scenes/virtual_button_scene.h" - -#define APP_NAME "[ESP8266] IFTTT Virtual Button" - -#define CONF_SSID "wifi_ssid" -#define CONF_PASSWORD "wifi_password" -#define CONF_KEY "webhooks_key" -#define CONF_EVENT "event" -#define CONFIG_FILE_HEADER "IFTTT Virtual Button Config File" -#define CONFIG_FILE_VERSION 1 - -typedef struct { - char* save_ssid; - char* save_password; - char* save_key; - char* save_event; -} Settings; - -typedef struct { - Power* power; - Gui* gui; - SceneManager* scene_manager; - ViewDispatcher* view_dispatcher; - SendView* sen_view; - AboutView* abou_view; - Submenu* submenu; - DialogEx* dialog; - PowerInfo info; - Settings settings; -} VirtualButtonApp; - -typedef enum { - VirtualButtonAppViewSendView, - VirtualButtonAppViewAboutView, - VirtualButtonAppViewSubmenu, - VirtualButtonAppViewDialog, -} VirtualButtonAppView; - -Settings save_settings(Settings settings); -Settings* load_settings(); \ No newline at end of file diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene.c b/applications/plugins/ifttt/scenes/virtual_button_scene.c deleted file mode 100644 index a75d822fc..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "virtual_button_scene.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const virtual_button_on_enter_handlers[])(void*) = { -#include "virtual_button_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const virtual_button_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "virtual_button_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const virtual_button_on_exit_handlers[])(void* context) = { -#include "virtual_button_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers virtual_button_scene_handlers = { - .on_enter_handlers = virtual_button_on_enter_handlers, - .on_event_handlers = virtual_button_on_event_handlers, - .on_exit_handlers = virtual_button_on_exit_handlers, - .scene_num = VirtualButtonAppSceneNum, -}; diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene.h b/applications/plugins/ifttt/scenes/virtual_button_scene.h deleted file mode 100644 index 870807dee..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) VirtualButtonAppScene##id, -typedef enum { -#include "virtual_button_scene_config.h" - VirtualButtonAppSceneNum, -} VirtualButtonAppScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers virtual_button_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "virtual_button_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "virtual_button_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "virtual_button_scene_config.h" -#undef ADD_SCENE diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene_about.c b/applications/plugins/ifttt/scenes/virtual_button_scene_about.c deleted file mode 100644 index 86fe1a9d0..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene_about.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "../ifttt_virtual_button.h" - -static void virtual_button_scene_about_view_update_model(VirtualButtonApp* app) { - power_get_info(app->power, &app->info); -} - -void virtual_button_scene_about_view_on_enter(void* context) { - VirtualButtonApp* app = context; - virtual_button_scene_about_view_update_model(app); - view_dispatcher_switch_to_view(app->view_dispatcher, VirtualButtonAppViewAboutView); -} - -bool virtual_button_scene_about_view_on_event(void* context, SceneManagerEvent event) { - VirtualButtonApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeTick) { - virtual_button_scene_about_view_update_model(app); - consumed = true; - } - return consumed; -} - -void virtual_button_scene_about_view_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene_config.h b/applications/plugins/ifttt/scenes/virtual_button_scene_config.h deleted file mode 100644 index 70af5ccf7..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene_config.h +++ /dev/null @@ -1,3 +0,0 @@ -ADD_SCENE(virtual_button, start, Start) -ADD_SCENE(virtual_button, send_view, SendView) -ADD_SCENE(virtual_button, about_view, AboutView) diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene_send.c b/applications/plugins/ifttt/scenes/virtual_button_scene_send.c deleted file mode 100644 index caa23fadf..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene_send.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "../ifttt_virtual_button.h" - -static void virtual_button_scene_send_view_update_model(VirtualButtonApp* app) { - power_get_info(app->power, &app->info); -} - -void virtual_button_scene_send_view_on_enter(void* context) { - VirtualButtonApp* app = context; - virtual_button_scene_send_view_update_model(app); - view_dispatcher_switch_to_view(app->view_dispatcher, VirtualButtonAppViewSendView); -} - -bool virtual_button_scene_send_view_on_event(void* context, SceneManagerEvent event) { - VirtualButtonApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeTick) { - virtual_button_scene_send_view_update_model(app); - consumed = true; - } - return consumed; -} - -void virtual_button_scene_send_view_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/ifttt/scenes/virtual_button_scene_start.c b/applications/plugins/ifttt/scenes/virtual_button_scene_start.c deleted file mode 100644 index 6b03a35f0..000000000 --- a/applications/plugins/ifttt/scenes/virtual_button_scene_start.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "../ifttt_virtual_button.h" - -enum VirtualButtonSubmenuIndex { - VirtualButtonSubmenuIndexSendView, - VirtualButtonSubmenuIndexAboutView, -}; - -static void virtual_button_scene_start_submenu_callback(void* context, uint32_t index) { - furi_assert(context); - VirtualButtonApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, index); -} - -void virtual_button_scene_start_on_enter(void* context) { - VirtualButtonApp* app = context; - Submenu* submenu = app->submenu; - - submenu_add_item( - submenu, - "Send IFTTT command", - VirtualButtonSubmenuIndexSendView, - virtual_button_scene_start_submenu_callback, - app); - submenu_add_item( - submenu, - "About", - VirtualButtonSubmenuIndexAboutView, - virtual_button_scene_start_submenu_callback, - app); - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(app->scene_manager, VirtualButtonAppSceneStart)); - - view_dispatcher_switch_to_view(app->view_dispatcher, VirtualButtonAppViewSubmenu); -} - -bool virtual_button_scene_start_on_event(void* context, SceneManagerEvent event) { - VirtualButtonApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == VirtualButtonSubmenuIndexSendView) { - scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneSendView); - } else if(event.event == VirtualButtonSubmenuIndexAboutView) { - scene_manager_next_scene(app->scene_manager, VirtualButtonAppSceneAboutView); - } - scene_manager_set_scene_state(app->scene_manager, VirtualButtonAppSceneStart, event.event); - consumed = true; - } - return consumed; -} - -void virtual_button_scene_start_on_exit(void* context) { - VirtualButtonApp* app = context; - submenu_reset(app->submenu); -} diff --git a/applications/plugins/ifttt/views/about_view.c b/applications/plugins/ifttt/views/about_view.c deleted file mode 100644 index 80c00883a..000000000 --- a/applications/plugins/ifttt/views/about_view.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "about_view.h" -#include -#include -#include -#include - -struct AboutView { - View* view; -}; - -typedef struct { - bool connected; -} AboutViewModel; - -static void about_view_draw_callback(Canvas* canvas, void* context) { - furi_assert(context); - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "IFTTT Virtual button"); - canvas_draw_str_aligned(canvas, 0, 15, AlignLeft, AlignTop, "Version 0.2"); - canvas_draw_str_aligned(canvas, 0, 50, AlignLeft, AlignTop, "press back"); -} - -AboutView* about_view_alloc() { - AboutView* about_view = malloc(sizeof(AboutView)); - about_view->view = view_alloc(); - view_set_context(about_view->view, about_view); - view_allocate_model(about_view->view, ViewModelTypeLocking, sizeof(AboutViewModel)); - view_set_draw_callback(about_view->view, about_view_draw_callback); - return about_view; -} - -void about_view_free(AboutView* about_view) { - furi_assert(about_view); - view_free(about_view->view); - free(about_view); -} - -View* about_view_get_view(AboutView* about_view) { - furi_assert(about_view); - return about_view->view; -} - -void about_view_set_data(AboutView* about_view, bool connected) { - furi_assert(about_view); - with_view_model( - about_view->view, AboutViewModel * model, { model->connected = connected; }, true); -} \ No newline at end of file diff --git a/applications/plugins/ifttt/views/about_view.h b/applications/plugins/ifttt/views/about_view.h deleted file mode 100644 index d1ac287e3..000000000 --- a/applications/plugins/ifttt/views/about_view.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -typedef struct AboutView AboutView; - -AboutView* about_view_alloc(); - -void about_view_free(AboutView* about_view); - -View* about_view_get_view(AboutView* about_view); \ No newline at end of file diff --git a/applications/plugins/ifttt/views/send_view.c b/applications/plugins/ifttt/views/send_view.c deleted file mode 100644 index 6046c39e3..000000000 --- a/applications/plugins/ifttt/views/send_view.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "send_view.h" -#include -#include -#include -#include -#include -#include -#include - -#define FLIPPERZERO_SERIAL_BAUD 115200 - -typedef enum ESerialCommand { ESerialCommand_Send } ESerialCommand; - -struct SendView { - View* view; -}; - -typedef struct { - bool right_pressed; - bool connected; -} SendViewModel; - -static void Shake(void) { - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - notification_message(notification, &sequence_single_vibro); - furi_record_close(RECORD_NOTIFICATION); -} - -void send_serial_command_send(ESerialCommand command) { - uint8_t data[1] = {0}; - - char name[10] = "send"; - int length = strlen(name); - for(int i = 0; i < length; i++) { - switch(command) { - case ESerialCommand_Send: - data[0] = name[i]; - break; - default: - return; - }; - - furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1); - } -} - -static void send_view_draw_callback(Canvas* canvas, void* context) { - furi_assert(context); - SendViewModel* model = context; - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 64, 0, AlignCenter, AlignTop, "SEND MODULE"); - canvas_draw_line(canvas, 0, 10, 128, 10); - canvas_draw_str_aligned(canvas, 64, 15, AlignCenter, AlignTop, "Press right to send IFTTT"); - canvas_draw_str_aligned(canvas, 64, 25, AlignCenter, AlignTop, "command or press and hold"); - canvas_draw_str_aligned(canvas, 64, 35, AlignCenter, AlignTop, "back to return to the menu"); - - // Right - if(model->right_pressed) { - } -} - -static void send_view_process(SendView* send_view, InputEvent* event) { - with_view_model( - send_view->view, - SendViewModel * model, - { - if(event->type == InputTypePress) { - if(event->key == InputKeyUp) { - } else if(event->key == InputKeyDown) { - } else if(event->key == InputKeyLeft) { - } else if(event->key == InputKeyRight) { - model->right_pressed = true; - Shake(); - send_serial_command_send(ESerialCommand_Send); - } else if(event->key == InputKeyOk) { - } else if(event->key == InputKeyBack) { - } - } else if(event->type == InputTypeRelease) { - if(event->key == InputKeyUp) { - } else if(event->key == InputKeyDown) { - } else if(event->key == InputKeyLeft) { - } else if(event->key == InputKeyRight) { - model->right_pressed = false; - } else if(event->key == InputKeyOk) { - } else if(event->key == InputKeyBack) { - } - } else if(event->type == InputTypeShort) { - if(event->key == InputKeyBack) { - } - } - }, - true); -} - -static bool send_view_input_callback(InputEvent* event, void* context) { - furi_assert(context); - SendView* send_view = context; - bool consumed = false; - - if(event->type == InputTypeLong && event->key == InputKeyBack) { - } else { - send_view_process(send_view, event); - consumed = true; - } - - return consumed; -} - -SendView* send_view_alloc() { - SendView* send_view = malloc(sizeof(SendView)); - send_view->view = view_alloc(); - view_set_context(send_view->view, send_view); - view_allocate_model(send_view->view, ViewModelTypeLocking, sizeof(SendViewModel)); - view_set_draw_callback(send_view->view, send_view_draw_callback); - view_set_input_callback(send_view->view, send_view_input_callback); - furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD); - - return send_view; -} - -void send_view_free(SendView* send_view) { - furi_assert(send_view); - view_free(send_view->view); - free(send_view); -} - -View* send_view_get_view(SendView* send_view) { - furi_assert(send_view); - return send_view->view; -} - -void send_view_set_data(SendView* send_view, bool connected) { - furi_assert(send_view); - with_view_model( - send_view->view, SendViewModel * model, { model->connected = connected; }, true); -} \ No newline at end of file diff --git a/applications/plugins/ifttt/views/send_view.h b/applications/plugins/ifttt/views/send_view.h deleted file mode 100644 index 4b1944dd4..000000000 --- a/applications/plugins/ifttt/views/send_view.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -typedef struct SendView SendView; - -SendView* send_view_alloc(); - -void send_view_free(SendView* send_view); - -View* send_view_get_view(SendView* send_view); \ No newline at end of file diff --git a/applications/plugins/lightmeter/.clang-format b/applications/plugins/lightmeter/.clang-format deleted file mode 100644 index 4b76f7fa4..000000000 --- a/applications/plugins/lightmeter/.clang-format +++ /dev/null @@ -1,191 +0,0 @@ ---- -Language: Cpp -AccessModifierOffset: -4 -AlignAfterOpenBracket: AlwaysBreak -AlignArrayOfStructures: None -AlignConsecutiveMacros: None -AlignConsecutiveAssignments: None -AlignConsecutiveBitFields: None -AlignConsecutiveDeclarations: None -AlignEscapedNewlines: Left -AlignOperands: Align -AlignTrailingComments: false -AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortEnumsOnASingleLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: true -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: - - __capability -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: true -BreakBeforeBraces: Attach -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: false -ColumnLimit: 99 -CommentPragmas: '^ IWYU pragma:' -QualifierAlignment: Leave -CompactNamespaces: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DeriveLineEnding: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -PackConstructorInitializers: BinPack -BasedOnStyle: '' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -AllowAllConstructorInitializersOnNextLine: true -FixNamespaceComments: false -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IfMacros: - - KJ_IF_MAYBE -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - SortPriority: 0 - CaseSensitive: false - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false -IncludeIsMainRegex: '(Test)?$' -IncludeIsMainSourceRegex: '' -IndentAccessModifiers: false -IndentCaseLabels: false -IndentCaseBlocks: false -IndentGotoLabels: true -IndentPPDirectives: None -IndentExternBlock: AfterExternBlock -IndentRequires: false -IndentWidth: 4 -IndentWrappedFunctionNames: true -InsertTrailingCommas: None -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -LambdaBodyIndentation: Signature -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 10 -PenaltyBreakBeforeFirstCallParameter: 30 -PenaltyBreakComment: 10 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakOpenParenthesis: 0 -PenaltyBreakString: 10 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 100 -PenaltyReturnTypeOnItsOwnLine: 60 -PenaltyIndentedWhitespace: 0 -PointerAlignment: Left -PPIndentWidth: -1 -ReferenceAlignment: Pointer -ReflowComments: false -RemoveBracesLLVM: false -SeparateDefinitionBlocks: Leave -ShortNamespaceLines: 1 -SortIncludes: Never -SortJavaStaticImport: Before -SortUsingDeclarations: false -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: Never -SpaceBeforeParensOptions: - AfterControlStatements: false - AfterForeachMacros: false - AfterFunctionDefinitionName: false - AfterFunctionDeclarationName: false - AfterIfMacros: false - AfterOverloadedOperator: false - BeforeNonEmptyParentheses: false -SpaceAroundPointerQualifiers: Default -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: Never -SpacesInConditionalStatement: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParentheses: false -SpacesInSquareBrackets: false -SpaceBeforeSquareBrackets: false -BitFieldColonSpacing: Both -Standard: c++03 -StatementAttributeLikeMacros: - - Q_EMIT -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 4 -UseCRLF: false -UseTab: Never -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE - - NS_SWIFT_NAME - - CF_SWIFT_NAME -... - diff --git a/applications/plugins/lightmeter/LICENSE b/applications/plugins/lightmeter/LICENSE deleted file mode 100644 index cb2f65db5..000000000 --- a/applications/plugins/lightmeter/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Oleksii Kutuzov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/lightmeter/README.md b/applications/plugins/lightmeter/README.md deleted file mode 100644 index dc6c6ffd5..000000000 --- a/applications/plugins/lightmeter/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# flipperzero-lightmeter - -[![Build FAP](https://github.com/oleksiikutuzov/flipperzero-lightmeter/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/oleksiikutuzov/flipperzero-lightmeter/actions/workflows/build.yml) - - - - - -## Wiring - -``` -VCC -> 3.3V -GND -> GND -SCL -> C0 -SDA -> C1 -``` - -## Sensor module - - - -### If you want to build this module, you'll need (it's quite over-engineered, sorry :D) -1. [Module PCB](https://github.com/oleksiikutuzov/flipperzero-lightmeter/blob/main/module/module_v2_gerber.zip) -2. [Enclosure](https://github.com/oleksiikutuzov/flipperzero-lightmeter/blob/main/module/module_v2_enclosure.stl) -3. 4-pin female header -4. 10-pin male header -5. 2x M3 threaded inserts (max diameter 5.3 mm, max height 4 mm) -6. 2x M3x5 screws - - -## TODO -- [ ] Save settings to sd card - -## References -App inspired by [lightmeter](https://github.com/vpominchuk/lightmeter) project for Arduino by [vpominchuk](https://github.com/vpominchuk). diff --git a/applications/plugins/lightmeter/application.fam b/applications/plugins/lightmeter/application.fam deleted file mode 100644 index b1de62641..000000000 --- a/applications/plugins/lightmeter/application.fam +++ /dev/null @@ -1,28 +0,0 @@ -App( - appid="BH1750_Lightmeter", - name="[BH1750] Lightmeter", - apptype=FlipperAppType.EXTERNAL, - entry_point="lightmeter_app", - cdefines=["APP_LIGHTMETER"], - requires=[ - "gui", - ], - stack_size=1 * 1024, - order=90, - fap_version=(0, 7), - fap_icon="lightmeter.png", - fap_category="GPIO", - fap_private_libs=[ - Lib( - name="BH1750", - cincludes=["."], - sources=[ - "BH1750.c", - ], - ), - ], - fap_icon_assets="icons", - fap_description="Lightmeter app for photography based on BH1750 sensor", - fap_author="Oleksii Kutuzov", - fap_weburl="https://github.com/oleksiikutuzov/flipperzero-lightmeter", -) diff --git a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.c b/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.c deleted file mode 100644 index 2487d5817..000000000 --- a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "lightmeter_scene.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const lightmeter_on_enter_handlers[])(void*) = { -#include "lightmeter_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const lightmeter_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "lightmeter_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const lightmeter_on_exit_handlers[])(void* context) = { -#include "lightmeter_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers lightmeter_scene_handlers = { - .on_enter_handlers = lightmeter_on_enter_handlers, - .on_event_handlers = lightmeter_on_event_handlers, - .on_exit_handlers = lightmeter_on_exit_handlers, - .scene_num = LightMeterAppSceneNum, -}; diff --git a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.h b/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.h deleted file mode 100644 index 9d5931384..000000000 --- a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) LightMeterAppScene##id, -typedef enum { -#include "lightmeter_scene_config.h" - LightMeterAppSceneNum, -} LightMeterAppScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers lightmeter_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "lightmeter_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "lightmeter_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "lightmeter_scene_config.h" -#undef ADD_SCENE diff --git a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene_config.h b/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene_config.h deleted file mode 100644 index c72a7713e..000000000 --- a/applications/plugins/lightmeter/gui/scenes/config/lightmeter_scene_config.h +++ /dev/null @@ -1,4 +0,0 @@ -ADD_SCENE(lightmeter, main, Main) -ADD_SCENE(lightmeter, config, Config) -ADD_SCENE(lightmeter, help, Help) -ADD_SCENE(lightmeter, about, About) diff --git a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_about.c b/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_about.c deleted file mode 100644 index 1508b4c00..000000000 --- a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_about.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "../../lightmeter.h" - -void lightmeter_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) { - LightMeterApp* app = context; - - UNUSED(app); - UNUSED(result); - UNUSED(type); - if(type == InputTypeShort) { - view_dispatcher_send_custom_event(app->view_dispatcher, result); - } -} - -void lightmeter_scene_about_on_enter(void* context) { - LightMeterApp* app = context; - - FuriString* temp_str; - temp_str = furi_string_alloc(); - furi_string_printf(temp_str, "\e#%s\n", "Information"); - - furi_string_cat_printf(temp_str, "Version: %s\n", LM_VERSION_APP); - furi_string_cat_printf(temp_str, "Developed by: %s\n", LM_DEVELOPED); - furi_string_cat_printf(temp_str, "Github: %s\n\n", LM_GITHUB); - - furi_string_cat_printf(temp_str, "\e#%s\n", "Description"); - furi_string_cat_printf( - temp_str, - "Showing suggested camera\nsettings based on ambient\nlight or flash.\n\nInspired by a lightmeter\nproject by vpominchuk\n"); - - widget_add_text_box_element( - app->widget, - 0, - 0, - 128, - 14, - AlignCenter, - AlignBottom, - "\e#\e! \e!\n", - false); - widget_add_text_box_element( - app->widget, - 0, - 2, - 128, - 14, - AlignCenter, - AlignBottom, - "\e#\e! Lightmeter \e!\n", - false); - widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str)); - furi_string_free(temp_str); - - view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewAbout); -} - -bool lightmeter_scene_about_on_event(void* context, SceneManagerEvent event) { - LightMeterApp* app = context; - - bool consumed = false; - UNUSED(app); - UNUSED(event); - - return consumed; -} - -void lightmeter_scene_about_on_exit(void* context) { - LightMeterApp* app = context; - - // Clear views - widget_reset(app->widget); -} diff --git a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_config.c b/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_config.c deleted file mode 100644 index 3d6bd5803..000000000 --- a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_config.c +++ /dev/null @@ -1,216 +0,0 @@ -#include "../../lightmeter.h" - -#define TAG "Scene Config" - -static const char* iso_numbers[] = { - [ISO_6] = "6", - [ISO_12] = "12", - [ISO_25] = "25", - [ISO_50] = "50", - [ISO_100] = "100", - [ISO_200] = "200", - [ISO_400] = "400", - [ISO_800] = "800", - [ISO_1600] = "1600", - [ISO_3200] = "3200", - [ISO_6400] = "6400", - [ISO_12800] = "12800", - [ISO_25600] = "25600", - [ISO_51200] = "51200", - [ISO_102400] = "102400", -}; - -static const char* nd_numbers[] = { - [ND_0] = "0", - [ND_2] = "2", - [ND_4] = "4", - [ND_8] = "8", - [ND_16] = "16", - [ND_32] = "32", - [ND_64] = "64", - [ND_128] = "128", - [ND_256] = "256", - [ND_512] = "512", - [ND_1024] = "1024", - [ND_2048] = "2048", - [ND_4096] = "4096", -}; - -static const char* diffusion_dome[] = { - [WITHOUT_DOME] = "No", - [WITH_DOME] = "Yes", -}; - -static const char* backlight[] = { - [BACKLIGHT_AUTO] = "Auto", - [BACKLIGHT_ON] = "On", -}; - -static const char* lux_only[] = { - [LUX_ONLY_OFF] = "Off", - [LUX_ONLY_ON] = "On", -}; - -enum LightMeterSubmenuIndex { - LightMeterSubmenuIndexISO, - LightMeterSubmenuIndexND, - LightMeterSubmenuIndexDome, - LightMeterSubmenuIndexBacklight, - LightMeterSubmenuIndexLuxMeter, - LightMeterSubmenuIndexHelp, - LightMeterSubmenuIndexAbout, -}; - -static void iso_numbers_cb(VariableItem* item) { - LightMeterApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, iso_numbers[index]); - - LightMeterConfig* config = app->config; - config->iso = index; - lightmeter_app_set_config(app, config); -} - -static void nd_numbers_cb(VariableItem* item) { - LightMeterApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, nd_numbers[index]); - - LightMeterConfig* config = app->config; - config->nd = index; - lightmeter_app_set_config(app, config); -} - -static void dome_presence_cb(VariableItem* item) { - LightMeterApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, diffusion_dome[index]); - - LightMeterConfig* config = app->config; - config->dome = index; - lightmeter_app_set_config(app, config); -} - -static void backlight_cb(VariableItem* item) { - LightMeterApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, backlight[index]); - - LightMeterConfig* config = app->config; - if(index != config->backlight) { - if(index == BACKLIGHT_ON) { - notification_message( - app->notifications, - &sequence_display_backlight_enforce_on); // force on backlight - } else { - notification_message( - app->notifications, - &sequence_display_backlight_enforce_auto); // force auto backlight - } - } - config->backlight = index; - lightmeter_app_set_config(app, config); -} - -static void lux_only_cb(VariableItem* item) { - LightMeterApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, lux_only[index]); - - LightMeterConfig* config = app->config; - config->lux_only = index; - lightmeter_app_set_config(app, config); -} - -static void ok_cb(void* context, uint32_t index) { - LightMeterApp* app = context; - UNUSED(app); - switch(index) { - case LightMeterSubmenuIndexHelp: - view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventHelp); - break; - case LightMeterSubmenuIndexAbout: - view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventAbout); - break; - default: - break; - } -} - -void lightmeter_scene_config_on_enter(void* context) { - LightMeterApp* app = context; - VariableItemList* var_item_list = app->var_item_list; - VariableItem* item; - LightMeterConfig* config = app->config; - - item = - variable_item_list_add(var_item_list, "ISO", COUNT_OF(iso_numbers), iso_numbers_cb, app); - variable_item_set_current_value_index(item, config->iso); - variable_item_set_current_value_text(item, iso_numbers[config->iso]); - - item = variable_item_list_add( - var_item_list, "ND factor", COUNT_OF(nd_numbers), nd_numbers_cb, app); - variable_item_set_current_value_index(item, config->nd); - variable_item_set_current_value_text(item, nd_numbers[config->nd]); - - item = variable_item_list_add( - var_item_list, "Diffusion dome", COUNT_OF(diffusion_dome), dome_presence_cb, app); - variable_item_set_current_value_index(item, config->dome); - variable_item_set_current_value_text(item, diffusion_dome[config->dome]); - - item = - variable_item_list_add(var_item_list, "Backlight", COUNT_OF(backlight), backlight_cb, app); - variable_item_set_current_value_index(item, config->backlight); - variable_item_set_current_value_text(item, backlight[config->backlight]); - - item = variable_item_list_add( - var_item_list, "Lux meter only", COUNT_OF(lux_only), lux_only_cb, app); - variable_item_set_current_value_index(item, config->lux_only); - variable_item_set_current_value_text(item, lux_only[config->lux_only]); - - item = variable_item_list_add(var_item_list, "Help and Pinout", 0, NULL, NULL); - item = variable_item_list_add(var_item_list, "About", 0, NULL, NULL); - - variable_item_list_set_selected_item( - var_item_list, - scene_manager_get_scene_state(app->scene_manager, LightMeterAppSceneConfig)); - - variable_item_list_set_enter_callback(var_item_list, ok_cb, app); - - view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewVarItemList); -} - -bool lightmeter_scene_config_on_event(void* context, SceneManagerEvent event) { - LightMeterApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeTick) { - consumed = true; - } else if(event.type == SceneManagerEventTypeCustom) { - switch(event.event) { - case LightMeterAppCustomEventHelp: - scene_manager_next_scene(app->scene_manager, LightMeterAppSceneHelp); - consumed = true; - break; - case LightMeterAppCustomEventAbout: - scene_manager_next_scene(app->scene_manager, LightMeterAppSceneAbout); - consumed = true; - break; - } - } - return consumed; -} - -void lightmeter_scene_config_on_exit(void* context) { - LightMeterApp* app = context; - variable_item_list_reset(app->var_item_list); - main_view_set_iso(app->main_view, app->config->iso); - main_view_set_nd(app->main_view, app->config->nd); - main_view_set_dome(app->main_view, app->config->dome); - main_view_set_lux_only(app->main_view, app->config->lux_only); -} diff --git a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_help.c b/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_help.c deleted file mode 100644 index 0441f0925..000000000 --- a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_help.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "../../lightmeter.h" - -void lightmeter_scene_help_on_enter(void* context) { - LightMeterApp* app = context; - - FuriString* temp_str; - temp_str = furi_string_alloc(); - furi_string_printf( - temp_str, "App works with BH1750\nambient light sensor\nconnected via I2C interface\n\n"); - furi_string_cat(temp_str, "\e#Pinout:\r\n"); - furi_string_cat( - temp_str, - " VCC: 3.3V\r\n" - " GND: GND\r\n" - " SDA: 15 [C1]\r\n" - " SCL: 16 [C0]\r\n"); - - widget_add_text_scroll_element(app->widget, 0, 0, 128, 64, furi_string_get_cstr(temp_str)); - furi_string_free(temp_str); - - view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewHelp); -} - -bool lightmeter_scene_help_on_event(void* context, SceneManagerEvent event) { - UNUSED(context); - UNUSED(event); - return false; -} - -void lightmeter_scene_help_on_exit(void* context) { - LightMeterApp* app = context; - - widget_reset(app->widget); -} diff --git a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_main.c b/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_main.c deleted file mode 100644 index 8ba474461..000000000 --- a/applications/plugins/lightmeter/gui/scenes/lightmeter_scene_main.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "../../lightmeter.h" - -static void lightmeter_scene_main_on_left(void* context) { - LightMeterApp* app = context; - - view_dispatcher_send_custom_event(app->view_dispatcher, LightMeterAppCustomEventConfig); -} - -void lightmeter_scene_main_on_enter(void* context) { - LightMeterApp* app = context; - - lightmeter_main_view_set_left_callback(app->main_view, lightmeter_scene_main_on_left, app); - view_dispatcher_switch_to_view(app->view_dispatcher, LightMeterAppViewMainView); -} - -bool lightmeter_scene_main_on_event(void* context, SceneManagerEvent event) { - LightMeterApp* app = context; - - bool response = false; - - switch(event.type) { - case SceneManagerEventTypeCustom: - if(event.event == LightMeterAppCustomEventConfig) { - scene_manager_next_scene(app->scene_manager, LightMeterAppSceneConfig); - response = true; - } - break; - - case SceneManagerEventTypeTick: - lightmeter_app_i2c_callback(app); - response = true; - break; - - default: - break; - } - - return response; -} - -void lightmeter_scene_main_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/lightmeter/gui/views/main_view.c b/applications/plugins/lightmeter/gui/views/main_view.c deleted file mode 100644 index fcbafbff4..000000000 --- a/applications/plugins/lightmeter/gui/views/main_view.c +++ /dev/null @@ -1,470 +0,0 @@ -#include "main_view.h" -#include -#include -#include -#include "../../lightmeter.h" -#include "../../lightmeter_helper.h" - -#define WORKER_TAG "Main View" - -static const int iso_numbers[] = { - [ISO_6] = 6, - [ISO_12] = 12, - [ISO_25] = 25, - [ISO_50] = 50, - [ISO_100] = 100, - [ISO_200] = 200, - [ISO_400] = 400, - [ISO_800] = 800, - [ISO_1600] = 1600, - [ISO_3200] = 3200, - [ISO_6400] = 6400, - [ISO_12800] = 12800, - [ISO_25600] = 25600, - [ISO_51200] = 51200, - [ISO_102400] = 102400, -}; - -static const int nd_numbers[] = { - [ND_0] = 0, - [ND_2] = 2, - [ND_4] = 4, - [ND_8] = 8, - [ND_16] = 16, - [ND_32] = 32, - [ND_64] = 64, - [ND_128] = 128, - [ND_256] = 256, - [ND_512] = 512, - [ND_1024] = 1024, - [ND_2048] = 2048, - [ND_4096] = 4096, -}; - -const float aperture_numbers[] = { - [AP_1] = 1.0, - [AP_1_4] = 1.4, - [AP_2] = 2.0, - [AP_2_8] = 2.8, - [AP_4] = 4.0, - [AP_5_6] = 5.6, - [AP_8] = 8, - [AP_11] = 11, - [AP_16] = 16, - [AP_22] = 22, - [AP_32] = 32, - [AP_45] = 45, - [AP_64] = 64, - [AP_90] = 90, - [AP_128] = 128, -}; - -const float speed_numbers[] = { - [SPEED_8000] = 1.0 / 8000, [SPEED_4000] = 1.0 / 4000, [SPEED_2000] = 1.0 / 2000, - [SPEED_1000] = 1.0 / 1000, [SPEED_500] = 1.0 / 500, [SPEED_250] = 1.0 / 250, - [SPEED_125] = 1.0 / 125, [SPEED_60] = 1.0 / 60, [SPEED_30] = 1.0 / 30, - [SPEED_15] = 1.0 / 15, [SPEED_8] = 1.0 / 8, [SPEED_4] = 1.0 / 4, - [SPEED_2] = 1.0 / 2, [SPEED_1S] = 1.0, [SPEED_2S] = 2.0, - [SPEED_4S] = 4.0, [SPEED_8S] = 8.0, [SPEED_15S] = 15.0, - [SPEED_30S] = 30.0, -}; - -struct MainView { - View* view; - LightMeterMainViewButtonCallback cb_left; - void* cb_context; -}; - -void lightmeter_main_view_set_left_callback( - MainView* lightmeter_main_view, - LightMeterMainViewButtonCallback callback, - void* context) { - with_view_model( - lightmeter_main_view->view, - MainViewModel * model, - { - UNUSED(model); - lightmeter_main_view->cb_left = callback; - lightmeter_main_view->cb_context = context; - }, - true); -} - -static void main_view_draw_callback(Canvas* canvas, void* context) { - furi_assert(context); - MainViewModel* model = context; - - canvas_clear(canvas); - - // draw button - canvas_set_font(canvas, FontSecondary); - elements_button_left(canvas, "Config"); - - if(!model->lux_only) { - // top row - draw_top_row(canvas, model); - - // add f, T values - canvas_set_font(canvas, FontBigNumbers); - - // draw f icon and number - canvas_draw_icon(canvas, 15, 17, &I_f_10x14); - draw_aperture(canvas, model); - - // draw T icon and number - canvas_draw_icon(canvas, 15, 34, &I_T_10x14); - draw_speed(canvas, model); - - // draw ND number - draw_nd_number(canvas, model); - - // draw EV number - canvas_set_font(canvas, FontSecondary); - draw_EV_number(canvas, model); - - // draw mode indicator - draw_mode_indicator(canvas, model); - } else { - draw_lux_only_mode(canvas, model); - } -} - -static void main_view_process(MainView* main_view, InputEvent* event) { - with_view_model( - main_view->view, - MainViewModel * model, - { - if(event->type == InputTypePress) { - if(event->key == InputKeyUp) { - switch(model->current_mode) { - case FIXED_APERTURE: - if(model->aperture < AP_NUM - 1) model->aperture++; - break; - - case FIXED_SPEED: - if(model->speed < SPEED_NUM - 1) model->speed++; - break; - - default: - break; - } - } else if(event->key == InputKeyDown) { - switch(model->current_mode) { - case FIXED_APERTURE: - if(model->aperture > 0) model->aperture--; - break; - - case FIXED_SPEED: - if(model->speed > 0) model->speed--; - break; - - default: - break; - } - } else if(event->key == InputKeyOk) { - switch(model->current_mode) { - case FIXED_SPEED: - model->current_mode = FIXED_APERTURE; - break; - - case FIXED_APERTURE: - model->current_mode = FIXED_SPEED; - break; - - default: - break; - } - } - } - }, - true); -} - -static bool main_view_input_callback(InputEvent* event, void* context) { - furi_assert(context); - MainView* main_view = context; - bool consumed = false; - - if(event->type == InputTypeShort && event->key == InputKeyLeft) { - if(main_view->cb_left) { - main_view->cb_left(main_view->cb_context); - } - consumed = true; - } else if(event->type == InputTypeShort && event->key == InputKeyBack) { - } else { - main_view_process(main_view, event); - consumed = true; - } - - return consumed; -} - -MainView* main_view_alloc() { - MainView* main_view = malloc(sizeof(MainView)); - main_view->view = view_alloc(); - view_set_context(main_view->view, main_view); - view_allocate_model(main_view->view, ViewModelTypeLocking, sizeof(MainViewModel)); - view_set_draw_callback(main_view->view, main_view_draw_callback); - view_set_input_callback(main_view->view, main_view_input_callback); - - return main_view; -} - -void main_view_free(MainView* main_view) { - furi_assert(main_view); - view_free(main_view->view); - free(main_view); -} - -View* main_view_get_view(MainView* main_view) { - furi_assert(main_view); - return main_view->view; -} - -void main_view_set_lux(MainView* main_view, float val) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->lux = val; }, true); -} - -void main_view_set_EV(MainView* main_view, float val) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->EV = val; }, true); -} - -void main_view_set_response(MainView* main_view, bool val) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->response = val; }, true); -} - -void main_view_set_iso(MainView* main_view, int iso) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->iso = iso; }, true); -} - -void main_view_set_nd(MainView* main_view, int nd) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->nd = nd; }, true); -} - -void main_view_set_aperture(MainView* main_view, int aperture) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->aperture = aperture; }, true); -} - -void main_view_set_speed(MainView* main_view, int speed) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->speed = speed; }, true); -} - -void main_view_set_dome(MainView* main_view, bool dome) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->dome = dome; }, true); -} - -void main_view_set_lux_only(MainView* main_view, bool lux_only) { - furi_assert(main_view); - with_view_model( - main_view->view, MainViewModel * model, { model->lux_only = lux_only; }, true); -} - -bool main_view_get_dome(MainView* main_view) { - furi_assert(main_view); - bool val = false; - with_view_model( - main_view->view, MainViewModel * model, { val = model->dome; }, true); - return val; -} - -void draw_top_row(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - char str[12]; - - if(!model->response) { - canvas_draw_box(canvas, 0, 0, 128, 12); - canvas_set_color(canvas, ColorWhite); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 24, 10, "No sensor found"); - canvas_set_color(canvas, ColorBlack); - } else { - model->iso_val = iso_numbers[model->iso]; - if(model->nd > 0) model->iso_val /= nd_numbers[model->nd]; - - if(model->lux > 0) { - if(model->current_mode == FIXED_APERTURE) { - model->speed_val = 100 * pow(aperture_numbers[model->aperture], 2) / - (double)model->iso_val / pow(2, model->EV); - } else { - model->aperture_val = sqrt( - pow(2, model->EV) * (double)model->iso_val * - (double)speed_numbers[model->speed] / 100); - } - } - - // TODO when T:30, f/0 instead of f/128 - - canvas_draw_line(canvas, 0, 10, 128, 10); - - canvas_set_font(canvas, FontPrimary); - // metering mode A – ambient, F – flash - // canvas_draw_str_aligned(canvas, 1, 1, AlignLeft, AlignTop, "A"); - - snprintf(str, sizeof(str), "ISO: %d", iso_numbers[model->iso]); - canvas_draw_str_aligned(canvas, 19, 1, AlignLeft, AlignTop, str); - - canvas_set_font(canvas, FontSecondary); - snprintf(str, sizeof(str), "lx: %.0f", (double)model->lux); - canvas_draw_str_aligned(canvas, 87, 2, AlignLeft, AlignTop, str); - } -} - -void draw_aperture(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - char str[12]; - - switch(model->current_mode) { - case FIXED_APERTURE: - if(model->response) { - if(model->aperture < AP_8) { - snprintf(str, sizeof(str), "/%.1f", (double)aperture_numbers[model->aperture]); - } else { - snprintf(str, sizeof(str), "/%.0f", (double)aperture_numbers[model->aperture]); - } - } else { - snprintf(str, sizeof(str), " ---"); - } - canvas_draw_str_aligned(canvas, 27, 15, AlignLeft, AlignTop, str); - break; - case FIXED_SPEED: - if(model->aperture_val < aperture_numbers[0] || !model->response) { - snprintf(str, sizeof(str), " ---"); - } else if(model->aperture_val < aperture_numbers[AP_8]) { - snprintf(str, sizeof(str), "/%.1f", (double)normalizeAperture(model->aperture_val)); - } else { - snprintf(str, sizeof(str), "/%.0f", (double)normalizeAperture(model->aperture_val)); - } - canvas_draw_str_aligned(canvas, 27, 15, AlignLeft, AlignTop, str); - break; - default: - break; - } -} - -void draw_speed(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - char str[12]; - - switch(model->current_mode) { - case FIXED_APERTURE: - if(model->lux > 0 && model->response) { - if(model->speed_val < 1 && model->speed_val > 0) { - snprintf(str, sizeof(str), ":1/%.0f", 1 / (double)normalizeTime(model->speed_val)); - } else { - snprintf(str, sizeof(str), ":%.0f", (double)normalizeTime(model->speed_val)); - } - } else { - snprintf(str, sizeof(str), " ---"); - } - canvas_draw_str_aligned(canvas, 27, 34, AlignLeft, AlignTop, str); - break; - - case FIXED_SPEED: - if(model->response) { - if(model->speed < SPEED_1S) { - snprintf(str, sizeof(str), ":1/%.0f", 1 / (double)speed_numbers[model->speed]); - } else { - snprintf(str, sizeof(str), ":%.0f", (double)speed_numbers[model->speed]); - } - } else { - snprintf(str, sizeof(str), " ---"); - } - canvas_draw_str_aligned(canvas, 27, 34, AlignLeft, AlignTop, str); - break; - - default: - break; - } -} - -void draw_mode_indicator(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - switch(model->current_mode) { - case FIXED_SPEED: - canvas_set_font(canvas, FontBigNumbers); - canvas_draw_str_aligned(canvas, 3, 36, AlignLeft, AlignTop, "*"); - break; - - case FIXED_APERTURE: - canvas_set_font(canvas, FontBigNumbers); - canvas_draw_str_aligned(canvas, 3, 17, AlignLeft, AlignTop, "*"); - break; - - default: - break; - } -} - -void draw_nd_number(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - char str[9]; - - canvas_set_font(canvas, FontSecondary); - - if(model->response) { - snprintf(str, sizeof(str), "ND: %d", nd_numbers[model->nd]); - } else { - snprintf(str, sizeof(str), "ND: ---"); - } - canvas_draw_str_aligned(canvas, 87, 20, AlignLeft, AlignBottom, str); -} - -void draw_EV_number(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - char str[7]; - - if(model->lux > 0 && model->response) { - snprintf(str, sizeof(str), "EV: %1.0f", (double)model->EV); - canvas_draw_str_aligned(canvas, 87, 29, AlignLeft, AlignBottom, str); - } else { - canvas_draw_str_aligned(canvas, 87, 29, AlignLeft, AlignBottom, "EV: --"); - } -} - -void draw_lux_only_mode(Canvas* canvas, MainViewModel* context) { - MainViewModel* model = context; - - if(!model->response) { - canvas_draw_box(canvas, 0, 0, 128, 12); - canvas_set_color(canvas, ColorWhite); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 24, 10, "No sensor found"); - canvas_set_color(canvas, ColorBlack); - } else { - char str[12]; - - canvas_set_font(canvas, FontPrimary); - - canvas_draw_line(canvas, 0, 10, 128, 10); - canvas_draw_str_aligned(canvas, 64, 1, AlignCenter, AlignTop, "Lux meter mode"); - - canvas_set_font(canvas, FontBigNumbers); - snprintf(str, sizeof(str), "%.0f", (double)model->lux); - canvas_draw_str_aligned(canvas, 80, 32, AlignRight, AlignCenter, str); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 85, 39, AlignLeft, AlignBottom, "Lux"); - } -} diff --git a/applications/plugins/lightmeter/gui/views/main_view.h b/applications/plugins/lightmeter/gui/views/main_view.h deleted file mode 100644 index 42d2d1877..000000000 --- a/applications/plugins/lightmeter/gui/views/main_view.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include -#include "BH1750_Lightmeter_icons.h" -#include "../../lightmeter_config.h" - -typedef struct MainView MainView; - -typedef enum { - FIXED_APERTURE, - FIXED_SPEED, - - MODES_SIZE -} MainViewMode; - -typedef struct { - uint8_t recv[2]; - MainViewMode current_mode; - float lux; - float EV; - float aperture_val; - float speed_val; - int iso_val; - bool response; - int iso; - int nd; - int aperture; - int speed; - bool dome; - bool lux_only; -} MainViewModel; - -typedef void (*LightMeterMainViewButtonCallback)(void* context); - -void lightmeter_main_view_set_left_callback( - MainView* lightmeter_main_view, - LightMeterMainViewButtonCallback callback, - void* context); - -MainView* main_view_alloc(); - -void main_view_free(MainView* main_view); - -View* main_view_get_view(MainView* main_view); - -void main_view_set_lux(MainView* main_view, float val); - -void main_view_set_EV(MainView* main_view_, float val); - -void main_view_set_response(MainView* main_view_, bool val); - -void main_view_set_iso(MainView* main_view, int val); - -void main_view_set_nd(MainView* main_view, int val); - -void main_view_set_aperture(MainView* main_view, int val); - -void main_view_set_speed(MainView* main_view, int val); - -void main_view_set_dome(MainView* main_view, bool val); - -void main_view_set_lux_only(MainView* main_view, bool val); - -bool main_view_get_dome(MainView* main_view); - -void draw_top_row(Canvas* canvas, MainViewModel* context); - -void draw_aperture(Canvas* canvas, MainViewModel* context); - -void draw_speed(Canvas* canvas, MainViewModel* context); - -void draw_mode_indicator(Canvas* canvas, MainViewModel* context); - -void draw_nd_number(Canvas* canvas, MainViewModel* context); - -void draw_EV_number(Canvas* canvas, MainViewModel* context); - -void draw_lux_only_mode(Canvas* canvas, MainViewModel* context); diff --git a/applications/plugins/lightmeter/icons/T_10x14.png b/applications/plugins/lightmeter/icons/T_10x14.png deleted file mode 100644 index d81c2c424..000000000 Binary files a/applications/plugins/lightmeter/icons/T_10x14.png and /dev/null differ diff --git a/applications/plugins/lightmeter/icons/f_10x14.png b/applications/plugins/lightmeter/icons/f_10x14.png deleted file mode 100644 index c3e85c0ec..000000000 Binary files a/applications/plugins/lightmeter/icons/f_10x14.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/framed_gui_config.png b/applications/plugins/lightmeter/images/framed_gui_config.png deleted file mode 100644 index b87c3bd5c..000000000 Binary files a/applications/plugins/lightmeter/images/framed_gui_config.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/framed_gui_lux_meter.png b/applications/plugins/lightmeter/images/framed_gui_lux_meter.png deleted file mode 100644 index 6ab0cf191..000000000 Binary files a/applications/plugins/lightmeter/images/framed_gui_lux_meter.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/framed_gui_main.png b/applications/plugins/lightmeter/images/framed_gui_main.png deleted file mode 100644 index 23dc4a2cc..000000000 Binary files a/applications/plugins/lightmeter/images/framed_gui_main.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/gui_config.png b/applications/plugins/lightmeter/images/gui_config.png deleted file mode 100644 index 95fdcb167..000000000 Binary files a/applications/plugins/lightmeter/images/gui_config.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/gui_lux_meter.png b/applications/plugins/lightmeter/images/gui_lux_meter.png deleted file mode 100644 index f7159e671..000000000 Binary files a/applications/plugins/lightmeter/images/gui_lux_meter.png and /dev/null differ diff --git a/applications/plugins/lightmeter/images/gui_main.png b/applications/plugins/lightmeter/images/gui_main.png deleted file mode 100644 index ba4c3f75f..000000000 Binary files a/applications/plugins/lightmeter/images/gui_main.png and /dev/null differ diff --git a/applications/plugins/lightmeter/lib/BH1750/BH1750.c b/applications/plugins/lightmeter/lib/BH1750/BH1750.c deleted file mode 100644 index 28616e040..000000000 --- a/applications/plugins/lightmeter/lib/BH1750/BH1750.c +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file BH1750.h - * @author Oleksii Kutuzov (oleksii.kutuzov@icloud.com) - * @brief - * @version 0.1 - * @date 2022-11-06 - * - * @copyright Copyright (c) 2022 - * - * Ported from: - * https://github.com/lamik/Light_Sensors_STM32 - */ - -#include "BH1750.h" - -BH1750_mode bh1750_mode = BH1750_DEFAULT_MODE; // Current sensor mode -uint8_t bh1750_mt_reg = BH1750_DEFAULT_MTREG; // Current MT register value - -BH1750_STATUS bh1750_init() { - if(BH1750_OK == bh1750_reset()) { - if(BH1750_OK == bh1750_set_mt_reg(BH1750_DEFAULT_MTREG)) { - return BH1750_OK; - } - } - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_reset() { - uint8_t command = 0x07; - bool status; - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_tx(I2C_BUS, BH1750_ADDRESS, &command, 1, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - - if(status) { - return BH1750_OK; - } - - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_set_power_state(uint8_t PowerOn) { - PowerOn = (PowerOn ? 1 : 0); - bool status; - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_tx(I2C_BUS, BH1750_ADDRESS, &PowerOn, 1, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - - if(status) { - return BH1750_OK; - } - - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_set_mode(BH1750_mode mode) { - if(!((mode >> 4) || (mode >> 5))) { - return BH1750_ERROR; - } - - if((mode & 0x0F) > 3) { - return BH1750_ERROR; - } - - bool status; - - bh1750_mode = mode; - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_tx(I2C_BUS, BH1750_ADDRESS, &mode, 1, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - - if(status) { - return BH1750_OK; - } - - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_set_mt_reg(uint8_t mt_reg) { - if(mt_reg < 31 || mt_reg > 254) { - return BH1750_ERROR; - } - - bh1750_mt_reg = mt_reg; - - uint8_t tmp[2]; - bool status; - - tmp[0] = (0x40 | (mt_reg >> 5)); - tmp[1] = (0x60 | (mt_reg & 0x1F)); - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_tx(I2C_BUS, BH1750_ADDRESS, &tmp[0], 1, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - if(!status) { - return BH1750_ERROR; - } - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_tx(I2C_BUS, BH1750_ADDRESS, &tmp[1], 1, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - if(status) { - return BH1750_OK; - } - - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_trigger_manual_conversion() { - if(BH1750_OK == bh1750_set_mode(bh1750_mode)) { - return BH1750_OK; - } - return BH1750_ERROR; -} - -BH1750_STATUS bh1750_read_light(float* result) { - float result_tmp; - uint8_t rcv[2]; - bool status; - - furi_hal_i2c_acquire(I2C_BUS); - status = furi_hal_i2c_rx(I2C_BUS, BH1750_ADDRESS, rcv, 2, I2C_TIMEOUT); - furi_hal_i2c_release(I2C_BUS); - - if(status) { - result_tmp = (rcv[0] << 8) | (rcv[1]); - - if(bh1750_mt_reg != BH1750_DEFAULT_MTREG) { - result_tmp *= (float)((uint8_t)BH1750_DEFAULT_MTREG / (float)bh1750_mt_reg); - } - - if(bh1750_mode == ONETIME_HIGH_RES_MODE_2 || bh1750_mode == CONTINUOUS_HIGH_RES_MODE_2) { - result_tmp /= 2.0; - } - - *result = result_tmp / BH1750_CONVERSION_FACTOR; - - return BH1750_OK; - } - return BH1750_ERROR; -} diff --git a/applications/plugins/lightmeter/lib/BH1750/BH1750.h b/applications/plugins/lightmeter/lib/BH1750/BH1750.h deleted file mode 100644 index 991350f7f..000000000 --- a/applications/plugins/lightmeter/lib/BH1750/BH1750.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file BH1750.h - * @author Oleksii Kutuzov (oleksii.kutuzov@icloud.com) - * @brief - * @version 0.1 - * @date 2022-11-06 - * - * @copyright Copyright (c) 2022 - * - * Ported from: - * https://github.com/lamik/Light_Sensors_STM32 - */ - -#include -#include - -#ifndef BH1750_H_ -#define BH1750_H_ - -// I2C BUS -#define I2C_BUS &furi_hal_i2c_handle_external -#define I2C_TIMEOUT 10 - -#define BH1750_ADDRESS (0x23 << 1) - -#define BH1750_POWER_DOWN 0x00 -#define BH1750_POWER_ON 0x01 -#define BH1750_RESET 0x07 -#define BH1750_DEFAULT_MTREG 69 -#define BH1750_DEFAULT_MODE ONETIME_HIGH_RES_MODE - -#define BH1750_CONVERSION_FACTOR 1.2 - -typedef enum { BH1750_OK = 0, BH1750_ERROR = 1 } BH1750_STATUS; - -typedef enum { - CONTINUOUS_HIGH_RES_MODE = 0x10, - CONTINUOUS_HIGH_RES_MODE_2 = 0x11, - CONTINUOUS_LOW_RES_MODE = 0x13, - ONETIME_HIGH_RES_MODE = 0x20, - ONETIME_HIGH_RES_MODE_2 = 0x21, - ONETIME_LOW_RES_MODE = 0x23 -} BH1750_mode; - -/** - * @brief Initialize the sensor. Sends the reset command and sets the measurement register to the default value. - * - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_init(); - -/** - * @brief Reset all registers to the default value. - * - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_reset(); - -/** - * @brief Sets the power state. 1 - running; 0 - sleep, low power. - * - * @param PowerOn sensor state. - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_set_power_state(uint8_t PowerOn); - -/** - * @brief Set the Measurement Time register. It allows to increase or decrease the sensitivity. - * - * @param MTreg value from 31 to 254, defaults to 69. - * - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_set_mt_reg(uint8_t MTreg); - -/** - * @brief Set the mode of converting. Look into the bh1750_mode enum. - * - * @param Mode mode enumerator - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_set_mode(BH1750_mode Mode); - -/** - * @brief Trigger the conversion in manual modes. - * - * @details a low-resolution mode, the conversion time is typically 16 ms, and for a high-resolution - * mode is 120 ms. You need to wait until reading the measurement value. There is no need - * to exit low-power mode for manual conversion. It makes automatically. - * - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_trigger_manual_conversion(); - -/** - * @brief Read the converted value and calculate the result. - * - * @param Result stores received value to this variable. - * @return BH1750_STATUS - */ -BH1750_STATUS bh1750_read_light(float* Result); - -#endif /* BH1750_H_ */ diff --git a/applications/plugins/lightmeter/lib/BH1750/LICENSE b/applications/plugins/lightmeter/lib/BH1750/LICENSE deleted file mode 100644 index cb2f65db5..000000000 --- a/applications/plugins/lightmeter/lib/BH1750/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Oleksii Kutuzov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/lightmeter/lib/BH1750/README.md b/applications/plugins/lightmeter/lib/BH1750/README.md deleted file mode 100644 index b1338d4ab..000000000 --- a/applications/plugins/lightmeter/lib/BH1750/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# flipperzero-BH1750 -BH1750 light sensor library for Flipper Zero diff --git a/applications/plugins/lightmeter/lib/BH1750/docs/BH1750.pdf b/applications/plugins/lightmeter/lib/BH1750/docs/BH1750.pdf deleted file mode 100644 index 267efddc6..000000000 Binary files a/applications/plugins/lightmeter/lib/BH1750/docs/BH1750.pdf and /dev/null differ diff --git a/applications/plugins/lightmeter/lightmeter.c b/applications/plugins/lightmeter/lightmeter.c deleted file mode 100644 index 07661d2d4..000000000 --- a/applications/plugins/lightmeter/lightmeter.c +++ /dev/null @@ -1,161 +0,0 @@ -#include "lightmeter.h" -#include "lightmeter_helper.h" - -#define TAG "MAIN APP" - -static bool lightmeter_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - LightMeterApp* app = context; - - return scene_manager_handle_custom_event(app->scene_manager, event); -} - -static bool lightmeter_back_event_callback(void* context) { - furi_assert(context); - LightMeterApp* app = context; - - return scene_manager_handle_back_event(app->scene_manager); -} - -static void lightmeter_tick_event_callback(void* context) { - furi_assert(context); - LightMeterApp* app = context; - - scene_manager_handle_tick_event(app->scene_manager); -} - -LightMeterApp* lightmeter_app_alloc(uint32_t first_scene) { - LightMeterApp* app = malloc(sizeof(LightMeterApp)); - - // Sensor - bh1750_set_power_state(1); - bh1750_init(); - bh1750_set_mode(ONETIME_HIGH_RES_MODE); - - // Set default values to config - app->config = malloc(sizeof(LightMeterConfig)); - app->config->iso = DEFAULT_ISO; - app->config->nd = DEFAULT_ND; - app->config->aperture = DEFAULT_APERTURE; - app->config->dome = DEFAULT_DOME; - app->config->backlight = DEFAULT_BACKLIGHT; - - // Records - app->gui = furi_record_open(RECORD_GUI); - app->notifications = furi_record_open(RECORD_NOTIFICATION); - - // View dispatcher - app->view_dispatcher = view_dispatcher_alloc(); - app->scene_manager = scene_manager_alloc(&lightmeter_scene_handlers, app); - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - view_dispatcher_set_custom_event_callback( - app->view_dispatcher, lightmeter_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - app->view_dispatcher, lightmeter_back_event_callback); - view_dispatcher_set_tick_event_callback( - app->view_dispatcher, lightmeter_tick_event_callback, furi_ms_to_ticks(200)); - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - // Views - app->main_view = main_view_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, LightMeterAppViewMainView, main_view_get_view(app->main_view)); - - // Set default values to main view from config - main_view_set_iso(app->main_view, app->config->iso); - main_view_set_nd(app->main_view, app->config->nd); - main_view_set_aperture(app->main_view, app->config->aperture); - main_view_set_speed(app->main_view, DEFAULT_SPEED); - main_view_set_dome(app->main_view, app->config->dome); - - // Variable item list - app->var_item_list = variable_item_list_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - LightMeterAppViewVarItemList, - variable_item_list_get_view(app->var_item_list)); - - // Widget - app->widget = widget_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, LightMeterAppViewAbout, widget_get_view(app->widget)); - view_dispatcher_add_view( - app->view_dispatcher, LightMeterAppViewHelp, widget_get_view(app->widget)); - - // Set first scene - scene_manager_next_scene(app->scene_manager, first_scene); - return app; -} - -void lightmeter_app_free(LightMeterApp* app) { - furi_assert(app); - - // Views - view_dispatcher_remove_view(app->view_dispatcher, LightMeterAppViewMainView); - main_view_free(app->main_view); - - // Variable item list - view_dispatcher_remove_view(app->view_dispatcher, LightMeterAppViewVarItemList); - variable_item_list_free(app->var_item_list); - - // Widget - view_dispatcher_remove_view(app->view_dispatcher, LightMeterAppViewAbout); - view_dispatcher_remove_view(app->view_dispatcher, LightMeterAppViewHelp); - widget_free(app->widget); - - // View dispatcher - scene_manager_free(app->scene_manager); - view_dispatcher_free(app->view_dispatcher); - - // Records - furi_record_close(RECORD_GUI); - if(app->config->backlight != BACKLIGHT_AUTO) { - notification_message( - app->notifications, - &sequence_display_backlight_enforce_auto); // set backlight back to auto - } - furi_record_close(RECORD_NOTIFICATION); - - bh1750_set_power_state(0); - - free(app->config); - free(app); -} - -int32_t lightmeter_app(void* p) { - UNUSED(p); - uint32_t first_scene = LightMeterAppSceneMain; - LightMeterApp* app = lightmeter_app_alloc(first_scene); - view_dispatcher_run(app->view_dispatcher); - lightmeter_app_free(app); - return 0; -} - -void lightmeter_app_set_config(LightMeterApp* context, LightMeterConfig* config) { - LightMeterApp* app = context; - - app->config = config; -} - -void lightmeter_app_i2c_callback(LightMeterApp* context) { - LightMeterApp* app = context; - - float EV = 0; - float lux = 0; - bool response = 0; - - if(bh1750_trigger_manual_conversion() == BH1750_OK) response = 1; - - if(response) { - bh1750_read_light(&lux); - - if(main_view_get_dome(app->main_view)) lux *= DOME_COEFFICIENT; - - EV = lux2ev(lux); - } - - main_view_set_lux(app->main_view, lux); - main_view_set_EV(app->main_view, EV); - main_view_set_response(app->main_view, response); -} diff --git a/applications/plugins/lightmeter/lightmeter.h b/applications/plugins/lightmeter/lightmeter.h deleted file mode 100644 index 2558be3c5..000000000 --- a/applications/plugins/lightmeter/lightmeter.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include -#include - -#include "gui/views/main_view.h" - -#include -#include - -#include "gui/scenes/config/lightmeter_scene.h" -#include - -#include "lightmeter_config.h" -#include - -typedef struct { - int iso; - int nd; - int aperture; - int dome; - int backlight; - int lux_only; -} LightMeterConfig; - -typedef struct { - Gui* gui; - SceneManager* scene_manager; - ViewDispatcher* view_dispatcher; - MainView* main_view; - VariableItemList* var_item_list; - LightMeterConfig* config; - NotificationApp* notifications; - Widget* widget; -} LightMeterApp; - -typedef enum { - LightMeterAppViewMainView, - LightMeterAppViewConfigView, - LightMeterAppViewVarItemList, - LightMeterAppViewAbout, - LightMeterAppViewHelp, -} LightMeterAppView; - -typedef enum { - LightMeterAppCustomEventConfig, - LightMeterAppCustomEventHelp, - LightMeterAppCustomEventAbout, -} LightMeterAppCustomEvent; - -void lightmeter_app_set_config(LightMeterApp* context, LightMeterConfig* config); - -void lightmeter_app_i2c_callback(LightMeterApp* context); diff --git a/applications/plugins/lightmeter/lightmeter.png b/applications/plugins/lightmeter/lightmeter.png deleted file mode 100644 index cacd2276f..000000000 Binary files a/applications/plugins/lightmeter/lightmeter.png and /dev/null differ diff --git a/applications/plugins/lightmeter/lightmeter_config.h b/applications/plugins/lightmeter/lightmeter_config.h deleted file mode 100644 index 4f7e11e0d..000000000 --- a/applications/plugins/lightmeter/lightmeter_config.h +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once - -#define LM_VERSION_APP "0.7" -#define LM_DEVELOPED "Oleksii Kutuzov" -#define LM_GITHUB "https://github.com/oleksiikutuzov/flipperzero-lightmeter" - -#define DOME_COEFFICIENT 2.3 -#define DEFAULT_ISO ISO_100 -#define DEFAULT_ND ND_0 -#define DEFAULT_APERTURE AP_2_8 -#define DEFAULT_SPEED SPEED_125 -#define DEFAULT_DOME WITHOUT_DOME -#define DEFAULT_BACKLIGHT BACKLIGHT_AUTO - -typedef enum { - ISO_6, - ISO_12, - ISO_25, - ISO_50, - ISO_100, - ISO_200, - ISO_400, - ISO_800, - ISO_1600, - ISO_3200, - ISO_6400, - ISO_12800, - ISO_25600, - ISO_51200, - ISO_102400, - - ISO_NUM, -} LightMeterISONumbers; - -typedef enum { - ND_0, - ND_2, - ND_4, - ND_8, - ND_16, - ND_32, - ND_64, - ND_128, - ND_256, - ND_512, - ND_1024, - ND_2048, - ND_4096, - - ND_NUM, -} LightMeterNDNumbers; - -typedef enum { - AP_1, - AP_1_4, - AP_2, - AP_2_8, - AP_4, - AP_5_6, - AP_8, - AP_11, - AP_16, - AP_22, - AP_32, - AP_45, - AP_64, - AP_90, - AP_128, - - AP_NUM, -} LightMeterApertureNumbers; - -typedef enum { - SPEED_8000, - SPEED_4000, - SPEED_2000, - SPEED_1000, - SPEED_500, - SPEED_250, - SPEED_125, - SPEED_60, - SPEED_30, - SPEED_15, - SPEED_8, - SPEED_4, - SPEED_2, - SPEED_1S, - SPEED_2S, - SPEED_4S, - SPEED_8S, - SPEED_15S, - SPEED_30S, - - SPEED_NUM, -} LightMeterSpeedNumbers; - -typedef enum { - WITHOUT_DOME, - WITH_DOME, -} LightMeterDomePresence; - -typedef enum { - LUX_ONLY_OFF, - LUX_ONLY_ON, -} LightMeterLuxOnlyMode; - -typedef enum { BACKLIGHT_AUTO, BACKLIGHT_ON } LightMeterBacklight; diff --git a/applications/plugins/lightmeter/lightmeter_helper.c b/applications/plugins/lightmeter/lightmeter_helper.c deleted file mode 100644 index 465ccbce1..000000000 --- a/applications/plugins/lightmeter/lightmeter_helper.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "lightmeter_helper.h" -#include "lightmeter_config.h" - -extern const float aperture_numbers[]; -extern const float speed_numbers[]; - -float lux2ev(float lux) { - return log2(lux / 2.5); -} - -float getMinDistance(float x, float v1, float v2) { - if(x - v1 > v2 - x) { - return v2; - } - - return v1; -} - -float normalizeAperture(float a) { - for(int i = 0; i < AP_NUM; i++) { - float a1 = aperture_numbers[i]; - float a2 = aperture_numbers[i + 1]; - - if(a1 < a && a2 >= a) { - return getMinDistance(a, a1, a2); - } - } - - return 0; -} - -float normalizeTime(float a) { - for(int i = 0; i < SPEED_NUM; i++) { - float a1 = speed_numbers[i]; - float a2 = speed_numbers[i + 1]; - - if(a1 < a && a2 >= a) { - return getMinDistance(a, a1, a2); - } - } - - return 0; -} diff --git a/applications/plugins/lightmeter/lightmeter_helper.h b/applications/plugins/lightmeter/lightmeter_helper.h deleted file mode 100644 index 78ea6a8d8..000000000 --- a/applications/plugins/lightmeter/lightmeter_helper.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include - -float lux2ev(float lux); - -float getMinDistance(float x, float v1, float v2); - -float normalizeAperture(float a); - -float normalizeTime(float a); diff --git a/applications/plugins/lightmeter/module/back.jpg b/applications/plugins/lightmeter/module/back.jpg deleted file mode 100644 index 366d7a852..000000000 Binary files a/applications/plugins/lightmeter/module/back.jpg and /dev/null differ diff --git a/applications/plugins/lightmeter/module/front.jpg b/applications/plugins/lightmeter/module/front.jpg deleted file mode 100644 index b38fd4150..000000000 Binary files a/applications/plugins/lightmeter/module/front.jpg and /dev/null differ diff --git a/applications/plugins/lightmeter/module/module.jpg b/applications/plugins/lightmeter/module/module.jpg deleted file mode 100644 index 53f481338..000000000 Binary files a/applications/plugins/lightmeter/module/module.jpg and /dev/null differ diff --git a/applications/plugins/lightmeter/module/module_v2_enclosure.stl b/applications/plugins/lightmeter/module/module_v2_enclosure.stl deleted file mode 100644 index ee2be93fd..000000000 Binary files a/applications/plugins/lightmeter/module/module_v2_enclosure.stl and /dev/null differ diff --git a/applications/plugins/lightmeter/module/module_v2_gerber.zip b/applications/plugins/lightmeter/module/module_v2_gerber.zip deleted file mode 100644 index 02887f4bf..000000000 Binary files a/applications/plugins/lightmeter/module/module_v2_gerber.zip and /dev/null differ diff --git a/applications/plugins/metronome/README.md b/applications/plugins/metronome/README.md deleted file mode 100644 index 4b6cd3122..000000000 --- a/applications/plugins/metronome/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Metronome - -[Original link](https://github.com/panki27/Metronome) - -A metronome for the [Flipper Zero](https://flipperzero.one/) device. Goes along perfectly with my [BPM tapper](https://github.com/panki27/bpm-tapper). - -![screenshot](img/screenshot.png) - -## Features - -- BPM adjustable, fine and coarse (hold pressed) -- Selectable amount of beats per bar -- Selectable note length -- First beat is pronounced -- Progress indicator -- LED flashes accordingly -- 3 different settings: Beep, Vibrate, Silent (push Down to change) - -## Compiling - -``` -./fbt firmware_metronome -``` diff --git a/applications/plugins/metronome/application.fam b/applications/plugins/metronome/application.fam deleted file mode 100644 index 32588d06e..000000000 --- a/applications/plugins/metronome/application.fam +++ /dev/null @@ -1,15 +0,0 @@ -App( - appid="Metronome", - name="Metronome", - apptype=FlipperAppType.EXTERNAL, - entry_point="metronome_app", - cdefines=["APP_METRONOME"], - requires=[ - "gui", - ], - fap_icon="metronome_icon.png", - fap_category="Music", - fap_icon_assets="images", - stack_size=2 * 1024, - order=20, -) diff --git a/applications/plugins/metronome/gui_extensions.c b/applications/plugins/metronome/gui_extensions.c deleted file mode 100644 index 458eb137b..000000000 --- a/applications/plugins/metronome/gui_extensions.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -//lib can only do bottom left/right -void elements_button_top_left(Canvas* canvas, const char* str) { - const uint8_t button_height = 12; - const uint8_t vertical_offset = 3; - const uint8_t horizontal_offset = 3; - const uint8_t string_width = canvas_string_width(canvas, str); - const Icon* icon = &I_ButtonUp_7x4; - const uint8_t icon_h_offset = 3; - const uint8_t icon_width_with_offset = icon->width + icon_h_offset; - const uint8_t icon_v_offset = icon->height + vertical_offset; - const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset; - - const uint8_t x = 0; - const uint8_t y = 0 + button_height; - - canvas_draw_box(canvas, x, y - button_height, button_width, button_height); - canvas_draw_line(canvas, x + button_width + 0, y - button_height, x + button_width + 0, y - 1); - canvas_draw_line(canvas, x + button_width + 1, y - button_height, x + button_width + 1, y - 2); - canvas_draw_line(canvas, x + button_width + 2, y - button_height, x + button_width + 2, y - 3); - - canvas_invert_color(canvas); - canvas_draw_icon(canvas, x + horizontal_offset, y - icon_v_offset, &I_ButtonUp_7x4); - canvas_draw_str( - canvas, x + horizontal_offset + icon_width_with_offset, y - vertical_offset, str); - canvas_invert_color(canvas); -} - -void elements_button_top_right(Canvas* canvas, const char* str) { - const uint8_t button_height = 12; - const uint8_t vertical_offset = 3; - const uint8_t horizontal_offset = 3; - const uint8_t string_width = canvas_string_width(canvas, str); - const Icon* icon = &I_ButtonUp_7x4; - const uint8_t icon_h_offset = 3; - const uint8_t icon_width_with_offset = icon->width + icon_h_offset; - const uint8_t icon_v_offset = icon->height + vertical_offset; - const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset; - - const uint8_t x = canvas_width(canvas); - const uint8_t y = 0 + button_height; - - canvas_draw_box(canvas, x - button_width, y - button_height, button_width, button_height); - canvas_draw_line(canvas, x - button_width - 1, y - button_height, x - button_width - 1, y - 1); - canvas_draw_line(canvas, x - button_width - 2, y - button_height, x - button_width - 2, y - 2); - canvas_draw_line(canvas, x - button_width - 3, y - button_height, x - button_width - 3, y - 3); - - canvas_invert_color(canvas); - canvas_draw_str(canvas, x - button_width + horizontal_offset, y - vertical_offset, str); - canvas_draw_icon( - canvas, x - horizontal_offset - icon->width, y - icon_v_offset, &I_ButtonUp_7x4); - canvas_invert_color(canvas); -} diff --git a/applications/plugins/metronome/gui_extensions.h b/applications/plugins/metronome/gui_extensions.h deleted file mode 100644 index 97df1952c..000000000 --- a/applications/plugins/metronome/gui_extensions.h +++ /dev/null @@ -1,3 +0,0 @@ -void elements_button_top_right(Canvas* canvas, const char* str); - -void elements_button_top_left(Canvas* canvas, const char* str); diff --git a/applications/plugins/metronome/icons/ButtonUp_7x4.png b/applications/plugins/metronome/icons/ButtonUp_7x4.png deleted file mode 100644 index 1be79328b..000000000 Binary files a/applications/plugins/metronome/icons/ButtonUp_7x4.png and /dev/null differ diff --git a/applications/plugins/metronome/images/ButtonUp_7x4.png b/applications/plugins/metronome/images/ButtonUp_7x4.png deleted file mode 100644 index 1be79328b..000000000 Binary files a/applications/plugins/metronome/images/ButtonUp_7x4.png and /dev/null differ diff --git a/applications/plugins/metronome/img/screenshot.png b/applications/plugins/metronome/img/screenshot.png deleted file mode 100644 index 7b6916e81..000000000 Binary files a/applications/plugins/metronome/img/screenshot.png and /dev/null differ diff --git a/applications/plugins/metronome/img/wave_left_4x14.png b/applications/plugins/metronome/img/wave_left_4x14.png deleted file mode 100644 index beb2a611d..000000000 Binary files a/applications/plugins/metronome/img/wave_left_4x14.png and /dev/null differ diff --git a/applications/plugins/metronome/img/wave_right_4x14.png b/applications/plugins/metronome/img/wave_right_4x14.png deleted file mode 100644 index af249ee5b..000000000 Binary files a/applications/plugins/metronome/img/wave_right_4x14.png and /dev/null differ diff --git a/applications/plugins/metronome/metronome.c b/applications/plugins/metronome/metronome.c deleted file mode 100644 index 18f68ea42..000000000 --- a/applications/plugins/metronome/metronome.c +++ /dev/null @@ -1,397 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "gui_extensions.h" - -#define BPM_STEP_SIZE_FINE 0.5d -#define BPM_STEP_SIZE_COARSE 10.0d -#define BPM_BOUNDARY_LOW 10.0d -#define BPM_BOUNDARY_HIGH 300.0d -#define BEEP_DELAY_MS 50 - -#define wave_bitmap_left_width 4 -#define wave_bitmap_left_height 14 -static uint8_t wave_bitmap_left_bits[] = - {0x08, 0x0C, 0x06, 0x06, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x06, 0x0C, 0x08}; - -#define wave_bitmap_right_width 4 -#define wave_bitmap_right_height 14 -static uint8_t wave_bitmap_right_bits[] = - {0x01, 0x03, 0x06, 0x06, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x06, 0x06, 0x03, 0x01}; - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -enum OutputMode { Loud, Vibro, Silent }; - -typedef struct { - double bpm; - bool playing; - int beats_per_bar; - int note_length; - int current_beat; - enum OutputMode output_mode; - FuriTimer* timer; - NotificationApp* notifications; -} MetronomeState; - -static void render_callback(Canvas* const canvas, void* ctx) { - const MetronomeState* metronome_state = acquire_mutex((ValueMutex*)ctx, 25); - if(metronome_state == NULL) { - return; - } - - FuriString* tempStr; - tempStr = furi_string_alloc(); - - canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontPrimary); - - // draw bars/beat - furi_string_printf( - tempStr, "%d/%d", metronome_state->beats_per_bar, metronome_state->note_length); - canvas_draw_str_aligned( - canvas, 64, 8, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - // draw BPM value - furi_string_printf(tempStr, "%.2f", metronome_state->bpm); - canvas_set_font(canvas, FontBigNumbers); - canvas_draw_str_aligned( - canvas, 64, 24, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr)); - furi_string_reset(tempStr); - - // draw volume indicator - // always draw first waves - canvas_draw_xbm( - canvas, 20, 17, wave_bitmap_left_width, wave_bitmap_left_height, wave_bitmap_left_bits); - canvas_draw_xbm( - canvas, - canvas_width(canvas) - 20 - wave_bitmap_right_width, - 17, - wave_bitmap_right_width, - wave_bitmap_right_height, - wave_bitmap_right_bits); - if(metronome_state->output_mode < Silent) { - canvas_draw_xbm( - canvas, 16, 17, wave_bitmap_left_width, wave_bitmap_left_height, wave_bitmap_left_bits); - canvas_draw_xbm( - canvas, - canvas_width(canvas) - 16 - wave_bitmap_right_width, - 17, - wave_bitmap_right_width, - wave_bitmap_right_height, - wave_bitmap_right_bits); - } - if(metronome_state->output_mode < Vibro) { - canvas_draw_xbm( - canvas, 12, 17, wave_bitmap_left_width, wave_bitmap_left_height, wave_bitmap_left_bits); - canvas_draw_xbm( - canvas, - canvas_width(canvas) - 12 - wave_bitmap_right_width, - 17, - wave_bitmap_right_width, - wave_bitmap_right_height, - wave_bitmap_right_bits); - } - // draw button prompts - canvas_set_font(canvas, FontSecondary); - elements_button_left(canvas, "Slow"); - elements_button_right(canvas, "Fast"); - if(metronome_state->playing) { - elements_button_center(canvas, "Stop "); - } else { - elements_button_center(canvas, "Start"); - } - elements_button_top_left(canvas, "Push"); - elements_button_top_right(canvas, "Hold"); - - // draw progress bar - elements_progress_bar( - canvas, 8, 36, 112, (float)metronome_state->current_beat / metronome_state->beats_per_bar); - - // cleanup - furi_string_free(tempStr); - release_mutex((ValueMutex*)ctx, metronome_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void timer_callback(void* ctx) { - // this is where we go BEEP! - MetronomeState* metronome_state = acquire_mutex((ValueMutex*)ctx, 25); - metronome_state->current_beat++; - if(metronome_state->current_beat > metronome_state->beats_per_bar) { - metronome_state->current_beat = 1; - } - if(metronome_state->current_beat == 1) { - // pronounced beat - notification_message(metronome_state->notifications, &sequence_set_only_red_255); - switch(metronome_state->output_mode) { - case Loud: - furi_hal_speaker_start(440.0f, 1.0f); - break; - case Vibro: - notification_message(metronome_state->notifications, &sequence_set_vibro_on); - break; - case Silent: - break; - default: - break; - } - } else { - // unpronounced beat - notification_message(metronome_state->notifications, &sequence_set_only_green_255); - switch(metronome_state->output_mode) { - case Loud: - furi_hal_speaker_start(220.0f, 1.0f); - break; - case Vibro: - notification_message(metronome_state->notifications, &sequence_set_vibro_on); - break; - case Silent: - break; - default: - break; - } - }; - - // this is a bit of a kludge... if we are on vibro and unpronounced, stop vibro after half the usual duration - switch(metronome_state->output_mode) { - case Loud: - furi_delay_ms(BEEP_DELAY_MS); - furi_hal_speaker_stop(); - break; - case Vibro: - if(metronome_state->current_beat == 1) { - furi_delay_ms(BEEP_DELAY_MS); - notification_message(metronome_state->notifications, &sequence_reset_vibro); - } else { - furi_delay_ms((int)BEEP_DELAY_MS / 2); - notification_message(metronome_state->notifications, &sequence_reset_vibro); - furi_delay_ms((int)BEEP_DELAY_MS / 2); - } - break; - case Silent: - break; - default: - break; - } - notification_message(metronome_state->notifications, &sequence_reset_rgb); - - release_mutex((ValueMutex*)ctx, metronome_state); -} - -static uint32_t state_to_sleep_ticks(MetronomeState* metronome_state) { - // calculate time between beeps - uint32_t tps = furi_kernel_get_tick_frequency(); - double multiplier = 4.0d / metronome_state->note_length; - double bps = (double)metronome_state->bpm / 60; - return (uint32_t)(round(tps / bps) - ((BEEP_DELAY_MS / 1000) * tps)) * multiplier; -} - -static void update_timer(MetronomeState* metronome_state) { - if(furi_timer_is_running(metronome_state->timer)) { - furi_timer_stop(metronome_state->timer); - furi_timer_start(metronome_state->timer, state_to_sleep_ticks(metronome_state)); - } -} - -static void increase_bpm(MetronomeState* metronome_state, double amount) { - metronome_state->bpm += amount; - if(metronome_state->bpm > (double)BPM_BOUNDARY_HIGH) { - metronome_state->bpm = BPM_BOUNDARY_HIGH; - } - update_timer(metronome_state); -} - -static void decrease_bpm(MetronomeState* metronome_state, double amount) { - metronome_state->bpm -= amount; - if(metronome_state->bpm < (double)BPM_BOUNDARY_LOW) { - metronome_state->bpm = BPM_BOUNDARY_LOW; - } - update_timer(metronome_state); -} - -static void cycle_beats_per_bar(MetronomeState* metronome_state) { - metronome_state->beats_per_bar++; - if(metronome_state->beats_per_bar > metronome_state->note_length) { - metronome_state->beats_per_bar = 1; - } -} - -static void cycle_note_length(MetronomeState* metronome_state) { - metronome_state->note_length *= 2; - if(metronome_state->note_length > 16) { - metronome_state->note_length = 2; - metronome_state->beats_per_bar = 1; - } - update_timer(metronome_state); -} - -static void cycle_output_mode(MetronomeState* metronome_state) { - metronome_state->output_mode++; - if(metronome_state->output_mode > Silent) { - metronome_state->output_mode = Loud; - } -} - -static void metronome_state_init(MetronomeState* const metronome_state) { - metronome_state->bpm = 120.0; - metronome_state->playing = false; - metronome_state->beats_per_bar = 4; - metronome_state->note_length = 4; - metronome_state->current_beat = 0; - metronome_state->output_mode = Loud; - metronome_state->notifications = furi_record_open(RECORD_NOTIFICATION); -} - -int32_t metronome_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - MetronomeState* metronome_state = malloc(sizeof(MetronomeState)); - metronome_state_init(metronome_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, metronome_state, sizeof(MetronomeState))) { - FURI_LOG_E("Metronome", "cannot create mutex\r\n"); - free(metronome_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - metronome_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, &state_mutex); - - // Open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - MetronomeState* metronome_state = (MetronomeState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - if(event.type == EventTypeKey) { - if(event.input.type == InputTypeShort) { - // push events - switch(event.input.key) { - case InputKeyUp: - cycle_beats_per_bar(metronome_state); - break; - case InputKeyDown: - cycle_output_mode(metronome_state); - break; - case InputKeyRight: - increase_bpm(metronome_state, BPM_STEP_SIZE_FINE); - break; - case InputKeyLeft: - decrease_bpm(metronome_state, BPM_STEP_SIZE_FINE); - break; - case InputKeyOk: - metronome_state->playing = !metronome_state->playing; - if(metronome_state->playing) { - furi_timer_start( - metronome_state->timer, state_to_sleep_ticks(metronome_state)); - } else { - furi_timer_stop(metronome_state->timer); - } - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } else if(event.input.type == InputTypeLong) { - // hold events - switch(event.input.key) { - case InputKeyUp: - cycle_note_length(metronome_state); - break; - case InputKeyDown: - break; - case InputKeyRight: - increase_bpm(metronome_state, BPM_STEP_SIZE_COARSE); - break; - case InputKeyLeft: - decrease_bpm(metronome_state, BPM_STEP_SIZE_COARSE); - break; - case InputKeyOk: - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } else if(event.input.type == InputTypeRepeat) { - // repeat events - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - increase_bpm(metronome_state, BPM_STEP_SIZE_COARSE); - break; - case InputKeyLeft: - decrease_bpm(metronome_state, BPM_STEP_SIZE_COARSE); - break; - case InputKeyOk: - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } - } else { - FURI_LOG_D("Metronome", "FuriMessageQueue: event timeout"); - // event timeout - } - - view_port_update(view_port); - release_mutex(&state_mutex, metronome_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - furi_timer_free(metronome_state->timer); - furi_record_close(RECORD_NOTIFICATION); - free(metronome_state); - - return 0; -} diff --git a/applications/plugins/metronome/metronome_icon.png b/applications/plugins/metronome/metronome_icon.png deleted file mode 100644 index 64d0ddbe9..000000000 Binary files a/applications/plugins/metronome/metronome_icon.png and /dev/null differ diff --git a/applications/plugins/montyhall/Monty.png b/applications/plugins/montyhall/Monty.png deleted file mode 100644 index 1f4c14cd6..000000000 Binary files a/applications/plugins/montyhall/Monty.png and /dev/null differ diff --git a/applications/plugins/montyhall/application.fam b/applications/plugins/montyhall/application.fam deleted file mode 100644 index 66d082853..000000000 --- a/applications/plugins/montyhall/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="MontyHall", - name="Monty Hall", - apptype=FlipperAppType.EXTERNAL, - entry_point="montyhall_game_app", - cdefines=["APP_MONTYHALL_GAME"], - requires=["gui"], - stack_size=1 * 1024, - order=185, - fap_icon="Monty.png", - fap_category="Games", -) diff --git a/applications/plugins/montyhall/monteyhall.c b/applications/plugins/montyhall/monteyhall.c deleted file mode 100644 index 024d539ec..000000000 --- a/applications/plugins/montyhall/monteyhall.c +++ /dev/null @@ -1,450 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#define SCREEN_WIDTH 128 -#define SCREEN_HEIGHT 64 - -//AUTHOR: https://github.com/DevMilanIan -//I_DoorClosed_22x35 sourced from VideoPoker/poker.c -> I_CardBack22x35 -//PRs for syntax, formatting, etc can get you listed as a contributor :) - -// CONCEPT: one of three doors will have a car while the other two have only a goat -// randomize a winning door each round, let the player choose a first selection -// reveal a goat door and allow the player to keep or switch their selection -// based on the Monty Hall problem from Let's Make a Deal - -//void draw_goat(Canvas* canvas, int x, int y) { TODO } - -void draw_car(Canvas* canvas, int x, int y) { - // x -> leftmost pixel, y -> topmost pixel - // could be in another file or a pixel array but idk how to so feel free to PR - - canvas_draw_dot(canvas, x + 1, y + 4); - canvas_draw_dot(canvas, x + 1, y + 5); - canvas_draw_dot(canvas, x + 2, y + 3); - canvas_draw_dot(canvas, x + 2, y + 6); - canvas_draw_dot(canvas, x + 3, y + 3); - canvas_draw_dot(canvas, x + 3, y + 6); - - canvas_draw_dot(canvas, x + 4, y + 2); - canvas_draw_dot(canvas, x + 4, y + 3); - canvas_draw_dot(canvas, x + 4, y + 6); - canvas_draw_dot(canvas, x + 4, y + 7); - - canvas_draw_dot(canvas, x + 5, y + 1); - canvas_draw_dot(canvas, x + 5, y + 2); - canvas_draw_dot(canvas, x + 5, y + 3); - canvas_draw_dot(canvas, x + 5, y + 5); - canvas_draw_dot(canvas, x + 5, y + 8); - - canvas_draw_dot(canvas, x + 6, y); - canvas_draw_dot(canvas, x + 6, y + 1); - canvas_draw_dot(canvas, x + 6, y + 3); - canvas_draw_dot(canvas, x + 6, y + 5); - canvas_draw_dot(canvas, x + 6, y + 8); - - canvas_draw_dot(canvas, x + 7, y); - canvas_draw_dot(canvas, x + 7, y + 3); - canvas_draw_dot(canvas, x + 7, y + 6); - canvas_draw_dot(canvas, x + 7, y + 7); - - canvas_draw_dot(canvas, x + 8, y); - canvas_draw_dot(canvas, x + 8, y + 3); - canvas_draw_dot(canvas, x + 8, y + 6); - - canvas_draw_dot(canvas, x + 9, y); - canvas_draw_dot(canvas, x + 9, y + 3); - canvas_draw_dot(canvas, x + 9, y + 6); - - canvas_draw_dot(canvas, x + 10, y); - canvas_draw_dot(canvas, x + 10, y + 3); - canvas_draw_dot(canvas, x + 10, y + 6); - - canvas_draw_dot(canvas, x + 11, y); - canvas_draw_dot(canvas, x + 11, y + 1); - canvas_draw_dot(canvas, x + 11, y + 3); - canvas_draw_dot(canvas, x + 11, y + 6); - - canvas_draw_dot(canvas, x + 12, y + 1); - canvas_draw_dot(canvas, x + 12, y + 2); - canvas_draw_dot(canvas, x + 12, y + 3); - canvas_draw_dot(canvas, x + 12, y + 6); - canvas_draw_dot(canvas, x + 12, y + 7); - - canvas_draw_dot(canvas, x + 13, y + 2); - canvas_draw_dot(canvas, x + 13, y + 3); - canvas_draw_dot(canvas, x + 13, y + 5); - canvas_draw_dot(canvas, x + 13, y + 8); - - canvas_draw_dot(canvas, x + 14, y + 1); - canvas_draw_dot(canvas, x + 14, y + 2); - canvas_draw_dot(canvas, x + 14, y + 5); - canvas_draw_dot(canvas, x + 14, y + 8); - - canvas_draw_dot(canvas, x + 15, y); - canvas_draw_dot(canvas, x + 15, y + 1); - canvas_draw_dot(canvas, x + 15, y + 6); - canvas_draw_dot(canvas, x + 15, y + 7); - - canvas_draw_dot(canvas, x + 16, y); - canvas_draw_dot(canvas, x + 16, y + 1); - canvas_draw_dot(canvas, x + 16, y + 2); - canvas_draw_dot(canvas, x + 16, y + 3); - canvas_draw_dot(canvas, x + 16, y + 4); - canvas_draw_dot(canvas, x + 16, y + 5); -} - -const uint8_t _I_DoorClosed_22x35_0[] = { - 0x01, 0x00, 0x23, 0x00, 0xfe, 0x7f, 0xe1, 0xf0, 0x28, 0x04, 0x43, 0xe3, 0xff, - 0x91, 0xea, 0x75, 0x52, 0x6a, 0xad, 0x56, 0x5b, 0xad, 0xd5, 0x4a, 0x80, 0xbe, - 0x05, 0xf0, 0x2f, 0x81, 0x7c, 0x0b, 0x45, 0x32, 0x2c, 0x91, 0x7c, 0x8c, 0xa4, -}; -const uint8_t* _I_DoorClosed_22x35[] = {_I_DoorClosed_22x35_0}; -const Icon I_DoorClosed_22x35 = - {.width = 22, .height = 35, .frame_count = 1, .frame_rate = 0, .frames = _I_DoorClosed_22x35}; - -typedef struct { - bool isOpen; - bool isSelected; // picked in RoundOne, RoundThree - bool isWinningDoor; // randomized in RoundOne -} Door; - -typedef struct { - Door doors[3]; - bool didSelect; // false in RoundOne -> RoundTwo when true - bool didSwitch; // determined in RoundFour -} DoorState; - -typedef enum { - RoundOne, // all doors closed, player selects a door when ready - RoundTwo, // door selected, reveal one of the remaining two (can go straight to GameOver) - RoundThree, // player can keep or switch their selection - RoundFour, // reveal all doors - GameOver // score has been updated, allow restart -} GameState; - -typedef struct { - GameState game_state; - DoorState door_state; - uint16_t score; -} MontyState; - -static void montyhall_game_init_state(MontyState* monty_state) { - if(!monty_state->score) { - monty_state->score = 0; - } - monty_state->door_state.didSelect = false; - - for(int i = 0; i < 3; i++) { - monty_state->door_state.doors[i].isOpen = false; - monty_state->door_state.doors[i].isSelected = false; - monty_state->door_state.doors[i].isWinningDoor = false; - } - - monty_state->game_state = RoundOne; - int doorIndex = random() % 3; - monty_state->door_state.doors[doorIndex].isWinningDoor = true; -} - -void selectDoor(MontyState* monty_state, int doorIndex) { - if(monty_state->game_state == RoundOne) { - monty_state->door_state.doors[doorIndex].isSelected = true; - if(monty_state->door_state.doors[doorIndex].isSelected) { - monty_state->door_state.didSelect = true; - monty_state->game_state = RoundTwo; - } - } else if(monty_state->game_state == RoundThree) { - for(int i = 0; i < 3; i++) { - monty_state->door_state.doors[i].isSelected = false; - } - - monty_state->door_state.doors[doorIndex].isSelected = true; - } -} - -int getRandomDoorIndex() { - int randomDoorIndex = random() % 3; - return randomDoorIndex; -} - -void revealBadDoor(MontyState* monty_state) { - int doorToReveal = getRandomDoorIndex(); - while(!monty_state->door_state.doors[doorToReveal].isOpen) { - if(!(monty_state->door_state.doors[doorToReveal].isSelected || - monty_state->door_state.doors[doorToReveal].isWinningDoor)) { - monty_state->door_state.doors[doorToReveal].isOpen = true; - } else { - doorToReveal = getRandomDoorIndex(); - } - } -} - -void revealDoors_updateScore(MontyState* monty_state) { - for(int i = 0; i < 3; i++) { - monty_state->door_state.doors[i].isOpen = true; - - if(monty_state->door_state.doors[i].isWinningDoor && - monty_state->door_state.doors[i].isSelected) { - monty_state->score++; - } - } -} - -static void draw_top(Canvas* canvas, const MontyState* monty_state) { - char buffer[16]; - snprintf(buffer, sizeof(buffer), "Cars: %u", monty_state->score); - canvas_draw_str_aligned(canvas, 2, 8, AlignLeft, AlignBottom, buffer); - - if(monty_state->game_state == RoundThree) { - canvas_draw_str_aligned( - canvas, SCREEN_WIDTH - 5, 8, AlignRight, AlignBottom, "Opened a decoy door"); - } -} - -static void draw_doors(Canvas* canvas, const MontyState* monty_state) { - // {| 16 | <22> | 15 | <22> | 15 | <22> | 16 |} = SCREEN_WIDTH - if(monty_state->door_state.doors[0].isOpen) { - if(monty_state->door_state.doors[0].isWinningDoor) { - canvas_draw_frame(canvas, 16, 12, 22, 35); - draw_car(canvas, 18, 26); - } else { - canvas_draw_frame(canvas, 16, 12, 22, 35); - canvas_draw_str(canvas, 18, 34, "Goat"); - } - } else { - canvas_draw_icon(canvas, 16, 12, &I_DoorClosed_22x35); - } - - if(monty_state->door_state.doors[1].isOpen) { - if(monty_state->door_state.doors[1].isWinningDoor) { - canvas_draw_frame(canvas, 53, 12, 22, 35); - draw_car(canvas, 55, 26); - } else { - canvas_draw_frame(canvas, 53, 12, 22, 35); - canvas_draw_str(canvas, 55, 34, "Goat"); - } - } else { - canvas_draw_icon(canvas, 53, 12, &I_DoorClosed_22x35); - } - - if(monty_state->door_state.doors[2].isOpen) { - if(monty_state->door_state.doors[2].isWinningDoor) { - canvas_draw_frame(canvas, 90, 12, 22, 35); - draw_car(canvas, 92, 26); - } else { - canvas_draw_frame(canvas, 90, 12, 22, 35); - canvas_draw_str(canvas, 92, 34, "Goat"); - } - } else { - canvas_draw_icon(canvas, 90, 12, &I_DoorClosed_22x35); - } -} - -static void draw_bottom(Canvas* canvas, const MontyState* monty_state) { - if(monty_state->game_state == RoundOne) { - elements_button_left(canvas, "Left"); - elements_button_center(canvas, "Center"); - elements_button_right(canvas, "Right"); - } - - if(monty_state->game_state == RoundThree) { - if(monty_state->door_state.doors[0].isSelected) { - elements_button_left(canvas, "Keep"); - if(!monty_state->door_state.doors[1].isOpen) { - elements_button_center(canvas, "Switch"); - } else { - elements_button_right(canvas, "Switch"); - } - } else if(monty_state->door_state.doors[1].isSelected) { - elements_button_center(canvas, "Keep"); - if(!monty_state->door_state.doors[0].isOpen) { - elements_button_left(canvas, "Switch"); - } else { - elements_button_right(canvas, "Switch"); - } - } else if(monty_state->door_state.doors[2].isSelected) { - elements_button_right(canvas, "Keep"); - if(!monty_state->door_state.doors[0].isOpen) { - elements_button_left(canvas, "Switch"); - } else { - elements_button_center(canvas, "Switch"); - } - } - } - - if(monty_state->game_state == RoundFour) { - elements_button_center(canvas, "Reveal"); - } - - if(monty_state->game_state == GameOver) { - canvas_draw_str(canvas, 16, SCREEN_HEIGHT - 5, "Hold center to restart"); - } -} - -static void montyhall_render_callback(Canvas* const canvas, void* ctx) { - const MontyState* monty_state = acquire_mutex((ValueMutex*)ctx, 25); - if(monty_state == NULL) { - return; - } - - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - draw_top(canvas, monty_state); - draw_doors(canvas, monty_state); - draw_bottom(canvas, monty_state); - - release_mutex((ValueMutex*)ctx, monty_state); -} - -static void montyhall_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - furi_message_queue_put(event_queue, input_event, FuriWaitForever); -} - -int32_t montyhall_game_app(void* p) { - UNUSED(p); - int32_t return_code = 0; - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - MontyState* monty_state = malloc(sizeof(MontyState)); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, monty_state, sizeof(MontyState))) { - return_code = 255; - goto free_and_exit; - } - - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, montyhall_render_callback, &state_mutex); - view_port_input_callback_set(view_port, montyhall_input_callback, event_queue); - - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - // Start the game - montyhall_game_init_state(monty_state); - - InputEvent event; - for(bool loop = true; loop;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - MontyState* monty_state = (MontyState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - if(event.type == InputTypeShort) { - switch(event.key) { - case InputKeyUp: /* - if(monty_state->game_state == RoundOne) { - monty_state->score++; - } else if(monty_state->game_state == RoundTwo) { - monty_state->score += 2; - } else if(monty_state->game_state == RoundThree) { - monty_state->score += 3; - } else if(monty_state->game_state == RoundFour) { - monty_state->score += 4; - } else if(monty_state->game_state == GameOver) { - monty_state->score += 5; - } */ - break; - case InputKeyDown: /* - if(monty_state->game_state == RoundOne) { - monty_state->score--; - } else if(monty_state->game_state == RoundTwo) { - monty_state->score -= 2; - } else if(monty_state->game_state == RoundThree) { - monty_state->score -= 3; - } else if(monty_state->game_state == RoundFour) { - monty_state->score -= 4; - } else if(monty_state->game_state == GameOver) { - monty_state->score -= 5; - } */ - break; - case InputKeyLeft: - if(monty_state->game_state == RoundOne) { - selectDoor(monty_state, 0); - if(monty_state->game_state == RoundTwo) { - revealBadDoor(monty_state); - monty_state->game_state = RoundThree; - } - } else if(monty_state->game_state == RoundThree) { - if(monty_state->door_state.doors[0].isSelected) { - monty_state->door_state.didSwitch = false; - } else if(!monty_state->door_state.doors[0].isOpen) { - monty_state->door_state.didSwitch = true; - selectDoor(monty_state, 0); - } - monty_state->game_state = RoundFour; - } - break; - case InputKeyOk: - if(monty_state->game_state == RoundOne) { - selectDoor(monty_state, 1); - if(monty_state->game_state == RoundTwo) { - revealBadDoor(monty_state); - monty_state->game_state = RoundThree; - } - } else if(monty_state->game_state == RoundThree) { - if(monty_state->door_state.doors[1].isSelected) { - monty_state->door_state.didSwitch = false; - } else if(!monty_state->door_state.doors[1].isOpen) { - monty_state->door_state.didSwitch = true; - selectDoor(monty_state, 1); - } - monty_state->game_state = RoundFour; - } else if(monty_state->game_state == RoundFour) { - revealDoors_updateScore(monty_state); - monty_state->game_state = GameOver; - } - break; - case InputKeyRight: - if(monty_state->game_state == RoundOne) { - selectDoor(monty_state, 2); - if(monty_state->game_state == RoundTwo) { - revealBadDoor(monty_state); - monty_state->game_state = RoundThree; - } - } else if(monty_state->game_state == RoundThree) { - if(monty_state->door_state.doors[2].isSelected) { - monty_state->door_state.didSwitch = false; - } else if(!monty_state->door_state.doors[2].isOpen) { - monty_state->door_state.didSwitch = true; - selectDoor(monty_state, 2); - } - monty_state->game_state = RoundFour; - } - break; - case InputKeyBack: - loop = false; - break; - default: - break; - } - } - } else if(event.type == InputTypeLong) { - if(event.key == InputKeyOk && monty_state->game_state == GameOver) { - montyhall_game_init_state(monty_state); - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, monty_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - delete_mutex(&state_mutex); - -free_and_exit: - free(monty_state); - furi_message_queue_free(event_queue); - - return return_code; -} \ No newline at end of file diff --git a/applications/plugins/morse_code/application.fam b/applications/plugins/morse_code/application.fam deleted file mode 100644 index 1cc7bdaa1..000000000 --- a/applications/plugins/morse_code/application.fam +++ /dev/null @@ -1,15 +0,0 @@ -App( - appid="Morse_Code", - name="Morse Code", - apptype=FlipperAppType.EXTERNAL, - entry_point="morse_code_app", - cdefines=["APP_MORSE_CODE"], - requires=[ - "gui", - ], - stack_size=1 * 1024, - order=20, - fap_icon="morse_code_10px.png", - fap_category="Music" - -) \ No newline at end of file diff --git a/applications/plugins/morse_code/morse_code.c b/applications/plugins/morse_code/morse_code.c deleted file mode 100644 index beb661222..000000000 --- a/applications/plugins/morse_code/morse_code.c +++ /dev/null @@ -1,166 +0,0 @@ -#include "morse_code_worker.h" -#include -#include -#include -#include -#include -#include -#include - -static const float MORSE_CODE_VOLUMES[] = {0, .25, .5, .75, 1}; - -typedef struct { - FuriString* words; - uint8_t volume; - uint32_t dit_delta; -} MorseCodeModel; - -typedef struct { - MorseCodeModel* model; - FuriMutex** model_mutex; - - FuriMessageQueue* input_queue; - - ViewPort* view_port; - Gui* gui; - - MorseCodeWorker* worker; -} MorseCode; - -static void render_callback(Canvas* const canvas, void* ctx) { - MorseCode* morse_code = ctx; - furi_check(furi_mutex_acquire(morse_code->model_mutex, FuriWaitForever) == FuriStatusOk); - // border around the edge of the screen - canvas_set_font(canvas, FontPrimary); - - //write words - elements_multiline_text_aligned( - canvas, 64, 30, AlignCenter, AlignCenter, furi_string_get_cstr(morse_code->model->words)); - - // volume view_port - uint8_t vol_bar_x_pos = 124; - uint8_t vol_bar_y_pos = 0; - const uint8_t volume_h = (64 / (COUNT_OF(MORSE_CODE_VOLUMES) - 1)) * morse_code->model->volume; - canvas_draw_frame(canvas, vol_bar_x_pos, vol_bar_y_pos, 4, 64); - canvas_draw_box(canvas, vol_bar_x_pos, vol_bar_y_pos + (64 - volume_h), 4, volume_h); - - //dit bpm - canvas_draw_str_aligned( - canvas, - 0, - 10, - AlignLeft, - AlignCenter, - furi_string_get_cstr( - furi_string_alloc_printf("Dit: %ld ms", morse_code->model->dit_delta))); - - //button info - elements_button_center(canvas, "Press/Hold"); - furi_mutex_release(morse_code->model_mutex); -} - -static void input_callback(InputEvent* input_event, void* ctx) { - MorseCode* morse_code = ctx; - furi_message_queue_put(morse_code->input_queue, input_event, FuriWaitForever); -} - -static void morse_code_worker_callback(FuriString* words, void* context) { - MorseCode* morse_code = context; - furi_check(furi_mutex_acquire(morse_code->model_mutex, FuriWaitForever) == FuriStatusOk); - morse_code->model->words = words; - furi_mutex_release(morse_code->model_mutex); - view_port_update(morse_code->view_port); -} - -MorseCode* morse_code_alloc() { - MorseCode* instance = malloc(sizeof(MorseCode)); - - instance->model = malloc(sizeof(MorseCodeModel)); - instance->model->words = furi_string_alloc_set_str(""); - instance->model->volume = 3; - instance->model->dit_delta = 150; - instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - instance->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - instance->worker = morse_code_worker_alloc(); - - morse_code_worker_set_callback(instance->worker, morse_code_worker_callback, instance); - - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, render_callback, instance); - view_port_input_callback_set(instance->view_port, input_callback, instance); - - // Open GUI and register view_port - instance->gui = furi_record_open(RECORD_GUI); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - return instance; -} - -void morse_code_free(MorseCode* instance) { - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close(RECORD_GUI); - view_port_free(instance->view_port); - - morse_code_worker_free(instance->worker); - - furi_message_queue_free(instance->input_queue); - - furi_mutex_free(instance->model_mutex); - - free(instance->model); - free(instance); -} - -int32_t morse_code_app() { - MorseCode* morse_code = morse_code_alloc(); - InputEvent input; - morse_code_worker_start(morse_code->worker); - morse_code_worker_set_volume( - morse_code->worker, MORSE_CODE_VOLUMES[morse_code->model->volume]); - morse_code_worker_set_dit_delta(morse_code->worker, morse_code->model->dit_delta); - while(furi_message_queue_get(morse_code->input_queue, &input, FuriWaitForever) == - FuriStatusOk) { - furi_check(furi_mutex_acquire(morse_code->model_mutex, FuriWaitForever) == FuriStatusOk); - if(input.key == InputKeyBack && input.type == InputTypeLong) { - furi_mutex_release(morse_code->model_mutex); - break; - } else if(input.key == InputKeyBack && input.type == InputTypeShort) { - morse_code_worker_reset_text(morse_code->worker); - } else if(input.key == InputKeyOk) { - if(input.type == InputTypePress) - morse_code_worker_play(morse_code->worker, true); - else if(input.type == InputTypeRelease) - morse_code_worker_play(morse_code->worker, false); - } else if(input.key == InputKeyUp && input.type == InputTypePress) { - if(morse_code->model->volume < COUNT_OF(MORSE_CODE_VOLUMES) - 1) - morse_code->model->volume++; - morse_code_worker_set_volume( - morse_code->worker, MORSE_CODE_VOLUMES[morse_code->model->volume]); - } else if(input.key == InputKeyDown && input.type == InputTypePress) { - if(morse_code->model->volume > 0) morse_code->model->volume--; - morse_code_worker_set_volume( - morse_code->worker, MORSE_CODE_VOLUMES[morse_code->model->volume]); - } else if(input.key == InputKeyLeft && input.type == InputTypePress) { - if(morse_code->model->dit_delta > 10) morse_code->model->dit_delta -= 10; - morse_code_worker_set_dit_delta(morse_code->worker, morse_code->model->dit_delta); - } else if(input.key == InputKeyRight && input.type == InputTypePress) { - if(morse_code->model->dit_delta >= 10) morse_code->model->dit_delta += 10; - morse_code_worker_set_dit_delta(morse_code->worker, morse_code->model->dit_delta); - } - - FURI_LOG_D( - "Input", - "%s %s %ld", - input_get_key_name(input.key), - input_get_type_name(input.type), - input.sequence); - - furi_mutex_release(morse_code->model_mutex); - view_port_update(morse_code->view_port); - } - morse_code_worker_stop(morse_code->worker); - morse_code_free(morse_code); - return 0; -} \ No newline at end of file diff --git a/applications/plugins/morse_code/morse_code_10px.png b/applications/plugins/morse_code/morse_code_10px.png deleted file mode 100644 index 087c5b239..000000000 Binary files a/applications/plugins/morse_code/morse_code_10px.png and /dev/null differ diff --git a/applications/plugins/morse_code/morse_code_worker.c b/applications/plugins/morse_code/morse_code_worker.c deleted file mode 100644 index 3b7bd4417..000000000 --- a/applications/plugins/morse_code/morse_code_worker.c +++ /dev/null @@ -1,170 +0,0 @@ -#include "morse_code_worker.h" -#include -#include - -#define TAG "MorseCodeWorker" - -#define MORSE_CODE_VERSION 0 - -//A-Z0-1 -const char morse_array[36][6] = {".-", "-...", "-.-.", "-..", ".", "..-.", - "--.", "....", "..", ".---", "-.-", ".-..", - "--", "-.", "---", ".--.", "--.-", ".-.", - "...", "-", "..-", "...-", ".--", "-..-", - "-.--", "--..", ".----", "..---", "...--", "....-", - ".....", "-....", "--...", "---..", "----.", "-----"}; -const char symbol_array[36] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', - 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', - 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}; - -struct MorseCodeWorker { - FuriThread* thread; - MorseCodeWorkerCallback callback; - void* callback_context; - bool is_running; - bool play; - float volume; - uint32_t dit_delta; - FuriString* buffer; - FuriString* words; -}; - -void morse_code_worker_fill_buffer(MorseCodeWorker* instance, uint32_t duration) { - FURI_LOG_D("MorseCode: Duration", "%ld", duration); - if(duration <= instance->dit_delta) - furi_string_push_back(instance->buffer, *DOT); - else if(duration <= (instance->dit_delta * 3)) - furi_string_push_back(instance->buffer, *LINE); - if(furi_string_size(instance->buffer) > 5) furi_string_reset(instance->buffer); - FURI_LOG_D("MorseCode: Buffer", "%s", furi_string_get_cstr(instance->buffer)); -} - -void morse_code_worker_fill_letter(MorseCodeWorker* instance) { - if(furi_string_size(instance->words) > 63) furi_string_reset(instance->words); - for(size_t i = 0; i < sizeof(morse_array); i++) { - if(furi_string_cmp_str(instance->buffer, morse_array[i]) == 0) { - furi_string_push_back(instance->words, symbol_array[i]); - break; - } - } - furi_string_reset(instance->buffer); - FURI_LOG_D("MorseCode: Words", "%s", furi_string_get_cstr(instance->words)); -} - -static int32_t morse_code_worker_thread_callback(void* context) { - furi_assert(context); - MorseCodeWorker* instance = context; - bool was_playing = false; - uint32_t start_tick = 0; - uint32_t end_tick = 0; - bool pushed = true; - bool spaced = true; - while(instance->is_running) { - furi_delay_ms(SLEEP); - if(instance->play) { - if(!was_playing) { - start_tick = furi_get_tick(); - furi_hal_speaker_start(FREQUENCY, instance->volume); - was_playing = true; - } - } else { - if(was_playing) { - pushed = false; - spaced = false; - furi_hal_speaker_stop(); - end_tick = furi_get_tick(); - was_playing = false; - morse_code_worker_fill_buffer(instance, end_tick - start_tick); - start_tick = 0; - } - } - if(!pushed) { - if(end_tick + (instance->dit_delta * 3) < furi_get_tick()) { - //NEW LETTER - morse_code_worker_fill_letter(instance); - if(instance->callback) - instance->callback(instance->words, instance->callback_context); - pushed = true; - } - } - if(!spaced) { - if(end_tick + (instance->dit_delta * 7) < furi_get_tick()) { - //NEW WORD - furi_string_push_back(instance->words, *SPACE); - if(instance->callback) - instance->callback(instance->words, instance->callback_context); - spaced = true; - } - } - } - return 0; -} - -MorseCodeWorker* morse_code_worker_alloc() { - MorseCodeWorker* instance = malloc(sizeof(MorseCodeWorker)); - instance->thread = furi_thread_alloc(); - furi_thread_set_name(instance->thread, "MorseCodeWorker"); - furi_thread_set_stack_size(instance->thread, 1024); - furi_thread_set_context(instance->thread, instance); - furi_thread_set_callback(instance->thread, morse_code_worker_thread_callback); - instance->play = false; - instance->volume = 1.0f; - instance->dit_delta = 150; - instance->buffer = furi_string_alloc_set_str(""); - instance->words = furi_string_alloc_set_str(""); - return instance; -} - -void morse_code_worker_free(MorseCodeWorker* instance) { - furi_assert(instance); - furi_string_free(instance->buffer); - furi_string_free(instance->words); - furi_thread_free(instance->thread); - free(instance); -} - -void morse_code_worker_set_callback( - MorseCodeWorker* instance, - MorseCodeWorkerCallback callback, - void* context) { - furi_assert(instance); - instance->callback = callback; - instance->callback_context = context; -} - -void morse_code_worker_play(MorseCodeWorker* instance, bool play) { - furi_assert(instance); - instance->play = play; -} - -void morse_code_worker_set_volume(MorseCodeWorker* instance, float level) { - furi_assert(instance); - instance->volume = level; -} - -void morse_code_worker_set_dit_delta(MorseCodeWorker* instance, uint32_t delta) { - furi_assert(instance); - instance->dit_delta = delta; -} - -void morse_code_worker_reset_text(MorseCodeWorker* instance) { - furi_assert(instance); - furi_string_reset(instance->buffer); - furi_string_reset(instance->words); -} - -void morse_code_worker_start(MorseCodeWorker* instance) { - furi_assert(instance); - furi_assert(instance->is_running == false); - instance->is_running = true; - furi_thread_start(instance->thread); - FURI_LOG_D("MorseCode: Start", "is Running"); -} - -void morse_code_worker_stop(MorseCodeWorker* instance) { - furi_assert(instance); - furi_assert(instance->is_running == true); - instance->is_running = false; - furi_thread_join(instance->thread); - FURI_LOG_D("MorseCode: Stop", "Stop"); -} diff --git a/applications/plugins/morse_code/morse_code_worker.h b/applications/plugins/morse_code/morse_code_worker.h deleted file mode 100644 index e880c9579..000000000 --- a/applications/plugins/morse_code/morse_code_worker.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include -#include - -#define FREQUENCY 261.63f -#define SLEEP 10 -#define DOT "." -#define LINE "-" -#define SPACE " " - -typedef void (*MorseCodeWorkerCallback)(FuriString* buffer, void* context); - -typedef struct MorseCodeWorker MorseCodeWorker; - -MorseCodeWorker* morse_code_worker_alloc(); - -void morse_code_worker_free(MorseCodeWorker* instance); - -void morse_code_worker_set_callback( - MorseCodeWorker* instance, - MorseCodeWorkerCallback callback, - void* context); - -void morse_code_worker_start(MorseCodeWorker* instance); - -void morse_code_worker_stop(MorseCodeWorker* instance); - -void morse_code_worker_play(MorseCodeWorker* instance, bool play); - -void morse_code_worker_reset_text(MorseCodeWorker* instance); - -void morse_code_worker_set_volume(MorseCodeWorker* instance, float level); - -void morse_code_worker_set_dit_delta(MorseCodeWorker* instance, uint32_t delta); diff --git a/applications/plugins/mousejacker/README.md b/applications/plugins/mousejacker/README.md deleted file mode 100644 index ad5fdecdc..000000000 --- a/applications/plugins/mousejacker/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# flipperzero-nrf24 - -An [NRF24](https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf) driver for the [Flipper Zero](https://flipperzero.one/) device. The NRF24 is a popular line of 2.4GHz radio transceivers from Nordic Semiconductors. This library is not currently complete, but functional. - -## Warning -This repo contains two Flipper Zero apps that utilize the NRF24 driver to sniff for NRF24 addresses and perform mousejack attacks. These apps are for **educational purposes** only. Please use this code responsibly and only use these apps on your own equipment. - -## Acknowledgments -The NRF24 sniffing technique was discovered and shared by Travis Goodspeed in [his blog](http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html). - -The mousejack vulnerabilities were discovered and reported by Marc Newlin, see [the blog](https://www.bastille.net/research/vulnerabilities/mousejack/technical-details) for technical details. - -Much of the driver code was inspired by [RadioHead's Arduino library](https://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF24.html). -Much of the mousejack code was inspired by the [Jackit project](https://github.com/insecurityofthings/jackit). - - -## PinOut from from NoComp/Frog - - -# Mousejack / NRF24 pinout by UberGuidoZ -2/A7 on FZ goes to MOSI/6 on nrf24l01
-3/A6 on FZ goes to MISO/7 on nrf24l01
-4/A4 on FZ goes to CSN/4 on nrf24l01
-5/B3 on FZ goes to SCK/5 on nrf24l01
-6/B2 on FZ goes to CE/3 on nrf24l01
-8/GND on FZ goes to GND/1 on nrf24l01
-9/3V3 on FZ goes to VCC/2 on nrf24l01
-IRQ/8 is left disconnected on nrf24l01 - -![NRF_Pins](https://user-images.githubusercontent.com/57457139/178093717-39effd5c-ebe2-4253-b13c-70517d7902f9.png) - -If the nRF module is acting a bit flakey, try adding a capacitor to the vcc/gnd lines! I've not tried the Plus model so it may have a bigger need for a cap. Otherwise, I haven't had any major issues. Anything from a 3.3 uF to 10 uF should do. (Watch your positive/negative placement! Negative to ground.) I learned if you wanna get fancy, include a 0.1 uF cap in parallel. The 3.3 uF to 10 uF will respond to slow freq changes while the 0.1 uF will respond to the high freq switching spikes that the larger one cannot. That said, a single 10 uF will likely suffice for the Mousejack attack. ¯\\\_(ツ)_/¯ - -![NRF_Capacitor](https://user-images.githubusercontent.com/57457139/178169959-d030f9a6-d2ac-46af-af8b-470ff092c8a7.jpg) - -Selfmade NRF24 breakoutboard: -![NRF_soldered](https://user-images.githubusercontent.com/22019133/183419103-9c40b28b-8152-4212-98e0-9a3358f69518.jpeg) -![NRF_soldered2](https://user-images.githubusercontent.com/22019133/183419176-26c0359b-0ecb-4015-8f8b-3a75209502ba.jpeg) - -## Practical hints from einstein2150 -If you are not successfull with the NRF Sniff Plugin you can try to get the MAC of the device with the crazyradio pa USB dongle. Have a look here: https://github.com/SySS-Research/nrf24-playset - - -A sample output of the NRF-Research script could be like -``` -[2022-08-05 13:28:56.366] Found nRF24 device with address 38:24:93:C0:07 on channel 75\ -[2022-08-05 13:28:56.371] Checking communication\ -[2022-08-05 13:28:59.088] Scan for nRF24 device\ -[2022-08-05 13:28:59.097] Actively searching for address 07:C0:93:24:38\ -``` - -Be carefull with the byte-order using in mousejacker! The correct byte order is the reverse-byteorder. In my example the reversed one is ```07:C0:93:24:38``` for my Logitech R400 presenter. -The next thing which could make trouble is the datarate. In my case the Logitech-device is only responding at 2Mbit. Commands at 1Mbit are not detected. - -Now its time to write all the relevant information in the config file. In my case you are creating a file ```addresses.txt``` in the SD directory of ```/nrfsniff```. The file content corresponding to the results of the research is ```07C0932438,2``` representing the reversed byte order of the MAC and the comma-separated datarate. - -Start the Mouse Jacker plugin and select the prepared ```addresses.txt```. If everything is alright you are starting with your MAC ready for attack: - -![mousejacker start-screen](https://user-images.githubusercontent.com/22019133/183419533-ef5c8df1-e328-45e3-b85d-376513d69c82.jpeg) - -If you have troube you can check if a datarate of 1 Mbit will help. Change ```07C0932438,2``` to ```07C0932438,1``` in this case. Another problem in the practical use is electromagnetical noise. In my case the external USB-3.1-Hub creating massive noise in the 2,4 Ghz-Frequency around a distance of 5 cm. Try using a long USB connection-cable for the receiver. In my case the response of the attack raises significant because the signals of the NRF-breakoutboard is no more covered with noise. - diff --git a/applications/plugins/mousejacker/application.fam b/applications/plugins/mousejacker/application.fam deleted file mode 100644 index 05835700b..000000000 --- a/applications/plugins/mousejacker/application.fam +++ /dev/null @@ -1,24 +0,0 @@ -App( - appid="NRF24_Mouse_Jacker", - name="[NRF24] Mouse Jacker", - apptype=FlipperAppType.EXTERNAL, - entry_point="mousejacker_app", - cdefines=["APP_MOUSEJACKER"], - requires=[ - "gui", - "dialogs", - ], - stack_size=2 * 1024, - order=50, - fap_icon="mouse_10px.png", - fap_category="GPIO", - fap_icon_assets="images", - fap_private_libs=[ - Lib( - name="nrf24", - sources=[ - "nrf24.c", - ], - ), - ], -) diff --git a/applications/plugins/mousejacker/icons/badusb_10px.png b/applications/plugins/mousejacker/icons/badusb_10px.png deleted file mode 100644 index 037474aa3..000000000 Binary files a/applications/plugins/mousejacker/icons/badusb_10px.png and /dev/null differ diff --git a/applications/plugins/mousejacker/icons/sub1_10px.png b/applications/plugins/mousejacker/icons/sub1_10px.png deleted file mode 100644 index 5a25fdf4e..000000000 Binary files a/applications/plugins/mousejacker/icons/sub1_10px.png and /dev/null differ diff --git a/applications/plugins/mousejacker/images/badusb_10px.png b/applications/plugins/mousejacker/images/badusb_10px.png deleted file mode 100644 index 037474aa3..000000000 Binary files a/applications/plugins/mousejacker/images/badusb_10px.png and /dev/null differ diff --git a/applications/plugins/mousejacker/images/sub1_10px.png b/applications/plugins/mousejacker/images/sub1_10px.png deleted file mode 100644 index 5a25fdf4e..000000000 Binary files a/applications/plugins/mousejacker/images/sub1_10px.png and /dev/null differ diff --git a/applications/plugins/mousejacker/lib/nrf24/nrf24.c b/applications/plugins/mousejacker/lib/nrf24/nrf24.c deleted file mode 100644 index 8b3776445..000000000 --- a/applications/plugins/mousejacker/lib/nrf24/nrf24.c +++ /dev/null @@ -1,520 +0,0 @@ -#include "nrf24.h" -#include -#include -#include -#include -#include - -void nrf24_init() { - furi_hal_spi_bus_handle_init(nrf24_HANDLE); - furi_hal_spi_acquire(nrf24_HANDLE); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh); - furi_hal_gpio_write(nrf24_CE_PIN, false); -} - -void nrf24_deinit() { - furi_hal_spi_release(nrf24_HANDLE); - furi_hal_spi_bus_handle_deinit(nrf24_HANDLE); - furi_hal_gpio_write(nrf24_CE_PIN, false); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} - -void nrf24_spi_trx( - FuriHalSpiBusHandle* handle, - uint8_t* tx, - uint8_t* rx, - uint8_t size, - uint32_t timeout) { - UNUSED(timeout); - furi_hal_gpio_write(handle->cs, false); - furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT); - furi_hal_gpio_write(handle->cs, true); -} - -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data) { - uint8_t tx[2] = {W_REGISTER | (REGISTER_MASK & reg), data}; - uint8_t rx[2] = {0}; - nrf24_spi_trx(handle, tx, rx, 2, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t - nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = W_REGISTER | (REGISTER_MASK & reg); - memcpy(&tx[1], data, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = R_REGISTER | (REGISTER_MASK & reg); - memset(&tx[1], 0, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - memcpy(data, &rx[1], size); - return rx[0]; -} - -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_RX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_TX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle) { - uint8_t maclen; - nrf24_read_reg(handle, REG_SETUP_AW, &maclen, 1); - maclen &= 3; - return maclen + 2; -} - -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen) { - assert(maclen > 1 && maclen < 6); - uint8_t status = 0; - status = nrf24_write_reg(handle, REG_SETUP_AW, maclen - 2); - return status; -} - -uint8_t nrf24_status(FuriHalSpiBusHandle* handle) { - uint8_t status; - uint8_t tx[] = {R_REGISTER | (REGISTER_MASK & REG_STATUS)}; - nrf24_spi_trx(handle, tx, &status, 1, nrf24_TIMEOUT); - return status; -} - -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle) { - uint8_t setup = 0; - uint32_t rate = 0; - nrf24_read_reg(handle, REG_RF_SETUP, &setup, 1); - setup &= 0x28; - if(setup == 0x20) - rate = 250000; // 250kbps - else if(setup == 0x08) - rate = 2000000; // 2Mbps - else if(setup == 0x00) - rate = 1000000; // 1Mbps - - return rate; -} - -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate) { - uint8_t r6 = 0; - uint8_t status = 0; - if(!rate) rate = 2000000; - - nrf24_read_reg(handle, REG_RF_SETUP, &r6, 1); // RF_SETUP register - r6 = r6 & (~0x28); // Clear rate fields. - if(rate == 2000000) - r6 = r6 | 0x08; - else if(rate == 1000000) - r6 = r6; - else if(rate == 250000) - r6 = r6 | 0x20; - - status = nrf24_write_reg(handle, REG_RF_SETUP, r6); // Write new rate. - return status; -} - -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle) { - uint8_t channel = 0; - nrf24_read_reg(handle, REG_RF_CH, &channel, 1); - return channel; -} - -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan) { - uint8_t status; - status = nrf24_write_reg(handle, REG_RF_CH, chan); - return status; -} - -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_TX_ADDR, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle) { - uint8_t len = 0; - nrf24_read_reg(handle, RX_PW_P0, &len, 1); - return len; -} - -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) { - uint8_t status = 0; - status = nrf24_write_reg(handle, RX_PW_P0, len); - return status; -} - -uint8_t - nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) { - uint8_t status = 0; - uint8_t size = 0; - uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0}; - uint8_t rx_pl_wid[] = {0, 0}; - uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command - uint8_t tmp_packet[33] = {0}; - - status = nrf24_status(handle); - - if(status & 0x40) { - if(full) - size = nrf24_get_packetlen(handle); - else { - nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT); - size = rx_pl_wid[1]; - } - - tx_cmd[0] = R_RX_PAYLOAD; - nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT); - nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit. - memcpy(packet, &tmp_packet[1], size); - } else if(status == 0) { - nrf24_flush_rx(handle); - nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit. - } - - *packetsize = size; - return status; -} - -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack) { - uint8_t status = 0; - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(tx, 0, size + 1); - memset(rx, 0, size + 1); - - if(!ack) - tx[0] = W_TX_PAYLOAD_NOACK; - else - tx[0] = W_TX_PAYLOAD; - - memcpy(&tx[1], payload, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - nrf24_set_tx_mode(handle); - - while(!(status & (TX_DS | MAX_RT))) status = nrf24_status(handle); - - if(status & MAX_RT) nrf24_flush_tx(handle); - - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, TX_DS | MAX_RT); - return status & TX_DS; -} - -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg = cfg | 2; - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_delay_ms(5000); - return status; -} - -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfc; // clear bottom two bits to power down the radio - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(handle, REG_EN_RXADDR, 0x0); - furi_hal_gpio_write(nrf24_CE_PIN, false); - return status; -} - -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0F); // enable 2-byte CRC, PWR_UP, and PRIM_RX - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg |= 0x03; // PWR_UP, and PRIM_RX - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1 - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2000); - return status; -} - -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - furi_hal_gpio_write(nrf24_CE_PIN, false); - nrf24_write_reg(handle, REG_STATUS, 0x30); - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0E); // enable 2-byte CRC, PWR_UP - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfe; // disable PRIM_RX - cfg |= 0x02; // PWR_UP - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2); - return status; -} - -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa) { - assert(channel <= 125); - assert(rate == 1 || rate == 2); - if(rate == 2) - rate = 8; // 2Mbps - else - rate = 0; // 1Mbps - - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts - if(disable_aa) - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - else - nrf24_write_reg(handle, REG_EN_AA, 0x1F); // Enable Shockburst - - nrf24_write_reg(handle, REG_DYNPD, 0x3F); // enable dynamic payload length on all pipes - if(noack) - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - else { - nrf24_write_reg(handle, REG_CONFIG, 0x0C); // 2 byte CRC - nrf24_write_reg(handle, REG_FEATURE, 0x07); // enable dyn payload and ack - nrf24_write_reg( - handle, REG_SETUP_RETR, 0x1f); // 15 retries for AA, 500us auto retransmit delay - } - - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - - if(maclen) nrf24_set_maclen(handle, maclen); - if(srcmac) nrf24_set_src_mac(handle, srcmac, maclen); - if(dstmac) nrf24_set_dst_mac(handle, dstmac, maclen); - - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - furi_delay_ms(200); -} - -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate) { - //uint8_t preamble[] = {0x55, 0x00}; // little endian - uint8_t preamble[] = {0xAA, 0x00}; // little endian - //uint8_t preamble[] = {0x00, 0x55}; // little endian - //uint8_t preamble[] = {0x00, 0xAA}; // little endian - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts - nrf24_write_reg(handle, REG_DYNPD, 0x0); // disable shockburst - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - nrf24_set_maclen(handle, 2); // shortest address - nrf24_set_src_mac(handle, preamble, 2); // set src mac to preamble bits to catch everything - nrf24_set_packetlen(handle, 32); // set max packet length - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - - // prime for RX, no checksum - nrf24_write_reg(handle, REG_CONFIG, 0x03); // PWR_UP and PRIM_RX, disable AA and CRC - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(100); -} - -void hexlify(uint8_t* in, uint8_t size, char* out) { - memset(out, 0, size * 2); - for(int i = 0; i < size; i++) - snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]); -} - -uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) { - uint64_t ret = 0; - for(int i = 0; i < size; i++) - if(bigendian) - ret |= bytes[i] << ((size - 1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 8; i++) { - if(bigendian) - out[i] = (val >> ((7 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian) { - uint32_t ret = 0; - for(int i = 0; i < 4; i++) - if(bigendian) - ret |= bytes[i] << ((3 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 4; i++) { - if(bigendian) - out[i] = (val >> ((3 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint64_t bytes_to_int16(uint8_t* bytes, bool bigendian) { - uint16_t ret = 0; - for(int i = 0; i < 2; i++) - if(bigendian) - ret |= bytes[i] << ((1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 2; i++) { - if(bigendian) - out[i] = (val >> ((1 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -// handle iffyness with preamble processing sometimes being a bit (literally) off -void alt_address_old(uint8_t* packet, uint8_t* altaddr) { - uint8_t macmess_hi_b[4]; - uint8_t macmess_lo_b[2]; - uint32_t macmess_hi; - uint16_t macmess_lo; - uint8_t preserved; - - // get first 6 bytes into 32-bit and 16-bit variables - memcpy(macmess_hi_b, packet, 4); - memcpy(macmess_lo_b, packet + 4, 2); - - macmess_hi = bytes_to_int32(macmess_hi_b, true); - - //preserve least 7 bits from hi that will be shifted down to lo - preserved = macmess_hi & 0x7f; - macmess_hi >>= 7; - - macmess_lo = bytes_to_int16(macmess_lo_b, true); - macmess_lo >>= 7; - macmess_lo = (preserved << 9) | macmess_lo; - int32_to_bytes(macmess_hi, macmess_hi_b, true); - int16_to_bytes(macmess_lo, macmess_lo_b, true); - memcpy(altaddr, &macmess_hi_b[1], 3); - memcpy(altaddr + 3, macmess_lo_b, 2); -} - -bool validate_address(uint8_t* addr) { - uint8_t bad[][3] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x00, 0x00}, {0xFF, 0xFF}}; - for(int i = 0; i < 4; i++) - for(int j = 0; j < 2; j++) - if(!memcmp(addr + j * 2, bad[i], 2)) return false; - - return true; -} - -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address) { - bool found = false; - uint8_t packet[32] = {0}; - uint8_t packetsize; - //char printit[65]; - uint8_t status = 0; - status = nrf24_rxpacket(handle, packet, &packetsize, true); - if(status & 0x40) { - if(validate_address(packet)) { - for(int i = 0; i < maclen; i++) address[i] = packet[maclen - 1 - i]; - - /* - alt_address(packet, packet); - - for(i = 0; i < maclen; i++) - address[i + 5] = packet[maclen - 1 - i]; - */ - - //memcpy(address, packet, maclen); - //hexlify(packet, packetsize, printit); - found = true; - } - } - - return found; -} - -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit) { - uint8_t ping_packet[] = {0x0f, 0x0f, 0x0f, 0x0f}; // this can be anything, we just need an ack - uint8_t ch = max_channel + 1; // means fail - nrf24_configure(handle, rate, srcmac, dstmac, maclen, 2, false, false); - for(ch = min_channel; ch <= max_channel + 1; ch++) { - nrf24_write_reg(handle, REG_RF_CH, ch); - if(nrf24_txpacket(handle, ping_packet, 4, true)) break; - } - - if(autoinit) { - FURI_LOG_D("nrf24", "initializing radio for channel %d", ch); - nrf24_configure(handle, rate, srcmac, dstmac, maclen, ch, false, false); - return ch; - } - - return ch; -} \ No newline at end of file diff --git a/applications/plugins/mousejacker/lib/nrf24/nrf24.h b/applications/plugins/mousejacker/lib/nrf24/nrf24.h deleted file mode 100644 index 3cfcfe089..000000000 --- a/applications/plugins/mousejacker/lib/nrf24/nrf24.h +++ /dev/null @@ -1,366 +0,0 @@ -#pragma once -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define R_REGISTER 0x00 -#define W_REGISTER 0x20 -#define REGISTER_MASK 0x1F -#define ACTIVATE 0x50 -#define R_RX_PL_WID 0x60 -#define R_RX_PAYLOAD 0x61 -#define W_TX_PAYLOAD 0xA0 -#define W_TX_PAYLOAD_NOACK 0xB0 -#define W_ACK_PAYLOAD 0xA8 -#define FLUSH_TX 0xE1 -#define FLUSH_RX 0xE2 -#define REUSE_TX_PL 0xE3 -#define RF24_NOP 0xFF - -#define REG_CONFIG 0x00 -#define REG_EN_AA 0x01 -#define REG_EN_RXADDR 0x02 -#define REG_SETUP_AW 0x03 -#define REG_SETUP_RETR 0x04 -#define REG_DYNPD 0x1C -#define REG_FEATURE 0x1D -#define REG_RF_SETUP 0x06 -#define REG_STATUS 0x07 -#define REG_RX_ADDR_P0 0x0A -#define REG_RF_CH 0x05 -#define REG_TX_ADDR 0x10 - -#define RX_PW_P0 0x11 -#define TX_DS 0x20 -#define MAX_RT 0x10 - -#define nrf24_TIMEOUT 500 -#define nrf24_CE_PIN &gpio_ext_pb2 -#define nrf24_HANDLE &furi_hal_spi_bus_handle_external - -/* Low level API */ - -/** Write device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * - * @return device status - */ -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data); - -/** Write buffer to device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * @param size - size of data to write - * - * @return device status - */ -uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Read device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param[out] data - pointer to data - * - * @return device status - */ -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Power up the radio for operation - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle); - -/** Power down the radio - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle); - -/** Sets the radio to RX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle); - -/** Sets the radio to TX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle); - -/*=============================================================================================================*/ - -/* High level API */ - -/** Must call this before using any other nrf24 API - * - */ -void nrf24_init(); - -/** Must call this when we end using nrf24 device - * - */ -void nrf24_deinit(); - -/** Send flush rx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle); - -/** Send flush tx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle); - -/** Gets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return packet length in data pipe 0 - */ -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle); - -/** Sets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * @param len - length to set - * - * @return device status - */ -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len); - -/** Gets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return MAC address length - */ -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle); - -/** Sets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length to set MAC address to, must be greater than 1 and less than 6 - * - * @return MAC address length - */ -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen); - -/** Gets the current status flags from the STATUS register - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return status flags - */ -uint8_t nrf24_status(FuriHalSpiBusHandle* handle); - -/** Gets the current transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return transfer rate in bps - */ -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle); - -/** Sets the transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * @param rate - the transfer rate in bps - * - * @return device status - */ -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate); - -/** Gets the current channel - * In nrf24, the channel number is multiplied times 1MHz and added to 2400MHz to get the frequency - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return channel - */ -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle); - -/** Sets the channel - * - * @param handle - pointer to FuriHalSpiHandle - * @param frequency - the frequency in hertz - * - * @return device status - */ -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan); - -/** Gets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Gets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Reads RX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] packet - the packet contents - * @param[out] packetsize - size of the received packet - * @param full - boolean set to true, packet length is determined by RX_PW_P0 register, false it is determined by dynamic payload length command - * - * @return device status - */ -uint8_t - nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full); - -/** Sends TX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param packet - the packet contents - * @param size - packet size - * @param ack - boolean to determine whether an ACK is required for the packet or not - * - * @return device status - */ -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack); - -/** Configure the radio - * This is not comprehensive, but covers a lot of the common configuration options that may be changed - * @param handle - pointer to FuriHalSpiHandle - * @param rate - transfer rate in Mbps (1 or 2) - * @param srcmac - source mac address - * @param dstmac - destination mac address - * @param maclen - length of mac address - * @param channel - channel to tune to - * @param noack - if true, disable auto-acknowledge - * @param disable_aa - if true, disable ShockBurst - * - */ -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa); - -/** Configures the radio for "promiscuous mode" and primes it for rx - * This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were. - * See http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html for details. - * @param handle - pointer to FuriHalSpiHandle - * @param channel - channel to tune to - * @param rate - transfer rate in Mbps (1 or 2) - */ -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate); - -/** Listens for a packet and returns first possible address sniffed - * Call this only after calling nrf24_init_promisc_mode - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length of target mac address - * @param[out] addresses - sniffed address - * - * @return success - */ -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address); - -/** Sends ping packet on each channel for designated tx mac looking for ack - * - * @param handle - pointer to FuriHalSpiHandle - * @param srcmac - source address - * @param dstmac - destination address - * @param maclen - length of address - * @param rate - transfer rate in Mbps (1 or 2) - * @param min_channel - channel to start with - * @param max_channel - channel to end at - * @param autoinit - if true, automatically configure radio for this channel - * - * @return channel that the address is listening on, if this value is above the max_channel param, it failed - */ -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit); - -/** Converts 64 bit value into uint8_t array - * @param val - 64-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian); - -/** Converts 32 bit value into uint8_t array - * @param val - 32-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian); - -/** Converts uint8_t array into 32 bit value - * @param bytes - uint8_t array - * @param bigendian - if true, convert as big endian, otherwise little endian - * - * @return 32-bit value - */ -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/mousejacker/mouse_10px.png b/applications/plugins/mousejacker/mouse_10px.png deleted file mode 100644 index 94c3a7a14..000000000 Binary files a/applications/plugins/mousejacker/mouse_10px.png and /dev/null differ diff --git a/applications/plugins/mousejacker/mousejacker.c b/applications/plugins/mousejacker/mousejacker.c deleted file mode 100644 index c45b0e502..000000000 --- a/applications/plugins/mousejacker/mousejacker.c +++ /dev/null @@ -1,399 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mousejacker_ducky.h" -#include -#include "NRF24_Mouse_Jacker_icons.h" - -#define TAG "mousejacker" -#define LOGITECH_MAX_CHANNEL 85 -#define NRFSNIFF_APP_PATH_FOLDER "/ext/nrfsniff" -#define NRFSNIFF_APP_PATH_EXTENSION ".txt" -#define NRFSNIFF_APP_FILENAME "addresses.txt" -#define MOUSEJACKER_APP_PATH_FOLDER "/ext/mousejacker" -#define MOUSEJACKER_APP_PATH_EXTENSION ".txt" -#define MAX_ADDRS 100 - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -uint8_t addrs_count = 0; -uint8_t addr_idx = 0; -uint8_t loaded_addrs[MAX_ADDRS][6]; // first byte is rate, the rest are the address - -char target_fmt_text[] = "Target addr: %s"; -char target_address_str[12] = "None"; -char target_text[30]; - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - // border around the edge of the screen - canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontSecondary); - if(!plugin_state->addr_err && !plugin_state->ducky_err && !plugin_state->is_thread_running && - !plugin_state->is_ducky_running) { - snprintf(target_text, sizeof(target_text), target_fmt_text, target_address_str); - canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text); - canvas_draw_str_aligned(canvas, 22, 20, AlignLeft, AlignBottom, "<- select address ->"); - canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "Press Ok button to "); - canvas_draw_str_aligned(canvas, 10, 40, AlignLeft, AlignBottom, "browse for ducky script"); - } else if(plugin_state->addr_err) { - canvas_draw_str_aligned( - canvas, 10, 10, AlignLeft, AlignBottom, "Error: No nrfsniff folder"); - canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, "or addresses.txt file"); - canvas_draw_str_aligned( - canvas, 10, 30, AlignLeft, AlignBottom, "loading error / empty file"); - canvas_draw_str_aligned( - canvas, 7, 40, AlignLeft, AlignBottom, "Run (NRF24: Sniff) app first!"); - } else if(plugin_state->ducky_err) { - canvas_draw_str_aligned( - canvas, 3, 10, AlignLeft, AlignBottom, "Error: No mousejacker folder"); - canvas_draw_str_aligned(canvas, 3, 20, AlignLeft, AlignBottom, "or duckyscript file"); - canvas_draw_str_aligned(canvas, 3, 30, AlignLeft, AlignBottom, "loading error"); - } else if(plugin_state->is_thread_running && !plugin_state->is_ducky_running) { - canvas_draw_str_aligned(canvas, 3, 10, AlignLeft, AlignBottom, "Loading..."); - canvas_draw_str_aligned(canvas, 3, 20, AlignLeft, AlignBottom, "Please wait!"); - } else if(plugin_state->is_thread_running && plugin_state->is_ducky_running) { - canvas_draw_str_aligned(canvas, 3, 10, AlignLeft, AlignBottom, "Running duckyscript"); - canvas_draw_str_aligned(canvas, 3, 20, AlignLeft, AlignBottom, "Please wait!"); - canvas_draw_str_aligned( - canvas, 3, 30, AlignLeft, AlignBottom, "Press back to exit (if it stuck)"); - } else { - canvas_draw_str_aligned(canvas, 3, 10, AlignLeft, AlignBottom, "Unknown Error"); - canvas_draw_str_aligned(canvas, 3, 20, AlignLeft, AlignBottom, "press back"); - canvas_draw_str_aligned(canvas, 3, 30, AlignLeft, AlignBottom, "to exit"); - } - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void mousejacker_state_init(PluginState* const plugin_state) { - plugin_state->is_thread_running = false; -} - -static void hexlify(uint8_t* in, uint8_t size, char* out) { - memset(out, 0, size * 2); - for(int i = 0; i < size; i++) - snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]); -} - -static bool open_ducky_script(Stream* stream, PluginState* plugin_state) { - DialogsApp* dialogs = furi_record_open("dialogs"); - bool result = false; - FuriString* path; - path = furi_string_alloc(); - furi_string_set(path, MOUSEJACKER_APP_PATH_FOLDER); - - DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options( - &browser_options, MOUSEJACKER_APP_PATH_EXTENSION, &I_badusb_10px); - browser_options.hide_ext = false; - - bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options); - - furi_record_close("dialogs"); - if(ret) { - if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path)); - } else { - result = true; - } - } - furi_string_free(path); - - plugin_state->is_ducky_running = true; - - return result; -} - -static bool open_addrs_file(Stream* stream) { - DialogsApp* dialogs = furi_record_open("dialogs"); - bool result = false; - FuriString* path; - path = furi_string_alloc(); - furi_string_set(path, NRFSNIFF_APP_PATH_FOLDER); - - DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options( - &browser_options, NRFSNIFF_APP_PATH_EXTENSION, &I_sub1_10px); - browser_options.hide_ext = false; - - bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options); - - furi_record_close("dialogs"); - if(ret) { - if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path)); - } else { - result = true; - } - } - furi_string_free(path); - return result; -} - -static bool process_ducky_file( - Stream* file_stream, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - PluginState* plugin_state) { - size_t file_size = 0; - size_t bytes_read = 0; - uint8_t* file_buf; - bool loaded = false; - FURI_LOG_D(TAG, "opening ducky script"); - if(open_ducky_script(file_stream, plugin_state)) { - file_size = stream_size(file_stream); - if(file_size == (size_t)0) { - FURI_LOG_D(TAG, "load failed. file_size: %d", file_size); - plugin_state->is_ducky_running = false; - return loaded; - } - file_buf = malloc(file_size); - memset(file_buf, 0, file_size); - bytes_read = stream_read(file_stream, file_buf, file_size); - if(bytes_read == file_size) { - FURI_LOG_D(TAG, "executing ducky script"); - mj_process_ducky_script( - nrf24_HANDLE, addr, addr_size, rate, (char*)file_buf, plugin_state); - FURI_LOG_D(TAG, "finished execution"); - DOLPHIN_DEED(getRandomDeed()); - loaded = true; - } else { - FURI_LOG_D(TAG, "load failed. file size: %d", file_size); - } - free(file_buf); - } - plugin_state->is_ducky_running = false; - return loaded; -} - -static bool load_addrs_file(Stream* file_stream) { - size_t file_size = 0; - size_t bytes_read = 0; - uint8_t* file_buf; - char* line_ptr; - uint8_t rate; - uint8_t addrlen = 0; - uint32_t counter = 0; - uint8_t addr[5] = {0}; - uint32_t i_addr_lo = 0; - uint32_t i_addr_hi = 0; - bool loaded = false; - FURI_LOG_D(TAG, "opening addrs file"); - addrs_count = 0; - if(open_addrs_file(file_stream)) { - file_size = stream_size(file_stream); - if(file_size == (size_t)0) { - FURI_LOG_D(TAG, "load failed. file_size: %d", file_size); - return loaded; - } - file_buf = malloc(file_size); - memset(file_buf, 0, file_size); - bytes_read = stream_read(file_stream, file_buf, file_size); - if(bytes_read == file_size) { - FURI_LOG_D(TAG, "loading addrs file"); - char* line = strtok((char*)file_buf, "\n"); - - while(line != NULL) { - line_ptr = strstr((char*)line, ","); - *line_ptr = 0; - rate = atoi(line_ptr + 1); - addrlen = (uint8_t)(strlen(line) / 2); - i_addr_lo = strtoul(line + 2, NULL, 16); - line[2] = (char)0; - i_addr_hi = strtoul(line, NULL, 16); - int32_to_bytes(i_addr_lo, &addr[1], true); - addr[0] = (uint8_t)(i_addr_hi & 0xFF); - memset(loaded_addrs[counter], rate, 1); - memcpy(&loaded_addrs[counter++][1], addr, addrlen); - addrs_count++; - line = strtok(NULL, "\n"); - loaded = true; - } - } else { - FURI_LOG_D(TAG, "load failed. file size: %d", file_size); - } - free(file_buf); - } - return loaded; -} - -// entrypoint for worker -static int32_t mj_worker_thread(void* ctx) { - PluginState* plugin_state = ctx; - bool ducky_ok = false; - if(!plugin_state->addr_err) { - plugin_state->is_thread_running = true; - plugin_state->file_stream = file_stream_alloc(plugin_state->storage); - nrf24_find_channel( - nrf24_HANDLE, - loaded_addrs[addr_idx] + 1, - loaded_addrs[addr_idx] + 1, - 5, - loaded_addrs[addr_idx][0], - 2, - LOGITECH_MAX_CHANNEL, - true); - ducky_ok = process_ducky_file( - plugin_state->file_stream, - loaded_addrs[addr_idx] + 1, - 5, - loaded_addrs[addr_idx][0], - plugin_state); - if(!ducky_ok) { - plugin_state->ducky_err = true; - } else { - plugin_state->ducky_err = false; - } - stream_free(plugin_state->file_stream); - } - plugin_state->is_thread_running = false; - return 0; -} - -void start_mjthread(PluginState* plugin_state) { - if(!plugin_state->is_thread_running) { - furi_thread_start(plugin_state->mjthread); - } -} - -int32_t mousejacker_app(void* p) { - UNUSED(p); - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - PluginState* plugin_state = malloc(sizeof(PluginState)); - mousejacker_state_init(plugin_state); - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - FURI_LOG_E("mousejacker", "cannot create mutex\r\n"); - furi_message_queue_free(event_queue); - free(plugin_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - plugin_state->storage = furi_record_open(RECORD_STORAGE); - storage_common_mkdir(plugin_state->storage, MOUSEJACKER_APP_PATH_FOLDER); - plugin_state->file_stream = file_stream_alloc(plugin_state->storage); - - plugin_state->mjthread = furi_thread_alloc(); - furi_thread_set_name(plugin_state->mjthread, "MJ Worker"); - furi_thread_set_stack_size(plugin_state->mjthread, 2048); - furi_thread_set_context(plugin_state->mjthread, plugin_state); - furi_thread_set_callback(plugin_state->mjthread, mj_worker_thread); - - // spawn load file dialog to choose sniffed addresses file - if(load_addrs_file(plugin_state->file_stream)) { - addr_idx = 0; - hexlify(&loaded_addrs[addr_idx][1], 5, target_address_str); - plugin_state->addr_err = false; - } else { - plugin_state->addr_err = true; - } - stream_free(plugin_state->file_stream); - nrf24_init(); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - if(!plugin_state->addr_err) { - addr_idx++; - if(addr_idx > addrs_count) addr_idx = 0; - hexlify(loaded_addrs[addr_idx] + 1, 5, target_address_str); - } - break; - case InputKeyLeft: - if(!plugin_state->addr_err) { - addr_idx--; - if(addr_idx == 0) addr_idx = addrs_count - 1; - hexlify(loaded_addrs[addr_idx] + 1, 5, target_address_str); - } - break; - case InputKeyOk: - if(!plugin_state->addr_err) { - if(!plugin_state->is_thread_running) { - start_mjthread(plugin_state); - view_port_update(view_port); - } - } - break; - case InputKeyBack: - plugin_state->close_thread_please = true; - if(plugin_state->is_thread_running && plugin_state->mjthread) { - furi_thread_join( - plugin_state->mjthread); // wait until thread is finished - } - plugin_state->close_thread_please = false; - processing = false; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - furi_thread_free(plugin_state->mjthread); - nrf24_deinit(); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - furi_record_close(RECORD_STORAGE); - view_port_free(view_port); - furi_message_queue_free(event_queue); - free(plugin_state); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/mousejacker/mousejacker_ducky.c b/applications/plugins/mousejacker/mousejacker_ducky.c deleted file mode 100644 index 7a57856e1..000000000 --- a/applications/plugins/mousejacker/mousejacker_ducky.c +++ /dev/null @@ -1,383 +0,0 @@ -#include "mousejacker_ducky.h" - -static const char ducky_cmd_comment[] = {"REM"}; -static const char ducky_cmd_delay[] = {"DELAY "}; -static const char ducky_cmd_string[] = {"STRING "}; -static const char ducky_cmd_repeat[] = {"REPEAT "}; - -static uint8_t LOGITECH_HID_TEMPLATE[] = - {0x00, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static uint8_t LOGITECH_HELLO[] = {0x00, 0x4F, 0x00, 0x04, 0xB0, 0x10, 0x00, 0x00, 0x00, 0xED}; -static uint8_t LOGITECH_KEEPALIVE[] = {0x00, 0x40, 0x00, 0x55, 0x6B}; - -uint8_t prev_hid = 0; - -#define RT_THRESHOLD 50 -#define LOGITECH_MIN_CHANNEL 2 -#define LOGITECH_MAX_CHANNEL 83 -#define LOGITECH_KEEPALIVE_SIZE 5 -#define LOGITECH_HID_TEMPLATE_SIZE 10 -#define LOGITECH_HELLO_SIZE 10 -#define TAG "mousejacker_ducky" - -MJDuckyKey mj_ducky_keys[] = {{" ", 44, 0}, {"!", 30, 2}, {"\"", 52, 2}, - {"#", 32, 2}, {"$", 33, 2}, {"%", 34, 2}, - {"&", 36, 2}, {"'", 52, 0}, {"(", 38, 2}, - {")", 39, 2}, {"*", 37, 2}, {"+", 46, 2}, - {",", 54, 0}, {"-", 45, 0}, {".", 55, 0}, - {"/", 56, 0}, {"0", 39, 0}, {"1", 30, 0}, - {"2", 31, 0}, {"3", 32, 0}, {"4", 33, 0}, - {"5", 34, 0}, {"6", 35, 0}, {"7", 36, 0}, - {"8", 37, 0}, {"9", 38, 0}, {":", 51, 2}, - {";", 51, 0}, {"<", 54, 2}, {"=", 46, 0}, - {">", 55, 2}, {"?", 56, 2}, {"@", 31, 2}, - {"A", 4, 2}, {"B", 5, 2}, {"C", 6, 2}, - {"D", 7, 2}, {"E", 8, 2}, {"F", 9, 2}, - {"G", 10, 2}, {"H", 11, 2}, {"I", 12, 2}, - {"J", 13, 2}, {"K", 14, 2}, {"L", 15, 2}, - {"M", 16, 2}, {"N", 17, 2}, {"O", 18, 2}, - {"P", 19, 2}, {"Q", 20, 2}, {"R", 21, 2}, - {"S", 22, 2}, {"T", 23, 2}, {"U", 24, 2}, - {"V", 25, 2}, {"W", 26, 2}, {"X", 27, 2}, - {"Y", 28, 2}, {"Z", 29, 2}, {"[", 47, 0}, - {"\\", 49, 0}, {"]", 48, 0}, {"^", 35, 2}, - {"_", 45, 2}, {"`", 53, 0}, {"a", 4, 0}, - {"b", 5, 0}, {"c", 6, 0}, {"d", 7, 0}, - {"e", 8, 0}, {"f", 9, 0}, {"g", 10, 0}, - {"h", 11, 0}, {"i", 12, 0}, {"j", 13, 0}, - {"k", 14, 0}, {"l", 15, 0}, {"m", 16, 0}, - {"n", 17, 0}, {"o", 18, 0}, {"p", 19, 0}, - {"q", 20, 0}, {"r", 21, 0}, {"s", 22, 0}, - {"t", 23, 0}, {"u", 24, 0}, {"v", 25, 0}, - {"w", 26, 0}, {"x", 27, 0}, {"y", 28, 0}, - {"z", 29, 0}, {"{", 47, 2}, {"|", 49, 2}, - {"}", 48, 2}, {"~", 53, 2}, {"BACKSPACE", 42, 0}, - {"", 0, 0}, {"ALT", 0, 4}, {"SHIFT", 0, 2}, - {"CTRL", 0, 1}, {"GUI", 0, 8}, {"SCROLLLOCK", 71, 0}, - {"ENTER", 40, 0}, {"F12", 69, 0}, {"HOME", 74, 0}, - {"F10", 67, 0}, {"F9", 66, 0}, {"ESCAPE", 41, 0}, - {"PAGEUP", 75, 0}, {"TAB", 43, 0}, {"PRINTSCREEN", 70, 0}, - {"F2", 59, 0}, {"CAPSLOCK", 57, 0}, {"F1", 58, 0}, - {"F4", 61, 0}, {"F6", 63, 0}, {"F8", 65, 0}, - {"DOWNARROW", 81, 0}, {"DELETE", 42, 0}, {"RIGHT", 79, 0}, - {"F3", 60, 0}, {"DOWN", 81, 0}, {"DEL", 76, 0}, - {"END", 77, 0}, {"INSERT", 73, 0}, {"F5", 62, 0}, - {"LEFTARROW", 80, 0}, {"RIGHTARROW", 79, 0}, {"PAGEDOWN", 78, 0}, - {"PAUSE", 72, 0}, {"SPACE", 44, 0}, {"UPARROW", 82, 0}, - {"F11", 68, 0}, {"F7", 64, 0}, {"UP", 82, 0}, - {"LEFT", 80, 0}}; - -/* -static bool mj_ducky_get_number(const char* param, uint32_t* val) { - uint32_t value = 0; - if(sscanf(param, "%lu", &value) == 1) { - *val = value; - return true; - } - return false; -} -*/ - -static uint32_t mj_ducky_get_command_len(const char* line) { - uint32_t len = strlen(line); - for(uint32_t i = 0; i < len; i++) { - if(line[i] == ' ') return i; - } - return 0; -} - -static bool mj_get_ducky_key(char* key, size_t keylen, MJDuckyKey* dk) { - //FURI_LOG_D(TAG, "looking up key %s with length %d", key, keylen); - for(uint i = 0; i < sizeof(mj_ducky_keys) / sizeof(MJDuckyKey); i++) { - if(!strncmp(mj_ducky_keys[i].name, key, keylen)) { - memcpy(dk, &mj_ducky_keys[i], sizeof(MJDuckyKey)); - return true; - } - } - - return false; -} - -static void checksum(uint8_t* payload, uint len) { - // This is also from the KeyKeriki paper - // Thanks Thorsten and Max! - uint8_t cksum = 0xff; - for(uint n = 0; n < len - 2; n++) cksum = (cksum - payload[n]) & 0xff; - cksum = (cksum + 1) & 0xff; - payload[len - 1] = cksum; -} - -static void inject_packet( - FuriHalSpiBusHandle* handle, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - uint8_t* payload, - size_t payload_size, - PluginState* plugin_state) { - uint8_t rt_count = 0; - while(1) { - if(!plugin_state->is_thread_running || plugin_state->close_thread_please) { - return; - } - if(nrf24_txpacket(handle, payload, payload_size, true)) { - break; - } - - rt_count++; - // retransmit threshold exceeded, scan for new channel - if(rt_count > RT_THRESHOLD) { - if(nrf24_find_channel( - handle, - addr, - addr, - addr_size, - rate, - LOGITECH_MIN_CHANNEL, - LOGITECH_MAX_CHANNEL, - true) > LOGITECH_MAX_CHANNEL) { - return; // fail - } - //FURI_LOG_D("mj", "find channel passed, %d", tessst); - - rt_count = 0; - } - } -} - -static void build_hid_packet(uint8_t mod, uint8_t hid, uint8_t* payload) { - memcpy(payload, LOGITECH_HID_TEMPLATE, LOGITECH_HID_TEMPLATE_SIZE); - payload[2] = mod; - payload[3] = hid; - checksum(payload, LOGITECH_HID_TEMPLATE_SIZE); -} - -static void send_hid_packet( - FuriHalSpiBusHandle* handle, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - uint8_t mod, - uint8_t hid, - PluginState* plugin_state) { - uint8_t hid_payload[LOGITECH_HID_TEMPLATE_SIZE] = {0}; - build_hid_packet(0, 0, hid_payload); - if(hid == prev_hid) - inject_packet( - handle, - addr, - addr_size, - rate, - hid_payload, - LOGITECH_HID_TEMPLATE_SIZE, - plugin_state); // empty hid packet - - prev_hid = hid; - build_hid_packet(mod, hid, hid_payload); - inject_packet( - handle, addr, addr_size, rate, hid_payload, LOGITECH_HID_TEMPLATE_SIZE, plugin_state); - furi_delay_ms(12); -} - -// returns false if there was an error processing script line -static bool mj_process_ducky_line( - FuriHalSpiBusHandle* handle, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - char* line, - char* prev_line, - PluginState* plugin_state) { - MJDuckyKey dk; - uint8_t hid_payload[LOGITECH_HID_TEMPLATE_SIZE] = {0}; - char* line_tmp = line; - uint32_t line_len = strlen(line); - if(!plugin_state->is_thread_running || plugin_state->close_thread_please) { - return true; - } - for(uint32_t i = 0; i < line_len; i++) { - if((line_tmp[i] != ' ') && (line_tmp[i] != '\t') && (line_tmp[i] != '\n')) { - line_tmp = &line_tmp[i]; - break; // Skip spaces and tabs - } - if(i == line_len - 1) return true; // Skip empty lines - } - - FURI_LOG_D(TAG, "line: %s", line_tmp); - - // General commands - if(strncmp(line_tmp, ducky_cmd_comment, strlen(ducky_cmd_comment)) == 0) { - // REM - comment line - return true; - } else if(strncmp(line_tmp, ducky_cmd_delay, strlen(ducky_cmd_delay)) == 0) { - // DELAY - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - uint32_t delay_val = 0; - delay_val = atoi(line_tmp); - if(delay_val > 0) { - uint32_t delay_count = delay_val / 10; - build_hid_packet(0, 0, hid_payload); - inject_packet( - handle, - addr, - addr_size, - rate, - hid_payload, - LOGITECH_HID_TEMPLATE_SIZE, - plugin_state); // empty hid packet - for(uint32_t i = 0; i < delay_count; i++) { - if(!plugin_state->is_thread_running || plugin_state->close_thread_please) { - return true; - } - inject_packet( - handle, - addr, - addr_size, - rate, - LOGITECH_KEEPALIVE, - LOGITECH_KEEPALIVE_SIZE, - plugin_state); - furi_delay_ms(10); - } - return true; - } - return false; - } else if(strncmp(line_tmp, ducky_cmd_string, strlen(ducky_cmd_string)) == 0) { - // STRING - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - for(size_t i = 0; i < strlen(line_tmp); i++) { - if(!mj_get_ducky_key(&line_tmp[i], 1, &dk)) return false; - - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - } - - return true; - } else if(strncmp(line_tmp, ducky_cmd_repeat, strlen(ducky_cmd_repeat)) == 0) { - // REPEAT - uint32_t repeat_cnt = 0; - if(prev_line == NULL) return false; - - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - repeat_cnt = atoi(line_tmp); - if(repeat_cnt < 2) return false; - - FURI_LOG_D(TAG, "repeating %s %ld times", prev_line, repeat_cnt); - for(uint32_t i = 0; i < repeat_cnt; i++) - mj_process_ducky_line(handle, addr, addr_size, rate, prev_line, NULL, plugin_state); - - return true; - } else if(strncmp(line_tmp, "ALT", strlen("ALT")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 4, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "GUI", strlen("GUI")) == 0 || - strncmp(line_tmp, "WINDOWS", strlen("WINDOWS")) == 0 || - strncmp(line_tmp, "COMMAND", strlen("COMMAND")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 8, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "CTRL-ALT", strlen("CTRL-ALT")) == 0 || - strncmp(line_tmp, "CONTROL-ALT", strlen("CONTROL-ALT")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 4 | 1, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "CTRL-SHIFT", strlen("CTRL-SHIFT")) == 0 || - strncmp(line_tmp, "CONTROL-SHIFT", strlen("CONTROL-SHIFT")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 4 | 2, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "CTRL", strlen("CTRL")) == 0 || - strncmp(line_tmp, "CONTROL", strlen("CONTROL")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 1, dk.hid, plugin_state); - return true; - } else if(strncmp(line_tmp, "SHIFT", strlen("SHIFT")) == 0) { - line_tmp = &line_tmp[mj_ducky_get_command_len(line_tmp) + 1]; - if(!mj_get_ducky_key(line_tmp, strlen(line_tmp), &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod | 2, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "ESC", strlen("ESC")) == 0 || - strncmp(line_tmp, "APP", strlen("APP")) == 0 || - strncmp(line_tmp, "ESCAPE", strlen("ESCAPE")) == 0) { - if(!mj_get_ducky_key("ESCAPE", 6, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if(strncmp(line_tmp, "ENTER", strlen("ENTER")) == 0) { - if(!mj_get_ducky_key("ENTER", 5, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "UP", strlen("UP")) == 0 || - strncmp(line_tmp, "UPARROW", strlen("UPARROW")) == 0) { - if(!mj_get_ducky_key("UP", 2, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "DOWN", strlen("DOWN")) == 0 || - strncmp(line_tmp, "DOWNARROW", strlen("DOWNARROW")) == 0) { - if(!mj_get_ducky_key("DOWN", 4, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "LEFT", strlen("LEFT")) == 0 || - strncmp(line_tmp, "LEFTARROW", strlen("LEFTARROW")) == 0) { - if(!mj_get_ducky_key("LEFT", 4, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if( - strncmp(line_tmp, "RIGHT", strlen("RIGHT")) == 0 || - strncmp(line_tmp, "RIGHTARROW", strlen("RIGHTARROW")) == 0) { - if(!mj_get_ducky_key("RIGHT", 5, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } else if(strncmp(line_tmp, "SPACE", strlen("SPACE")) == 0) { - if(!mj_get_ducky_key("SPACE", 5, &dk)) return false; - send_hid_packet(handle, addr, addr_size, rate, dk.mod, dk.hid, plugin_state); - return true; - } - - return false; -} - -void mj_process_ducky_script( - FuriHalSpiBusHandle* handle, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - char* script, - PluginState* plugin_state) { - uint8_t hid_payload[LOGITECH_HID_TEMPLATE_SIZE] = {0}; - char* prev_line = NULL; - - inject_packet( - handle, addr, addr_size, rate, LOGITECH_HELLO, LOGITECH_HELLO_SIZE, plugin_state); - char* line = strtok(script, "\n"); - while(line != NULL) { - if(strcmp(&line[strlen(line) - 1], "\r") == 0) line[strlen(line) - 1] = (char)0; - - if(!mj_process_ducky_line(handle, addr, addr_size, rate, line, prev_line, plugin_state)) - FURI_LOG_D(TAG, "unable to process ducky script line: %s", line); - - prev_line = line; - line = strtok(NULL, "\n"); - } - build_hid_packet(0, 0, hid_payload); - inject_packet( - handle, - addr, - addr_size, - rate, - hid_payload, - LOGITECH_HID_TEMPLATE_SIZE, - plugin_state); // empty hid packet at end -} \ No newline at end of file diff --git a/applications/plugins/mousejacker/mousejacker_ducky.h b/applications/plugins/mousejacker/mousejacker_ducky.h deleted file mode 100644 index b4922ed38..000000000 --- a/applications/plugins/mousejacker/mousejacker_ducky.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char* name; - uint8_t hid; - uint8_t mod; -} MJDuckyKey; - -typedef struct { - bool ducky_err; - bool addr_err; - bool is_thread_running; - bool is_ducky_running; - bool close_thread_please; - Storage* storage; - FuriThread* mjthread; - Stream* file_stream; -} PluginState; - -void mj_process_ducky_script( - FuriHalSpiBusHandle* handle, - uint8_t* addr, - uint8_t addr_size, - uint8_t rate, - char* script, - PluginState* plugin_state); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/music_beeper/application.fam b/applications/plugins/music_beeper/application.fam deleted file mode 100644 index 3bde6aa52..000000000 --- a/applications/plugins/music_beeper/application.fam +++ /dev/null @@ -1,17 +0,0 @@ -App( - appid="Music_Beeper", - name="Music Beeper", - apptype=FlipperAppType.EXTERNAL, - entry_point="music_beeper_app", - cdefines=["APP_MUSIC_BEEPER"], - requires=[ - "gui", - "dialogs", - ], - provides=["music_beeper_start"], - stack_size=2 * 1024, - order=45, - fap_icon="icons/music_10px.png", - fap_category="Music", - fap_icon_assets="icons", -) diff --git a/applications/plugins/music_beeper/icons/music_10px.png b/applications/plugins/music_beeper/icons/music_10px.png deleted file mode 100644 index d41eb0db8..000000000 Binary files a/applications/plugins/music_beeper/icons/music_10px.png and /dev/null differ diff --git a/applications/plugins/music_beeper/music_beeper.c b/applications/plugins/music_beeper/music_beeper.c deleted file mode 100644 index b610b3aae..000000000 --- a/applications/plugins/music_beeper/music_beeper.c +++ /dev/null @@ -1,367 +0,0 @@ -#include "music_beeper_worker.h" - -#include -#include - -#include -#include -#include -#include - -#define TAG "MusicBeeper" - -#define MUSIC_BEEPER_APP_PATH_FOLDER ANY_PATH("music_beeper") -#define MUSIC_BEEPER_APP_EXTENSION "*" - -#define MUSIC_BEEPER_SEMITONE_HISTORY_SIZE 4 - -typedef struct { - uint8_t semitone_history[MUSIC_BEEPER_SEMITONE_HISTORY_SIZE]; - uint8_t duration_history[MUSIC_BEEPER_SEMITONE_HISTORY_SIZE]; - - uint8_t volume; - uint8_t semitone; - uint8_t dots; - uint8_t duration; - float position; -} MusicBeeperModel; - -typedef struct { - MusicBeeperModel* model; - FuriMutex** model_mutex; - - FuriMessageQueue* input_queue; - - ViewPort* view_port; - Gui* gui; - - MusicBeeperWorker* worker; -} MusicBeeper; - -static const float MUSIC_BEEPER_VOLUMES[] = {0, .25, .5, .75, 1}; - -static const char* semitone_to_note(int8_t semitone) { - switch(semitone) { - case 0: - return "C"; - case 1: - return "C#"; - case 2: - return "D"; - case 3: - return "D#"; - case 4: - return "E"; - case 5: - return "F"; - case 6: - return "F#"; - case 7: - return "G"; - case 8: - return "G#"; - case 9: - return "A"; - case 10: - return "A#"; - case 11: - return "B"; - default: - return "--"; - } -} - -static bool is_white_note(uint8_t semitone, uint8_t id) { - switch(semitone) { - case 0: - if(id == 0) return true; - break; - case 2: - if(id == 1) return true; - break; - case 4: - if(id == 2) return true; - break; - case 5: - if(id == 3) return true; - break; - case 7: - if(id == 4) return true; - break; - case 9: - if(id == 5) return true; - break; - case 11: - if(id == 6) return true; - break; - default: - break; - } - - return false; -} - -static bool is_black_note(uint8_t semitone, uint8_t id) { - switch(semitone) { - case 1: - if(id == 0) return true; - break; - case 3: - if(id == 1) return true; - break; - case 6: - if(id == 3) return true; - break; - case 8: - if(id == 4) return true; - break; - case 10: - if(id == 5) return true; - break; - default: - break; - } - - return false; -} - -static void render_callback(Canvas* canvas, void* ctx) { - MusicBeeper* music_beeper = ctx; - furi_check(furi_mutex_acquire(music_beeper->model_mutex, FuriWaitForever) == FuriStatusOk); - - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 12, "MusicBeeper"); - - uint8_t x_pos = 0; - uint8_t y_pos = 24; - const uint8_t white_w = 10; - const uint8_t white_h = 40; - - const int8_t black_x = 6; - const int8_t black_y = -5; - const uint8_t black_w = 8; - const uint8_t black_h = 32; - - // white keys - for(size_t i = 0; i < 7; i++) { - if(is_white_note(music_beeper->model->semitone, i)) { - canvas_draw_box(canvas, x_pos + white_w * i, y_pos, white_w + 1, white_h); - } else { - canvas_draw_frame(canvas, x_pos + white_w * i, y_pos, white_w + 1, white_h); - } - } - - // black keys - for(size_t i = 0; i < 7; i++) { - if(i != 2 && i != 6) { - canvas_set_color(canvas, ColorWhite); - canvas_draw_box( - canvas, x_pos + white_w * i + black_x, y_pos + black_y, black_w + 1, black_h); - canvas_set_color(canvas, ColorBlack); - if(is_black_note(music_beeper->model->semitone, i)) { - canvas_draw_box( - canvas, x_pos + white_w * i + black_x, y_pos + black_y, black_w + 1, black_h); - } else { - canvas_draw_frame( - canvas, x_pos + white_w * i + black_x, y_pos + black_y, black_w + 1, black_h); - } - } - } - - // volume view_port - x_pos = 124; - y_pos = 0; - const uint8_t volume_h = - (64 / (COUNT_OF(MUSIC_BEEPER_VOLUMES) - 1)) * music_beeper->model->volume; - canvas_draw_frame(canvas, x_pos, y_pos, 4, 64); - canvas_draw_box(canvas, x_pos, y_pos + (64 - volume_h), 4, volume_h); - - // note stack view_port - x_pos = 73; - y_pos = 0; - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_frame(canvas, x_pos, y_pos, 49, 64); - canvas_draw_line(canvas, x_pos + 28, 0, x_pos + 28, 64); - - char duration_text[16]; - for(uint8_t i = 0; i < MUSIC_BEEPER_SEMITONE_HISTORY_SIZE; i++) { - if(music_beeper->model->duration_history[i] == 0xFF) { - snprintf(duration_text, 15, "--"); - } else { - snprintf(duration_text, 15, "%d", music_beeper->model->duration_history[i]); - } - - if(i == 0) { - canvas_draw_box(canvas, x_pos, y_pos + 48, 49, 16); - canvas_set_color(canvas, ColorWhite); - } else { - canvas_set_color(canvas, ColorBlack); - } - canvas_draw_str( - canvas, - x_pos + 4, - 64 - 16 * i - 3, - semitone_to_note(music_beeper->model->semitone_history[i])); - canvas_draw_str(canvas, x_pos + 31, 64 - 16 * i - 3, duration_text); - canvas_draw_line(canvas, x_pos, 64 - 16 * i, x_pos + 48, 64 - 16 * i); - } - - furi_mutex_release(music_beeper->model_mutex); -} - -static void input_callback(InputEvent* input_event, void* ctx) { - MusicBeeper* music_beeper = ctx; - if(input_event->type == InputTypeShort) { - furi_message_queue_put(music_beeper->input_queue, input_event, 0); - } -} - -static void music_beeper_worker_callback( - uint8_t semitone, - uint8_t dots, - uint8_t duration, - float position, - void* context) { - MusicBeeper* music_beeper = context; - furi_check(furi_mutex_acquire(music_beeper->model_mutex, FuriWaitForever) == FuriStatusOk); - - for(size_t i = 0; i < MUSIC_BEEPER_SEMITONE_HISTORY_SIZE - 1; i++) { - size_t r = MUSIC_BEEPER_SEMITONE_HISTORY_SIZE - 1 - i; - music_beeper->model->duration_history[r] = music_beeper->model->duration_history[r - 1]; - music_beeper->model->semitone_history[r] = music_beeper->model->semitone_history[r - 1]; - } - - semitone = (semitone == 0xFF) ? 0xFF : semitone % 12; - - music_beeper->model->semitone = semitone; - music_beeper->model->dots = dots; - music_beeper->model->duration = duration; - music_beeper->model->position = position; - - music_beeper->model->semitone_history[0] = semitone; - music_beeper->model->duration_history[0] = duration; - - furi_mutex_release(music_beeper->model_mutex); - view_port_update(music_beeper->view_port); -} - -void music_beeper_clear(MusicBeeper* instance) { - memset(instance->model->duration_history, 0xff, MUSIC_BEEPER_SEMITONE_HISTORY_SIZE); - memset(instance->model->semitone_history, 0xff, MUSIC_BEEPER_SEMITONE_HISTORY_SIZE); - music_beeper_worker_clear(instance->worker); -} - -MusicBeeper* music_beeper_alloc() { - MusicBeeper* instance = malloc(sizeof(MusicBeeper)); - - instance->model = malloc(sizeof(MusicBeeperModel)); - instance->model->volume = 4; - - instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - instance->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - instance->worker = music_beeper_worker_alloc(); - music_beeper_worker_set_volume( - instance->worker, MUSIC_BEEPER_VOLUMES[instance->model->volume]); - music_beeper_worker_set_callback(instance->worker, music_beeper_worker_callback, instance); - - music_beeper_clear(instance); - - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, render_callback, instance); - view_port_input_callback_set(instance->view_port, input_callback, instance); - - // Open GUI and register view_port - instance->gui = furi_record_open(RECORD_GUI); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - return instance; -} - -void music_beeper_free(MusicBeeper* instance) { - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close(RECORD_GUI); - view_port_free(instance->view_port); - - music_beeper_worker_free(instance->worker); - - furi_message_queue_free(instance->input_queue); - - furi_mutex_free(instance->model_mutex); - - free(instance->model); - free(instance); -} - -int32_t music_beeper_app(void* p) { - MusicBeeper* music_beeper = music_beeper_alloc(); - - FuriString* file_path; - file_path = furi_string_alloc(); - - do { - if(p && strlen(p)) { - furi_string_set(file_path, (const char*)p); - } else { - furi_string_set(file_path, MUSIC_BEEPER_APP_PATH_FOLDER); - - DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options( - &browser_options, MUSIC_BEEPER_APP_EXTENSION, &I_music_10px); - browser_options.hide_ext = false; - - DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); - bool res = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options); - - furi_record_close(RECORD_DIALOGS); - if(!res) { - FURI_LOG_E(TAG, "No file selected"); - break; - } - } - - if(!music_beeper_worker_load(music_beeper->worker, furi_string_get_cstr(file_path))) { - FURI_LOG_E(TAG, "Unable to load file"); - break; - } - - music_beeper_worker_start(music_beeper->worker); - - InputEvent input; - while(furi_message_queue_get(music_beeper->input_queue, &input, FuriWaitForever) == - FuriStatusOk) { - furi_check( - furi_mutex_acquire(music_beeper->model_mutex, FuriWaitForever) == FuriStatusOk); - - if(input.key == InputKeyBack) { - furi_mutex_release(music_beeper->model_mutex); - break; - } else if(input.key == InputKeyUp) { - if(music_beeper->model->volume < COUNT_OF(MUSIC_BEEPER_VOLUMES) - 1) - music_beeper->model->volume++; - music_beeper_worker_set_volume( - music_beeper->worker, MUSIC_BEEPER_VOLUMES[music_beeper->model->volume]); - } else if(input.key == InputKeyDown) { - if(music_beeper->model->volume > 0) music_beeper->model->volume--; - music_beeper_worker_set_volume( - music_beeper->worker, MUSIC_BEEPER_VOLUMES[music_beeper->model->volume]); - } - - furi_mutex_release(music_beeper->model_mutex); - view_port_update(music_beeper->view_port); - } - - music_beeper_worker_stop(music_beeper->worker); - if(p && strlen(p)) break; // Exit instead of going to browser if launched with arg - music_beeper_clear(music_beeper); - } while(1); - - furi_string_free(file_path); - music_beeper_free(music_beeper); - - return 0; -} diff --git a/applications/plugins/music_beeper/music_beeper_cli.c b/applications/plugins/music_beeper/music_beeper_cli.c deleted file mode 100644 index 26299fa64..000000000 --- a/applications/plugins/music_beeper/music_beeper_cli.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include "music_beeper_worker.h" - -static void music_beeper_cli(Cli* cli, FuriString* args, void* context) { - UNUSED(context); - MusicBeeperWorker* music_beeper_worker = music_beeper_worker_alloc(); - Storage* storage = furi_record_open(RECORD_STORAGE); - - do { - if(storage_common_stat(storage, furi_string_get_cstr(args), NULL) == FSE_OK) { - if(!music_beeper_worker_load(music_beeper_worker, furi_string_get_cstr(args))) { - printf("Failed to open file %s\r\n", furi_string_get_cstr(args)); - break; - } - } else { - if(!music_beeper_worker_load_rtttl_from_string( - music_beeper_worker, furi_string_get_cstr(args))) { - printf("Argument is not a file or RTTTL\r\n"); - break; - } - } - - printf("Press CTRL+C to stop\r\n"); - music_beeper_worker_set_volume(music_beeper_worker, 1.0f); - music_beeper_worker_start(music_beeper_worker); - while(!cli_cmd_interrupt_received(cli)) { - furi_delay_ms(50); - } - music_beeper_worker_stop(music_beeper_worker); - } while(0); - - furi_record_close(RECORD_STORAGE); - music_beeper_worker_free(music_beeper_worker); -} - -void music_beeper_on_system_start() { -#ifdef SRV_CLI - Cli* cli = furi_record_open(RECORD_CLI); - - cli_add_command(cli, "music_beeper", CliCommandFlagDefault, music_beeper_cli, NULL); - - furi_record_close(RECORD_CLI); -#else - UNUSED(music_beeper_cli); -#endif -} diff --git a/applications/plugins/music_beeper/music_beeper_worker.c b/applications/plugins/music_beeper/music_beeper_worker.c deleted file mode 100644 index 711ac1b2e..000000000 --- a/applications/plugins/music_beeper/music_beeper_worker.c +++ /dev/null @@ -1,506 +0,0 @@ -#include "music_beeper_worker.h" - -#include -#include - -#include -#include - -#include - -#define TAG "MusicBeeperWorker" - -#define MUSIC_BEEPER_FILETYPE "Flipper Music Format" -#define MUSIC_BEEPER_VERSION 0 - -#define SEMITONE_PAUSE 0xFF - -#define NOTE_C4 261.63f -#define NOTE_C4_SEMITONE (4.0f * 12.0f) -#define TWO_POW_TWELTH_ROOT 1.059463094359f - -typedef struct { - uint8_t semitone; - uint8_t duration; - uint8_t dots; -} NoteBlock; - -ARRAY_DEF(NoteBlockArray, NoteBlock, M_POD_OPLIST); - -struct MusicBeeperWorker { - FuriThread* thread; - bool should_work; - - MusicBeeperWorkerCallback callback; - void* callback_context; - - float volume; - uint32_t bpm; - uint32_t duration; - uint32_t octave; - NoteBlockArray_t notes; -}; - -static int32_t music_beeper_worker_thread_callback(void* context) { - furi_assert(context); - MusicBeeperWorker* instance = context; - - NoteBlockArray_it_t it; - NoteBlockArray_it(it, instance->notes); - - while(instance->should_work) { - if(NoteBlockArray_end_p(it)) { - NoteBlockArray_it(it, instance->notes); - furi_delay_ms(10); - } else { - NoteBlock* note_block = NoteBlockArray_ref(it); - - float note_from_a4 = (float)note_block->semitone - NOTE_C4_SEMITONE; - float frequency = NOTE_C4 * powf(TWO_POW_TWELTH_ROOT, note_from_a4); - float duration = - 60.0 * furi_kernel_get_tick_frequency() * 4 / instance->bpm / note_block->duration; - uint32_t dots = note_block->dots; - while(dots > 0) { - duration += duration / 2; - dots--; - } - uint32_t next_tick = furi_get_tick() + duration; - float volume = instance->volume; - - if(instance->callback) { - instance->callback( - note_block->semitone, - note_block->dots, - note_block->duration, - 0.0, - instance->callback_context); - } - - furi_hal_speaker_stop(); - furi_hal_speaker_start(frequency, volume); - while(instance->should_work && furi_get_tick() < next_tick) { - volume *= 1; - furi_hal_speaker_set_volume(volume); - furi_delay_ms(2); - } - NoteBlockArray_next(it); - } - } - - furi_hal_speaker_stop(); - - return 0; -} - -MusicBeeperWorker* music_beeper_worker_alloc() { - MusicBeeperWorker* instance = malloc(sizeof(MusicBeeperWorker)); - - NoteBlockArray_init(instance->notes); - - instance->thread = furi_thread_alloc(); - furi_thread_set_name(instance->thread, "MusicBeeperWorker"); - furi_thread_set_stack_size(instance->thread, 1024); - furi_thread_set_context(instance->thread, instance); - furi_thread_set_callback(instance->thread, music_beeper_worker_thread_callback); - - instance->volume = 1.0f; - - return instance; -} - -void music_beeper_worker_clear(MusicBeeperWorker* instance) { - NoteBlockArray_reset(instance->notes); -} - -void music_beeper_worker_free(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_thread_free(instance->thread); - NoteBlockArray_clear(instance->notes); - free(instance); -} - -static bool is_digit(const char c) { - return isdigit(c) != 0; -} - -static bool is_letter(const char c) { - return islower(c) != 0 || isupper(c) != 0; -} - -static bool is_space(const char c) { - return c == ' ' || c == '\t'; -} - -static size_t extract_number(const char* string, uint32_t* number) { - size_t ret = 0; - *number = 0; - while(is_digit(*string)) { - *number *= 10; - *number += (*string - '0'); - string++; - ret++; - } - return ret; -} - -static size_t extract_dots(const char* string, uint32_t* number) { - size_t ret = 0; - *number = 0; - while(*string == '.') { - *number += 1; - string++; - ret++; - } - return ret; -} - -static size_t extract_char(const char* string, char* symbol) { - if(is_letter(*string)) { - *symbol = *string; - return 1; - } else { - return 0; - } -} - -static size_t extract_sharp(const char* string, char* symbol) { - if(*string == '#' || *string == '_') { - *symbol = '#'; - return 1; - } else { - return 0; - } -} - -static size_t skip_till(const char* string, const char symbol) { - size_t ret = 0; - while(*string != '\0' && *string != symbol) { - string++; - ret++; - } - if(*string != symbol) { - ret = 0; - } - return ret; -} - -static bool music_beeper_worker_add_note( - MusicBeeperWorker* instance, - uint8_t semitone, - uint8_t duration, - uint8_t dots) { - NoteBlock note_block; - - note_block.semitone = semitone; - note_block.duration = duration; - note_block.dots = dots; - - NoteBlockArray_push_back(instance->notes, note_block); - - return true; -} - -static int8_t note_to_semitone(const char note) { - switch(note) { - case 'C': - return 0; - // C# - case 'D': - return 2; - // D# - case 'E': - return 4; - case 'F': - return 5; - // F# - case 'G': - return 7; - // G# - case 'A': - return 9; - // A# - case 'B': - return 11; - default: - return 0; - } -} - -static bool music_beeper_worker_parse_notes(MusicBeeperWorker* instance, const char* string) { - const char* cursor = string; - bool result = true; - - while(*cursor != '\0') { - if(!is_space(*cursor)) { - uint32_t duration = 0; - char note_char = '\0'; - char sharp_char = '\0'; - uint32_t octave = 0; - uint32_t dots = 0; - - // Parsing - cursor += extract_number(cursor, &duration); - cursor += extract_char(cursor, ¬e_char); - cursor += extract_sharp(cursor, &sharp_char); - cursor += extract_number(cursor, &octave); - cursor += extract_dots(cursor, &dots); - - // Post processing - note_char = toupper(note_char); - if(!duration) { - duration = instance->duration; - } - if(!octave) { - octave = instance->octave; - } - - // Validation - bool is_valid = true; - is_valid &= (duration >= 1 && duration <= 128); - is_valid &= ((note_char >= 'A' && note_char <= 'G') || note_char == 'P'); - is_valid &= (sharp_char == '#' || sharp_char == '\0'); - is_valid &= (octave <= 16); - is_valid &= (dots <= 16); - if(!is_valid) { - FURI_LOG_E( - TAG, - "Invalid note: %lu%c%c%lu.%lu", - duration, - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots); - result = false; - break; - } - - // Note to semitones - uint8_t semitone = 0; - if(note_char == 'P') { - semitone = SEMITONE_PAUSE; - } else { - semitone += octave * 12; - semitone += note_to_semitone(note_char); - semitone += sharp_char == '#' ? 1 : 0; - } - - if(music_beeper_worker_add_note(instance, semitone, duration, dots)) { - FURI_LOG_D( - TAG, - "Added note: %c%c%lu.%lu = %u %lu", - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots, - semitone, - duration); - } else { - FURI_LOG_E( - TAG, - "Invalid note: %c%c%lu.%lu = %u %lu", - note_char == '\0' ? '_' : note_char, - sharp_char == '\0' ? '_' : sharp_char, - octave, - dots, - semitone, - duration); - } - cursor += skip_till(cursor, ','); - } - - if(*cursor != '\0') cursor++; - } - - return result; -} - -bool music_beeper_worker_load(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool ret = false; - if(strcasestr(file_path, ".fmf")) { - ret = music_beeper_worker_load_fmf_from_file(instance, file_path); - } else { - ret = music_beeper_worker_load_rtttl_from_file(instance, file_path); - } - return ret; -} - -bool music_beeper_worker_load_fmf_from_file(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool result = false; - FuriString* temp_str; - temp_str = furi_string_alloc(); - - Storage* storage = furi_record_open(RECORD_STORAGE); - FlipperFormat* file = flipper_format_file_alloc(storage); - - do { - if(!flipper_format_file_open_existing(file, file_path)) break; - - uint32_t version = 0; - if(!flipper_format_read_header(file, temp_str, &version)) break; - if(furi_string_cmp_str(temp_str, MUSIC_BEEPER_FILETYPE) || - (version != MUSIC_BEEPER_VERSION)) { - FURI_LOG_E(TAG, "Incorrect file format or version"); - break; - } - - if(!flipper_format_read_uint32(file, "BPM", &instance->bpm, 1)) { - FURI_LOG_E(TAG, "BPM is missing"); - break; - } - if(!flipper_format_read_uint32(file, "Duration", &instance->duration, 1)) { - FURI_LOG_E(TAG, "Duration is missing"); - break; - } - if(!flipper_format_read_uint32(file, "Octave", &instance->octave, 1)) { - FURI_LOG_E(TAG, "Octave is missing"); - break; - } - - if(!flipper_format_read_string(file, "Notes", temp_str)) { - FURI_LOG_E(TAG, "Notes is missing"); - break; - } - - if(!music_beeper_worker_parse_notes(instance, furi_string_get_cstr(temp_str))) { - break; - } - - result = true; - } while(false); - - furi_record_close(RECORD_STORAGE); - flipper_format_free(file); - furi_string_free(temp_str); - - return result; -} - -bool music_beeper_worker_load_rtttl_from_file(MusicBeeperWorker* instance, const char* file_path) { - furi_assert(instance); - furi_assert(file_path); - - bool result = false; - FuriString* content; - content = furi_string_alloc(); - Storage* storage = furi_record_open(RECORD_STORAGE); - File* file = storage_file_alloc(storage); - - do { - if(!storage_file_open(file, file_path, FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_E(TAG, "Unable to open file"); - break; - }; - - uint16_t ret = 0; - do { - uint8_t buffer[65] = {0}; - ret = storage_file_read(file, buffer, sizeof(buffer) - 1); - for(size_t i = 0; i < ret; i++) { - furi_string_push_back(content, buffer[i]); - } - } while(ret > 0); - - furi_string_trim(content); - if(!furi_string_size(content)) { - FURI_LOG_E(TAG, "Empty file"); - break; - } - - if(!music_beeper_worker_load_rtttl_from_string(instance, furi_string_get_cstr(content))) { - FURI_LOG_E(TAG, "Invalid file content"); - break; - } - - result = true; - } while(0); - - storage_file_free(file); - furi_record_close(RECORD_STORAGE); - furi_string_free(content); - - return result; -} - -bool music_beeper_worker_load_rtttl_from_string(MusicBeeperWorker* instance, const char* string) { - furi_assert(instance); - - const char* cursor = string; - - // Skip name - cursor += skip_till(cursor, ':'); - if(*cursor != ':') { - return false; - } - - // Duration - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->duration); - - // Octave - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->octave); - - // BPM - cursor += skip_till(cursor, '='); - if(*cursor != '=') { - return false; - } - cursor++; - cursor += extract_number(cursor, &instance->bpm); - - // Notes - cursor += skip_till(cursor, ':'); - if(*cursor != ':') { - return false; - } - cursor++; - if(!music_beeper_worker_parse_notes(instance, cursor)) { - return false; - } - - return true; -} - -void music_beeper_worker_set_callback( - MusicBeeperWorker* instance, - MusicBeeperWorkerCallback callback, - void* context) { - furi_assert(instance); - instance->callback = callback; - instance->callback_context = context; -} - -void music_beeper_worker_set_volume(MusicBeeperWorker* instance, float volume) { - furi_assert(instance); - instance->volume = volume; -} - -void music_beeper_worker_start(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_assert(instance->should_work == false); - - instance->should_work = true; - furi_thread_start(instance->thread); -} - -void music_beeper_worker_stop(MusicBeeperWorker* instance) { - furi_assert(instance); - furi_assert(instance->should_work == true); - - instance->should_work = false; - furi_thread_join(instance->thread); -} diff --git a/applications/plugins/music_beeper/music_beeper_worker.h b/applications/plugins/music_beeper/music_beeper_worker.h deleted file mode 100644 index bc30abf81..000000000 --- a/applications/plugins/music_beeper/music_beeper_worker.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*MusicBeeperWorkerCallback)( - uint8_t semitone, - uint8_t dots, - uint8_t duration, - float position, - void* context); - -typedef struct MusicBeeperWorker MusicBeeperWorker; - -MusicBeeperWorker* music_beeper_worker_alloc(); - -void music_beeper_worker_clear(MusicBeeperWorker* instance); - -void music_beeper_worker_free(MusicBeeperWorker* instance); - -bool music_beeper_worker_load(MusicBeeperWorker* instance, const char* file_path); - -bool music_beeper_worker_load_fmf_from_file(MusicBeeperWorker* instance, const char* file_path); - -bool music_beeper_worker_load_rtttl_from_file(MusicBeeperWorker* instance, const char* file_path); - -bool music_beeper_worker_load_rtttl_from_string(MusicBeeperWorker* instance, const char* string); - -void music_beeper_worker_set_callback( - MusicBeeperWorker* instance, - MusicBeeperWorkerCallback callback, - void* context); - -void music_beeper_worker_set_volume(MusicBeeperWorker* instance, float volume); - -void music_beeper_worker_start(MusicBeeperWorker* instance); - -void music_beeper_worker_stop(MusicBeeperWorker* instance); - -#ifdef __cplusplus -} -#endif diff --git a/applications/plugins/musictracker/.github/workflows/build_dev.yml b/applications/plugins/musictracker/.github/workflows/build_dev.yml deleted file mode 100644 index 4d3da2331..000000000 --- a/applications/plugins/musictracker/.github/workflows/build_dev.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Build dev - -on: - push: - branches: - - master - -jobs: - build_dev: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Build - uses: oleksiikutuzov/flipperzero-ufbt-action@v1 - with: - channel: dev \ No newline at end of file diff --git a/applications/plugins/musictracker/README.md b/applications/plugins/musictracker/README.md deleted file mode 100644 index 584c2ff86..000000000 --- a/applications/plugins/musictracker/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Flipper Zero music tracker --=-=- MVP Stage: minimum viable player -=-=- - -[>Get latest build<](https://nightly.link/DrZlo13/flipper-zero-music-tracker/workflows/build_dev/master/zero_tracker.fap.zip) diff --git a/applications/plugins/musictracker/application.fam b/applications/plugins/musictracker/application.fam deleted file mode 100644 index 51a0e839d..000000000 --- a/applications/plugins/musictracker/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="Zero_Tracker", - name="Zero Tracker", - apptype=FlipperAppType.EXTERNAL, - entry_point="zero_tracker_app", - requires=[ - "gui", - ], - stack_size=4 * 1024, - order=20, - fap_icon="zero_tracker.png", - fap_category="Music", - fap_icon_assets="icons", -) diff --git a/applications/plugins/musictracker/icons/.gitignore b/applications/plugins/musictracker/icons/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/applications/plugins/musictracker/tracker_engine/speaker_hal.c b/applications/plugins/musictracker/tracker_engine/speaker_hal.c deleted file mode 100644 index 208fee04c..000000000 --- a/applications/plugins/musictracker/tracker_engine/speaker_hal.c +++ /dev/null @@ -1,102 +0,0 @@ -#include "speaker_hal.h" - -#define FURI_HAL_SPEAKER_TIMER TIM16 -#define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1 -#define FURI_HAL_SPEAKER_PRESCALER 500 - -void tracker_speaker_play(float frequency, float pwm) { - uint32_t autoreload = (SystemCoreClock / FURI_HAL_SPEAKER_PRESCALER / frequency) - 1; - if(autoreload < 2) { - autoreload = 2; - } else if(autoreload > UINT16_MAX) { - autoreload = UINT16_MAX; - } - - if(pwm < 0) pwm = 0; - if(pwm > 1) pwm = 1; - - uint32_t compare_value = pwm * autoreload; - - if(compare_value == 0) { - compare_value = 1; - } - - if(LL_TIM_OC_GetCompareCH1(FURI_HAL_SPEAKER_TIMER) != compare_value) { - LL_TIM_OC_SetCompareCH1(FURI_HAL_SPEAKER_TIMER, compare_value); - } - - if(LL_TIM_GetAutoReload(FURI_HAL_SPEAKER_TIMER) != autoreload) { - LL_TIM_SetAutoReload(FURI_HAL_SPEAKER_TIMER, autoreload); - if(LL_TIM_GetCounter(FURI_HAL_SPEAKER_TIMER) > autoreload) { - LL_TIM_SetCounter(FURI_HAL_SPEAKER_TIMER, 0); - } - } - - LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER); -} - -void tracker_speaker_stop() { - LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER); -} - -void tracker_speaker_init() { - furi_hal_speaker_start(200.0f, 0.01f); - tracker_speaker_stop(); -} - -void tracker_speaker_deinit() { - furi_hal_speaker_stop(); -} - -static FuriHalInterruptISR tracker_isr; -static void* tracker_isr_context; -static void tracker_interrupt_cb(void* context) { - UNUSED(context); - - if(LL_TIM_IsActiveFlag_UPDATE(TIM2)) { - LL_TIM_ClearFlag_UPDATE(TIM2); - - if(tracker_isr) { - tracker_isr(tracker_isr_context); - } - } -} - -void tracker_interrupt_init(float freq, FuriHalInterruptISR isr, void* context) { - tracker_isr = isr; - tracker_isr_context = context; - - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, tracker_interrupt_cb, NULL); - - LL_TIM_InitTypeDef TIM_InitStruct = {0}; - // Prescaler to get 1kHz clock - TIM_InitStruct.Prescaler = SystemCoreClock / 1000000 - 1; - TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; - // Auto reload to get freq Hz interrupt - TIM_InitStruct.Autoreload = (1000000 / freq) - 1; - TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; - LL_TIM_Init(TIM2, &TIM_InitStruct); - LL_TIM_EnableIT_UPDATE(TIM2); - LL_TIM_EnableAllOutputs(TIM2); - LL_TIM_EnableCounter(TIM2); -} - -void tracker_interrupt_deinit() { - FURI_CRITICAL_ENTER(); - LL_TIM_DeInit(TIM2); - FURI_CRITICAL_EXIT(); - - furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL); -} - -void tracker_debug_init() { - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); -} - -void tracker_debug_set(bool value) { - furi_hal_gpio_write(&gpio_ext_pc3, value); -} - -void tracker_debug_deinit() { - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} \ No newline at end of file diff --git a/applications/plugins/musictracker/tracker_engine/speaker_hal.h b/applications/plugins/musictracker/tracker_engine/speaker_hal.h deleted file mode 100644 index 7867fe93f..000000000 --- a/applications/plugins/musictracker/tracker_engine/speaker_hal.h +++ /dev/null @@ -1,19 +0,0 @@ -#include - -void tracker_speaker_init(); - -void tracker_speaker_deinit(); - -void tracker_speaker_play(float frequency, float pwm); - -void tracker_speaker_stop(); - -void tracker_interrupt_init(float freq, FuriHalInterruptISR isr, void* context); - -void tracker_interrupt_deinit(); - -void tracker_debug_init(); - -void tracker_debug_set(bool value); - -void tracker_debug_deinit(); \ No newline at end of file diff --git a/applications/plugins/musictracker/tracker_engine/tracker.c b/applications/plugins/musictracker/tracker_engine/tracker.c deleted file mode 100644 index e5efcea17..000000000 --- a/applications/plugins/musictracker/tracker_engine/tracker.c +++ /dev/null @@ -1,441 +0,0 @@ -#include "tracker.h" -#include -#include "speaker_hal.h" - -// SongState song_state = { -// .tick = 0, -// .tick_limit = 2, -// .row = 0, -// }; - -typedef struct { - uint8_t speed; - uint8_t depth; - int8_t direction; - int8_t value; -} IntegerOscillator; - -typedef struct { - float frequency; - float frequency_target; - float pwm; - bool play; - IntegerOscillator vibrato; -} ChannelState; - -typedef struct { - ChannelState* channels; - uint8_t tick; - uint8_t tick_limit; - - uint8_t pattern_index; - uint8_t row_index; - uint8_t order_list_index; -} SongState; - -typedef struct { - uint8_t note; - uint8_t effect; - uint8_t data; -} UnpackedRow; - -struct Tracker { - const Song* song; - bool playing; - TrackerMessageCallback callback; - void* context; - SongState song_state; -}; - -static void channels_state_init(ChannelState* channel) { - channel->frequency = 0; - channel->frequency_target = FREQUENCY_UNSET; - channel->pwm = PWM_DEFAULT; - channel->play = false; - channel->vibrato.speed = 0; - channel->vibrato.depth = 0; - channel->vibrato.direction = 0; - channel->vibrato.value = 0; -} - -static void tracker_song_state_init(Tracker* tracker) { - tracker->song_state.tick = 0; - tracker->song_state.tick_limit = 2; - tracker->song_state.row_index = 0; - tracker->song_state.order_list_index = 0; - tracker->song_state.pattern_index = tracker->song->order_list[0]; - - if(tracker->song_state.channels != NULL) { - free(tracker->song_state.channels); - } - - tracker->song_state.channels = malloc(sizeof(ChannelState) * tracker->song->channels_count); - for(uint8_t i = 0; i < tracker->song->channels_count; i++) { - channels_state_init(&tracker->song_state.channels[i]); - } -} - -static void tracker_song_state_clear(Tracker* tracker) { - if(tracker->song_state.channels != NULL) { - free(tracker->song_state.channels); - tracker->song_state.channels = NULL; - } -} - -static uint8_t record_get_note(Row note) { - return note & ROW_NOTE_MASK; -} - -static uint8_t record_get_effect(Row note) { - return (note >> 6) & ROW_EFFECT_MASK; -} - -static uint8_t record_get_effect_data(Row note) { - return (note >> 10) & ROW_EFFECT_DATA_MASK; -} - -#define NOTES_PER_OCT 12 -const float notes_oct[NOTES_PER_OCT] = { - 130.813f, - 138.591f, - 146.832f, - 155.563f, - 164.814f, - 174.614f, - 184.997f, - 195.998f, - 207.652f, - 220.00f, - 233.082f, - 246.942f, -}; - -static float note_to_freq(uint8_t note) { - if(note == NOTE_NONE) return 0.0f; - note = note - NOTE_C2; - uint8_t octave = note / NOTES_PER_OCT; - uint8_t note_in_oct = note % NOTES_PER_OCT; - return notes_oct[note_in_oct] * (1 << octave); -} - -static float frequency_offset_semitones(float frequency, uint8_t semitones) { - return frequency * (1.0f + ((1.0f / 12.0f) * semitones)); -} - -static float frequency_get_seventh_of_a_semitone(float frequency) { - return frequency * ((1.0f / 12.0f) / 7.0f); -} - -static UnpackedRow get_current_row(const Song* song, SongState* song_state, uint8_t channel) { - const Pattern* pattern = &song->patterns[song_state->pattern_index]; - const Row row = pattern->channels[channel].rows[song_state->row_index]; - return (UnpackedRow){ - .note = record_get_note(row), - .effect = record_get_effect(row), - .data = record_get_effect_data(row), - }; -} - -static int16_t advance_order_and_get_next_pattern_index(const Song* song, SongState* song_state) { - song_state->order_list_index++; - if(song_state->order_list_index >= song->order_list_size) { - return -1; - } else { - return song->order_list[song_state->order_list_index]; - } -} - -typedef struct { - int16_t pattern; - int16_t row; - bool change_pattern; - bool change_row; -} Location; - -static void tracker_send_position_message(Tracker* tracker) { - if(tracker->callback != NULL) { - tracker->callback( - (TrackerMessage){ - .type = TrackerPositionChanged, - .data = - { - .position = - { - .order_list_index = tracker->song_state.order_list_index, - .row = tracker->song_state.row_index, - }, - }, - }, - tracker->context); - } -} - -static void tracker_send_end_message(Tracker* tracker) { - if(tracker->callback != NULL) { - tracker->callback((TrackerMessage){.type = TrackerEndOfSong}, tracker->context); - } -} - -static void advance_to_pattern(Tracker* tracker, Location advance) { - if(advance.change_pattern) { - if(advance.pattern < 0 || advance.pattern >= tracker->song->patterns_count) { - tracker->playing = false; - tracker_send_end_message(tracker); - } else { - tracker->song_state.pattern_index = advance.pattern; - tracker->song_state.row_index = 0; - } - } - - if(advance.change_row) { - if(advance.row < 0) advance.row = 0; - if(advance.row >= PATTERN_SIZE) advance.row = PATTERN_SIZE - 1; - tracker->song_state.row_index = advance.row; - } - - tracker_send_position_message(tracker); -} - -static void tracker_interrupt_body(Tracker* tracker) { - if(!tracker->playing) { - tracker_speaker_stop(); - return; - } - - const uint8_t channel_index = 0; - SongState* song_state = &tracker->song_state; - ChannelState* channel_state = &song_state->channels[channel_index]; - const Song* song = tracker->song; - UnpackedRow row = get_current_row(song, song_state, channel_index); - - // load frequency from note at tick 0 - if(song_state->tick == 0) { - bool invalidate_row = false; - // handle "on first tick" effects - if(row.effect == EffectBreakPattern) { - int16_t next_row_index = row.data; - int16_t next_pattern_index = - advance_order_and_get_next_pattern_index(song, song_state); - advance_to_pattern( - tracker, - (Location){ - .pattern = next_pattern_index, - .row = next_row_index, - .change_pattern = true, - .change_row = true, - }); - - invalidate_row = true; - } - - if(row.effect == EffectJumpToOrder) { - song_state->order_list_index = row.data; - int16_t next_pattern_index = song->order_list[song_state->order_list_index]; - - advance_to_pattern( - tracker, - (Location){ - .pattern = next_pattern_index, - .change_pattern = true, - }); - - invalidate_row = true; - } - - // tracker state can be affected by effects - if(!tracker->playing) { - tracker_speaker_stop(); - return; - } - - if(invalidate_row) { - row = get_current_row(song, song_state, channel_index); - - if(row.effect == EffectSetSpeed) { - song_state->tick_limit = row.data; - } - } - - // handle note effects - if(row.note == NOTE_OFF) { - channel_state->play = false; - } else if((row.note > NOTE_NONE) && (row.note < NOTE_OFF)) { - channel_state->play = true; - - // reset vibrato - channel_state->vibrato.speed = 0; - channel_state->vibrato.depth = 0; - channel_state->vibrato.value = 0; - channel_state->vibrato.direction = 0; - - // reset pwm - channel_state->pwm = PWM_DEFAULT; - - if(row.effect == EffectSlideToNote) { - channel_state->frequency_target = note_to_freq(row.note); - } else { - channel_state->frequency = note_to_freq(row.note); - channel_state->frequency_target = FREQUENCY_UNSET; - } - } - } - - if(channel_state->play) { - float frequency, pwm; - - if((row.effect == EffectSlideUp || row.effect == EffectSlideDown) && - row.data != EFFECT_DATA_NONE) { - // apply slide effect - channel_state->frequency += (row.effect == EffectSlideUp ? 1 : -1) * row.data; - } else if(row.effect == EffectSlideToNote) { - // apply slide to note effect, if target frequency is set - if(channel_state->frequency_target > 0) { - if(channel_state->frequency_target > channel_state->frequency) { - channel_state->frequency += row.data; - if(channel_state->frequency > channel_state->frequency_target) { - channel_state->frequency = channel_state->frequency_target; - channel_state->frequency_target = FREQUENCY_UNSET; - } - } else if(channel_state->frequency_target < channel_state->frequency) { - channel_state->frequency -= row.data; - if(channel_state->frequency < channel_state->frequency_target) { - channel_state->frequency = channel_state->frequency_target; - channel_state->frequency_target = FREQUENCY_UNSET; - } - } - } - } - - frequency = channel_state->frequency; - pwm = channel_state->pwm; - - // apply arpeggio effect - if(row.effect == EffectArpeggio) { - if(row.data != EFFECT_DATA_NONE) { - if((song_state->tick % 3) == 1) { - uint8_t note_offset = EFFECT_DATA_GET_X(row.data); - frequency = frequency_offset_semitones(frequency, note_offset); - } else if((song_state->tick % 3) == 2) { - uint8_t note_offset = EFFECT_DATA_GET_Y(row.data); - frequency = frequency_offset_semitones(frequency, note_offset); - } - } - } else if(row.effect == EffectVibrato) { - // apply vibrato effect, data = speed, depth - uint8_t vibrato_speed = EFFECT_DATA_GET_X(row.data); - uint8_t vibrato_depth = EFFECT_DATA_GET_Y(row.data); - - // update vibrato parameters if speed or depth is non-zero - if(vibrato_speed != 0) channel_state->vibrato.speed = vibrato_speed; - if(vibrato_depth != 0) channel_state->vibrato.depth = vibrato_depth; - - // update vibrato value - channel_state->vibrato.value += - channel_state->vibrato.direction * channel_state->vibrato.speed; - - // change direction if value is at the limit - if(channel_state->vibrato.value > channel_state->vibrato.depth) { - channel_state->vibrato.direction = -1; - } else if(channel_state->vibrato.value < -channel_state->vibrato.depth) { - channel_state->vibrato.direction = 1; - } else if(channel_state->vibrato.direction == 0) { - // set initial direction, if it is not set - channel_state->vibrato.direction = 1; - } - - frequency += - (frequency_get_seventh_of_a_semitone(frequency) * channel_state->vibrato.value); - } else if(row.effect == EffectPWM) { - pwm = (pwm - PWM_MIN) / EFFECT_DATA_1_MAX * row.data + PWM_MIN; - } - - tracker_speaker_play(frequency, pwm); - } else { - tracker_speaker_stop(); - } - - song_state->tick++; - if(song_state->tick >= song_state->tick_limit) { - song_state->tick = 0; - - // next note - song_state->row_index = (song_state->row_index + 1); - - if(song_state->row_index >= PATTERN_SIZE) { - int16_t next_pattern_index = - advance_order_and_get_next_pattern_index(song, song_state); - advance_to_pattern( - tracker, - (Location){ - .pattern = next_pattern_index, - .change_pattern = true, - }); - } else { - tracker_send_position_message(tracker); - } - } -} - -static void tracker_interrupt_cb(void* context) { - Tracker* tracker = (Tracker*)context; - tracker_debug_set(true); - tracker_interrupt_body(tracker); - tracker_debug_set(false); -} - -/********************************************************************* - * Tracker Interface - *********************************************************************/ - -Tracker* tracker_alloc() { - Tracker* tracker = malloc(sizeof(Tracker)); - return tracker; -} - -void tracker_free(Tracker* tracker) { - tracker_song_state_clear(tracker); - free(tracker); -} - -void tracker_set_message_callback(Tracker* tracker, TrackerMessageCallback callback, void* context) { - furi_check(tracker->playing == false); - tracker->callback = callback; - tracker->context = context; -} - -void tracker_set_song(Tracker* tracker, const Song* song) { - furi_check(tracker->playing == false); - tracker->song = song; - tracker_song_state_init(tracker); -} - -void tracker_set_order_index(Tracker* tracker, uint8_t order_index) { - furi_check(tracker->playing == false); - furi_check(order_index < tracker->song->order_list_size); - tracker->song_state.order_list_index = order_index; - tracker->song_state.pattern_index = tracker->song->order_list[order_index]; -} - -void tracker_set_row(Tracker* tracker, uint8_t row) { - furi_check(tracker->playing == false); - furi_check(row < PATTERN_SIZE); - tracker->song_state.row_index = row; -} - -void tracker_start(Tracker* tracker) { - furi_check(tracker->song != NULL); - - tracker->playing = true; - tracker_send_position_message(tracker); - tracker_debug_init(); - tracker_speaker_init(); - tracker_interrupt_init(tracker->song->ticks_per_second, tracker_interrupt_cb, tracker); -} - -void tracker_stop(Tracker* tracker) { - tracker_interrupt_deinit(); - tracker_speaker_deinit(); - tracker_debug_deinit(); - - tracker->playing = false; -} \ No newline at end of file diff --git a/applications/plugins/musictracker/tracker_engine/tracker.h b/applications/plugins/musictracker/tracker_engine/tracker.h deleted file mode 100644 index 70bf4bd6b..000000000 --- a/applications/plugins/musictracker/tracker_engine/tracker.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "tracker_notes.h" -#include "tracker_song.h" - -typedef enum { - TrackerPositionChanged, - TrackerEndOfSong, -} TrackerMessageType; - -typedef struct { - TrackerMessageType type; - union tracker_message_data { - struct { - uint8_t order_list_index; - uint8_t row; - } position; - } data; -} TrackerMessage; - -typedef void (*TrackerMessageCallback)(TrackerMessage message, void* context); - -typedef struct Tracker Tracker; - -Tracker* tracker_alloc(); - -void tracker_free(Tracker* tracker); - -void tracker_set_message_callback(Tracker* tracker, TrackerMessageCallback callback, void* context); - -void tracker_set_song(Tracker* tracker, const Song* song); - -void tracker_set_order_index(Tracker* tracker, uint8_t order_index); - -void tracker_set_row(Tracker* tracker, uint8_t row); - -void tracker_start(Tracker* tracker); - -void tracker_stop(Tracker* tracker); \ No newline at end of file diff --git a/applications/plugins/musictracker/tracker_engine/tracker_notes.h b/applications/plugins/musictracker/tracker_engine/tracker_notes.h deleted file mode 100644 index 22ab3590f..000000000 --- a/applications/plugins/musictracker/tracker_engine/tracker_notes.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -#define NOTE_NONE 0 -#define NOTE_C2 1 -#define NOTE_Cs2 2 -#define NOTE_D2 3 -#define NOTE_Ds2 4 -#define NOTE_E2 5 -#define NOTE_F2 6 -#define NOTE_Fs2 7 -#define NOTE_G2 8 -#define NOTE_Gs2 9 -#define NOTE_A2 10 -#define NOTE_As2 11 -#define NOTE_B2 12 -#define NOTE_C3 13 -#define NOTE_Cs3 14 -#define NOTE_D3 15 -#define NOTE_Ds3 16 -#define NOTE_E3 17 -#define NOTE_F3 18 -#define NOTE_Fs3 19 -#define NOTE_G3 20 -#define NOTE_Gs3 21 -#define NOTE_A3 22 -#define NOTE_As3 23 -#define NOTE_B3 24 -#define NOTE_C4 25 -#define NOTE_Cs4 26 -#define NOTE_D4 27 -#define NOTE_Ds4 28 -#define NOTE_E4 29 -#define NOTE_F4 30 -#define NOTE_Fs4 31 -#define NOTE_G4 32 -#define NOTE_Gs4 33 -#define NOTE_A4 34 -#define NOTE_As4 35 -#define NOTE_B4 36 -#define NOTE_C5 37 -#define NOTE_Cs5 38 -#define NOTE_D5 39 -#define NOTE_Ds5 40 -#define NOTE_E5 41 -#define NOTE_F5 42 -#define NOTE_Fs5 43 -#define NOTE_G5 44 -#define NOTE_Gs5 45 -#define NOTE_A5 46 -#define NOTE_As5 47 -#define NOTE_B5 48 -#define NOTE_C6 49 -#define NOTE_Cs6 50 -#define NOTE_D6 51 -#define NOTE_Ds6 52 -#define NOTE_E6 53 -#define NOTE_F6 54 -#define NOTE_Fs6 55 -#define NOTE_G6 56 -#define NOTE_Gs6 57 -#define NOTE_A6 58 -#define NOTE_As6 59 -#define NOTE_B6 60 -#define NOTE_OFF 63 \ No newline at end of file diff --git a/applications/plugins/musictracker/tracker_engine/tracker_song.h b/applications/plugins/musictracker/tracker_engine/tracker_song.h deleted file mode 100644 index 7a054f7b1..000000000 --- a/applications/plugins/musictracker/tracker_engine/tracker_song.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -#include - -/** - * @brief Row - * - * AH AL - * FEDCBA98 76543210 - * nnnnnnee eedddddd - * -------- -------- - * nnnnnn = [0] do nothing, [1..60] note number, [61] note off, [62..63] not used - * ee ee = [0..F] effect - * 111222 = [0..63] or [0..7, 0..7] effect data - */ -typedef uint16_t Row; - -#define ROW_NOTE_MASK 0x3F -#define ROW_EFFECT_MASK 0x0F -#define ROW_EFFECT_DATA_MASK 0x3F - -typedef enum { - // 0xy, x - first semitones offset, y - second semitones offset. 0 - no offset .. 7 - +7 semitones... - // Play the arpeggio chord with three notes. The first note is the base note, the second and third are offset by x and y. - // Each note plays one tick. - EffectArpeggio = 0x00, - - // 1xx, xx - effect speed, 0 - no effect, 1 - slowest, 0x3F - fastest. - // Slide the note pitch up by xx Hz every tick. - EffectSlideUp = 0x01, - - // 2xx, xx - effect speed, 0 - no effect, 1 - slowest, 0x3F - fastest. - // Slide the note pitch down by xx Hz every tick. - EffectSlideDown = 0x02, - - // 3xx, xx - effect speed, 0 - no effect, 1 - slowest, 0x3F - fastest. - // Slide the already playing note pitch towards another one by xx Hz every tick. - // The note value is saved until the note is playing, so you don't have to repeat the note value to continue sliding. - EffectSlideToNote = 0x03, - - // 4xy, x - vibrato speed (0..7), y - vibrato depth (0..7). - // Vibrato effect. The pitch of the note increases by x Hz each tick to a positive vibrato depth, then decreases to a negative depth. - // Value 1 of depth means 1/7 of a semitone (about 14.28 ct), so value 7 means full semitone. - // Note will play without vibrato on the first tick at the beginning of the effect. - // Vibrato speed and depth are saved until the note is playing, and will be updated only if they are not zero, so you doesn't have to repeat them every tick. - EffectVibrato = 0x04, - - // Effect05 = 0x05, - // Effect06 = 0x06, - // Effect07 = 0x07, - // Effect08 = 0x08, - // Effect09 = 0x09, - // Effect0A = 0x0A, - - // Bxx, xx - pattern number - // Jump to the order xx in the pattern order table at first tick of current row. - // So if you want to jump to the pattern after note 4, you should put this effect on the 5th note. - EffectJumpToOrder = 0x0B, - - // Cxx, xx - pwm value - // Set the PWM value to xx for current row. - EffectPWM = 0x0C, - - // Bxx, xx - row number - // Jump to the row xx in next pattern at first tick of current row. - // So if you want to jump to the pattern after note 4, you should put this effect on the 5th note. - EffectBreakPattern = 0x0D, - - // Effect0E = 0x0E, - - // Fxx, xx - song speed, 0 - 1 tick per note, 1 - 2 ticks per note, 0x3F - 64 ticks per note. - // Set the speed of the song in terms of ticks per note. - // Will be applied at the first tick of current row. - EffectSetSpeed = 0x0F, -} Effect; - -#define EFFECT_DATA_2(x, y) ((x) | ((y) << 3)) -#define EFFECT_DATA_GET_X(data) ((data)&0x07) -#define EFFECT_DATA_GET_Y(data) (((data) >> 3) & 0x07) -#define EFFECT_DATA_NONE 0 -#define EFFECT_DATA_1_MAX 0x3F -#define EFFECT_DATA_2_MAX 0x07 - -#define FREQUENCY_UNSET -1.0f - -#define PWM_MIN 0.01f -#define PWM_MAX 0.5f -#define PWM_DEFAULT PWM_MAX - -#define PATTERN_SIZE 64 - -#define ROW_MAKE(note, effect, data) \ - ((Row)(((note)&0x3F) | (((effect)&0xF) << 6) | (((data)&0x3F) << 10))) - -typedef struct { - Row rows[PATTERN_SIZE]; -} Channel; - -typedef struct { - Channel* channels; -} Pattern; - -typedef struct { - uint8_t channels_count; - uint8_t patterns_count; - Pattern* patterns; - uint8_t order_list_size; - uint8_t* order_list; - uint16_t ticks_per_second; -} Song; \ No newline at end of file diff --git a/applications/plugins/musictracker/view/tracker_view.c b/applications/plugins/musictracker/view/tracker_view.c deleted file mode 100644 index 87e6b0fcf..000000000 --- a/applications/plugins/musictracker/view/tracker_view.c +++ /dev/null @@ -1,182 +0,0 @@ -#include "tracker_view.h" -#include -#include - -typedef struct { - const Song* song; - uint8_t order_list_index; - uint8_t row; -} TrackerViewModel; - -struct TrackerView { - View* view; - void* back_context; - TrackerViewCallback back_callback; -}; - -static Channel* get_current_channel(TrackerViewModel* model) { - uint8_t channel_id = 0; - uint8_t pattern_id = model->song->order_list[model->order_list_index]; - Pattern* pattern = &model->song->patterns[pattern_id]; - return &pattern->channels[channel_id]; -} - -static const char* get_note_from_id(uint8_t note) { -#define NOTE_COUNT 12 - const char* notes[NOTE_COUNT] = { - "C ", - "C#", - "D ", - "D#", - "E ", - "F ", - "F#", - "G ", - "G#", - "A ", - "A#", - "B ", - }; - return notes[(note) % NOTE_COUNT]; -#undef NOTE_COUNT -} - -static uint8_t get_octave_from_id(uint8_t note) { - return ((note) / 12) + 2; -} - -static uint8_t get_first_row_id(uint8_t row) { - return (row / 10) * 10; -} - -static void - draw_row(Canvas* canvas, uint8_t i, Channel* channel, uint8_t row, FuriString* buffer) { - uint8_t x = 12 * (i + 1); - uint8_t first_row_id = get_first_row_id(row); - uint8_t current_row_id = first_row_id + i; - - if((current_row_id) >= 64) { - return; - } - - Row current_row = channel->rows[current_row_id]; - uint8_t note = current_row & ROW_NOTE_MASK; - uint8_t effect = (current_row >> 6) & ROW_EFFECT_MASK; - uint8_t data = (current_row >> 10) & ROW_EFFECT_DATA_MASK; - - if(current_row_id == row) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_line(canvas, x - 9, 1, x - 9, 62); - canvas_draw_box(canvas, x - 8, 0, 9, 64); - canvas_draw_line(canvas, x + 1, 1, x + 1, 62); - canvas_set_color(canvas, ColorWhite); - } - - furi_string_printf(buffer, "%02X", current_row_id); - canvas_draw_str(canvas, x, 61, furi_string_get_cstr(buffer)); - - if(note > 0 && note < NOTE_OFF) { - furi_string_printf( - buffer, "%s%d", get_note_from_id(note - 1), get_octave_from_id(note - 1)); - canvas_draw_str(canvas, x, 44, furi_string_get_cstr(buffer)); - } else if(note == NOTE_OFF) { - canvas_draw_str(canvas, x, 44, "OFF"); - } else { - canvas_draw_str(canvas, x, 44, "---"); - } - - if(effect == 0 && data == 0) { - canvas_draw_str(canvas, x, 21, "-"); - canvas_draw_str(canvas, x, 12, "--"); - } else { - furi_string_printf(buffer, "%X", effect); - canvas_draw_str(canvas, x, 21, furi_string_get_cstr(buffer)); - - if(effect == EffectArpeggio || effect == EffectVibrato) { - uint8_t data_x = EFFECT_DATA_GET_X(data); - uint8_t data_y = EFFECT_DATA_GET_Y(data); - furi_string_printf(buffer, "%d%d", data_x, data_y); - canvas_draw_str(canvas, x, 12, furi_string_get_cstr(buffer)); - } else { - furi_string_printf(buffer, "%02X", data); - canvas_draw_str(canvas, x, 12, furi_string_get_cstr(buffer)); - } - } - - if(current_row_id == row) { - canvas_set_color(canvas, ColorBlack); - } -} - -static void tracker_view_draw_callback(Canvas* canvas, void* _model) { - TrackerViewModel* model = _model; - if(model->song == NULL) { - return; - } - - canvas_set_font_direction(canvas, CanvasDirectionBottomToTop); - canvas_set_font(canvas, FontKeyboard); - - Channel* channel = get_current_channel(model); - FuriString* buffer = furi_string_alloc(); - - for(uint8_t i = 0; i < 10; i++) { - draw_row(canvas, i, channel, model->row, buffer); - } - furi_string_free(buffer); -} - -static bool tracker_view_input_callback(InputEvent* event, void* context) { - TrackerView* tracker_view = context; - - if(tracker_view->back_callback) { - if(event->type == InputTypeShort && event->key == InputKeyBack) { - tracker_view->back_callback(tracker_view->back_context); - return true; - } - } - return false; -} - -TrackerView* tracker_view_alloc() { - TrackerView* tracker_view = malloc(sizeof(TrackerView)); - tracker_view->view = view_alloc(); - view_allocate_model(tracker_view->view, ViewModelTypeLocking, sizeof(TrackerViewModel)); - view_set_context(tracker_view->view, tracker_view); - view_set_draw_callback(tracker_view->view, (ViewDrawCallback)tracker_view_draw_callback); - view_set_input_callback(tracker_view->view, (ViewInputCallback)tracker_view_input_callback); - return tracker_view; -} - -void tracker_view_free(TrackerView* tracker_view) { - view_free(tracker_view->view); - free(tracker_view); -} - -View* tracker_view_get_view(TrackerView* tracker_view) { - return tracker_view->view; -} - -void tracker_view_set_back_callback( - TrackerView* tracker_view, - TrackerViewCallback callback, - void* context) { - tracker_view->back_callback = callback; - tracker_view->back_context = context; -} - -void tracker_view_set_song(TrackerView* tracker_view, const Song* song) { - with_view_model( - tracker_view->view, TrackerViewModel * model, { model->song = song; }, true); -} - -void tracker_view_set_position(TrackerView* tracker_view, uint8_t order_list_index, uint8_t row) { - with_view_model( - tracker_view->view, - TrackerViewModel * model, - { - model->order_list_index = order_list_index; - model->row = row; - }, - true); -} \ No newline at end of file diff --git a/applications/plugins/musictracker/view/tracker_view.h b/applications/plugins/musictracker/view/tracker_view.h deleted file mode 100644 index 6c2e69ba4..000000000 --- a/applications/plugins/musictracker/view/tracker_view.h +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "../tracker_engine/tracker.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct TrackerView TrackerView; - -TrackerView* tracker_view_alloc(); - -void tracker_view_free(TrackerView* tracker_view); - -View* tracker_view_get_view(TrackerView* tracker_view); - -typedef void (*TrackerViewCallback)(void* context); - -void tracker_view_set_back_callback( - TrackerView* tracker_view, - TrackerViewCallback callback, - void* context); - -void tracker_view_set_song(TrackerView* tracker_view, const Song* song); - -void tracker_view_set_position(TrackerView* tracker_view, uint8_t order_list_index, uint8_t row); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/musictracker/zero_tracker.c b/applications/plugins/musictracker/zero_tracker.c deleted file mode 100644 index f4c10d9ef..000000000 --- a/applications/plugins/musictracker/zero_tracker.c +++ /dev/null @@ -1,536 +0,0 @@ -#include -#include -#include -#include -#include "zero_tracker.h" -#include "tracker_engine/tracker.h" -#include "view/tracker_view.h" - -// Channel p_0_channels[] = { -// { -// .rows = -// { -// // 1/4 -// ROW_MAKE(NOTE_C3, EffectArpeggio, EFFECT_DATA_2(4, 7)), -// ROW_MAKE(0, EffectArpeggio, EFFECT_DATA_2(4, 7)), -// ROW_MAKE(NOTE_C4, EffectSlideToNote, 0x20), -// ROW_MAKE(0, EffectSlideToNote, 0x20), -// // -// ROW_MAKE(0, EffectSlideToNote, 0x20), -// ROW_MAKE(0, EffectSlideToNote, 0x20), -// ROW_MAKE(0, EffectSlideToNote, 0x20), -// ROW_MAKE(0, EffectSlideToNote, 0x20), -// // -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), -// // -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), -// // 2/4 -// ROW_MAKE(NOTE_C3, EffectSlideDown, 0x20), -// ROW_MAKE(0, EffectSlideDown, 0x20), -// ROW_MAKE(NOTE_C4, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// // -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// // -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// // -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(3, 3)), -// ROW_MAKE(NOTE_OFF, EffectVibrato, EFFECT_DATA_2(3, 3)), -// // 3/4 -// ROW_MAKE(NOTE_C3, EffectArpeggio, EFFECT_DATA_2(4, 7)), -// ROW_MAKE(0, EffectArpeggio, EFFECT_DATA_2(4, 7)), -// ROW_MAKE(NOTE_OFF, 0, 0), -// ROW_MAKE(0, 0, 0), -// // -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// // -// ROW_MAKE(NOTE_C2, EffectPWM, 60), -// ROW_MAKE(0, EffectPWM, 32), -// ROW_MAKE(0, EffectPWM, 12), -// ROW_MAKE(NOTE_OFF, 0, 0), -// // -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// // 4/4 -// ROW_MAKE(NOTE_C3, EffectSlideDown, 0x20), -// ROW_MAKE(0, EffectSlideDown, 0x20), -// ROW_MAKE(0, EffectSlideDown, 0x20), -// ROW_MAKE(NOTE_OFF, 0, 0), -// // -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// // -// ROW_MAKE(NOTE_C2, EffectPWM, 60), -// ROW_MAKE(0, EffectPWM, 32), -// ROW_MAKE(0, EffectPWM, 12), -// ROW_MAKE(NOTE_OFF, 0, 0), -// // -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// ROW_MAKE(0, 0, 0), -// }, -// }, -// }; - -Channel p_0_channels[] = { - { - .rows = - { - // - ROW_MAKE(NOTE_A4, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_C3, 0, 0), - ROW_MAKE(NOTE_F2, 0, 0), - ROW_MAKE(NOTE_C3, 0, 0), - // - ROW_MAKE(NOTE_E4, 0, 0), - ROW_MAKE(NOTE_C3, 0, 0), - ROW_MAKE(NOTE_E4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_E5, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_C3, EffectSlideDown, 0x30), - ROW_MAKE(NOTE_F2, 0, 0), - ROW_MAKE(NOTE_C3, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_C3, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - // - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_B4, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_D3, 0, 0), - ROW_MAKE(NOTE_G2, 0, 0), - ROW_MAKE(NOTE_D3, 0, 0), - // - ROW_MAKE(NOTE_E4, 0, 0), - ROW_MAKE(NOTE_D3, 0, 0), - ROW_MAKE(NOTE_E4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_E5, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_D3, EffectSlideDown, 0x3F), - ROW_MAKE(NOTE_G2, 0, 0), - ROW_MAKE(NOTE_D3, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_D3, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - // - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(NOTE_OFF, 0, 0), - }, - }, -}; - -Channel p_1_channels[] = { - { - .rows = - { - // - ROW_MAKE(NOTE_C5, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_G4, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C6, 0, 0), - ROW_MAKE(NOTE_E3, EffectSlideDown, 0x30), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_G4, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - // - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C5, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_G4, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(0, EffectPWM, 55), - ROW_MAKE(0, EffectPWM, 45), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C6, 0, 0), - ROW_MAKE(NOTE_E3, EffectSlideDown, 0x30), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 50), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_G4, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, 0, 0), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - // - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(1, 1)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(0, EffectVibrato, EFFECT_DATA_2(2, 2)), - ROW_MAKE(NOTE_OFF, 0, 0), - }, - }, -}; - -Channel p_2_channels[] = { - { - .rows = - { - // - ROW_MAKE(NOTE_C5, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, 0, 0), - // - ROW_MAKE(NOTE_C5, EffectPWM, 55), - ROW_MAKE(NOTE_A4, EffectPWM, 45), - ROW_MAKE(NOTE_C5, EffectPWM, 35), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(NOTE_C5, EffectPWM, 55), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_E3, EffectSlideDown, 0x30), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_OFF, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_D5, EffectPWM, 55), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - // - ROW_MAKE(NOTE_D5, EffectPWM, 45), - ROW_MAKE(NOTE_B4, EffectPWM, 45), - ROW_MAKE(NOTE_D5, EffectPWM, 35), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, EffectArpeggio, EFFECT_DATA_2(4, 7)), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_E5, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_E5, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - // - ROW_MAKE(NOTE_E5, EffectPWM, 55), - ROW_MAKE(NOTE_C5, EffectPWM, 45), - ROW_MAKE(NOTE_E5, EffectPWM, 35), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_E5, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_E5, EffectPWM, 55), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_E3, EffectSlideDown, 0x30), - ROW_MAKE(NOTE_A2, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - // - ROW_MAKE(NOTE_OFF, 0, 0), - ROW_MAKE(NOTE_E3, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_D5, EffectPWM, 55), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - // - ROW_MAKE(NOTE_D5, EffectPWM, 45), - ROW_MAKE(NOTE_B4, EffectPWM, 45), - ROW_MAKE(NOTE_D5, EffectPWM, 35), - ROW_MAKE(NOTE_OFF, 0, 0), - }, - }, -}; - -Channel p_3_channels[] = { - { - .rows = - { - // - ROW_MAKE(NOTE_Ds5, EffectArpeggio, EFFECT_DATA_2(4, 6)), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_Ds5, 0, 0), - ROW_MAKE(NOTE_C5, EffectPWM, 55), - // - ROW_MAKE(NOTE_Ds5, EffectPWM, 45), - ROW_MAKE(NOTE_C5, EffectPWM, 35), - ROW_MAKE(NOTE_Ds5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - // - ROW_MAKE(NOTE_D5, EffectPWM, 45), - ROW_MAKE(NOTE_B4, EffectPWM, 35), - ROW_MAKE(NOTE_D5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_Cs5, EffectArpeggio, EFFECT_DATA_2(4, 6)), - ROW_MAKE(NOTE_As4, 0, 0), - ROW_MAKE(NOTE_Cs5, 0, 0), - ROW_MAKE(NOTE_As4, EffectPWM, 55), - // - ROW_MAKE(NOTE_Cs5, EffectPWM, 45), - ROW_MAKE(NOTE_As4, EffectPWM, 35), - ROW_MAKE(NOTE_Cs5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, EffectPWM, 55), - // - ROW_MAKE(NOTE_C5, EffectPWM, 45), - ROW_MAKE(NOTE_A4, EffectPWM, 35), - ROW_MAKE(NOTE_C5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_B4, EffectArpeggio, EFFECT_DATA_2(4, 6)), - ROW_MAKE(NOTE_Gs4, 0, 0), - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_Gs4, EffectPWM, 55), - // - ROW_MAKE(NOTE_B4, EffectPWM, 45), - ROW_MAKE(NOTE_Gs4, EffectPWM, 35), - ROW_MAKE(NOTE_B4, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, 0, 0), - ROW_MAKE(NOTE_C5, 0, 0), - ROW_MAKE(NOTE_A4, EffectPWM, 55), - // - ROW_MAKE(NOTE_C5, EffectPWM, 45), - ROW_MAKE(NOTE_A4, EffectPWM, 35), - ROW_MAKE(NOTE_C5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_Cs5, EffectArpeggio, EFFECT_DATA_2(4, 6)), - ROW_MAKE(NOTE_As4, 0, 0), - ROW_MAKE(NOTE_Cs5, 0, 0), - ROW_MAKE(NOTE_As4, EffectPWM, 55), - // - ROW_MAKE(NOTE_Cs5, EffectPWM, 45), - ROW_MAKE(NOTE_As4, EffectPWM, 35), - ROW_MAKE(NOTE_Cs5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - // - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, 0, 0), - ROW_MAKE(NOTE_D5, 0, 0), - ROW_MAKE(NOTE_B4, EffectPWM, 55), - // - ROW_MAKE(NOTE_D5, EffectPWM, 45), - ROW_MAKE(NOTE_B4, EffectPWM, 35), - ROW_MAKE(NOTE_D5, EffectPWM, 30), - ROW_MAKE(NOTE_OFF, 0, 0), - }, - }, -}; -Pattern patterns[] = { - {.channels = p_0_channels}, - {.channels = p_1_channels}, - {.channels = p_2_channels}, - {.channels = p_3_channels}, -}; - -uint8_t order_list[] = { - 0, - 1, - 0, - 2, - 0, - 1, - 0, - 3, -}; - -Song song = { - .channels_count = 1, - .patterns_count = sizeof(patterns) / sizeof(patterns[0]), - .patterns = patterns, - - .order_list_size = sizeof(order_list) / sizeof(order_list[0]), - .order_list = order_list, - - .ticks_per_second = 60, -}; - -void tracker_message(TrackerMessage message, void* context) { - FuriMessageQueue* queue = context; - furi_assert(queue); - furi_message_queue_put(queue, &message, 0); -} - -int32_t zero_tracker_app(void* p) { - UNUSED(p); - - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - notification_message(notification, &sequence_display_backlight_enforce_on); - - Gui* gui = furi_record_open(RECORD_GUI); - ViewDispatcher* view_dispatcher = view_dispatcher_alloc(); - TrackerView* tracker_view = tracker_view_alloc(); - tracker_view_set_song(tracker_view, &song); - view_dispatcher_add_view(view_dispatcher, 0, tracker_view_get_view(tracker_view)); - view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); - view_dispatcher_switch_to_view(view_dispatcher, 0); - - FuriMessageQueue* queue = furi_message_queue_alloc(8, sizeof(TrackerMessage)); - Tracker* tracker = tracker_alloc(); - tracker_set_message_callback(tracker, tracker_message, queue); - tracker_set_song(tracker, &song); - tracker_start(tracker); - - while(1) { - TrackerMessage message; - FuriStatus status = furi_message_queue_get(queue, &message, portMAX_DELAY); - if(status == FuriStatusOk) { - if(message.type == TrackerPositionChanged) { - uint8_t order_list_index = message.data.position.order_list_index; - uint8_t row = message.data.position.row; - uint8_t pattern = song.order_list[order_list_index]; - tracker_view_set_position(tracker_view, order_list_index, row); - FURI_LOG_I("Tracker", "O:%d P:%d R:%d", order_list_index, pattern, row); - } else if(message.type == TrackerEndOfSong) { - FURI_LOG_I("Tracker", "End of song"); - break; - } - } - } - - tracker_stop(tracker); - tracker_free(tracker); - furi_message_queue_free(queue); - - furi_delay_ms(500); - - view_dispatcher_remove_view(view_dispatcher, 0); - tracker_view_free(tracker_view); - view_dispatcher_free(view_dispatcher); - - notification_message(notification, &sequence_display_backlight_enforce_auto); - - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_GUI); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/musictracker/zero_tracker.h b/applications/plugins/musictracker/zero_tracker.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/applications/plugins/musictracker/zero_tracker.png b/applications/plugins/musictracker/zero_tracker.png deleted file mode 100644 index 61488d153..000000000 Binary files a/applications/plugins/musictracker/zero_tracker.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/LICENSE b/applications/plugins/nrf24scan/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/nrf24scan/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/nrf24scan/README.md b/applications/plugins/nrf24scan/README.md deleted file mode 100644 index b1e7f1305..000000000 --- a/applications/plugins/nrf24scan/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# NRF24 scanner with logging and resend ability for Flipper Zero - -An [NRF24](https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf) driver for the [Flipper Zero](https://flipperzero.one/) device. The NRF24 is a popular line of 2.4GHz radio transceivers from Nordic Semiconductors.
-NRF24L01+ Enhanced ShockBurst packet decoder example using Python: [nrf24_packet_decoder.py](https://raw.githubusercontent.com/vad7/nrf24scan/master/nrf24_packet_decoder.py)
-
-Flipper Zero FAP file: [Nrf24_Scanner.fap](https://raw.githubusercontent.com/vad7/nrf24scan/master/Nrf24_Scanner.fap) -

-___________________________________________________________________________ -
-Приложение для Flipper Zero, читающее эфир на радиомодулях nRF24L01.
-Выбор пукта меню - стрелки вверх/вниз, стрелки влево/вправо либо изменют настройки либо управляют видом списка, кнопка ОК либо выбирает режим (короткое нажатие), либо выполняет дополнительное действие (длительное нажатие).

-
-По умолчанию при запуске включается режим поиска (sniff) - ищутся все валидные пакеты с корректным CRC.
-Размер CRC и тип пакета (Enhanced ShockBurst или нет) задается. CRC может быть или 1 или 2 байта.
-Так как пакеты читаются в RAW формате, то длина полезной нагрузки не может быть больше 23 байт, пакеты с большей длинной не будут пойманы.
-Изменение режима sniff/scan - стрелками на пункте Scan.

-Режим сканирования (scan) - чтение пакетов по заданным в настройках мак адресам и настройкам.
-На начальном экране в режиме чтения можно загрузить файл настроек (по умолчанию загружается settings.txt из папки nrf24_scanner на SD карте).
-В файле настройке задаются адреса (максимум 6) в шестнадцатеричном виде (старший байт - первый), длина адреса вычисляется по P0.
-Остальные настройки можно поменять интерактивно
-Настройки сохраняются длительным нажатием на ОК.

-Описание настроек:
-Ch - номер канала.
-Rate - скорость передачи данных
-Next Ch time - через сколько секунд будет увеличен номер канала
-Log - выбор режима авто сохраннения в файлы log-xx.txt. Yes - сохранять в новый файл при заполнении буфера в 99 записей, Append - добавлять в последний файл, Clear - только очистка буфера

-В пунктах Ch, Rate, Next при нажатии OK меняются параметры связи:
-ESB - Enhanced ShockBurst (включена автоотправка подтверждения получения пакета, работающий приемник тоже попытается это сделать, возможны коллизии)
-DPL - Динамический пакет
-CRC1/2 - Размер CRC в байтах
-Payload - размер пакета в байтах
-
-Просмотр принятых пакетов

- -
-В пункте "Start scan/sniff" можно выбрать стрелками сканировать и смотреть или просто смотреть (view).
-Если в файле настройки было несколько адресов, то первая цифра - номер канала (pipe) от 0 до 5.
-Стрелки - перемещение по списку и горизонтальное скролирование
-OK - отправка пакета
-Длительное нажатие OK - вход в режим просмотра адресов и включения декодирования заголовка ESB пакета и CRC.
-При декодировании заголовка (PCF) - первые 2 цифры - длина пакета в hex или 33, если длина пакета фиксирована
-3-я цифра - PID (2bit) << 1 + флаг NO_ACK
-Если включен режим декодирования CRC, то по всему пакету ищется подходящая CRC и подчеркивается в списке, а так же вместо ":" выводится "=" после номера записи в буфере
-
- -
- -
- -
-
-_________________________________________________________________________________ -
-
-Settings file (default addr.txt) format:
- -Rate: 0/1/2 - rate in Mbps (=0.25/1/2)
-Ch: 0..125 - default channel
-ESB: 0/1 (1 - Enhanced ShockBurst)
-DPL: 0/1 (1 - Dynamic Payload Length)
-CRC: 0/1/2 (CRC length)
-Payload: 1..32 (bytes)
-P0: address pipe #0 in hex (max 5 bytes, LSB last)
-P1: address pipe #1 in hex (max 5 bytes, LSB last)
-P2: address pipe #2, LSB in hex (1 byte)
-P3: address pipe #3, LSB in hex (1 byte)
-P4: address pipe #4, LSB in hex (1 byte)
-P5: address pipe #5, LSB in hex (1 byte)
-captured data in raw format, first byte = address # 0..5, Payload len if DPL
-... up to MAX_LOG_RECORDS-1
-
-In the list of the received:
-Press OK - send the packet,
-Long press OK - view addresses.
-
-Decode the Packet Control Field and check CRC (long press OK in the list and then press '<' / '>').
-ESB (Enhanced Shockburst) option must be turned off. -Press '>' to decode CRC.
-1 - pipe #
-2 - Payload length (for valide packet must be 1..20 or 33 hex)
-3 - PID (2 bit) + NO_ACK (1 bit)
-
-
-
-## PinOut from from NoComp/Frog - - -# NRF24 pinout by UberGuidoZ -2/A7 on FZ goes to MOSI/6 on nrf24l01
-3/A6 on FZ goes to MISO/7 on nrf24l01
-4/A4 on FZ goes to CSN/4 on nrf24l01
-5/B3 on FZ goes to SCK/5 on nrf24l01
-6/B2 on FZ goes to CE/3 on nrf24l01
-8/GND on FZ goes to GND/1 on nrf24l01
-9/3V3 on FZ goes to VCC/2 on nrf24l01
-IRQ/8 is left disconnected on nrf24l01 -![NRF_Pins](https://user-images.githubusercontent.com/57457139/178093717-39effd5c-ebe2-4253-b13c-70517d7902f9.png) -If the nRF module is acting a bit flakey, try adding a capacitor to the vcc/gnd lines! I've not tried the Plus model so it may have a bigger need for a cap. Otherwise, I haven't had any major issues. Anything from a 3.3 uF to 10 uF should do. (Watch your positive/negative placement! Negative to ground.) I learned if you wanna get fancy, include a 0.1 uF cap in parallel. The 3.3 uF to 10 uF will respond to slow freq changes while the 0.1 uF will respond to the high freq switching spikes that the larger one cannot. That said, a single 10 uF will likely suffice for the Mousejack attack. ¯\\\_(ツ)_/¯ -![NRF_Capacitor](https://user-images.githubusercontent.com/57457139/178169959-d030f9a6-d2ac-46af-af8b-470ff092c8a7.jpg) - diff --git a/applications/plugins/nrf24scan/Screenshot-1.png b/applications/plugins/nrf24scan/Screenshot-1.png deleted file mode 100644 index 61ca892d8..000000000 Binary files a/applications/plugins/nrf24scan/Screenshot-1.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/Screenshot-2.png b/applications/plugins/nrf24scan/Screenshot-2.png deleted file mode 100644 index 0e3ebf5b2..000000000 Binary files a/applications/plugins/nrf24scan/Screenshot-2.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/Screenshot-3.png b/applications/plugins/nrf24scan/Screenshot-3.png deleted file mode 100644 index 651052350..000000000 Binary files a/applications/plugins/nrf24scan/Screenshot-3.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/Screenshot-4.png b/applications/plugins/nrf24scan/Screenshot-4.png deleted file mode 100644 index 6351cdd3f..000000000 Binary files a/applications/plugins/nrf24scan/Screenshot-4.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/Screenshot-5.png b/applications/plugins/nrf24scan/Screenshot-5.png deleted file mode 100644 index d9e3173a2..000000000 Binary files a/applications/plugins/nrf24scan/Screenshot-5.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/addr-WCO1.txt b/applications/plugins/nrf24scan/addr-WCO1.txt deleted file mode 100644 index 658340d03..000000000 --- a/applications/plugins/nrf24scan/addr-WCO1.txt +++ /dev/null @@ -1,7 +0,0 @@ -Rate: 1 -Ch: 120 -ESB: 1 -DPL: 1 -CRC: 2 -Payload: 4 -P0: C8C8E5 diff --git a/applications/plugins/nrf24scan/addresses.txt b/applications/plugins/nrf24scan/addresses.txt deleted file mode 100644 index 1934efbf4..000000000 --- a/applications/plugins/nrf24scan/addresses.txt +++ /dev/null @@ -1,10 +0,0 @@ -Rate: 1 -Ch: 2 -ESB: 1 -DPL: 0 -CRC: 2 -P0: C8C8C0 -P1: C8C8C1 -P2: C2 -P3: C3 -P4: E5 diff --git a/applications/plugins/nrf24scan/application.fam b/applications/plugins/nrf24scan/application.fam deleted file mode 100644 index c346112e2..000000000 --- a/applications/plugins/nrf24scan/application.fam +++ /dev/null @@ -1,20 +0,0 @@ -App( - appid="Nrf24_Scanner", - name="[NRF24] Scanner", - apptype=FlipperAppType.EXTERNAL, - entry_point="nrf24scan_app", - cdefines=["APP_NRF24SCAN"], - requires=["gui"], - stack_size=2 * 1024, - order=60, - fap_icon="nrf24scan_10px.png", - fap_category="GPIO", - fap_private_libs=[ - Lib( - name="nrf24", - sources=[ - "nrf24.c", - ], - ), - ], -) diff --git a/applications/plugins/nrf24scan/lib/nrf24/nrf24.c b/applications/plugins/nrf24scan/lib/nrf24/nrf24.c deleted file mode 100644 index ab6f252a5..000000000 --- a/applications/plugins/nrf24scan/lib/nrf24/nrf24.c +++ /dev/null @@ -1,535 +0,0 @@ -// Modified by vad7, 25.11.2022 -// -#include "nrf24.h" -#include -#include -#include -#include -#include - -void nrf24_init() { - furi_hal_spi_bus_handle_init(nrf24_HANDLE); - furi_hal_spi_acquire(nrf24_HANDLE); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh); - furi_hal_gpio_write(nrf24_CE_PIN, false); -} - -void nrf24_deinit() { - furi_hal_spi_release(nrf24_HANDLE); - furi_hal_spi_bus_handle_deinit(nrf24_HANDLE); - furi_hal_gpio_write(nrf24_CE_PIN, false); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} - -void nrf24_spi_trx( - FuriHalSpiBusHandle* handle, - uint8_t* tx, - uint8_t* rx, - uint8_t size, - uint32_t timeout) { - UNUSED(timeout); - furi_hal_gpio_write(handle->cs, false); - furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT); - furi_hal_gpio_write(handle->cs, true); -} - -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data) { - uint8_t tx[2] = {W_REGISTER | (REGISTER_MASK & reg), data}; - uint8_t rx[2] = {0}; - nrf24_spi_trx(handle, tx, rx, 2, nrf24_TIMEOUT); - //FURI_LOG_D("NRF_WR", " #%02X=%02X", reg, data); - return rx[0]; -} - -uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = W_REGISTER | (REGISTER_MASK & reg); - memcpy(&tx[1], data, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - //FURI_LOG_D("NRF_WR", " #%02X(%02X)=0x%02X%02X%02X%02X%02X", reg, size, data[0], data[1], data[2], data[3], data[4] ); - return rx[0]; -} - -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = R_REGISTER | (REGISTER_MASK & reg); - memset(&tx[1], 0, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - memcpy(data, &rx[1], size); - return rx[0]; -} - -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_RX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_TX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle) { - uint8_t maclen; - nrf24_read_reg(handle, REG_SETUP_AW, &maclen, 1); - maclen &= 3; - return maclen + 2; -} - -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen) { - assert(maclen > 1 && maclen < 6); - uint8_t status = 0; - status = nrf24_write_reg(handle, REG_SETUP_AW, maclen - 2); - return status; -} - -uint8_t nrf24_status(FuriHalSpiBusHandle* handle) { - uint8_t status; - uint8_t tx[] = {R_REGISTER | (REGISTER_MASK & REG_STATUS)}; - nrf24_spi_trx(handle, tx, &status, 1, nrf24_TIMEOUT); - return status; -} - -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle) { - uint8_t setup = 0; - uint32_t rate = 0; - nrf24_read_reg(handle, REG_RF_SETUP, &setup, 1); - setup &= 0x28; - if(setup == 0x20) - rate = 250000; // 250kbps - else if(setup == 0x08) - rate = 2000000; // 2Mbps - else if(setup == 0x00) - rate = 1000000; // 1Mbps - - return rate; -} - -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate) { - uint8_t r6 = 0; - uint8_t status = 0; - if(!rate) rate = 2000000; - - nrf24_read_reg(handle, REG_RF_SETUP, &r6, 1); // RF_SETUP register - r6 = r6 & (~0x28); // Clear rate fields. - if(rate == 2000000) - r6 = r6 | 0x08; - else if(rate == 1000000) - r6 = r6; - else if(rate == 250000) - r6 = r6 | 0x20; - - status = nrf24_write_reg(handle, REG_RF_SETUP, r6); // Write new rate. - return status; -} - -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle) { - uint8_t channel = 0; - nrf24_read_reg(handle, REG_RF_CH, &channel, 1); - return channel; -} - -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan) { - uint8_t status; - status = nrf24_write_reg(handle, REG_RF_CH, chan); - return status; -} - -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_TX_ADDR, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe) { - uint8_t len = 0; - if(pipe > 5) pipe = 0; - nrf24_read_reg(handle, RX_PW_P0 + pipe, &len, 1); - return len; -} - -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) { - uint8_t status = 0; - status = nrf24_write_reg(handle, RX_PW_P0, len); - return status; -} - -uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) { - uint8_t status = 0; - uint8_t size = 0; - uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command - uint8_t tmp_packet[33] = {0}; - - status = nrf24_status(handle); - if(!(status & RX_DR)) { - tx_cmd[0] = R_REGISTER | (REGISTER_MASK & REG_FIFO_STATUS); - nrf24_spi_trx(handle, tx_cmd, tmp_packet, 2, nrf24_TIMEOUT); - if((tmp_packet[1] & 1) == 0) status |= RX_DR; // packet in FIFO buffer - } - if(status & RX_DR) { - if(full) - size = nrf24_get_packetlen(handle, (status >> 1) & 7); - else { - tx_cmd[0] = R_RX_PL_WID; tx_cmd[1] = 0; - nrf24_spi_trx(handle, tx_cmd, tmp_packet, 2, nrf24_TIMEOUT); - size = tmp_packet[1]; - } - if(size > 32) size = 32; - if(size == 0) size = 32; - tx_cmd[0] = R_RX_PAYLOAD; tx_cmd[1] = 0; - nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT); - memcpy(packet, &tmp_packet[1], size); - nrf24_write_reg(handle, REG_STATUS, RX_DR); // clear RX_DR - } else if(status & (TX_DS | MAX_RT)) { // MAX_RT, TX_DS - nrf24_write_reg(handle, REG_STATUS, (TX_DS | MAX_RT)); // clear RX_DR, MAX_RT. - } - - *packetsize = size; - return status; -} - -// Return 0 when error -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack) { - uint8_t status = 0; - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(tx, 0, size + 1); - memset(rx, 0, size + 1); - - if(!ack) - tx[0] = W_TX_PAYLOAD_NOACK; - else - tx[0] = W_TX_PAYLOAD; - - memcpy(&tx[1], payload, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - nrf24_set_tx_mode(handle); - - uint32_t start_time = furi_get_tick(); - while(!(status & (TX_DS | MAX_RT)) && furi_get_tick() - start_time < 2000UL) status = nrf24_status(handle); - - if(status & MAX_RT) nrf24_flush_tx(handle); - - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, TX_DS | MAX_RT); - return status & TX_DS; -} - -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg = cfg | 2; - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_delay_ms(1000); - return status; -} - -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfc; // clear bottom two bits to power down the radio - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(handle, REG_EN_RXADDR, 0x0); - furi_hal_gpio_write(nrf24_CE_PIN, false); - return status; -} - -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0F); // enable 2-byte CRC, PWR_UP, and PRIM_RX - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg |= 0x03; // PWR_UP, and PRIM_RX - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1 - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2); - return status; -} - -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - furi_hal_gpio_write(nrf24_CE_PIN, false); - nrf24_write_reg(handle, REG_STATUS, 0x30); - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0E); // enable 2-byte CRC, PWR_UP - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfe; // disable PRIM_RX - cfg |= 0x02; // PWR_UP - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2); - return status; -} - -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa) { - assert(channel <= 125); - assert(rate == 1 || rate == 2); - if(rate == 2) - rate = 8; // 2Mbps - else - rate = 0; // 1Mbps - - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, 0x70); // clear interrupts - if(disable_aa) - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - else - nrf24_write_reg(handle, REG_EN_AA, 0x1F); // Enable Shockburst - - nrf24_write_reg(handle, REG_DYNPD, 0x3F); // enable dynamic payload length on all pipes - if(noack) - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - else { - nrf24_write_reg(handle, REG_CONFIG, 0x0C); // 2 byte CRC - nrf24_write_reg(handle, REG_FEATURE, 0x07); // enable dyn payload and ack - nrf24_write_reg( - handle, REG_SETUP_RETR, 0x1f); // 15 retries for AA, 500us auto retransmit delay - } - - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - - if(maclen) nrf24_set_maclen(handle, maclen); - if(srcmac) nrf24_set_src_mac(handle, srcmac, maclen); - if(dstmac) nrf24_set_dst_mac(handle, dstmac, maclen); - - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - furi_delay_ms(200); -} - -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate) { - //uint8_t preamble[] = {0x55, 0x00}; // little endian - uint8_t preamble[] = {0xAA, 0x00}; // little endian - //uint8_t preamble[] = {0x00, 0x55}; // little endian - //uint8_t preamble[] = {0x00, 0xAA}; // little endian - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_write_reg(handle, REG_STATUS, 0x70); // clear interrupts - nrf24_write_reg(handle, REG_DYNPD, 0x0); // disable shockburst - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - nrf24_set_maclen(handle, 2); // shortest address - nrf24_set_src_mac(handle, preamble, 2); // set src mac to preamble bits to catch everything - nrf24_set_packetlen(handle, 32); // set max packet length - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - - // prime for RX, no checksum - nrf24_write_reg(handle, REG_CONFIG, 0x03); // PWR_UP and PRIM_RX, disable AA and CRC - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(100); -} - -void hexlify(uint8_t* in, uint8_t size, char* out) { - memset(out, 0, size * 2); - for(int i = 0; i < size; i++) - snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]); -} - -uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) { - uint64_t ret = 0; - for(int i = 0; i < size; i++) - if(bigendian) - ret |= bytes[i] << ((size - 1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 8; i++) { - if(bigendian) - out[i] = (val >> ((7 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian) { - uint32_t ret = 0; - for(int i = 0; i < 4; i++) - if(bigendian) - ret |= bytes[i] << ((3 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 4; i++) { - if(bigendian) - out[i] = (val >> ((3 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint64_t bytes_to_int16(uint8_t* bytes, bool bigendian) { - uint16_t ret = 0; - for(int i = 0; i < 2; i++) - if(bigendian) - ret |= bytes[i] << ((1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 2; i++) { - if(bigendian) - out[i] = (val >> ((1 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -// handle iffyness with preamble processing sometimes being a bit (literally) off -void alt_address_old(uint8_t* packet, uint8_t* altaddr) { - uint8_t macmess_hi_b[4]; - uint8_t macmess_lo_b[2]; - uint32_t macmess_hi; - uint16_t macmess_lo; - uint8_t preserved; - - // get first 6 bytes into 32-bit and 16-bit variables - memcpy(macmess_hi_b, packet, 4); - memcpy(macmess_lo_b, packet + 4, 2); - - macmess_hi = bytes_to_int32(macmess_hi_b, true); - - //preserve least 7 bits from hi that will be shifted down to lo - preserved = macmess_hi & 0x7f; - macmess_hi >>= 7; - - macmess_lo = bytes_to_int16(macmess_lo_b, true); - macmess_lo >>= 7; - macmess_lo = (preserved << 9) | macmess_lo; - int32_to_bytes(macmess_hi, macmess_hi_b, true); - int16_to_bytes(macmess_lo, macmess_lo_b, true); - memcpy(altaddr, &macmess_hi_b[1], 3); - memcpy(altaddr + 3, macmess_lo_b, 2); -} - -bool validate_address(uint8_t* addr) { - uint8_t bad[][3] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x00, 0x00}, {0xFF, 0xFF}}; - for(int i = 0; i < 4; i++) - for(int j = 0; j < 2; j++) - if(!memcmp(addr + j * 2, bad[i], 2)) return false; - - return true; -} - -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address) { - bool found = false; - uint8_t packet[32] = {0}; - uint8_t packetsize; - //char printit[65]; - uint8_t status = 0; - status = nrf24_rxpacket(handle, packet, &packetsize, true); - if(status & 0x40) { - if(validate_address(packet)) { - for(int i = 0; i < maclen; i++) address[i] = packet[maclen - 1 - i]; - - /* - alt_address(packet, packet); - - for(i = 0; i < maclen; i++) - address[i + 5] = packet[maclen - 1 - i]; - */ - - //memcpy(address, packet, maclen); - //hexlify(packet, packetsize, printit); - found = true; - } - } - - return found; -} - -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit) { - uint8_t ping_packet[] = {0x0f, 0x0f, 0x0f, 0x0f}; // this can be anything, we just need an ack - uint8_t ch = max_channel + 1; // means fail - nrf24_configure(handle, rate, srcmac, dstmac, maclen, 2, false, false); - for(ch = min_channel; ch <= max_channel + 1; ch++) { - nrf24_write_reg(handle, REG_RF_CH, ch); - if(nrf24_txpacket(handle, ping_packet, 4, true)) break; - } - - if(autoinit) { - FURI_LOG_D("nrf24", "initializing radio for channel %d", ch); - nrf24_configure(handle, rate, srcmac, dstmac, maclen, ch, false, false); - return ch; - } - - return ch; -} - -uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen) -{ - uint8_t addr[5]; - for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1]; - return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen); -} \ No newline at end of file diff --git a/applications/plugins/nrf24scan/lib/nrf24/nrf24.h b/applications/plugins/nrf24scan/lib/nrf24/nrf24.h deleted file mode 100644 index a2ac139a8..000000000 --- a/applications/plugins/nrf24scan/lib/nrf24/nrf24.h +++ /dev/null @@ -1,381 +0,0 @@ -#pragma once -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define R_REGISTER 0x00 -#define W_REGISTER 0x20 -#define REGISTER_MASK 0x1F -#define ACTIVATE 0x50 -#define R_RX_PL_WID 0x60 -#define R_RX_PAYLOAD 0x61 -#define W_TX_PAYLOAD 0xA0 -#define W_TX_PAYLOAD_NOACK 0xB0 -#define W_ACK_PAYLOAD 0xA8 -#define FLUSH_TX 0xE1 -#define FLUSH_RX 0xE2 -#define REUSE_TX_PL 0xE3 -#define RF24_NOP 0xFF - -#define REG_CONFIG 0x00 -#define REG_EN_AA 0x01 -#define REG_EN_RXADDR 0x02 -#define REG_SETUP_AW 0x03 -#define REG_SETUP_RETR 0x04 -#define REG_DYNPD 0x1C -#define REG_FEATURE 0x1D -#define REG_RF_SETUP 0x06 -#define REG_STATUS 0x07 -#define REG_RX_ADDR_P0 0x0A -#define REG_RX_ADDR_P1 0x0B -#define REG_RX_ADDR_P2 0x0C -#define REG_RX_ADDR_P3 0x0D -#define REG_RX_ADDR_P4 0x0E -#define REG_RX_ADDR_P5 0x0F -#define REG_RF_CH 0x05 -#define REG_TX_ADDR 0x10 -#define REG_FIFO_STATUS 0x17 - -#define RX_PW_P0 0x11 -#define RX_PW_P1 0x12 -#define RX_PW_P2 0x13 -#define RX_PW_P3 0x14 -#define RX_PW_P4 0x15 -#define RX_PW_P5 0x16 -#define RX_DR 0x40 -#define TX_DS 0x20 -#define MAX_RT 0x10 - -#define nrf24_TIMEOUT 500 -#define nrf24_CE_PIN &gpio_ext_pb2 -#define nrf24_HANDLE &furi_hal_spi_bus_handle_external - -/* Low level API */ - -/** Write device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * - * @return device status - */ -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data); - -/** Write buffer to device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * @param size - size of data to write - * - * @return device status - */ -uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Read device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param[out] data - pointer to data - * - * @return device status - */ -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Power up the radio for operation - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle); - -/** Power down the radio - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle); - -/** Sets the radio to RX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle); - -/** Sets the radio to TX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle); - -/*=============================================================================================================*/ - -/* High level API */ - -/** Must call this before using any other nrf24 API - * - */ -void nrf24_init(); - -/** Must call this when we end using nrf24 device - * - */ -void nrf24_deinit(); - -/** Send flush rx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle); - -/** Send flush tx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle); - -/** Gets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * pipe - pipe index (0..5) - * @return packet length in data pipe 0 - */ -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle, uint8_t pipe); - -/** Sets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * @param len - length to set - * - * @return device status - */ -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len); - -/** Gets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return MAC address length - */ -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle); - -/** Sets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length to set MAC address to, must be greater than 1 and less than 6 - * - * @return MAC address length - */ -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen); - -/** Gets the current status flags from the STATUS register - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return status flags - */ -uint8_t nrf24_status(FuriHalSpiBusHandle* handle); - -/** Gets the current transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return transfer rate in bps - */ -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle); - -/** Sets the transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * @param rate - the transfer rate in bps - * - * @return device status - */ -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate); - -/** Gets the current channel - * In nrf24, the channel number is multiplied times 1MHz and added to 2400MHz to get the frequency - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return channel - */ -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle); - -/** Sets the channel - * - * @param handle - pointer to FuriHalSpiHandle - * @param frequency - the frequency in hertz - * - * @return device status - */ -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan); - -/** Gets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Gets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Reads RX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] packet - the packet contents - * @param[out] packetsize - size of the received packet - * @param full - boolean set to true, packet length is determined by RX_PW_P0 register, false it is determined by dynamic payload length command - * - * @return device status - */ -uint8_t - nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full); - -/** Sends TX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param packet - the packet contents - * @param size - packet size - * @param ack - boolean to determine whether an ACK is required for the packet or not - * - * @return device status - */ -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack); - -/** Configure the radio - * This is not comprehensive, but covers a lot of the common configuration options that may be changed - * @param handle - pointer to FuriHalSpiHandle - * @param rate - transfer rate in Mbps (1 or 2) - * @param srcmac - source mac address - * @param dstmac - destination mac address - * @param maclen - length of mac address - * @param channel - channel to tune to - * @param noack - if true, disable auto-acknowledge - * @param disable_aa - if true, disable ShockBurst - * - */ -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa); - -// Set mac address (MSB first), Return: Status -uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen); - -/** Configures the radio for "promiscuous mode" and primes it for rx - * This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were. - * See http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html for details. - * @param handle - pointer to FuriHalSpiHandle - * @param channel - channel to tune to - * @param rate - transfer rate in Mbps (1 or 2) - */ -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate); - -/** Listens for a packet and returns first possible address sniffed - * Call this only after calling nrf24_init_promisc_mode - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length of target mac address - * @param[out] addresses - sniffed address - * - * @return success - */ -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address); - -/** Sends ping packet on each channel for designated tx mac looking for ack - * - * @param handle - pointer to FuriHalSpiHandle - * @param srcmac - source address - * @param dstmac - destination address - * @param maclen - length of address - * @param rate - transfer rate in Mbps (1 or 2) - * @param min_channel - channel to start with - * @param max_channel - channel to end at - * @param autoinit - if true, automatically configure radio for this channel - * - * @return channel that the address is listening on, if this value is above the max_channel param, it failed - */ -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit); - -/** Converts 64 bit value into uint8_t array - * @param val - 64-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian); - -/** Converts 32 bit value into uint8_t array - * @param val - 32-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian); - -/** Converts uint8_t array into 32 bit value - * @param bytes - uint8_t array - * @param bigendian - if true, convert as big endian, otherwise little endian - * - * @return 32-bit value - */ -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/nrf24scan/nrf24_packet_decoder.py b/applications/plugins/nrf24scan/nrf24_packet_decoder.py deleted file mode 100644 index 9e1a42a18..000000000 --- a/applications/plugins/nrf24scan/nrf24_packet_decoder.py +++ /dev/null @@ -1,99 +0,0 @@ -# -# NRF24L01+ Enhanced ShockBurst packets decoder -# -payload_len_default = 4 -packets = \ -( - '10101010 11101110 00000011 00001000 00001011 01000111 000100 10 0 10101010 10101010 10101010 10101010 00011101', - '10101010 11001000 11001000 11000011 110011 10 0 00001011 00000011 00000101 00000000 0010001100100000', -) - -def bin2hex(x): - def bin2hex_helper(r): - while r: - yield r[0:2].upper() - r = r[2:] - - fmt = "{0:0" + str(int(len(x) / 8 * 2)) + "X}" - hex_data = fmt.format(int(x, 2)) - return list(bin2hex_helper(hex_data)) - - -def split_packet(packet, parts): - """Split a string of 1s and 0s into multiple substrings as specified by parts. - Example: "111000011000", (3, 4, 2) -> ["111", "0000", "11", "000"] - :param packet: String of 1s and 0s - :param parts: Tuple of length of substrings - :return: list of substrings - """ - out = [] - packet = packet.replace(' ', '') - for part_length in parts: - out.append(packet[0:part_length]) - packet = packet[part_length:] - out.append(packet) - return out - - -def parse_packet(packet, address_length): - """Split a packet into its fields and return them as tuple.""" - preamble, address, payload_length, pid, no_ack, rest = split_packet(packet=packet, - parts=(8, 8 * address_length, 6, 2, 1)) - payload, crc = split_packet(packet=rest, parts=((payload_len_default if int(payload_length, 2) > 32 else int(payload_length, 2)) * 8,)) - - assert preamble in ('10101010', '01010101') - assert len(crc) in (8, 16) - - return preamble, address, payload_length, pid, no_ack, payload, crc - - -def crc(bits, size=8): - """Calculate the crc value for the polynomial initialized with 0xFF/0xFFFF) - :param size: 8 or 16 bit crc - :param bits: String of 1s and 0s - :return: - :polynomial: 1 byte CRC - standard is 0x107 = 0b100000111 = x^8+x^2+x^1+1, result the same for 0x07 - :polynomial: 2 byte CRC - standard is 0x11021 = X^16+X^12+X^5+1, result the same for 0x1021 - """ - if size == 8: - polynomial = 0x107 - crc = 0xFF - else: - polynomial = 0x11021 - crc = 0xFFFF - max_crc_value = (1 << size) - 1 # e.g. 0xFF for mode 8bit-crc - for bit in bits: - bit = int(bit, 2) - crc <<= 1 - if (crc >> size) ^ bit: # top most lfsr bit xor current data bit - crc ^= polynomial - crc &= max_crc_value # trim the crc to reject carry over bits - return crc - - -if __name__ == '__main__': - for packet in packets: - fld = packet.split(' '); - address_length = -1 - for f in fld: - if len(f) == 6: break - address_length += 1 - preamble, address, payload_length, pid, no_ack, payload, crc_received = \ - parse_packet(packet=packet, address_length=address_length) - crc_size = len(crc_received) - crc_received = hex(int(crc_received, 2)) - print(f"Packet: {packet}") - print('\n'.join(( - f'Preamble: {preamble}', - f'Address: {address_length} bytes - {bin2hex(address)}', - f'Payload length in packet: {int(payload_length, 2)}, used: {(payload_len_default if int(payload_length, 2) > 32 else int(payload_length, 2))}', - f'Pid: {int(pid, 2)}', - f'No_ack: {int(no_ack, 2) == 1}', - f'Payload: {bin2hex(payload)}', - f'CRC{crc_size}: {crc_received}'))) - crc_calculated = hex(crc(address + payload_length + pid + no_ack + payload, size=crc_size)) - if crc_received == crc_calculated: - print('CRC is valid!') - else: - print(f'CRC mismatch! Calculated CRC is f{crc_calculated}.') - print('-------------') diff --git a/applications/plugins/nrf24scan/nrf24scan.c b/applications/plugins/nrf24scan/nrf24scan.c deleted file mode 100644 index 4056c9d98..000000000 --- a/applications/plugins/nrf24scan/nrf24scan.c +++ /dev/null @@ -1,1350 +0,0 @@ -// -// Written by vad7, 20.11.2022. -// -#include "nrf24scan.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TAG "nrf24scan" -#define VERSION "1.8" -#define MAX_CHANNEL 125 -#define MAX_ADDR 6 - -#define SCAN_APP_PATH_FOLDER "/ext/nrf24scan" -#define SETTINGS_FILENAME "addresses.txt" // Settings file format (1 parameter per line): -// SNIFF - if present then sniff mode -// Rate: 0/1/2 - rate in Mbps (=0.25/1/2) -// Ch: 0..125 - default channel -// ESB: 0/1 (1 - Enhanced ShockBurst) -// DPL: 0/1 (1 - Dynamic Payload Length) -// CRC: 0/1/2 (CRC length) -// Payload: 1..32 (bytes) -// P0: address P0 in hex (5 byte, LSB last) -// P1: address P1 in hex (5 byte, LSB last) -// P2: address P2, LSB in hex (1 byte) -// P3: address P3, LSB in hex (1 byte) -// P4: address P4, LSB in hex (1 byte) -// P5: address P5, LSB in hex (1 byte) -// captured data: -// first byte = { RAW packet flag (0x80/0x00) } + { channel number } -// second byte = { Payload len 5 bits, 0 = 32 } + {{ RAW packet: ESB flag 0x04/0x00 + address size-2 if RAW packet } or { pipe #(0..5) }}, -// ... up to MAX_LOG_RECORDS-1 -#define SNIFF_FILENAME "sniff.txt" // settings for sniff mode -#define LOG_FILENAME "log" -#define LOG_FILEEXT ".txt" -#define MAX_LOG_RECORDS 100 -#define LOG_REC_SIZE 34 // max packet size -#define VIEW_LOG_MAX_X 22 -#define VIEW_LOG_WIDTH_B 10 // bytes - -const char SettingsFld_Rate[] = "Rate:"; -const char SettingsFld_Ch[] = "Ch:"; -const char SettingsFld_ESB[] = "ESB:"; -const char SettingsFld_DPL[] = "DPL:"; -const char SettingsFld_CRC[] = "CRC:"; -const char SettingsFld_Payload[] = "Payload:"; -const char SettingsFld_Sniff[] = "SNIFF"; -char SettingsFld_Addr = 'P'; - -Nrf24Scan* APP; -uint8_t what_doing = 0; // 0 - setup, 1 - view log, 2 - view addresses -uint8_t what_to_do = 1; // 0 - view, 1 - view & sniff, 2 - view & read -uint32_t key_press_seq_ok = 0; -uint8_t save_settings = 0; -char screen_buf[64]; -char addr_file_name[32]; -uint8_t NRF_rate = 1; // 0 - 250Kbps, 1 - 1Mbps, 2 - 2Mbps -uint8_t NRF_channel = 0; // 0..125 -uint8_t NRF_ESB = 1; // 0 - ShockBurst, 1 - Enhanced ShockBurst -uint8_t NRF_DPL = 0; // 1 - Dynamic Payload Length -uint8_t NRF_CRC = 2; // 1 - No, 1 - CRC 1byte, 2 - CRC 2byte -uint8_t NRF_Payload = 32; // len in bytes, max 32 -uint8_t NRF_Sniff_payload_max = 28; -uint8_t NRF_AA_OFF = 0; // Disable Auto Acknowledgement -bool NRF_ERROR = 0; - -struct { - uint8_t addr_P0[5]; // MSB first - uint8_t addr_P1[5]; // MSB first - uint8_t addr_P2; // LSB only, MSB bytes equal addr_P1 - uint8_t addr_P3; // LSB only, MSB bytes equal addr_P1 - uint8_t addr_P4; // LSB only, MSB bytes equal addr_P1 - uint8_t addr_P5; // LSB only, MSB bytes equal addr_P1 - uint8_t addr_len; // 2..5 - uint8_t addr_count; -} addrs; - -int8_t log_to_file = 0; // 0 - no, 1 - yes(new), 2 - append, -1 - only clear -uint16_t log_arr_idx; -uint16_t view_log_arr_idx = 0; -uint16_t view_log_arr_x = 0; -bool save_to_new_log = true; -uint16_t last_packet_send = -1; -uint8_t last_packet_send_st = 0; -int16_t find_channel_period = 0; // sec -uint8_t menu_selected = 0; -uint32_t start_time; -uint8_t view_log_decode_PCF = - 0; // view log: 1 - decode packet control field (9b) when ESB off. After pipe # (hex): -uint8_t view_log_decode_CRC = 0; // CRC bytes - 1/2, 0 - none - -#define menu_selected_max 5 -enum { - Menu_open_file = 0, - Menu_enter_channel, - Menu_enter_rate, - Menu_enter_scan_period, - Menu_log, - Menu_ok -}; - -//#define MIN(a, b) ((a> 7)); - arr++; - out += 2; - } while(--bytes); -} - -void clear_log() { - log_arr_idx = 0; - view_log_arr_idx = 0; - last_packet_send = -1; -} - -void allocate_log_array() { - APP->log_arr = malloc(LOG_REC_SIZE * MAX_LOG_RECORDS); - if(APP->log_arr == NULL) { - FURI_LOG_E(TAG, "Not enouch memory: %d", LOG_REC_SIZE * MAX_LOG_RECORDS); - strcpy(addr_file_name, "MEMORY LOW!"); - } - clear_log(); -} - -void write_to_log_file(Storage* storage, bool f_settings) { - if(log_arr_idx == 0 && !f_settings) return; - Stream* file_stream = file_stream_alloc(storage); - FuriString* str = furi_string_alloc(); - furi_string_set(str, SCAN_APP_PATH_FOLDER); - furi_string_cat(str, "/"); - bool fl; - if(f_settings) { - furi_string_cat(str, SETTINGS_FILENAME); - fl = file_stream_open( - file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_CREATE_ALWAYS); - if(!fl) file_stream_close(file_stream); - } else { - furi_string_cat(str, LOG_FILENAME); - furi_string_cat(str, LOG_FILEEXT); - if(save_to_new_log) { - int cnt = 1; - do { - fl = file_stream_open( - file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_CREATE_NEW); - if(fl) break; - file_stream_close(file_stream); - furi_string_set(str, SCAN_APP_PATH_FOLDER); - furi_string_cat(str, "/"); - furi_string_cat(str, LOG_FILENAME); - furi_string_cat_printf(str, "-%02d", cnt); - furi_string_cat(str, LOG_FILEEXT); - } while(++cnt < 100); - if(!fl) { - FURI_LOG_E(TAG, "Failed to create new log file"); - notification_message(APP->notification, &sequence_blink_red_100); - } - } else { - fl = file_stream_open( - file_stream, furi_string_get_cstr(str), FSAM_READ_WRITE, FSOM_OPEN_APPEND); - if(fl) { - if(stream_size(file_stream) == 0) save_to_new_log = true; - } else - file_stream_close(file_stream); - } - } - if(fl) { - FURI_LOG_D(TAG, "Save to %s", furi_string_get_cstr(str)); - if(save_to_new_log || f_settings) { - if(what_to_do == 1) - furi_string_printf(str, "%s\n", SettingsFld_Sniff); - else - furi_string_reset(str); - furi_string_cat_printf( - str, - "%s %d\n%s %d\n%s %d\n", - SettingsFld_Rate, - NRF_rate, - SettingsFld_Ch, - NRF_channel, - SettingsFld_ESB, - NRF_ESB); - furi_string_cat_printf( - str, - "%s %d\n%s %d\n%s %d\n", - SettingsFld_DPL, - NRF_DPL, - SettingsFld_CRC, - NRF_CRC, - SettingsFld_Payload, - NRF_Payload); - furi_string_cat_printf(str, "P0: "); - add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P0, addrs.addr_len); - furi_string_cat(str, "\n"); - if(addrs.addr_count > 1) { - furi_string_cat_printf(str, "P1: "); - add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P1, addrs.addr_len); - furi_string_cat(str, "\n"); - } - if(addrs.addr_count > 2) { - furi_string_cat_printf(str, "P2: "); - furi_string_cat_printf(str, "%02X\n", addrs.addr_P2); - } - if(addrs.addr_count > 3) { - furi_string_cat_printf(str, "P3: "); - furi_string_cat_printf(str, "%02X\n", addrs.addr_P3); - } - if(addrs.addr_count > 4) { - furi_string_cat_printf(str, "P4: "); - furi_string_cat_printf(str, "%02X\n", addrs.addr_P4); - } - if(addrs.addr_count > 5) { - furi_string_cat_printf(str, "P5: "); - furi_string_cat_printf(str, "%02X\n", addrs.addr_P5); - } - if(!(fl = stream_write_string(file_stream, str) == furi_string_size(str))) { - FURI_LOG_E(TAG, "Failed to write header to file!"); - notification_message(APP->notification, &sequence_blink_red_100); - } - } - if(fl) { - if(f_settings) { - save_settings = 0; - if(strcmp(addr_file_name, "NONE") == 0) strcpy(addr_file_name, SETTINGS_FILENAME); - } else { - int i = 0; - for(; i < log_arr_idx; i++) { - furi_string_reset(str); - uint8_t* ptr = APP->log_arr + i * LOG_REC_SIZE; - int len; - if(ptr[0] & 0x80) { // RAW - len = (ptr[1] & 0b11) + 2 + ((ptr[1] & 0b100) ? 2 : 0) + (ptr[1] >> 3) + - 2; // addr + PCF? + payload + crcmax - } else { - len = (ptr[1] >> 3); - if(len == 0) len = 32; - } - if(len < NRF_Payload) len = NRF_Payload; - add_to_furi_str_hex_bytes(str, (char*)ptr, len + 2); - furi_string_cat(str, "\n"); - if(stream_write_string(file_stream, str) != furi_string_size(str)) { - FURI_LOG_E(TAG, "Failed to write to file!"); - break; - } - } - if(i == log_arr_idx) { - notification_message(APP->notification, &sequence_blink_yellow_100); - FURI_LOG_D(TAG, "File saved"); - } - save_to_new_log = false; - } - } - file_stream_close(file_stream); - } else { - FURI_LOG_E(TAG, "Failed to open file %s", furi_string_get_cstr(str)); - notification_message(APP->notification, &sequence_blink_red_100); - } - stream_free(file_stream); - furi_string_free(str); -} - -static bool select_settings_file(Stream* stream) { - DialogsApp* dialogs = furi_record_open("dialogs"); - bool result = false; - FuriString* path; - path = furi_string_alloc(); - furi_string_set(path, SCAN_APP_PATH_FOLDER); - - DialogsFileBrowserOptions browser_options; - dialog_file_browser_set_basic_options(&browser_options, ".txt", NULL); - browser_options.hide_ext = false; - - bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options); - - furi_record_close("dialogs"); - if(ret) { - if(!file_stream_open(stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path)); - file_stream_close(stream); - } else { - FURI_LOG_D(TAG, "Open file \"%s\"", furi_string_get_cstr(path)); - strncpy( - addr_file_name, - furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER), - sizeof(addr_file_name)); - result = true; - } - } - furi_string_free(path); - return result; -} - -// 0 - success, otherwise an error -static uint8_t load_settings_file(Stream* file_stream) { - size_t file_size = 0; - char* file_buf; - uint8_t err = 5; - file_size = stream_size(file_stream); - if(file_size == (size_t)0) { - FURI_LOG_D(TAG, "load failed. file_size: %d", file_size); - return 1; - } - file_size = MIN(file_size, (size_t)LOG_REC_SIZE * MAX_LOG_RECORDS * 2 + 100); - file_buf = malloc(file_size + 1); - if(file_buf == NULL) { - FURI_LOG_D(TAG, "Memory low, need: %d", file_size); - return 2; - } - memset(file_buf, 0, file_size + 1); - if(stream_read(file_stream, (uint8_t*)file_buf, file_size) == file_size) { - FURI_LOG_D(TAG, "Loading settings file"); - char* line_ptr = file_buf; - int16_t line_num = 0; - memset((uint8_t*)&addrs, 0, sizeof(addrs)); - what_to_do = 2; - bool log_loaded = false; - while(line_ptr && (size_t)(line_ptr - file_buf) < file_size) { - char* end_ptr = strstr((char*)line_ptr, "\n"); - if(end_ptr == NULL) - end_ptr = file_buf + file_size; - else - *end_ptr = '\0'; - int line_len = end_ptr - line_ptr; - if(*line_ptr == '\r' || line_len == 0) { - line_ptr = end_ptr + 1; - continue; - } - if(*(end_ptr - 1) < '0') { - *(end_ptr - 1) = '\0'; - line_len--; - } - //FURI_LOG_D(TAG, " L#%d: [%d]%s", line_num, line_len, line_ptr); - if(strncmp(line_ptr, SettingsFld_Rate, sizeof(SettingsFld_Rate) - 1) == 0) { - NRF_rate = atoi(line_ptr + sizeof(SettingsFld_Rate)); - } else if(strncmp(line_ptr, SettingsFld_Ch, sizeof(SettingsFld_Ch) - 1) == 0) { - NRF_channel = atoi(line_ptr + sizeof(SettingsFld_Ch)); - } else if(strncmp(line_ptr, SettingsFld_ESB, sizeof(SettingsFld_ESB) - 1) == 0) { - NRF_ESB = atoi(line_ptr + sizeof(SettingsFld_ESB)); - } else if(strncmp(line_ptr, SettingsFld_DPL, sizeof(SettingsFld_DPL) - 1) == 0) { - NRF_DPL = atoi(line_ptr + sizeof(SettingsFld_DPL)); - } else if(strncmp(line_ptr, SettingsFld_CRC, sizeof(SettingsFld_CRC) - 1) == 0) { - NRF_CRC = atoi(line_ptr + sizeof(SettingsFld_CRC)); - if(what_to_do == 1) view_log_decode_CRC = NRF_CRC; - } else if(strncmp(line_ptr, SettingsFld_Payload, sizeof(SettingsFld_Payload) - 1) == 0) { - NRF_Payload = atoi(line_ptr + sizeof(SettingsFld_Payload)); - if(NRF_Payload == 0 || NRF_Payload > 32) NRF_Payload = 32; - } else if(strncmp(line_ptr, SettingsFld_Sniff, sizeof(SettingsFld_Sniff) - 1) == 0) { - what_to_do = 1; - } else if(*line_ptr == SettingsFld_Addr) { - char a = *(++line_ptr); - line_ptr += 3; - switch(a) { - case '0': - addrs.addr_len = - ConvertHexToArray(line_ptr, addrs.addr_P0, what_to_do == 1 ? 3 : 5); - //FURI_LOG_D(TAG, " +Addr(%d): %02X%02X%02X...", addrs.addr_len, addrs.addr_P0[0], addrs.addr_P0[1], addrs.addr_P0[2]); - if(addrs.addr_len >= 2) err = 0; - break; - case '1': - ConvertHexToArray(line_ptr, addrs.addr_P1, what_to_do == 1 ? 3 : 5); - //FURI_LOG_D(TAG, " +Addr: %02X%02X%02X...", addrs.addr_P0[1], addrs.addr_P1[1], addrs.addr_P1[2]); - break; - case '2': - ConvertHexToArray(line_ptr, &addrs.addr_P2, 1); - break; - case '3': - ConvertHexToArray(line_ptr, &addrs.addr_P3, 1); - break; - case '4': - ConvertHexToArray(line_ptr, &addrs.addr_P4, 1); - break; - case '5': - ConvertHexToArray(line_ptr, &addrs.addr_P5, 1); - break; - default: - a = 0; - break; - } - if(err == 0 && a) addrs.addr_count = a - '0' + 1; - } else if(line_len >= 3 * 2) { // data - if(!log_loaded) { - clear_log(); - what_to_do = 0; - log_loaded = true; - } - if(log_arr_idx < MAX_LOG_RECORDS - 1) { - ConvertHexToArray( - line_ptr, APP->log_arr + log_arr_idx * LOG_REC_SIZE, LOG_REC_SIZE); - log_arr_idx++; - } - } - line_ptr = end_ptr + 1; - line_num++; - } - } else { - FURI_LOG_D(TAG, "load failed. file size: %d", file_size); - err = 4; - } - free(file_buf); - return err; -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void prepare_nrf24(bool fsend_packet) { - nrf24_write_reg(nrf24_HANDLE, REG_STATUS, 0x70); // clear interrupts - nrf24_write_reg(nrf24_HANDLE, REG_RF_SETUP, NRF_rate); - uint8_t erx_addr = (1 << 0); // Enable RX_P0 - if(!fsend_packet) { - if(addrs.addr_count == 0) return; - uint8_t payload = NRF_Payload; - if(what_to_do == 1) { // SNIFF - payload += 5 + NRF_CRC; // + addr_max + CRC - if(NRF_ESB) payload += 2; - if(payload > 32) payload = 32; - nrf24_write_reg(nrf24_HANDLE, REG_CONFIG, 0x70); // Mask all interrupts - nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // Automatic Retransmission - nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // Auto acknowledgement - nrf24_write_reg( - nrf24_HANDLE, - REG_FEATURE, - 0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload - } else { - nrf24_write_reg( - nrf24_HANDLE, - REG_CONFIG, - 0x70 | ((NRF_CRC == 1 ? 0b1000 : - NRF_CRC == 2 ? 0b1100 : - 0))); // Mask all interrupts - nrf24_write_reg( - nrf24_HANDLE, REG_SETUP_RETR, NRF_ESB ? 0x11 : 0); // Automatic Retransmission - nrf24_write_reg( - nrf24_HANDLE, - REG_EN_AA, - NRF_AA_OFF || !NRF_ESB ? 0 : 0x3F); // Auto acknowledgement - nrf24_write_reg( - nrf24_HANDLE, - REG_FEATURE, - NRF_DPL ? - 4 + 1 : - 1); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload - } - nrf24_set_maclen(nrf24_HANDLE, addrs.addr_len); - nrf24_set_mac(REG_RX_ADDR_P0, addrs.addr_P0, addrs.addr_len); - uint8_t tmp[5] = {0}; - nrf24_read_reg(nrf24_HANDLE, REG_RX_ADDR_P0, tmp, addrs.addr_len); - for(uint8_t i = 0; i < addrs.addr_len / 2; i++) { - uint8_t tb = tmp[i]; - tmp[i] = tmp[addrs.addr_len - i - 1]; - tmp[addrs.addr_len - i - 1] = tb; - } - NRF_ERROR = memcmp(addrs.addr_P0, tmp, addrs.addr_len) != 0; - FURI_LOG_D(TAG, "Payload: %d", payload); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P0, payload); - if(addrs.addr_count > 1) { - nrf24_set_mac(REG_RX_ADDR_P1, addrs.addr_P1, addrs.addr_len); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P1, payload); - erx_addr |= (1 << 1); // Enable RX_P1 - } else - nrf24_write_reg(nrf24_HANDLE, RX_PW_P1, 0); - if(addrs.addr_count > 2) { - nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P2, &addrs.addr_P2, 1); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P2, payload); - erx_addr |= (1 << 2); // Enable RX_P2 - } else - nrf24_write_reg(nrf24_HANDLE, RX_PW_P2, 0); - if(addrs.addr_count > 3) { - nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P3, &addrs.addr_P3, 1); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P3, payload); - erx_addr |= (1 << 3); // Enable RX_P3 - } else - nrf24_write_reg(nrf24_HANDLE, RX_PW_P3, 0); - if(addrs.addr_count > 4) { - nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P4, &addrs.addr_P4, 1); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P4, payload); - erx_addr |= (1 << 4); // Enable RX_P4 - } else - nrf24_write_reg(nrf24_HANDLE, RX_PW_P4, 0); - if(addrs.addr_count > 5) { - nrf24_write_buf_reg(nrf24_HANDLE, REG_RX_ADDR_P5, &addrs.addr_P5, 1); - nrf24_write_reg(nrf24_HANDLE, RX_PW_P5, payload); - erx_addr |= (1 << 5); // Enable RX_P5 - } else - nrf24_write_reg(nrf24_HANDLE, RX_PW_P5, 0); - nrf24_write_reg(nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg - nrf24_write_reg(nrf24_HANDLE, REG_EN_RXADDR, erx_addr); - nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel); - } - nrf24_flush_rx(nrf24_HANDLE); - nrf24_flush_tx(nrf24_HANDLE); - nrf24_set_idle(nrf24_HANDLE); -} - -static void start_scanning() { - FURI_LOG_D(TAG, "Start proc-%d: Ch=%d Rate=%d", what_to_do, NRF_channel, NRF_rate); - if(what_to_do == 1) { - NRF_Sniff_payload_max = 32 - 3 - (NRF_ESB ? 2 : 0) - NRF_CRC + (addrs.addr_len - 2); - if(NRF_Payload > NRF_Sniff_payload_max) NRF_Payload = NRF_Sniff_payload_max; - view_log_decode_CRC = NRF_CRC; - } - prepare_nrf24(false); - if(NRF_ERROR) { - FURI_LOG_E(TAG, "NRF R/W ERROR!"); - return; - } - nrf24_set_rx_mode(nrf24_HANDLE); - start_time = furi_get_tick(); -} - -// start bitnum = 7 -uint16_t calc_crc(uint32_t crc, uint8_t* ptr, uint8_t bitnum, uint16_t bits) { - //uint8_t bitnum = 7; - uint32_t crc_high, polynom; - if(view_log_decode_CRC == 2) { - crc_high = (1 << 16); - polynom = 0x11021; // X^16+X^12+X^5+1 - } else { - crc_high = (1 << 8); - polynom = 0x107; // x^8+x^2+x^1+1 - } - while(bits--) { - crc <<= 1; - if(((crc & crc_high) != 0) ^ ((*ptr >> bitnum) & 1)) crc ^= polynom; - if(bitnum == 0) { - ptr++; - bitnum = 7; - } else - bitnum--; - } - return crc & (view_log_decode_CRC == 2 ? 0xFFFF : 0xFF); -} - -// shifted 1 bit right -uint16_t get_shifted_crc(uint8_t* pcrc) { - uint16_t crc = ((uint8_t)(*pcrc << 1)) | (*(pcrc + 1) >> 7); - if(view_log_decode_CRC == 2) { - crc = (crc << 8) | (((uint8_t)(*(pcrc + 1) << 1))) | (*(pcrc + 2) >> 7); - } - return crc; -} - -bool check_packet(uint8_t* pkt, uint8_t size) { - if(furi_log_get_level() == FuriLogLevelDebug) { - char dbuf[65]; - dbuf[0] = 0; - add_to_str_hex_bytes(dbuf, (char*)pkt, size); - FURI_LOG_D(TAG, "PKT%d: %s (%d)", *(pkt - 1), dbuf, size); - } - for(uint8_t addr_size = 3; addr_size <= 5; addr_size++) { - if(NRF_ESB) { - uint8_t b = *(pkt + addr_size) >> 2; - if((b > NRF_Payload - (addr_size - 3) && b != 0x33)) continue; - if(b != 0x33) { // DPL - uint16_t crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF; - crc = calc_crc(crc, pkt, 7, 9 + (b + addr_size) * 8); - //FURI_LOG_D(TAG, "DCRC: %X - %X", crc, get_shifted_crc(pkt + b + 1)); - if(crc == get_shifted_crc(pkt + b + addr_size + 1)) { - *(pkt - 1) = ((b & 0x1F) << 3) + 0b100 + (addr_size - 2); - FURI_LOG_D(TAG, "VALID CRC %X: dpl: %d, addr: %d", crc, b, addr_size); - return true; - } - } else { - for(uint8_t i = 0; i < size - view_log_decode_CRC; i++) { - uint16_t crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF; - crc = calc_crc(crc, pkt, 7, (addr_size + i) * 8 + 9); - //FURI_LOG_D(TAG, "CRC: %X - %X", crc, get_shifted_crc(pkt + addr_size + i + 1)); - if(crc == get_shifted_crc(pkt + addr_size + i + 1)) { - *(pkt - 1) = ((i & 0x1F) << 3) + 0b100 + (addr_size - 2); - FURI_LOG_D(TAG, "VALID CRC %X: pl: %d, addr: %d", crc, i, addr_size); - return true; - } - } - } - } else { - for(uint8_t i = 0; i < size - view_log_decode_CRC; i++) { - uint16_t crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF; - crc = calc_crc(crc, pkt, 7, (addr_size + i) * 8); - if((view_log_decode_CRC == 1 && crc == *(pkt + addr_size + i + 1)) || - (view_log_decode_CRC == 2 && - crc == ((*(pkt + addr_size + i + 1) << 8) | *(pkt + addr_size + i + 2)))) { - *(pkt - 1) = ((i & 0x1F) << 3) + 0b000 + (addr_size - 2); - FURI_LOG_D(TAG, "VALID CRC %X: pl: %d, addr: %d", crc, i, addr_size); - return true; - } - } - } - } - return false; -} - -bool nrf24_read_newpacket() { - if(APP->log_arr == NULL) return false; - bool found = false; - uint8_t packetsize; - uint8_t* ptr = APP->log_arr + log_arr_idx * LOG_REC_SIZE; - uint8_t st = nrf24_rxpacket( - nrf24_HANDLE, ptr + 2 + (what_to_do == 1 ? addrs.addr_len - 2 : 0), &packetsize, !NRF_DPL); - if(st & RX_DR) { - st = (st >> 1) & 7; // pipe # - if(what_to_do == 1) { - *ptr++ = NRF_channel | 0x80; - *ptr++ = st; // pipe # - if(addrs.addr_len > 2) { - *ptr = st == 0 ? addrs.addr_P0[2] : - st == 1 ? addrs.addr_P1[2] : - st == 2 ? addrs.addr_P2 : - st == 3 ? addrs.addr_P3 : - st == 4 ? addrs.addr_P4 : - addrs.addr_P5; - } else { - if(*ptr == 0x55 || *ptr == 0xAA || *ptr == 0x00 || *ptr == 0xFF) - return found; // skip pkt when address begin with - } - if(!check_packet(ptr, packetsize)) { - if(addrs.addr_len > 2) return false; // skip if mac MSB added to preamble - if(addrs.addr_count == 1 && - addrs.addr_P0[1] == 0xAA) { // Shift packet right by one bit if preamble = 0xAA - for(uint8_t i = packetsize - 1; i > 0; i--) { - ptr[i] = ptr[i - 1] << 7 | ptr[i] >> 1; - } - *ptr >>= 1; - //if((st == 0 && (addrs.addr_P0[1] & 1)) || (st == 1 && (addrs.addr_P1[1] & 1))) *ptr |= 0x80; - if(!check_packet(ptr, packetsize)) return false; - } else - return false; - } - } else { - *ptr++ = NRF_channel; - *ptr++ = ((packetsize & 0x1F) << 3) | st; // payload size + pipe # - } - if(packetsize < 32) memset(ptr + packetsize, 0, 32 - packetsize); - if(log_arr_idx < MAX_LOG_RECORDS - 1) { - log_arr_idx++; - } else { - if(log_to_file == 1 || log_to_file == 2) { - write_to_log_file(APP->storage, false); - clear_log(); - } else { - memmove(APP->log_arr, APP->log_arr + LOG_REC_SIZE, log_arr_idx * LOG_REC_SIZE); - } - } - FURI_LOG_D(TAG, "Found packet #%d pipe %d", log_arr_idx, st); - notification_message(APP->notification, &sequence_blink_white_100); - found = true; - } - return found; -} - -bool nrf24_send_packet() { - if(log_arr_idx == 0) return false; - prepare_nrf24(!what_to_do); - uint8_t* ptr = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE; - nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, *ptr & 0x7F); - if(*ptr & 0x80) { // RAW packet - //uint8_t pktinfo = *(ptr + 1); - //nrf24_set_maclen(nrf24_HANDLE, (pktinfo & 0b11) + 2); - //if(pktinfo & 0b100) { // ESB - nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // No Automatic Retransmission - nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // No Auto acknowledgement - //} - //uint8_t alen = (*(ptr + 2) & 0b11) + 2; - uint8_t adr[2]; - adr[0] = ptr[2]; - adr[1] = ptr[3]; - nrf24_set_maclen(nrf24_HANDLE, 2); - nrf24_set_mac(REG_RX_ADDR_P0, adr, 2); - nrf24_set_mac(REG_TX_ADDR, adr, 2); - last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, ptr + 2 + 2, 32 - 2, false); - } else { - nrf24_write_reg( - nrf24_HANDLE, REG_SETUP_RETR, NRF_ESB ? 0x11 : 0); // Automatic Retransmission - nrf24_write_reg( - nrf24_HANDLE, REG_EN_AA, NRF_AA_OFF || !NRF_ESB ? 0 : 0x3F); // Auto acknowledgement - uint8_t* adr; - uint8_t a = *(ptr + 1) & 0b111; - if(a < 2) { - if(a == 0) - adr = addrs.addr_P0; - else - adr = addrs.addr_P1; - nrf24_set_mac(REG_RX_ADDR_P0, adr, addrs.addr_len); - nrf24_set_mac(REG_TX_ADDR, adr, addrs.addr_len); - } else { - uint8_t buf[5]; - memcpy(buf, addrs.addr_P1, addrs.addr_len - 1); - buf[addrs.addr_len - 1] = a == 2 ? addrs.addr_P2 : - a == 3 ? addrs.addr_P3 : - a == 4 ? addrs.addr_P4 : - addrs.addr_P5; - nrf24_set_mac(REG_RX_ADDR_P0, buf, addrs.addr_len); - nrf24_set_mac(REG_TX_ADDR, buf, addrs.addr_len); - } - a = *(ptr + 1) >> 3; - if(a == 0) a = 32; - nrf24_write_reg( - nrf24_HANDLE, - REG_CONFIG, - 0x70 | ((NRF_CRC == 1 ? 0b1000 : - NRF_CRC == 2 ? 0b1100 : - 0))); // Mask all interrupts - nrf24_write_reg(nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg - last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, ptr + 2, a, false); - } - last_packet_send = view_log_arr_idx; - notification_message( - APP->notification, - last_packet_send_st ? &sequence_blink_blue_100 : &sequence_blink_red_100); - if(what_to_do) start_scanning(); - return last_packet_send_st; -} - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) return; - //canvas_draw_frame(canvas, 0, 0, 128, 64); // border around the edge of the screen - if(what_doing == 0) { - canvas_set_font(canvas, FontSecondary); // 8x10 font - if(save_settings) - snprintf( - screen_buf, sizeof(screen_buf), "Save: %s", SETTINGS_FILENAME); // menu_selected = 0 - else - snprintf(screen_buf, sizeof(screen_buf), "Load: %s", addr_file_name); - canvas_draw_str(canvas, 10, 10, screen_buf); - snprintf(screen_buf, sizeof(screen_buf), "Ch: %d", NRF_channel); // menu_selected = 1 - canvas_draw_str(canvas, 10, 20, screen_buf); - if(NRF_ESB) { - strcpy(screen_buf, "ESB"); - if(NRF_DPL) strcat(screen_buf, " DPL"); - canvas_draw_str(canvas, 80, 20, screen_buf); - } - if(NRF_AA_OFF) { - canvas_draw_str(canvas, 61, 20, "AA"); - canvas_draw_line(canvas, 60, 21, 72, 12); - } - snprintf( - screen_buf, - sizeof(screen_buf), - "Rate: %sbps", - NRF_rate == 2 ? "2M" : - NRF_rate == 1 ? "1M" : - "250K"); // menu_selected = 2 - canvas_draw_str(canvas, 10, 30, screen_buf); - snprintf(screen_buf, sizeof(screen_buf), "Payload: %d", NRF_Payload); - canvas_draw_str(canvas, 80, 30, screen_buf); - strcpy(screen_buf, "Next Ch time: "); // menu_selected = 3 - if(find_channel_period == 0) - strcat(screen_buf, "off"); - else - snprintf( - screen_buf + strlen(screen_buf), sizeof(screen_buf), "%d s", find_channel_period); - canvas_draw_str(canvas, 10, 40, screen_buf); - if(NRF_CRC == 1) - canvas_draw_str(canvas, 99, 40, "CRC1"); - else if(NRF_CRC == 2) - canvas_draw_str(canvas, 99, 40, "CRC2"); - snprintf( - screen_buf, - sizeof(screen_buf), - "Log: %s", - log_to_file == 0 ? "No" : - log_to_file == 1 ? "Yes" : - log_to_file == 2 ? "Append" : - "Clear"); // menu_selected = 4 - canvas_draw_str(canvas, 10, 50, screen_buf); - if(what_to_do) { // menu_selected = 5 - if(NRF_ERROR) - snprintf(screen_buf, sizeof(screen_buf), "nRF24L01+ R/W ERROR!"); - else { - if(what_to_do == 1) - snprintf(screen_buf, sizeof(screen_buf), "Start sniff"); - else - snprintf( - screen_buf, sizeof(screen_buf), "Start scan (pipes: %d)", addrs.addr_count); - } - } else - snprintf(screen_buf, sizeof(screen_buf), "View log (pipes: %d)", addrs.addr_count); - canvas_draw_str(canvas, 10, 60, screen_buf); - canvas_draw_str(canvas, 0, menu_selected * 10 + 10, ">"); - } else if(what_doing == 1) { - canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines - bool ch2 = false; - screen_buf[0] = '\0'; - if(view_log_arr_x == 0) { - strcat(screen_buf, " "); - ch2 = true; - } else { - snprintf(screen_buf, sizeof(screen_buf), "<%d", view_log_arr_x); - if(view_log_arr_x < VIEW_LOG_MAX_X) ch2 = true; - } - snprintf( - screen_buf + strlen(screen_buf), - sizeof(screen_buf), - " %s ch: %d - %d.", - what_to_do == 1 ? "Sniff" : - what_to_do == 2 ? "Read" : - "View", - NRF_channel, - log_arr_idx); - canvas_draw_str(canvas, 0, 7, screen_buf); - if(ch2) canvas_draw_str(canvas, 121, 7, ">"); - if(log_arr_idx) { - if(view_log_arr_idx >= log_arr_idx) view_log_arr_idx = log_arr_idx - 1; - uint16_t page = view_log_arr_idx & ~7; - for(uint8_t i = 0; i < 8 && page + i < log_arr_idx; i++) { - screen_buf[0] = (view_log_arr_idx & 7) != i ? ' ' : - last_packet_send != view_log_arr_idx ? '>' : - last_packet_send_st ? '*' : - '!'; - screen_buf[1] = '\0'; - uint8_t* ptr = APP->log_arr + (page + i) * LOG_REC_SIZE; - uint8_t channel = *ptr++; - uint8_t* crcptr = NULL; - uint8_t pre = 0; - int count = 0; - if(channel & 0x80) { // RAW packet: nn:>{.address..}-xxxxxxxx - uint8_t pktinfo = *ptr++; - bool _PCF = pktinfo & 0b100; - uint8_t plen = count = (pktinfo >> 3); - uint8_t adrsize = (pktinfo & 0b11) + 2; - plen += adrsize; - count += view_log_decode_CRC; - if(view_log_arr_x > 0) count -= view_log_arr_x - 1; - uint8_t max_width = VIEW_LOG_WIDTH_B; - if(view_log_arr_x == 0) max_width -= 5; - if(count > max_width) count = max_width; - if(count > 0) { - uint8_t* pcrc = ptr; - uint16_t crc; - crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF; - crc = calc_crc(crc, pcrc, 7, (_PCF ? 9 : 0) + plen * 8); - pcrc += plen; - if(_PCF) { //ESB - pcrc++; - if(crc == get_shifted_crc(pcrc)) crcptr = pcrc; - } else { - if((view_log_decode_CRC == 1 && crc == *pcrc) || - (view_log_decode_CRC == 2 && crc == ((*pcrc << 8) | *(pcrc + 1)))) { - crcptr = pcrc; - } - } - if(view_log_arr_x == 0) { - add_to_str_hex_bytes(screen_buf, (char*)ptr, adrsize); - for(int8_t j = 5 - adrsize; j > 0; j--) strcat(screen_buf, " "); - strcat(screen_buf, "-"); - pre += 5 * 2 + 1; - } else { - ptr += view_log_arr_x - 1; - } - ptr += adrsize; - if(_PCF) - add_to_str_hex_bytes_shift_9b(screen_buf, (char*)ptr++, count); - else - add_to_str_hex_bytes(screen_buf, (char*)ptr, count); - } - } else { - uint8_t dpl = *ptr++; - uint8_t pipe = dpl & 0b111; - dpl >>= 3; - if(dpl == 0) dpl = 32; - count = dpl - view_log_arr_x; - if(view_log_decode_PCF) count--; - uint8_t max_width = VIEW_LOG_WIDTH_B; - if(view_log_arr_x == 0) { - if(addrs.addr_count > 1) max_width--; - if(view_log_decode_PCF) max_width -= 2; - } - if(count > max_width) count = max_width; - if(count > 0) { - if(view_log_decode_CRC) { - static uint16_t prev_addr_CRC; - static int8_t prev_pipe = -1; - uint8_t* pcrc = ptr; - uint16_t crc; - if(prev_pipe == pipe) { - crc = prev_addr_CRC; - } else { - crc = view_log_decode_CRC == 2 ? 0xFFFF : 0xFF; - if(pipe <= 1) { - crc = calc_crc( - crc, - pipe == 0 ? addrs.addr_P0 : addrs.addr_P1, - 7, - addrs.addr_len * 8); - } else { - crc = - calc_crc(crc, addrs.addr_P1, 7, (addrs.addr_len - 1) * 8); - crc = calc_crc( - crc, - pipe == 2 ? &addrs.addr_P2 : - pipe == 3 ? &addrs.addr_P3 : - pipe == 4 ? &addrs.addr_P4 : - &addrs.addr_P5, - 7, - 8); - } - prev_addr_CRC = crc; - prev_pipe = pipe; - } - if(view_log_decode_PCF) { - crc = calc_crc(crc, pcrc++, 7, 9); - if(crc == get_shifted_crc(pcrc)) crcptr = pcrc; - if(crcptr == NULL) { - for(int8_t j = 0; j < (int8_t)dpl - view_log_decode_CRC - 1; - j++) { - crc = calc_crc(crc, pcrc++, 6, 8); - if(crc == get_shifted_crc(pcrc)) { - crcptr = pcrc; - break; - } - } - } - } else { - for(int8_t j = 0; j < (int8_t)dpl - view_log_decode_CRC; j++) { - crc = calc_crc(crc, pcrc++, 7, 8); - if((view_log_decode_CRC == 1 && crc == *pcrc) || - (view_log_decode_CRC == 2 && - crc == ((*pcrc << 8) | *(pcrc + 1)))) { - crcptr = pcrc; - break; - } - } - } - } - } - ptr += view_log_arr_x; - if(max_width < VIEW_LOG_WIDTH_B) { - pre += snprintf(screen_buf + 1, 10, "%X-", pipe); - if(view_log_decode_PCF) { - pre += snprintf( - screen_buf + strlen(screen_buf), - 10, - "%02X%01X-", - *ptr >> 2, - ((*ptr & 3) << 1) | (*(ptr + 1) >> 7)); - } - } - if(view_log_decode_PCF) - add_to_str_hex_bytes_shift_9b(screen_buf, (char*)ptr++, count); - else - add_to_str_hex_bytes(screen_buf, (char*)ptr, count); - } - uint16_t y = 14 + i * 7; - canvas_draw_str(canvas, 3 * 5, y, screen_buf); - uint16_t x = snprintf(screen_buf, sizeof(screen_buf), "%d", page + i + 1); - canvas_draw_str(canvas, 0, y, screen_buf); - if(crcptr) { // 5x7 font, 9 lines - canvas_draw_str(canvas, x * 5, y, "="); - int n = crcptr - (uint8_t*)ptr; - if(n > -view_log_decode_CRC && n < count) { - int len; - x = (4 + pre) * 5; - if(n < 0) { - len = view_log_decode_CRC + n; - n = 0; - } else { - len = MIN(view_log_decode_CRC, count - n); - x += n * 2 * 5; - canvas_draw_line(canvas, x - 1, y, x - 1, y - 1); - } - canvas_draw_line(canvas, x - 1, y, n = x + len * 2 * 5 - 1, y); - canvas_draw_line(canvas, n, y, n, y - 1); - } - } else - canvas_draw_str(canvas, x * 5, y, ":"); - } - } - } else { - canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines - if(addrs.addr_count > 0) { - snprintf(screen_buf, sizeof(screen_buf), "P0: "); - add_to_str_hex_bytes(screen_buf, (char*)addrs.addr_P0, addrs.addr_len); - canvas_draw_str(canvas, 0, 1 * 7, screen_buf); - } - if(addrs.addr_count > 1) { - snprintf(screen_buf, sizeof(screen_buf), "P1: "); - add_to_str_hex_bytes(screen_buf, (char*)addrs.addr_P1, addrs.addr_len); - canvas_draw_str(canvas, 0, 2 * 7, screen_buf); - } - if(addrs.addr_count > 2) { - canvas_draw_str(canvas, 0, 3 * 7, "P2: "); - snprintf(screen_buf, sizeof(screen_buf), "%02X", addrs.addr_P2); - canvas_draw_str(canvas, (4 + (addrs.addr_len - 1) * 2) * 5, 3 * 7, screen_buf); - } - if(addrs.addr_count > 3) { - canvas_draw_str(canvas, 0, 4 * 7, "P3: "); - snprintf(screen_buf, sizeof(screen_buf), "%02X", addrs.addr_P3); - canvas_draw_str(canvas, (4 + (addrs.addr_len - 1) * 2) * 5, 4 * 7, screen_buf); - } - if(addrs.addr_count > 4) { - canvas_draw_str(canvas, 0, 5 * 7, "P4: "); - snprintf(screen_buf, sizeof(screen_buf), "%02X", addrs.addr_P4); - canvas_draw_str(canvas, (4 + (addrs.addr_len - 1) * 2) * 5, 5 * 7, screen_buf); - } - if(addrs.addr_count > 5) { - canvas_draw_str(canvas, 0, 6 * 7, "P5: "); - snprintf(screen_buf, sizeof(screen_buf), "%02X", addrs.addr_P5); - canvas_draw_str(canvas, (4 + (addrs.addr_len - 1) * 2) * 5, 6 * 7, screen_buf); - } - if(log_arr_idx) { - uint8_t* ptr = APP->log_arr + view_log_arr_idx * LOG_REC_SIZE; - uint8_t pktinfo = *(ptr + 1); - snprintf(screen_buf, 32, ">> Ch: %d, size: %d", *ptr & 0x7F, pktinfo >> 3); - if(*ptr & 0x80) - snprintf( - screen_buf + strlen(screen_buf), 32, " RAW %s", (pktinfo & 0b100) ? "PCF" : ""); - canvas_draw_str(canvas, 0, 7 * 7, screen_buf); - } - screen_buf[0] = 'v'; - strcpy(screen_buf + 1, VERSION); - canvas_draw_str(canvas, 108, 7, screen_buf); - if(view_log_decode_PCF || view_log_decode_CRC) { - strcpy(screen_buf, "Decode: "); - if(view_log_decode_PCF) strcat(screen_buf, "PCF "); - if(view_log_decode_CRC == 1) - strcat(screen_buf, "CRC1"); - else if(view_log_decode_CRC == 2) - strcat(screen_buf, "CRC2"); - canvas_draw_str(canvas, 0, 64, screen_buf); - } - } - release_mutex((ValueMutex*)ctx, plugin_state); -} - -int32_t nrf24scan_app(void* p) { - UNUSED(p); - APP = malloc(sizeof(Nrf24Scan)); - APP->event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - APP->plugin_state = malloc(sizeof(PluginState)); - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, APP->plugin_state, sizeof(PluginState))) { - furi_message_queue_free(APP->event_queue); - FURI_LOG_E(TAG, "cannot create mutex"); - free(APP->plugin_state); - return 255; - } - memset((uint8_t*)&addrs, 0, sizeof(addrs)); - nrf24_init(); - - // Set system callbacks - APP->view_port = view_port_alloc(); - view_port_draw_callback_set(APP->view_port, render_callback, &state_mutex); - view_port_input_callback_set(APP->view_port, input_callback, APP->event_queue); - - // Open GUI and register view_port - APP->gui = furi_record_open(RECORD_GUI); - gui_add_view_port(APP->gui, APP->view_port, GuiLayerFullscreen); - APP->notification = furi_record_open(RECORD_NOTIFICATION); - APP->storage = furi_record_open(RECORD_STORAGE); - storage_common_mkdir(APP->storage, SCAN_APP_PATH_FOLDER); - Stream* file_stream = file_stream_alloc(APP->storage); - FuriString* path = furi_string_alloc(); - furi_string_set(path, SCAN_APP_PATH_FOLDER); - furi_string_cat(path, "/"); - furi_string_cat(path, SNIFF_FILENAME); - if(file_stream_open(file_stream, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) { - uint8_t err = load_settings_file(file_stream); - if(!err) - strncpy( - addr_file_name, - furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER), - sizeof(addr_file_name)); - else - snprintf(addr_file_name, sizeof(addr_file_name), "LOAD ERROR#%d", err); - } else { - strcpy(addr_file_name, "NONE"); - if(what_to_do == 1) { - addrs.addr_P0[0] = 0; - addrs.addr_P0[1] = 0xAA; - addrs.addr_len = 2; - addrs.addr_count = 1; - view_log_decode_CRC = NRF_CRC = 2; - } - } - file_stream_close(file_stream); - stream_free(file_stream); - furi_string_free(path); - allocate_log_array(); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(APP->event_queue, &event, 100); - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - //FURI_LOG_D(TAG, "Key: %d Type: %d Sec: %u", event.input.key, event.input.type, event.input.sequence); - switch(event.input.key) { - case InputKeyUp: - if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) { - if(what_doing == 0) { - if(menu_selected > 0) - menu_selected--; - else - menu_selected = menu_selected_max; - } else if(what_doing == 1) { - view_log_arr_idx -= event.input.type == InputTypeRepeat ? 10 : 1; - if(view_log_arr_idx >= log_arr_idx) view_log_arr_idx = 0; - } - } - break; - case InputKeyDown: - if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) { - if(what_doing == 0) { - if(menu_selected < menu_selected_max) - menu_selected++; - else - menu_selected = 0; - } else if(what_doing == 1) { - view_log_arr_idx += event.input.type == InputTypeRepeat ? 10 : 1; - if(view_log_arr_idx >= log_arr_idx) view_log_arr_idx = log_arr_idx - 1; - } - } - break; - case InputKeyLeft: - if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) { - if(what_doing == 0) { - switch(menu_selected) { - case Menu_enter_channel: - NRF_channel -= event.input.type == InputTypeRepeat ? 10 : 1; - if(NRF_channel > MAX_CHANNEL) NRF_channel = MAX_CHANNEL; - break; - case Menu_enter_rate: - NRF_Payload -= event.input.type == InputTypeRepeat ? 10 : 1; - if(NRF_Payload == 0 || NRF_Payload > 32) NRF_Payload = 1; - break; - case Menu_enter_scan_period: - find_channel_period -= event.input.type == InputTypeRepeat ? 10 : - 1; - if(find_channel_period < 0) find_channel_period = 0; - break; - case Menu_log: - if(--log_to_file < -1) log_to_file = 2; - break; - case Menu_ok: - if(++what_to_do > 2) what_to_do = 0; - break; - } - } else if(what_doing == 1) { - if(view_log_arr_x > 0) view_log_arr_x--; - } else if(what_doing == 2) { - //if(NRF_ESB == 0) - view_log_decode_PCF ^= 1; - } - } - break; - case InputKeyRight: - if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) { - if(what_doing == 0) { - switch(menu_selected) { - case Menu_open_file: - save_settings ^= 1; - break; - case Menu_enter_channel: - NRF_channel += event.input.type == InputTypeRepeat ? 10 : 1; - if(NRF_channel > MAX_CHANNEL) NRF_channel = 0; - break; - case Menu_enter_rate: - NRF_Payload += event.input.type == InputTypeRepeat ? 10 : 1; - if(NRF_Payload == 0 || NRF_Payload > 32) NRF_Payload = 32; - break; - case Menu_enter_scan_period: - find_channel_period += event.input.type == InputTypeRepeat ? 10 : - 1; - break; - case Menu_log: - if(++log_to_file > 2) log_to_file = -1; - break; - case Menu_ok: - if(++what_to_do > 2) what_to_do = 0; - break; - } - } else if(what_doing == 1) { - if(view_log_arr_x < VIEW_LOG_MAX_X) view_log_arr_x++; - } else if(what_doing == 2) { - if(++view_log_decode_CRC > 2) view_log_decode_CRC = 0; - } - } - break; - case InputKeyOk: - if(event.input.type == InputTypeShort) { - if(what_doing == 0) { - switch(menu_selected) { - case Menu_open_file: - if(save_settings) { - write_to_log_file(APP->storage, true); - } else { - file_stream = file_stream_alloc(APP->storage); - if(select_settings_file(file_stream)) { - uint8_t err = load_settings_file(file_stream); - if(!err) - save_to_new_log = true; - else - snprintf( - addr_file_name, - sizeof(addr_file_name), - "LOAD ERROR#%d", - err); - file_stream_close(file_stream); - menu_selected = Menu_ok; - } - stream_free(file_stream); - } - break; - case Menu_enter_channel: - if(NRF_ESB) { - if(NRF_DPL) - NRF_DPL = NRF_ESB = 0; - else - NRF_DPL = 1; - } else - NRF_ESB = 1; - //if(NRF_ESB) view_log_decode_PCF = 0; - break; - case Menu_enter_rate: - NRF_rate++; - if(NRF_rate > 2) NRF_rate = 0; - break; - case Menu_enter_scan_period: - if(++NRF_CRC > 2) NRF_CRC = what_to_do == 1 ? 1 : 0; - break; - case Menu_ok: - if(what_to_do) { - if(addrs.addr_count || what_to_do == 1) { - if(log_to_file == -1) { - log_to_file = 0; - clear_log(); - save_to_new_log = true; - } else if(log_to_file == 1) - save_to_new_log = true; - start_scanning(); - if(!NRF_ERROR) what_doing = 1; - } - } else - what_doing = 1; - key_press_seq_ok = event.input.sequence; - break; - } - } else if(what_doing == 1) { - nrf24_send_packet(); - } - } else if(event.input.type == InputTypeLong) { - if(what_doing == 0) { - if(menu_selected == Menu_enter_channel) { - NRF_AA_OFF ^= 1; - key_press_seq_ok = event.input.sequence; - } else if(menu_selected == Menu_log) { // Log - if(log_arr_idx && (log_to_file == 1 || log_to_file == 2)) { - write_to_log_file(APP->storage, false); - clear_log(); - } - } - } else if(what_doing == 1) { - what_doing = 2; - } - } - break; - case InputKeyBack: - if(event.input.type == InputTypeLong) - processing = false; - else if(event.input.type == InputTypeShort) { - if(what_doing) what_doing--; - if(what_doing == 0) nrf24_set_idle(nrf24_HANDLE); - ; - } - break; - default: - break; - } - } - } - if(what_doing && what_to_do) { - nrf24_read_newpacket(); - if(find_channel_period && - furi_get_tick() - start_time >= (uint32_t)find_channel_period * 1000UL) { - if(++NRF_channel > MAX_CHANNEL) NRF_channel = 0; - start_scanning(); - } - } - - view_port_update(APP->view_port); - release_mutex(&state_mutex, plugin_state); - } - nrf24_set_idle(nrf24_HANDLE); - if(log_arr_idx && (log_to_file == 1 || log_to_file == 2)) { - write_to_log_file(APP->storage, false); - } - nrf24_deinit(); - - view_port_enabled_set(APP->view_port, false); - gui_remove_view_port(APP->gui, APP->view_port); - furi_record_close(RECORD_GUI); - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_STORAGE); - view_port_free(APP->view_port); - furi_message_queue_free(APP->event_queue); - free(APP->plugin_state); - if(APP->log_arr) free(APP->log_arr); - free(APP); - return 0; -} \ No newline at end of file diff --git a/applications/plugins/nrf24scan/nrf24scan.h b/applications/plugins/nrf24scan/nrf24scan.h deleted file mode 100644 index c3fa2891a..000000000 --- a/applications/plugins/nrf24scan/nrf24scan.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - int x; - int y; -} PluginState; - -typedef struct { - Gui* gui; - FuriMessageQueue* event_queue; - PluginState* plugin_state; - ViewPort* view_port; - Storage* storage; - NotificationApp* notification; - uint8_t* log_arr; -} Nrf24Scan; diff --git a/applications/plugins/nrf24scan/nrf24scan_10px.png b/applications/plugins/nrf24scan/nrf24scan_10px.png deleted file mode 100644 index 348b35eca..000000000 Binary files a/applications/plugins/nrf24scan/nrf24scan_10px.png and /dev/null differ diff --git a/applications/plugins/nrf24scan/sniff.txt b/applications/plugins/nrf24scan/sniff.txt deleted file mode 100644 index 4f8ae847c..000000000 --- a/applications/plugins/nrf24scan/sniff.txt +++ /dev/null @@ -1,6 +0,0 @@ -SNIFF -Rate: 1 -Ch: 2 -ESB: 1 -CRC: 2 -P0: 00AA diff --git a/applications/plugins/nrfsniff/README.md b/applications/plugins/nrfsniff/README.md deleted file mode 100644 index 89cc401c3..000000000 --- a/applications/plugins/nrfsniff/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# flipperzero-nrf24 - -An [NRF24](https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Preliminary_Product_Specification_v1_0.pdf) driver for the [Flipper Zero](https://flipperzero.one/) device. The NRF24 is a popular line of 2.4GHz radio transceivers from Nordic Semiconductors. This library is not currently complete, but functional. - -## Warning -This repo contains two Flipper Zero apps that utilize the NRF24 driver to sniff for NRF24 addresses and perform mousejack attacks. These apps are for **educational purposes** only. Please use this code responsibly and only use these apps on your own equipment. - -## Acknowledgments -The NRF24 sniffing technique was discovered and shared by Travis Goodspeed in [his blog](http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html). - -The mousejack vulnerabilities were discovered and reported by Marc Newlin, see [the blog](https://www.bastille.net/research/vulnerabilities/mousejack/technical-details) for technical details. - -Much of the driver code was inspired by [RadioHead's Arduino library](https://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF24.html). -Much of the mousejack code was inspired by the [Jackit project](https://github.com/insecurityofthings/jackit). -# -## PinOut from from NoComp/Frog - - -# Mousejack / NRF24 pinout by UberGuidoZ -2/A7 on FZ goes to MOSI/6 on nrf24l01
-3/A6 on FZ goes to MISO/7 on nrf24l01
-4/A4 on FZ goes to CSN/4 on nrf24l01
-5/B3 on FZ goes to SCK/5 on nrf24l01
-6/B2 on FZ goes to CE/3 on nrf24l01
-8/GND on FZ goes to GND/1 on nrf24l01
-9/3V3 on FZ goes to VCC/2 on nrf24l01
-IRQ/8 is left disconnected on nrf24l01 -![NRF_Pins](https://user-images.githubusercontent.com/57457139/178093717-39effd5c-ebe2-4253-b13c-70517d7902f9.png) -If the nRF module is acting a bit flakey, try adding a capacitor to the vcc/gnd lines! I've not tried the Plus model so it may have a bigger need for a cap. Otherwise, I haven't had any major issues. Anything from a 3.3 uF to 10 uF should do. (Watch your positive/negative placement! Negative to ground.) I learned if you wanna get fancy, include a 0.1 uF cap in parallel. The 3.3 uF to 10 uF will respond to slow freq changes while the 0.1 uF will respond to the high freq switching spikes that the larger one cannot. That said, a single 10 uF will likely suffice for the Mousejack attack. ¯\\\_(ツ)_/¯ -![NRF_Capacitor](https://user-images.githubusercontent.com/57457139/178169959-d030f9a6-d2ac-46af-af8b-470ff092c8a7.jpg) - diff --git a/applications/plugins/nrfsniff/application.fam b/applications/plugins/nrfsniff/application.fam deleted file mode 100644 index e55ab3e9c..000000000 --- a/applications/plugins/nrfsniff/application.fam +++ /dev/null @@ -1,20 +0,0 @@ -App( - appid="NRF24_Sniffer", - name="[NRF24] Sniffer", - apptype=FlipperAppType.EXTERNAL, - entry_point="nrfsniff_app", - cdefines=["APP_NRFSNIFF"], - requires=["gui"], - stack_size=2 * 1024, - order=60, - fap_icon="nrfsniff_10px.png", - fap_category="GPIO", - fap_private_libs=[ - Lib( - name="nrf24", - sources=[ - "nrf24.c", - ], - ), - ], -) diff --git a/applications/plugins/nrfsniff/lib/nrf24/nrf24.c b/applications/plugins/nrfsniff/lib/nrf24/nrf24.c deleted file mode 100644 index 8b3776445..000000000 --- a/applications/plugins/nrfsniff/lib/nrf24/nrf24.c +++ /dev/null @@ -1,520 +0,0 @@ -#include "nrf24.h" -#include -#include -#include -#include -#include - -void nrf24_init() { - furi_hal_spi_bus_handle_init(nrf24_HANDLE); - furi_hal_spi_acquire(nrf24_HANDLE); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh); - furi_hal_gpio_write(nrf24_CE_PIN, false); -} - -void nrf24_deinit() { - furi_hal_spi_release(nrf24_HANDLE); - furi_hal_spi_bus_handle_deinit(nrf24_HANDLE); - furi_hal_gpio_write(nrf24_CE_PIN, false); - furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow); -} - -void nrf24_spi_trx( - FuriHalSpiBusHandle* handle, - uint8_t* tx, - uint8_t* rx, - uint8_t size, - uint32_t timeout) { - UNUSED(timeout); - furi_hal_gpio_write(handle->cs, false); - furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT); - furi_hal_gpio_write(handle->cs, true); -} - -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data) { - uint8_t tx[2] = {W_REGISTER | (REGISTER_MASK & reg), data}; - uint8_t rx[2] = {0}; - nrf24_spi_trx(handle, tx, rx, 2, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t - nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = W_REGISTER | (REGISTER_MASK & reg); - memcpy(&tx[1], data, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) { - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(rx, 0, size + 1); - tx[0] = R_REGISTER | (REGISTER_MASK & reg); - memset(&tx[1], 0, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - memcpy(data, &rx[1], size); - return rx[0]; -} - -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_RX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle) { - uint8_t tx[] = {FLUSH_TX}; - uint8_t rx[] = {0}; - nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT); - return rx[0]; -} - -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle) { - uint8_t maclen; - nrf24_read_reg(handle, REG_SETUP_AW, &maclen, 1); - maclen &= 3; - return maclen + 2; -} - -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen) { - assert(maclen > 1 && maclen < 6); - uint8_t status = 0; - status = nrf24_write_reg(handle, REG_SETUP_AW, maclen - 2); - return status; -} - -uint8_t nrf24_status(FuriHalSpiBusHandle* handle) { - uint8_t status; - uint8_t tx[] = {R_REGISTER | (REGISTER_MASK & REG_STATUS)}; - nrf24_spi_trx(handle, tx, &status, 1, nrf24_TIMEOUT); - return status; -} - -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle) { - uint8_t setup = 0; - uint32_t rate = 0; - nrf24_read_reg(handle, REG_RF_SETUP, &setup, 1); - setup &= 0x28; - if(setup == 0x20) - rate = 250000; // 250kbps - else if(setup == 0x08) - rate = 2000000; // 2Mbps - else if(setup == 0x00) - rate = 1000000; // 1Mbps - - return rate; -} - -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate) { - uint8_t r6 = 0; - uint8_t status = 0; - if(!rate) rate = 2000000; - - nrf24_read_reg(handle, REG_RF_SETUP, &r6, 1); // RF_SETUP register - r6 = r6 & (~0x28); // Clear rate fields. - if(rate == 2000000) - r6 = r6 | 0x08; - else if(rate == 1000000) - r6 = r6; - else if(rate == 250000) - r6 = r6 | 0x20; - - status = nrf24_write_reg(handle, REG_RF_SETUP, r6); // Write new rate. - return status; -} - -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle) { - uint8_t channel = 0; - nrf24_read_reg(handle, REG_RF_CH, &channel, 1); - return channel; -} - -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan) { - uint8_t status; - status = nrf24_write_reg(handle, REG_RF_CH, chan); - return status; -} - -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, mac, size); - return status; -} - -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) { - uint8_t size = 0; - uint8_t status = 0; - size = nrf24_get_maclen(handle); - status = nrf24_read_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) { - uint8_t status = 0; - uint8_t clearmac[] = {0, 0, 0, 0, 0}; - nrf24_set_maclen(handle, size); - nrf24_write_buf_reg(handle, REG_TX_ADDR, clearmac, 5); - status = nrf24_write_buf_reg(handle, REG_TX_ADDR, mac, size); - return status; -} - -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle) { - uint8_t len = 0; - nrf24_read_reg(handle, RX_PW_P0, &len, 1); - return len; -} - -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) { - uint8_t status = 0; - status = nrf24_write_reg(handle, RX_PW_P0, len); - return status; -} - -uint8_t - nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) { - uint8_t status = 0; - uint8_t size = 0; - uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0}; - uint8_t rx_pl_wid[] = {0, 0}; - uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command - uint8_t tmp_packet[33] = {0}; - - status = nrf24_status(handle); - - if(status & 0x40) { - if(full) - size = nrf24_get_packetlen(handle); - else { - nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT); - size = rx_pl_wid[1]; - } - - tx_cmd[0] = R_RX_PAYLOAD; - nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT); - nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit. - memcpy(packet, &tmp_packet[1], size); - } else if(status == 0) { - nrf24_flush_rx(handle); - nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit. - } - - *packetsize = size; - return status; -} - -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack) { - uint8_t status = 0; - uint8_t tx[size + 1]; - uint8_t rx[size + 1]; - memset(tx, 0, size + 1); - memset(rx, 0, size + 1); - - if(!ack) - tx[0] = W_TX_PAYLOAD_NOACK; - else - tx[0] = W_TX_PAYLOAD; - - memcpy(&tx[1], payload, size); - nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT); - nrf24_set_tx_mode(handle); - - while(!(status & (TX_DS | MAX_RT))) status = nrf24_status(handle); - - if(status & MAX_RT) nrf24_flush_tx(handle); - - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, TX_DS | MAX_RT); - return status & TX_DS; -} - -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg = cfg | 2; - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_delay_ms(5000); - return status; -} - -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfc; // clear bottom two bits to power down the radio - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(handle, REG_EN_RXADDR, 0x0); - furi_hal_gpio_write(nrf24_CE_PIN, false); - return status; -} - -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0F); // enable 2-byte CRC, PWR_UP, and PRIM_RX - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg |= 0x03; // PWR_UP, and PRIM_RX - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - //nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1 - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2000); - return status; -} - -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle) { - uint8_t status = 0; - uint8_t cfg = 0; - furi_hal_gpio_write(nrf24_CE_PIN, false); - nrf24_write_reg(handle, REG_STATUS, 0x30); - //status = nrf24_write_reg(handle, REG_CONFIG, 0x0E); // enable 2-byte CRC, PWR_UP - nrf24_read_reg(handle, REG_CONFIG, &cfg, 1); - cfg &= 0xfe; // disable PRIM_RX - cfg |= 0x02; // PWR_UP - status = nrf24_write_reg(handle, REG_CONFIG, cfg); - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(2); - return status; -} - -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa) { - assert(channel <= 125); - assert(rate == 1 || rate == 2); - if(rate == 2) - rate = 8; // 2Mbps - else - rate = 0; // 1Mbps - - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_set_idle(handle); - nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts - if(disable_aa) - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - else - nrf24_write_reg(handle, REG_EN_AA, 0x1F); // Enable Shockburst - - nrf24_write_reg(handle, REG_DYNPD, 0x3F); // enable dynamic payload length on all pipes - if(noack) - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - else { - nrf24_write_reg(handle, REG_CONFIG, 0x0C); // 2 byte CRC - nrf24_write_reg(handle, REG_FEATURE, 0x07); // enable dyn payload and ack - nrf24_write_reg( - handle, REG_SETUP_RETR, 0x1f); // 15 retries for AA, 500us auto retransmit delay - } - - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - - if(maclen) nrf24_set_maclen(handle, maclen); - if(srcmac) nrf24_set_src_mac(handle, srcmac, maclen); - if(dstmac) nrf24_set_dst_mac(handle, dstmac, maclen); - - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - furi_delay_ms(200); -} - -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate) { - //uint8_t preamble[] = {0x55, 0x00}; // little endian - uint8_t preamble[] = {0xAA, 0x00}; // little endian - //uint8_t preamble[] = {0x00, 0x55}; // little endian - //uint8_t preamble[] = {0x00, 0xAA}; // little endian - nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF - nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts - nrf24_write_reg(handle, REG_DYNPD, 0x0); // disable shockburst - nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst - nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack - nrf24_set_maclen(handle, 2); // shortest address - nrf24_set_src_mac(handle, preamble, 2); // set src mac to preamble bits to catch everything - nrf24_set_packetlen(handle, 32); // set max packet length - nrf24_set_idle(handle); - nrf24_flush_rx(handle); - nrf24_flush_tx(handle); - nrf24_write_reg(handle, REG_RF_CH, channel); - nrf24_write_reg(handle, REG_RF_SETUP, rate); - - // prime for RX, no checksum - nrf24_write_reg(handle, REG_CONFIG, 0x03); // PWR_UP and PRIM_RX, disable AA and CRC - furi_hal_gpio_write(nrf24_CE_PIN, true); - furi_delay_ms(100); -} - -void hexlify(uint8_t* in, uint8_t size, char* out) { - memset(out, 0, size * 2); - for(int i = 0; i < size; i++) - snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]); -} - -uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) { - uint64_t ret = 0; - for(int i = 0; i < size; i++) - if(bigendian) - ret |= bytes[i] << ((size - 1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 8; i++) { - if(bigendian) - out[i] = (val >> ((7 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian) { - uint32_t ret = 0; - for(int i = 0; i < 4; i++) - if(bigendian) - ret |= bytes[i] << ((3 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 4; i++) { - if(bigendian) - out[i] = (val >> ((3 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -uint64_t bytes_to_int16(uint8_t* bytes, bool bigendian) { - uint16_t ret = 0; - for(int i = 0; i < 2; i++) - if(bigendian) - ret |= bytes[i] << ((1 - i) * 8); - else - ret |= bytes[i] << (i * 8); - - return ret; -} - -void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) { - for(int i = 0; i < 2; i++) { - if(bigendian) - out[i] = (val >> ((1 - i) * 8)) & 0xff; - else - out[i] = (val >> (i * 8)) & 0xff; - } -} - -// handle iffyness with preamble processing sometimes being a bit (literally) off -void alt_address_old(uint8_t* packet, uint8_t* altaddr) { - uint8_t macmess_hi_b[4]; - uint8_t macmess_lo_b[2]; - uint32_t macmess_hi; - uint16_t macmess_lo; - uint8_t preserved; - - // get first 6 bytes into 32-bit and 16-bit variables - memcpy(macmess_hi_b, packet, 4); - memcpy(macmess_lo_b, packet + 4, 2); - - macmess_hi = bytes_to_int32(macmess_hi_b, true); - - //preserve least 7 bits from hi that will be shifted down to lo - preserved = macmess_hi & 0x7f; - macmess_hi >>= 7; - - macmess_lo = bytes_to_int16(macmess_lo_b, true); - macmess_lo >>= 7; - macmess_lo = (preserved << 9) | macmess_lo; - int32_to_bytes(macmess_hi, macmess_hi_b, true); - int16_to_bytes(macmess_lo, macmess_lo_b, true); - memcpy(altaddr, &macmess_hi_b[1], 3); - memcpy(altaddr + 3, macmess_lo_b, 2); -} - -bool validate_address(uint8_t* addr) { - uint8_t bad[][3] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x00, 0x00}, {0xFF, 0xFF}}; - for(int i = 0; i < 4; i++) - for(int j = 0; j < 2; j++) - if(!memcmp(addr + j * 2, bad[i], 2)) return false; - - return true; -} - -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address) { - bool found = false; - uint8_t packet[32] = {0}; - uint8_t packetsize; - //char printit[65]; - uint8_t status = 0; - status = nrf24_rxpacket(handle, packet, &packetsize, true); - if(status & 0x40) { - if(validate_address(packet)) { - for(int i = 0; i < maclen; i++) address[i] = packet[maclen - 1 - i]; - - /* - alt_address(packet, packet); - - for(i = 0; i < maclen; i++) - address[i + 5] = packet[maclen - 1 - i]; - */ - - //memcpy(address, packet, maclen); - //hexlify(packet, packetsize, printit); - found = true; - } - } - - return found; -} - -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit) { - uint8_t ping_packet[] = {0x0f, 0x0f, 0x0f, 0x0f}; // this can be anything, we just need an ack - uint8_t ch = max_channel + 1; // means fail - nrf24_configure(handle, rate, srcmac, dstmac, maclen, 2, false, false); - for(ch = min_channel; ch <= max_channel + 1; ch++) { - nrf24_write_reg(handle, REG_RF_CH, ch); - if(nrf24_txpacket(handle, ping_packet, 4, true)) break; - } - - if(autoinit) { - FURI_LOG_D("nrf24", "initializing radio for channel %d", ch); - nrf24_configure(handle, rate, srcmac, dstmac, maclen, ch, false, false); - return ch; - } - - return ch; -} \ No newline at end of file diff --git a/applications/plugins/nrfsniff/lib/nrf24/nrf24.h b/applications/plugins/nrfsniff/lib/nrf24/nrf24.h deleted file mode 100644 index 3cfcfe089..000000000 --- a/applications/plugins/nrfsniff/lib/nrf24/nrf24.h +++ /dev/null @@ -1,366 +0,0 @@ -#pragma once -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define R_REGISTER 0x00 -#define W_REGISTER 0x20 -#define REGISTER_MASK 0x1F -#define ACTIVATE 0x50 -#define R_RX_PL_WID 0x60 -#define R_RX_PAYLOAD 0x61 -#define W_TX_PAYLOAD 0xA0 -#define W_TX_PAYLOAD_NOACK 0xB0 -#define W_ACK_PAYLOAD 0xA8 -#define FLUSH_TX 0xE1 -#define FLUSH_RX 0xE2 -#define REUSE_TX_PL 0xE3 -#define RF24_NOP 0xFF - -#define REG_CONFIG 0x00 -#define REG_EN_AA 0x01 -#define REG_EN_RXADDR 0x02 -#define REG_SETUP_AW 0x03 -#define REG_SETUP_RETR 0x04 -#define REG_DYNPD 0x1C -#define REG_FEATURE 0x1D -#define REG_RF_SETUP 0x06 -#define REG_STATUS 0x07 -#define REG_RX_ADDR_P0 0x0A -#define REG_RF_CH 0x05 -#define REG_TX_ADDR 0x10 - -#define RX_PW_P0 0x11 -#define TX_DS 0x20 -#define MAX_RT 0x10 - -#define nrf24_TIMEOUT 500 -#define nrf24_CE_PIN &gpio_ext_pb2 -#define nrf24_HANDLE &furi_hal_spi_bus_handle_external - -/* Low level API */ - -/** Write device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * - * @return device status - */ -uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data); - -/** Write buffer to device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param data - data to write - * @param size - size of data to write - * - * @return device status - */ -uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Read device register - * - * @param handle - pointer to FuriHalSpiHandle - * @param reg - register - * @param[out] data - pointer to data - * - * @return device status - */ -uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); - -/** Power up the radio for operation - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle); - -/** Power down the radio - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle); - -/** Sets the radio to RX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle); - -/** Sets the radio to TX mode - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle); - -/*=============================================================================================================*/ - -/* High level API */ - -/** Must call this before using any other nrf24 API - * - */ -void nrf24_init(); - -/** Must call this when we end using nrf24 device - * - */ -void nrf24_deinit(); - -/** Send flush rx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle); - -/** Send flush tx command - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return device status - */ -uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle); - -/** Gets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return packet length in data pipe 0 - */ -uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle); - -/** Sets the RX packet length in data pipe 0 - * - * @param handle - pointer to FuriHalSpiHandle - * @param len - length to set - * - * @return device status - */ -uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len); - -/** Gets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return MAC address length - */ -uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle); - -/** Sets configured length of MAC address - * - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length to set MAC address to, must be greater than 1 and less than 6 - * - * @return MAC address length - */ -uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen); - -/** Gets the current status flags from the STATUS register - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return status flags - */ -uint8_t nrf24_status(FuriHalSpiBusHandle* handle); - -/** Gets the current transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return transfer rate in bps - */ -uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle); - -/** Sets the transfer rate - * - * @param handle - pointer to FuriHalSpiHandle - * @param rate - the transfer rate in bps - * - * @return device status - */ -uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate); - -/** Gets the current channel - * In nrf24, the channel number is multiplied times 1MHz and added to 2400MHz to get the frequency - * - * @param handle - pointer to FuriHalSpiHandle - * - * @return channel - */ -uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle); - -/** Sets the channel - * - * @param handle - pointer to FuriHalSpiHandle - * @param frequency - the frequency in hertz - * - * @return device status - */ -uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan); - -/** Gets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the source mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Gets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] mac - the source mac address - * - * @return device status - */ -uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac); - -/** Sets the dest mac address - * - * @param handle - pointer to FuriHalSpiHandle - * @param mac - the mac address to set - * @param size - the size of the mac address (2 to 5) - * - * @return device status - */ -uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); - -/** Reads RX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param[out] packet - the packet contents - * @param[out] packetsize - size of the received packet - * @param full - boolean set to true, packet length is determined by RX_PW_P0 register, false it is determined by dynamic payload length command - * - * @return device status - */ -uint8_t - nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full); - -/** Sends TX packet - * - * @param handle - pointer to FuriHalSpiHandle - * @param packet - the packet contents - * @param size - packet size - * @param ack - boolean to determine whether an ACK is required for the packet or not - * - * @return device status - */ -uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack); - -/** Configure the radio - * This is not comprehensive, but covers a lot of the common configuration options that may be changed - * @param handle - pointer to FuriHalSpiHandle - * @param rate - transfer rate in Mbps (1 or 2) - * @param srcmac - source mac address - * @param dstmac - destination mac address - * @param maclen - length of mac address - * @param channel - channel to tune to - * @param noack - if true, disable auto-acknowledge - * @param disable_aa - if true, disable ShockBurst - * - */ -void nrf24_configure( - FuriHalSpiBusHandle* handle, - uint8_t rate, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t channel, - bool noack, - bool disable_aa); - -/** Configures the radio for "promiscuous mode" and primes it for rx - * This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were. - * See http://travisgoodspeed.blogspot.com/2011/02/promiscuity-is-nrf24l01s-duty.html for details. - * @param handle - pointer to FuriHalSpiHandle - * @param channel - channel to tune to - * @param rate - transfer rate in Mbps (1 or 2) - */ -void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate); - -/** Listens for a packet and returns first possible address sniffed - * Call this only after calling nrf24_init_promisc_mode - * @param handle - pointer to FuriHalSpiHandle - * @param maclen - length of target mac address - * @param[out] addresses - sniffed address - * - * @return success - */ -bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address); - -/** Sends ping packet on each channel for designated tx mac looking for ack - * - * @param handle - pointer to FuriHalSpiHandle - * @param srcmac - source address - * @param dstmac - destination address - * @param maclen - length of address - * @param rate - transfer rate in Mbps (1 or 2) - * @param min_channel - channel to start with - * @param max_channel - channel to end at - * @param autoinit - if true, automatically configure radio for this channel - * - * @return channel that the address is listening on, if this value is above the max_channel param, it failed - */ -uint8_t nrf24_find_channel( - FuriHalSpiBusHandle* handle, - uint8_t* srcmac, - uint8_t* dstmac, - uint8_t maclen, - uint8_t rate, - uint8_t min_channel, - uint8_t max_channel, - bool autoinit); - -/** Converts 64 bit value into uint8_t array - * @param val - 64-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian); - -/** Converts 32 bit value into uint8_t array - * @param val - 32-bit integer - * @param[out] out - bytes out - * @param bigendian - if true, convert as big endian, otherwise little endian - */ -void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian); - -/** Converts uint8_t array into 32 bit value - * @param bytes - uint8_t array - * @param bigendian - if true, convert as big endian, otherwise little endian - * - * @return 32-bit value - */ -uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/nrfsniff/nrfsniff.c b/applications/plugins/nrfsniff/nrfsniff.c deleted file mode 100644 index ce2836152..000000000 --- a/applications/plugins/nrfsniff/nrfsniff.c +++ /dev/null @@ -1,459 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LOGITECH_MAX_CHANNEL 85 -#define COUNT_THRESHOLD 2 -#define DEFAULT_SAMPLE_TIME 8000 -#define MAX_ADDRS 100 -#define MAX_CONFIRMED 32 - -#define NRFSNIFF_APP_PATH_FOLDER "/ext/nrfsniff" -#define NRFSNIFF_APP_FILENAME "addresses.txt" -#define TAG "nrfsniff" - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - int x; - int y; -} PluginState; - -char rate_text_fmt[] = "Transfer rate: %dMbps"; -char sample_text_fmt[] = "Sample Time: %d ms"; -char channel_text_fmt[] = "Channel: %d Sniffing: %s"; -char preamble_text_fmt[] = "Preamble: %02X"; -char sniff_text_fmt[] = "Found: %d Unique: %u"; -char addresses_header_text[] = "Address,rate"; -char sniffed_address_fmt[] = "%s,%d"; -char rate_text[46]; -char channel_text[38]; -char sample_text[32]; -char preamble_text[14]; -char sniff_text[38]; -char sniffed_address[14]; - -uint8_t target_channel = 0; -uint32_t found_count = 0; -uint32_t unique_saved_count = 0; -uint32_t sample_time = DEFAULT_SAMPLE_TIME; -uint8_t target_rate = 8; // rate can be either 8 (2Mbps) or 0 (1Mbps) -uint8_t target_preamble[] = {0xAA, 0x00}; -uint8_t sniffing_state = false; -char top_address[12]; - -uint8_t candidates[MAX_ADDRS][5] = {0}; // last 100 sniffed addresses -uint32_t counts[MAX_ADDRS]; -uint8_t confirmed[MAX_CONFIRMED][5] = {0}; // first 32 confirmed addresses -uint8_t confirmed_idx = 0; -uint32_t total_candidates = 0; -uint32_t candidate_idx = 0; - -static int get_addr_index(uint8_t* addr, uint8_t addr_size) { - for(uint32_t i = 0; i < total_candidates; i++) { - uint8_t* arr_item = candidates[i]; - if(!memcmp(arr_item, addr, addr_size)) return i; - } - - return -1; -} - -static int get_highest_idx() { - uint32_t highest = 0; - int highest_idx = 0; - for(uint32_t i = 0; i < total_candidates; i++) { - if(counts[i] > highest) { - highest = counts[i]; - highest_idx = i; - } - } - - return highest_idx; -} - -// if array is full, start over from beginning -static void insert_addr(uint8_t* addr, uint8_t addr_size) { - if(candidate_idx >= MAX_ADDRS) candidate_idx = 0; - - memcpy(candidates[candidate_idx], addr, addr_size); - counts[candidate_idx] = 1; - if(total_candidates < MAX_ADDRS) total_candidates++; - candidate_idx++; -} - -static void render_callback(Canvas* const canvas, void* ctx) { - uint8_t rate = 2; - char sniffing[] = "Yes"; - - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - // border around the edge of the screen - canvas_draw_frame(canvas, 0, 0, 128, 64); - canvas_set_font(canvas, FontSecondary); - - if(target_rate == 0) rate = 1; - - if(!sniffing_state) strcpy(sniffing, "No"); - - snprintf(rate_text, sizeof(rate_text), rate_text_fmt, (int)rate); - snprintf(channel_text, sizeof(channel_text), channel_text_fmt, (int)target_channel, sniffing); - snprintf(sample_text, sizeof(sample_text), sample_text_fmt, (int)sample_time); - //snprintf(preamble_text, sizeof(preamble_text), preamble_text_fmt, target_preamble[0]); - snprintf(sniff_text, sizeof(sniff_text), sniff_text_fmt, found_count, unique_saved_count); - snprintf( - sniffed_address, sizeof(sniffed_address), sniffed_address_fmt, top_address, (int)rate); - canvas_draw_str_aligned(canvas, 10, 10, AlignLeft, AlignBottom, rate_text); - canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, sample_text); - canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, channel_text); - //canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, preamble_text); - canvas_draw_str_aligned(canvas, 10, 40, AlignLeft, AlignBottom, sniff_text); - canvas_draw_str_aligned(canvas, 30, 50, AlignLeft, AlignBottom, addresses_header_text); - canvas_draw_str_aligned(canvas, 30, 60, AlignLeft, AlignBottom, sniffed_address); - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void hexlify(uint8_t* in, uint8_t size, char* out) { - memset(out, 0, size * 2); - for(int i = 0; i < size; i++) - snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]); -} - -static bool save_addr_to_file( - Storage* storage, - uint8_t* data, - uint8_t size, - NotificationApp* notification) { - size_t file_size = 0; - uint8_t linesize = 0; - char filepath[42] = {0}; - char addrline[14] = {0}; - char ending[4]; - uint8_t* file_contents; - uint8_t rate = 1; - Stream* stream = file_stream_alloc(storage); - - if(target_rate == 8) rate = 2; - snprintf(ending, sizeof(ending), ",%d\n", rate); - hexlify(data, size, addrline); - strcat(addrline, ending); - linesize = strlen(addrline); - strcpy(filepath, NRFSNIFF_APP_PATH_FOLDER); - strcat(filepath, "/"); - strcat(filepath, NRFSNIFF_APP_FILENAME); - stream_seek(stream, 0, StreamOffsetFromStart); - - // check if address already exists in file - if(file_stream_open(stream, filepath, FSAM_READ_WRITE, FSOM_OPEN_APPEND)) { - bool found = false; - file_size = stream_size(stream); - stream_seek(stream, 0, StreamOffsetFromStart); - if(file_size > 0) { - file_contents = malloc(file_size + 1); - memset(file_contents, 0, file_size + 1); - if(stream_read(stream, file_contents, file_size) > 0) { - char* line = strtok((char*)file_contents, "\n"); - - while(line != NULL) { - if(!memcmp(line, addrline, 12)) { - found = true; - break; - } - line = strtok(NULL, "\n"); - } - } - free(file_contents); - } - - if(found) { - FURI_LOG_I(TAG, "Address exists in file. Ending save process."); - stream_free(stream); - return false; - } else { - if(stream_write(stream, (uint8_t*)addrline, linesize) != linesize) { - FURI_LOG_I(TAG, "Failed to write bytes to file stream."); - stream_free(stream); - return false; - } else { - FURI_LOG_I(TAG, "Found a new address: %s", addrline); - FURI_LOG_I(TAG, "Save successful!"); - - notification_message(notification, &sequence_success); - - stream_free(stream); - unique_saved_count++; - return true; - } - } - } else { - FURI_LOG_I(TAG, "Cannot open file \"%s\"", filepath); - stream_free(stream); - return false; - } -} - -void alt_address(uint8_t* addr, uint8_t* altaddr) { - uint8_t macmess_hi_b[4]; - uint32_t macmess_hi; - uint8_t macmess_lo; - uint8_t preserved; - uint8_t tmpaddr[5]; - - // swap bytes - for(int i = 0; i < 5; i++) tmpaddr[i] = addr[4 - i]; - - // get address into 32-bit and 8-bit variables - memcpy(macmess_hi_b, tmpaddr, 4); - macmess_lo = tmpaddr[4]; - - macmess_hi = bytes_to_int32(macmess_hi_b, true); - - //preserve lowest bit from hi to shift to low - preserved = macmess_hi & 1; - macmess_hi >>= 1; - macmess_lo >>= 1; - macmess_lo = (preserved << 7) | macmess_lo; - int32_to_bytes(macmess_hi, macmess_hi_b, true); - memcpy(tmpaddr, macmess_hi_b, 4); - tmpaddr[4] = macmess_lo; - - // swap bytes back - for(int i = 0; i < 5; i++) altaddr[i] = tmpaddr[4 - i]; -} - -static bool previously_confirmed(uint8_t* addr) { - bool found = false; - for(int i = 0; i < MAX_CONFIRMED; i++) { - if(!memcmp(confirmed[i], addr, 5)) { - found = true; - break; - } - } - - return found; -} - -static void wrap_up(Storage* storage, NotificationApp* notification) { - uint8_t ch; - uint8_t addr[5]; - uint8_t altaddr[5]; - char trying[12]; - int idx; - uint8_t rate = 0; - if(target_rate == 8) rate = 2; - - nrf24_set_idle(nrf24_HANDLE); - - while(true) { - idx = get_highest_idx(); - if(counts[idx] < COUNT_THRESHOLD) break; - - counts[idx] = 0; - memcpy(addr, candidates[idx], 5); - hexlify(addr, 5, trying); - FURI_LOG_I(TAG, "trying address %s", trying); - ch = nrf24_find_channel(nrf24_HANDLE, addr, addr, 5, rate, 2, LOGITECH_MAX_CHANNEL, false); - FURI_LOG_I(TAG, "find_channel returned %d", (int)ch); - if(ch > LOGITECH_MAX_CHANNEL) { - alt_address(addr, altaddr); - hexlify(altaddr, 5, trying); - FURI_LOG_I(TAG, "trying alternate address %s", trying); - ch = nrf24_find_channel( - nrf24_HANDLE, altaddr, altaddr, 5, rate, 2, LOGITECH_MAX_CHANNEL, false); - FURI_LOG_I(TAG, "find_channel returned %d", (int)ch); - memcpy(addr, altaddr, 5); - } - - if(ch <= LOGITECH_MAX_CHANNEL) { - hexlify(addr, 5, top_address); - found_count++; - save_addr_to_file(storage, addr, 5, notification); - DOLPHIN_DEED(getRandomDeed()); - if(confirmed_idx < MAX_CONFIRMED) memcpy(confirmed[confirmed_idx++], addr, 5); - break; - } - } -} - -static void clear_cache() { - found_count = 0; - unique_saved_count = 0; - confirmed_idx = 0; - candidate_idx = 0; - target_channel = 2; - total_candidates = 0; - memset(candidates, 0, sizeof(candidates)); - memset(counts, 0, sizeof(counts)); - memset(confirmed, 0, sizeof(confirmed)); -} - -static void start_sniffing() { - nrf24_init_promisc_mode(nrf24_HANDLE, target_channel, target_rate); -} - -int32_t nrfsniff_app(void* p) { - UNUSED(p); - uint8_t address[5] = {0}; - uint32_t start = 0; - hexlify(address, 5, top_address); - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - PluginState* plugin_state = malloc(sizeof(PluginState)); - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - furi_message_queue_free(event_queue); - FURI_LOG_E(TAG, "cannot create mutex\r\n"); - free(plugin_state); - return 255; - } - - nrf24_init(); - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); - - Storage* storage = furi_record_open(RECORD_STORAGE); - storage_common_mkdir(storage, NRFSNIFF_APP_PATH_FOLDER); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress || - (event.input.type == InputTypeLong && event.input.key == InputKeyBack)) { - switch(event.input.key) { - case InputKeyUp: - // toggle rate 1/2Mbps - if(!sniffing_state) { - if(target_rate == 0) - target_rate = 8; - else - target_rate = 0; - } - break; - case InputKeyDown: - // toggle preamble - if(!sniffing_state) { - if(target_preamble[0] == 0x55) - target_preamble[0] = 0xAA; - else - target_preamble[0] = 0x55; - - nrf24_set_src_mac(nrf24_HANDLE, target_preamble, 2); - } - break; - case InputKeyRight: - // increment channel - //if(!sniffing_state && target_channel <= LOGITECH_MAX_CHANNEL) - // target_channel++; - sample_time += 500; - break; - case InputKeyLeft: - // decrement channel - //if(!sniffing_state && target_channel > 0) target_channel--; - if(sample_time > 500) sample_time -= 500; - break; - case InputKeyOk: - // toggle sniffing - sniffing_state = !sniffing_state; - if(sniffing_state) { - clear_cache(); - start_sniffing(); - start = furi_get_tick(); - } else - wrap_up(storage, notification); - break; - case InputKeyBack: - if(event.input.type == InputTypeLong) processing = false; - break; - default: - break; - } - } - } - } else { - // FURI_LOG_D(TAG, "osMessageQueue: event timeout"); - // event timeout - } - - if(sniffing_state) { - if(nrf24_sniff_address(nrf24_HANDLE, 5, address)) { - int idx; - uint8_t* top_addr; - if(!previously_confirmed(address)) { - idx = get_addr_index(address, 5); - if(idx == -1) - insert_addr(address, 5); - else - counts[idx]++; - - top_addr = candidates[get_highest_idx()]; - hexlify(top_addr, 5, top_address); - } - } - - if(furi_get_tick() - start >= sample_time) { - target_channel++; - if(target_channel > LOGITECH_MAX_CHANNEL) target_channel = 2; - { - wrap_up(storage, notification); - start_sniffing(); - } - - start = furi_get_tick(); - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - clear_cache(); - sample_time = DEFAULT_SAMPLE_TIME; - target_rate = 8; // rate can be either 8 (2Mbps) or 0 (1Mbps) - sniffing_state = false; - nrf24_deinit(); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - furi_record_close(RECORD_NOTIFICATION); - furi_record_close(RECORD_STORAGE); - view_port_free(view_port); - furi_message_queue_free(event_queue); - - return 0; -} diff --git a/applications/plugins/nrfsniff/nrfsniff_10px.png b/applications/plugins/nrfsniff/nrfsniff_10px.png deleted file mode 100644 index 348b35eca..000000000 Binary files a/applications/plugins/nrfsniff/nrfsniff_10px.png and /dev/null differ diff --git a/applications/plugins/ocarina/README.md b/applications/plugins/ocarina/README.md deleted file mode 100644 index 1fcfd00fa..000000000 --- a/applications/plugins/ocarina/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# flipperzero-ocarina -A basic Ocarina (of Time) for the Flipper Zero. - -Controls are the same as the N64 version of the Ocarina of Time, the Ok button takes the place of the A button diff --git a/applications/plugins/ocarina/application.fam b/applications/plugins/ocarina/application.fam deleted file mode 100644 index 192cb2f16..000000000 --- a/applications/plugins/ocarina/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="Ocarina", - name="Ocarina", - apptype=FlipperAppType.EXTERNAL, - entry_point="ocarina_app", - cdefines=["APP_OCARINA"], - requires=["gui"], - stack_size=1 * 1024, - order=30, - fap_icon="icons/music_10px.png", - fap_category="Music", - fap_icon_assets="icons", -) diff --git a/applications/plugins/ocarina/icons/music_10px.png b/applications/plugins/ocarina/icons/music_10px.png deleted file mode 100644 index d41eb0db8..000000000 Binary files a/applications/plugins/ocarina/icons/music_10px.png and /dev/null differ diff --git a/applications/plugins/ocarina/ocarina.c b/applications/plugins/ocarina/ocarina.c deleted file mode 100644 index 013f81ab8..000000000 --- a/applications/plugins/ocarina/ocarina.c +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include -#include -#include - -#define NOTE_UP 587.33f -#define NOTE_LEFT 493.88f -#define NOTE_RIGHT 440.00f -#define NOTE_DOWN 349.23 -#define NOTE_OK 293.66f - -typedef struct { - FuriMutex* model_mutex; - - FuriMessageQueue* event_queue; - - ViewPort* view_port; - Gui* gui; -} Ocarina; - -void draw_callback(Canvas* canvas, void* ctx) { - Ocarina* ocarina = ctx; - furi_check(furi_mutex_acquire(ocarina->model_mutex, FuriWaitForever) == FuriStatusOk); - - //canvas_draw_box(canvas, ocarina->model->x, ocarina->model->y, 4, 4); - canvas_draw_frame(canvas, 0, 0, 128, 64); - canvas_draw_str(canvas, 50, 10, "Ocarina"); - canvas_draw_str(canvas, 30, 20, "OK button for A"); - - furi_mutex_release(ocarina->model_mutex); -} - -void input_callback(InputEvent* input, void* ctx) { - Ocarina* ocarina = ctx; - // Puts input onto event queue with priority 0, and waits until completion. - furi_message_queue_put(ocarina->event_queue, input, FuriWaitForever); -} - -Ocarina* ocarina_alloc() { - Ocarina* instance = malloc(sizeof(Ocarina)); - - instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); - - instance->event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - view_port_input_callback_set(instance->view_port, input_callback, instance); - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - return instance; -} - -void ocarina_free(Ocarina* instance) { - view_port_enabled_set(instance->view_port, false); // Disabsles our ViewPort - gui_remove_view_port(instance->gui, instance->view_port); // Removes our ViewPort from the Gui - furi_record_close("gui"); // Closes the gui record - view_port_free(instance->view_port); // Frees memory allocated by view_port_alloc - furi_message_queue_free(instance->event_queue); - - furi_mutex_free(instance->model_mutex); - - furi_hal_speaker_stop(); - - free(instance); -} - -int32_t ocarina_app(void* p) { - UNUSED(p); - - Ocarina* ocarina = ocarina_alloc(); - - InputEvent event; - for(bool processing = true; processing;) { - // Pops a message off the queue and stores it in `event`. - // No message priority denoted by NULL, and 100 ticks of timeout. - FuriStatus status = furi_message_queue_get(ocarina->event_queue, &event, 100); - furi_check(furi_mutex_acquire(ocarina->model_mutex, FuriWaitForever) == FuriStatusOk); - - float volume = 1.0f; - if(status == FuriStatusOk) { - if(event.type == InputTypePress) { - switch(event.key) { - case InputKeyUp: - furi_hal_speaker_start(NOTE_UP, volume); - break; - case InputKeyDown: - furi_hal_speaker_start(NOTE_DOWN, volume); - break; - case InputKeyLeft: - furi_hal_speaker_start(NOTE_LEFT, volume); - break; - case InputKeyRight: - furi_hal_speaker_start(NOTE_RIGHT, volume); - break; - case InputKeyOk: - furi_hal_speaker_start(NOTE_OK, volume); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } else if(event.type == InputTypeRelease) { - furi_hal_speaker_stop(); - } - } - - furi_mutex_release(ocarina->model_mutex); - view_port_update(ocarina->view_port); // signals our draw callback - } - ocarina_free(ocarina); - return 0; -} diff --git a/applications/plugins/rc2014_coleco/LICENSE b/applications/plugins/rc2014_coleco/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/rc2014_coleco/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/rc2014_coleco/README.md b/applications/plugins/rc2014_coleco/README.md deleted file mode 100644 index 0667860e7..000000000 --- a/applications/plugins/rc2014_coleco/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# RC2014 ColecoVision Controller for Flipper Zero - -A Flipper Zero application and [RC2014] module allowing the Flipper to be used as a controller for ColecoVision games on -the [RC2014]. - -![ui](ui.png) - -## Running ColecoVision Games on the RC2014 - -A full tutorial is out of scope here, but briefly, you will need a [RC2014] with J. B. Langston's [TMS9918A Video Card] -and [SN76489 Sound Card], as well as some way to launch ColecoVision ROMs. - -Note that if you're using the standard pageable ROM module (e.g. if you're using the stock Pro kit), you will need to -[modify it](https://github.com/jblang/TMS9918A/issues/12) in order for the TMS9918A module to work on the ColecoVision -port addresses. - -## Hardware Setup - -The [interface](interface) directory contains Eagle schematics for a RC2014 module that handles the controller port -addressing for two players, breaking out the 8 data line inputs as well as the mode select line. This can actually be -used for different controller implementations and is slightly more flexible than the actual [ColecoVision] spec. - -To use this with the Flipper Zero and this application, a GPIO board is needed to provide hardware multiplexing for the -data lines. A schematic for the GPIO board will be added to this repository soon. - -## Building the FAP - -1. Clone the [flipperzero-firmware] repository. -2. Create a symbolic link in `applications_user` named `coleco`, pointing to this repository. -3. Compile with `./fbt fap_coleco`. -4. Copy `build/f7-firmware-D/.extapps/coleco.fap` to `apps/Misc` on the SD card (directly or using [qFlipper]). - -[RC2014]: https://rc2014.co.uk/ -[TMS9918A Video Card]: https://github.com/jblang/TMS9918A -[SN76489 Sound Card]: https://github.com/jblang/SN76489 -[ColecoVision]: http://www.atarihq.com/danb/files/CV-Tech.txt -[flipperzero-firmware]: https://github.com/flipperdevices/flipperzero-firmware -[qFlipper]: https://flipperzero.one/update diff --git a/applications/plugins/rc2014_coleco/application.fam b/applications/plugins/rc2014_coleco/application.fam deleted file mode 100644 index 2a3900e19..000000000 --- a/applications/plugins/rc2014_coleco/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="RC2014_Coleco", - name="RC2014 ColecoVision", - apptype=FlipperAppType.EXTERNAL, - entry_point="coleco_app", - cdefines=["APP_COLECO"], - requires=["gui"], - stack_size=1 * 1024, - order=35, - fap_icon="coleco_10px.png", - fap_icon_assets="icons", - fap_category="GPIO", -) diff --git a/applications/plugins/rc2014_coleco/coleco.c b/applications/plugins/rc2014_coleco/coleco.c deleted file mode 100644 index 6ae050633..000000000 --- a/applications/plugins/rc2014_coleco/coleco.c +++ /dev/null @@ -1,366 +0,0 @@ -#include -#include -#include -#include -#include "RC2014_Coleco_icons.h" - -#define CODE_0 0x0A -#define CODE_1 0x0D -#define CODE_2 0x07 -#define CODE_3 0x0C -#define CODE_4 0x02 -#define CODE_5 0x03 -#define CODE_6 0x0E -#define CODE_7 0x05 -#define CODE_8 0x01 -#define CODE_9 0x0B -#define CODE_H 0x06 -#define CODE_S 0x09 -#define CODE_N 0x0F - -const GpioPin* const pin_up = &gpio_ext_pa6; -const GpioPin* const pin_down = &gpio_ext_pc0; -const GpioPin* const pin_right = &gpio_ext_pb2; -const GpioPin* const pin_left = &gpio_ext_pc3; -const GpioPin* const pin_code0 = &gpio_ext_pa7; -const GpioPin* const pin_code1 = &gpio_ext_pa4; -const GpioPin* const pin_code2 = &ibutton_gpio; -const GpioPin* const pin_code3 = &gpio_ext_pc1; -const GpioPin* const pin_fire = &gpio_ext_pb3; -const GpioPin* const pin_alt = &gpio_usart_tx; - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - bool dpad; - int row; - int column; -} Coleco; - -static void render_callback(Canvas* const canvas, void* context) { - Coleco* coleco = acquire_mutex((ValueMutex*)context, 25); - if(coleco == NULL) { - return; - } - - if(coleco->dpad) { - canvas_draw_icon(canvas, 4, 16, &I_ColecoJoystick_sel_33x33); - canvas_draw_icon(canvas, 27, 52, &I_ColecoFire_sel_18x9); - } else { - const bool hvr = coleco->row == 0 && coleco->column < 2; - canvas_draw_icon( - canvas, 4, 16, hvr ? &I_ColecoJoystick_hvr_33x33 : &I_ColecoJoystick_33x33); - canvas_draw_icon(canvas, 27, 52, hvr ? &I_ColecoFire_hvr_18x9 : &I_ColecoFire_18x9); - } - - canvas_draw_icon( - canvas, - 27, - 4, - (coleco->row == 0 && coleco->column == 2) ? &I_ColecoAlt_hvr_18x9 : &I_ColecoAlt_18x9); - canvas_draw_icon( - canvas, - 49, - 44, - (coleco->row == 1 && coleco->column == 0) ? &I_Coleco1_hvr_17x17 : &I_Coleco1_17x17); - canvas_draw_icon( - canvas, - 49, - 24, - (coleco->row == 1 && coleco->column == 1) ? &I_Coleco2_hvr_17x17 : &I_Coleco2_17x17); - canvas_draw_icon( - canvas, - 49, - 4, - (coleco->row == 1 && coleco->column == 2) ? &I_Coleco3_hvr_17x17 : &I_Coleco3_17x17); - canvas_draw_icon( - canvas, - 69, - 44, - (coleco->row == 2 && coleco->column == 0) ? &I_Coleco4_hvr_17x17 : &I_Coleco4_17x17); - canvas_draw_icon( - canvas, - 69, - 24, - (coleco->row == 2 && coleco->column == 1) ? &I_Coleco5_hvr_17x17 : &I_Coleco5_17x17); - canvas_draw_icon( - canvas, - 69, - 4, - (coleco->row == 2 && coleco->column == 2) ? &I_Coleco6_hvr_17x17 : &I_Coleco6_17x17); - canvas_draw_icon( - canvas, - 89, - 44, - (coleco->row == 3 && coleco->column == 0) ? &I_Coleco7_hvr_17x17 : &I_Coleco7_17x17); - canvas_draw_icon( - canvas, - 89, - 24, - (coleco->row == 3 && coleco->column == 1) ? &I_Coleco8_hvr_17x17 : &I_Coleco8_17x17); - canvas_draw_icon( - canvas, - 89, - 4, - (coleco->row == 3 && coleco->column == 2) ? &I_Coleco9_hvr_17x17 : &I_Coleco9_17x17); - canvas_draw_icon( - canvas, - 109, - 44, - (coleco->row == 4 && coleco->column == 0) ? &I_ColecoStar_hvr_17x17 : &I_ColecoStar_17x17); - canvas_draw_icon( - canvas, - 109, - 24, - (coleco->row == 4 && coleco->column == 1) ? &I_Coleco0_hvr_17x17 : &I_Coleco0_17x17); - canvas_draw_icon( - canvas, - 109, - 4, - (coleco->row == 4 && coleco->column == 2) ? &I_ColecoPound_hvr_17x17 : - &I_ColecoPound_17x17); - - release_mutex((ValueMutex*)context, coleco); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void coleco_write_code(uint8_t code) { - furi_hal_gpio_write(pin_code0, (code & 1)); - furi_hal_gpio_write(pin_code1, (code & 2)); - furi_hal_gpio_write(pin_code2, (code & 4)); - furi_hal_gpio_write(pin_code3, (code & 8)); -} - -static void coleco_gpio_init() { - // configure output pins - furi_hal_gpio_init(pin_up, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_down, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_right, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_left, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_code0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_code1, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_code2, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_code3, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_fire, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - furi_hal_gpio_init(pin_alt, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh); - - furi_hal_gpio_write(pin_up, true); - furi_hal_gpio_write(pin_down, true); - furi_hal_gpio_write(pin_right, true); - furi_hal_gpio_write(pin_left, true); - furi_hal_gpio_write(pin_fire, true); - furi_hal_gpio_write(pin_alt, true); - - coleco_write_code(CODE_N); -} - -static Coleco* coleco_alloc() { - Coleco* coleco = malloc(sizeof(Coleco)); - - coleco->dpad = false; - coleco->row = 0; - coleco->column = 1; - - return coleco; -} - -static void coleco_free(Coleco* coleco) { - furi_assert(coleco); - - free(coleco); -} - -int32_t coleco_app(void* p) { - UNUSED(p); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - Coleco* coleco = coleco_alloc(); - - ValueMutex coleco_mutex; - if(!init_mutex(&coleco_mutex, coleco, sizeof(Coleco))) { - FURI_LOG_E("Coleco", "cannot create mutex\r\n"); - coleco_free(coleco); - return 255; - } - - // set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &coleco_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - coleco_gpio_init(); - furi_hal_power_enable_otg(); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - Coleco* coleco = (Coleco*)acquire_mutex_block(&coleco_mutex); - - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - switch(event.input.key) { - case InputKeyUp: - if(coleco->dpad) { - if(event.input.type == InputTypePress) { - furi_hal_gpio_write(pin_up, false); - } else if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_up, true); - } - } else { - if(event.input.type == InputTypePress && coleco->column < 2) { - coleco->column++; - coleco_write_code(CODE_N); - } - } - break; - case InputKeyDown: - if(coleco->dpad) { - if(event.input.type == InputTypePress) { - furi_hal_gpio_write(pin_down, false); - } else if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_down, true); - } - } else { - if(event.input.type == InputTypePress && coleco->column > 0) { - coleco->column--; - coleco_write_code(CODE_N); - } - } - break; - case InputKeyRight: - if(coleco->dpad) { - if(event.input.type == InputTypePress) { - furi_hal_gpio_write(pin_right, false); - } else if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_right, true); - } - } else { - if(event.input.type == InputTypePress && coleco->row < 4) { - coleco->row++; - coleco_write_code(CODE_N); - } - } - break; - case InputKeyLeft: - if(coleco->dpad) { - if(event.input.type == InputTypePress) { - furi_hal_gpio_write(pin_left, false); - } else if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_left, true); - } - } else { - if(event.input.type == InputTypePress && coleco->row > 0) { - coleco->row--; - coleco_write_code(CODE_N); - } - } - break; - case InputKeyOk: - if(coleco->dpad) { - if(event.input.type == InputTypePress) { - furi_hal_gpio_write(pin_fire, false); - } else if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_fire, true); - } - } else { - if(event.input.type == InputTypePress) { - if(coleco->row == 0) { - if(coleco->column == 2) { - furi_hal_gpio_write(pin_alt, false); - } else { - coleco->dpad = true; - } - } else if(coleco->row == 1) { - if(coleco->column == 0) { - coleco_write_code(CODE_1); - } else if(coleco->column == 1) { - coleco_write_code(CODE_2); - } else { - coleco_write_code(CODE_3); - } - } else if(coleco->row == 2) { - if(coleco->column == 0) { - coleco_write_code(CODE_4); - } else if(coleco->column == 1) { - coleco_write_code(CODE_5); - } else { - coleco_write_code(CODE_6); - } - } else if(coleco->row == 3) { - if(coleco->column == 0) { - coleco_write_code(CODE_7); - } else if(coleco->column == 1) { - coleco_write_code(CODE_8); - } else { - coleco_write_code(CODE_9); - } - } else if(coleco->row == 4) { - if(coleco->column == 0) { - coleco_write_code(CODE_S); - } else if(coleco->column == 1) { - coleco_write_code(CODE_0); - } else { - coleco_write_code(CODE_H); - } - } - } - if(event.input.type == InputTypeRelease) { - furi_hal_gpio_write(pin_alt, true); - coleco_write_code(CODE_N); - } - } - break; - case InputKeyBack: - if(event.input.type == InputTypePress) { - if(coleco->dpad) { - coleco->dpad = false; - } else { - processing = false; - } - } - break; - default: - break; - } - - view_port_update(view_port); - } - } else { - FURI_LOG_D("Coleco", "FuriMessageQueue: event timeout"); - } - - release_mutex(&coleco_mutex, coleco); - } - - furi_hal_power_disable_otg(); - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&coleco_mutex); - coleco_free(coleco); - return 0; -} diff --git a/applications/plugins/rc2014_coleco/coleco_10px.png b/applications/plugins/rc2014_coleco/coleco_10px.png deleted file mode 100644 index d51652adc..000000000 Binary files a/applications/plugins/rc2014_coleco/coleco_10px.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco0_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco0_17x17.png deleted file mode 100644 index b53bc3b5f..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco0_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco0_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco0_hvr_17x17.png deleted file mode 100644 index 19627388e..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco0_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco1_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco1_17x17.png deleted file mode 100644 index 2c3977967..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco1_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco1_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco1_hvr_17x17.png deleted file mode 100644 index 562c7e8db..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco1_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco2_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco2_17x17.png deleted file mode 100644 index f8f18405f..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco2_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco2_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco2_hvr_17x17.png deleted file mode 100644 index cac468981..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco2_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco3_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco3_17x17.png deleted file mode 100644 index 3f2288392..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco3_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco3_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco3_hvr_17x17.png deleted file mode 100644 index c0015312a..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco3_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco4_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco4_17x17.png deleted file mode 100644 index b3888910c..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco4_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco4_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco4_hvr_17x17.png deleted file mode 100644 index 63e086275..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco4_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco5_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco5_17x17.png deleted file mode 100644 index 42eb3f59d..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco5_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco5_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco5_hvr_17x17.png deleted file mode 100644 index b06fdfaf9..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco5_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco6_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco6_17x17.png deleted file mode 100644 index 6ed3e239c..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco6_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco6_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco6_hvr_17x17.png deleted file mode 100644 index 4be93b365..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco6_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco7_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco7_17x17.png deleted file mode 100644 index 2d200d71b..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco7_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco7_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco7_hvr_17x17.png deleted file mode 100644 index 8886dffef..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco7_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco8_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco8_17x17.png deleted file mode 100644 index 3905ef80d..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco8_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco8_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco8_hvr_17x17.png deleted file mode 100644 index 519ac1e97..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco8_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco9_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco9_17x17.png deleted file mode 100644 index a51739a1b..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco9_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/Coleco9_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/Coleco9_hvr_17x17.png deleted file mode 100644 index 206e0acd9..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/Coleco9_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoAlt_18x9.png b/applications/plugins/rc2014_coleco/icons/ColecoAlt_18x9.png deleted file mode 100644 index 7e6853e52..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoAlt_18x9.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoAlt_hvr_18x9.png b/applications/plugins/rc2014_coleco/icons/ColecoAlt_hvr_18x9.png deleted file mode 100644 index 6b15dcf7b..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoAlt_hvr_18x9.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoFire_18x9.png b/applications/plugins/rc2014_coleco/icons/ColecoFire_18x9.png deleted file mode 100644 index 8be499c21..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoFire_18x9.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoFire_hvr_18x9.png b/applications/plugins/rc2014_coleco/icons/ColecoFire_hvr_18x9.png deleted file mode 100644 index 2b0d1d72c..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoFire_hvr_18x9.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoFire_sel_18x9.png b/applications/plugins/rc2014_coleco/icons/ColecoFire_sel_18x9.png deleted file mode 100644 index 383cd3a2d..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoFire_sel_18x9.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_33x33.png b/applications/plugins/rc2014_coleco/icons/ColecoJoystick_33x33.png deleted file mode 100644 index de4c574bc..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_33x33.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_hvr_33x33.png b/applications/plugins/rc2014_coleco/icons/ColecoJoystick_hvr_33x33.png deleted file mode 100644 index fd653bfaf..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_hvr_33x33.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_sel_33x33.png b/applications/plugins/rc2014_coleco/icons/ColecoJoystick_sel_33x33.png deleted file mode 100644 index ea01af395..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoJoystick_sel_33x33.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoPound_17x17.png b/applications/plugins/rc2014_coleco/icons/ColecoPound_17x17.png deleted file mode 100644 index 10b46e0ca..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoPound_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoPound_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/ColecoPound_hvr_17x17.png deleted file mode 100644 index 784f3687c..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoPound_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoStar_17x17.png b/applications/plugins/rc2014_coleco/icons/ColecoStar_17x17.png deleted file mode 100644 index 3031c0baf..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoStar_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/icons/ColecoStar_hvr_17x17.png b/applications/plugins/rc2014_coleco/icons/ColecoStar_hvr_17x17.png deleted file mode 100644 index 546922971..000000000 Binary files a/applications/plugins/rc2014_coleco/icons/ColecoStar_hvr_17x17.png and /dev/null differ diff --git a/applications/plugins/rc2014_coleco/interface/flipper-coleco.brd b/applications/plugins/rc2014_coleco/interface/flipper-coleco.brd deleted file mode 100644 index 47ed27322..000000000 --- a/applications/plugins/rc2014_coleco/interface/flipper-coleco.brd +++ /dev/null @@ -1,2554 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -COLECOVISION -INTERFACE -PLAYER 1 -PLAYER 2 -74HCT138 -74HCT00 -74HCT541 -74HCT541 - - - -<b>TTL Devices, 74xx Series with US Symbols</b><p> -Based on the following sources: -<ul> -<li>Texas Instruments <i>TTL Data Book</i>&nbsp;&nbsp;&nbsp;Volume 1, 1996. -<li>TTL Data Book, Volume 2 , 1993 -<li>National Seminconductor Databook 1990, ALS/LS Logic -<li>ttl 74er digital data dictionary, ECA Electronic + Acustic GmbH, ISBN 3-88109-032-0 -<li>http://icmaster.com/ViewCompare.asp -</ul> -<author>Created by librarian@cadsoft.de</author> - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>Resistors, Capacitors, Inductors</b><p> -Based on the previous libraries: -<ul> -<li>r.lbr -<li>cap.lbr -<li>cap-fe.lbr -<li>captant.lbr -<li>polcap.lbr -<li>ipc-smd.lbr -</ul> -All SMD packages are defined according to the IPC specifications and CECC<p> -<author>Created by librarian@cadsoft.de</author><p> -<p> -for Electrolyt Capacitors see also :<p> -www.bccomponents.com <p> -www.panasonic.com<p> -www.kemet.com<p> -http://www.secc.co.jp/pdf/os_e/2004/e_os_all.pdf <b>(SANYO)</b> -<p> -for trimmer refence see : <u>www.electrospec-inc.com/cross_references/trimpotcrossref.asp</u><p> - -<table border=0 cellspacing=0 cellpadding=0 width="100%" cellpaddding=0> -<tr valign="top"> - -<! <td width="10">&nbsp;</td> -<td width="90%"> - -<b><font color="#0000FF" size="4">TRIM-POT CROSS REFERENCE</font></b> -<P> -<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2> - <TR> - <TD COLSPAN=8> - <FONT SIZE=3 FACE=ARIAL><B>RECTANGULAR MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">BOURNS</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">BI&nbsp;TECH</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">DALE-VISHAY</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">PHILIPS/MEPCO</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">MURATA</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">PANASONIC</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">SPECTROL</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">MILSPEC</FONT> - </B> - </TD><TD>&nbsp;</TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3 > - 3005P<BR> - 3006P<BR> - 3006W<BR> - 3006Y<BR> - 3009P<BR> - 3009W<BR> - 3009Y<BR> - 3057J<BR> - 3057L<BR> - 3057P<BR> - 3057Y<BR> - 3059J<BR> - 3059L<BR> - 3059P<BR> - 3059Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 89P<BR> - 89W<BR> - 89X<BR> - 89PH<BR> - 76P<BR> - 89XH<BR> - 78SLT<BR> - 78L&nbsp;ALT<BR> - 56P&nbsp;ALT<BR> - 78P&nbsp;ALT<BR> - T8S<BR> - 78L<BR> - 56P<BR> - 78P<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - T18/784<BR> - 783<BR> - 781<BR> - -<BR> - -<BR> - -<BR> - 2199<BR> - 1697/1897<BR> - 1680/1880<BR> - 2187<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 8035EKP/CT20/RJ-20P<BR> - -<BR> - RJ-20X<BR> - -<BR> - -<BR> - -<BR> - 1211L<BR> - 8012EKQ&nbsp;ALT<BR> - 8012EKR&nbsp;ALT<BR> - 1211P<BR> - 8012EKJ<BR> - 8012EKL<BR> - 8012EKQ<BR> - 8012EKR<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 2101P<BR> - 2101W<BR> - 2101Y<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 2102L<BR> - 2102S<BR> - 2102Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - EVMCOG<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 43P<BR> - 43W<BR> - 43Y<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 40L<BR> - 40P<BR> - 40Y<BR> - 70Y-T602<BR> - 70L<BR> - 70P<BR> - 70Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - RT/RTR12<BR> - RT/RTR12<BR> - RT/RTR12<BR> - -<BR> - RJ/RJR12<BR> - RJ/RJR12<BR> - RJ/RJR12<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=8>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=8> - <FONT SIZE=4 FACE=ARIAL><B>SQUARE MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3250L<BR> - 3250P<BR> - 3250W<BR> - 3250X<BR> - 3252P<BR> - 3252W<BR> - 3252X<BR> - 3260P<BR> - 3260W<BR> - 3260X<BR> - 3262P<BR> - 3262W<BR> - 3262X<BR> - 3266P<BR> - 3266W<BR> - 3266X<BR> - 3290H<BR> - 3290P<BR> - 3290W<BR> - 3292P<BR> - 3292W<BR> - 3292X<BR> - 3296P<BR> - 3296W<BR> - 3296X<BR> - 3296Y<BR> - 3296Z<BR> - 3299P<BR> - 3299W<BR> - 3299X<BR> - 3299Y<BR> - 3299Z<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66X&nbsp;ALT<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66X&nbsp;ALT<BR> - -<BR> - 64W&nbsp;ALT<BR> - -<BR> - 64P&nbsp;ALT<BR> - 64W&nbsp;ALT<BR> - 64X&nbsp;ALT<BR> - 64P<BR> - 64W<BR> - 64X<BR> - 66X&nbsp;ALT<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66P<BR> - 66W<BR> - 66X<BR> - 67P<BR> - 67W<BR> - 67X<BR> - 67Y<BR> - 67Z<BR> - 68P<BR> - 68W<BR> - 68X<BR> - 67Y&nbsp;ALT<BR> - 67Z&nbsp;ALT<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 5050<BR> - 5091<BR> - 5080<BR> - 5087<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - T63YB<BR> - T63XB<BR> - -<BR> - -<BR> - -<BR> - 5887<BR> - 5891<BR> - 5880<BR> - -<BR> - -<BR> - -<BR> - T93Z<BR> - T93YA<BR> - T93XA<BR> - T93YB<BR> - T93XB<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 8026EKP<BR> - 8026EKW<BR> - 8026EKM<BR> - 8026EKP<BR> - 8026EKB<BR> - 8026EKM<BR> - 1309X<BR> - 1309P<BR> - 1309W<BR> - 8024EKP<BR> - 8024EKW<BR> - 8024EKN<BR> - RJ-9P/CT9P<BR> - RJ-9W<BR> - RJ-9X<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3103P<BR> - 3103Y<BR> - 3103Z<BR> - 3103P<BR> - 3103Y<BR> - 3103Z<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3105P/3106P<BR> - 3105W/3106W<BR> - 3105X/3106X<BR> - 3105Y/3106Y<BR> - 3105Z/3105Z<BR> - 3102P<BR> - 3102W<BR> - 3102X<BR> - 3102Y<BR> - 3102Z<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - EVMCBG<BR> - EVMCCG<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 55-1-X<BR> - 55-4-X<BR> - 55-3-X<BR> - 55-2-X<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 50-2-X<BR> - 50-4-X<BR> - 50-3-X<BR> - -<BR> - -<BR> - -<BR> - 64P<BR> - 64W<BR> - 64X<BR> - 64Y<BR> - 64Z<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - RT/RTR22<BR> - RT/RTR22<BR> - RT/RTR22<BR> - RT/RTR22<BR> - RJ/RJR22<BR> - RJ/RJR22<BR> - RJ/RJR22<BR> - RT/RTR26<BR> - RT/RTR26<BR> - RT/RTR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RT/RTR24<BR> - RT/RTR24<BR> - RT/RTR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=8>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=8> - <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3323P<BR> - 3323S<BR> - 3323W<BR> - 3329H<BR> - 3329P<BR> - 3329W<BR> - 3339H<BR> - 3339P<BR> - 3339W<BR> - 3352E<BR> - 3352H<BR> - 3352K<BR> - 3352P<BR> - 3352T<BR> - 3352V<BR> - 3352W<BR> - 3362H<BR> - 3362M<BR> - 3362P<BR> - 3362R<BR> - 3362S<BR> - 3362U<BR> - 3362W<BR> - 3362X<BR> - 3386B<BR> - 3386C<BR> - 3386F<BR> - 3386H<BR> - 3386K<BR> - 3386M<BR> - 3386P<BR> - 3386S<BR> - 3386W<BR> - 3386X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 25P<BR> - 25S<BR> - 25RX<BR> - 82P<BR> - 82M<BR> - 82PA<BR> - -<BR> - -<BR> - -<BR> - 91E<BR> - 91X<BR> - 91T<BR> - 91B<BR> - 91A<BR> - 91V<BR> - 91W<BR> - 25W<BR> - 25V<BR> - 25P<BR> - -<BR> - 25S<BR> - 25U<BR> - 25RX<BR> - 25X<BR> - 72XW<BR> - 72XL<BR> - 72PM<BR> - 72RX<BR> - -<BR> - 72PX<BR> - 72P<BR> - 72RXW<BR> - 72RXL<BR> - 72X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - T7YB<BR> - T7YA<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - TXD<BR> - TYA<BR> - TYP<BR> - -<BR> - TYD<BR> - TX<BR> - -<BR> - 150SX<BR> - 100SX<BR> - 102T<BR> - 101S<BR> - 190T<BR> - 150TX<BR> - 101<BR> - -<BR> - -<BR> - 101SX<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ET6P<BR> - ET6S<BR> - ET6X<BR> - RJ-6W/8014EMW<BR> - RJ-6P/8014EMP<BR> - RJ-6X/8014EMX<BR> - TM7W<BR> - TM7P<BR> - TM7X<BR> - -<BR> - 8017SMS<BR> - -<BR> - 8017SMB<BR> - 8017SMA<BR> - -<BR> - -<BR> - CT-6W<BR> - CT-6H<BR> - CT-6P<BR> - CT-6R<BR> - -<BR> - CT-6V<BR> - CT-6X<BR> - -<BR> - -<BR> - 8038EKV<BR> - -<BR> - 8038EKX<BR> - -<BR> - -<BR> - 8038EKP<BR> - 8038EKZ<BR> - 8038EKW<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - 3321H<BR> - 3321P<BR> - 3321N<BR> - 1102H<BR> - 1102P<BR> - 1102T<BR> - RVA0911V304A<BR> - -<BR> - RVA0911H413A<BR> - RVG0707V100A<BR> - RVA0607V(H)306A<BR> - RVA1214H213A<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3104B<BR> - 3104C<BR> - 3104F<BR> - 3104H<BR> - -<BR> - 3104M<BR> - 3104P<BR> - 3104S<BR> - 3104W<BR> - 3104X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - EVMQ0G<BR> - EVMQIG<BR> - EVMQ3G<BR> - EVMS0G<BR> - EVMQ0G<BR> - EVMG0G<BR> - -<BR> - -<BR> - -<BR> - EVMK4GA00B<BR> - EVM30GA00B<BR> - EVMK0GA00B<BR> - EVM38GA00B<BR> - EVMB6<BR> - EVLQ0<BR> - -<BR> - EVMMSG<BR> - EVMMBG<BR> - EVMMAG<BR> - -<BR> - -<BR> - EVMMCS<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - EVMM1<BR> - -<BR> - -<BR> - EVMM0<BR> - -<BR> - -<BR> - EVMM3<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - 62-3-1<BR> - 62-1-2<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 67R<BR> - -<BR> - 67P<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 67X<BR> - 63V<BR> - 63S<BR> - 63M<BR> - -<BR> - -<BR> - 63H<BR> - 63P<BR> - -<BR> - -<BR> - 63X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - RJ/RJR50<BR> - RJ/RJR50<BR> - RJ/RJR50<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> -</TABLE> -<P>&nbsp;<P> -<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3> - <TR> - <TD COLSPAN=7> - <FONT color="#0000FF" SIZE=4 FACE=ARIAL><B>SMD TRIM-POT CROSS REFERENCE</B></FONT> - <P> - <FONT SIZE=4 FACE=ARIAL><B>MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3224G<BR> - 3224J<BR> - 3224W<BR> - 3269P<BR> - 3269W<BR> - 3269X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 44G<BR> - 44J<BR> - 44W<BR> - 84P<BR> - 84W<BR> - 84X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - ST63Z<BR> - ST63Y<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - ST5P<BR> - ST5W<BR> - ST5X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=7>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=7> - <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> - </TD> - </TR> - <TR> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3314G<BR> - 3314J<BR> - 3364A/B<BR> - 3364C/D<BR> - 3364W/X<BR> - 3313G<BR> - 3313J<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 23B<BR> - 23A<BR> - 21X<BR> - 21W<BR> - -<BR> - 22B<BR> - 22A<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ST5YL/ST53YL<BR> - ST5YJ/5T53YJ<BR> - ST-23A<BR> - ST-22B<BR> - ST-22<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ST-4B<BR> - ST-4A<BR> - -<BR> - -<BR> - -<BR> - ST-3B<BR> - ST-3A<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - EVM-6YS<BR> - EVM-1E<BR> - EVM-1G<BR> - EVM-1D<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - G4B<BR> - G4A<BR> - TR04-3S1<BR> - TRG04-2S1<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - DVR-43A<BR> - CVR-42C<BR> - CVR-42A/C<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> -</TABLE> -<P> -<FONT SIZE=4 FACE=ARIAL><B>ALT =&nbsp;ALTERNATE</B></FONT> -<P> - -&nbsp; -<P> -</td> -</tr> -</table> - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 2.4 x 4.4 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - -<b>Pin Header Connectors</b><p> -<author>Created by librarian@cadsoft.de</author> - - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - -<b>EAGLE Design Rules</b> -<p> -Die Standard-Design-Rules sind so gewählt, dass sie für -die meisten Anwendungen passen. Sollte ihre Platine -besondere Anforderungen haben, treffen Sie die erforderlichen -Einstellungen hier und speichern die Design Rules unter -einem neuen Namen ab. -<b>Laen's PCB Order Design Rules</b> -<p> -Please make sure your boards conform to these design rules. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Since Version 6.2.2 text objects can contain more than one line, -which will not be processed correctly with this version. - - - diff --git a/applications/plugins/rc2014_coleco/interface/flipper-coleco.sch b/applications/plugins/rc2014_coleco/interface/flipper-coleco.sch deleted file mode 100644 index c29acd315..000000000 --- a/applications/plugins/rc2014_coleco/interface/flipper-coleco.sch +++ /dev/null @@ -1,5482 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>TTL Devices, 74xx Series with US Symbols</b><p> -Based on the following sources: -<ul> -<li>Texas Instruments <i>TTL Data Book</i>&nbsp;&nbsp;&nbsp;Volume 1, 1996. -<li>TTL Data Book, Volume 2 , 1993 -<li>National Seminconductor Databook 1990, ALS/LS Logic -<li>ttl 74er digital data dictionary, ECA Electronic + Acustic GmbH, ISBN 3-88109-032-0 -<li>http://icmaster.com/ViewCompare.asp -</ul> -<author>Created by librarian@cadsoft.de</author> - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Wide Small Outline package</b> 300 mil - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->VALUE ->NAME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>Leadless Chip Carrier</b><p> Ceramic Package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Small Outline package</b> 150 mil - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->VALUE ->NAME - - - - - - - - - - - - - - - - - - -<b>Dual In Line Package</b> - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Small Outline package</b> 150 mil - - - - - - - - - - - - - - - - - - - - - - - - - - ->VALUE ->NAME - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - ->NAME -GND -VCC - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - -Octal <b>BUFFER</b> and <b>LINE DRIVER</b>, 3-state - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -3-line to 8-line <b>DECODER/DEMULTIPLEXER</b> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Quad 2-input <b>NAND</b> gate - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -A15 -A0 -M1 -RST -CLK -INT -MREQ -WR -RO -IORQ -D0 -D7 -TX -RX - - ->NAME -GND -VCC - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>Pin Header Connectors</b><p> -<author>Created by librarian@cadsoft.de</author> - - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - - - - - - - - - - - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<b>Supply Symbols</b><p> - GND, VCC, 0V, +5V, -5V, etc.<p> - Please keep in mind, that these devices are necessary for the - automatic wiring of the supply signals.<p> - The pin name defined in the symbol is identical to the net which is to be wired automatically.<p> - In this library the device names are the same as the pin names of the symbols, therefore the correct signal names appear next to the supply symbols in the schematic.<p> - <author>Created by librarian@cadsoft.de</author> - - - - - ->VALUE - - - - - ->VALUE - - - - - -<b>SUPPLY SYMBOL</b> - - - - - - - - - - - - -<b>SUPPLY SYMBOL</b> - - - - - - - - - - - - - - -<b>Resistors, Capacitors, Inductors</b><p> -Based on the previous libraries: -<ul> -<li>r.lbr -<li>cap.lbr -<li>cap-fe.lbr -<li>captant.lbr -<li>polcap.lbr -<li>ipc-smd.lbr -</ul> -All SMD packages are defined according to the IPC specifications and CECC<p> -<author>Created by librarian@cadsoft.de</author><p> -<p> -for Electrolyt Capacitors see also :<p> -www.bccomponents.com <p> -www.panasonic.com<p> -www.kemet.com<p> -http://www.secc.co.jp/pdf/os_e/2004/e_os_all.pdf <b>(SANYO)</b> -<p> -for trimmer refence see : <u>www.electrospec-inc.com/cross_references/trimpotcrossref.asp</u><p> - -<table border=0 cellspacing=0 cellpadding=0 width="100%" cellpaddding=0> -<tr valign="top"> - -<! <td width="10">&nbsp;</td> -<td width="90%"> - -<b><font color="#0000FF" size="4">TRIM-POT CROSS REFERENCE</font></b> -<P> -<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2> - <TR> - <TD COLSPAN=8> - <FONT SIZE=3 FACE=ARIAL><B>RECTANGULAR MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">BOURNS</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">BI&nbsp;TECH</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">DALE-VISHAY</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">PHILIPS/MEPCO</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">MURATA</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">PANASONIC</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">SPECTROL</FONT> - </B> - </TD> - <TD ALIGN=CENTER> - <B> - <FONT SIZE=3 FACE=ARIAL color="#FF0000">MILSPEC</FONT> - </B> - </TD><TD>&nbsp;</TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3 > - 3005P<BR> - 3006P<BR> - 3006W<BR> - 3006Y<BR> - 3009P<BR> - 3009W<BR> - 3009Y<BR> - 3057J<BR> - 3057L<BR> - 3057P<BR> - 3057Y<BR> - 3059J<BR> - 3059L<BR> - 3059P<BR> - 3059Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 89P<BR> - 89W<BR> - 89X<BR> - 89PH<BR> - 76P<BR> - 89XH<BR> - 78SLT<BR> - 78L&nbsp;ALT<BR> - 56P&nbsp;ALT<BR> - 78P&nbsp;ALT<BR> - T8S<BR> - 78L<BR> - 56P<BR> - 78P<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - T18/784<BR> - 783<BR> - 781<BR> - -<BR> - -<BR> - -<BR> - 2199<BR> - 1697/1897<BR> - 1680/1880<BR> - 2187<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 8035EKP/CT20/RJ-20P<BR> - -<BR> - RJ-20X<BR> - -<BR> - -<BR> - -<BR> - 1211L<BR> - 8012EKQ&nbsp;ALT<BR> - 8012EKR&nbsp;ALT<BR> - 1211P<BR> - 8012EKJ<BR> - 8012EKL<BR> - 8012EKQ<BR> - 8012EKR<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 2101P<BR> - 2101W<BR> - 2101Y<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 2102L<BR> - 2102S<BR> - 2102Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - EVMCOG<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 43P<BR> - 43W<BR> - 43Y<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 40L<BR> - 40P<BR> - 40Y<BR> - 70Y-T602<BR> - 70L<BR> - 70P<BR> - 70Y<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - RT/RTR12<BR> - RT/RTR12<BR> - RT/RTR12<BR> - -<BR> - RJ/RJR12<BR> - RJ/RJR12<BR> - RJ/RJR12<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=8>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=8> - <FONT SIZE=4 FACE=ARIAL><B>SQUARE MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3250L<BR> - 3250P<BR> - 3250W<BR> - 3250X<BR> - 3252P<BR> - 3252W<BR> - 3252X<BR> - 3260P<BR> - 3260W<BR> - 3260X<BR> - 3262P<BR> - 3262W<BR> - 3262X<BR> - 3266P<BR> - 3266W<BR> - 3266X<BR> - 3290H<BR> - 3290P<BR> - 3290W<BR> - 3292P<BR> - 3292W<BR> - 3292X<BR> - 3296P<BR> - 3296W<BR> - 3296X<BR> - 3296Y<BR> - 3296Z<BR> - 3299P<BR> - 3299W<BR> - 3299X<BR> - 3299Y<BR> - 3299Z<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66X&nbsp;ALT<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66X&nbsp;ALT<BR> - -<BR> - 64W&nbsp;ALT<BR> - -<BR> - 64P&nbsp;ALT<BR> - 64W&nbsp;ALT<BR> - 64X&nbsp;ALT<BR> - 64P<BR> - 64W<BR> - 64X<BR> - 66X&nbsp;ALT<BR> - 66P&nbsp;ALT<BR> - 66W&nbsp;ALT<BR> - 66P<BR> - 66W<BR> - 66X<BR> - 67P<BR> - 67W<BR> - 67X<BR> - 67Y<BR> - 67Z<BR> - 68P<BR> - 68W<BR> - 68X<BR> - 67Y&nbsp;ALT<BR> - 67Z&nbsp;ALT<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 5050<BR> - 5091<BR> - 5080<BR> - 5087<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - T63YB<BR> - T63XB<BR> - -<BR> - -<BR> - -<BR> - 5887<BR> - 5891<BR> - 5880<BR> - -<BR> - -<BR> - -<BR> - T93Z<BR> - T93YA<BR> - T93XA<BR> - T93YB<BR> - T93XB<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 8026EKP<BR> - 8026EKW<BR> - 8026EKM<BR> - 8026EKP<BR> - 8026EKB<BR> - 8026EKM<BR> - 1309X<BR> - 1309P<BR> - 1309W<BR> - 8024EKP<BR> - 8024EKW<BR> - 8024EKN<BR> - RJ-9P/CT9P<BR> - RJ-9W<BR> - RJ-9X<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3103P<BR> - 3103Y<BR> - 3103Z<BR> - 3103P<BR> - 3103Y<BR> - 3103Z<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3105P/3106P<BR> - 3105W/3106W<BR> - 3105X/3106X<BR> - 3105Y/3106Y<BR> - 3105Z/3105Z<BR> - 3102P<BR> - 3102W<BR> - 3102X<BR> - 3102Y<BR> - 3102Z<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - EVMCBG<BR> - EVMCCG<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 55-1-X<BR> - 55-4-X<BR> - 55-3-X<BR> - 55-2-X<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 50-2-X<BR> - 50-4-X<BR> - 50-3-X<BR> - -<BR> - -<BR> - -<BR> - 64P<BR> - 64W<BR> - 64X<BR> - 64Y<BR> - 64Z<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - RT/RTR22<BR> - RT/RTR22<BR> - RT/RTR22<BR> - RT/RTR22<BR> - RJ/RJR22<BR> - RJ/RJR22<BR> - RJ/RJR22<BR> - RT/RTR26<BR> - RT/RTR26<BR> - RT/RTR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RJ/RJR26<BR> - RT/RTR24<BR> - RT/RTR24<BR> - RT/RTR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - RJ/RJR24<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=8>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=8> - <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> - </TD> - </TR> - <TR> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> - </TD> - <TD ALIGN=CENTER> - <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3323P<BR> - 3323S<BR> - 3323W<BR> - 3329H<BR> - 3329P<BR> - 3329W<BR> - 3339H<BR> - 3339P<BR> - 3339W<BR> - 3352E<BR> - 3352H<BR> - 3352K<BR> - 3352P<BR> - 3352T<BR> - 3352V<BR> - 3352W<BR> - 3362H<BR> - 3362M<BR> - 3362P<BR> - 3362R<BR> - 3362S<BR> - 3362U<BR> - 3362W<BR> - 3362X<BR> - 3386B<BR> - 3386C<BR> - 3386F<BR> - 3386H<BR> - 3386K<BR> - 3386M<BR> - 3386P<BR> - 3386S<BR> - 3386W<BR> - 3386X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 25P<BR> - 25S<BR> - 25RX<BR> - 82P<BR> - 82M<BR> - 82PA<BR> - -<BR> - -<BR> - -<BR> - 91E<BR> - 91X<BR> - 91T<BR> - 91B<BR> - 91A<BR> - 91V<BR> - 91W<BR> - 25W<BR> - 25V<BR> - 25P<BR> - -<BR> - 25S<BR> - 25U<BR> - 25RX<BR> - 25X<BR> - 72XW<BR> - 72XL<BR> - 72PM<BR> - 72RX<BR> - -<BR> - 72PX<BR> - 72P<BR> - 72RXW<BR> - 72RXL<BR> - 72X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - T7YB<BR> - T7YA<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - TXD<BR> - TYA<BR> - TYP<BR> - -<BR> - TYD<BR> - TX<BR> - -<BR> - 150SX<BR> - 100SX<BR> - 102T<BR> - 101S<BR> - 190T<BR> - 150TX<BR> - 101<BR> - -<BR> - -<BR> - 101SX<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ET6P<BR> - ET6S<BR> - ET6X<BR> - RJ-6W/8014EMW<BR> - RJ-6P/8014EMP<BR> - RJ-6X/8014EMX<BR> - TM7W<BR> - TM7P<BR> - TM7X<BR> - -<BR> - 8017SMS<BR> - -<BR> - 8017SMB<BR> - 8017SMA<BR> - -<BR> - -<BR> - CT-6W<BR> - CT-6H<BR> - CT-6P<BR> - CT-6R<BR> - -<BR> - CT-6V<BR> - CT-6X<BR> - -<BR> - -<BR> - 8038EKV<BR> - -<BR> - 8038EKX<BR> - -<BR> - -<BR> - 8038EKP<BR> - 8038EKZ<BR> - 8038EKW<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - 3321H<BR> - 3321P<BR> - 3321N<BR> - 1102H<BR> - 1102P<BR> - 1102T<BR> - RVA0911V304A<BR> - -<BR> - RVA0911H413A<BR> - RVG0707V100A<BR> - RVA0607V(H)306A<BR> - RVA1214H213A<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 3104B<BR> - 3104C<BR> - 3104F<BR> - 3104H<BR> - -<BR> - 3104M<BR> - 3104P<BR> - 3104S<BR> - 3104W<BR> - 3104X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - EVMQ0G<BR> - EVMQIG<BR> - EVMQ3G<BR> - EVMS0G<BR> - EVMQ0G<BR> - EVMG0G<BR> - -<BR> - -<BR> - -<BR> - EVMK4GA00B<BR> - EVM30GA00B<BR> - EVMK0GA00B<BR> - EVM38GA00B<BR> - EVMB6<BR> - EVLQ0<BR> - -<BR> - EVMMSG<BR> - EVMMBG<BR> - EVMMAG<BR> - -<BR> - -<BR> - EVMMCS<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - EVMM1<BR> - -<BR> - -<BR> - EVMM0<BR> - -<BR> - -<BR> - EVMM3<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - 62-3-1<BR> - 62-1-2<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 67R<BR> - -<BR> - 67P<BR> - -<BR> - -<BR> - -<BR> - -<BR> - 67X<BR> - 63V<BR> - 63S<BR> - 63M<BR> - -<BR> - -<BR> - 63H<BR> - 63P<BR> - -<BR> - -<BR> - 63X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - RJ/RJR50<BR> - RJ/RJR50<BR> - RJ/RJR50<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> -</TABLE> -<P>&nbsp;<P> -<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3> - <TR> - <TD COLSPAN=7> - <FONT color="#0000FF" SIZE=4 FACE=ARIAL><B>SMD TRIM-POT CROSS REFERENCE</B></FONT> - <P> - <FONT SIZE=4 FACE=ARIAL><B>MULTI-TURN</B></FONT> - </TD> - </TR> - <TR> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3224G<BR> - 3224J<BR> - 3224W<BR> - 3269P<BR> - 3269W<BR> - 3269X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 44G<BR> - 44J<BR> - 44W<BR> - 84P<BR> - 84W<BR> - 84X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - ST63Z<BR> - ST63Y<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - ST5P<BR> - ST5W<BR> - ST5X<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> - <TR> - <TD COLSPAN=7>&nbsp; - </TD> - </TR> - <TR> - <TD COLSPAN=7> - <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> - </TD> - </TR> - <TR> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> - </TD> - <TD> - <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> - </TD> - </TR> - <TR> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 3314G<BR> - 3314J<BR> - 3364A/B<BR> - 3364C/D<BR> - 3364W/X<BR> - 3313G<BR> - 3313J<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - 23B<BR> - 23A<BR> - 21X<BR> - 21W<BR> - -<BR> - 22B<BR> - 22A<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ST5YL/ST53YL<BR> - ST5YJ/5T53YJ<BR> - ST-23A<BR> - ST-22B<BR> - ST-22<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - ST-4B<BR> - ST-4A<BR> - -<BR> - -<BR> - -<BR> - ST-3B<BR> - ST-3A<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - EVM-6YS<BR> - EVM-1E<BR> - EVM-1G<BR> - EVM-1D<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - G4B<BR> - G4A<BR> - TR04-3S1<BR> - TRG04-2S1<BR> - -<BR> - -<BR> - -<BR></FONT> - </TD> - <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> - -<BR> - -<BR> - DVR-43A<BR> - CVR-42C<BR> - CVR-42A/C<BR> - -<BR> - -<BR></FONT> - </TD> - </TR> -</TABLE> -<P> -<FONT SIZE=4 FACE=ARIAL><B>ALT =&nbsp;ALTERNATE</B></FONT> -<P> - -&nbsp; -<P> -</td> -</tr> -</table> - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b><p> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b> - - - - - - - - ->NAME ->VALUE - - - - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 2.4 x 4.4 mm - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 2.5 x 5 mm - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 3 x 5 mm - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 4 x 5 mm - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 5 x 5 mm - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm, outline 6 x 5 mm - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 mm + 5 mm, outline 2.4 x 7 mm - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 + 5 mm, outline 2.5 x 7.5 mm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 + 5 mm, outline 3.5 x 7.5 mm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 + 5 mm, outline 4.5 x 7.5 mm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 2.5 + 5 mm, outline 5.5 x 7.5 mm - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 2.4 x 4.4 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 2.5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 4.5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 3 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 5.5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 7.5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -Horizontal, grid 5 mm, outline 7.5 x 7.5 mm - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<b>CAPACITOR</b><p> -grid 7.5 mm, outline 3.2 x 10.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 7.5 mm, outline 4.2 x 10.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 7.5 mm, outline 5.2 x 10.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 10.2 mm, outline 4.3 x 13.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 10.2 mm, outline 5.4 x 13.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 10.2 mm, outline 6.4 x 13.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 10.2 mm + 15.2 mm, outline 6.2 x 18.4 mm - - - - - - - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 15 mm, outline 5.4 x 18.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 15 mm, outline 6.4 x 18.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 15 mm, outline 7.2 x 18.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 15 mm, outline 8.4 x 18.3 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 15 mm, outline 9.1 x 18.2 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 22.5 mm, outline 6.2 x 26.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 22.5 mm, outline 7.4 x 26.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 22.5 mm, outline 8.7 x 26.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 22.5 mm, outline 10.8 x 26.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 22.5 mm, outline 11.3 x 26.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 9.3 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 11.3 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 13.4 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 20.5 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 32.5 mm, outline 13.7 x 37.4 mm - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 32.5 mm, outline 16.2 x 37.4 mm - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 32.5 mm, outline 18.2 x 37.4 mm - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 37.5 mm, outline 19.2 x 41.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 37.5 mm, outline 20.3 x 41.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 5 mm, outline 3.5 x 7.5 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 37.5 mm, outline 15.5 x 41.8 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 7.5 mm, outline 6.3 x 10.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 15.4 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>CAPACITOR</b><p> -grid 27.5 mm, outline 17.3 x 31.6 mm - - - - - - - - - - - - - - - - ->NAME ->VALUE - - -<b>Ceramic Chip Capacitor KEMET 0204 reflow solder</b><p> -Metric Code Size 1005 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 0603 reflow solder</b><p> -Metric Code Size 1608 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 0805 reflow solder</b><p> -Metric Code Size 2012 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 1206 reflow solder</b><p> -Metric Code Size 3216 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 1210 reflow solder</b><p> -Metric Code Size 3225 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 1812 reflow solder</b><p> -Metric Code Size 4532 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 1825 reflow solder</b><p> -Metric Code Size 4564 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 2220 reflow solder</b><p>Metric Code Size 5650 - - - - ->NAME ->VALUE - - - - -<b>Ceramic Chip Capacitor KEMET 2225 reflow solder</b><p>Metric Code Size 5664 - - - - ->NAME ->VALUE - - - - -<b> </b><p> -Source: http://www.vishay.com/docs/10129/hpc0201a.pdf - - ->NAME ->VALUE - - - -Source: http://www.avxcorp.com/docs/catalogs/cx5r.pdf - - ->NAME ->VALUE - - - - - - -<b>CAPACITOR</b><p> -Source: AVX .. aphvc.pdf - - - - ->NAME ->VALUE - - - - -<b>CAPACITOR</b><p> -Source: AVX .. aphvc.pdf - - - - ->NAME ->VALUE - - - - -<b>CAPACITOR</b> - - - ->NAME ->VALUE - - - - - - - - - - ->NAME ->VALUE - - - - - - - - -<B>CAPACITOR</B>, European symbol - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/plugins/rc2014_coleco/ui.png b/applications/plugins/rc2014_coleco/ui.png deleted file mode 100644 index 97c0ddc21..000000000 Binary files a/applications/plugins/rc2014_coleco/ui.png and /dev/null differ diff --git a/applications/plugins/sam/application.fam b/applications/plugins/sam/application.fam deleted file mode 100644 index 0fd70ee42..000000000 --- a/applications/plugins/sam/application.fam +++ /dev/null @@ -1,45 +0,0 @@ -App( - appid="SAM", - name="SAM AYBABTU", - apptype=FlipperAppType.EXTERNAL, - entry_point="sam_app", - requires=[ - "gui", - "dialogs", - ], - stack_size=4 * 1024, - order=20, - fap_icon="icons/music_10px.png", - fap_category="Music", - fap_icon_assets="icons", -) -App( - appid="SAM_YES", - name="SAM YES", - apptype=FlipperAppType.EXTERNAL, - entry_point="sam_app_yes", - requires=[ - "gui", - "dialogs", - ], - stack_size=4 * 1024, - order=20, - fap_icon="icons/music_10px.png", - fap_category="Music", - fap_icon_assets="icons", -) -App( - appid="SAM_NO", - name="SAM NO", - apptype=FlipperAppType.EXTERNAL, - entry_point="sam_app_no", - requires=[ - "gui", - "dialogs", - ], - stack_size=4 * 1024, - order=20, - fap_icon="icons/music_10px.png", - fap_category="Music", - fap_icon_assets="icons", -) diff --git a/applications/plugins/sam/icons/music_10px.png b/applications/plugins/sam/icons/music_10px.png deleted file mode 100644 index d41eb0db8..000000000 Binary files a/applications/plugins/sam/icons/music_10px.png and /dev/null differ diff --git a/applications/plugins/sam/sam_app.cpp b/applications/plugins/sam/sam_app.cpp deleted file mode 100644 index 4b218d1f7..000000000 --- a/applications/plugins/sam/sam_app.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include "stm32_sam.h" -// WOULD BE COOL IF SOMEONE MADE A TEXT ENTRY SCREEN TO HAVE IT READ WHAT IS ENTERED TO TEXT -STM32SAM voice; - -extern "C" int32_t sam_app(void* p) { - UNUSED(p); - - voice.begin(); - voice.say( - "All your base are belong to us. You have no chance to survive make your time. ha. ha. ha. GOOD BYE. "); - - return 0; -} - -extern "C" int32_t sam_app_yes(void* p) { - UNUSED(p); - - voice.begin(); - voice.say("Yes"); - - return 0; -} - -extern "C" int32_t sam_app_no(void* p) { - UNUSED(p); - - voice.begin(); - voice.say("No"); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/sam/stm32_sam.cpp b/applications/plugins/sam/stm32_sam.cpp deleted file mode 100644 index 16f6fcaab..000000000 --- a/applications/plugins/sam/stm32_sam.cpp +++ /dev/null @@ -1,5704 +0,0 @@ - -#include "stm32_sam.h" -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// All -// -//////////////////////////////////////////////////////////////////////////////////////////// - -char input[256 + 1] = {0}; //tab39445 -//standard sam sound - -unsigned char wait1 = 7; -unsigned char wait2 = 6; - -unsigned char A, X, Y; -unsigned char mem44; -unsigned char mem47; -unsigned char mem49; -unsigned char mem39; -unsigned char mem50; -unsigned char mem51; -unsigned char mem53; -unsigned char mem56; -unsigned char mem59 = 0; - -unsigned char phonemeIndexOutput[60]; //tab47296 -unsigned char stressOutput[60]; //tab47365 -unsigned char phonemeLengthOutput[60]; //tab47416 - -// contains the soundbuffer position -int bufferpos; - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Sam Tabs -// -//////////////////////////////////////////////////////////////////////////////////////////// - -//tab40672 -const unsigned char stressInputTable[] = {'*', '1', '2', '3', '4', '5', '6', '7', '8'}; - -//tab40682 -const unsigned char signInputTable1[] = { - ' ', '.', '?', ',', '-', 'I', 'I', 'E', 'A', 'A', 'A', 'A', 'U', 'A', 'I', 'E', 'U', - 'O', 'R', 'L', 'W', 'Y', 'W', 'R', 'L', 'W', 'Y', 'M', 'N', 'N', 'D', 'Q', 'S', 'S', - 'F', 'T', '/', '/', 'Z', 'Z', 'V', 'D', 'C', '*', 'J', '*', '*', '*', 'E', 'A', 'O', - 'A', 'O', 'U', 'B', '*', '*', 'D', '*', '*', 'G', '*', '*', 'G', '*', '*', 'P', '*', - '*', 'T', '*', '*', 'K', '*', '*', 'K', '*', '*', 'U', 'U', 'U'}; - -//tab40763 -const unsigned char signInputTable2[] = { - '*', '*', '*', '*', '*', 'Y', 'H', 'H', 'E', 'A', 'H', 'O', 'H', 'X', 'X', 'R', 'X', - 'H', 'X', 'X', 'X', 'X', 'H', '*', '*', '*', '*', '*', '*', 'X', 'X', '*', '*', 'H', - '*', 'H', 'H', 'X', '*', 'H', '*', 'H', 'H', '*', '*', '*', '*', '*', 'Y', 'Y', 'Y', - 'W', 'W', 'W', '*', '*', '*', '*', '*', '*', '*', '*', '*', 'X', '*', '*', '*', '*', - '*', '*', '*', '*', '*', '*', '*', 'X', '*', '*', 'L', 'M', 'N'}; - -//loc_9F8C -const unsigned char flags[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0x84, 0x84, 0xA4, - 0xA4, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x44, 0x44, 0x44, 0x44, 0x44, 0x4C, - 0x4C, 0x4C, 0x48, 0x4C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x44, 0x44, 0x44, 0x44, - 0x48, 0x40, 0x4C, 0x44, 0x00, 0x00, 0xB4, 0xB4, 0xB4, 0x94, 0x94, 0x94, 0x4E, 0x4E, - 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x80, 0xC1, 0xC1 - -}; - -//??? flags overlap flags2 -//loc_9FDA -const unsigned char flags2[] = { - 0x80, 0xC1, 0xC1, 0xC1, 0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x08, 0x0C, 0x08, 0x04, 0x40, - 0x24, 0x20, 0x20, 0x24, 0x00, 0x00, 0x24, 0x20, 0x20, 0x24, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -//tab45616??? -const unsigned char phonemeStressedLengthTable[] = { - 0x00, 0x12, 0x12, 0x12, 8, 0xB, 9, 0xB, 0xE, 0xF, 0xB, 0x10, 0xC, 6, 6, 0xE, - 0xC, 0xE, 0xC, 0xB, 8, 8, 0xB, 0xA, 9, 8, 8, 8, 8, 8, 3, 5, - 2, 2, 2, 2, 2, 2, 6, 6, 8, 6, 6, 2, 9, 4, 2, 1, - 0xE, 0xF, 0xF, 0xF, 0xE, 0xE, 8, 2, 2, 7, 2, 1, 7, 2, 2, 7, - 2, 2, 8, 2, 2, 6, 2, 2, 7, 2, 4, 7, 1, 4, 5, 5}; - -//tab45536??? -const unsigned char phonemeLengthTable[] = { - 0, 0x12, 0x12, 0x12, 8, 8, 8, 8, 8, 0xB, 6, 0xC, 0xA, 5, 5, 0xB, 0xA, 0xA, 0xA, 9, - 8, 7, 9, 7, 6, 8, 6, 7, 7, 7, 2, 5, 2, 2, 2, 2, 2, 2, 6, 6, - 7, 6, 6, 2, 8, 3, 1, 0x1E, 0xD, 0xC, 0xC, 0xC, 0xE, 9, 6, 1, 2, 5, 1, 1, - 6, 1, 2, 6, 1, 2, 8, 2, 2, 4, 2, 2, 6, 1, 4, 6, 1, 4, 0xC7, 0xFF}; - -/* - - Ind | phoneme | flags | - -----|---------|----------| - 0 | * | 00000000 | - 1 | .* | 00000000 | - 2 | ?* | 00000000 | - 3 | ,* | 00000000 | - 4 | -* | 00000000 | - - VOWELS - 5 | IY | 10100100 | - 6 | IH | 10100100 | - 7 | EH | 10100100 | - 8 | AE | 10100100 | - 9 | AA | 10100100 | - 10 | AH | 10100100 | - 11 | AO | 10000100 | - 17 | OH | 10000100 | - 12 | UH | 10000100 | - 16 | UX | 10000100 | - 15 | ER | 10000100 | - 13 | AX | 10100100 | - 14 | IX | 10100100 | - - DIPHTONGS - 48 | EY | 10110100 | - 49 | AY | 10110100 | - 50 | OY | 10110100 | - 51 | AW | 10010100 | - 52 | OW | 10010100 | - 53 | UW | 10010100 | - - - 21 | YX | 10000100 | - 20 | WX | 10000100 | - 18 | RX | 10000100 | - 19 | LX | 10000100 | - 37 | /X | 01000000 | - 30 | DX | 01001000 | - - - 22 | WH | 01000100 | - - - VOICED CONSONANTS - 23 | R* | 01000100 | - 24 | L* | 01000100 | - 25 | W* | 01000100 | - 26 | Y* | 01000100 | - 27 | M* | 01001100 | - 28 | N* | 01001100 | - 29 | NX | 01001100 | - 54 | B* | 01001110 | - 57 | D* | 01001110 | - 60 | G* | 01001110 | - 44 | J* | 01001100 | - 38 | Z* | 01000100 | - 39 | ZH | 01000100 | - 40 | V* | 01000100 | - 41 | DH | 01000100 | - - unvoiced CONSONANTS - 32 | S* | 01000000 | - 33 | SH | 01000000 | - 34 | F* | 01000000 | - 35 | TH | 01000000 | - 66 | P* | 01001011 | - 69 | T* | 01001011 | - 72 | K* | 01001011 | - 42 | CH | 01001000 | - 36 | /H | 01000000 | - - 43 | ** | 01000000 | - 45 | ** | 01000100 | - 46 | ** | 00000000 | - 47 | ** | 00000000 | - - - 55 | ** | 01001110 | - 56 | ** | 01001110 | - 58 | ** | 01001110 | - 59 | ** | 01001110 | - 61 | ** | 01001110 | - 62 | ** | 01001110 | - 63 | GX | 01001110 | - 64 | ** | 01001110 | - 65 | ** | 01001110 | - 67 | ** | 01001011 | - 68 | ** | 01001011 | - 70 | ** | 01001011 | - 71 | ** | 01001011 | - 73 | ** | 01001011 | - 74 | ** | 01001011 | - 75 | KX | 01001011 | - 76 | ** | 01001011 | - 77 | ** | 01001011 | - - - SPECIAL - 78 | UL | 10000000 | - 79 | UM | 11000001 | - 80 | UN | 11000001 | - 31 | Q* | 01001100 | - -*/ - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// RenderTabs -// -//////////////////////////////////////////////////////////////////////////////////////////// - -const unsigned char tab48426[5] = {0x18, 0x1A, 0x17, 0x17, 0x17}; - -const unsigned char tab47492[] = {0, 0, 0xE0, 0xE6, 0xEC, 0xF3, 0xF9, 0, 6, 0xC, 6}; - -const unsigned char amplitudeRescale[] = { - 0, - 1, - 2, - 2, - 2, - 3, - 3, - 4, - 4, - 5, - 6, - 8, - 9, - 0xB, - 0xD, - 0xF, - 0 //17 elements? -}; - -// Used to decide which phoneme's blend lengths. The candidate with the lower score is selected. -// tab45856 -const unsigned char blendRank[] = {0, 0x1F, 0x1F, 0x1F, 0x1F, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 5, 5, 2, 0xA, 2, 8, - 5, 5, 0xB, 0xA, 9, 8, 8, 0xA0, 8, 8, - 0x17, 0x1F, 0x12, 0x12, 0x12, 0x12, 0x1E, 0x1E, 0x14, 0x14, - 0x14, 0x14, 0x17, 0x17, 0x1A, 0x1A, 0x1D, 0x1D, 2, 2, - 2, 2, 2, 2, 0x1A, 0x1D, 0x1B, 0x1A, 0x1D, 0x1B, - 0x1A, 0x1D, 0x1B, 0x1A, 0x1D, 0x1B, 0x17, 0x1D, 0x17, 0x17, - 0x1D, 0x17, 0x17, 0x1D, 0x17, 0x17, 0x1D, 0x17, 0x17, 0x17}; - -// Number of frames at the end of a phoneme devoted to interpolating to next phoneme's final value -//tab45696 -const unsigned char outBlendLength[] = {0, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 3, 2, 4, 4, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 0, 1, 0, 1, 0, 5, - 5, 5, 5, 5, 4, 4, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, - 0, 1, 2, 0, 2, 2, 0, 1, 3, 0, 2, 3, 0, 2, 0xA0, 0xA0}; - -// Number of frames at beginning of a phoneme devoted to interpolating to phoneme's final value -// tab45776 -const unsigned char inBlendLength[] = {0, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 3, 3, 4, 4, 3, 3, 3, 3, 3, 1, 2, 3, 2, 1, - 3, 3, 3, 3, 1, 1, 3, 3, 3, 2, 2, 3, 2, 3, 0, 0, - 5, 5, 5, 5, 4, 4, 2, 0, 2, 2, 0, 3, 2, 0, 4, 2, - 0, 3, 2, 0, 2, 2, 0, 2, 3, 0, 3, 3, 0, 3, 0xB0, 0xA0}; - -// Looks like it's used as bit flags -// High bits masked by 248 (11111000) -// -// 32: S* 241 11110001 -// 33: SH 226 11100010 -// 34: F* 211 11010011 -// 35: TH 187 10111011 -// 36: /H 124 01111100 -// 37: /X 149 10010101 -// 38: Z* 1 00000001 -// 39: ZH 2 00000010 -// 40: V* 3 00000011 -// 41: DH 3 00000011 -// 43: ** 114 01110010 -// 45: ** 2 00000010 -// 67: ** 27 00011011 -// 70: ** 25 00011001 -// tab45936 -const unsigned char sampledConsonantFlags[] = { - 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, 0, 0, 0, 0, 0, 0, 0, 0xF1, 0xE2, 0xD3, 0xBB, 0x7C, 0x95, 1, 2, - 3, 3, 0, 0x72, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0x1B, 0, 0, 0x19, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - -//tab45056 -unsigned char freq1data[] = { - 0x00, 0x13, 0x13, 0x13, 0x13, 0xA, 0xE, 0x12, 0x18, 0x1A, 0x16, 0x14, 0x10, 0x14, 0xE, 0x12, - 0xE, 0x12, 0x12, 0x10, 0xC, 0xE, 0xA, 0x12, 0xE, 0xA, 8, 6, 6, 6, 6, 0x11, - 6, 6, 6, 6, 0xE, 0x10, 9, 0xA, 8, 0xA, 6, 6, 6, 5, 6, 0, - 0x12, 0x1A, 0x14, 0x1A, 0x12, 0xC, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 0xA, 0xA, 6, 6, 6, 0x2C, 0x13}; - -//tab451356 -unsigned char freq2data[] = {0x00, 0x43, 0x43, 0x43, 0x43, 0x54, 0x48, 0x42, 0x3E, 0x28, - 0x2C, 0x1E, 0x24, 0x2C, 0x48, 0x30, 0x24, 0x1E, 0x32, 0x24, - 0x1C, 0x44, 0x18, 0x32, 0x1E, 0x18, 0x52, 0x2E, 0x36, 0x56, - 0x36, 0x43, 0x49, 0x4F, 0x1A, 0x42, 0x49, 0x25, 0x33, 0x42, - 0x28, 0x2F, 0x4F, 0x4F, 0x42, 0x4F, 0x6E, 0x00, 0x48, 0x26, - 0x1E, 0x2A, 0x1E, 0x22, 0x1A, 0x1A, 0x1A, 0x42, 0x42, 0x42, - 0x6E, 0x6E, 0x6E, 0x54, 0x54, 0x54, 0x1A, 0x1A, 0x1A, 0x42, - 0x42, 0x42, 0x6D, 0x56, 0x6D, 0x54, 0x54, 0x54, 0x7F, 0x7F}; -//tab45216 -unsigned char freq3data[] = {0x00, 0x5B, 0x5B, 0x5B, 0x5B, 0x6E, 0x5D, 0x5B, 0x58, 0x59, - 0x57, 0x58, 0x52, 0x59, 0x5D, 0x3E, 0x52, 0x58, 0x3E, 0x6E, - 0x50, 0x5D, 0x5A, 0x3C, 0x6E, 0x5A, 0x6E, 0x51, 0x79, 0x65, - 0x79, 0x5B, 0x63, 0x6A, 0x51, 0x79, 0x5D, 0x52, 0x5D, 0x67, - 0x4C, 0x5D, 0x65, 0x65, 0x79, 0x65, 0x79, 0x00, 0x5A, 0x58, - 0x58, 0x58, 0x58, 0x52, 0x51, 0x51, 0x51, 0x79, 0x79, 0x79, - 0x70, 0x6E, 0x6E, 0x5E, 0x5E, 0x5E, 0x51, 0x51, 0x51, 0x79, - 0x79, 0x79, 0x65, 0x65, 0x70, 0x5E, 0x5E, 0x5E, 0x08, 0x01}; - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Reciter -// -//////////////////////////////////////////////////////////////////////////////////////////// - -unsigned char inputtemp[256]; // secure copy of input tab36096 - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Render -// -//////////////////////////////////////////////////////////////////////////////////////////// - -//timetable for more accurate c64 simulation -int timetable[5][5] = { - {162, 167, 167, 127, 128}, - {226, 60, 60, 0, 0}, - {225, 60, 59, 0, 0}, - {200, 0, 0, 54, 55}, - {199, 0, 0, 54, 54}}; - -unsigned oldtimetableindex; - -const unsigned char ampl1data[] = {0, 0, 0, 0, 0, 0xD, 0xD, 0xE, 0xF, 0xF, 0xF, 0xF, - 0xF, 0xC, 0xD, 0xC, 0xF, 0xF, 0xD, 0xD, 0xD, 0xE, 0xD, 0xC, - 0xD, 0xD, 0xD, 0xC, 9, 9, 0, 0, 0, 0, 0, 0, - 0, 0, 0xB, 0xB, 0xB, 0xB, 0, 0, 1, 0xB, 0, 2, - 0xE, 0xF, 0xF, 0xF, 0xF, 0xD, 2, 4, 0, 2, 4, 0, - 1, 4, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0xC, 0, 0, 0, 0, 0xF, 0xF}; - -const unsigned char ampl2data[] = { - 0, 0, 0, 0, 0, 0xA, 0xB, 0xD, 0xE, 0xD, 0xC, 0xC, 0xB, 9, 0xB, 0xB, 0xC, 0xC, 0xC, 8, - 8, 0xC, 8, 0xA, 8, 8, 0xA, 3, 9, 6, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, - 3, 4, 0, 0, 0, 5, 0xA, 2, 0xE, 0xD, 0xC, 0xD, 0xC, 8, 0, 1, 0, 0, 1, 0, - 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0xA, 0, 0, 0xA, 0, 0, 0}; - -const unsigned char ampl3data[] = {0, 0, 0, 0, 0, 8, 7, 8, 8, 1, 1, 0, 1, 0, 7, 5, - 1, 0, 6, 1, 0, 7, 0, 5, 1, 0, 8, 0, 0, 3, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0xE, 1, - 9, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 5, 0, 0x13, 0x10}; - -//tab42240 -const signed char sinus[256] = { - 0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, - 49, 51, 54, 57, 60, 63, 65, 68, 71, 73, 76, 78, 81, 83, 85, 88, - 90, 92, 94, 96, 98, 100, 102, 104, 106, 107, 109, 111, 112, 113, 115, 116, - 117, 118, 120, 121, 122, 122, 123, 124, 125, 125, 126, 126, 126, 127, 127, 127, - 127, 127, 127, 127, 126, 126, 126, 125, 125, 124, 123, 122, 122, 121, 120, 118, - 117, 116, 115, 113, 112, 111, 109, 107, 106, 104, 102, 100, 98, 96, 94, 92, - 90, 88, 85, 83, 81, 78, 76, 73, 71, 68, 65, 63, 60, 57, 54, 51, - 49, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 12, 9, 6, 3, - 0, -3, -6, -9, -12, -16, -19, -22, -25, -28, -31, -34, -37, -40, -43, -46, - -49, -51, -54, -57, -60, -63, -65, -68, -71, -73, -76, -78, -81, -83, -85, -88, - -90, -92, -94, -96, -98, -100, -102, -104, -106, -107, -109, -111, -112, -113, -115, -116, - -117, -118, -120, -121, -122, -122, -123, -124, -125, -125, -126, -126, -126, -127, -127, -127, - -127, -127, -127, -127, -126, -126, -126, -125, -125, -124, -123, -122, -122, -121, -120, -118, - -117, -116, -115, -113, -112, -111, -109, -107, -106, -104, -102, -100, -98, -96, -94, -92, - -90, -88, -85, -83, -81, -78, -76, -73, -71, -68, -65, -63, -60, -57, -54, -51, - -49, -46, -43, -40, -37, -34, -31, -28, -25, -22, -19, -16, -12, -9, -6, -3}; - -//tab42496 -const unsigned char rectangle[] = { - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, - 0x70}; - -//random data ? -const unsigned char sampleTable[0x500] = { - //00 - - 0x38, - 0x84, - 0x6B, - 0x19, - 0xC6, - 0x63, - 0x18, - 0x86, - 0x73, - 0x98, - 0xC6, - 0xB1, - 0x1C, - 0xCA, - 0x31, - 0x8C, - 0xC7, - 0x31, - 0x88, - 0xC2, - 0x30, - 0x98, - 0x46, - 0x31, - 0x18, - 0xC6, - 0x35, - 0xC, - 0xCA, - 0x31, - 0xC, - 0xC6 - //20 - , - 0x21, - 0x10, - 0x24, - 0x69, - 0x12, - 0xC2, - 0x31, - 0x14, - 0xC4, - 0x71, - 8, - 0x4A, - 0x22, - 0x49, - 0xAB, - 0x6A, - 0xA8, - 0xAC, - 0x49, - 0x51, - 0x32, - 0xD5, - 0x52, - 0x88, - 0x93, - 0x6C, - 0x94, - 0x22, - 0x15, - 0x54, - 0xD2, - 0x25 - //40 - , - 0x96, - 0xD4, - 0x50, - 0xA5, - 0x46, - 0x21, - 8, - 0x85, - 0x6B, - 0x18, - 0xC4, - 0x63, - 0x10, - 0xCE, - 0x6B, - 0x18, - 0x8C, - 0x71, - 0x19, - 0x8C, - 0x63, - 0x35, - 0xC, - 0xC6, - 0x33, - 0x99, - 0xCC, - 0x6C, - 0xB5, - 0x4E, - 0xA2, - 0x99 - //60 - , - 0x46, - 0x21, - 0x28, - 0x82, - 0x95, - 0x2E, - 0xE3, - 0x30, - 0x9C, - 0xC5, - 0x30, - 0x9C, - 0xA2, - 0xB1, - 0x9C, - 0x67, - 0x31, - 0x88, - 0x66, - 0x59, - 0x2C, - 0x53, - 0x18, - 0x84, - 0x67, - 0x50, - 0xCA, - 0xE3, - 0xA, - 0xAC, - 0xAB, - 0x30 - //80 - , - 0xAC, - 0x62, - 0x30, - 0x8C, - 0x63, - 0x10, - 0x94, - 0x62, - 0xB1, - 0x8C, - 0x82, - 0x28, - 0x96, - 0x33, - 0x98, - 0xD6, - 0xB5, - 0x4C, - 0x62, - 0x29, - 0xA5, - 0x4A, - 0xB5, - 0x9C, - 0xC6, - 0x31, - 0x14, - 0xD6, - 0x38, - 0x9C, - 0x4B, - 0xB4 - //A0 - , - 0x86, - 0x65, - 0x18, - 0xAE, - 0x67, - 0x1C, - 0xA6, - 0x63, - 0x19, - 0x96, - 0x23, - 0x19, - 0x84, - 0x13, - 8, - 0xA6, - 0x52, - 0xAC, - 0xCA, - 0x22, - 0x89, - 0x6E, - 0xAB, - 0x19, - 0x8C, - 0x62, - 0x34, - 0xC4, - 0x62, - 0x19, - 0x86, - 0x63 - //C0 - , - 0x18, - 0xC4, - 0x23, - 0x58, - 0xD6, - 0xA3, - 0x50, - 0x42, - 0x54, - 0x4A, - 0xAD, - 0x4A, - 0x25, - 0x11, - 0x6B, - 0x64, - 0x89, - 0x4A, - 0x63, - 0x39, - 0x8A, - 0x23, - 0x31, - 0x2A, - 0xEA, - 0xA2, - 0xA9, - 0x44, - 0xC5, - 0x12, - 0xCD, - 0x42 - //E0 - , - 0x34, - 0x8C, - 0x62, - 0x18, - 0x8C, - 0x63, - 0x11, - 0x48, - 0x66, - 0x31, - 0x9D, - 0x44, - 0x33, - 0x1D, - 0x46, - 0x31, - 0x9C, - 0xC6, - 0xB1, - 0xC, - 0xCD, - 0x32, - 0x88, - 0xC4, - 0x73, - 0x18, - 0x86, - 0x73, - 8, - 0xD6, - 0x63, - 0x58 - //100 - , - 7, - 0x81, - 0xE0, - 0xF0, - 0x3C, - 7, - 0x87, - 0x90, - 0x3C, - 0x7C, - 0xF, - 0xC7, - 0xC0, - 0xC0, - 0xF0, - 0x7C, - 0x1E, - 7, - 0x80, - 0x80, - 0, - 0x1C, - 0x78, - 0x70, - 0xF1, - 0xC7, - 0x1F, - 0xC0, - 0xC, - 0xFE, - 0x1C, - 0x1F - //120 - , - 0x1F, - 0xE, - 0xA, - 0x7A, - 0xC0, - 0x71, - 0xF2, - 0x83, - 0x8F, - 3, - 0xF, - 0xF, - 0xC, - 0, - 0x79, - 0xF8, - 0x61, - 0xE0, - 0x43, - 0xF, - 0x83, - 0xE7, - 0x18, - 0xF9, - 0xC1, - 0x13, - 0xDA, - 0xE9, - 0x63, - 0x8F, - 0xF, - 0x83 - //140 - , - 0x83, - 0x87, - 0xC3, - 0x1F, - 0x3C, - 0x70, - 0xF0, - 0xE1, - 0xE1, - 0xE3, - 0x87, - 0xB8, - 0x71, - 0xE, - 0x20, - 0xE3, - 0x8D, - 0x48, - 0x78, - 0x1C, - 0x93, - 0x87, - 0x30, - 0xE1, - 0xC1, - 0xC1, - 0xE4, - 0x78, - 0x21, - 0x83, - 0x83, - 0xC3 - //160 - , - 0x87, - 6, - 0x39, - 0xE5, - 0xC3, - 0x87, - 7, - 0xE, - 0x1C, - 0x1C, - 0x70, - 0xF4, - 0x71, - 0x9C, - 0x60, - 0x36, - 0x32, - 0xC3, - 0x1E, - 0x3C, - 0xF3, - 0x8F, - 0xE, - 0x3C, - 0x70, - 0xE3, - 0xC7, - 0x8F, - 0xF, - 0xF, - 0xE, - 0x3C - //180 - , - 0x78, - 0xF0, - 0xE3, - 0x87, - 6, - 0xF0, - 0xE3, - 7, - 0xC1, - 0x99, - 0x87, - 0xF, - 0x18, - 0x78, - 0x70, - 0x70, - 0xFC, - 0xF3, - 0x10, - 0xB1, - 0x8C, - 0x8C, - 0x31, - 0x7C, - 0x70, - 0xE1, - 0x86, - 0x3C, - 0x64, - 0x6C, - 0xB0, - 0xE1 - //1A0 - , - 0xE3, - 0xF, - 0x23, - 0x8F, - 0xF, - 0x1E, - 0x3E, - 0x38, - 0x3C, - 0x38, - 0x7B, - 0x8F, - 7, - 0xE, - 0x3C, - 0xF4, - 0x17, - 0x1E, - 0x3C, - 0x78, - 0xF2, - 0x9E, - 0x72, - 0x49, - 0xE3, - 0x25, - 0x36, - 0x38, - 0x58, - 0x39, - 0xE2, - 0xDE - //1C0 - , - 0x3C, - 0x78, - 0x78, - 0xE1, - 0xC7, - 0x61, - 0xE1, - 0xE1, - 0xB0, - 0xF0, - 0xF0, - 0xC3, - 0xC7, - 0xE, - 0x38, - 0xC0, - 0xF0, - 0xCE, - 0x73, - 0x73, - 0x18, - 0x34, - 0xB0, - 0xE1, - 0xC7, - 0x8E, - 0x1C, - 0x3C, - 0xF8, - 0x38, - 0xF0, - 0xE1 - //1E0 - , - 0xC1, - 0x8B, - 0x86, - 0x8F, - 0x1C, - 0x78, - 0x70, - 0xF0, - 0x78, - 0xAC, - 0xB1, - 0x8F, - 0x39, - 0x31, - 0xDB, - 0x38, - 0x61, - 0xC3, - 0xE, - 0xE, - 0x38, - 0x78, - 0x73, - 0x17, - 0x1E, - 0x39, - 0x1E, - 0x38, - 0x64, - 0xE1, - 0xF1, - 0xC1 - //200 - , - 0x4E, - 0xF, - 0x40, - 0xA2, - 2, - 0xC5, - 0x8F, - 0x81, - 0xA1, - 0xFC, - 0x12, - 8, - 0x64, - 0xE0, - 0x3C, - 0x22, - 0xE0, - 0x45, - 7, - 0x8E, - 0xC, - 0x32, - 0x90, - 0xF0, - 0x1F, - 0x20, - 0x49, - 0xE0, - 0xF8, - 0xC, - 0x60, - 0xF0 - //220 - , - 0x17, - 0x1A, - 0x41, - 0xAA, - 0xA4, - 0xD0, - 0x8D, - 0x12, - 0x82, - 0x1E, - 0x1E, - 3, - 0xF8, - 0x3E, - 3, - 0xC, - 0x73, - 0x80, - 0x70, - 0x44, - 0x26, - 3, - 0x24, - 0xE1, - 0x3E, - 4, - 0x4E, - 4, - 0x1C, - 0xC1, - 9, - 0xCC - //240 - , - 0x9E, - 0x90, - 0x21, - 7, - 0x90, - 0x43, - 0x64, - 0xC0, - 0xF, - 0xC6, - 0x90, - 0x9C, - 0xC1, - 0x5B, - 3, - 0xE2, - 0x1D, - 0x81, - 0xE0, - 0x5E, - 0x1D, - 3, - 0x84, - 0xB8, - 0x2C, - 0xF, - 0x80, - 0xB1, - 0x83, - 0xE0, - 0x30, - 0x41 - //260 - , - 0x1E, - 0x43, - 0x89, - 0x83, - 0x50, - 0xFC, - 0x24, - 0x2E, - 0x13, - 0x83, - 0xF1, - 0x7C, - 0x4C, - 0x2C, - 0xC9, - 0xD, - 0x83, - 0xB0, - 0xB5, - 0x82, - 0xE4, - 0xE8, - 6, - 0x9C, - 7, - 0xA0, - 0x99, - 0x1D, - 7, - 0x3E, - 0x82, - 0x8F - //280 - , - 0x70, - 0x30, - 0x74, - 0x40, - 0xCA, - 0x10, - 0xE4, - 0xE8, - 0xF, - 0x92, - 0x14, - 0x3F, - 6, - 0xF8, - 0x84, - 0x88, - 0x43, - 0x81, - 0xA, - 0x34, - 0x39, - 0x41, - 0xC6, - 0xE3, - 0x1C, - 0x47, - 3, - 0xB0, - 0xB8, - 0x13, - 0xA, - 0xC2 - //2A0 - , - 0x64, - 0xF8, - 0x18, - 0xF9, - 0x60, - 0xB3, - 0xC0, - 0x65, - 0x20, - 0x60, - 0xA6, - 0x8C, - 0xC3, - 0x81, - 0x20, - 0x30, - 0x26, - 0x1E, - 0x1C, - 0x38, - 0xD3, - 1, - 0xB0, - 0x26, - 0x40, - 0xF4, - 0xB, - 0xC3, - 0x42, - 0x1F, - 0x85, - 0x32 - //2C0 - , - 0x26, - 0x60, - 0x40, - 0xC9, - 0xCB, - 1, - 0xEC, - 0x11, - 0x28, - 0x40, - 0xFA, - 4, - 0x34, - 0xE0, - 0x70, - 0x4C, - 0x8C, - 0x1D, - 7, - 0x69, - 3, - 0x16, - 0xC8, - 4, - 0x23, - 0xE8, - 0xC6, - 0x9A, - 0xB, - 0x1A, - 3, - 0xE0 - //2E0 - , - 0x76, - 6, - 5, - 0xCF, - 0x1E, - 0xBC, - 0x58, - 0x31, - 0x71, - 0x66, - 0, - 0xF8, - 0x3F, - 4, - 0xFC, - 0xC, - 0x74, - 0x27, - 0x8A, - 0x80, - 0x71, - 0xC2, - 0x3A, - 0x26, - 6, - 0xC0, - 0x1F, - 5, - 0xF, - 0x98, - 0x40, - 0xAE - //300 - , - 1, - 0x7F, - 0xC0, - 7, - 0xFF, - 0, - 0xE, - 0xFE, - 0, - 3, - 0xDF, - 0x80, - 3, - 0xEF, - 0x80, - 0x1B, - 0xF1, - 0xC2, - 0, - 0xE7, - 0xE0, - 0x18, - 0xFC, - 0xE0, - 0x21, - 0xFC, - 0x80, - 0x3C, - 0xFC, - 0x40, - 0xE, - 0x7E - //320 - , - 0, - 0x3F, - 0x3E, - 0, - 0xF, - 0xFE, - 0, - 0x1F, - 0xFF, - 0, - 0x3E, - 0xF0, - 7, - 0xFC, - 0, - 0x7E, - 0x10, - 0x3F, - 0xFF, - 0, - 0x3F, - 0x38, - 0xE, - 0x7C, - 1, - 0x87, - 0xC, - 0xFC, - 0xC7, - 0, - 0x3E, - 4 - //340 - , - 0xF, - 0x3E, - 0x1F, - 0xF, - 0xF, - 0x1F, - 0xF, - 2, - 0x83, - 0x87, - 0xCF, - 3, - 0x87, - 0xF, - 0x3F, - 0xC0, - 7, - 0x9E, - 0x60, - 0x3F, - 0xC0, - 3, - 0xFE, - 0, - 0x3F, - 0xE0, - 0x77, - 0xE1, - 0xC0, - 0xFE, - 0xE0, - 0xC3 - //360 - , - 0xE0, - 1, - 0xDF, - 0xF8, - 3, - 7, - 0, - 0x7E, - 0x70, - 0, - 0x7C, - 0x38, - 0x18, - 0xFE, - 0xC, - 0x1E, - 0x78, - 0x1C, - 0x7C, - 0x3E, - 0xE, - 0x1F, - 0x1E, - 0x1E, - 0x3E, - 0, - 0x7F, - 0x83, - 7, - 0xDB, - 0x87, - 0x83 - //380 - , - 7, - 0xC7, - 7, - 0x10, - 0x71, - 0xFF, - 0, - 0x3F, - 0xE2, - 1, - 0xE0, - 0xC1, - 0xC3, - 0xE1, - 0, - 0x7F, - 0xC0, - 5, - 0xF0, - 0x20, - 0xF8, - 0xF0, - 0x70, - 0xFE, - 0x78, - 0x79, - 0xF8, - 2, - 0x3F, - 0xC, - 0x8F, - 3 - //3a0 - , - 0xF, - 0x9F, - 0xE0, - 0xC1, - 0xC7, - 0x87, - 3, - 0xC3, - 0xC3, - 0xB0, - 0xE1, - 0xE1, - 0xC1, - 0xE3, - 0xE0, - 0x71, - 0xF0, - 0, - 0xFC, - 0x70, - 0x7C, - 0xC, - 0x3E, - 0x38, - 0xE, - 0x1C, - 0x70, - 0xC3, - 0xC7, - 3, - 0x81, - 0xC1 - //3c0 - , - 0xC7, - 0xE7, - 0, - 0xF, - 0xC7, - 0x87, - 0x19, - 9, - 0xEF, - 0xC4, - 0x33, - 0xE0, - 0xC1, - 0xFC, - 0xF8, - 0x70, - 0xF0, - 0x78, - 0xF8, - 0xF0, - 0x61, - 0xC7, - 0, - 0x1F, - 0xF8, - 1, - 0x7C, - 0xF8, - 0xF0, - 0x78, - 0x70, - 0x3C - //3e0 - , - 0x7C, - 0xCE, - 0xE, - 0x21, - 0x83, - 0xCF, - 8, - 7, - 0x8F, - 8, - 0xC1, - 0x87, - 0x8F, - 0x80, - 0xC7, - 0xE3, - 0, - 7, - 0xF8, - 0xE0, - 0xEF, - 0, - 0x39, - 0xF7, - 0x80, - 0xE, - 0xF8, - 0xE1, - 0xE3, - 0xF8, - 0x21, - 0x9F - //400 - , - 0xC0, - 0xFF, - 3, - 0xF8, - 7, - 0xC0, - 0x1F, - 0xF8, - 0xC4, - 4, - 0xFC, - 0xC4, - 0xC1, - 0xBC, - 0x87, - 0xF0, - 0xF, - 0xC0, - 0x7F, - 5, - 0xE0, - 0x25, - 0xEC, - 0xC0, - 0x3E, - 0x84, - 0x47, - 0xF0, - 0x8E, - 3, - 0xF8, - 3 - //420 - , - 0xFB, - 0xC0, - 0x19, - 0xF8, - 7, - 0x9C, - 0xC, - 0x17, - 0xF8, - 7, - 0xE0, - 0x1F, - 0xA1, - 0xFC, - 0xF, - 0xFC, - 1, - 0xF0, - 0x3F, - 0, - 0xFE, - 3, - 0xF0, - 0x1F, - 0, - 0xFD, - 0, - 0xFF, - 0x88, - 0xD, - 0xF9, - 1 - //440 - , - 0xFF, - 0, - 0x70, - 7, - 0xC0, - 0x3E, - 0x42, - 0xF3, - 0xD, - 0xC4, - 0x7F, - 0x80, - 0xFC, - 7, - 0xF0, - 0x5E, - 0xC0, - 0x3F, - 0, - 0x78, - 0x3F, - 0x81, - 0xFF, - 1, - 0xF8, - 1, - 0xC3, - 0xE8, - 0xC, - 0xE4, - 0x64, - 0x8F - ////460 - , - 0xE4, - 0xF, - 0xF0, - 7, - 0xF0, - 0xC2, - 0x1F, - 0, - 0x7F, - 0xC0, - 0x6F, - 0x80, - 0x7E, - 3, - 0xF8, - 7, - 0xF0, - 0x3F, - 0xC0, - 0x78, - 0xF, - 0x82, - 7, - 0xFE, - 0x22, - 0x77, - 0x70, - 2, - 0x76, - 3, - 0xFE, - 0 - //480 - , - 0xFE, - 0x67, - 0, - 0x7C, - 0xC7, - 0xF1, - 0x8E, - 0xC6, - 0x3B, - 0xE0, - 0x3F, - 0x84, - 0xF3, - 0x19, - 0xD8, - 3, - 0x99, - 0xFC, - 9, - 0xB8, - 0xF, - 0xF8, - 0, - 0x9D, - 0x24, - 0x61, - 0xF9, - 0xD, - 0, - 0xFD, - 3, - 0xF0 - //4a0 - , - 0x1F, - 0x90, - 0x3F, - 1, - 0xF8, - 0x1F, - 0xD0, - 0xF, - 0xF8, - 0x37, - 1, - 0xF8, - 7, - 0xF0, - 0xF, - 0xC0, - 0x3F, - 0, - 0xFE, - 3, - 0xF8, - 0xF, - 0xC0, - 0x3F, - 0, - 0xFA, - 3, - 0xF0, - 0xF, - 0x80, - 0xFF, - 1 - //4c0 - , - 0xB8, - 7, - 0xF0, - 1, - 0xFC, - 1, - 0xBC, - 0x80, - 0x13, - 0x1E, - 0, - 0x7F, - 0xE1, - 0x40, - 0x7F, - 0xA0, - 0x7F, - 0xB0, - 0, - 0x3F, - 0xC0, - 0x1F, - 0xC0, - 0x38, - 0xF, - 0xF0, - 0x1F, - 0x80, - 0xFF, - 1, - 0xFC, - 3 - //4e0 - , - 0xF1, - 0x7E, - 1, - 0xFE, - 1, - 0xF0, - 0xFF, - 0, - 0x7F, - 0xC0, - 0x1D, - 7, - 0xF0, - 0xF, - 0xC0, - 0x7E, - 6, - 0xE0, - 7, - 0xE0, - 0xF, - 0xF8, - 6, - 0xC1, - 0xFE, - 1, - 0xFC, - 3, - 0xE0, - 0xF, - 0, - 0xFC}; - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Render -// -//////////////////////////////////////////////////////////////////////////////////////////// - -unsigned char pitches[256]; // tab43008 - -unsigned char frequency1[256]; -unsigned char frequency2[256]; -unsigned char frequency3[256]; - -unsigned char amplitude1[256]; -unsigned char amplitude2[256]; -unsigned char amplitude3[256]; - -unsigned char sampledConsonantFlag[256]; // tab44800 - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Sam -// -//////////////////////////////////////////////////////////////////////////////////////////// - -unsigned char stress[256]; //numbers from 0 to 8 -unsigned char phonemeLength[256]; //tab40160 -unsigned char phonemeindex[256]; - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// ReciterTabs -// -//////////////////////////////////////////////////////////////////////////////////////////// - -//some flags -const unsigned char tab36376[] = { - 0, 0, 0, 0, 0, 0, 0, 0, // 0-7 - 0, 0, 0, 0, 0, 0, 0, 0, // 8-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2, 2, 2, 2, 2, 2, 130, // ' ', '!' - 0, 0, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 2, 2, 2, 2, 2, 2, 2, 192, 168, 176, 172, 192, 160, 184, // '@', 'A' - 160, 192, 188, 160, 172, 168, 172, 192, 160, 160, 172, 180, 164, 192, 168, 168, - 176, 192, 188, 0, 0, 0, 2, 0, // 'X', 'Y', 'Z', '[', - 32, 32, 155, 32, 192, 185, 32, 205, 163, 76, 138, 142}; - -const unsigned char rules[] = { - ']', 'A' | 0x80, ' ', '(', 'A', '.', ')', '=', - 'E', 'H', '4', 'Y', '.', ' ' | 0x80, '(', 'A', - ')', ' ', '=', 'A', 'H' | 0x80, ' ', '(', 'A', - 'R', 'E', ')', ' ', '=', 'A', 'A', 'R' | 0x80, - ' ', '(', 'A', 'R', ')', 'O', '=', 'A', - 'X', 'R' | 0x80, '(', 'A', 'R', ')', '#', '=', - 'E', 'H', '4', 'R' | 0x80, ' ', '^', '(', 'A', - 'S', ')', '#', '=', 'E', 'Y', '4', 'S' | 0x80, - '(', 'A', ')', 'W', 'A', '=', 'A', 'X' | 0x80, - '(', 'A', 'W', ')', '=', 'A', 'O', '5' | 0x80, - ' ', ':', '(', 'A', 'N', 'Y', ')', '=', - 'E', 'H', '4', 'N', 'I', 'Y' | 0x80, '(', 'A', - ')', '^', '+', '#', '=', 'E', 'Y', '5' | 0x80, - '#', ':', '(', 'A', 'L', 'L', 'Y', ')', - '=', 'U', 'L', 'I', 'Y' | 0x80, ' ', '(', 'A', - 'L', ')', '#', '=', 'U', 'L' | 0x80, '(', 'A', - 'G', 'A', 'I', 'N', ')', '=', 'A', 'X', - 'G', 'E', 'H', '4', 'N' | 0x80, '#', ':', '(', - 'A', 'G', ')', 'E', '=', 'I', 'H', 'J' | 0x80, - '(', 'A', ')', '^', '%', '=', 'E', 'Y' | 0x80, - '(', 'A', ')', '^', '+', ':', '#', '=', - 'A', 'E' | 0x80, ' ', ':', '(', 'A', ')', '^', - '+', ' ', '=', 'E', 'Y', '4' | 0x80, ' ', '(', - 'A', 'R', 'R', ')', '=', 'A', 'X', 'R' | 0x80, - '(', 'A', 'R', 'R', ')', '=', 'A', 'E', - '4', 'R' | 0x80, ' ', '^', '(', 'A', 'R', ')', - ' ', '=', 'A', 'A', '5', 'R' | 0x80, '(', 'A', - 'R', ')', '=', 'A', 'A', '5', 'R' | 0x80, '(', - 'A', 'I', 'R', ')', '=', 'E', 'H', '4', - 'R' | 0x80, '(', 'A', 'I', ')', '=', 'E', 'Y', - '4' | 0x80, '(', 'A', 'Y', ')', '=', 'E', 'Y', - '5' | 0x80, '(', 'A', 'U', ')', '=', 'A', 'O', - '4' | 0x80, '#', ':', '(', 'A', 'L', ')', ' ', - '=', 'U', 'L' | 0x80, '#', ':', '(', 'A', 'L', - 'S', ')', ' ', '=', 'U', 'L', 'Z' | 0x80, '(', - 'A', 'L', 'K', ')', '=', 'A', 'O', '4', - 'K' | 0x80, '(', 'A', 'L', ')', '^', '=', 'A', - 'O', 'L' | 0x80, ' ', ':', '(', 'A', 'B', 'L', - 'E', ')', '=', 'E', 'Y', '4', 'B', 'U', - 'L' | 0x80, '(', 'A', 'B', 'L', 'E', ')', '=', - 'A', 'X', 'B', 'U', 'L' | 0x80, '(', 'A', ')', - 'V', 'O', '=', 'E', 'Y', '4' | 0x80, '(', 'A', - 'N', 'G', ')', '+', '=', 'E', 'Y', '4', - 'N', 'J' | 0x80, '(', 'A', 'T', 'A', 'R', 'I', - ')', '=', 'A', 'H', 'T', 'A', 'A', '4', - 'R', 'I', 'Y' | 0x80, '(', 'A', ')', 'T', 'O', - 'M', '=', 'A', 'E' | 0x80, '(', 'A', ')', 'T', - 'T', 'I', '=', 'A', 'E' | 0x80, ' ', '(', 'A', - 'T', ')', ' ', '=', 'A', 'E', 'T' | 0x80, ' ', - '(', 'A', ')', 'T', '=', 'A', 'H' | 0x80, '(', - 'A', ')', '=', 'A', 'E' | 0x80, - - ']', 'B' | 0x80, ' ', '(', 'B', ')', ' ', '=', - 'B', 'I', 'Y', '4' | 0x80, ' ', '(', 'B', 'E', - ')', '^', '#', '=', 'B', 'I', 'H' | 0x80, '(', - 'B', 'E', 'I', 'N', 'G', ')', '=', 'B', - 'I', 'Y', '4', 'I', 'H', 'N', 'X' | 0x80, ' ', - '(', 'B', 'O', 'T', 'H', ')', ' ', '=', - 'B', 'O', 'W', '4', 'T', 'H' | 0x80, ' ', '(', - 'B', 'U', 'S', ')', '#', '=', 'B', 'I', - 'H', '4', 'Z' | 0x80, '(', 'B', 'R', 'E', 'A', - 'K', ')', '=', 'B', 'R', 'E', 'Y', '5', - 'K' | 0x80, '(', 'B', 'U', 'I', 'L', ')', '=', - 'B', 'I', 'H', '4', 'L' | 0x80, '(', 'B', ')', - '=', 'B' | 0x80, - - ']', 'C' | 0x80, ' ', '(', 'C', ')', ' ', '=', - 'S', 'I', 'Y', '4' | 0x80, ' ', '(', 'C', 'H', - ')', '^', '=', 'K' | 0x80, '^', 'E', '(', 'C', - 'H', ')', '=', 'K' | 0x80, '(', 'C', 'H', 'A', - ')', 'R', '#', '=', 'K', 'E', 'H', '5' | 0x80, - '(', 'C', 'H', ')', '=', 'C', 'H' | 0x80, ' ', - 'S', '(', 'C', 'I', ')', '#', '=', 'S', - 'A', 'Y', '4' | 0x80, '(', 'C', 'I', ')', 'A', - '=', 'S', 'H' | 0x80, '(', 'C', 'I', ')', 'O', - '=', 'S', 'H' | 0x80, '(', 'C', 'I', ')', 'E', - 'N', '=', 'S', 'H' | 0x80, '(', 'C', 'I', 'T', - 'Y', ')', '=', 'S', 'I', 'H', 'T', 'I', - 'Y' | 0x80, '(', 'C', ')', '+', '=', 'S' | 0x80, '(', - 'C', 'K', ')', '=', 'K' | 0x80, '(', 'C', 'O', - 'M', 'M', 'O', 'D', 'O', 'R', 'E', ')', - '=', 'K', 'A', 'A', '4', 'M', 'A', 'H', - 'D', 'O', 'H', 'R' | 0x80, '(', 'C', 'O', 'M', - ')', '=', 'K', 'A', 'H', 'M' | 0x80, '(', 'C', - 'U', 'I', 'T', ')', '=', 'K', 'I', 'H', - 'T' | 0x80, '(', 'C', 'R', 'E', 'A', ')', '=', - 'K', 'R', 'I', 'Y', 'E', 'Y' | 0x80, '(', 'C', - ')', '=', 'K' | 0x80, - - ']', 'D' | 0x80, ' ', '(', 'D', ')', ' ', '=', - 'D', 'I', 'Y', '4' | 0x80, ' ', '(', 'D', 'R', - '.', ')', ' ', '=', 'D', 'A', 'A', '4', - 'K', 'T', 'E', 'R' | 0x80, '#', ':', '(', 'D', - 'E', 'D', ')', ' ', '=', 'D', 'I', 'H', - 'D' | 0x80, '.', 'E', '(', 'D', ')', ' ', '=', - 'D' | 0x80, '#', ':', '^', 'E', '(', 'D', ')', - ' ', '=', 'T' | 0x80, ' ', '(', 'D', 'E', ')', - '^', '#', '=', 'D', 'I', 'H' | 0x80, ' ', '(', - 'D', 'O', ')', ' ', '=', 'D', 'U', 'W' | 0x80, - ' ', '(', 'D', 'O', 'E', 'S', ')', '=', - 'D', 'A', 'H', 'Z' | 0x80, '(', 'D', 'O', 'N', - 'E', ')', ' ', '=', 'D', 'A', 'H', '5', - 'N' | 0x80, '(', 'D', 'O', 'I', 'N', 'G', ')', - '=', 'D', 'U', 'W', '4', 'I', 'H', 'N', - 'X' | 0x80, ' ', '(', 'D', 'O', 'W', ')', '=', - 'D', 'A', 'W' | 0x80, '#', '(', 'D', 'U', ')', - 'A', '=', 'J', 'U', 'W' | 0x80, '#', '(', 'D', - 'U', ')', '^', '#', '=', 'J', 'A', 'X' | 0x80, - '(', 'D', ')', '=', 'D' | 0x80, - - ']', 'E' | 0x80, ' ', '(', 'E', ')', ' ', '=', - 'I', 'Y', 'I', 'Y', '4' | 0x80, '#', ':', '(', - 'E', ')', ' ', '=' | 0x80, '\'', ':', '^', '(', - 'E', ')', ' ', '=' | 0x80, ' ', ':', '(', 'E', - ')', ' ', '=', 'I', 'Y' | 0x80, '#', '(', 'E', - 'D', ')', ' ', '=', 'D' | 0x80, '#', ':', '(', - 'E', ')', 'D', ' ', '=' | 0x80, '(', 'E', 'V', - ')', 'E', 'R', '=', 'E', 'H', '4', 'V' | 0x80, - '(', 'E', ')', '^', '%', '=', 'I', 'Y', - '4' | 0x80, '(', 'E', 'R', 'I', ')', '#', '=', - 'I', 'Y', '4', 'R', 'I', 'Y' | 0x80, '(', 'E', - 'R', 'I', ')', '=', 'E', 'H', '4', 'R', - 'I', 'H' | 0x80, '#', ':', '(', 'E', 'R', ')', - '#', '=', 'E', 'R' | 0x80, '(', 'E', 'R', 'R', - 'O', 'R', ')', '=', 'E', 'H', '4', 'R', - 'O', 'H', 'R' | 0x80, '(', 'E', 'R', 'A', 'S', - 'E', ')', '=', 'I', 'H', 'R', 'E', 'Y', - '5', 'S' | 0x80, '(', 'E', 'R', ')', '#', '=', - 'E', 'H', 'R' | 0x80, '(', 'E', 'R', ')', '=', - 'E', 'R' | 0x80, ' ', '(', 'E', 'V', 'E', 'N', - ')', '=', 'I', 'Y', 'V', 'E', 'H', 'N' | 0x80, - '#', ':', '(', 'E', ')', 'W', '=' | 0x80, '@', - '(', 'E', 'W', ')', '=', 'U', 'W' | 0x80, '(', - 'E', 'W', ')', '=', 'Y', 'U', 'W' | 0x80, '(', - 'E', ')', 'O', '=', 'I', 'Y' | 0x80, '#', ':', - '&', '(', 'E', 'S', ')', ' ', '=', 'I', - 'H', 'Z' | 0x80, '#', ':', '(', 'E', ')', 'S', - ' ', '=' | 0x80, '#', ':', '(', 'E', 'L', 'Y', - ')', ' ', '=', 'L', 'I', 'Y' | 0x80, '#', ':', - '(', 'E', 'M', 'E', 'N', 'T', ')', '=', - 'M', 'E', 'H', 'N', 'T' | 0x80, '(', 'E', 'F', - 'U', 'L', ')', '=', 'F', 'U', 'H', 'L' | 0x80, - '(', 'E', 'E', ')', '=', 'I', 'Y', '4' | 0x80, - '(', 'E', 'A', 'R', 'N', ')', '=', 'E', - 'R', '5', 'N' | 0x80, ' ', '(', 'E', 'A', 'R', - ')', '^', '=', 'E', 'R', '5' | 0x80, '(', 'E', - 'A', 'D', ')', '=', 'E', 'H', 'D' | 0x80, '#', - ':', '(', 'E', 'A', ')', ' ', '=', 'I', - 'Y', 'A', 'X' | 0x80, '(', 'E', 'A', ')', 'S', - 'U', '=', 'E', 'H', '5' | 0x80, '(', 'E', 'A', - ')', '=', 'I', 'Y', '5' | 0x80, '(', 'E', 'I', - 'G', 'H', ')', '=', 'E', 'Y', '4' | 0x80, '(', - 'E', 'I', ')', '=', 'I', 'Y', '4' | 0x80, ' ', - '(', 'E', 'Y', 'E', ')', '=', 'A', 'Y', - '4' | 0x80, '(', 'E', 'Y', ')', '=', 'I', 'Y' | 0x80, - '(', 'E', 'U', ')', '=', 'Y', 'U', 'W', - '5' | 0x80, '(', 'E', 'Q', 'U', 'A', 'L', ')', - '=', 'I', 'Y', '4', 'K', 'W', 'U', 'L' | 0x80, - '(', 'E', ')', '=', 'E', 'H' | 0x80, - - ']', 'F' | 0x80, ' ', '(', 'F', ')', ' ', '=', - 'E', 'H', '4', 'F' | 0x80, '(', 'F', 'U', 'L', - ')', '=', 'F', 'U', 'H', 'L' | 0x80, '(', 'F', - 'R', 'I', 'E', 'N', 'D', ')', '=', 'F', - 'R', 'E', 'H', '5', 'N', 'D' | 0x80, '(', 'F', - 'A', 'T', 'H', 'E', 'R', ')', '=', 'F', - 'A', 'A', '4', 'D', 'H', 'E', 'R' | 0x80, '(', - 'F', ')', 'F', '=' | 0x80, '(', 'F', ')', '=', - 'F' | 0x80, - - ']', 'G' | 0x80, ' ', '(', 'G', ')', ' ', '=', - 'J', 'I', 'Y', '4' | 0x80, '(', 'G', 'I', 'V', - ')', '=', 'G', 'I', 'H', '5', 'V' | 0x80, ' ', - '(', 'G', ')', 'I', '^', '=', 'G' | 0x80, '(', - 'G', 'E', ')', 'T', '=', 'G', 'E', 'H', - '5' | 0x80, 'S', 'U', '(', 'G', 'G', 'E', 'S', - ')', '=', 'G', 'J', 'E', 'H', '4', 'S' | 0x80, - '(', 'G', 'G', ')', '=', 'G' | 0x80, ' ', 'B', - '#', '(', 'G', ')', '=', 'G' | 0x80, '(', 'G', - ')', '+', '=', 'J' | 0x80, '(', 'G', 'R', 'E', - 'A', 'T', ')', '=', 'G', 'R', 'E', 'Y', - '4', 'T' | 0x80, '(', 'G', 'O', 'N', ')', 'E', - '=', 'G', 'A', 'O', '5', 'N' | 0x80, '#', '(', - 'G', 'H', ')', '=' | 0x80, ' ', '(', 'G', 'N', - ')', '=', 'N' | 0x80, '(', 'G', ')', '=', 'G' | 0x80, - - ']', 'H' | 0x80, ' ', '(', 'H', ')', ' ', '=', - 'E', 'Y', '4', 'C', 'H' | 0x80, ' ', '(', 'H', - 'A', 'V', ')', '=', '/', 'H', 'A', 'E', - '6', 'V' | 0x80, ' ', '(', 'H', 'E', 'R', 'E', - ')', '=', '/', 'H', 'I', 'Y', 'R' | 0x80, ' ', - '(', 'H', 'O', 'U', 'R', ')', '=', 'A', - 'W', '5', 'E', 'R' | 0x80, '(', 'H', 'O', 'W', - ')', '=', '/', 'H', 'A', 'W' | 0x80, '(', 'H', - ')', '#', '=', '/', 'H' | 0x80, '(', 'H', ')', - '=' | 0x80, - - ']', 'I' | 0x80, ' ', '(', 'I', 'N', ')', '=', - 'I', 'H', 'N' | 0x80, ' ', '(', 'I', ')', ' ', - '=', 'A', 'Y', '4' | 0x80, '(', 'I', ')', ' ', - '=', 'A', 'Y' | 0x80, '(', 'I', 'N', ')', 'D', - '=', 'A', 'Y', '5', 'N' | 0x80, 'S', 'E', 'M', - '(', 'I', ')', '=', 'I', 'Y' | 0x80, ' ', 'A', - 'N', 'T', '(', 'I', ')', '=', 'A', 'Y' | 0x80, - '(', 'I', 'E', 'R', ')', '=', 'I', 'Y', - 'E', 'R' | 0x80, '#', ':', 'R', '(', 'I', 'E', - 'D', ')', ' ', '=', 'I', 'Y', 'D' | 0x80, '(', - 'I', 'E', 'D', ')', ' ', '=', 'A', 'Y', - '5', 'D' | 0x80, '(', 'I', 'E', 'N', ')', '=', - 'I', 'Y', 'E', 'H', 'N' | 0x80, '(', 'I', 'E', - ')', 'T', '=', 'A', 'Y', '4', 'E', 'H' | 0x80, - '(', 'I', '\'', ')', '=', 'A', 'Y', '5' | 0x80, - ' ', ':', '(', 'I', ')', '^', '%', '=', - 'A', 'Y', '5' | 0x80, ' ', ':', '(', 'I', 'E', - ')', ' ', '=', 'A', 'Y', '4' | 0x80, '(', 'I', - ')', '%', '=', 'I', 'Y' | 0x80, '(', 'I', 'E', - ')', '=', 'I', 'Y', '4' | 0x80, ' ', '(', 'I', - 'D', 'E', 'A', ')', '=', 'A', 'Y', 'D', - 'I', 'Y', '5', 'A', 'H' | 0x80, '(', 'I', ')', - '^', '+', ':', '#', '=', 'I', 'H' | 0x80, '(', - 'I', 'R', ')', '#', '=', 'A', 'Y', 'R' | 0x80, - '(', 'I', 'Z', ')', '%', '=', 'A', 'Y', - 'Z' | 0x80, '(', 'I', 'S', ')', '%', '=', 'A', - 'Y', 'Z' | 0x80, 'I', '^', '(', 'I', ')', '^', - '#', '=', 'I', 'H' | 0x80, '+', '^', '(', 'I', - ')', '^', '+', '=', 'A', 'Y' | 0x80, '#', ':', - '^', '(', 'I', ')', '^', '+', '=', 'I', - 'H' | 0x80, '(', 'I', ')', '^', '+', '=', 'A', - 'Y' | 0x80, '(', 'I', 'R', ')', '=', 'E', 'R' | 0x80, - '(', 'I', 'G', 'H', ')', '=', 'A', 'Y', - '4' | 0x80, '(', 'I', 'L', 'D', ')', '=', 'A', - 'Y', '5', 'L', 'D' | 0x80, ' ', '(', 'I', 'G', - 'N', ')', '=', 'I', 'H', 'G', 'N' | 0x80, '(', - 'I', 'G', 'N', ')', ' ', '=', 'A', 'Y', - '4', 'N' | 0x80, '(', 'I', 'G', 'N', ')', '^', - '=', 'A', 'Y', '4', 'N' | 0x80, '(', 'I', 'G', - 'N', ')', '%', '=', 'A', 'Y', '4', 'N' | 0x80, - '(', 'I', 'C', 'R', 'O', ')', '=', 'A', - 'Y', '4', 'K', 'R', 'O', 'H' | 0x80, '(', 'I', - 'Q', 'U', 'E', ')', '=', 'I', 'Y', '4', - 'K' | 0x80, '(', 'I', ')', '=', 'I', 'H' | 0x80, - - ']', 'J' | 0x80, ' ', '(', 'J', ')', ' ', '=', - 'J', 'E', 'Y', '4' | 0x80, '(', 'J', ')', '=', - 'J' | 0x80, - - ']', 'K' | 0x80, ' ', '(', 'K', ')', ' ', '=', - 'K', 'E', 'Y', '4' | 0x80, ' ', '(', 'K', ')', - 'N', '=' | 0x80, '(', 'K', ')', '=', 'K' | 0x80, - - ']', 'L' | 0x80, ' ', '(', 'L', ')', ' ', '=', - 'E', 'H', '4', 'L' | 0x80, '(', 'L', 'O', ')', - 'C', '#', '=', 'L', 'O', 'W' | 0x80, 'L', '(', - 'L', ')', '=' | 0x80, '#', ':', '^', '(', 'L', - ')', '%', '=', 'U', 'L' | 0x80, '(', 'L', 'E', - 'A', 'D', ')', '=', 'L', 'I', 'Y', 'D' | 0x80, - ' ', '(', 'L', 'A', 'U', 'G', 'H', ')', - '=', 'L', 'A', 'E', '4', 'F' | 0x80, '(', 'L', - ')', '=', 'L' | 0x80, - - ']', 'M' | 0x80, ' ', '(', 'M', ')', ' ', '=', - 'E', 'H', '4', 'M' | 0x80, ' ', '(', 'M', 'R', - '.', ')', ' ', '=', 'M', 'I', 'H', '4', - 'S', 'T', 'E', 'R' | 0x80, ' ', '(', 'M', 'S', - '.', ')', '=', 'M', 'I', 'H', '5', 'Z' | 0x80, - ' ', '(', 'M', 'R', 'S', '.', ')', ' ', - '=', 'M', 'I', 'H', '4', 'S', 'I', 'X', - 'Z' | 0x80, '(', 'M', 'O', 'V', ')', '=', 'M', - 'U', 'W', '4', 'V' | 0x80, '(', 'M', 'A', 'C', - 'H', 'I', 'N', ')', '=', 'M', 'A', 'H', - 'S', 'H', 'I', 'Y', '5', 'N' | 0x80, 'M', '(', - 'M', ')', '=' | 0x80, '(', 'M', ')', '=', 'M' | 0x80, - - ']', 'N' | 0x80, ' ', '(', 'N', ')', ' ', '=', - 'E', 'H', '4', 'N' | 0x80, 'E', '(', 'N', 'G', - ')', '+', '=', 'N', 'J' | 0x80, '(', 'N', 'G', - ')', 'R', '=', 'N', 'X', 'G' | 0x80, '(', 'N', - 'G', ')', '#', '=', 'N', 'X', 'G' | 0x80, '(', - 'N', 'G', 'L', ')', '%', '=', 'N', 'X', - 'G', 'U', 'L' | 0x80, '(', 'N', 'G', ')', '=', - 'N', 'X' | 0x80, '(', 'N', 'K', ')', '=', 'N', - 'X', 'K' | 0x80, ' ', '(', 'N', 'O', 'W', ')', - ' ', '=', 'N', 'A', 'W', '4' | 0x80, 'N', '(', - 'N', ')', '=' | 0x80, '(', 'N', 'O', 'N', ')', - 'E', '=', 'N', 'A', 'H', '4', 'N' | 0x80, '(', - 'N', ')', '=', 'N' | 0x80, - - ']', 'O' | 0x80, ' ', '(', 'O', ')', ' ', '=', - 'O', 'H', '4', 'W' | 0x80, '(', 'O', 'F', ')', - ' ', '=', 'A', 'H', 'V' | 0x80, ' ', '(', 'O', - 'H', ')', ' ', '=', 'O', 'W', '5' | 0x80, '(', - 'O', 'R', 'O', 'U', 'G', 'H', ')', '=', - 'E', 'R', '4', 'O', 'W' | 0x80, '#', ':', '(', - 'O', 'R', ')', ' ', '=', 'E', 'R' | 0x80, '#', - ':', '(', 'O', 'R', 'S', ')', ' ', '=', - 'E', 'R', 'Z' | 0x80, '(', 'O', 'R', ')', '=', - 'A', 'O', 'R' | 0x80, ' ', '(', 'O', 'N', 'E', - ')', '=', 'W', 'A', 'H', 'N' | 0x80, '#', '(', - 'O', 'N', 'E', ')', ' ', '=', 'W', 'A', - 'H', 'N' | 0x80, '(', 'O', 'W', ')', '=', 'O', - 'W' | 0x80, ' ', '(', 'O', 'V', 'E', 'R', ')', - '=', 'O', 'W', '5', 'V', 'E', 'R' | 0x80, 'P', - 'R', '(', 'O', ')', 'V', '=', 'U', 'W', - '4' | 0x80, '(', 'O', 'V', ')', '=', 'A', 'H', - '4', 'V' | 0x80, '(', 'O', ')', '^', '%', '=', - 'O', 'W', '5' | 0x80, '(', 'O', ')', '^', 'E', - 'N', '=', 'O', 'W' | 0x80, '(', 'O', ')', '^', - 'I', '#', '=', 'O', 'W', '5' | 0x80, '(', 'O', - 'L', ')', 'D', '=', 'O', 'W', '4', 'L' | 0x80, - '(', 'O', 'U', 'G', 'H', 'T', ')', '=', - 'A', 'O', '5', 'T' | 0x80, '(', 'O', 'U', 'G', - 'H', ')', '=', 'A', 'H', '5', 'F' | 0x80, ' ', - '(', 'O', 'U', ')', '=', 'A', 'W' | 0x80, 'H', - '(', 'O', 'U', ')', 'S', '#', '=', 'A', - 'W', '4' | 0x80, '(', 'O', 'U', 'S', ')', '=', - 'A', 'X', 'S' | 0x80, '(', 'O', 'U', 'R', ')', - '=', 'O', 'H', 'R' | 0x80, '(', 'O', 'U', 'L', - 'D', ')', '=', 'U', 'H', '5', 'D' | 0x80, '(', - 'O', 'U', ')', '^', 'L', '=', 'A', 'H', - '5' | 0x80, '(', 'O', 'U', 'P', ')', '=', 'U', - 'W', '5', 'P' | 0x80, '(', 'O', 'U', ')', '=', - 'A', 'W' | 0x80, '(', 'O', 'Y', ')', '=', 'O', - 'Y' | 0x80, '(', 'O', 'I', 'N', 'G', ')', '=', - 'O', 'W', '4', 'I', 'H', 'N', 'X' | 0x80, '(', - 'O', 'I', ')', '=', 'O', 'Y', '5' | 0x80, '(', - 'O', 'O', 'R', ')', '=', 'O', 'H', '5', - 'R' | 0x80, '(', 'O', 'O', 'K', ')', '=', 'U', - 'H', '5', 'K' | 0x80, 'F', '(', 'O', 'O', 'D', - ')', '=', 'U', 'W', '5', 'D' | 0x80, 'L', '(', - 'O', 'O', 'D', ')', '=', 'A', 'H', '5', - 'D' | 0x80, 'M', '(', 'O', 'O', 'D', ')', '=', - 'U', 'W', '5', 'D' | 0x80, '(', 'O', 'O', 'D', - ')', '=', 'U', 'H', '5', 'D' | 0x80, 'F', '(', - 'O', 'O', 'T', ')', '=', 'U', 'H', '5', - 'T' | 0x80, '(', 'O', 'O', ')', '=', 'U', 'W', - '5' | 0x80, '(', 'O', '\'', ')', '=', 'O', 'H' | 0x80, - '(', 'O', ')', 'E', '=', 'O', 'W' | 0x80, '(', - 'O', ')', ' ', '=', 'O', 'W' | 0x80, '(', 'O', - 'A', ')', '=', 'O', 'W', '4' | 0x80, ' ', '(', - 'O', 'N', 'L', 'Y', ')', '=', 'O', 'W', - '4', 'N', 'L', 'I', 'Y' | 0x80, ' ', '(', 'O', - 'N', 'C', 'E', ')', '=', 'W', 'A', 'H', - '4', 'N', 'S' | 0x80, '(', 'O', 'N', '\'', 'T', - ')', '=', 'O', 'W', '4', 'N', 'T' | 0x80, 'C', - '(', 'O', ')', 'N', '=', 'A', 'A' | 0x80, '(', - 'O', ')', 'N', 'G', '=', 'A', 'O' | 0x80, ' ', - ':', '^', '(', 'O', ')', 'N', '=', 'A', - 'H' | 0x80, 'I', '(', 'O', 'N', ')', '=', 'U', - 'N' | 0x80, '#', ':', '(', 'O', 'N', ')', '=', - 'U', 'N' | 0x80, '#', '^', '(', 'O', 'N', ')', - '=', 'U', 'N' | 0x80, '(', 'O', ')', 'S', 'T', - '=', 'O', 'W' | 0x80, '(', 'O', 'F', ')', '^', - '=', 'A', 'O', '4', 'F' | 0x80, '(', 'O', 'T', - 'H', 'E', 'R', ')', '=', 'A', 'H', '5', - 'D', 'H', 'E', 'R' | 0x80, 'R', '(', 'O', ')', - 'B', '=', 'R', 'A', 'A' | 0x80, '^', 'R', '(', - 'O', ')', ':', '#', '=', 'O', 'W', '5' | 0x80, - '(', 'O', 'S', 'S', ')', ' ', '=', 'A', - 'O', '5', 'S' | 0x80, '#', ':', '^', '(', 'O', - 'M', ')', '=', 'A', 'H', 'M' | 0x80, '(', 'O', - ')', '=', 'A', 'A' | 0x80, - - ']', 'P' | 0x80, ' ', '(', 'P', ')', ' ', '=', - 'P', 'I', 'Y', '4' | 0x80, '(', 'P', 'H', ')', - '=', 'F' | 0x80, '(', 'P', 'E', 'O', 'P', 'L', - ')', '=', 'P', 'I', 'Y', '5', 'P', 'U', - 'L' | 0x80, '(', 'P', 'O', 'W', ')', '=', 'P', - 'A', 'W', '4' | 0x80, '(', 'P', 'U', 'T', ')', - ' ', '=', 'P', 'U', 'H', 'T' | 0x80, '(', 'P', - ')', 'P', '=' | 0x80, '(', 'P', ')', 'S', '=' | 0x80, - '(', 'P', ')', 'N', '=' | 0x80, '(', 'P', 'R', - 'O', 'F', '.', ')', '=', 'P', 'R', 'O', - 'H', 'F', 'E', 'H', '4', 'S', 'E', 'R' | 0x80, - '(', 'P', ')', '=', 'P' | 0x80, - - ']', 'Q' | 0x80, ' ', '(', 'Q', ')', ' ', '=', - 'K', 'Y', 'U', 'W', '4' | 0x80, '(', 'Q', 'U', - 'A', 'R', ')', '=', 'K', 'W', 'O', 'H', - '5', 'R' | 0x80, '(', 'Q', 'U', ')', '=', 'K', - 'W' | 0x80, '(', 'Q', ')', '=', 'K' | 0x80, ']', 'R' | 0x80, - ' ', '(', 'R', ')', ' ', '=', 'A', 'A', - '5', 'R' | 0x80, ' ', '(', 'R', 'E', ')', '^', - '#', '=', 'R', 'I', 'Y' | 0x80, '(', 'R', ')', - 'R', '=' | 0x80, '(', 'R', ')', '=', 'R' | 0x80, - - ']', 'S' | 0x80, ' ', '(', 'S', ')', ' ', '=', - 'E', 'H', '4', 'S' | 0x80, '(', 'S', 'H', ')', - '=', 'S', 'H' | 0x80, '#', '(', 'S', 'I', 'O', - 'N', ')', '=', 'Z', 'H', 'U', 'N' | 0x80, '(', - 'S', 'O', 'M', 'E', ')', '=', 'S', 'A', - 'H', 'M' | 0x80, '#', '(', 'S', 'U', 'R', ')', - '#', '=', 'Z', 'H', 'E', 'R' | 0x80, '(', 'S', - 'U', 'R', ')', '#', '=', 'S', 'H', 'E', - 'R' | 0x80, '#', '(', 'S', 'U', ')', '#', '=', - 'Z', 'H', 'U', 'W' | 0x80, '#', '(', 'S', 'S', - 'U', ')', '#', '=', 'S', 'H', 'U', 'W' | 0x80, - '#', '(', 'S', 'E', 'D', ')', '=', 'Z', - 'D' | 0x80, '#', '(', 'S', ')', '#', '=', 'Z' | 0x80, - '(', 'S', 'A', 'I', 'D', ')', '=', 'S', - 'E', 'H', 'D' | 0x80, '^', '(', 'S', 'I', 'O', - 'N', ')', '=', 'S', 'H', 'U', 'N' | 0x80, '(', - 'S', ')', 'S', '=' | 0x80, '.', '(', 'S', ')', - ' ', '=', 'Z' | 0x80, '#', ':', '.', 'E', '(', - 'S', ')', ' ', '=', 'Z' | 0x80, '#', ':', '^', - '#', '(', 'S', ')', ' ', '=', 'S' | 0x80, 'U', - '(', 'S', ')', ' ', '=', 'S' | 0x80, ' ', ':', - '#', '(', 'S', ')', ' ', '=', 'Z' | 0x80, '#', - '#', '(', 'S', ')', ' ', '=', 'Z' | 0x80, ' ', - '(', 'S', 'C', 'H', ')', '=', 'S', 'K' | 0x80, - '(', 'S', ')', 'C', '+', '=' | 0x80, '#', '(', - 'S', 'M', ')', '=', 'Z', 'U', 'M' | 0x80, '#', - '(', 'S', 'N', ')', '\'', '=', 'Z', 'U', - 'M' | 0x80, '(', 'S', 'T', 'L', 'E', ')', '=', - 'S', 'U', 'L' | 0x80, '(', 'S', ')', '=', 'S' | 0x80, - - ']', 'T' | 0x80, ' ', '(', 'T', ')', ' ', '=', - 'T', 'I', 'Y', '4' | 0x80, ' ', '(', 'T', 'H', - 'E', ')', ' ', '#', '=', 'D', 'H', 'I', - 'Y' | 0x80, ' ', '(', 'T', 'H', 'E', ')', ' ', - '=', 'D', 'H', 'A', 'X' | 0x80, '(', 'T', 'O', - ')', ' ', '=', 'T', 'U', 'X' | 0x80, ' ', '(', - 'T', 'H', 'A', 'T', ')', '=', 'D', 'H', - 'A', 'E', 'T' | 0x80, ' ', '(', 'T', 'H', 'I', - 'S', ')', ' ', '=', 'D', 'H', 'I', 'H', - 'S' | 0x80, ' ', '(', 'T', 'H', 'E', 'Y', ')', - '=', 'D', 'H', 'E', 'Y' | 0x80, ' ', '(', 'T', - 'H', 'E', 'R', 'E', ')', '=', 'D', 'H', - 'E', 'H', 'R' | 0x80, '(', 'T', 'H', 'E', 'R', - ')', '=', 'D', 'H', 'E', 'R' | 0x80, '(', 'T', - 'H', 'E', 'I', 'R', ')', '=', 'D', 'H', - 'E', 'H', 'R' | 0x80, ' ', '(', 'T', 'H', 'A', - 'N', ')', ' ', '=', 'D', 'H', 'A', 'E', - 'N' | 0x80, ' ', '(', 'T', 'H', 'E', 'M', ')', - ' ', '=', 'D', 'H', 'A', 'E', 'N' | 0x80, '(', - 'T', 'H', 'E', 'S', 'E', ')', ' ', '=', - 'D', 'H', 'I', 'Y', 'Z' | 0x80, ' ', '(', 'T', - 'H', 'E', 'N', ')', '=', 'D', 'H', 'E', - 'H', 'N' | 0x80, '(', 'T', 'H', 'R', 'O', 'U', - 'G', 'H', ')', '=', 'T', 'H', 'R', 'U', - 'W', '4' | 0x80, '(', 'T', 'H', 'O', 'S', 'E', - ')', '=', 'D', 'H', 'O', 'H', 'Z' | 0x80, '(', - 'T', 'H', 'O', 'U', 'G', 'H', ')', ' ', - '=', 'D', 'H', 'O', 'W' | 0x80, '(', 'T', 'O', - 'D', 'A', 'Y', ')', '=', 'T', 'U', 'X', - 'D', 'E', 'Y' | 0x80, '(', 'T', 'O', 'M', 'O', - ')', 'R', 'R', 'O', 'W', '=', 'T', 'U', - 'M', 'A', 'A', '5' | 0x80, '(', 'T', 'O', ')', - 'T', 'A', 'L', '=', 'T', 'O', 'W', '5' | 0x80, - ' ', '(', 'T', 'H', 'U', 'S', ')', '=', - 'D', 'H', 'A', 'H', '4', 'S' | 0x80, '(', 'T', - 'H', ')', '=', 'T', 'H' | 0x80, '#', ':', '(', - 'T', 'E', 'D', ')', '=', 'T', 'I', 'X', - 'D' | 0x80, 'S', '(', 'T', 'I', ')', '#', 'N', - '=', 'C', 'H' | 0x80, '(', 'T', 'I', ')', 'O', - '=', 'S', 'H' | 0x80, '(', 'T', 'I', ')', 'A', - '=', 'S', 'H' | 0x80, '(', 'T', 'I', 'E', 'N', - ')', '=', 'S', 'H', 'U', 'N' | 0x80, '(', 'T', - 'U', 'R', ')', '#', '=', 'C', 'H', 'E', - 'R' | 0x80, '(', 'T', 'U', ')', 'A', '=', 'C', - 'H', 'U', 'W' | 0x80, ' ', '(', 'T', 'W', 'O', - ')', '=', 'T', 'U', 'W' | 0x80, '&', '(', 'T', - ')', 'E', 'N', ' ', '=' | 0x80, '(', 'T', ')', - '=', 'T' | 0x80, - - ']', 'U' | 0x80, ' ', '(', 'U', ')', ' ', '=', - 'Y', 'U', 'W', '4' | 0x80, ' ', '(', 'U', 'N', - ')', 'I', '=', 'Y', 'U', 'W', 'N' | 0x80, ' ', - '(', 'U', 'N', ')', '=', 'A', 'H', 'N' | 0x80, - ' ', '(', 'U', 'P', 'O', 'N', ')', '=', - 'A', 'X', 'P', 'A', 'O', 'N' | 0x80, '@', '(', - 'U', 'R', ')', '#', '=', 'U', 'H', '4', - 'R' | 0x80, '(', 'U', 'R', ')', '#', '=', 'Y', - 'U', 'H', '4', 'R' | 0x80, '(', 'U', 'R', ')', - '=', 'E', 'R' | 0x80, '(', 'U', ')', '^', ' ', - '=', 'A', 'H' | 0x80, '(', 'U', ')', '^', '^', - '=', 'A', 'H', '5' | 0x80, '(', 'U', 'Y', ')', - '=', 'A', 'Y', '5' | 0x80, ' ', 'G', '(', 'U', - ')', '#', '=' | 0x80, 'G', '(', 'U', ')', '%', - '=' | 0x80, 'G', '(', 'U', ')', '#', '=', 'W' | 0x80, - '#', 'N', '(', 'U', ')', '=', 'Y', 'U', - 'W' | 0x80, '@', '(', 'U', ')', '=', 'U', 'W' | 0x80, - '(', 'U', ')', '=', 'Y', 'U', 'W' | 0x80, - - ']', 'V' | 0x80, ' ', '(', 'V', ')', ' ', '=', - 'V', 'I', 'Y', '4' | 0x80, '(', 'V', 'I', 'E', - 'W', ')', '=', 'V', 'Y', 'U', 'W', '5' | 0x80, - '(', 'V', ')', '=', 'V' | 0x80, - - ']', 'W' | 0x80, ' ', '(', 'W', ')', ' ', '=', - 'D', 'A', 'H', '4', 'B', 'U', 'L', 'Y', - 'U', 'W' | 0x80, ' ', '(', 'W', 'E', 'R', 'E', - ')', '=', 'W', 'E', 'R' | 0x80, '(', 'W', 'A', - ')', 'S', 'H', '=', 'W', 'A', 'A' | 0x80, '(', - 'W', 'A', ')', 'S', 'T', '=', 'W', 'E', - 'Y' | 0x80, '(', 'W', 'A', ')', 'S', '=', 'W', - 'A', 'H' | 0x80, '(', 'W', 'A', ')', 'T', '=', - 'W', 'A', 'A' | 0x80, '(', 'W', 'H', 'E', 'R', - 'E', ')', '=', 'W', 'H', 'E', 'H', 'R' | 0x80, - '(', 'W', 'H', 'A', 'T', ')', '=', 'W', - 'H', 'A', 'H', 'T' | 0x80, '(', 'W', 'H', 'O', - 'L', ')', '=', '/', 'H', 'O', 'W', 'L' | 0x80, - '(', 'W', 'H', 'O', ')', '=', '/', 'H', - 'U', 'W' | 0x80, '(', 'W', 'H', ')', '=', 'W', - 'H' | 0x80, '(', 'W', 'A', 'R', ')', '#', '=', - 'W', 'E', 'H', 'R' | 0x80, '(', 'W', 'A', 'R', - ')', '=', 'W', 'A', 'O', 'R' | 0x80, '(', 'W', - 'O', 'R', ')', '^', '=', 'W', 'E', 'R' | 0x80, - '(', 'W', 'R', ')', '=', 'R' | 0x80, '(', 'W', - 'O', 'M', ')', 'A', '=', 'W', 'U', 'H', - 'M' | 0x80, '(', 'W', 'O', 'M', ')', 'E', '=', - 'W', 'I', 'H', 'M' | 0x80, '(', 'W', 'E', 'A', - ')', 'R', '=', 'W', 'E', 'H' | 0x80, '(', 'W', - 'A', 'N', 'T', ')', '=', 'W', 'A', 'A', - '5', 'N', 'T' | 0x80, 'A', 'N', 'S', '(', 'W', - 'E', 'R', ')', '=', 'E', 'R' | 0x80, '(', 'W', - ')', '=', 'W' | 0x80, - - ']', 'X' | 0x80, ' ', '(', 'X', ')', ' ', '=', - 'E', 'H', '4', 'K', 'R' | 0x80, ' ', '(', 'X', - ')', '=', 'Z' | 0x80, '(', 'X', ')', '=', 'K', - 'S' | 0x80, - - ']', 'Y' | 0x80, ' ', '(', 'Y', ')', ' ', '=', - 'W', 'A', 'Y', '4' | 0x80, '(', 'Y', 'O', 'U', - 'N', 'G', ')', '=', 'Y', 'A', 'H', 'N', - 'X' | 0x80, ' ', '(', 'Y', 'O', 'U', 'R', ')', - '=', 'Y', 'O', 'H', 'R' | 0x80, ' ', '(', 'Y', - 'O', 'U', ')', '=', 'Y', 'U', 'W' | 0x80, ' ', - '(', 'Y', 'E', 'S', ')', '=', 'Y', 'E', - 'H', 'S' | 0x80, ' ', '(', 'Y', ')', '=', 'Y' | 0x80, - 'F', '(', 'Y', ')', '=', 'A', 'Y' | 0x80, 'P', - 'S', '(', 'Y', 'C', 'H', ')', '=', 'A', - 'Y', 'K' | 0x80, '#', ':', '^', '(', 'Y', ')', - '=', 'I', 'Y' | 0x80, '#', ':', '^', '(', 'Y', - ')', 'I', '=', 'I', 'Y' | 0x80, ' ', ':', '(', - 'Y', ')', ' ', '=', 'A', 'Y' | 0x80, ' ', ':', - '(', 'Y', ')', '#', '=', 'A', 'Y' | 0x80, ' ', - ':', '(', 'Y', ')', '^', '+', ':', '#', - '=', 'I', 'H' | 0x80, ' ', ':', '(', 'Y', ')', - '^', '#', '=', 'A', 'Y' | 0x80, '(', 'Y', ')', - '=', 'I', 'H' | 0x80, - - ']', 'Z' | 0x80, ' ', '(', 'Z', ')', ' ', '=', - 'Z', 'I', 'Y', '4' | 0x80, '(', 'Z', ')', '=', - 'Z' | 0x80, 'j' | 0x80}; - -const unsigned char rules2[] = { - '(', 'A', ')', '=' | 0x80, '(', '!', ')', '=', - '.' | 0x80, '(', '"', ')', ' ', '=', '-', 'A', - 'H', '5', 'N', 'K', 'W', 'O', 'W', 'T', - '-' | 0x80, '(', '"', ')', '=', 'K', 'W', 'O', - 'W', '4', 'T', '-' | 0x80, '(', '#', ')', '=', - ' ', 'N', 'A', 'H', '4', 'M', 'B', 'E', - 'R' | 0x80, '(', '$', ')', '=', ' ', 'D', 'A', - 'A', '4', 'L', 'E', 'R' | 0x80, '(', '%', ')', - '=', ' ', 'P', 'E', 'R', 'S', 'E', 'H', - '4', 'N', 'T' | 0x80, '(', '&', ')', '=', ' ', - 'A', 'E', 'N', 'D' | 0x80, '(', '\'', ')', '=' | 0x80, - '(', '*', ')', '=', ' ', 'A', 'E', '4', - 'S', 'T', 'E', 'R', 'I', 'H', 'S', 'K' | 0x80, - '(', '+', ')', '=', ' ', 'P', 'L', 'A', - 'H', '4', 'S' | 0x80, '(', ',', ')', '=', ',' | 0x80, - ' ', '(', '-', ')', ' ', '=', '-' | 0x80, '(', - '-', ')', '=' | 0x80, '(', '.', ')', '=', ' ', - 'P', 'O', 'Y', 'N', 'T' | 0x80, '(', '/', ')', - '=', ' ', 'S', 'L', 'A', 'E', '4', 'S', - 'H' | 0x80, '(', '0', ')', '=', ' ', 'Z', 'I', - 'Y', '4', 'R', 'O', 'W' | 0x80, ' ', '(', '1', - 'S', 'T', ')', '=', 'F', 'E', 'R', '4', - 'S', 'T' | 0x80, ' ', '(', '1', '0', 'T', 'H', - ')', '=', 'T', 'E', 'H', '4', 'N', 'T', - 'H' | 0x80, '(', '1', ')', '=', ' ', 'W', 'A', - 'H', '4', 'N' | 0x80, ' ', '(', '2', 'N', 'D', - ')', '=', 'S', 'E', 'H', '4', 'K', 'U', - 'N', 'D' | 0x80, '(', '2', ')', '=', ' ', 'T', - 'U', 'W', '4' | 0x80, ' ', '(', '3', 'R', 'D', - ')', '=', 'T', 'H', 'E', 'R', '4', 'D' | 0x80, - '(', '3', ')', '=', ' ', 'T', 'H', 'R', - 'I', 'Y', '4' | 0x80, '(', '4', ')', '=', ' ', - 'F', 'O', 'H', '4', 'R' | 0x80, ' ', '(', '5', - 'T', 'H', ')', '=', 'F', 'I', 'H', '4', - 'F', 'T', 'H' | 0x80, '(', '5', ')', '=', ' ', - 'F', 'A', 'Y', '4', 'V' | 0x80, ' ', '(', '6', - '4', ')', ' ', '=', 'S', 'I', 'H', '4', - 'K', 'S', 'T', 'I', 'Y', ' ', 'F', 'O', - 'H', 'R' | 0x80, '(', '6', ')', '=', ' ', 'S', - 'I', 'H', '4', 'K', 'S' | 0x80, '(', '7', ')', - '=', ' ', 'S', 'E', 'H', '4', 'V', 'U', - 'N' | 0x80, ' ', '(', '8', 'T', 'H', ')', '=', - 'E', 'Y', '4', 'T', 'H' | 0x80, '(', '8', ')', - '=', ' ', 'E', 'Y', '4', 'T' | 0x80, '(', '9', - ')', '=', ' ', 'N', 'A', 'Y', '4', 'N' | 0x80, - '(', ':', ')', '=', '.' | 0x80, '(', ';', ')', - '=', '.' | 0x80, '(', '<', ')', '=', ' ', 'L', - 'E', 'H', '4', 'S', ' ', 'D', 'H', 'A', - 'E', 'N' | 0x80, '(', '=', ')', '=', ' ', 'I', - 'Y', '4', 'K', 'W', 'U', 'L', 'Z' | 0x80, '(', - '>', ')', '=', ' ', 'G', 'R', 'E', 'Y', - '4', 'T', 'E', 'R', ' ', 'D', 'H', 'A', - 'E', 'N' | 0x80, '(', '?', ')', '=', '?' | 0x80, '(', - '@', ')', '=', ' ', 'A', 'E', '6', 'T' | 0x80, - '(', '^', ')', '=', ' ', 'K', 'A', 'E', - '4', 'R', 'I', 'X', 'T' | 0x80, ']', 'A' | 0x80}; - -//26 items. From 'A' to 'Z' -// positions for mem62 and mem63 for each character -const unsigned char tab37489[] = {0, 149, 247, 162, 57, 197, 6, 126, 199, 38, 55, 78, 145, - 241, 85, 161, 254, 36, 69, 45, 167, 54, 83, 46, 71, 218}; - -const unsigned char tab37515[] = {125, 126, 126, 127, 128, 129, 130, 130, 130, 132, 132, 132, 132, - 132, 133, 135, 135, 136, 136, 137, 138, 139, 139, 140, 140, 140}; - -void STM32SAM::Output8BitAry(int index, unsigned char ary[5]) { - int k; - - uint32_t bufferposOld = bufferpos; - - bufferpos += timetable[oldtimetableindex][index]; - oldtimetableindex = index; - - int sample_uS = bufferpos - bufferposOld; - - uint32_t f = 0; - - // write a little bit in advance - for(k = 0; k < 5; k++) { - // buffer[bufferpos / 50 + k] = ary[k]; - - // f = micros() + sample_uS / (_STM32SAM_SPEED + 1); - // while(micros() < f) { - // }; - f = sample_uS / (_STM32SAM_SPEED + 1); - furi_delay_us(f); - SetAUDIO(ary[k]); - // delayMicroseconds(sample_uS / 5 ); - } - - // SetAUDIO(ary[0]); -} - -void STM32SAM::Output8Bit(int index, unsigned char A) { - unsigned char ary[5] = {A, A, A, A, A}; - Output8BitAry(index, ary); -} - -//written by me because of different table positions. -// mem[47] = ... -// 168=pitches -// 169=frequency1 -// 170=frequency2 -// 171=frequency3 -// 172=amplitude1 -// 173=amplitude2 -// 174=amplitude3 -unsigned char STM32SAM::Read(unsigned char p, unsigned char Y) { - switch(p) { - case 168: - return pitches[Y]; - case 169: - return frequency1[Y]; - case 170: - return frequency2[Y]; - case 171: - return frequency3[Y]; - case 172: - return amplitude1[Y]; - case 173: - return amplitude2[Y]; - case 174: - return amplitude3[Y]; - } - // Serial1.println("Error reading to tables"); - return 0; -} - -void STM32SAM::Write(unsigned char p, unsigned char Y, unsigned char value) { - switch(p) { - case 168: - pitches[Y] = value; - return; - case 169: - frequency1[Y] = value; - return; - case 170: - frequency2[Y] = value; - return; - case 171: - frequency3[Y] = value; - return; - case 172: - amplitude1[Y] = value; - return; - case 173: - amplitude2[Y] = value; - return; - case 174: - amplitude3[Y] = value; - return; - } - //Serial1.println("Error writing to tables\n"); -} - -// ------------------------------------------------------------------------- -//Code48227 -// Render a sampled sound from the sampleTable. -// -// Phoneme Sample Start Sample End -// 32: S* 15 255 -// 33: SH 257 511 -// 34: F* 559 767 -// 35: TH 583 767 -// 36: /H 903 1023 -// 37: /X 1135 1279 -// 38: Z* 84 119 -// 39: ZH 340 375 -// 40: V* 596 639 -// 41: DH 596 631 -// -// 42: CH -// 43: ** 399 511 -// -// 44: J* -// 45: ** 257 276 -// 46: ** -// -// 66: P* -// 67: ** 743 767 -// 68: ** -// -// 69: T* -// 70: ** 231 255 -// 71: ** -// -// The SampledPhonemesTable[] holds flags indicating if a phoneme is -// voiced or not. If the upper 5 bits are zero, the sample is voiced. -// -// Samples in the sampleTable are compressed, with bits being converted to -// bytes from high bit to low, as follows: -// -// unvoiced 0 bit -> X -// unvoiced 1 bit -> 5 -// -// voiced 0 bit -> 6 -// voiced 1 bit -> 24 -// -// Where X is a value from the table: -// -// { 0x18, 0x1A, 0x17, 0x17, 0x17 }; -// -// The index into this table is determined by masking off the lower -// 3 bits from the SampledPhonemesTable: -// -// index = (SampledPhonemesTable[i] & 7) - 1; -// -// For voices samples, samples are interleaved between voiced output. - -// Code48227() -void STM32SAM::RenderSample(unsigned char* mem66) { - int tempA; - // current phoneme's index - mem49 = Y; - - // mask low three bits and subtract 1 get value to - // convert 0 bits on unvoiced samples. - A = mem39 & 7; - X = A - 1; - - // store the result - mem56 = X; - - // determine which offset to use from table { 0x18, 0x1A, 0x17, 0x17, 0x17 } - // T, S, Z 0 0x18 - // CH, J, SH, ZH 1 0x1A - // P, F*, V, TH, DH 2 0x17 - // /H 3 0x17 - // /X 4 0x17 - - // get value from the table - mem53 = tab48426[X]; - mem47 = X; //46016+mem[56]*256 - - // voiced sample? - A = mem39 & 248; - if(A == 0) { - // voiced phoneme: Z*, ZH, V*, DH - Y = mem49; - A = pitches[mem49] >> 4; - - // jump to voiced portion - goto pos48315; - } - - Y = A ^ 255; -pos48274: - - // step through the 8 bits in the sample - mem56 = 8; - - // get the next sample from the table - // mem47*256 = offset to start of samples - A = sampleTable[mem47 * 256 + Y]; -pos48280: - - // left shift to get the high bit - tempA = A; - A = A << 1; - //48281: BCC 48290 - - // bit not set? - if((tempA & 128) == 0) { - // convert the bit to value from table - X = mem53; - //mem[54296] = X; - // output the byte - Output8Bit(1, (X & 0x0f) * 16); - // if X != 0, exit loop - if(X != 0) goto pos48296; - } - - // output a 5 for the on bit - Output8Bit(2, 5 * 16); - - //48295: NOP -pos48296: - - X = 0; - - // decrement counter - mem56--; - - // if not done, jump to top of loop - if(mem56 != 0) goto pos48280; - - // increment position - Y++; - if(Y != 0) goto pos48274; - - // restore values and return - mem44 = 1; - Y = mem49; - return; - - unsigned char phase1; - -pos48315: - // handle voiced samples here - - // number of samples? - phase1 = A ^ 255; - - Y = *mem66; - do { - //pos48321: - - // shift through all 8 bits - mem56 = 8; - //A = Read(mem47, Y); - - // fetch value from table - A = sampleTable[mem47 * 256 + Y]; - - // loop 8 times - //pos48327: - do { - //48327: ASL A - //48328: BCC 48337 - - // left shift and check high bit - tempA = A; - A = A << 1; - if((tempA & 128) != 0) { - // if bit set, output 26 - X = 26; - Output8Bit(3, (X & 0xf) * 16); - } else { - //timetable 4 - // bit is not set, output a 6 - X = 6; - Output8Bit(4, (X & 0xf) * 16); - } - - mem56--; - } while(mem56 != 0); - - // move ahead in the table - Y++; - - // continue until counter done - phase1++; - - } while(phase1 != 0); - // if (phase1 != 0) goto pos48321; - - // restore values and return - A = 1; - mem44 = 1; - *mem66 = Y; - Y = mem49; - return; -} - -// RENDER THE PHONEMES IN THE LIST -// -// The phoneme list is converted into sound through the steps: -// -// 1. Copy each phoneme number of times into the frames list, -// where each frame represents 10 milliseconds of sound. -// -// 2. Determine the transitions lengths between phonemes, and linearly -// interpolate the values across the frames. -// -// 3. Offset the pitches by the fundamental frequency. -// -// 4. Render the each frame. - -//void Code47574() -void STM32SAM::Render() { - unsigned char phase1 = 0; //mem43 - unsigned char phase2 = 0; - unsigned char phase3 = 0; - unsigned char mem66 = 0; - unsigned char mem38 = 0; - unsigned char mem40 = 0; - unsigned char speedcounter = 0; //mem45 - unsigned char mem48 = 0; - int i; - if(phonemeIndexOutput[0] == 255) return; //exit if no data - - A = 0; - X = 0; - mem44 = 0; - - // CREATE FRAMES - // - // The length parameter in the list corresponds to the number of frames - // to expand the phoneme to. Each frame represents 10 milliseconds of time. - // So a phoneme with a length of 7 = 7 frames = 70 milliseconds duration. - // - // The parameters are copied from the phoneme to the frame verbatim. - - // pos47587: - do { - // get the index - Y = mem44; - // get the phoneme at the index - A = phonemeIndexOutput[mem44]; - mem56 = A; - - // if terminal phoneme, exit the loop - if(A == 255) break; - - // period phoneme *. - if(A == 1) { - // add rising inflection - A = 1; - mem48 = 1; - //goto pos48376; - AddInflection(mem48, phase1); - } - /* - if (A == 2) goto pos48372; - */ - - // question mark phoneme? - if(A == 2) { - // create falling inflection - mem48 = 255; - AddInflection(mem48, phase1); - } - // pos47615: - - // get the stress amount (more stress = higher pitch) - phase1 = tab47492[stressOutput[Y] + 1]; - - // get number of frames to write - phase2 = phonemeLengthOutput[Y]; - Y = mem56; - - // copy from the source to the frames list - do { - frequency1[X] = freq1data[Y]; // F1 frequency - frequency2[X] = freq2data[Y]; // F2 frequency - frequency3[X] = freq3data[Y]; // F3 frequency - amplitude1[X] = ampl1data[Y]; // F1 amplitude - amplitude2[X] = ampl2data[Y]; // F2 amplitude - amplitude3[X] = ampl3data[Y]; // F3 amplitude - sampledConsonantFlag[X] = - sampledConsonantFlags[Y]; // phoneme data for sampled consonants - pitches[X] = pitch + phase1; // pitch - X++; - phase2--; - } while(phase2 != 0); - mem44++; - } while(mem44 != 0); - // ------------------- - //pos47694: - - // CREATE TRANSITIONS - // - // Linear transitions are now created to smoothly connect the - // end of one sustained portion of a phoneme to the following - // phoneme. - // - // To do this, three tables are used: - // - // Table Purpose - // ========= ================================================== - // blendRank Determines which phoneme's blend values are used. - // - // blendOut The number of frames at the end of the phoneme that - // will be used to transition to the following phoneme. - // - // blendIn The number of frames of the following phoneme that - // will be used to transition into that phoneme. - // - // In creating a transition between two phonemes, the phoneme - // with the HIGHEST rank is used. Phonemes are ranked on how much - // their identity is based on their transitions. For example, - // vowels are and diphthongs are identified by their sustained portion, - // rather than the transitions, so they are given low values. In contrast, - // stop consonants (P, B, T, K) and glides (Y, L) are almost entirely - // defined by their transitions, and are given high rank values. - // - // Here are the rankings used by SAM: - // - // Rank Type Phonemes - // 2 All vowels IY, IH, etc. - // 5 Diphthong endings YX, WX, ER - // 8 Terminal liquid consonants LX, WX, YX, N, NX - // 9 Liquid consonants L, RX, W - // 10 Glide R, OH - // 11 Glide WH - // 18 Voiceless fricatives S, SH, F, TH - // 20 Voiced fricatives Z, ZH, V, DH - // 23 Plosives, stop consonants P, T, K, KX, DX, CH - // 26 Stop consonants J, GX, B, D, G - // 27-29 Stop consonants (internal) ** - // 30 Unvoiced consonants /H, /X and Q* - // 160 Nasal M - // - // To determine how many frames to use, the two phonemes are - // compared using the blendRank[] table. The phoneme with the - // higher rank is selected. In case of a tie, a blend of each is used: - // - // if blendRank[phoneme1] == blendRank[phomneme2] - // // use lengths from each phoneme - // outBlendFrames = outBlend[phoneme1] - // inBlendFrames = outBlend[phoneme2] - // else if blendRank[phoneme1] > blendRank[phoneme2] - // // use lengths from first phoneme - // outBlendFrames = outBlendLength[phoneme1] - // inBlendFrames = inBlendLength[phoneme1] - // else - // // use lengths from the second phoneme - // // note that in and out are SWAPPED! - // outBlendFrames = inBlendLength[phoneme2] - // inBlendFrames = outBlendLength[phoneme2] - // - // Blend lengths can't be less than zero. - // - // Transitions are assumed to be symetrical, so if the transition - // values for the second phoneme are used, the inBlendLength and - // outBlendLength values are SWAPPED. - // - // For most of the parameters, SAM interpolates over the range of the last - // outBlendFrames-1 and the first inBlendFrames. - // - // The exception to this is the Pitch[] parameter, which is interpolates the - // pitch from the CENTER of the current phoneme to the CENTER of the next - // phoneme. - // - // Here are two examples. First, For example, consider the word "SUN" (S AH N) - // - // Phoneme Duration BlendWeight OutBlendFrames InBlendFrames - // S 2 18 1 3 - // AH 8 2 4 4 - // N 7 8 1 2 - // - // The formant transitions for the output frames are calculated as follows: - // - // flags ampl1 freq1 ampl2 freq2 ampl3 freq3 pitch - // ------------------------------------------------ - // S - // 241 0 6 0 73 0 99 61 Use S (weight 18) for transition instead of AH (weight 2) - // 241 0 6 0 73 0 99 61 <-- (OutBlendFrames-1) = (1-1) = 0 frames - // AH - // 0 2 10 2 66 0 96 59 * <-- InBlendFrames = 3 frames - // 0 4 14 3 59 0 93 57 * - // 0 8 18 5 52 0 90 55 * - // 0 15 22 9 44 1 87 53 - // 0 15 22 9 44 1 87 53 - // 0 15 22 9 44 1 87 53 Use N (weight 8) for transition instead of AH (weight 2). - // 0 15 22 9 44 1 87 53 Since N is second phoneme, reverse the IN and OUT values. - // 0 11 17 8 47 1 98 56 * <-- (InBlendFrames-1) = (2-1) = 1 frames - // N - // 0 8 12 6 50 1 109 58 * <-- OutBlendFrames = 1 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // - // Now, consider the reverse "NUS" (N AH S): - // - // flags ampl1 freq1 ampl2 freq2 ampl3 freq3 pitch - // ------------------------------------------------ - // N - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 - // 0 5 6 5 54 0 121 61 Use N (weight 8) for transition instead of AH (weight 2) - // 0 5 6 5 54 0 121 61 <-- (OutBlendFrames-1) = (1-1) = 0 frames - // AH - // 0 8 11 6 51 0 110 59 * <-- InBlendFrames = 2 - // 0 11 16 8 48 0 99 56 * - // 0 15 22 9 44 1 87 53 Use S (weight 18) for transition instead of AH (weight 2) - // 0 15 22 9 44 1 87 53 Since S is second phoneme, reverse the IN and OUT values. - // 0 9 18 5 51 1 90 55 * <-- (InBlendFrames-1) = (3-1) = 2 - // 0 4 14 3 58 1 93 57 * - // S - // 241 2 10 2 65 1 96 59 * <-- OutBlendFrames = 1 - // 241 0 6 0 73 0 99 61 - - A = 0; - mem44 = 0; - mem49 = 0; // mem49 starts at as 0 - X = 0; - while(1) //while No. 1 - { - // get the current and following phoneme - Y = phonemeIndexOutput[X]; - A = phonemeIndexOutput[X + 1]; - X++; - - // exit loop at end token - if(A == 255) break; //goto pos47970; - - // get the ranking of each phoneme - X = A; - mem56 = blendRank[A]; - A = blendRank[Y]; - - // compare the rank - lower rank value is stronger - if(A == mem56) { - // same rank, so use out blend lengths from each phoneme - phase1 = outBlendLength[Y]; - phase2 = outBlendLength[X]; - } else if(A < mem56) { - // first phoneme is stronger, so us it's blend lengths - phase1 = inBlendLength[X]; - phase2 = outBlendLength[X]; - } else { - // second phoneme is stronger, so use it's blend lengths - // note the out/in are swapped - phase1 = outBlendLength[Y]; - phase2 = inBlendLength[Y]; - } - - Y = mem44; - A = mem49 + phonemeLengthOutput[mem44]; // A is mem49 + length - mem49 = A; // mem49 now holds length + position - A = A + phase2; //Maybe Problem because of carry flag - - //47776: ADC 42 - speedcounter = A; - mem47 = 168; - phase3 = mem49 - phase1; // what is mem49 - A = phase1 + phase2; // total transition? - mem38 = A; - - X = A; - X -= 2; - if((X & 128) == 0) - do //while No. 2 - { - //pos47810: - - // mem47 is used to index the tables: - // 168 pitches[] - // 169 frequency1 - // 170 frequency2 - // 171 frequency3 - // 172 amplitude1 - // 173 amplitude2 - // 174 amplitude3 - - mem40 = mem38; - - if(mem47 == 168) // pitch - { - // unlike the other values, the pitches[] interpolates from - // the middle of the current phoneme to the middle of the - // next phoneme - - unsigned char mem36, mem37; - // half the width of the current phoneme - mem36 = phonemeLengthOutput[mem44] >> 1; - // half the width of the next phoneme - mem37 = phonemeLengthOutput[mem44 + 1] >> 1; - // sum the values - mem40 = mem36 + mem37; // length of both halves - mem37 += mem49; // center of next phoneme - mem36 = mem49 - mem36; // center index of current phoneme - A = Read( - mem47, mem37); // value at center of next phoneme - end interpolation value - //A = mem[address]; - - Y = mem36; // start index of interpolation - mem53 = A - Read(mem47, mem36); // value to center of current phoneme - } else { - // value to interpolate to - A = Read(mem47, speedcounter); - // position to start interpolation from - Y = phase3; - // value to interpolate from - mem53 = A - Read(mem47, phase3); - } - - //Code47503(mem40); - // ML : Code47503 is division with remainder, and mem50 gets the sign - - // calculate change per frame - signed char m53 = (signed char)mem53; - mem50 = mem53 & 128; - unsigned char m53abs = abs(m53); - mem51 = m53abs % mem40; //abs((char)m53) % mem40; - mem53 = (unsigned char)((signed char)(m53) / mem40); - - // interpolation range - X = mem40; // number of frames to interpolate over - Y = phase3; // starting frame - - // linearly interpolate values - - mem56 = 0; - //47907: CLC - //pos47908: - while(1) //while No. 3 - { - A = Read(mem47, Y) + mem53; //carry alway cleared - - mem48 = A; - Y++; - X--; - if(X == 0) break; - - mem56 += mem51; - if(mem56 >= mem40) //??? - { - mem56 -= mem40; //carry? is set - //if ((mem56 & 128)==0) - if((mem50 & 128) == 0) { - //47935: BIT 50 - //47937: BMI 47943 - if(mem48 != 0) mem48++; - } else - mem48--; - } - //pos47945: - Write(mem47, Y, mem48); - } //while No. 3 - - //pos47952: - mem47++; - //if (mem47 != 175) goto pos47810; - } while(mem47 != 175); //while No. 2 - //pos47963: - mem44++; - X = mem44; - } //while No. 1 - - //goto pos47701; - //pos47970: - - // add the length of this phoneme - mem48 = mem49 + phonemeLengthOutput[mem44]; - - // ASSIGN PITCH CONTOUR - // - // This subtracts the F1 frequency from the pitch to create a - // pitch contour. Without this, the output would be at a single - // pitch level (monotone). - - // don't adjust pitch if in sing mode - if(!singmode) { - // iterate through the buffer - for(i = 0; i < 256; i++) { - // subtract half the frequency of the formant 1. - // this adds variety to the voice - pitches[i] -= (frequency1[i] >> 1); - } - } - - phase1 = 0; - phase2 = 0; - phase3 = 0; - mem49 = 0; - speedcounter = 72; //sam standard speed - - // RESCALE AMPLITUDE - // - // Rescale volume from a linear scale to decibels. - // - - //amplitude rescaling - for(i = 255; i >= 0; i--) { - amplitude1[i] = amplitudeRescale[amplitude1[i]]; - amplitude2[i] = amplitudeRescale[amplitude2[i]]; - amplitude3[i] = amplitudeRescale[amplitude3[i]]; - } - - Y = 0; - A = pitches[0]; - mem44 = A; - X = A; - mem38 = A - (A >> 2); // 3/4*A ??? - - // PROCESS THE FRAMES - // - // In traditional vocal synthesis, the glottal pulse drives filters, which - // are attenuated to the frequencies of the formants. - // - // SAM generates these formants directly with sin and rectangular waves. - // To simulate them being driven by the glottal pulse, the waveforms are - // reset at the beginning of each glottal pulse. - - //finally the loop for sound output - //pos48078: - while(1) { - // get the sampled information on the phoneme - A = sampledConsonantFlag[Y]; - mem39 = A; - - // unvoiced sampled phoneme? - A = A & 248; - if(A != 0) { - // render the sample for the phoneme - RenderSample(&mem66); - - // skip ahead two in the phoneme buffer - Y += 2; - mem48 -= 2; - } else { - // simulate the glottal pulse and formants - unsigned char ary[5]; - unsigned int p1 = - phase1 * 256; // Fixed point integers because we need to divide later on - unsigned int p2 = phase2 * 256; - unsigned int p3 = phase3 * 256; - int k; - for(k = 0; k < 5; k++) { - signed char sp1 = (signed char)sinus[0xff & (p1 >> 8)]; - signed char sp2 = (signed char)sinus[0xff & (p2 >> 8)]; - signed char rp3 = (signed char)rectangle[0xff & (p3 >> 8)]; - signed int sin1 = sp1 * ((unsigned char)amplitude1[Y] & 0x0f); - signed int sin2 = sp2 * ((unsigned char)amplitude2[Y] & 0x0f); - signed int rect = rp3 * ((unsigned char)amplitude3[Y] & 0x0f); - signed int mux = sin1 + sin2 + rect; - mux /= 32; - mux += 128; // Go from signed to unsigned amplitude - ary[k] = mux; - p1 += frequency1[Y] * 256 / 4; // Compromise, this becomes a shift and works well - p2 += frequency2[Y] * 256 / 4; - p3 += frequency3[Y] * 256 / 4; - } - // output the accumulated value - Output8BitAry(0, ary); - speedcounter--; - if(speedcounter != 0) goto pos48155; - Y++; //go to next amplitude - - // decrement the frame count - mem48--; - } - - // if the frame count is zero, exit the loop - if(mem48 == 0) return; - speedcounter = speed; - pos48155: - - // decrement the remaining length of the glottal pulse - mem44--; - - // finished with a glottal pulse? - if(mem44 == 0) { - pos48159: - // fetch the next glottal pulse length - A = pitches[Y]; - mem44 = A; - A = A - (A >> 2); - mem38 = A; - - // reset the formant wave generators to keep them in - // sync with the glottal pulse - phase1 = 0; - phase2 = 0; - phase3 = 0; - continue; - } - - // decrement the count - mem38--; - - // is the count non-zero and the sampled flag is zero? - if((mem38 != 0) || (mem39 == 0)) { - // reset the phase of the formants to match the pulse - phase1 += frequency1[Y]; - phase2 += frequency2[Y]; - phase3 += frequency3[Y]; - continue; - } - - // voiced sampled phonemes interleave the sample with the - // glottal pulse. The sample flag is non-zero, so render - // the sample for the phoneme. - RenderSample(&mem66); - goto pos48159; - } //while - - // The following code is never reached. It's left over from when - // the voiced sample code was part of this loop, instead of part - // of RenderSample(); - - //pos48315: - int tempA; - phase1 = A ^ 255; - Y = mem66; - do { - //pos48321: - - mem56 = 8; - A = Read(mem47, Y); - - //pos48327: - do { - //48327: ASL A - //48328: BCC 48337 - tempA = A; - A = A << 1; - if((tempA & 128) != 0) { - X = 26; - // mem[54296] = X; - bufferpos += 150; - // - // - // buffer[bufferpos / 50] = (X & 15) * 16; - // - // - - } else { - //mem[54296] = 6; - X = 6; - bufferpos += 150; - // - // buffer[bufferpos / 50] = (X & 15) * 16; - // - // - } - - for(X = wait2; X > 0; X--) - ; //wait - mem56--; - } while(mem56 != 0); - - Y++; - phase1++; - - } while(phase1 != 0); - // if (phase1 != 0) goto pos48321; - A = 1; - mem44 = 1; - mem66 = Y; - Y = mem49; - return; -} - -// Create a rising or falling inflection 30 frames prior to -// index X. A rising inflection is used for questions, and -// a falling inflection is used for statements. - -void STM32SAM::AddInflection(unsigned char mem48, unsigned char phase1) { - //pos48372: - // mem48 = 255; - //pos48376: - - // store the location of the punctuation - mem49 = X; - A = X; - int Atemp = A; - - // backup 30 frames - A = A - 30; - // if index is before buffer, point to start of buffer - if(Atemp <= 30) A = 0; - X = A; - - // FIXME: Explain this fix better, it's not obvious - // ML : A =, fixes a problem with invalid pitch with '.' - while((A = pitches[X]) == 127) X++; - -pos48398: - //48398: CLC - //48399: ADC 48 - - // add the inflection direction - A += mem48; - phase1 = A; - - // set the inflection - pitches[X] = A; -pos48406: - - // increment the position - X++; - - // exit if the punctuation has been reached - if(X == mem49) return; //goto pos47615; - if(pitches[X] == 255) goto pos48406; - A = phase1; - goto pos48398; -} - -/* - SAM's voice can be altered by changing the frequencies of the - mouth formant (F1) and the throat formant (F2). Only the voiced - phonemes (5-29 and 48-53) are altered. -*/ -void STM32SAM::SetMouthThroat() { - unsigned char initialFrequency; - unsigned char newFrequency = 0; - //unsigned char mouth; //mem38880 - //unsigned char throat; //mem38881 - - // mouth formants (F1) 5..29 - unsigned char mouthFormants5_29[30] = {0, 0, 0, 0, 0, 10, 14, 19, 24, 27, - 23, 21, 16, 20, 14, 18, 14, 18, 18, 16, - 13, 15, 11, 18, 14, 11, 9, 6, 6, 6}; - - // throat formants (F2) 5..29 - unsigned char throatFormants5_29[30] = {255, 255, 255, 255, 255, 84, 73, 67, 63, 40, - 44, 31, 37, 45, 73, 49, 36, 30, 51, 37, - 29, 69, 24, 50, 30, 24, 83, 46, 54, 86}; - - // there must be no zeros in this 2 tables - // formant 1 frequencies (mouth) 48..53 - unsigned char mouthFormants48_53[6] = {19, 27, 21, 27, 18, 13}; - - // formant 2 frequencies (throat) 48..53 - unsigned char throatFormants48_53[6] = {72, 39, 31, 43, 30, 34}; - - unsigned char pos = 5; //mem39216 - //pos38942: - // recalculate formant frequencies 5..29 for the mouth (F1) and throat (F2) - while(pos != 30) { - // recalculate mouth frequency - initialFrequency = mouthFormants5_29[pos]; - if(initialFrequency != 0) newFrequency = trans(mouth, initialFrequency); - freq1data[pos] = newFrequency; - - // recalculate throat frequency - initialFrequency = throatFormants5_29[pos]; - if(initialFrequency != 0) newFrequency = trans(throat, initialFrequency); - freq2data[pos] = newFrequency; - pos++; - } - - //pos39059: - // recalculate formant frequencies 48..53 - pos = 48; - Y = 0; - while(pos != 54) { - // recalculate F1 (mouth formant) - initialFrequency = mouthFormants48_53[Y]; - newFrequency = trans(mouth, initialFrequency); - freq1data[pos] = newFrequency; - - // recalculate F2 (throat formant) - initialFrequency = throatFormants48_53[Y]; - newFrequency = trans(throat, initialFrequency); - freq2data[pos] = newFrequency; - Y++; - pos++; - } -} - -//return = (mem39212*mem39213) >> 1 -unsigned char STM32SAM::trans(unsigned char mem39212, unsigned char mem39213) { - //pos39008: - unsigned char carry; - int temp; - unsigned char mem39214, mem39215; - A = 0; - mem39215 = 0; - mem39214 = 0; - X = 8; - do { - carry = mem39212 & 1; - mem39212 = mem39212 >> 1; - if(carry != 0) { - /* - 39018: LSR 39212 - 39021: BCC 39033 - */ - carry = 0; - A = mem39215; - temp = (int)A + (int)mem39213; - A = A + mem39213; - if(temp > 255) carry = 1; - mem39215 = A; - } - temp = mem39215 & 1; - mem39215 = (mem39215 >> 1) | (carry ? 128 : 0); - carry = temp; - //39033: ROR 39215 - X--; - } while(X != 0); - temp = mem39214 & 128; - mem39214 = (mem39214 << 1) | (carry ? 1 : 0); - carry = temp; - temp = mem39215 & 128; - mem39215 = (mem39215 << 1) | (carry ? 1 : 0); - carry = temp; - - return mem39215; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Sam -// -//////////////////////////////////////////////////////////////////////////////////////////// - -//char input[]={"/HAALAOAO MAYN NAAMAEAE IHSTT SAEBAASTTIHAAN \x9b\x9b\0"}; -//unsigned char input[]={"/HAALAOAO \x9b\0"}; -//unsigned char input[]={"AA \x9b\0"}; -//unsigned char input[] = {"GUH5DEHN TAEG\x9b\0"}; - -//unsigned char input[]={"AY5 AEM EY TAO4LXKIHNX KAX4MPYUX4TAH. GOW4 AH/HEH3D PAHNK.MEYK MAY8 DEY.\x9b\0"}; -//unsigned char input[]={"/HEH3LOW2, /HAW AH YUX2 TUXDEY. AY /HOH3P YUX AH FIYLIHNX OW4 KEY.\x9b\0"}; -//unsigned char input[]={"/HEY2, DHIHS IH3Z GREY2T. /HAH /HAH /HAH.AYL BIY5 BAEK.\x9b\0"}; -//unsigned char input[]={"/HAH /HAH /HAH \x9b\0"}; -//unsigned char input[]={"/HAH /HAH /HAH.\x9b\0"}; -//unsigned char input[]={".TUW BIY5Y3,, OHR NAA3T - TUW BIY5IYIY., DHAE4T IHZ DHAH KWEH4SCHAHN.\x9b\0"}; -//unsigned char input[]={"/HEY2, DHIHS \x9b\0"}; - -//unsigned char input[]={" IYIHEHAEAAAHAOOHUHUXERAXIX \x9b\0"}; -//unsigned char input[]={" RLWWYMNNXBDGJZZHVDH \x9b\0"}; -//unsigned char input[]={" SSHFTHPTKCH/H \x9b\0"}; - -//unsigned char input[]={" EYAYOYAWOWUW ULUMUNQ YXWXRXLX/XDX\x9b\0"}; - -void STM32SAM::SetInput(char* _input) { - int i, l; - l = strlen(_input); - if(l > 254) l = 254; - for(i = 0; i < l; i++) { - input[i] = _input[i]; - } - input[l] = 0; -} - -// 168=pitches -// 169=frequency1 -// 170=frequency2 -// 171=frequency3 -// 172=amplitude1 -// 173=amplitude2 -// 174=amplitude3 - -void STM32SAM::Init() { - bufferpos = 0; - int i; - SetMouthThroat(); - - bufferpos = 0; - // TODO, check for free the memory, 10 seconds of output should be more than enough - //buffer = malloc(22050*10); - - // buffer = (char*) calloc(1, sizeof(char)); - - /* - freq2data = &mem[45136]; - freq1data = &mem[45056]; - freq3data = &mem[45216]; - */ - //pitches = &mem[43008]; - /* - frequency1 = &mem[43264]; - frequency2 = &mem[43520]; - frequency3 = &mem[43776]; - */ - /* - amplitude1 = &mem[44032]; - amplitude2 = &mem[44288]; - amplitude3 = &mem[44544]; - */ - //phoneme = &mem[39904]; - /* - ampl1data = &mem[45296]; - ampl2data = &mem[45376]; - ampl3data = &mem[45456]; - */ - - for(i = 0; i < 256; i++) { - stress[i] = 0; - phonemeLength[i] = 0; - } - - for(i = 0; i < 60; i++) { - phonemeIndexOutput[i] = 0; - stressOutput[i] = 0; - phonemeLengthOutput[i] = 0; - } - phonemeindex[255] = - 255; //to prevent buffer overflow // ML : changed from 32 to 255 to stop freezing with long inputs -} - -//int Code39771() -int STM32SAM::SAMMain() { - Init(); - phonemeindex[255] = 32; //to prevent buffer overflow - - if(!Parser1()) { - return 0; - } - - Parser2(); - CopyStress(); - SetPhonemeLength(); - AdjustLengths(); - Code41240(); - do { - A = phonemeindex[X]; - if(A > 80) { - phonemeindex[X] = 255; - break; // error: delete all behind it - } - X++; - } while(X != 0); - - //pos39848: - InsertBreath(); - - //mem[40158] = 255; - - PrepareOutput(); - - return 1; -} - -//void Code48547() -void STM32SAM::PrepareOutput() { - A = 0; - X = 0; - Y = 0; - - //pos48551: - while(1) { - A = phonemeindex[X]; - if(A == 255) { - A = 255; - phonemeIndexOutput[Y] = 255; - Render(); - return; - } - if(A == 254) { - X++; - int temp = X; - //mem[48546] = X; - phonemeIndexOutput[Y] = 255; - Render(); - //X = mem[48546]; - X = temp; - Y = 0; - continue; - } - - if(A == 0) { - X++; - continue; - } - - phonemeIndexOutput[Y] = A; - phonemeLengthOutput[Y] = phonemeLength[X]; - stressOutput[Y] = stress[X]; - X++; - Y++; - } -} - -//void Code41014() -void STM32SAM::Insert( - unsigned char position /*var57*/, - unsigned char mem60, - unsigned char mem59, - unsigned char mem58) { - int i; - for(i = 253; i >= position; i--) // ML : always keep last safe-guarding 255 - { - phonemeindex[i + 1] = phonemeindex[i]; - phonemeLength[i + 1] = phonemeLength[i]; - stress[i + 1] = stress[i]; - } - - phonemeindex[position] = mem60; - phonemeLength[position] = mem59; - stress[position] = mem58; - return; -} - -//void Code48431() -void STM32SAM::InsertBreath() { - unsigned char mem54; - unsigned char mem55; - unsigned char index; //variable Y - mem54 = 255; - X++; - mem55 = 0; - unsigned char mem66 = 0; - while(1) { - //pos48440: - X = mem66; - index = phonemeindex[X]; - if(index == 255) return; - mem55 += phonemeLength[X]; - - if(mem55 < 232) { - if(index != 254) // ML : Prevents an index out of bounds problem - { - A = flags2[index] & 1; - if(A != 0) { - X++; - mem55 = 0; - Insert(X, 254, mem59, 0); - mem66++; - mem66++; - continue; - } - } - if(index == 0) mem54 = X; - mem66++; - continue; - } - X = mem54; - phonemeindex[X] = 31; // 'Q*' glottal stop - phonemeLength[X] = 4; - stress[X] = 0; - X++; - mem55 = 0; - Insert(X, 254, mem59, 0); - X++; - mem66 = X; - } -} - -// Iterates through the phoneme buffer, copying the stress value from -// the following phoneme under the following circumstance: - -// 1. The current phoneme is voiced, excluding plosives and fricatives -// 2. The following phoneme is voiced, excluding plosives and fricatives, and -// 3. The following phoneme is stressed -// -// In those cases, the stress value+1 from the following phoneme is copied. -// -// For example, the word LOITER is represented as LOY5TER, with as stress -// of 5 on the diphtong OY. This routine will copy the stress value of 6 (5+1) -// to the L that precedes it. - -//void Code41883() -void STM32SAM::CopyStress() { - // loop thought all the phonemes to be output - unsigned char pos = 0; //mem66 - while(1) { - // get the phomene - Y = phonemeindex[pos]; - - // exit at end of buffer - if(Y == 255) return; - - // if CONSONANT_FLAG set, skip - only vowels get stress - if((flags[Y] & 64) == 0) { - pos++; - continue; - } - // get the next phoneme - Y = phonemeindex[pos + 1]; - if(Y == 255) //prevent buffer overflow - { - pos++; - continue; - } else - // if the following phoneme is a vowel, skip - if((flags[Y] & 128) == 0) { - pos++; - continue; - } - - // get the stress value at the next position - Y = stress[pos + 1]; - - // if next phoneme is not stressed, skip - if(Y == 0) { - pos++; - continue; - } - - // if next phoneme is not a VOWEL OR ER, skip - if((Y & 128) != 0) { - pos++; - continue; - } - - // copy stress from prior phoneme to this one - stress[pos] = Y + 1; - - // advance pointer - pos++; - } -} - -// The input[] buffer contains a string of phonemes and stress markers along -// the lines of: -// -// DHAX KAET IHZ AH5GLIY. <0x9B> -// -// The byte 0x9B marks the end of the buffer. Some phonemes are 2 bytes -// long, such as "DH" and "AX". Others are 1 byte long, such as "T" and "Z". -// There are also stress markers, such as "5" and ".". -// -// The first character of the phonemes are stored in the table signInputTable1[]. -// The second character of the phonemes are stored in the table signInputTable2[]. -// The stress characters are arranged in low to high stress order in stressInputTable[]. -// -// The following process is used to parse the input[] buffer: -// -// Repeat until the <0x9B> character is reached: -// -// First, a search is made for a 2 character match for phonemes that do not -// end with the '*' (wildcard) character. On a match, the index of the phoneme -// is added to phonemeIndex[] and the buffer position is advanced 2 bytes. -// -// If this fails, a search is made for a 1 character match against all -// phoneme names ending with a '*' (wildcard). If this succeeds, the -// phoneme is added to phonemeIndex[] and the buffer position is advanced -// 1 byte. -// -// If this fails, search for a 1 character match in the stressInputTable[]. -// If this succeeds, the stress value is placed in the last stress[] table -// at the same index of the last added phoneme, and the buffer position is -// advanced by 1 byte. -// -// If this fails, return a 0. -// -// On success: -// -// 1. phonemeIndex[] will contain the index of all the phonemes. -// 2. The last index in phonemeIndex[] will be 255. -// 3. stress[] will contain the stress value for each phoneme - -// input[] holds the string of phonemes, each two bytes wide -// signInputTable1[] holds the first character of each phoneme -// signInputTable2[] holds te second character of each phoneme -// phonemeIndex[] holds the indexes of the phonemes after parsing input[] -// -// The parser scans through the input[], finding the names of the phonemes -// by searching signInputTable1[] and signInputTable2[]. On a match, it -// copies the index of the phoneme into the phonemeIndexTable[]. -// -// The character <0x9B> marks the end of text in input[]. When it is reached, -// the index 255 is placed at the end of the phonemeIndexTable[], and the -// function returns with a 1 indicating success. -int STM32SAM::Parser1() { - int i; - unsigned char sign1; - unsigned char sign2; - unsigned char position = 0; - X = 0; - A = 0; - Y = 0; - - // CLEAR THE STRESS TABLE - for(i = 0; i < 256; i++) stress[i] = 0; - - // THIS CODE MATCHES THE PHONEME LETTERS TO THE TABLE - // pos41078: - while(1) { - // GET THE FIRST CHARACTER FROM THE PHONEME BUFFER - sign1 = input[X]; - // TEST FOR 155 (�) END OF LINE MARKER - if(sign1 == 155) { - // MARK ENDPOINT AND RETURN - phonemeindex[position] = 255; //mark endpoint - // REACHED END OF PHONEMES, SO EXIT - return 1; //all ok - } - - // GET THE NEXT CHARACTER FROM THE BUFFER - X++; - sign2 = input[X]; - - // NOW sign1 = FIRST CHARACTER OF PHONEME, AND sign2 = SECOND CHARACTER OF PHONEME - - // TRY TO MATCH PHONEMES ON TWO TWO-CHARACTER NAME - // IGNORE PHONEMES IN TABLE ENDING WITH WILDCARDS - - // SET INDEX TO 0 - Y = 0; - pos41095: - - // GET FIRST CHARACTER AT POSITION Y IN signInputTable - // --> should change name to PhonemeNameTable1 - A = signInputTable1[Y]; - - // FIRST CHARACTER MATCHES? - if(A == sign1) { - // GET THE CHARACTER FROM THE PhonemeSecondLetterTable - A = signInputTable2[Y]; - // NOT A SPECIAL AND MATCHES SECOND CHARACTER? - if((A != '*') && (A == sign2)) { - // STORE THE INDEX OF THE PHONEME INTO THE phomeneIndexTable - phonemeindex[position] = Y; - - // ADVANCE THE POINTER TO THE phonemeIndexTable - position++; - // ADVANCE THE POINTER TO THE phonemeInputBuffer - X++; - - // CONTINUE PARSING - continue; - } - } - - // NO MATCH, TRY TO MATCH ON FIRST CHARACTER TO WILDCARD NAMES (ENDING WITH '*') - - // ADVANCE TO THE NEXT POSITION - Y++; - // IF NOT END OF TABLE, CONTINUE - if(Y != 81) goto pos41095; - - // REACHED END OF TABLE WITHOUT AN EXACT (2 CHARACTER) MATCH. - // THIS TIME, SEARCH FOR A 1 CHARACTER MATCH AGAINST THE WILDCARDS - - // RESET THE INDEX TO POINT TO THE START OF THE PHONEME NAME TABLE - Y = 0; - pos41134: - // DOES THE PHONEME IN THE TABLE END WITH '*'? - if(signInputTable2[Y] == '*') { - // DOES THE FIRST CHARACTER MATCH THE FIRST LETTER OF THE PHONEME - if(signInputTable1[Y] == sign1) { - // SAVE THE POSITION AND MOVE AHEAD - phonemeindex[position] = Y; - - // ADVANCE THE POINTER - position++; - - // CONTINUE THROUGH THE LOOP - continue; - } - } - Y++; - if(Y != 81) goto pos41134; //81 is size of PHONEME NAME table - - // FAILED TO MATCH WITH A WILDCARD. ASSUME THIS IS A STRESS - // CHARACTER. SEARCH THROUGH THE STRESS TABLE - - // SET INDEX TO POSITION 8 (END OF STRESS TABLE) - Y = 8; - - // WALK BACK THROUGH TABLE LOOKING FOR A MATCH - while((sign1 != stressInputTable[Y]) && (Y > 0)) { - // DECREMENT INDEX - Y--; - } - - // REACHED THE END OF THE SEARCH WITHOUT BREAKING OUT OF LOOP? - if(Y == 0) { - //mem[39444] = X; - //41181: JSR 42043 //Error - // FAILED TO MATCH ANYTHING, RETURN 0 ON FAILURE - return 0; - } - // SET THE STRESS FOR THE PRIOR PHONEME - stress[position - 1] = Y; - } //while -} - -//change phonemelength depedendent on stress -//void Code41203() -void STM32SAM::SetPhonemeLength() { - unsigned char A; - int position = 0; - while(phonemeindex[position] != 255) { - A = stress[position]; - //41218: BMI 41229 - if((A == 0) || ((A & 128) != 0)) { - phonemeLength[position] = phonemeLengthTable[phonemeindex[position]]; - } else { - phonemeLength[position] = phonemeStressedLengthTable[phonemeindex[position]]; - } - position++; - } -} - -void STM32SAM::Code41240() { - unsigned char pos = 0; - - while(phonemeindex[pos] != 255) { - unsigned char index; //register AC - X = pos; - index = phonemeindex[pos]; - if((flags[index] & 2) == 0) { - pos++; - continue; - } else if((flags[index] & 1) == 0) { - Insert(pos + 1, index + 1, phonemeLengthTable[index + 1], stress[pos]); - Insert(pos + 2, index + 2, phonemeLengthTable[index + 2], stress[pos]); - pos += 3; - continue; - } - - do { - X++; - A = phonemeindex[X]; - } while(A == 0); - - if(A != 255) { - if((flags[A] & 8) != 0) { - pos++; - continue; - } - if((A == 36) || (A == 37)) { - pos++; // '/H' '/X' - continue; - } - } - - Insert(pos + 1, index + 1, phonemeLengthTable[index + 1], stress[pos]); - Insert(pos + 2, index + 2, phonemeLengthTable[index + 2], stress[pos]); - pos += 3; - }; -} - -// Rewrites the phonemes using the following rules: -// -// -> WX -// -> YX -// UL -> AX L -// UM -> AX M -// -> Q -// T R -> CH R -// D R -> J R -// R -> RX -// L -> LX -// G S -> G Z -// K -> KX -// G -> GX -// S P -> S B -// S T -> S D -// S K -> S G -// S KX -> S GX -// UW -> UX -// CH -> CH CH' (CH requires two phonemes to represent it) -// J -> J J' (J requires two phonemes to represent it) -// T -> DX -// D -> DX - -//void Code41397() -void STM32SAM::Parser2() { - unsigned char pos = 0; //mem66; - unsigned char mem58 = 0; - - // Loop through phonemes - while(1) { - // SET X TO THE CURRENT POSITION - X = pos; - // GET THE PHONEME AT THE CURRENT POSITION - A = phonemeindex[pos]; - - // Is phoneme pause? - if(A == 0) { - // Move ahead to the - pos++; - continue; - } - - // If end of phonemes flag reached, exit routine - if(A == 255) return; - - // Copy the current phoneme index to Y - Y = A; - - // RULE: - // -> WX - // -> YX - // Example: OIL, COW - - // Check for DIPHTONG - if((flags[A] & 16) == 0) goto pos41457; - - // Not a diphthong. Get the stress - mem58 = stress[pos]; - - // End in IY sound? - A = flags[Y] & 32; - - // If ends with IY, use YX, else use WX - if(A == 0) - A = 20; - else - A = 21; // 'WX' = 20 'YX' = 21 - //pos41443: - // Insert at WX or YX following, copying the stress - - Insert(pos + 1, A, mem59, mem58); - X = pos; - // Jump to ??? - goto pos41749; - - pos41457: - - // RULE: - // UL -> AX L - // Example: MEDDLE - - // Get phoneme - A = phonemeindex[X]; - // Skip this rule if phoneme is not UL - if(A != 78) goto pos41487; // 'UL' - A = 24; // 'L' //change 'UL' to 'AX L' - - pos41466: - // Get current phoneme stress - mem58 = stress[X]; - - // Change UL to AX - phonemeindex[X] = 13; // 'AX' - // Perform insert. Note code below may jump up here with different values - Insert(X + 1, A, mem59, mem58); - pos++; - // Move to next phoneme - continue; - - pos41487: - - // RULE: - // UM -> AX M - // Example: ASTRONOMY - - // Skip rule if phoneme != UM - if(A != 79) goto pos41495; // 'UM' - // Jump up to branch - replaces current phoneme with AX and continues - A = 27; // 'M' //change 'UM' to 'AX M' - - goto pos41466; - pos41495: - - // RULE: - // UN -> AX N - // Example: FUNCTION - - // Skip rule if phoneme != UN - if(A != 80) goto pos41503; // 'UN' - - // Jump up to branch - replaces current phoneme with AX and continues - A = 28; // 'N' //change UN to 'AX N' - - goto pos41466; - pos41503: - - // RULE: - // -> Q - // EXAMPLE: AWAY EIGHT - - Y = A; - // VOWEL set? - A = flags[A] & 128; - - // Skip if not a vowel - if(A != 0) { - // Get the stress - A = stress[X]; - - // If stressed... - if(A != 0) { - // Get the following phoneme - X++; - A = phonemeindex[X]; - // If following phoneme is a pause - - if(A == 0) { - // Get the phoneme following pause - X++; - Y = phonemeindex[X]; - - // Check for end of buffer flag - if(Y == 255) //buffer overflow - // ??? Not sure about these flags - A = 65 & 128; - else - // And VOWEL flag to current phoneme's flags - A = flags[Y] & 128; - - // If following phonemes is not a pause - if(A != 0) { - // If the following phoneme is not stressed - A = stress[X]; - if(A != 0) { - // 31 = 'Q' - Insert(X, 31, mem59, 0); - pos++; - continue; - } - } - } - } - } - - // RULES FOR PHONEMES BEFORE R - // T R -> CH R - // Example: TRACK - - // Get current position and phoneme - X = pos; - A = phonemeindex[pos]; - if(A != 23) goto pos41611; // 'R' - - // Look at prior phoneme - X--; - A = phonemeindex[pos - 1]; - //pos41567: - if(A == 69) // 'T' - { - phonemeindex[pos - 1] = 42; - goto pos41779; - } - - // RULES FOR PHONEMES BEFORE R - // D R -> J R - // Example: DRY - - // Prior phonemes D? - if(A == 57) // 'D' - { - // Change D to J - phonemeindex[pos - 1] = 44; - - goto pos41788; - } - - // RULES FOR PHONEMES BEFORE R - // R -> RX - // Example: ART - - // If vowel flag is set change R to RX - A = flags[A] & 128; - - if(A != 0) phonemeindex[pos] = 18; // 'RX' - - // continue to next phoneme - pos++; - continue; - - pos41611: - - // RULE: - // L -> LX - // Example: ALL - - // Is phoneme L? - if(A == 24) // 'L' - { - // If prior phoneme does not have VOWEL flag set, move to next phoneme - if((flags[phonemeindex[pos - 1]] & 128) == 0) { - pos++; - continue; - } - // Prior phoneme has VOWEL flag set, so change L to LX and move to next phoneme - - phonemeindex[X] = 19; // 'LX' - pos++; - continue; - } - - // RULE: - // G S -> G Z - // - // Can't get to fire - - // 1. The G -> GX rule intervenes - // 2. Reciter already replaces GS -> GZ - - // Is current phoneme S? - if(A == 32) // 'S' - { - // If prior phoneme is not G, move to next phoneme - if(phonemeindex[pos - 1] != 60) { - pos++; - continue; - } - // Replace S with Z and move on - - phonemeindex[pos] = 38; // 'Z' - pos++; - continue; - } - - // RULE: - // K -> KX - // Example: COW - - // Is current phoneme K? - if(A == 72) // 'K' - { - // Get next phoneme - Y = phonemeindex[pos + 1]; - // If at end, replace current phoneme with KX - if(Y == 255) - phonemeindex[pos] = 75; // ML : prevents an index out of bounds problem - else { - // VOWELS AND DIPHTONGS ENDING WITH IY SOUND flag set? - A = flags[Y] & 32; - - // Replace with KX - if(A == 0) phonemeindex[pos] = 75; // 'KX' - } - } else - - // RULE: - // G -> GX - // Example: GO - - // Is character a G? - if(A == 60) // 'G' - { - // Get the following character - unsigned char index = phonemeindex[pos + 1]; - - // At end of buffer? - if(index == 255) //prevent buffer overflow - { - pos++; - continue; - } else - // If diphtong ending with YX, move continue processing next phoneme - if((flags[index] & 32) != 0) { - pos++; - continue; - } - // replace G with GX and continue processing next phoneme - - phonemeindex[pos] = 63; // 'GX' - pos++; - continue; - } - - // RULE: - // S P -> S B - // S T -> S D - // S K -> S G - // S KX -> S GX - // Examples: SPY, STY, SKY, SCOWL - - Y = phonemeindex[pos]; - //pos41719: - // Replace with softer version? - A = flags[Y] & 1; - if(A == 0) goto pos41749; - A = phonemeindex[pos - 1]; - if(A != 32) // 'S' - { - A = Y; - goto pos41812; - } - // Replace with softer version - - phonemeindex[pos] = Y - 12; - pos++; - continue; - - pos41749: - - // RULE: - // UW -> UX - // - // Example: NEW, DEW, SUE, ZOO, THOO, TOO - - // UW -> UX - - A = phonemeindex[X]; - if(A == 53) // 'UW' - { - // ALVEOLAR flag set? - Y = phonemeindex[X - 1]; - A = flags2[Y] & 4; - // If not set, continue processing next phoneme - if(A == 0) { - pos++; - continue; - } - - phonemeindex[X] = 16; - pos++; - continue; - } - pos41779: - - // RULE: - // CH -> CH CH' (CH requires two phonemes to represent it) - // Example: CHEW - - if(A == 42) // 'CH' - { - // pos41783: - - Insert(X + 1, A + 1, mem59, stress[X]); - pos++; - continue; - } - - pos41788: - - // RULE: - // J -> J J' (J requires two phonemes to represent it) - // Example: JAY - - if(A == 44) // 'J' - { - Insert(X + 1, A + 1, mem59, stress[X]); - pos++; - continue; - } - - // Jump here to continue - pos41812: - - // RULE: Soften T following vowel - // NOTE: This rule fails for cases such as "ODD" - // T -> DX - // D -> DX - // Example: PARTY, TARDY - - // Past this point, only process if phoneme is T or D - - if(A != 69) // 'T' - if(A != 57) { - pos++; // 'D' - continue; - } - //pos41825: - - // If prior phoneme is not a vowel, continue processing phonemes - if((flags[phonemeindex[X - 1]] & 128) == 0) { - pos++; - continue; - } - - // Get next phoneme - X++; - A = phonemeindex[X]; - //pos41841 - // Is the next phoneme a pause? - if(A != 0) { - // If next phoneme is not a pause, continue processing phonemes - if((flags[A] & 128) == 0) { - pos++; - continue; - } - // If next phoneme is stressed, continue processing phonemes - // FIXME: How does a pause get stressed? - if(stress[X] != 0) { - pos++; - continue; - } - //pos41856: - // Set phonemes to DX - - phonemeindex[pos] = 30; // 'DX' - } else { - A = phonemeindex[X + 1]; - if(A == 255) //prevent buffer overflow - A = 65 & 128; - else - // Is next phoneme a vowel or ER? - A = flags[A] & 128; - - if(A != 0) phonemeindex[pos] = 30; // 'DX' - } - - pos++; - - } // while -} // parser 2 - -// Applies various rules that adjust the lengths of phonemes -// -// Lengthen or between and by 1.5 -// - decrease length by 1 -// - decrease vowel by 1/8th -// - increase vowel by 1/2 + 1 -// - set nasal = 5, consonant = 6 -// {optional silence} - shorten both to 1/2 + 1 -// - decrease by 2 - -//void Code48619() -void STM32SAM::AdjustLengths() { - // LENGTHEN VOWELS PRECEDING PUNCTUATION - // - // Search for punctuation. If found, back up to the first vowel, then - // process all phonemes between there and up to (but not including) the punctuation. - // If any phoneme is found that is a either a fricative or voiced, the duration is - // increased by (length * 1.5) + 1 - - // loop index - X = 0; - unsigned char index; - - // iterate through the phoneme list - unsigned char loopIndex = 0; - while(1) { - // get a phoneme - index = phonemeindex[X]; - - // exit loop if end on buffer token - if(index == 255) break; - - // not punctuation? - if((flags2[index] & 1) == 0) { - // skip - X++; - continue; - } - - // hold index - loopIndex = X; - - // Loop backwards from this point - pos48644: - - // back up one phoneme - X--; - - // stop once the beginning is reached - if(X == 0) break; - - // get the preceding phoneme - index = phonemeindex[X]; - - if(index != 255) //inserted to prevent access overrun - if((flags[index] & 128) == 0) goto pos48644; // if not a vowel, continue looping - - //pos48657: - do { - // test for vowel - index = phonemeindex[X]; - - if(index != 255) //inserted to prevent access overrun - // test for fricative/unvoiced or not voiced - if(((flags2[index] & 32) == 0) || ((flags[index] & 4) != 0)) //nochmal �berpr�fen - { - //A = flags[Y] & 4; - //if(A == 0) goto pos48688; - - // get the phoneme length - A = phonemeLength[X]; - - // change phoneme length to (length * 1.5) + 1 - A = (A >> 1) + A + 1; - - phonemeLength[X] = A; - } - // keep moving forward - X++; - } while(X != loopIndex); - // if (X != loopIndex) goto pos48657; - X++; - } // while - - // Similar to the above routine, but shorten vowels under some circumstances - - // Loop throught all phonemes - loopIndex = 0; - //pos48697 - - while(1) { - // get a phoneme - X = loopIndex; - index = phonemeindex[X]; - - // exit routine at end token - if(index == 255) return; - - // vowel? - A = flags[index] & 128; - if(A != 0) { - // get next phoneme - X++; - index = phonemeindex[X]; - - // get flags - if(index == 255) - mem56 = 65; // use if end marker - else - mem56 = flags[index]; - - // not a consonant - if((flags[index] & 64) == 0) { - // RX or LX? - if((index == 18) || (index == 19)) // 'RX' & 'LX' - { - // get the next phoneme - X++; - index = phonemeindex[X]; - - // next phoneme a consonant? - if((flags[index] & 64) != 0) { - // RULE: RX | LX - - // decrease length of vowel by 1 frame - phonemeLength[loopIndex]--; - } - // move ahead - loopIndex++; - continue; - } - // move ahead - loopIndex++; - continue; - } - - // Got here if not - - // not voiced - if((mem56 & 4) == 0) { - // Unvoiced - // *, .*, ?*, ,*, -*, DX, S*, SH, F*, TH, /H, /X, CH, P*, T*, K*, KX - - // not an unvoiced plosive? - if((mem56 & 1) == 0) { - // move ahead - loopIndex++; - continue; - } - - // P*, T*, K*, KX - - // RULE: - // - - // move back - X--; - - // decrease length by 1/8th - mem56 = phonemeLength[X] >> 3; - phonemeLength[X] -= mem56; - - // move ahead - loopIndex++; - continue; - } - - // RULE: - // - - // decrease length - A = phonemeLength[X - 1]; - phonemeLength[X - 1] = (A >> 2) + A + 1; // 5/4*A + 1 - - // move ahead - loopIndex++; - continue; - } - - // WH, R*, L*, W*, Y*, M*, N*, NX, Q*, Z*, ZH, V*, DH, J*, B*, D*, G*, GX - - //pos48821: - - // RULE: - // Set punctuation length to 6 - // Set stop consonant length to 5 - - // nasal? - if((flags2[index] & 8) != 0) { - // M*, N*, NX, - - // get the next phoneme - X++; - index = phonemeindex[X]; - - // end of buffer? - if(index == 255) - A = 65 & 2; //prevent buffer overflow - else - A = flags[index] & 2; // check for stop consonant - - // is next phoneme a stop consonant? - if(A != 0) - - // B*, D*, G*, GX, P*, T*, K*, KX - - { - // set stop consonant length to 6 - phonemeLength[X] = 6; - - // set nasal length to 5 - phonemeLength[X - 1] = 5; - } - // move to next phoneme - loopIndex++; - continue; - } - - // WH, R*, L*, W*, Y*, Q*, Z*, ZH, V*, DH, J*, B*, D*, G*, GX - - // RULE: {optional silence} - // Shorten both to (length/2 + 1) - - // (voiced) stop consonant? - if((flags[index] & 2) != 0) { - // B*, D*, G*, GX - - // move past silence - do { - // move ahead - X++; - index = phonemeindex[X]; - } while(index == 0); - - // check for end of buffer - if(index == 255) //buffer overflow - { - // ignore, overflow code - if((65 & 2) == 0) { - loopIndex++; - continue; - } - } else if((flags[index] & 2) == 0) { - // if another stop consonant, move ahead - loopIndex++; - continue; - } - - // RULE: {optional silence} - - // X gets overwritten, so hold prior X value for debug statement - // int debugX = X; - // shorten the prior phoneme length to (length/2 + 1) - phonemeLength[X] = (phonemeLength[X] >> 1) + 1; - X = loopIndex; - - // also shorten this phoneme length to (length/2 +1) - phonemeLength[loopIndex] = (phonemeLength[loopIndex] >> 1) + 1; - - // move ahead - loopIndex++; - continue; - } - - // WH, R*, L*, W*, Y*, Q*, Z*, ZH, V*, DH, J*, **, - - // RULE: - // Decrease by 2 - - // liquic consonant? - if((flags2[index] & 16) != 0) { - // R*, L*, W*, Y* - - // get the prior phoneme - index = phonemeindex[X - 1]; - - // prior phoneme a stop consonant> - if((flags[index] & 2) != 0) { - // Rule: - - // decrease the phoneme length by 2 frames (20 ms) - phonemeLength[X] -= 2; - } - } - - // move to next phoneme - loopIndex++; - continue; - } - // goto pos48701; -} - -// ------------------------------------------------------------------------- -// ML : Code47503 is division with remainder, and mem50 gets the sign -void STM32SAM::Code47503(unsigned char mem52) { - Y = 0; - if((mem53 & 128) != 0) { - mem53 = -mem53; - Y = 128; - } - mem50 = Y; - A = 0; - for(X = 8; X > 0; X--) { - int temp = mem53; - mem53 = mem53 << 1; - A = A << 1; - if(temp >= 128) A++; - if(A >= mem52) { - A = A - mem52; - mem53++; - } - } - - mem51 = A; - if((mem50 & 128) != 0) mem53 = -mem53; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Reciter -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::Code37055(unsigned char mem59) { - X = mem59; - X--; - A = inputtemp[X]; - Y = A; - A = tab36376[Y]; - return; -} - -void STM32SAM::Code37066(unsigned char mem58) { - X = mem58; - X++; - A = inputtemp[X]; - Y = A; - A = tab36376[Y]; -} - -unsigned char STM32SAM::GetRuleByte(unsigned short mem62, unsigned char Y) { - unsigned int address = mem62; - - if(mem62 >= 37541) { - address -= 37541; - return rules2[address + Y]; - } - address -= 32000; - return rules[address + Y]; -} - -int STM32SAM::TextToPhonemes(unsigned char* input) // Code36484 -{ - //unsigned char *tab39445 = &mem[39445]; //input and output - //unsigned char mem29; - unsigned char mem56; //output position for phonemes - unsigned char mem57; - unsigned char mem58; - unsigned char mem59; - unsigned char mem60; - unsigned char mem61; - unsigned short mem62; // memory position of current rule - - unsigned char mem64; // position of '=' or current character - unsigned char mem65; // position of ')' - unsigned char mem66; // position of '(' - unsigned char mem36653; - - inputtemp[0] = 32; - - // secure copy of input - // because input will be overwritten by phonemes - X = 1; - Y = 0; - do { - //pos36499: - A = input[Y] & 127; - if(A >= 112) - A = A & 95; - else if(A >= 96) - A = A & 79; - - inputtemp[X] = A; - X++; - Y++; - } while(Y != 255); - - X = 255; - inputtemp[X] = 27; - mem61 = 255; - -pos36550: - A = 255; - mem56 = 255; - -pos36554: - while(1) { - mem61++; - X = mem61; - A = inputtemp[X]; - mem64 = A; - if(A == '[') { - mem56++; - X = mem56; - A = 155; - input[X] = 155; - //goto pos36542; - // Code39771(); //Code39777(); - return 1; - } - - //pos36579: - if(A != '.') break; - X++; - Y = inputtemp[X]; - A = tab36376[Y] & 1; - if(A != 0) break; - mem56++; - X = mem56; - A = '.'; - input[X] = '.'; - } //while - - //pos36607: - A = mem64; - Y = A; - A = tab36376[A]; - mem57 = A; - if((A & 2) != 0) { - mem62 = 37541; - goto pos36700; - } - - //pos36630: - A = mem57; - if(A != 0) goto pos36677; - A = 32; - inputtemp[X] = ' '; - mem56++; - X = mem56; - if(X > 120) goto pos36654; - input[X] = A; - goto pos36554; - - // ----- - - //36653 is unknown. Contains position - -pos36654: - input[X] = 155; - A = mem61; - mem36653 = A; - // mem29 = A; // not used - // Code36538(); das ist eigentlich - return 1; - //Code39771(); - //go on if there is more input ??? - mem61 = mem36653; - goto pos36550; - -pos36677: - A = mem57 & 128; - if(A == 0) { - //36683: BRK - return 0; - } - - // go to the right rules for this character. - X = mem64 - 'A'; - mem62 = tab37489[X] | (tab37515[X] << 8); - - // ------------------------------------- - // go to next rule - // ------------------------------------- - -pos36700: - - // find next rule - Y = 0; - do { - mem62 += 1; - A = GetRuleByte(mem62, Y); - } while((A & 128) == 0); - Y++; - - //pos36720: - // find '(' - while(1) { - A = GetRuleByte(mem62, Y); - if(A == '(') break; - Y++; - } - mem66 = Y; - - //pos36732: - // find ')' - do { - Y++; - A = GetRuleByte(mem62, Y); - } while(A != ')'); - mem65 = Y; - - //pos36741: - // find '=' - do { - Y++; - A = GetRuleByte(mem62, Y); - A = A & 127; - } while(A != '='); - mem64 = Y; - - X = mem61; - mem60 = X; - - // compare the string within the bracket - Y = mem66; - Y++; - //pos36759: - while(1) { - mem57 = inputtemp[X]; - A = GetRuleByte(mem62, Y); - if(A != mem57) goto pos36700; - Y++; - if(Y == mem65) break; - X++; - mem60 = X; - } - - // the string in the bracket is correct - - //pos36787: - A = mem61; - mem59 = mem61; - -pos36791: - while(1) { - mem66--; - Y = mem66; - A = GetRuleByte(mem62, Y); - mem57 = A; - //36800: BPL 36805 - if((A & 128) != 0) goto pos37180; - X = A & 127; - A = tab36376[X] & 128; - if(A == 0) break; - X = mem59 - 1; - A = inputtemp[X]; - if(A != mem57) goto pos36700; - mem59 = X; - } - - //pos36833: - A = mem57; - if(A == ' ') goto pos36895; - if(A == '#') goto pos36910; - if(A == '.') goto pos36920; - if(A == '&') goto pos36935; - if(A == '@') goto pos36967; - if(A == '^') goto pos37004; - if(A == '+') goto pos37019; - if(A == ':') goto pos37040; - // Code42041(); //Error - //36894: BRK - return 0; - - // -------------- - -pos36895: - Code37055(mem59); - A = A & 128; - if(A != 0) goto pos36700; -pos36905: - mem59 = X; - goto pos36791; - - // -------------- - -pos36910: - Code37055(mem59); - A = A & 64; - if(A != 0) goto pos36905; - goto pos36700; - - // -------------- - -pos36920: - Code37055(mem59); - A = A & 8; - if(A == 0) goto pos36700; -pos36930: - mem59 = X; - goto pos36791; - - // -------------- - -pos36935: - Code37055(mem59); - A = A & 16; - if(A != 0) goto pos36930; - A = inputtemp[X]; - if(A != 72) goto pos36700; - X--; - A = inputtemp[X]; - if((A == 67) || (A == 83)) goto pos36930; - goto pos36700; - - // -------------- - -pos36967: - Code37055(mem59); - A = A & 4; - if(A != 0) goto pos36930; - A = inputtemp[X]; - if(A != 72) goto pos36700; - if((A != 84) && (A != 67) && (A != 83)) goto pos36700; - mem59 = X; - goto pos36791; - - // -------------- - -pos37004: - Code37055(mem59); - A = A & 32; - if(A == 0) goto pos36700; - -pos37014: - mem59 = X; - goto pos36791; - - // -------------- - -pos37019: - X = mem59; - X--; - A = inputtemp[X]; - if((A == 'E') || (A == 'I') || (A == 'Y')) goto pos37014; - goto pos36700; - // -------------- - -pos37040: - Code37055(mem59); - A = A & 32; - if(A == 0) goto pos36791; - mem59 = X; - goto pos37040; - - //--------------------------------------- - -pos37077: - X = mem58 + 1; - A = inputtemp[X]; - if(A != 'E') goto pos37157; - X++; - Y = inputtemp[X]; - X--; - A = tab36376[Y] & 128; - if(A == 0) goto pos37108; - X++; - A = inputtemp[X]; - if(A != 'R') goto pos37113; -pos37108: - mem58 = X; - goto pos37184; -pos37113: - if((A == 83) || (A == 68)) goto pos37108; // 'S' 'D' - if(A != 76) goto pos37135; // 'L' - X++; - A = inputtemp[X]; - if(A != 89) goto pos36700; - goto pos37108; - -pos37135: - if(A != 70) goto pos36700; - X++; - A = inputtemp[X]; - if(A != 85) goto pos36700; - X++; - A = inputtemp[X]; - if(A == 76) goto pos37108; - goto pos36700; - -pos37157: - if(A != 73) goto pos36700; - X++; - A = inputtemp[X]; - if(A != 78) goto pos36700; - X++; - A = inputtemp[X]; - if(A == 71) goto pos37108; - //pos37177: - goto pos36700; - - // ----------------------------------------- - -pos37180: - - A = mem60; - mem58 = A; - -pos37184: - Y = mem65 + 1; - - //37187: CPY 64 - // if(? != 0) goto pos37194; - if(Y == mem64) goto pos37455; - mem65 = Y; - //37196: LDA (62),y - A = GetRuleByte(mem62, Y); - mem57 = A; - X = A; - A = tab36376[X] & 128; - if(A == 0) goto pos37226; - X = mem58 + 1; - A = inputtemp[X]; - if(A != mem57) goto pos36700; - mem58 = X; - goto pos37184; -pos37226: - A = mem57; - if(A == 32) goto pos37295; // ' ' - if(A == 35) goto pos37310; // '#' - if(A == 46) goto pos37320; // '.' - if(A == 38) goto pos37335; // '&' - if(A == 64) goto pos37367; // '' - if(A == 94) goto pos37404; // '' - if(A == 43) goto pos37419; // '+' - if(A == 58) goto pos37440; // ':' - if(A == 37) goto pos37077; // '%' - //pos37291: - // Code42041(); //Error - //37294: BRK - return 0; - - // -------------- -pos37295: - Code37066(mem58); - A = A & 128; - if(A != 0) goto pos36700; -pos37305: - mem58 = X; - goto pos37184; - - // -------------- - -pos37310: - Code37066(mem58); - A = A & 64; - if(A != 0) goto pos37305; - goto pos36700; - - // -------------- - -pos37320: - Code37066(mem58); - A = A & 8; - if(A == 0) goto pos36700; - -pos37330: - mem58 = X; - goto pos37184; - - // -------------- - -pos37335: - Code37066(mem58); - A = A & 16; - if(A != 0) goto pos37330; - A = inputtemp[X]; - if(A != 72) goto pos36700; - X++; - A = inputtemp[X]; - if((A == 67) || (A == 83)) goto pos37330; - goto pos36700; - - // -------------- - -pos37367: - Code37066(mem58); - A = A & 4; - if(A != 0) goto pos37330; - A = inputtemp[X]; - if(A != 72) goto pos36700; - if((A != 84) && (A != 67) && (A != 83)) goto pos36700; - mem58 = X; - goto pos37184; - - // -------------- - -pos37404: - Code37066(mem58); - A = A & 32; - if(A == 0) goto pos36700; -pos37414: - mem58 = X; - goto pos37184; - - // -------------- - -pos37419: - X = mem58; - X++; - A = inputtemp[X]; - if((A == 69) || (A == 73) || (A == 89)) goto pos37414; - goto pos36700; - - // ---------------------- - -pos37440: - - Code37066(mem58); - A = A & 32; - if(A == 0) goto pos37184; - mem58 = X; - goto pos37440; -pos37455: - Y = mem64; - mem61 = mem60; - -pos37461: - //37461: LDA (62),y - A = GetRuleByte(mem62, Y); - mem57 = A; - A = A & 127; - if(A != '=') { - mem56++; - X = mem56; - input[X] = A; - } - - //37478: BIT 57 - //37480: BPL 37485 //not negative flag - if((mem57 & 128) == 0) goto pos37485; //??? - goto pos36554; -pos37485: - Y++; - goto pos37461; -} - -// Constructor - -STM32SAM::STM32SAM(uint32_t STM32SAM_SPEED /* = 5 */) { - STM32SAM_SPEED = STM32SAM_SPEED & 0x1f; // limit it from 0 to 31 - - _STM32SAM_SPEED = STM32SAM_SPEED; - - // set default voice - - speed = 72; - pitch = 64; - mouth = 128; - throat = 128; - - phonetic = 0; - singmode = 0; - - wait1 = 7; - wait2 = 6; - - mem59 = 0; - - oldtimetableindex = 0; -} - -STM32SAM::STM32SAM() { - _STM32SAM_SPEED = 7; - - // set default voice - - speed = 72; - pitch = 64; - mouth = 128; - throat = 128; - - phonetic = 0; - singmode = 0; - - wait1 = 7; - wait2 = 6; - - mem59 = 0; - - oldtimetableindex = 0; -} - -/* - STM32SAM::~STM32SAM() { - { - // TODO: end(); - } -*/ - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM sam (variable string, phonetic, sing, pitch, speed, mouth, throat) -// STM32SAM say (sing off, phonetic off) (const string) -// STM32SAM say (sing off, phonetic off) (variable string) -// STM32SAM sing (sing on, phonetic off) (const string) -// STM32SAM sing (sing on, phonetic off) (variable string) -// STM32SAM sayPhonetic (sing off, phonetic on) (const string) -// STM32SAM sayPhonetic (sing off, phonetic on) (variable string) -// STM32SAM singPhonetic (sing on, phonetic on) (const string) -// STM32SAM singPhonetic (sing on, phonetic on) (variable string) -// STM32SAM voice (pitch, speed, mouth, throat) -// STM32SAM setPitch (pitch) -// STM32SAM setSpeed (speed) -// STM32SAM setMouth (mouth) -// STM32SAM setThroat (throat) -// -// -//////////////////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM sam (const string, phonetic, sing, pitch, speed, mouth, throat) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -char to_upper_case(char c) { - if(c >= 'a' && c <= 'z') { - return c - 'a' + 'A'; - } - return c; -} - -void STM32SAM::sam( - const char* argv, - unsigned char _phonetic, - unsigned char _singmode, - unsigned char _pitch, - unsigned char _speed, - unsigned char _mouth, - unsigned char _throat) { - phonetic = _phonetic; - singmode = _singmode; - pitch = _pitch; - speed = _speed; - mouth = _mouth; - throat = _throat; - - int i; - - for(i = 0; i < 256; i++) { - input[i] = argv[i]; - } - - for(i = 0; input[i] != 0; i++) { - if(i != 0) { - input[i] = to_upper_case((int)argv[i]); - } - } - - if(!phonetic) { - strncat(input, "[", 256); - if(!TextToPhonemes((unsigned char*)input)) { - // PrintUsage(); - return; - } - - } else { - strncat(input, "\x9b", 256); - } - - SetInput(input); - - if(!SAMMain()) { - return; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM sam (variable string, phonetic, sing, pitch, speed, mouth, throat) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::sam( - char* argv, - unsigned char _phonetic, - unsigned char _singmode, - unsigned char _pitch, - unsigned char _speed, - unsigned char _mouth, - unsigned char _throat) { - phonetic = _phonetic; - singmode = _singmode; - pitch = _pitch; - speed = _speed; - mouth = _mouth; - throat = _throat; - - int i; - - for(i = 0; i < 256; i++) { - input[i] = argv[i]; - } - - for(i = 0; input[i] != 0; i++) { - if(i != 0) { - input[i] = to_upper_case((int)argv[i]); - } - } - - if(!phonetic) { - strncat(input, "[", 256); - if(!TextToPhonemes((unsigned char*)input)) { - // PrintUsage(); - return; - } - - } else { - strncat(input, "\x9b", 256); - } - - SetInput(input); - - if(!SAMMain()) { - return; - } -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM say(sing off, phonetic off) (const string) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::say(const char* argv) { - int i; - - phonetic = 0; - singmode = 0; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -void STM32SAM::say(char* argv) { - int i; - - phonetic = 0; - singmode = 0; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM sing (sing on, phonetic off) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::sing(const char* argv) { - int i; - - phonetic = 0; - singmode = 1; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -void STM32SAM::sing(char* argv) { - int i; - - phonetic = 0; - singmode = 1; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM sayPhonetic (sing off, phonetic on) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::sayPhonetic(const char* argv) { - int i; - - phonetic = 1; - singmode = 0; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -void STM32SAM::sayPhonetic(char* argv) { - int i; - - phonetic = 1; - singmode = 0; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM singPhonetic (sing on, phonetic on) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::singPhonetic(const char* argv) { - int i; - - phonetic = 1; - singmode = 1; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -void STM32SAM::singPhonetic(char* argv) { - int i; - - phonetic = 1; - singmode = 0; - - char const_input[256]; - - for(i = 0; i < 256; i++) { - const_input[i] = argv[i]; - } - - sam(const_input, phonetic, singmode, pitch, speed, mouth, throat); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM voice (pitch, speed, mouth, throat) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::setVoice( - unsigned char _pitch /* = 64 */, - unsigned char _speed /* = 72 */, - unsigned char _mouth /* = 128 */, - unsigned char _throat /* = 128 */) { - pitch = _pitch; - speed = _speed; - mouth = _mouth; - throat = _throat; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM setPitch (pitch) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::setPitch(unsigned char _pitch /* = 64 */) { - pitch = _pitch; -} -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM setSpeed (speed) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::setSpeed(unsigned char _speed /* = 72 */) { - speed = _speed; -} -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM setMouth (mouth) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::setMouth(unsigned char _mouth /* = 128 */) { - mouth = _mouth; -} - -//////////////////////////////////////////////////////////////////////////////////////////// -// -// STM32SAM setThroat (throat) -// -//////////////////////////////////////////////////////////////////////////////////////////// - -void STM32SAM::setThroat(unsigned char _throat /* = 128 */) { - throat = _throat; -} -//////////////////////////////////////////////////////////////////////////////////////////// -// -// Hardware -// -//////////////////////////////////////////////////////////////////////////////////////////// -// Hardware specifics, for easier porting to other microcontrollers - -// -// Set PA8 pin as PWM, at 256 timer ticks overflow (8bit resolution) - -#include -#include - -#define FURI_HAL_SPEAKER_TIMER TIM16 -#define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1 - -void STM32SAM::begin(void) { -#ifdef USE_ROGER_CORE - - pinMode(PA8, PWM); // audio output pin - - Timer1.setPeriod( - 4); // Can't set at 256 ticks, only in uS. First nearest uS is 4 (Roger core is only for bluepill, that means 72*4=288 ticks, or 128*4=512 ticks when overclocked. It's ok, just overall volume will be lower, because maximum volume will be 256/288 or 256/512) - -#endif - -#ifdef USE_STM32duino_CORE - pinMode(PA8, OUTPUT); - - PWM->pause(); - PWM->setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PA8); // TIM1 CH1 (PA8) - PWM->setPrescaleFactor(1); - PWM->setOverflow(256, TICK_FORMAT); // 256 ticks overflow, no matter the CPU (timer) speed - PWM->resume(); - -#endif - - LL_TIM_InitTypeDef TIM_InitStruct; - memset(&TIM_InitStruct, 0, sizeof(LL_TIM_InitTypeDef)); - TIM_InitStruct.Prescaler = 4; - TIM_InitStruct.Autoreload = 255; - LL_TIM_Init(FURI_HAL_SPEAKER_TIMER, &TIM_InitStruct); - - LL_TIM_OC_InitTypeDef TIM_OC_InitStruct; - memset(&TIM_OC_InitStruct, 0, sizeof(LL_TIM_OC_InitTypeDef)); - TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1; - TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_ENABLE; - TIM_OC_InitStruct.CompareValue = 127; - LL_TIM_OC_Init(FURI_HAL_SPEAKER_TIMER, FURI_HAL_SPEAKER_CHANNEL, &TIM_OC_InitStruct); - - LL_TIM_EnableAllOutputs(FURI_HAL_SPEAKER_TIMER); - LL_TIM_EnableCounter(FURI_HAL_SPEAKER_TIMER); -} // begin - -inline void STM32SAM::SetAUDIO(unsigned char main_volume) { -#ifdef USE_ROGER_CORE - Timer1.setCompare(TIMER_CH1, main_volume); -#endif - -#ifdef USE_STM32duino_CORE - PWM->setCaptureCompare(1, main_volume, TICK_COMPARE_FORMAT); -#endif - - // if(main_volume > 64) { - // LL_TIM_OC_SetCompareCH1(FURI_HAL_SPEAKER_TIMER, 127); - // } else { - // LL_TIM_OC_SetCompareCH1(FURI_HAL_SPEAKER_TIMER, main_volume); - // } - - float data = main_volume; - data /= 255.0f; - data -= 0.5f; - data *= 4.0f; - data = tanhf(data); - - data += 0.5f; - data *= 255.0f; - - if(data < 0) { - data = 0; - } else if(data > 255) { - data = 255; - } - - LL_TIM_OC_SetCompareCH1(FURI_HAL_SPEAKER_TIMER, data); -} \ No newline at end of file diff --git a/applications/plugins/sam/stm32_sam.h b/applications/plugins/sam/stm32_sam.h deleted file mode 100644 index 910227ac3..000000000 --- a/applications/plugins/sam/stm32_sam.h +++ /dev/null @@ -1,96 +0,0 @@ -#include - -#ifndef __STM32SAM__ -#define __STM32SAM__ - -// SAM Text-To-Speech (TTS), ported from https://github.com/s-macke/SAM - -class STM32SAM { -public: - STM32SAM(uint32_t STM32SAM_SPEED); - STM32SAM(); - - void begin(void); - - void - sam(const char* argv, - unsigned char phonetic, - unsigned char singmode, - unsigned char pitch, - unsigned char speed, - unsigned char mouth, - unsigned char throat); - void - sam(char* argv, - unsigned char phonetic, - unsigned char singmode, - unsigned char pitch, - unsigned char speed, - unsigned char mouth, - unsigned char throat); - - void say(const char* argv); - void say(char* argv); - void sing(const char* argv); - void sing(char* argv); - void sayPhonetic(const char* argv); - void sayPhonetic(char* argv); - void singPhonetic(const char* argv); - void singPhonetic(char* argv); - void setVoice( - unsigned char _pitch = 64, - unsigned char _speed = 72, - unsigned char _mouth = 128, - unsigned char _throat = 128); - void setPitch(unsigned char _pitch = 64); - void setSpeed(unsigned char _speed = 72); - void setMouth(unsigned char _mouth = 128); - void setThroat(unsigned char _throat = 128); - -private: - void SetAUDIO(unsigned char main_volume); - - void Output8BitAry(int index, unsigned char ary[5]); - void Output8Bit(int index, unsigned char A); - unsigned char Read(unsigned char p, unsigned char Y); - void Write(unsigned char p, unsigned char Y, unsigned char value); - void RenderSample(unsigned char* mem66); - void Render(); - void AddInflection(unsigned char mem48, unsigned char phase1); - void SetMouthThroat(); - unsigned char trans(unsigned char mem39212, unsigned char mem39213); - void SetInput(char* _input); - void Init(); - int SAMMain(); - void PrepareOutput(); - void Insert( - unsigned char position /*var57*/, - unsigned char mem60, - unsigned char mem59, - unsigned char mem58); - void InsertBreath(); - void CopyStress(); - int Parser1(); - void SetPhonemeLength(); - void Code41240(); - void Parser2(); - void AdjustLengths(); - void Code47503(unsigned char mem52); - void Code37055(unsigned char mem59); - void Code37066(unsigned char mem58); - unsigned char GetRuleByte(unsigned short mem62, unsigned char Y); - int TextToPhonemes(unsigned char* input); // Code36484 - - uint32_t _STM32SAM_SPEED; - - unsigned char speed; - unsigned char pitch; - unsigned char mouth; - unsigned char throat; - - unsigned char phonetic; - unsigned char singmode; - -}; // STM32SAM class - -#endif \ No newline at end of file diff --git a/applications/plugins/scorched_tanks/LICENSE b/applications/plugins/scorched_tanks/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/scorched_tanks/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/scorched_tanks/README.md b/applications/plugins/scorched_tanks/README.md deleted file mode 100644 index 1c1970c19..000000000 --- a/applications/plugins/scorched_tanks/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Scorched tanks - flipper zero game -A flipper zero game inspired by scorched earth. - -Current state is shown below: - -![input](scorched_tanks_v1.gif) - -## How to do: -Do not hesitate to create PRs. If you start working on sth, please start branch name with TODO id (e.g. `feature/2-change-tank-icon`) - -If you see an improvement, modify this readme and add suggestions via PR. Bugs can be reported via Issues - -## What to do next (it's not in the priority order): -5. flatten surface beneath tanks -7. explosion animation -9. sub-ghz multi-player -11. add other types of weapons -12. code AI -13. add terain destruction -14. add terain gravity (fall down after hitting the middle of the mountain) -18. Add menu with settings (vibartion on/off, difficulty) -20. add more ground modifiers (currently there is only one hill in the middle, maybe 2 hills, skew map, etc) - -## What have been done: -1. ~~remove movement~~ -2. ~~change tank icon~~ -3. ~~power as variable not constant~~ -4. ~~better map generation: high, low regions~~ (continuation in point 20.) -6. ~~collision with the enemy~~ -8. ~~local multi-player~~ -10. ~~improve projectile trace draw on angles > 80~~ -15. ~~FIX: firing stops when bullet fly above the screen~~ -16. ~~Slightly randomize player and enemy spawn locations~~ -17. ~~Shooting vibration~~ -19. ~~Add wind~~ diff --git a/applications/plugins/scorched_tanks/application.fam b/applications/plugins/scorched_tanks/application.fam deleted file mode 100644 index fa0e6dd2b..000000000 --- a/applications/plugins/scorched_tanks/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="Scorched_Tanks", - name="Scorched Tanks", - apptype=FlipperAppType.EXTERNAL, - entry_point="scorched_tanks_game_app", - cdefines=["APP_SCORCHED_TANKS_GAME"], - requires=["gui"], - stack_size=1 * 1024, - order=100, - fap_icon="scorchedTanks_10px.png", - fap_category="Games", -) diff --git a/applications/plugins/scorched_tanks/scorchedTanks_10px.png b/applications/plugins/scorched_tanks/scorchedTanks_10px.png deleted file mode 100644 index 6e1ae4c04..000000000 Binary files a/applications/plugins/scorched_tanks/scorchedTanks_10px.png and /dev/null differ diff --git a/applications/plugins/scorched_tanks/scorched_tanks_game_app.c b/applications/plugins/scorched_tanks/scorched_tanks_game_app.c deleted file mode 100644 index fd4c73ee7..000000000 --- a/applications/plugins/scorched_tanks/scorched_tanks_game_app.c +++ /dev/null @@ -1,540 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define SCREEN_WIDTH 128 -#define SCREEN_HEIGHT 64 -#define PLAYER_INIT_LOCATION_X 20 -#define PLAYER_INIT_AIM 45 -#define PLAYER_INIT_POWER 50 -#define ENEMY_INIT_LOCATION_X 108 -#define TANK_BARREL_LENGTH 8 -#define GRAVITY_FORCE (double)0.5 -#define MIN_GROUND_HEIGHT 35 -#define MAX_GROUND_HEIGHT 55 -#define MAX_FIRE_POWER 100 -#define MIN_FIRE_POWER 0 -#define TANK_COLLIDER_SIZE 3 -#define MAX_WIND 10 -#define MAX_PLAYER_DIFF_X 20 -#define MAX_ENEMY_DIFF_X 20 - -// That's a filthy workaround but sin(player.aimAngle) breaks it all... If you're able to fix it, please do create a PR! -double scorched_tanks_sin[91] = { - 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.122, -0.139, -0.156, -0.174, -0.191, - -0.208, -0.225, -0.242, -0.259, -0.276, -0.292, -0.309, -0.326, -0.342, -0.358, -0.375, -0.391, - -0.407, -0.423, -0.438, -0.454, -0.469, -0.485, -0.500, -0.515, -0.530, -0.545, -0.559, -0.574, - -0.588, -0.602, -0.616, -0.629, -0.643, -0.656, -0.669, -0.682, -0.695, -0.707, -0.719, -0.731, - -0.743, -0.755, -0.766, -0.777, -0.788, -0.799, -0.809, -0.819, -0.829, -0.839, -0.848, -0.857, - -0.866, -0.875, -0.883, -0.891, -0.899, -0.906, -0.914, -0.921, -0.927, -0.934, -0.940, -0.946, - -0.951, -0.956, -0.961, -0.966, -0.970, -0.974, -0.978, -0.982, -0.985, -0.988, -0.990, -0.993, - -0.995, -0.996, -0.998, -0.999, -0.999, -1.000, -1.000}; -double scorched_tanks_cos[91] = { - 1.000, 1.000, 0.999, 0.999, 0.998, 0.996, 0.995, 0.993, 0.990, 0.988, 0.985, 0.982, 0.978, - 0.974, 0.970, 0.966, 0.961, 0.956, 0.951, 0.946, 0.940, 0.934, 0.927, 0.921, 0.914, 0.906, - 0.899, 0.891, 0.883, 0.875, 0.866, 0.857, 0.848, 0.839, 0.829, 0.819, 0.809, 0.799, 0.788, - 0.777, 0.766, 0.755, 0.743, 0.731, 0.719, 0.707, 0.695, 0.682, 0.669, 0.656, 0.643, 0.629, - 0.616, 0.602, 0.588, 0.574, 0.559, 0.545, 0.530, 0.515, 0.500, 0.485, 0.469, 0.454, 0.438, - 0.423, 0.407, 0.391, 0.375, 0.358, 0.342, 0.326, 0.309, 0.292, 0.276, 0.259, 0.242, 0.225, - 0.208, 0.191, 0.174, 0.156, 0.139, 0.122, 0.105, 0.087, 0.070, 0.052, 0.035, 0.017, 0.000}; -double scorched_tanks_tan[91] = { - 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.123, -0.141, -0.158, -0.176, - -0.194, -0.213, -0.231, -0.249, -0.268, -0.287, -0.306, -0.325, -0.344, -0.364, -0.384, - -0.404, -0.424, -0.445, -0.466, -0.488, -0.510, -0.532, -0.554, -0.577, -0.601, -0.625, - -0.649, -0.674, -0.700, -0.727, -0.754, -0.781, -0.810, -0.839, -0.869, -0.900, -0.932, - -0.966, -1.000, -1.036, -1.072, -1.111, -1.150, -1.192, -1.235, -1.280, -1.327, -1.376, - -1.428, -1.483, -1.540, -1.600, -1.664, -1.732, -1.804, -1.881, -1.963, -2.050, -2.144, - -2.246, -2.356, -2.475, -2.605, -2.747, -2.904, -3.078, -3.271, -3.487, -3.732, -4.011, - -4.331, -4.704, -5.144, -5.671, -6.313, -7.115, -8.144, -9.513, -11.429, -14.298, -19.077, - -28.627, -57.254, -90747.269}; -unsigned char scorched_tanks_ground_modifiers[SCREEN_WIDTH] = { - 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20, - 18, 16, 14, 12, 10, 8, 6, 4, 2, 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, 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, 0, 0, 0}; - -typedef struct { - // +-----x - // | - // | - // y - uint8_t x; - uint8_t y; -} Point; - -typedef struct { - // +-----x - // | - // | - // y - double x; - double y; -} PointDetailed; - -typedef struct { - unsigned char locationX; - unsigned char hp; - int aimAngle; - unsigned char firePower; -} Tank; - -typedef struct { - Point ground[SCREEN_WIDTH]; - Tank player; - Tank enemy; - bool isPlayerTurn; - bool isShooting; - int windSpeed; - Point trajectory[SCREEN_WIDTH]; - unsigned char trajectoryAnimationStep; - PointDetailed bulletPosition; - PointDetailed bulletVector; -} Game; - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} ScorchedTanksEvent; - -int scorched_tanks_random(int min, int max) { - return min + rand() % ((max + 1) - min); -} - -void scorched_tanks_generate_ground(Game* game_state) { - int lastHeight = 45; - - for(unsigned char a = 0; a < SCREEN_WIDTH; a++) { - int diffHeight = scorched_tanks_random(-2, 3); - int changeLength = scorched_tanks_random(1, 6); - - if(diffHeight == 0) { - changeLength = 1; - } - - for(int b = 0; b < changeLength; b++) { - if(a + b < SCREEN_WIDTH) { - int index = a + b; - int newPoint = lastHeight + diffHeight; - newPoint = newPoint < MIN_GROUND_HEIGHT ? MIN_GROUND_HEIGHT : newPoint; - newPoint = newPoint > MAX_GROUND_HEIGHT ? MAX_GROUND_HEIGHT : newPoint; - game_state->ground[index].x = index; - game_state->ground[index].y = newPoint - scorched_tanks_ground_modifiers[a]; - lastHeight = newPoint; - } else { - a += b; - break; - } - } - - a += changeLength - 1; - } -} - -void scorched_tanks_init_game(Game* game_state) { - game_state->player.locationX = PLAYER_INIT_LOCATION_X + - scorched_tanks_random(0, MAX_PLAYER_DIFF_X) - - MAX_PLAYER_DIFF_X / 2; - game_state->player.aimAngle = PLAYER_INIT_AIM; - game_state->player.firePower = PLAYER_INIT_POWER; - game_state->enemy.aimAngle = PLAYER_INIT_AIM; - game_state->enemy.firePower = PLAYER_INIT_POWER; - game_state->enemy.locationX = - ENEMY_INIT_LOCATION_X + scorched_tanks_random(0, MAX_ENEMY_DIFF_X) - MAX_ENEMY_DIFF_X / 2; - game_state->isPlayerTurn = true; - - game_state->windSpeed = scorched_tanks_random(0, MAX_WIND); - - for(int x = 0; x < SCREEN_WIDTH; x++) { - game_state->trajectory[x].x = 0; - game_state->trajectory[x].y = 0; - } - - scorched_tanks_generate_ground(game_state); -} - -void scorched_tanks_calculate_trajectory(Game* game_state) { - if(game_state->isShooting) { - game_state->bulletVector.x += ((double)game_state->windSpeed - MAX_WIND / 2) / 40; - game_state->bulletVector.y += GRAVITY_FORCE; - - game_state->bulletPosition.x += game_state->bulletVector.x; - game_state->bulletPosition.y += game_state->bulletVector.y; - - int totalDistanceToEnemy = 100; - - if(game_state->isPlayerTurn) { - double distanceToEnemyX = game_state->enemy.locationX - game_state->bulletPosition.x; - double distanceToEnemyY = game_state->ground[game_state->enemy.locationX].y - - TANK_COLLIDER_SIZE - game_state->bulletPosition.y; - totalDistanceToEnemy = - sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); - } else { - double distanceToEnemyX = game_state->player.locationX - game_state->bulletPosition.x; - double distanceToEnemyY = game_state->ground[game_state->player.locationX].y - - TANK_COLLIDER_SIZE - game_state->bulletPosition.y; - totalDistanceToEnemy = - sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); - } - - if(totalDistanceToEnemy <= TANK_COLLIDER_SIZE) { - game_state->isShooting = false; - scorched_tanks_init_game(game_state); - game_state->isPlayerTurn = !game_state->isPlayerTurn; - return; - } - - if(game_state->bulletPosition.x > SCREEN_WIDTH || - game_state->bulletPosition.y > - game_state->ground[(int)round(game_state->bulletPosition.x)].y) { - game_state->isShooting = false; - game_state->bulletPosition.x = 0; - game_state->bulletPosition.y = 0; - game_state->windSpeed = scorched_tanks_random(0, MAX_WIND); - game_state->isPlayerTurn = !game_state->isPlayerTurn; - return; - } - - if(game_state->bulletPosition.y > 0) { - game_state->trajectory[game_state->trajectoryAnimationStep].x = - round(game_state->bulletPosition.x); - game_state->trajectory[game_state->trajectoryAnimationStep].y = - round(game_state->bulletPosition.y); - game_state->trajectoryAnimationStep++; - } - } -} - -static void scorched_tanks_draw_tank( - Canvas* const canvas, - unsigned char x, - unsigned char y, - bool isPlayer) { - unsigned char lineIndex = 0; - - if(isPlayer) { - // Draw tank base - canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++); - canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); - canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); - - // draw turret - canvas_draw_line(canvas, x - 2, y - lineIndex, x + 1, y - lineIndex++); - canvas_draw_line(canvas, x - 2, y - lineIndex, x, y - lineIndex++); - } else { - // Draw tank base - canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++); - canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); - canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); - - // draw turret - canvas_draw_line(canvas, x - 1, y - lineIndex, x + 2, y - lineIndex++); - canvas_draw_line(canvas, x, y - lineIndex, x + 2, y - lineIndex++); - } -} - -static void scorched_tanks_render_callback(Canvas* const canvas, void* ctx) { - const Game* game_state = acquire_mutex((ValueMutex*)ctx, 25); - - if(game_state == NULL) { - return; - } - - canvas_draw_frame(canvas, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - - canvas_set_color(canvas, ColorBlack); - - if(game_state->isShooting) { - canvas_draw_dot(canvas, game_state->bulletPosition.x, game_state->bulletPosition.y); - } - - for(int a = 1; a < SCREEN_WIDTH; a++) { - canvas_draw_line( - canvas, - game_state->ground[a - 1].x, - game_state->ground[a - 1].y, - game_state->ground[a].x, - game_state->ground[a].y); - - if(game_state->trajectory[a].y != 0) { - canvas_draw_dot(canvas, game_state->trajectory[a].x, game_state->trajectory[a].y); - } - } - - scorched_tanks_draw_tank( - canvas, - game_state->enemy.locationX, - game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE, - true); - - scorched_tanks_draw_tank( - canvas, - game_state->player.locationX, - game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE, - false); - - int aimX1 = 0; - int aimY1 = 0; - int aimX2 = 0; - int aimY2 = 0; - - if(game_state->isPlayerTurn) { - aimX1 = game_state->player.locationX; - aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE; - - double sinFromAngle = scorched_tanks_sin[game_state->player.aimAngle]; - double cosFromAngle = scorched_tanks_cos[game_state->player.aimAngle]; - aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; - aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; - - aimX1 += 1; - aimX2 += 1; - } else { - aimX1 = game_state->enemy.locationX; - aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE; - - double sinFromAngle = scorched_tanks_sin[game_state->enemy.aimAngle]; - double cosFromAngle = scorched_tanks_cos[game_state->enemy.aimAngle]; - aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; - aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; - - aimX2 = aimX1 - (aimX2 - aimX1); - - aimX1 -= 1; - aimX2 -= 1; - } - - canvas_draw_line(canvas, aimX1, aimY1 - 3, aimX2, aimY2 - 3); - - canvas_set_font(canvas, FontSecondary); - - char buffer2[12]; - snprintf(buffer2, sizeof(buffer2), "wind: %i", game_state->windSpeed - MAX_WIND / 2); - canvas_draw_str(canvas, 55, 10, buffer2); - - if(game_state->isPlayerTurn) { - canvas_draw_str(canvas, 93, 10, "player1"); - - char buffer[12]; - snprintf(buffer, sizeof(buffer), "a: %u", game_state->player.aimAngle); - canvas_draw_str(canvas, 2, 10, buffer); - - snprintf(buffer, sizeof(buffer), "p: %u", game_state->player.firePower); - canvas_draw_str(canvas, 27, 10, buffer); - } else { - canvas_draw_str(canvas, 93, 10, "player2"); - - char buffer[12]; - snprintf(buffer, sizeof(buffer), "a: %u", game_state->enemy.aimAngle); - canvas_draw_str(canvas, 2, 10, buffer); - - snprintf(buffer, sizeof(buffer), "p: %u", game_state->enemy.firePower); - canvas_draw_str(canvas, 27, 10, buffer); - } - - release_mutex((ValueMutex*)ctx, game_state); -} - -static void scorched_tanks_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - ScorchedTanksEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void scorched_tanks_update_timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - ScorchedTanksEvent event = {.type = EventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -static void scorched_tanks_increase_power(Game* game_state) { - if(game_state->player.firePower < MAX_FIRE_POWER && !game_state->isShooting) { - if(game_state->isPlayerTurn && game_state->player.firePower < MAX_FIRE_POWER) { - game_state->player.firePower++; - } - - if(!game_state->isPlayerTurn && game_state->enemy.firePower < MAX_FIRE_POWER) { - game_state->enemy.firePower++; - } - } -} - -static void scorched_tanks_decrease_power(Game* game_state) { - if(game_state->player.firePower > MIN_FIRE_POWER && !game_state->isShooting) { - if(game_state->isPlayerTurn && game_state->player.firePower > MIN_FIRE_POWER) { - game_state->player.firePower--; - } - - if(!game_state->isPlayerTurn && game_state->enemy.firePower > MIN_FIRE_POWER) { - game_state->enemy.firePower--; - } - } -} - -static void scorched_tanks_aim_up(Game* game_state) { - if(!game_state->isShooting) { - if(game_state->isPlayerTurn && game_state->player.aimAngle < 90) { - game_state->player.aimAngle++; - } - - if(!game_state->isPlayerTurn && game_state->enemy.aimAngle < 90) { - game_state->enemy.aimAngle++; - } - } -} - -static void scorched_tanks_aim_down(Game* game_state) { - if(game_state->player.aimAngle > 0 && !game_state->isShooting) { - if(game_state->isPlayerTurn) { - game_state->player.aimAngle--; - } else { - game_state->enemy.aimAngle--; - } - } -} - -const NotificationSequence sequence_long_vibro = { - &message_vibro_on, - &message_delay_500, - &message_vibro_off, - NULL, -}; - -static void scorched_tanks_fire(Game* game_state) { - if(!game_state->isShooting) { - if(game_state->isPlayerTurn) { - double sinFromAngle = scorched_tanks_sin[game_state->player.aimAngle]; - double cosFromAngle = scorched_tanks_cos[game_state->player.aimAngle]; - unsigned char aimX1 = game_state->player.locationX; - unsigned char aimY1 = - game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE; - int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; - int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; - game_state->bulletPosition.x = aimX2; - game_state->bulletPosition.y = aimY2; - game_state->bulletVector.x = scorched_tanks_cos[game_state->player.aimAngle] * - ((double)game_state->player.firePower / 10); - game_state->bulletVector.y = scorched_tanks_sin[game_state->player.aimAngle] * - ((double)game_state->player.firePower / 10); - } else { - double sinFromAngle = scorched_tanks_sin[game_state->enemy.aimAngle]; - double cosFromAngle = scorched_tanks_cos[game_state->enemy.aimAngle]; - unsigned char aimX1 = game_state->enemy.locationX; - unsigned char aimY1 = - game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE; - int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; - int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; - aimX2 = aimX1 - (aimX2 - aimX1); - - game_state->bulletPosition.x = aimX2; - game_state->bulletPosition.y = aimY2; - game_state->bulletVector.x = -scorched_tanks_cos[game_state->enemy.aimAngle] * - ((double)game_state->enemy.firePower / 10); - game_state->bulletVector.y = scorched_tanks_sin[game_state->enemy.aimAngle] * - ((double)game_state->enemy.firePower / 10); - } - - game_state->trajectoryAnimationStep = 0; - - for(int x = 0; x < SCREEN_WIDTH; x++) { - game_state->trajectory[x].x = 0; - game_state->trajectory[x].y = 0; - } - - game_state->isShooting = true; - - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_long_vibro); - notification_message(notification, &sequence_blink_white_100); - furi_record_close("notification"); - } -} - -int32_t scorched_tanks_game_app(void* p) { - UNUSED(p); - srand(DWT->CYCCNT); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(ScorchedTanksEvent)); - - Game* game_state = malloc(sizeof(Game)); - scorched_tanks_init_game(game_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, game_state, sizeof(ScorchedTanksEvent))) { - FURI_LOG_E("ScorchedTanks", "cannot create mutex\r\n"); - free(game_state); - return 255; - } - - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, scorched_tanks_render_callback, &state_mutex); - view_port_input_callback_set(view_port, scorched_tanks_input_callback, event_queue); - - FuriTimer* timer = - furi_timer_alloc(scorched_tanks_update_timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, 2000); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - ScorchedTanksEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 50); - - if(event.type == EventTypeKey) { // && game->isPlayerTurn - if(event.input.type == InputTypeRepeat || event.input.type == InputTypeShort) { - switch(event.input.key) { - case InputKeyUp: - scorched_tanks_aim_up(game_state); - break; - case InputKeyDown: - scorched_tanks_aim_down(game_state); - break; - case InputKeyRight: - scorched_tanks_increase_power(game_state); - break; - case InputKeyLeft: - scorched_tanks_decrease_power(game_state); - break; - case InputKeyOk: - scorched_tanks_fire(game_state); - break; - case InputKeyBack: - processing = false; - break; - default: - break; - } - } - } else if(event.type == EventTypeTick) { - scorched_tanks_calculate_trajectory(game_state); - } - - view_port_update(view_port); - release_mutex(&state_mutex, game_state); - } - - furi_timer_free(timer); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - free(game_state); - - return 0; -} diff --git a/applications/plugins/scorched_tanks/scorched_tanks_v1.gif b/applications/plugins/scorched_tanks/scorched_tanks_v1.gif deleted file mode 100644 index 45b2ce117..000000000 Binary files a/applications/plugins/scorched_tanks/scorched_tanks_v1.gif and /dev/null differ diff --git a/applications/plugins/tama_p1/README.md b/applications/plugins/tama_p1/README.md deleted file mode 100644 index 20690c7a2..000000000 --- a/applications/plugins/tama_p1/README.md +++ /dev/null @@ -1,35 +0,0 @@ -Tama P1 Emulator for Flipper Zero -======================================= - -This is a tama P1 Emulator app for Flipper Zero, based on [TamaLIB](https://github.com/jcrona/tamalib/). - -How to play ------------ -Create a `tama_p1` folder in your microSD card, and put the ROM as `rom.bin`. -Left button is A, OK is B, and right button is C. Hold the back button to exit. -There is currently no saving, so your progress will be reset when you exit the -app. - -Building --------- -Run the following to compile icons: -``` -scripts/assets.py icons applications/tama_p1/icons applications/tama_p1/compiled -``` - -Note: you may also need to add `-Wno-unused-parameter` to `CCFLAGS` in -`site_cons/cc.scons` to suppress unused parameter errors in TamaLIB. - -Implemented ------------ -- Basic emulation -- Input -- Sound - -To-do ------ -- Saving/loading - - Multiple slots? -- In-game reset -- Test mode? -- Volume adjustment diff --git a/applications/plugins/tama_p1/application.fam b/applications/plugins/tama_p1/application.fam deleted file mode 100644 index 6059f8ed0..000000000 --- a/applications/plugins/tama_p1/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="TAMA_P1", - name="TAMA P1", - apptype=FlipperAppType.EXTERNAL, - entry_point="tama_p1_app", - cdefines=["APP_TAMA_P1"], - requires=["gui", "storage"], - stack_size=1 * 1024, - order=215, - fap_icon="tamaIcon.png", - fap_category="Games", -) diff --git a/applications/plugins/tama_p1/compiled/assets_icons.h b/applications/plugins/tama_p1/compiled/assets_icons.h deleted file mode 100644 index aa2735b72..000000000 --- a/applications/plugins/tama_p1/compiled/assets_icons.h +++ /dev/null @@ -1,66 +0,0 @@ -#include - -const uint8_t _I_icon_0_0[] = { - 0x01, 0x00, 0x1a, 0x00, 0x00, 0x0d, 0xaa, 0x1d, 0x7e, 0x00, 0x9c, 0x3e, 0xf9, 0x0f, 0x9e, - 0x43, 0xe3, 0x00, 0x12, 0x9c, 0x43, 0xa7, 0x10, 0xc9, 0xe4, 0x30, 0x0a, 0x31, 0x08, 0x60, -}; -const uint8_t* const _I_icon_0[] = {_I_icon_0_0}; - -const uint8_t _I_icon_1_0[] = { - 0x00, 0x00, 0x00, 0x40, 0x04, 0x04, 0x04, 0xf0, 0x11, 0xf9, 0x1b, 0xf8, 0x07, 0x8c, 0x06, - 0xed, 0x36, 0xac, 0x26, 0xe8, 0x02, 0x52, 0x0b, 0x02, 0x18, 0xe0, 0x01, 0xe0, 0x01, -}; -const uint8_t* const _I_icon_1[] = {_I_icon_1_0}; - -const uint8_t _I_icon_2_0[] = { - 0x00, 0x00, 0x00, 0x0e, 0x00, 0x13, 0x00, 0x21, 0x3c, 0x21, 0x3e, 0x23, 0x3f, 0x9f, 0x1f, - 0xc0, 0x0f, 0xe0, 0x07, 0xf0, 0x01, 0x7c, 0x00, 0x1f, 0x00, 0x06, 0x00, 0x06, 0x00, -}; -const uint8_t* const _I_icon_2[] = {_I_icon_2_0}; - -const uint8_t _I_icon_3_0[] = { - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x1c, 0x40, 0x3a, 0xc0, 0x36, 0xf0, 0x37, 0x18, 0x2d, - 0x0c, 0x2b, 0x0e, 0x02, 0x1f, 0x06, 0x3e, 0x07, 0xfe, 0x00, 0x7f, 0x00, 0x18, 0x00, -}; -const uint8_t* const _I_icon_3[] = {_I_icon_3_0}; - -const uint8_t _I_icon_4_0[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xc7, 0x3c, 0x82, 0x2f, 0xf2, 0x26, 0xc7, 0x2c, - 0x69, 0x28, 0x2f, 0x2c, 0xe7, 0x27, 0x02, 0x20, 0x02, 0x30, 0x06, 0x1c, 0xfc, 0x0f, -}; -const uint8_t* const _I_icon_4[] = {_I_icon_4_0}; - -const uint8_t _I_icon_5_0[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0xfe, 0x0f, 0x03, 0x38, 0xc9, 0x22, 0x9a, 0x32, - 0xa2, 0x28, 0x24, 0x2c, 0x21, 0x20, 0x61, 0x30, 0x21, 0x10, 0xf3, 0x11, 0x1e, 0x0f, -}; -const uint8_t* const _I_icon_5[] = {_I_icon_5_0}; - -const uint8_t _I_icon_6_0[] = { - 0x01, 0x00, 0x17, 0x00, 0x00, 0x44, 0x62, 0xfd, 0x38, 0xbf, 0xcf, 0xb7, 0xf3, 0xf8, - 0xfc, 0x6e, 0x3f, 0x1a, 0xff, 0xc0, 0x3f, 0xf0, 0x1f, 0xf4, 0x02, 0x71, 0x00, -}; -const uint8_t* const _I_icon_6[] = {_I_icon_6_0}; - -const uint8_t _I_icon_7_0[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x41, 0x0e, 0xc4, 0x1f, 0x94, 0x20, - 0x00, 0x21, 0x22, 0x1f, 0x1d, 0x0a, 0x63, 0x20, 0xde, 0x20, 0x80, 0x1f, 0x00, 0x0e, -}; -const uint8_t* const _I_icon_7[] = {_I_icon_7_0}; - -const Icon I_icon_0 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_0}; -const Icon I_icon_1 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_1}; -const Icon I_icon_2 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_2}; -const Icon I_icon_3 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_3}; -const Icon I_icon_4 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_4}; -const Icon I_icon_5 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_5}; -const Icon I_icon_6 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_6}; -const Icon I_icon_7 = - {.width = 14, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_icon_7}; \ No newline at end of file diff --git a/applications/plugins/tama_p1/hal.c b/applications/plugins/tama_p1/hal.c deleted file mode 100644 index c862e44b3..000000000 --- a/applications/plugins/tama_p1/hal.c +++ /dev/null @@ -1,137 +0,0 @@ -#include -#include -#include -#include -#include "tama.h" - -#define TAG_HAL "TamaLIB" - -static void* tama_p1_hal_malloc(u32_t size) { - return malloc(size); -} - -static void tama_p1_hal_free(void* ptr) { - free(ptr); -} - -static void tama_p1_hal_halt(void) { - g_ctx->halted = true; -} - -static bool_t tama_p1_hal_is_log_enabled(log_level_t level) { - switch(level) { - case LOG_ERROR: - return true; - case LOG_INFO: - return true; - case LOG_MEMORY: - return false; - case LOG_CPU: - return false; - default: - return false; - } -} - -static void tama_p1_hal_log(log_level_t level, char* buff, ...) { - if(!tama_p1_hal_is_log_enabled(level)) return; - - FuriString* string; - va_list args; - va_start(args, buff); - furi_string_cat_vprintf(string, buff, args); - va_end(args); - - switch(level) { - case LOG_ERROR: - FURI_LOG_E(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - case LOG_INFO: - FURI_LOG_I(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - case LOG_MEMORY: - case LOG_CPU: - default: - FURI_LOG_D(TAG_HAL, "%s", furi_string_get_cstr(string)); - break; - } - - furi_string_free(string); -} - -static void tama_p1_hal_sleep_until(timestamp_t ts) { - while(true) { - uint32_t count = LL_TIM_GetCounter(TIM2); - uint32_t delay = ts - count; - // FURI_LOG_D(TAG, "delay: %x", delay); - // Stolen from furi_delay_until_tick - if(delay != 0 && 0 == (delay >> (8 * sizeof(uint32_t) - 1))) { - // Not the best place to release mutex, but this is the only place we know whether - // we're ahead or behind, otherwise around the step call we'll always have to - // delay a tick and run more and more behind. - furi_mutex_release(g_state_mutex); - furi_delay_tick(1); - while(furi_mutex_acquire(g_state_mutex, FuriWaitForever) != FuriStatusOk) - furi_delay_tick(1); - } else { - break; - } - } -} - -static timestamp_t tama_p1_hal_get_timestamp(void) { - return LL_TIM_GetCounter(TIM2); -} - -static void tama_p1_hal_update_screen(void) { - // Do nothing, covered by main loop -} - -static void tama_p1_hal_set_lcd_matrix(u8_t x, u8_t y, bool_t val) { - if(val) - g_ctx->framebuffer[y] |= 1 << x; - else - g_ctx->framebuffer[y] &= ~(1 << x); -} - -static void tama_p1_hal_set_lcd_icon(u8_t icon, bool_t val) { - if(val) - g_ctx->icons |= 1 << icon; - else - g_ctx->icons &= ~(1 << icon); -} - -static void tama_p1_hal_play_frequency(bool_t en) { - if(en) - furi_hal_speaker_start(g_ctx->frequency, 0.5f); - else - furi_hal_speaker_stop(); - - g_ctx->buzzer_on = en; -} - -static void tama_p1_hal_set_frequency(u32_t freq) { - g_ctx->frequency = freq / 10.0F; - if(g_ctx->buzzer_on) tama_p1_hal_play_frequency(true); -} - -static int tama_p1_hal_handler(void) { - // Do nothing - return 0; -} - -void tama_p1_hal_init(hal_t* hal) { - hal->malloc = tama_p1_hal_malloc; - hal->free = tama_p1_hal_free; - hal->halt = tama_p1_hal_halt; - hal->is_log_enabled = tama_p1_hal_is_log_enabled; - hal->log = tama_p1_hal_log; - hal->sleep_until = tama_p1_hal_sleep_until; - hal->get_timestamp = tama_p1_hal_get_timestamp; - hal->update_screen = tama_p1_hal_update_screen; - hal->set_lcd_matrix = tama_p1_hal_set_lcd_matrix; - hal->set_lcd_icon = tama_p1_hal_set_lcd_icon; - hal->set_frequency = tama_p1_hal_set_frequency; - hal->play_frequency = tama_p1_hal_play_frequency; - hal->handler = tama_p1_hal_handler; -} \ No newline at end of file diff --git a/applications/plugins/tama_p1/hal_types.h b/applications/plugins/tama_p1/hal_types.h deleted file mode 100644 index d27e6dfbe..000000000 --- a/applications/plugins/tama_p1/hal_types.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * TamaLIB - A hardware agnostic tama P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _HAL_TYPES_H_ -#define _HAL_TYPES_H_ - -#include - -typedef bool bool_t; -typedef uint8_t u4_t; -typedef uint8_t u5_t; -typedef uint8_t u8_t; -typedef uint16_t u12_t; -typedef uint16_t u13_t; -typedef uint32_t u32_t; -typedef uint32_t - timestamp_t; // WARNING: Must be an unsigned type to properly handle wrapping (u32 wraps in around 1h11m when expressed in us) - -#endif /* _HAL_TYPES_H_ */ diff --git a/applications/plugins/tama_p1/icons/icon_0.png b/applications/plugins/tama_p1/icons/icon_0.png deleted file mode 100644 index 7b94d3511..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_0.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_1.png b/applications/plugins/tama_p1/icons/icon_1.png deleted file mode 100644 index 934cf7187..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_1.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_2.png b/applications/plugins/tama_p1/icons/icon_2.png deleted file mode 100644 index b83e449d9..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_2.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_3.png b/applications/plugins/tama_p1/icons/icon_3.png deleted file mode 100644 index 34f4db24d..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_3.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_4.png b/applications/plugins/tama_p1/icons/icon_4.png deleted file mode 100644 index fe02b83af..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_4.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_5.png b/applications/plugins/tama_p1/icons/icon_5.png deleted file mode 100644 index 889acd50e..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_5.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_6.png b/applications/plugins/tama_p1/icons/icon_6.png deleted file mode 100644 index 57d2f181b..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_6.png and /dev/null differ diff --git a/applications/plugins/tama_p1/icons/icon_7.png b/applications/plugins/tama_p1/icons/icon_7.png deleted file mode 100644 index 4ff6e504a..000000000 Binary files a/applications/plugins/tama_p1/icons/icon_7.png and /dev/null differ diff --git a/applications/plugins/tama_p1/tama.h b/applications/plugins/tama_p1/tama.h deleted file mode 100644 index d3b67b90d..000000000 --- a/applications/plugins/tama_p1/tama.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include "tamalib/tamalib.h" - -#define TAG "TamaP1" -#define TAMA_ROM_PATH EXT_PATH("tama_p1/rom.bin") -#define TAMA_SCREEN_SCALE_FACTOR 2 -#define TAMA_LCD_ICON_SIZE 14 -#define TAMA_LCD_ICON_MARGIN 1 - -typedef struct { - FuriThread* thread; - hal_t hal; - uint8_t* rom; - // 32x16 screen, perfectly represented through uint32_t - uint32_t framebuffer[16]; - uint8_t icons; - bool halted; - bool fast_forward_done; - bool buzzer_on; - float frequency; -} TamaApp; - -typedef enum { - EventTypeInput, - EventTypeTick, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} TamaEvent; - -extern TamaApp* g_ctx; -extern FuriMutex* g_state_mutex; - -void tama_p1_hal_init(hal_t* hal); diff --git a/applications/plugins/tama_p1/tamaIcon.png b/applications/plugins/tama_p1/tamaIcon.png deleted file mode 100644 index 1962b68ae..000000000 Binary files a/applications/plugins/tama_p1/tamaIcon.png and /dev/null differ diff --git a/applications/plugins/tama_p1/tama_p1.c b/applications/plugins/tama_p1/tama_p1.c deleted file mode 100644 index f2da6b394..000000000 --- a/applications/plugins/tama_p1/tama_p1.c +++ /dev/null @@ -1,299 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "tamalib/tamalib.h" -#include "tama.h" -#include "compiled/assets_icons.h" - -TamaApp* g_ctx; -FuriMutex* g_state_mutex; - -static const Icon* icons_list[] = { - &I_icon_0, - &I_icon_1, - &I_icon_2, - &I_icon_3, - &I_icon_4, - &I_icon_5, - &I_icon_6, - &I_icon_7, -}; - -static void tama_p1_draw_callback(Canvas* const canvas, void* cb_ctx) { - furi_assert(cb_ctx); - - FuriMutex* const mutex = cb_ctx; - if(furi_mutex_acquire(mutex, 25) != FuriStatusOk) return; - - if(g_ctx->rom == NULL) { - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 30, 30, "No ROM"); - } else if(g_ctx->halted) { - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 30, 30, "Halted"); - } else { - // FURI_LOG_D(TAG, "Drawing frame"); - // Calculate positioning - uint16_t canv_width = canvas_width(canvas); - uint16_t canv_height = canvas_height(canvas); - uint16_t lcd_matrix_scaled_width = 32 * TAMA_SCREEN_SCALE_FACTOR; - uint16_t lcd_matrix_scaled_height = 16 * TAMA_SCREEN_SCALE_FACTOR; - uint16_t lcd_matrix_top = (canv_height - lcd_matrix_scaled_height) / 2; - uint16_t lcd_matrix_left = (canv_width - lcd_matrix_scaled_width) / 2; - uint16_t lcd_icon_upper_top = lcd_matrix_top - TAMA_LCD_ICON_SIZE - TAMA_LCD_ICON_MARGIN; - uint16_t lcd_icon_upper_left = lcd_matrix_left; - uint16_t lcd_icon_lower_top = - lcd_matrix_top + lcd_matrix_scaled_height + TAMA_LCD_ICON_MARGIN; - uint16_t lcd_icon_lower_left = lcd_matrix_left; - uint16_t lcd_icon_spacing_horiz = - (lcd_matrix_scaled_width - (4 * TAMA_LCD_ICON_SIZE)) / 3 + TAMA_LCD_ICON_SIZE; - - // Draw pixels - // canvas_draw_frame( - // canvas, - // lcd_matrix_left, - // lcd_matrix_top, - // lcd_matrix_scaled_width, - // lcd_matrix_scaled_height); - - uint16_t y = lcd_matrix_top; - for(uint8_t row = 0; row < 16; ++row) { - uint16_t x = lcd_matrix_left; - uint32_t row_pixels = g_ctx->framebuffer[row]; - for(uint8_t col = 0; col < 32; ++col) { - if(row_pixels & 1) { - canvas_draw_box( - canvas, x, y, TAMA_SCREEN_SCALE_FACTOR, TAMA_SCREEN_SCALE_FACTOR); - } - x += TAMA_SCREEN_SCALE_FACTOR; - row_pixels >>= 1; - } - y += TAMA_SCREEN_SCALE_FACTOR; - } - - // Draw icons - uint8_t lcd_icons = g_ctx->icons; - // Top - y = lcd_icon_upper_top; - uint16_t x_ic = lcd_icon_upper_left; - for(uint8_t i = 0; i < 4; ++i) { - // canvas_draw_frame(canvas, x_ic, y, TAMA_LCD_ICON_SIZE, TAMA_LCD_ICON_SIZE); - if(lcd_icons & 1) { - canvas_draw_icon(canvas, x_ic, y, icons_list[i]); - } - x_ic += lcd_icon_spacing_horiz; - lcd_icons >>= 1; - } - - // Bottom - y = lcd_icon_lower_top; - x_ic = lcd_icon_lower_left; - for(uint8_t i = 4; i < 8; ++i) { - // canvas_draw_frame(canvas, x_ic, y, TAMA_LCD_ICON_SIZE, TAMA_LCD_ICON_SIZE); - if(lcd_icons & 1) { - canvas_draw_icon(canvas, x_ic, y, icons_list[i]); - } - x_ic += lcd_icon_spacing_horiz; - lcd_icons >>= 1; - } - } - - furi_mutex_release(mutex); -} - -static void tama_p1_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - TamaEvent event = {.type = EventTypeInput, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void tama_p1_update_timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - TamaEvent event = {.type = EventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -static int32_t tama_p1_worker(void* context) { - bool running = true; - FuriMutex* mutex = context; - while(furi_mutex_acquire(mutex, FuriWaitForever) != FuriStatusOk) furi_delay_tick(1); - - cpu_sync_ref_timestamp(); - LL_TIM_EnableCounter(TIM2); - while(running) { - if(furi_thread_flags_get()) { - running = false; - } else { - // FURI_LOG_D(TAG, "Stepping"); - // for (int i = 0; i < 100; ++i) - tamalib_step(); - } - } - LL_TIM_DisableCounter(TIM2); - furi_mutex_release(mutex); - return 0; -} - -static void tama_p1_init(TamaApp* const ctx) { - g_ctx = ctx; - memset(ctx, 0, sizeof(TamaApp)); - tama_p1_hal_init(&ctx->hal); - - // Load ROM - Storage* storage = furi_record_open(RECORD_STORAGE); - FileInfo fi; - if(storage_common_stat(storage, TAMA_ROM_PATH, &fi) == FSE_OK) { - File* rom_file = storage_file_alloc(storage); - if(storage_file_open(rom_file, TAMA_ROM_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) { - ctx->rom = malloc((size_t)fi.size); - uint8_t* buf_ptr = ctx->rom; - size_t read = 0; - while(read < fi.size) { - size_t to_read = fi.size - read; - if(to_read > UINT16_MAX) to_read = UINT16_MAX; - uint16_t now_read = storage_file_read(rom_file, buf_ptr, (uint16_t)to_read); - read += now_read; - buf_ptr += now_read; - } - - // Reorder endianess of ROM - for(size_t i = 0; i < fi.size; i += 2) { - uint8_t b = ctx->rom[i]; - ctx->rom[i] = ctx->rom[i + 1]; - ctx->rom[i + 1] = b & 0xF; - } - } - - storage_file_close(rom_file); - storage_file_free(rom_file); - } - furi_record_close(RECORD_STORAGE); - - if(ctx->rom != NULL) { - // Init TIM2 - // 64KHz - LL_TIM_InitTypeDef tim_init = { - .Prescaler = 999, - .CounterMode = LL_TIM_COUNTERMODE_UP, - .Autoreload = 0xFFFFFFFF, - }; - LL_TIM_Init(TIM2, &tim_init); - LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL); - LL_TIM_DisableCounter(TIM2); - LL_TIM_SetCounter(TIM2, 0); - - // Init TamaLIB - tamalib_register_hal(&ctx->hal); - tamalib_init((u12_t*)ctx->rom, NULL, 64000); - tamalib_set_speed(1); - - // TODO: implement fast forwarding - ctx->fast_forward_done = true; - - // Start stepping thread - ctx->thread = furi_thread_alloc(); - furi_thread_set_name(ctx->thread, "TamaLIB"); - furi_thread_set_stack_size(ctx->thread, 1024); - furi_thread_set_callback(ctx->thread, tama_p1_worker); - furi_thread_set_context(ctx->thread, g_state_mutex); - furi_thread_start(ctx->thread); - } -} - -static void tama_p1_deinit(TamaApp* const ctx) { - if(ctx->rom != NULL) { - tamalib_release(); - furi_thread_free(ctx->thread); - free(ctx->rom); - } -} - -int32_t tama_p1_app(void* p) { - UNUSED(p); - - TamaApp* ctx = malloc(sizeof(TamaApp)); - g_state_mutex = furi_mutex_alloc(FuriMutexTypeRecursive); - tama_p1_init(ctx); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(TamaEvent)); - - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, tama_p1_draw_callback, g_state_mutex); - view_port_input_callback_set(view_port, tama_p1_input_callback, event_queue); - - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - FuriTimer* timer = - furi_timer_alloc(tama_p1_update_timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, furi_kernel_get_tick_frequency() / 30); - - for(bool running = true; running;) { - TamaEvent event; - FuriStatus event_status = furi_message_queue_get(event_queue, &event, FuriWaitForever); - if(event_status == FuriStatusOk) { - // Local override with acquired context - if(furi_mutex_acquire(g_state_mutex, FuriWaitForever) != FuriStatusOk) continue; - - if(event.type == EventTypeTick) { - // FURI_LOG_D(TAG, "EventTypeTick"); - view_port_update(view_port); - } else if(event.type == EventTypeInput) { - FURI_LOG_D( - TAG, - "EventTypeInput: %d %d %d", - event.input.sequence, - event.input.key, - event.input.type); - InputType input_type = event.input.type; - if(input_type == InputTypePress || input_type == InputTypeRelease) { - btn_state_t tama_btn_state = 0; - if(input_type == InputTypePress) - tama_btn_state = BTN_STATE_PRESSED; - else if(input_type == InputTypeRelease) - tama_btn_state = BTN_STATE_RELEASED; - - if(event.input.key == InputKeyLeft) { - tamalib_set_button(BTN_LEFT, tama_btn_state); - } else if(event.input.key == InputKeyOk) { - tamalib_set_button(BTN_MIDDLE, tama_btn_state); - } else if(event.input.key == InputKeyRight) { - tamalib_set_button(BTN_RIGHT, tama_btn_state); - } - } - - if(event.input.key == InputKeyBack && event.input.type == InputTypeLong) { - furi_timer_stop(timer); - running = false; - } - } - - furi_mutex_release(g_state_mutex); - } else { - // Timeout - // FURI_LOG_D(TAG, "Timed out"); - } - } - - if(ctx->rom != NULL) { - furi_thread_flags_set(furi_thread_get_id(ctx->thread), 1); - furi_thread_join(ctx->thread); - } - - furi_timer_free(timer); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(event_queue); - furi_mutex_free(g_state_mutex); - tama_p1_deinit(ctx); - free(ctx); - - return 0; -} diff --git a/applications/plugins/tama_p1/tamalib/LICENSE b/applications/plugins/tama_p1/tamalib/LICENSE deleted file mode 100644 index d159169d1..000000000 --- a/applications/plugins/tama_p1/tamalib/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 2 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/applications/plugins/tama_p1/tamalib/README.md b/applications/plugins/tama_p1/tamalib/README.md deleted file mode 100644 index add42da1a..000000000 --- a/applications/plugins/tama_p1/tamalib/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - - -## Synopsis - -TamaLib is a hardware agnostic Tamagotchi P1 emulation library built from scratch. It is self-contained and aims at running on any platform powerful enough, from microcontrollers (MCUs) to desktop computers, thus spreading virtual life across the digital world. - -So far, it has been successfully implemented on different platforms: -- Desktop computers (check out [TamaTool](https://github.com/jcrona/tamatool/) for more information) -- STM32F072 MCU based board (check out [MCUGotchi](https://github.com/jcrona/mcugotchi/) for more information). -- OpenTama which is an STM32L072 MCU based board (check out [OpenTama](https://github.com/Sparkr-tech/opentama) and [MCUGotchi](https://github.com/jcrona/mcugotchi/) for more information). -- Arduino UNO (check out [ArduinoGotchi](https://github.com/GaryZ88/ArduinoGotchi/) for more information). - -## Importing TamaLIB - -TamaLIB cannot be used as is. In order to create life on a specific target, you need to import all TamaLIB related __.c__ and __.h__ files in your project (for instance in a __lib__ subfolder), to create a __hal_types.h__ file using the template provided and to implement the __hal_t__ structure, that will act as an abstraction layer between TamaLIB and your OS or SDK (detailed information can be found in __hal.h__). This abstraction layer basically connects TamaLIB to your target's buttons, clock, audio and screen, while also defining the C types that TamaLIB should use to represent 4-bit, 5-bit, 8-bit, 12-bit, 13-bit and 32-bit variables. Once done, you will be able to call the TamaLIB API from your project. - - -## Using the TamaLIB API - -Basically: -``` -/* ... */ - -/* Register the HAL */ -tamalib_register_hal(&my_hal); - -/* ... */ - -/* Initialize TamaLIB */ -tamalib_init(my_program, my_breakpoints, 1000000); // my_breakpoints can be NULL, 1000000 means that timestamps will be expressed in us - -/* ... */ - -/* Enter TamaLIB's loop */ -tamalib_mainloop(); - -/* ... */ - -/* Release TamaLIB */ -tamalib_release(); - -/* ... */ -``` -Your main project should then forward any button input to TamaLIB using the `tamalib_set_button()` function. - -As an alternative to `tamalib_mainloop()`, you can call `tamalib_step()` directly if your execution flow requires something more complex than a simple mainloop. In that case, TamaLIB will neither call the HAL `handler()` function, nor the HAL `update_screen()` function by itslef. - - -## License - -TamaLIB is distributed under the GPLv2 license. See the LICENSE file for more information. - - -## Hardware information - -The Tamagotchi P1 is based on an -[E0C6S46 Epson MCU](https://download.epson-europe.com/pub/electronics-de/asmic/4bit/62family/technicalmanual/tm_6s46.pdf), -and runs at 32,768 kHz. Its LCD is 32x16 B/W pixels, with 8 icons. -To my knowledge, the ROM available online has been extracted from a high-res picture of a die. The ROM mask was clear enough to be optically read. The pictures can be seen [there](https://siliconpr0n.org/map/bandai/tamagotchi-v1/) (thx asterick for the link !). -I would love to see the same work done on a P2 and add support for it in TamaLIB/TamaTool ! - -__ -Copyright (C) 2021 Jean-Christophe Rona diff --git a/applications/plugins/tama_p1/tamalib/cpu.c b/applications/plugins/tama_p1/tamalib/cpu.c deleted file mode 100644 index 3f422c2d6..000000000 --- a/applications/plugins/tama_p1/tamalib/cpu.c +++ /dev/null @@ -1,2033 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "cpu.h" -#include "hw.h" -#include "hal.h" - -#define TICK_FREQUENCY 32768 // Hz - -#define TIMER_1HZ_PERIOD 32768 // in ticks -#define TIMER_256HZ_PERIOD 128 // in ticks - -#define MASK_4B 0xF00 -#define MASK_6B 0xFC0 -#define MASK_7B 0xFE0 -#define MASK_8B 0xFF0 -#define MASK_10B 0xFFC -#define MASK_12B 0xFFF - -#define PCS (pc & 0xFF) -#define PCSL (pc & 0xF) -#define PCSH ((pc >> 4) & 0xF) -#define PCP ((pc >> 8) & 0xF) -#define PCB ((pc >> 12) & 0x1) -#define TO_PC(bank, page, step) ((step & 0xFF) | ((page & 0xF) << 8) | (bank & 0x1) << 12) -#define NBP ((np >> 4) & 0x1) -#define NPP (np & 0xF) -#define TO_NP(bank, page) ((page & 0xF) | (bank & 0x1) << 4) -#define XHL (x & 0xFF) -#define XL (x & 0xF) -#define XH ((x >> 4) & 0xF) -#define XP ((x >> 8) & 0xF) -#define YHL (y & 0xFF) -#define YL (y & 0xF) -#define YH ((y >> 4) & 0xF) -#define YP ((y >> 8) & 0xF) -#define M(n) get_memory(n) -#define SET_M(n, v) set_memory(n, v) -#define RQ(i) get_rq(i) -#define SET_RQ(i, v) set_rq(i, v) -#define SPL (sp & 0xF) -#define SPH ((sp >> 4) & 0xF) - -#define FLAG_C (0x1 << 0) -#define FLAG_Z (0x1 << 1) -#define FLAG_D (0x1 << 2) -#define FLAG_I (0x1 << 3) - -#define C !!(flags & FLAG_C) -#define Z !!(flags & FLAG_Z) -#define D !!(flags & FLAG_D) -#define I !!(flags & FLAG_I) - -#define SET_C() \ - { flags |= FLAG_C; } -#define CLEAR_C() \ - { flags &= ~FLAG_C; } -#define SET_Z() \ - { flags |= FLAG_Z; } -#define CLEAR_Z() \ - { flags &= ~FLAG_Z; } -#define SET_D() \ - { flags |= FLAG_D; } -#define CLEAR_D() \ - { flags &= ~FLAG_D; } -#define SET_I() \ - { flags |= FLAG_I; } -#define CLEAR_I() \ - { flags &= ~FLAG_I; } - -#define REG_CLK_INT_FACTOR_FLAGS 0xF00 -#define REG_SW_INT_FACTOR_FLAGS 0xF01 -#define REG_PROG_INT_FACTOR_FLAGS 0xF02 -#define REG_SERIAL_INT_FACTOR_FLAGS 0xF03 -#define REG_K00_K03_INT_FACTOR_FLAGS 0xF04 -#define REG_K10_K13_INT_FACTOR_FLAGS 0xF05 -#define REG_CLOCK_INT_MASKS 0xF10 -#define REG_SW_INT_MASKS 0xF11 -#define REG_PROG_INT_MASKS 0xF12 -#define REG_SERIAL_INT_MASKS 0xF13 -#define REG_K00_K03_INT_MASKS 0xF14 -#define REG_K10_K13_INT_MASKS 0xF15 -#define REG_PROG_TIMER_DATA_L 0xF24 -#define REG_PROG_TIMER_DATA_H 0xF25 -#define REG_PROG_TIMER_RELOAD_DATA_L 0xF26 -#define REG_PROG_TIMER_RELOAD_DATA_H 0xF27 -#define REG_K00_K03_INPUT_PORT 0xF40 -#define REG_K10_K13_INPUT_PORT 0xF42 -#define REG_K40_K43_BZ_OUTPUT_PORT 0xF54 -#define REG_CPU_OSC3_CTRL 0xF70 -#define REG_LCD_CTRL 0xF71 -#define REG_LCD_CONTRAST 0xF72 -#define REG_SVD_CTRL 0xF73 -#define REG_BUZZER_CTRL1 0xF74 -#define REG_BUZZER_CTRL2 0xF75 -#define REG_CLK_WD_TIMER_CTRL 0xF76 -#define REG_SW_TIMER_CTRL 0xF77 -#define REG_PROG_TIMER_CTRL 0xF78 -#define REG_PROG_TIMER_CLK_SEL 0xF79 - -#define INPUT_PORT_NUM 2 - -typedef struct { - char* log; - u12_t code; - u12_t mask; - u12_t shift_arg0; - u12_t mask_arg0; // != 0 only if there are two arguments - u8_t cycles; - void (*cb)(u8_t arg0, u8_t arg1); -} op_t; - -typedef struct { - u4_t states; -} input_port_t; - -/* Registers */ -static u13_t pc, next_pc; -static u12_t x, y; -static u4_t a, b; -static u5_t np; -static u8_t sp; - -/* Flags */ -static u4_t flags; - -static const u12_t* g_program = NULL; -static MEM_BUFFER_TYPE memory[MEM_BUFFER_SIZE]; - -static input_port_t inputs[INPUT_PORT_NUM] = {{0}}; - -/* Interrupts (in priority order) */ -static interrupt_t interrupts[INT_SLOT_NUM] = { - {0x0, 0x0, 0, 0x0C}, // Prog timer - {0x0, 0x0, 0, 0x0A}, // Serial interface - {0x0, 0x0, 0, 0x08}, // Input (K10-K13) - {0x0, 0x0, 0, 0x06}, // Input (K00-K03) - {0x0, 0x0, 0, 0x04}, // Stopwatch timer - {0x0, 0x0, 0, 0x02}, // Clock timer -}; - -static breakpoint_t* g_breakpoints = NULL; - -static u32_t call_depth = 0; - -static u32_t clk_timer_timestamp = 0; // in ticks -static u32_t prog_timer_timestamp = 0; // in ticks -static bool_t prog_timer_enabled = 0; -static u8_t prog_timer_data = 0; -static u8_t prog_timer_rld = 0; - -static u32_t tick_counter = 0; -static u32_t ts_freq; -static u8_t speed_ratio = 1; -static timestamp_t ref_ts; - -static state_t cpu_state = { - .pc = &pc, - .x = &x, - .y = &y, - .a = &a, - .b = &b, - .np = &np, - .sp = &sp, - .flags = &flags, - - .tick_counter = &tick_counter, - .clk_timer_timestamp = &clk_timer_timestamp, - .prog_timer_timestamp = &prog_timer_timestamp, - .prog_timer_enabled = &prog_timer_enabled, - .prog_timer_data = &prog_timer_data, - .prog_timer_rld = &prog_timer_rld, - - .call_depth = &call_depth, - - .interrupts = interrupts, - - .memory = memory, -}; - -void cpu_add_bp(breakpoint_t** list, u13_t addr) { - breakpoint_t* bp; - - bp = (breakpoint_t*)g_hal->malloc(sizeof(breakpoint_t)); - if(!bp) { - g_hal->log(LOG_ERROR, "Cannot allocate memory for breakpoint 0x%04X!\n", addr); - return; - } - - bp->addr = addr; - - if(*list != NULL) { - bp->next = *list; - } else { - /* List is empty */ - bp->next = NULL; - } - - *list = bp; -} - -void cpu_free_bp(breakpoint_t** list) { - breakpoint_t *bp = *list, *tmp; - - while(bp != NULL) { - tmp = bp->next; - g_hal->free(bp); - bp = tmp; - } - - *list = NULL; -} - -void cpu_set_speed(u8_t speed) { - speed_ratio = speed; -} - -state_t* cpu_get_state(void) { - return &cpu_state; -} - -u32_t cpu_get_depth(void) { - return call_depth; -} - -static void generate_interrupt(int_slot_t slot, u8_t bit) { - /* Set the factor flag no matter what */ - interrupts[slot].factor_flag_reg = interrupts[slot].factor_flag_reg | (0x1 << bit); - - /* Trigger the INT only if not masked */ - if(interrupts[slot].mask_reg & (0x1 << bit)) { - interrupts[slot].triggered = 1; - } -} - -void cpu_set_input_pin(pin_t pin, pin_state_t state) { - /* Set the I/O */ - inputs[pin & 0x4].states = (inputs[pin & 0x4].states & ~(0x1 << (pin & 0x3))) | - (state << (pin & 0x3)); - - /* Trigger the interrupt (TODO: handle relation register) */ - if(state == PIN_STATE_LOW) { - switch((pin & 0x4) >> 2) { - case 0: - generate_interrupt(INT_K00_K03_SLOT, pin & 0x3); - break; - - case 1: - generate_interrupt(INT_K10_K13_SLOT, pin & 0x3); - break; - } - } -} - -void cpu_sync_ref_timestamp(void) { - ref_ts = g_hal->get_timestamp(); -} - -static u4_t get_io(u12_t n) { - u4_t tmp; - - switch(n) { - case REG_CLK_INT_FACTOR_FLAGS: - /* Interrupt factor flags (clock timer) */ - tmp = interrupts[INT_CLOCK_TIMER_SLOT].factor_flag_reg; - interrupts[INT_CLOCK_TIMER_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_SW_INT_FACTOR_FLAGS: - /* Interrupt factor flags (stopwatch) */ - tmp = interrupts[INT_STOPWATCH_SLOT].factor_flag_reg; - interrupts[INT_STOPWATCH_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_PROG_INT_FACTOR_FLAGS: - /* Interrupt factor flags (prog timer) */ - tmp = interrupts[INT_PROG_TIMER_SLOT].factor_flag_reg; - interrupts[INT_PROG_TIMER_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_SERIAL_INT_FACTOR_FLAGS: - /* Interrupt factor flags (serial) */ - tmp = interrupts[INT_SERIAL_SLOT].factor_flag_reg; - interrupts[INT_SERIAL_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_K00_K03_INT_FACTOR_FLAGS: - /* Interrupt factor flags (K00-K03) */ - tmp = interrupts[INT_K00_K03_SLOT].factor_flag_reg; - interrupts[INT_K00_K03_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_K10_K13_INT_FACTOR_FLAGS: - /* Interrupt factor flags (K10-K13) */ - tmp = interrupts[INT_K10_K13_SLOT].factor_flag_reg; - interrupts[INT_K10_K13_SLOT].factor_flag_reg = 0; - return tmp; - - case REG_CLOCK_INT_MASKS: - /* Clock timer interrupt masks */ - return interrupts[INT_CLOCK_TIMER_SLOT].mask_reg; - - case REG_SW_INT_MASKS: - /* Stopwatch interrupt masks */ - return interrupts[INT_STOPWATCH_SLOT].mask_reg & 0x3; - - case REG_PROG_INT_MASKS: - /* Prog timer interrupt masks */ - return interrupts[INT_PROG_TIMER_SLOT].mask_reg & 0x1; - - case REG_SERIAL_INT_MASKS: - /* Serial interface interrupt masks */ - return interrupts[INT_SERIAL_SLOT].mask_reg & 0x1; - - case REG_K00_K03_INT_MASKS: - /* Input (K00-K03) interrupt masks */ - return interrupts[INT_K00_K03_SLOT].mask_reg; - - case REG_K10_K13_INT_MASKS: - /* Input (K10-K13) interrupt masks */ - return interrupts[INT_K10_K13_SLOT].mask_reg; - - case REG_PROG_TIMER_DATA_L: - /* Prog timer data (low) */ - return prog_timer_data & 0xF; - - case REG_PROG_TIMER_DATA_H: - /* Prog timer data (high) */ - return (prog_timer_data >> 4) & 0xF; - - case REG_PROG_TIMER_RELOAD_DATA_L: - /* Prog timer reload data (low) */ - return prog_timer_rld & 0xF; - - case REG_PROG_TIMER_RELOAD_DATA_H: - /* Prog timer reload data (high) */ - return (prog_timer_rld >> 4) & 0xF; - - case REG_K00_K03_INPUT_PORT: - /* Input port (K00-K03) */ - return inputs[0].states; - - case REG_K10_K13_INPUT_PORT: - /* Input port (K10-K13) */ - return inputs[1].states; - - case REG_K40_K43_BZ_OUTPUT_PORT: - /* Output port (R40-R43) */ - return GET_IO_MEMORY(memory, n); - - case REG_CPU_OSC3_CTRL: - /* CPU/OSC3 clocks switch, CPU voltage switch */ - return GET_IO_MEMORY(memory, n); - - case REG_LCD_CTRL: - /* LCD control */ - return GET_IO_MEMORY(memory, n); - - case REG_LCD_CONTRAST: - /* LCD contrast */ - break; - - case REG_SVD_CTRL: - /* SVD */ - return GET_IO_MEMORY(memory, n) & 0x7; // Voltage always OK - - case REG_BUZZER_CTRL1: - /* Buzzer config 1 */ - return GET_IO_MEMORY(memory, n); - - case REG_BUZZER_CTRL2: - /* Buzzer config 2 */ - return GET_IO_MEMORY(memory, n) & 0x3; // Buzzer ready - - case REG_CLK_WD_TIMER_CTRL: - /* Clock/Watchdog timer reset */ - break; - - case REG_SW_TIMER_CTRL: - /* Stopwatch stop/run/reset */ - break; - - case REG_PROG_TIMER_CTRL: - /* Prog timer stop/run/reset */ - return !!prog_timer_enabled; - - case REG_PROG_TIMER_CLK_SEL: - /* Prog timer clock selection */ - break; - - default: - g_hal->log(LOG_ERROR, "Read from unimplemented I/O 0x%03X - PC = 0x%04X\n", n, pc); - } - - return 0; -} - -static void set_io(u12_t n, u4_t v) { - switch(n) { - case REG_CLOCK_INT_MASKS: - /* Clock timer interrupt masks */ - /* Assume 1Hz timer INT enabled (0x8) */ - interrupts[INT_CLOCK_TIMER_SLOT].mask_reg = v; - break; - - case REG_SW_INT_MASKS: - /* Stopwatch interrupt masks */ - /* Assume all INT disabled */ - interrupts[INT_STOPWATCH_SLOT].mask_reg = v; - break; - - case REG_PROG_INT_MASKS: - /* Prog timer interrupt masks */ - /* Assume Prog timer INT enabled (0x1) */ - interrupts[INT_PROG_TIMER_SLOT].mask_reg = v; - break; - - case REG_SERIAL_INT_MASKS: - /* Serial interface interrupt masks */ - /* Assume all INT disabled */ - interrupts[INT_K10_K13_SLOT].mask_reg = v; - break; - - case REG_K00_K03_INT_MASKS: - /* Input (K00-K03) interrupt masks */ - /* Assume all INT disabled */ - interrupts[INT_SERIAL_SLOT].mask_reg = v; - break; - - case REG_K10_K13_INT_MASKS: - /* Input (K10-K13) interrupt masks */ - /* Assume all INT disabled */ - interrupts[INT_K10_K13_SLOT].mask_reg = v; - break; - - case REG_PROG_TIMER_RELOAD_DATA_L: - /* Prog timer reload data (low) */ - prog_timer_rld = v | (prog_timer_rld & 0xF0); - break; - - case REG_PROG_TIMER_RELOAD_DATA_H: - /* Prog timer reload data (high) */ - prog_timer_rld = (prog_timer_rld & 0xF) | (v << 4); - break; - - case REG_K00_K03_INPUT_PORT: - /* Input port (K00-K03) */ - /* Write not allowed */ - break; - - case REG_K40_K43_BZ_OUTPUT_PORT: - /* Output port (R40-R43) */ - //g_hal->log(LOG_INFO, "Output/Buzzer: 0x%X\n", v); - hw_enable_buzzer(!(v & 0x8)); - break; - - case REG_CPU_OSC3_CTRL: - /* CPU/OSC3 clocks switch, CPU voltage switch */ - /* Assume 32,768 OSC1 selected, OSC3 off, battery >= 3,1V (0x1) */ - break; - - case REG_LCD_CTRL: - /* LCD control */ - break; - - case REG_LCD_CONTRAST: - /* LCD contrast */ - /* Assume medium contrast (0x8) */ - break; - - case REG_SVD_CTRL: - /* SVD */ - /* Assume battery voltage always OK (0x6) */ - break; - - case REG_BUZZER_CTRL1: - /* Buzzer config 1 */ - hw_set_buzzer_freq(v & 0x7); - break; - - case REG_BUZZER_CTRL2: - /* Buzzer config 2 */ - break; - - case REG_CLK_WD_TIMER_CTRL: - /* Clock/Watchdog timer reset */ - /* Ignore watchdog */ - break; - - case REG_SW_TIMER_CTRL: - /* Stopwatch stop/run/reset */ - break; - - case REG_PROG_TIMER_CTRL: - /* Prog timer stop/run/reset */ - if(v & 0x2) { - prog_timer_data = prog_timer_rld; - } - - if((v & 0x1) && !prog_timer_enabled) { - prog_timer_timestamp = tick_counter; - } - - prog_timer_enabled = v & 0x1; - break; - - case REG_PROG_TIMER_CLK_SEL: - /* Prog timer clock selection */ - /* Assume 256Hz, output disabled */ - break; - - default: - g_hal->log(LOG_ERROR, "Write 0x%X to unimplemented I/O 0x%03X - PC = 0x%04X\n", v, n, pc); - } -} - -static void set_lcd(u12_t n, u4_t v) { - u8_t i; - u8_t seg, com0; - - seg = ((n & 0x7F) >> 1); - com0 = (((n & 0x80) >> 7) * 8 + (n & 0x1) * 4); - - for(i = 0; i < 4; i++) { - hw_set_lcd_pin(seg, com0 + i, (v >> i) & 0x1); - } -} - -static u4_t get_memory(u12_t n) { - u4_t res = 0; - - if(n < MEM_RAM_SIZE) { - /* RAM */ - g_hal->log(LOG_MEMORY, "RAM - "); - res = GET_RAM_MEMORY(memory, n); - } else if(n >= MEM_DISPLAY1_ADDR && n < (MEM_DISPLAY1_ADDR + MEM_DISPLAY1_SIZE)) { - /* Display Memory 1 */ - g_hal->log(LOG_MEMORY, "Display Memory 1 - "); - res = GET_DISP1_MEMORY(memory, n); - } else if(n >= MEM_DISPLAY2_ADDR && n < (MEM_DISPLAY2_ADDR + MEM_DISPLAY2_SIZE)) { - /* Display Memory 2 */ - g_hal->log(LOG_MEMORY, "Display Memory 2 - "); - res = GET_DISP2_MEMORY(memory, n); - } else if(n >= MEM_IO_ADDR && n < (MEM_IO_ADDR + MEM_IO_SIZE)) { - /* I/O Memory */ - g_hal->log(LOG_MEMORY, "I/O - "); - res = get_io(n); - } else { - g_hal->log(LOG_ERROR, "Read from invalid memory address 0x%03X - PC = 0x%04X\n", n, pc); - return 0; - } - - g_hal->log(LOG_MEMORY, "Read 0x%X - Address 0x%03X - PC = 0x%04X\n", res, n, pc); - - return res; -} - -static void set_memory(u12_t n, u4_t v) { - /* Cache any data written to a valid address, and process it */ - if(n < MEM_RAM_SIZE) { - /* RAM */ - SET_RAM_MEMORY(memory, n, v); - g_hal->log(LOG_MEMORY, "RAM - "); - } else if(n >= MEM_DISPLAY1_ADDR && n < (MEM_DISPLAY1_ADDR + MEM_DISPLAY1_SIZE)) { - /* Display Memory 1 */ - SET_DISP1_MEMORY(memory, n, v); - set_lcd(n, v); - g_hal->log(LOG_MEMORY, "Display Memory 1 - "); - } else if(n >= MEM_DISPLAY2_ADDR && n < (MEM_DISPLAY2_ADDR + MEM_DISPLAY2_SIZE)) { - /* Display Memory 2 */ - SET_DISP2_MEMORY(memory, n, v); - set_lcd(n, v); - g_hal->log(LOG_MEMORY, "Display Memory 2 - "); - } else if(n >= MEM_IO_ADDR && n < (MEM_IO_ADDR + MEM_IO_SIZE)) { - /* I/O Memory */ - SET_IO_MEMORY(memory, n, v); - set_io(n, v); - g_hal->log(LOG_MEMORY, "I/O - "); - } else { - g_hal->log( - LOG_ERROR, "Write 0x%X to invalid memory address 0x%03X - PC = 0x%04X\n", v, n, pc); - return; - } - - g_hal->log(LOG_MEMORY, "Write 0x%X - Address 0x%03X - PC = 0x%04X\n", v, n, pc); -} - -void cpu_refresh_hw(void) { - static const struct range { - u12_t addr; - u12_t size; - } refresh_locs[] = { - {MEM_DISPLAY1_ADDR, MEM_DISPLAY1_SIZE}, /* Display Memory 1 */ - {MEM_DISPLAY2_ADDR, MEM_DISPLAY2_SIZE}, /* Display Memory 2 */ - {REG_BUZZER_CTRL1, 1}, /* Buzzer frequency */ - {REG_K40_K43_BZ_OUTPUT_PORT, 1}, /* Buzzer enabled */ - - {0, 0}, // end of list - }; - - for(int i = 0; refresh_locs[i].size != 0; i++) { - for(u12_t n = refresh_locs[i].addr; n < (refresh_locs[i].addr + refresh_locs[i].size); - n++) { - set_memory(n, GET_MEMORY(memory, n)); - } - } -} - -static u4_t get_rq(u12_t rq) { - switch(rq & 0x3) { - case 0x0: - return a; - - case 0x1: - return b; - - case 0x2: - return M(x); - - case 0x3: - return M(y); - } - - return 0; -} - -static void set_rq(u12_t rq, u4_t v) { - switch(rq & 0x3) { - case 0x0: - a = v; - break; - - case 0x1: - b = v; - break; - - case 0x2: - SET_M(x, v); - break; - - case 0x3: - SET_M(y, v); - break; - } -} - -/* Instructions */ -static void op_pset_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - np = arg0; -} - -static void op_jp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - next_pc = arg0 | (np << 8); -} - -static void op_jp_c_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(flags & FLAG_C) { - next_pc = arg0 | (np << 8); - } -} - -static void op_jp_nc_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(!(flags & FLAG_C)) { - next_pc = arg0 | (np << 8); - } -} - -static void op_jp_z_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(flags & FLAG_Z) { - next_pc = arg0 | (np << 8); - } -} - -static void op_jp_nz_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(!(flags & FLAG_Z)) { - next_pc = arg0 | (np << 8); - } -} - -static void op_jpba_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - next_pc = a | (b << 4) | (np << 8); -} - -static void op_call_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - pc = (pc + 1) & 0x1FFF; // This does not actually change the PC register - SET_M(sp - 1, PCP); - SET_M(sp - 2, PCSH); - SET_M(sp - 3, PCSL); - sp = (sp - 3) & 0xFF; - next_pc = TO_PC(PCB, NPP, arg0); - call_depth++; -} - -static void op_calz_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - pc = (pc + 1) & 0x1FFF; // This does not actually change the PC register - SET_M(sp - 1, PCP); - SET_M(sp - 2, PCSH); - SET_M(sp - 3, PCSL); - sp = (sp - 3) & 0xFF; - next_pc = TO_PC(PCB, 0, arg0); - call_depth++; -} - -static void op_ret_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - next_pc = M(sp) | (M(sp + 1) << 4) | (M(sp + 2) << 8) | (PCB << 12); - sp = (sp + 3) & 0xFF; - call_depth--; -} - -static void op_rets_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - next_pc = M(sp) | (M(sp + 1) << 4) | (M(sp + 2) << 8) | (PCB << 12); - sp = (sp + 3) & 0xFF; - next_pc = (pc + 1) & 0x1FFF; - call_depth--; -} - -static void op_retd_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - next_pc = M(sp) | (M(sp + 1) << 4) | (M(sp + 2) << 8) | (PCB << 12); - sp = (sp + 3) & 0xFF; - SET_M(x, arg0 & 0xF); - SET_M(x + 1, (arg0 >> 4) & 0xF); - x = ((x + 2) & 0xFF) | (XP << 8); - call_depth--; -} - -static void op_nop5_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); -} - -static void op_nop7_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); -} - -static void op_halt_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - g_hal->halt(); -} - -static void op_inc_x_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - x = ((x + 1) & 0xFF) | (XP << 8); -} - -static void op_inc_y_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - y = ((y + 1) & 0xFF) | (YP << 8); -} - -static void op_ld_x_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - x = arg0 | (XP << 8); -} - -static void op_ld_y_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - y = arg0 | (YP << 8); -} - -static void op_ld_xp_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - x = XHL | (RQ(arg0) << 8); -} - -static void op_ld_xh_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - x = XL | (RQ(arg0) << 4) | (XP << 8); -} - -static void op_ld_xl_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - x = RQ(arg0) | (XH << 4) | (XP << 8); -} - -static void op_ld_yp_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - y = YHL | (RQ(arg0) << 8); -} - -static void op_ld_yh_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - y = YL | (RQ(arg0) << 4) | (YP << 8); -} - -static void op_ld_yl_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - y = RQ(arg0) | (YH << 4) | (YP << 8); -} - -static void op_ld_r_xp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, XP); -} - -static void op_ld_r_xh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, XH); -} - -static void op_ld_r_xl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, XL); -} - -static void op_ld_r_yp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, YP); -} - -static void op_ld_r_yh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, YH); -} - -static void op_ld_r_yl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, YL); -} - -static void op_adc_xh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = XH + arg0 + C; - x = XL | ((tmp & 0xF) << 4) | (XP << 8); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!(tmp & 0xF)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_adc_xl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = XL + arg0 + C; - x = (tmp & 0xF) | (XH << 4) | (XP << 8); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!(tmp & 0xF)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_adc_yh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = YH + arg0 + C; - y = YL | ((tmp & 0xF) << 4) | (YP << 8); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!(tmp & 0xF)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_adc_yl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = YL + arg0 + C; - y = (tmp & 0xF) | (YH << 4) | (YP << 8); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!(tmp & 0xF)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_xh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(XH < arg0) { - SET_C(); - } else { - CLEAR_C(); - } - if(XH == arg0) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_xl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(XL < arg0) { - SET_C(); - } else { - CLEAR_C(); - } - if(XL == arg0) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_yh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(YH < arg0) { - SET_C(); - } else { - CLEAR_C(); - } - if(YH == arg0) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_yl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - if(YL < arg0) { - SET_C(); - } else { - CLEAR_C(); - } - if(YL == arg0) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_ld_r_i_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, arg1); -} - -static void op_ld_r_q_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg1)); -} - -static void op_ld_a_mn_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - a = M(arg0); -} - -static void op_ld_b_mn_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - b = M(arg0); -} - -static void op_ld_mn_a_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_M(arg0, a); -} - -static void op_ld_mn_b_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_M(arg0, b); -} - -static void op_ldpx_mx_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_M(x, arg0); - x = ((x + 1) & 0xFF) | (XP << 8); -} - -static void op_ldpx_r_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg1)); - x = ((x + 1) & 0xFF) | (XP << 8); -} - -static void op_ldpy_my_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_M(y, arg0); - y = ((y + 1) & 0xFF) | (YP << 8); -} - -static void op_ldpy_r_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg1)); - y = ((y + 1) & 0xFF) | (YP << 8); -} - -static void op_lbpx_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_M(x, arg0 & 0xF); - SET_M(x + 1, (arg0 >> 4) & 0xF); - x = ((x + 2) & 0xFF) | (XP << 8); -} - -static void op_set_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - flags |= arg0; -} - -static void op_rst_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - flags &= arg0; -} - -static void op_scf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - SET_C(); -} - -static void op_rcf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - CLEAR_C(); -} - -static void op_szf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - SET_Z(); -} - -static void op_rzf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - CLEAR_Z(); -} - -static void op_sdf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - SET_D(); -} - -static void op_rdf_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - CLEAR_D(); -} - -static void op_ei_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - SET_I(); -} - -static void op_di_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - CLEAR_I(); -} - -static void op_inc_sp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp + 1) & 0xFF; -} - -static void op_dec_sp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; -} - -static void op_push_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, RQ(arg0)); -} - -static void op_push_xp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, XP); -} - -static void op_push_xh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, XH); -} - -static void op_push_xl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, XL); -} - -static void op_push_yp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, YP); -} - -static void op_push_yh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, YH); -} - -static void op_push_yl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, YL); -} - -static void op_push_f_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - sp = (sp - 1) & 0xFF; - SET_M(sp, flags); -} - -static void op_pop_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, M(sp)); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_xp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - x = XL | (XH << 4) | (M(sp) << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_xh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - x = XL | (M(sp) << 4) | (XP << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_xl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - x = M(sp) | (XH << 4) | (XP << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_yp_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - y = YL | (YH << 4) | (M(sp) << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_yh_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - y = YL | (M(sp) << 4) | (YP << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_yl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - y = M(sp) | (YH << 4) | (YP << 8); - sp = (sp + 1) & 0xFF; -} - -static void op_pop_f_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg0); - UNUSED(arg1); - flags = M(sp); - sp = (sp + 1) & 0xFF; -} - -static void op_ld_sph_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - sp = SPL | (RQ(arg0) << 4); -} - -static void op_ld_spl_r_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - sp = RQ(arg0) | (SPH << 4); -} - -static void op_ld_r_sph_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, SPH); -} - -static void op_ld_r_spl_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, SPL); -} - -static void op_add_r_i_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) + arg1; - if(D) { - if(tmp >= 10) { - SET_RQ(arg0, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_RQ(arg0, tmp); - CLEAR_C(); - } - } else { - SET_RQ(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_add_r_q_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) + RQ(arg1); - if(D) { - if(tmp >= 10) { - SET_RQ(arg0, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_RQ(arg0, tmp); - CLEAR_C(); - } - } else { - SET_RQ(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_adc_r_i_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) + arg1 + C; - if(D) { - if(tmp >= 10) { - SET_RQ(arg0, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_RQ(arg0, tmp); - CLEAR_C(); - } - } else { - SET_RQ(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_adc_r_q_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) + RQ(arg1) + C; - if(D) { - if(tmp >= 10) { - SET_RQ(arg0, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_RQ(arg0, tmp); - CLEAR_C(); - } - } else { - SET_RQ(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_sub_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) - RQ(arg1); - if(D) { - if(tmp >> 4) { - SET_RQ(arg0, (tmp - 6) & 0xF); - } else { - SET_RQ(arg0, tmp); - } - } else { - SET_RQ(arg0, tmp & 0xF); - } - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_sbc_r_i_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) - arg1 - C; - if(D) { - if(tmp >> 4) { - SET_RQ(arg0, (tmp - 6) & 0xF); - } else { - SET_RQ(arg0, tmp); - } - } else { - SET_RQ(arg0, tmp & 0xF); - } - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_sbc_r_q_cb(u8_t arg0, u8_t arg1) { - u8_t tmp; - - tmp = RQ(arg0) - RQ(arg1) - C; - if(D) { - if(tmp >> 4) { - SET_RQ(arg0, (tmp - 6) & 0xF); - } else { - SET_RQ(arg0, tmp); - } - } else { - SET_RQ(arg0, tmp & 0xF); - } - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_and_r_i_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) & arg1); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_and_r_q_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) & RQ(arg1)); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_or_r_i_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) | arg1); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_or_r_q_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) | RQ(arg1)); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_xor_r_i_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) ^ arg1); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_xor_r_q_cb(u8_t arg0, u8_t arg1) { - SET_RQ(arg0, RQ(arg0) ^ RQ(arg1)); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_r_i_cb(u8_t arg0, u8_t arg1) { - if(RQ(arg0) < arg1) { - SET_C(); - } else { - CLEAR_C(); - } - if(RQ(arg0) == arg1) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_cp_r_q_cb(u8_t arg0, u8_t arg1) { - if(RQ(arg0) < RQ(arg1)) { - SET_C(); - } else { - CLEAR_C(); - } - if(RQ(arg0) == RQ(arg1)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_fan_r_i_cb(u8_t arg0, u8_t arg1) { - if(!(RQ(arg0) & arg1)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_fan_r_q_cb(u8_t arg0, u8_t arg1) { - if(!(RQ(arg0) & RQ(arg1))) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_rlc_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = (RQ(arg0) << 1) | C; - if(RQ(arg0) & 0x8) { - SET_C(); - } else { - CLEAR_C(); - } - SET_RQ(arg0, tmp & 0xF); - /* No need to set Z (issue in DS) */ -} - -static void op_rrc_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = (RQ(arg0) >> 1) | (C << 3); - if(RQ(arg0) & 0x1) { - SET_C(); - } else { - CLEAR_C(); - } - SET_RQ(arg0, tmp & 0xF); - /* No need to set Z (issue in DS) */ -} - -static void op_inc_mn_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(arg0) + 1; - SET_M(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!M(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_dec_mn_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(arg0) - 1; - SET_M(arg0, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!M(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -static void op_acpx_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(x) + RQ(arg0) + C; - if(D) { - if(tmp >= 10) { - SET_M(x, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_M(x, tmp); - CLEAR_C(); - } - } else { - SET_M(x, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!M(x)) { - SET_Z(); - } else { - CLEAR_Z(); - } - x = ((x + 1) & 0xFF) | (XP << 8); -} - -static void op_acpy_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(y) + RQ(arg0) + C; - if(D) { - if(tmp >= 10) { - SET_M(y, (tmp - 10) & 0xF); - SET_C(); - } else { - SET_M(y, tmp); - CLEAR_C(); - } - } else { - SET_M(y, tmp & 0xF); - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - } - if(!M(y)) { - SET_Z(); - } else { - CLEAR_Z(); - } - y = ((y + 1) & 0xFF) | (YP << 8); -} - -static void op_scpx_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(x) - RQ(arg0) - C; - if(D) { - if(tmp >> 4) { - SET_M(x, (tmp - 6) & 0xF); - } else { - SET_M(x, tmp); - } - } else { - SET_M(x, tmp & 0xF); - } - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!M(x)) { - SET_Z(); - } else { - CLEAR_Z(); - } - x = ((x + 1) & 0xFF) | (XP << 8); -} - -static void op_scpy_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - u8_t tmp; - - tmp = M(y) - RQ(arg0) - C; - if(D) { - if(tmp >> 4) { - SET_M(y, (tmp - 6) & 0xF); - } else { - SET_M(y, tmp); - } - } else { - SET_M(y, tmp & 0xF); - } - if(tmp >> 4) { - SET_C(); - } else { - CLEAR_C(); - } - if(!M(y)) { - SET_Z(); - } else { - CLEAR_Z(); - } - y = ((y + 1) & 0xFF) | (YP << 8); -} - -static void op_not_cb(u8_t arg0, u8_t arg1) { - UNUSED(arg1); - SET_RQ(arg0, ~RQ(arg0) & 0xF); - if(!RQ(arg0)) { - SET_Z(); - } else { - CLEAR_Z(); - } -} - -/* The E0C6S46 supported instructions */ -static const op_t ops[] = { - {"PSET #0x%02X ", 0xE40, MASK_7B, 0, 0, 5, &op_pset_cb}, // PSET - {"JP #0x%02X ", 0x000, MASK_4B, 0, 0, 5, &op_jp_cb}, // JP - {"JP C #0x%02X ", 0x200, MASK_4B, 0, 0, 5, &op_jp_c_cb}, // JP_C - {"JP NC #0x%02X ", 0x300, MASK_4B, 0, 0, 5, &op_jp_nc_cb}, // JP_NC - {"JP Z #0x%02X ", 0x600, MASK_4B, 0, 0, 5, &op_jp_z_cb}, // JP_Z - {"JP NZ #0x%02X ", 0x700, MASK_4B, 0, 0, 5, &op_jp_nz_cb}, // JP_NZ - {"JPBA ", 0xFE8, MASK_12B, 0, 0, 5, &op_jpba_cb}, // JPBA - {"CALL #0x%02X ", 0x400, MASK_4B, 0, 0, 7, &op_call_cb}, // CALL - {"CALZ #0x%02X ", 0x500, MASK_4B, 0, 0, 7, &op_calz_cb}, // CALZ - {"RET ", 0xFDF, MASK_12B, 0, 0, 7, &op_ret_cb}, // RET - {"RETS ", 0xFDE, MASK_12B, 0, 0, 12, &op_rets_cb}, // RETS - {"RETD #0x%02X ", 0x100, MASK_4B, 0, 0, 12, &op_retd_cb}, // RETD - {"NOP5 ", 0xFFB, MASK_12B, 0, 0, 5, &op_nop5_cb}, // NOP5 - {"NOP7 ", 0xFFF, MASK_12B, 0, 0, 7, &op_nop7_cb}, // NOP7 - {"HALT ", 0xFF8, MASK_12B, 0, 0, 5, &op_halt_cb}, // HALT - {"INC X #0x%02X ", 0xEE0, MASK_12B, 0, 0, 5, &op_inc_x_cb}, // INC_X - {"INC Y #0x%02X ", 0xEF0, MASK_12B, 0, 0, 5, &op_inc_y_cb}, // INC_Y - {"LD X #0x%02X ", 0xB00, MASK_4B, 0, 0, 5, &op_ld_x_cb}, // LD_X - {"LD Y #0x%02X ", 0x800, MASK_4B, 0, 0, 5, &op_ld_y_cb}, // LD_Y - {"LD XP R(#0x%02X) ", 0xE80, MASK_10B, 0, 0, 5, &op_ld_xp_r_cb}, // LD_XP_R - {"LD XH R(#0x%02X) ", 0xE84, MASK_10B, 0, 0, 5, &op_ld_xh_r_cb}, // LD_XH_R - {"LD XL R(#0x%02X) ", 0xE88, MASK_10B, 0, 0, 5, &op_ld_xl_r_cb}, // LD_XL_R - {"LD YP R(#0x%02X) ", 0xE90, MASK_10B, 0, 0, 5, &op_ld_yp_r_cb}, // LD_YP_R - {"LD YH R(#0x%02X) ", 0xE94, MASK_10B, 0, 0, 5, &op_ld_yh_r_cb}, // LD_YH_R - {"LD YL R(#0x%02X) ", 0xE98, MASK_10B, 0, 0, 5, &op_ld_yl_r_cb}, // LD_YL_R - {"LD R(#0x%02X) XP ", 0xEA0, MASK_10B, 0, 0, 5, &op_ld_r_xp_cb}, // LD_R_XP - {"LD R(#0x%02X) XH ", 0xEA4, MASK_10B, 0, 0, 5, &op_ld_r_xh_cb}, // LD_R_XH - {"LD R(#0x%02X) XL ", 0xEA8, MASK_10B, 0, 0, 5, &op_ld_r_xl_cb}, // LD_R_XL - {"LD R(#0x%02X) YP ", 0xEB0, MASK_10B, 0, 0, 5, &op_ld_r_yp_cb}, // LD_R_YP - {"LD R(#0x%02X) YH ", 0xEB4, MASK_10B, 0, 0, 5, &op_ld_r_yh_cb}, // LD_R_YH - {"LD R(#0x%02X) YL ", 0xEB8, MASK_10B, 0, 0, 5, &op_ld_r_yl_cb}, // LD_R_YL - {"ADC XH #0x%02X ", 0xA00, MASK_8B, 0, 0, 7, &op_adc_xh_cb}, // ADC_XH - {"ADC XL #0x%02X ", 0xA10, MASK_8B, 0, 0, 7, &op_adc_xl_cb}, // ADC_XL - {"ADC YH #0x%02X ", 0xA20, MASK_8B, 0, 0, 7, &op_adc_yh_cb}, // ADC_YH - {"ADC YL #0x%02X ", 0xA30, MASK_8B, 0, 0, 7, &op_adc_yl_cb}, // ADC_YL - {"CP XH #0x%02X ", 0xA40, MASK_8B, 0, 0, 7, &op_cp_xh_cb}, // CP_XH - {"CP XL #0x%02X ", 0xA50, MASK_8B, 0, 0, 7, &op_cp_xl_cb}, // CP_XL - {"CP YH #0x%02X ", 0xA60, MASK_8B, 0, 0, 7, &op_cp_yh_cb}, // CP_YH - {"CP YL #0x%02X ", 0xA70, MASK_8B, 0, 0, 7, &op_cp_yl_cb}, // CP_YL - {"LD R(#0x%02X) #0x%02X ", 0xE00, MASK_6B, 4, 0x030, 5, &op_ld_r_i_cb}, // LD_R_I - {"LD R(#0x%02X) Q(#0x%02X)", 0xEC0, MASK_8B, 2, 0x00C, 5, &op_ld_r_q_cb}, // LD_R_Q - {"LD A M(#0x%02X) ", 0xFA0, MASK_8B, 0, 0, 5, &op_ld_a_mn_cb}, // LD_A_MN - {"LD B M(#0x%02X) ", 0xFB0, MASK_8B, 0, 0, 5, &op_ld_b_mn_cb}, // LD_B_MN - {"LD M(#0x%02X) A ", 0xF80, MASK_8B, 0, 0, 5, &op_ld_mn_a_cb}, // LD_MN_A - {"LD M(#0x%02X) B ", 0xF90, MASK_8B, 0, 0, 5, &op_ld_mn_b_cb}, // LD_MN_B - {"LDPX MX #0x%02X ", 0xE60, MASK_8B, 0, 0, 5, &op_ldpx_mx_cb}, // LDPX_MX - {"LDPX R(#0x%02X) Q(#0x%02X)", 0xEE0, MASK_8B, 2, 0x00C, 5, &op_ldpx_r_cb}, // LDPX_R - {"LDPY MY #0x%02X ", 0xE70, MASK_8B, 0, 0, 5, &op_ldpy_my_cb}, // LDPY_MY - {"LDPY R(#0x%02X) Q(#0x%02X)", 0xEF0, MASK_8B, 2, 0x00C, 5, &op_ldpy_r_cb}, // LDPY_R - {"LBPX #0x%02X ", 0x900, MASK_4B, 0, 0, 5, &op_lbpx_cb}, // LBPX - {"SET #0x%02X ", 0xF40, MASK_8B, 0, 0, 7, &op_set_cb}, // SET - {"RST #0x%02X ", 0xF50, MASK_8B, 0, 0, 7, &op_rst_cb}, // RST - {"SCF ", 0xF41, MASK_12B, 0, 0, 7, &op_scf_cb}, // SCF - {"RCF ", 0xF5E, MASK_12B, 0, 0, 7, &op_rcf_cb}, // RCF - {"SZF ", 0xF42, MASK_12B, 0, 0, 7, &op_szf_cb}, // SZF - {"RZF ", 0xF5D, MASK_12B, 0, 0, 7, &op_rzf_cb}, // RZF - {"SDF ", 0xF44, MASK_12B, 0, 0, 7, &op_sdf_cb}, // SDF - {"RDF ", 0xF5B, MASK_12B, 0, 0, 7, &op_rdf_cb}, // RDF - {"EI ", 0xF48, MASK_12B, 0, 0, 7, &op_ei_cb}, // EI - {"DI ", 0xF57, MASK_12B, 0, 0, 7, &op_di_cb}, // DI - {"INC SP ", 0xFDB, MASK_12B, 0, 0, 5, &op_inc_sp_cb}, // INC_SP - {"DEC SP ", 0xFCB, MASK_12B, 0, 0, 5, &op_dec_sp_cb}, // DEC_SP - {"PUSH R(#0x%02X) ", 0xFC0, MASK_10B, 0, 0, 5, &op_push_r_cb}, // PUSH_R - {"PUSH XP ", 0xFC4, MASK_12B, 0, 0, 5, &op_push_xp_cb}, // PUSH_XP - {"PUSH XH ", 0xFC5, MASK_12B, 0, 0, 5, &op_push_xh_cb}, // PUSH_XH - {"PUSH XL ", 0xFC6, MASK_12B, 0, 0, 5, &op_push_xl_cb}, // PUSH_XL - {"PUSH YP ", 0xFC7, MASK_12B, 0, 0, 5, &op_push_yp_cb}, // PUSH_YP - {"PUSH YH ", 0xFC8, MASK_12B, 0, 0, 5, &op_push_yh_cb}, // PUSH_YH - {"PUSH YL ", 0xFC9, MASK_12B, 0, 0, 5, &op_push_yl_cb}, // PUSH_YL - {"PUSH F ", 0xFCA, MASK_12B, 0, 0, 5, &op_push_f_cb}, // PUSH_F - {"POP R(#0x%02X) ", 0xFD0, MASK_10B, 0, 0, 5, &op_pop_r_cb}, // POP_R - {"POP XP ", 0xFD4, MASK_12B, 0, 0, 5, &op_pop_xp_cb}, // POP_XP - {"POP XH ", 0xFD5, MASK_12B, 0, 0, 5, &op_pop_xh_cb}, // POP_XH - {"POP XL ", 0xFD6, MASK_12B, 0, 0, 5, &op_pop_xl_cb}, // POP_XL - {"POP YP ", 0xFD7, MASK_12B, 0, 0, 5, &op_pop_yp_cb}, // POP_YP - {"POP YH ", 0xFD8, MASK_12B, 0, 0, 5, &op_pop_yh_cb}, // POP_YH - {"POP YL ", 0xFD9, MASK_12B, 0, 0, 5, &op_pop_yl_cb}, // POP_YL - {"POP F ", 0xFDA, MASK_12B, 0, 0, 5, &op_pop_f_cb}, // POP_F - {"LD SPH R(#0x%02X) ", 0xFE0, MASK_10B, 0, 0, 5, &op_ld_sph_r_cb}, // LD_SPH_R - {"LD SPL R(#0x%02X) ", 0xFF0, MASK_10B, 0, 0, 5, &op_ld_spl_r_cb}, // LD_SPL_R - {"LD R(#0x%02X) SPH ", 0xFE4, MASK_10B, 0, 0, 5, &op_ld_r_sph_cb}, // LD_R_SPH - {"LD R(#0x%02X) SPL ", 0xFF4, MASK_10B, 0, 0, 5, &op_ld_r_spl_cb}, // LD_R_SPL - {"ADD R(#0x%02X) #0x%02X ", 0xC00, MASK_6B, 4, 0x030, 7, &op_add_r_i_cb}, // ADD_R_I - {"ADD R(#0x%02X) Q(#0x%02X)", 0xA80, MASK_8B, 2, 0x00C, 7, &op_add_r_q_cb}, // ADD_R_Q - {"ADC R(#0x%02X) #0x%02X ", 0xC40, MASK_6B, 4, 0x030, 7, &op_adc_r_i_cb}, // ADC_R_I - {"ADC R(#0x%02X) Q(#0x%02X)", 0xA90, MASK_8B, 2, 0x00C, 7, &op_adc_r_q_cb}, // ADC_R_Q - {"SUB R(#0x%02X) Q(#0x%02X)", 0xAA0, MASK_8B, 2, 0x00C, 7, &op_sub_cb}, // SUB - {"SBC R(#0x%02X) #0x%02X ", 0xB40, MASK_6B, 4, 0x030, 7, &op_sbc_r_i_cb}, // SBC_R_I - {"SBC R(#0x%02X) Q(#0x%02X)", 0xAB0, MASK_8B, 2, 0x00C, 7, &op_sbc_r_q_cb}, // SBC_R_Q - {"AND R(#0x%02X) #0x%02X ", 0xC80, MASK_6B, 4, 0x030, 7, &op_and_r_i_cb}, // AND_R_I - {"AND R(#0x%02X) Q(#0x%02X)", 0xAC0, MASK_8B, 2, 0x00C, 7, &op_and_r_q_cb}, // AND_R_Q - {"OR R(#0x%02X) #0x%02X ", 0xCC0, MASK_6B, 4, 0x030, 7, &op_or_r_i_cb}, // OR_R_I - {"OR R(#0x%02X) Q(#0x%02X)", 0xAD0, MASK_8B, 2, 0x00C, 7, &op_or_r_q_cb}, // OR_R_Q - {"XOR R(#0x%02X) #0x%02X ", 0xD00, MASK_6B, 4, 0x030, 7, &op_xor_r_i_cb}, // XOR_R_I - {"XOR R(#0x%02X) Q(#0x%02X)", 0xAE0, MASK_8B, 2, 0x00C, 7, &op_xor_r_q_cb}, // XOR_R_Q - {"CP R(#0x%02X) #0x%02X ", 0xDC0, MASK_6B, 4, 0x030, 7, &op_cp_r_i_cb}, // CP_R_I - {"CP R(#0x%02X) Q(#0x%02X)", 0xF00, MASK_8B, 2, 0x00C, 7, &op_cp_r_q_cb}, // CP_R_Q - {"FAN R(#0x%02X) #0x%02X ", 0xD80, MASK_6B, 4, 0x030, 7, &op_fan_r_i_cb}, // FAN_R_I - {"FAN R(#0x%02X) Q(#0x%02X)", 0xF10, MASK_8B, 2, 0x00C, 7, &op_fan_r_q_cb}, // FAN_R_Q - {"RLC R(#0x%02X) ", 0xAF0, MASK_8B, 0, 0, 7, &op_rlc_cb}, // RLC - {"RRC R(#0x%02X) ", 0xE8C, MASK_10B, 0, 0, 5, &op_rrc_cb}, // RRC - {"INC M(#0x%02X) ", 0xF60, MASK_8B, 0, 0, 7, &op_inc_mn_cb}, // INC_MN - {"DEC M(#0x%02X) ", 0xF70, MASK_8B, 0, 0, 7, &op_dec_mn_cb}, // DEC_MN - {"ACPX R(#0x%02X) ", 0xF28, MASK_10B, 0, 0, 7, &op_acpx_cb}, // ACPX - {"ACPY R(#0x%02X) ", 0xF2C, MASK_10B, 0, 0, 7, &op_acpy_cb}, // ACPY - {"SCPX R(#0x%02X) ", 0xF38, MASK_10B, 0, 0, 7, &op_scpx_cb}, // SCPX - {"SCPY R(#0x%02X) ", 0xF3C, MASK_10B, 0, 0, 7, &op_scpy_cb}, // SCPY - {"NOT R(#0x%02X) ", 0xD0F, 0xFCF, 4, 0, 7, &op_not_cb}, // NOT - - {NULL, 0, 0, 0, 0, 0, NULL}, -}; - -static timestamp_t wait_for_cycles(timestamp_t since, u8_t cycles) { - timestamp_t deadline; - - tick_counter += cycles; - - if(speed_ratio == 0) { - /* Emulation will be as fast as possible */ - return g_hal->get_timestamp(); - } - - deadline = since + (cycles * ts_freq) / (TICK_FREQUENCY * speed_ratio); - g_hal->sleep_until(deadline); - - return deadline; -} - -static void process_interrupts(void) { - u8_t i; - - /* Process interrupts in priority order */ - for(i = 0; i < INT_SLOT_NUM; i++) { - if(interrupts[i].triggered) { - //printf("IT %u !\n", i); - SET_M(sp - 1, PCP); - SET_M(sp - 2, PCSH); - SET_M(sp - 3, PCSL); - sp = (sp - 3) & 0xFF; - CLEAR_I(); - np = TO_NP(NBP, 1); - pc = TO_PC(PCB, 1, interrupts[i].vector); - call_depth++; - - ref_ts = wait_for_cycles(ref_ts, 12); - interrupts[i].triggered = 0; - } - } -} - -static void print_state(u8_t op_num, u12_t op, u13_t addr) { - u8_t i; - - if(!g_hal->is_log_enabled(LOG_CPU)) { - return; - } - - g_hal->log(LOG_CPU, "0x%04X: ", addr); - - for(i = 0; i < call_depth; i++) { - g_hal->log(LOG_CPU, " "); - } - - if(ops[op_num].mask_arg0 != 0) { - /* Two arguments */ - g_hal->log( - LOG_CPU, - ops[op_num].log, - (op & ops[op_num].mask_arg0) >> ops[op_num].shift_arg0, - op & ~(ops[op_num].mask | ops[op_num].mask_arg0)); - } else { - /* One argument */ - g_hal->log(LOG_CPU, ops[op_num].log, (op & ~ops[op_num].mask) >> ops[op_num].shift_arg0); - } - - if(call_depth < 10) { - for(i = 0; i < (10 - call_depth); i++) { - g_hal->log(LOG_CPU, " "); - } - } - - g_hal->log(LOG_CPU, " ; 0x%03X - ", op); - for(i = 0; i < 12; i++) { - g_hal->log(LOG_CPU, "%s", ((op >> (11 - i)) & 0x1) ? "1" : "0"); - } - g_hal->log( - LOG_CPU, - " - PC = 0x%04X, SP = 0x%02X, NP = 0x%02X, X = 0x%03X, Y = 0x%03X, A = 0x%X, B = 0x%X, F = 0x%X\n", - pc, - sp, - np, - x, - y, - a, - b, - flags); -} - -void cpu_reset(void) { - u13_t i; - - /* Registers and variables init */ - pc = TO_PC(0, 1, 0x00); // PC starts at bank 0, page 1, step 0 - np = TO_NP(0, 1); // NP starts at page 1 - a = 0; // undef - b = 0; // undef - x = 0; // undef - y = 0; // undef - sp = 0; // undef - flags = 0; - - /* Init RAM to zeros */ - for(i = 0; i < MEM_BUFFER_SIZE; i++) { - memory[i] = 0; - } - - SET_IO_MEMORY(memory, REG_K40_K43_BZ_OUTPUT_PORT, 0xF); // Output port (R40-R43) - SET_IO_MEMORY(memory, REG_LCD_CTRL, 0x8); // LCD control - /* TODO: Input relation register */ - - cpu_sync_ref_timestamp(); -} - -bool_t cpu_init(const u12_t* program, breakpoint_t* breakpoints, u32_t freq) { - g_program = program; - g_breakpoints = breakpoints; - ts_freq = freq; - - cpu_reset(); - - return 0; -} - -void cpu_release(void) { -} - -int cpu_step(void) { - u12_t op; - u8_t i; - breakpoint_t* bp = g_breakpoints; - static u8_t previous_cycles = 0; - - op = g_program[pc]; - - /* Lookup the OP code */ - for(i = 0; ops[i].log != NULL; i++) { - if((op & ops[i].mask) == ops[i].code) { - break; - } - } - - if(ops[i].log == NULL) { - g_hal->log(LOG_ERROR, "Unknown op-code 0x%X (pc = 0x%04X)\n", op, pc); - return 1; - } - - next_pc = (pc + 1) & 0x1FFF; - - /* Display the operation along with the current state of the processor */ - print_state(i, op, pc); - - /* Match the speed of the real processor - * NOTE: For better accuracy, the final wait should happen here, however - * the downside is that all interrupts will likely be delayed by one OP - */ - ref_ts = wait_for_cycles(ref_ts, previous_cycles); - - /* Process the OP code */ - if(ops[i].cb != NULL) { - if(ops[i].mask_arg0 != 0) { - /* Two arguments */ - ops[i].cb( - (op & ops[i].mask_arg0) >> ops[i].shift_arg0, - op & ~(ops[i].mask | ops[i].mask_arg0)); - } else { - /* One arguments */ - ops[i].cb((op & ~ops[i].mask) >> ops[i].shift_arg0, 0); - } - } - - /* Prepare for the next instruction */ - pc = next_pc; - previous_cycles = ops[i].cycles; - - if(i > 0) { - /* OP code is not PSET, reset NP */ - np = (pc >> 8) & 0x1F; - } - - /* Handle timers using the internal tick counter */ - if(tick_counter - clk_timer_timestamp >= TIMER_1HZ_PERIOD) { - do { - clk_timer_timestamp += TIMER_1HZ_PERIOD; - } while(tick_counter - clk_timer_timestamp >= TIMER_1HZ_PERIOD); - - generate_interrupt(INT_CLOCK_TIMER_SLOT, 3); - } - - if(prog_timer_enabled && tick_counter - prog_timer_timestamp >= TIMER_256HZ_PERIOD) { - do { - prog_timer_timestamp += TIMER_256HZ_PERIOD; - prog_timer_data--; - - if(prog_timer_data == 0) { - prog_timer_data = prog_timer_rld; - generate_interrupt(INT_PROG_TIMER_SLOT, 0); - } - } while(tick_counter - prog_timer_timestamp >= TIMER_256HZ_PERIOD); - } - - /* Check if there is any pending interrupt */ - if(I && i > 0) { // Do not process interrupts after a PSET operation - process_interrupts(); - } - - /* Check if we could pause the execution */ - while(bp != NULL) { - if(bp->addr == pc) { - return 1; - } - - bp = bp->next; - } - - return 0; -} diff --git a/applications/plugins/tama_p1/tamalib/cpu.h b/applications/plugins/tama_p1/tamalib/cpu.h deleted file mode 100644 index 4405103b2..000000000 --- a/applications/plugins/tama_p1/tamalib/cpu.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _CPU_H_ -#define _CPU_H_ - -#include "hal.h" - -#define MEMORY_SIZE 4096 // 4096 x 4 bits (640 x 4 bits of RAM) - -#define MEM_RAM_ADDR 0x000 -#define MEM_RAM_SIZE 0x280 -#define MEM_DISPLAY1_ADDR 0xE00 -#define MEM_DISPLAY1_SIZE 0x050 -#define MEM_DISPLAY2_ADDR 0xE80 -#define MEM_DISPLAY2_SIZE 0x050 -#define MEM_IO_ADDR 0xF00 -#define MEM_IO_SIZE 0x080 - -/* Define this if you want to reduce the footprint of the memory buffer from 4096 u4_t (most likely bytes) - * to 464 u8_t (bytes for sure), while increasing slightly the number of operations needed to read/write from/to it. - */ -#define LOW_FOOTPRINT - -#ifdef LOW_FOOTPRINT -/* Invalid memory areas are not buffered to reduce the footprint of the library in memory */ -#define MEM_BUFFER_SIZE (MEM_RAM_SIZE + MEM_DISPLAY1_SIZE + MEM_DISPLAY2_SIZE + MEM_IO_SIZE) / 2 - -/* Maps the CPU memory to the memory buffer */ -#define RAM_TO_MEMORY(n) ((n - MEM_RAM_ADDR) / 2) -#define DISP1_TO_MEMORY(n) ((n - MEM_DISPLAY1_ADDR + MEM_RAM_SIZE) / 2) -#define DISP2_TO_MEMORY(n) ((n - MEM_DISPLAY2_ADDR + MEM_RAM_SIZE + MEM_DISPLAY1_SIZE) / 2) -#define IO_TO_MEMORY(n) \ - ((n - MEM_IO_ADDR + MEM_RAM_SIZE + MEM_DISPLAY1_SIZE + MEM_DISPLAY2_SIZE) / 2) - -#define SET_RAM_MEMORY(buffer, n, v) \ - { \ - buffer[RAM_TO_MEMORY(n)] = (buffer[RAM_TO_MEMORY(n)] & ~(0xF << (((n) % 2) << 2))) | \ - ((v)&0xF) << (((n) % 2) << 2); \ - } -#define SET_DISP1_MEMORY(buffer, n, v) \ - { \ - buffer[DISP1_TO_MEMORY(n)] = (buffer[DISP1_TO_MEMORY(n)] & ~(0xF << (((n) % 2) << 2))) | \ - ((v)&0xF) << (((n) % 2) << 2); \ - } -#define SET_DISP2_MEMORY(buffer, n, v) \ - { \ - buffer[DISP2_TO_MEMORY(n)] = (buffer[DISP2_TO_MEMORY(n)] & ~(0xF << (((n) % 2) << 2))) | \ - ((v)&0xF) << (((n) % 2) << 2); \ - } -#define SET_IO_MEMORY(buffer, n, v) \ - { \ - buffer[IO_TO_MEMORY(n)] = (buffer[IO_TO_MEMORY(n)] & ~(0xF << (((n) % 2) << 2))) | \ - ((v)&0xF) << (((n) % 2) << 2); \ - } -#define SET_MEMORY(buffer, n, v) \ - { \ - if((n) < (MEM_RAM_ADDR + MEM_RAM_SIZE)) { \ - SET_RAM_MEMORY(buffer, n, v); \ - } else if((n) < MEM_DISPLAY1_ADDR) { \ - /* INVALID_MEMORY */ \ - } else if((n) < (MEM_DISPLAY1_ADDR + MEM_DISPLAY1_SIZE)) { \ - SET_DISP1_MEMORY(buffer, n, v); \ - } else if((n) < MEM_DISPLAY2_ADDR) { \ - /* INVALID_MEMORY */ \ - } else if((n) < (MEM_DISPLAY2_ADDR + MEM_DISPLAY2_SIZE)) { \ - SET_DISP2_MEMORY(buffer, n, v); \ - } else if((n) < MEM_IO_ADDR) { \ - /* INVALID_MEMORY */ \ - } else if((n) < (MEM_IO_ADDR + MEM_IO_SIZE)) { \ - SET_IO_MEMORY(buffer, n, v); \ - } else { \ - /* INVALID_MEMORY */ \ - } \ - } - -#define GET_RAM_MEMORY(buffer, n) ((buffer[RAM_TO_MEMORY(n)] >> (((n) % 2) << 2)) & 0xF) -#define GET_DISP1_MEMORY(buffer, n) ((buffer[DISP1_TO_MEMORY(n)] >> (((n) % 2) << 2)) & 0xF) -#define GET_DISP2_MEMORY(buffer, n) ((buffer[DISP2_TO_MEMORY(n)] >> (((n) % 2) << 2)) & 0xF) -#define GET_IO_MEMORY(buffer, n) ((buffer[IO_TO_MEMORY(n)] >> (((n) % 2) << 2)) & 0xF) -#define GET_MEMORY(buffer, n) \ - ((buffer \ - [((n) < (MEM_RAM_ADDR + MEM_RAM_SIZE)) ? RAM_TO_MEMORY(n) : \ - ((n) < MEM_DISPLAY1_ADDR) ? 0 : \ - ((n) < (MEM_DISPLAY1_ADDR + MEM_DISPLAY1_SIZE)) ? DISP1_TO_MEMORY(n) : \ - ((n) < MEM_DISPLAY2_ADDR) ? 0 : \ - ((n) < (MEM_DISPLAY2_ADDR + MEM_DISPLAY2_SIZE)) ? DISP2_TO_MEMORY(n) : \ - ((n) < MEM_IO_ADDR) ? 0 : \ - ((n) < (MEM_IO_ADDR + MEM_IO_SIZE)) ? IO_TO_MEMORY(n) : \ - 0] >> \ - (((n) % 2) << 2)) & \ - 0xF) - -#define MEM_BUFFER_TYPE u8_t -#else -#define MEM_BUFFER_SIZE MEMORY_SIZE - -#define SET_MEMORY(buffer, n, v) \ - { buffer[n] = v; } -#define SET_RAM_MEMORY(buffer, n, v) SET_MEMORY(buffer, n, v) -#define SET_DISP1_MEMORY(buffer, n, v) SET_MEMORY(buffer, n, v) -#define SET_DISP2_MEMORY(buffer, n, v) SET_MEMORY(buffer, n, v) -#define SET_IO_MEMORY(buffer, n, v) SET_MEMORY(buffer, n, v) - -#define GET_MEMORY(buffer, n) (buffer[n]) -#define GET_RAM_MEMORY(buffer, n) GET_MEMORY(buffer, n) -#define GET_DISP1_MEMORY(buffer, n) GET_MEMORY(buffer, n) -#define GET_DISP2_MEMORY(buffer, n) GET_MEMORY(buffer, n) -#define GET_IO_MEMORY(buffer, n) GET_MEMORY(buffer, n) - -#define MEM_BUFFER_TYPE u4_t -#endif - -typedef struct breakpoint { - u13_t addr; - struct breakpoint* next; -} breakpoint_t; - -/* Pins (TODO: add other pins) */ -typedef enum { - PIN_K00 = 0x0, - PIN_K01 = 0x1, - PIN_K02 = 0x2, - PIN_K03 = 0x3, - PIN_K10 = 0X4, - PIN_K11 = 0X5, - PIN_K12 = 0X6, - PIN_K13 = 0X7, -} pin_t; - -typedef enum { - PIN_STATE_LOW = 0, - PIN_STATE_HIGH = 1, -} pin_state_t; - -typedef enum { - INT_PROG_TIMER_SLOT = 0, - INT_SERIAL_SLOT = 1, - INT_K10_K13_SLOT = 2, - INT_K00_K03_SLOT = 3, - INT_STOPWATCH_SLOT = 4, - INT_CLOCK_TIMER_SLOT = 5, - INT_SLOT_NUM, -} int_slot_t; - -typedef struct { - u4_t factor_flag_reg; - u4_t mask_reg; - bool_t triggered; /* 1 if triggered, 0 otherwise */ - u8_t vector; -} interrupt_t; - -typedef struct { - u13_t* pc; - u12_t* x; - u12_t* y; - u4_t* a; - u4_t* b; - u5_t* np; - u8_t* sp; - u4_t* flags; - - u32_t* tick_counter; - u32_t* clk_timer_timestamp; - u32_t* prog_timer_timestamp; - bool_t* prog_timer_enabled; - u8_t* prog_timer_data; - u8_t* prog_timer_rld; - - u32_t* call_depth; - - interrupt_t* interrupts; - - MEM_BUFFER_TYPE* memory; -} state_t; - -void cpu_add_bp(breakpoint_t** list, u13_t addr); -void cpu_free_bp(breakpoint_t** list); - -void cpu_set_speed(u8_t speed); - -state_t* cpu_get_state(void); - -u32_t cpu_get_depth(void); - -void cpu_set_input_pin(pin_t pin, pin_state_t state); - -void cpu_sync_ref_timestamp(void); - -void cpu_refresh_hw(void); - -void cpu_reset(void); - -bool_t cpu_init(const u12_t* program, breakpoint_t* breakpoints, u32_t freq); -void cpu_release(void); - -int cpu_step(void); - -#endif /* _CPU_H_ */ diff --git a/applications/plugins/tama_p1/tamalib/hal.h b/applications/plugins/tama_p1/tamalib/hal.h deleted file mode 100644 index 84140befb..000000000 --- a/applications/plugins/tama_p1/tamalib/hal.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _HAL_H_ -#define _HAL_H_ - -#include "../hal_types.h" - -#ifndef NULL -#define NULL 0 -#endif - -typedef enum { - LOG_ERROR = 0x1, - LOG_INFO = (0x1 << 1), - LOG_MEMORY = (0x1 << 2), - LOG_CPU = (0x1 << 3), -} log_level_t; - -/* The Hardware Abstraction Layer - * NOTE: This structure acts as an abstraction layer between TamaLIB and the OS/SDK. - * All pointers MUST be implemented, but some implementations can be left empty. - */ -typedef struct { - /* Memory allocation functions - * NOTE: Needed only if breakpoints support is required. - */ - void* (*malloc)(u32_t size); - void (*free)(void* ptr); - - /* What to do if the CPU has halted - */ - void (*halt)(void); - - /* Log related function - * NOTE: Needed only if log messages are required. - */ - bool_t (*is_log_enabled)(log_level_t level); - void (*log)(log_level_t level, char* buff, ...); - - /* Clock related functions - * NOTE: Timestamps granularity is configured with tamalib_init(), an accuracy - * of ~30 us (1/32768) is required for a cycle accurate emulation. - */ - void (*sleep_until)(timestamp_t ts); - timestamp_t (*get_timestamp)(void); - - /* Screen related functions - * NOTE: In case of direct hardware access to pixels, the set_XXXX() functions - * (called for each pixel/icon update) can directly drive them, otherwise they - * should just store the data in a buffer and let update_screen() do the actual - * rendering (at 30 fps). - */ - void (*update_screen)(void); - void (*set_lcd_matrix)(u8_t x, u8_t y, bool_t val); - void (*set_lcd_icon)(u8_t icon, bool_t val); - - /* Sound related functions - * NOTE: set_frequency() changes the output frequency of the sound, while - * play_frequency() decides whether the sound should be heard or not. - */ - void (*set_frequency)(u32_t freq); - void (*play_frequency)(bool_t en); - - /* Event handler from the main app (if any) - * NOTE: This function usually handles button related events, states loading/saving ... - */ - int (*handler)(void); -} hal_t; - -extern hal_t* g_hal; - -#endif /* _HAL_H_ */ diff --git a/applications/plugins/tama_p1/tamalib/hal_types.h.template b/applications/plugins/tama_p1/tamalib/hal_types.h.template deleted file mode 100644 index 38c4d212c..000000000 --- a/applications/plugins/tama_p1/tamalib/hal_types.h.template +++ /dev/null @@ -1,32 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _HAL_TYPES_H_ -#define _HAL_TYPES_H_ - -typedef unsigned char bool_t; -typedef unsigned char u4_t; -typedef unsigned char u5_t; -typedef unsigned char u8_t; -typedef unsigned short u12_t; -typedef unsigned short u13_t; -typedef unsigned int u32_t; -typedef unsigned int timestamp_t; // WARNING: Must be an unsigned type to properly handle wrapping (u32 wraps in around 1h11m when expressed in us) - -#endif /* _HAL_TYPES_H_ */ diff --git a/applications/plugins/tama_p1/tamalib/hw.c b/applications/plugins/tama_p1/tamalib/hw.c deleted file mode 100644 index 0a91f2a78..000000000 --- a/applications/plugins/tama_p1/tamalib/hw.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "hw.h" -#include "cpu.h" -#include "hal.h" - -/* SEG -> LCD mapping */ -static u8_t seg_pos[40] = {0, 1, 2, 3, 4, 5, 6, 7, 32, 8, 9, 10, 11, 12, - 13, 14, 15, 33, 34, 35, 31, 30, 29, 28, 27, 26, 25, 24, - 36, 23, 22, 21, 20, 19, 18, 17, 16, 37, 38, 39}; - -bool_t hw_init(void) { - /* Buttons are active LOW */ - cpu_set_input_pin(PIN_K00, PIN_STATE_HIGH); - cpu_set_input_pin(PIN_K01, PIN_STATE_HIGH); - cpu_set_input_pin(PIN_K02, PIN_STATE_HIGH); - - return 0; -} - -void hw_release(void) { -} - -void hw_set_lcd_pin(u8_t seg, u8_t com, u8_t val) { - if(seg_pos[seg] < LCD_WIDTH) { - g_hal->set_lcd_matrix(seg_pos[seg], com, val); - } else { - /* - * IC n -> seg-com|... - * IC 0 -> 8-0 |18-3 |19-2 - * IC 1 -> 8-1 |17-0 |19-3 - * IC 2 -> 8-2 |17-1 |37-12|38-13|39-14 - * IC 3 -> 8-3 |17-2 |18-1 |19-0 - * IC 4 -> 28-12|37-13|38-14|39-15 - * IC 5 -> 28-13|37-14|38-15 - * IC 6 -> 28-14|37-15|39-12 - * IC 7 -> 28-15|38-12|39-13 - */ - if(seg == 8 && com < 4) { - g_hal->set_lcd_icon(com, val); - } else if(seg == 28 && com >= 12) { - g_hal->set_lcd_icon(com - 8, val); - } - } -} - -void hw_set_button(button_t btn, btn_state_t state) { - pin_state_t pin_state = (state == BTN_STATE_PRESSED) ? PIN_STATE_LOW : PIN_STATE_HIGH; - - switch(btn) { - case BTN_LEFT: - cpu_set_input_pin(PIN_K02, pin_state); - break; - - case BTN_MIDDLE: - cpu_set_input_pin(PIN_K01, pin_state); - break; - - case BTN_RIGHT: - cpu_set_input_pin(PIN_K00, pin_state); - break; - } -} - -void hw_set_buzzer_freq(u4_t freq) { - u32_t snd_freq = 0; - - switch(freq) { - case 0: - /* 4096.0 Hz */ - snd_freq = 40960; - break; - - case 1: - /* 3276.8 Hz */ - snd_freq = 32768; - break; - - case 2: - /* 2730.7 Hz */ - snd_freq = 27307; - break; - - case 3: - /* 2340.6 Hz */ - snd_freq = 23406; - break; - - case 4: - /* 2048.0 Hz */ - snd_freq = 20480; - break; - - case 5: - /* 1638.4 Hz */ - snd_freq = 16384; - break; - - case 6: - /* 1365.3 Hz */ - snd_freq = 13653; - break; - - case 7: - /* 1170.3 Hz */ - snd_freq = 11703; - break; - } - - if(snd_freq != 0) { - g_hal->set_frequency(snd_freq); - } -} - -void hw_enable_buzzer(bool_t en) { - g_hal->play_frequency(en); -} diff --git a/applications/plugins/tama_p1/tamalib/hw.h b/applications/plugins/tama_p1/tamalib/hw.h deleted file mode 100644 index 853515b39..000000000 --- a/applications/plugins/tama_p1/tamalib/hw.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _HW_H_ -#define _HW_H_ - -#include "hal.h" - -#define LCD_WIDTH 32 -#define LCD_HEIGHT 16 - -#define ICON_NUM 8 - -typedef enum { - BTN_STATE_RELEASED = 0, - BTN_STATE_PRESSED, -} btn_state_t; - -typedef enum { - BTN_LEFT = 0, - BTN_MIDDLE, - BTN_RIGHT, -} button_t; - -bool_t hw_init(void); -void hw_release(void); - -void hw_set_lcd_pin(u8_t seg, u8_t com, u8_t val); -void hw_set_button(button_t btn, btn_state_t state); - -void hw_set_buzzer_freq(u4_t freq); -void hw_enable_buzzer(bool_t en); - -#endif /* _HW_H_ */ diff --git a/applications/plugins/tama_p1/tamalib/tamalib.c b/applications/plugins/tama_p1/tamalib/tamalib.c deleted file mode 100644 index 92a19678c..000000000 --- a/applications/plugins/tama_p1/tamalib/tamalib.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#include "tamalib.h" -#include "hw.h" -#include "cpu.h" -#include "hal.h" - -#define DEFAULT_FRAMERATE 30 // fps - -static exec_mode_t exec_mode = EXEC_MODE_RUN; - -static u32_t step_depth = 0; - -static timestamp_t screen_ts = 0; - -static u32_t ts_freq; - -static u8_t g_framerate = DEFAULT_FRAMERATE; - -hal_t* g_hal; - -bool_t tamalib_init(const u12_t* program, breakpoint_t* breakpoints, u32_t freq) { - bool_t res = 0; - - res |= cpu_init(program, breakpoints, freq); - res |= hw_init(); - - ts_freq = freq; - - return res; -} - -void tamalib_release(void) { - hw_release(); - cpu_release(); -} - -void tamalib_set_framerate(u8_t framerate) { - g_framerate = framerate; -} - -u8_t tamalib_get_framerate(void) { - return g_framerate; -} - -void tamalib_register_hal(hal_t* hal) { - g_hal = hal; -} - -void tamalib_set_exec_mode(exec_mode_t mode) { - exec_mode = mode; - step_depth = cpu_get_depth(); - cpu_sync_ref_timestamp(); -} - -void tamalib_step(void) { - if(exec_mode == EXEC_MODE_PAUSE) { - return; - } - - if(cpu_step()) { - exec_mode = EXEC_MODE_PAUSE; - step_depth = cpu_get_depth(); - } else { - switch(exec_mode) { - case EXEC_MODE_PAUSE: - case EXEC_MODE_RUN: - break; - - case EXEC_MODE_STEP: - exec_mode = EXEC_MODE_PAUSE; - break; - - case EXEC_MODE_NEXT: - if(cpu_get_depth() <= step_depth) { - exec_mode = EXEC_MODE_PAUSE; - step_depth = cpu_get_depth(); - } - break; - - case EXEC_MODE_TO_CALL: - if(cpu_get_depth() > step_depth) { - exec_mode = EXEC_MODE_PAUSE; - step_depth = cpu_get_depth(); - } - break; - - case EXEC_MODE_TO_RET: - if(cpu_get_depth() < step_depth) { - exec_mode = EXEC_MODE_PAUSE; - step_depth = cpu_get_depth(); - } - break; - } - } -} - -void tamalib_mainloop(void) { - timestamp_t ts; - - while(!g_hal->handler()) { - tamalib_step(); - - /* Update the screen @ g_framerate fps */ - ts = g_hal->get_timestamp(); - if(ts - screen_ts >= ts_freq / g_framerate) { - screen_ts = ts; - g_hal->update_screen(); - } - } -} diff --git a/applications/plugins/tama_p1/tamalib/tamalib.h b/applications/plugins/tama_p1/tamalib/tamalib.h deleted file mode 100644 index 570f845eb..000000000 --- a/applications/plugins/tama_p1/tamalib/tamalib.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library - * - * Copyright (C) 2021 Jean-Christophe Rona - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -#ifndef _TAMALIB_H_ -#define _TAMALIB_H_ - -#include "cpu.h" -#include "hw.h" -#include "hal.h" - -#define tamalib_set_button(btn, state) hw_set_button(btn, state) - -#define tamalib_set_speed(speed) cpu_set_speed(speed) - -#define tamalib_get_state() cpu_get_state() -#define tamalib_refresh_hw() cpu_refresh_hw() - -#define tamalib_reset() cpu_reset() - -#define tamalib_add_bp(list, addr) cpu_add_bp(list, addr) -#define tamalib_free_bp(list) cpu_free_bp(list) - -typedef enum { - EXEC_MODE_PAUSE, - EXEC_MODE_RUN, - EXEC_MODE_STEP, - EXEC_MODE_NEXT, - EXEC_MODE_TO_CALL, - EXEC_MODE_TO_RET, -} exec_mode_t; - -void tamalib_release(void); -bool_t tamalib_init(const u12_t* program, breakpoint_t* breakpoints, u32_t freq); - -void tamalib_set_framerate(u8_t framerate); -u8_t tamalib_get_framerate(void); - -void tamalib_register_hal(hal_t* hal); - -void tamalib_set_exec_mode(exec_mode_t mode); - -/* NOTE: Only one of these two functions must be used in the main application - * (tamalib_step() should be used only if tamalib_mainloop() does not fit the - * main application execution flow). - */ -void tamalib_step(void); -void tamalib_mainloop(void); - -#endif /* _TAMALIB_H_ */ diff --git a/applications/plugins/tictactoe_game/application.fam b/applications/plugins/tictactoe_game/application.fam deleted file mode 100644 index 2ad09f11b..000000000 --- a/applications/plugins/tictactoe_game/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="TicTacToe", - name="Tic Tac Toe", - apptype=FlipperAppType.EXTERNAL, - entry_point="tictactoe_game_app", - cdefines=["APP_TICTACTOE_GAME"], - requires=["gui"], - stack_size=1 * 1024, - order=250, - fap_icon="tictactoe_10px.png", - fap_category="Games", -) diff --git a/applications/plugins/tictactoe_game/tictactoe_10px.png b/applications/plugins/tictactoe_game/tictactoe_10px.png deleted file mode 100644 index 41ca1d973..000000000 Binary files a/applications/plugins/tictactoe_game/tictactoe_10px.png and /dev/null differ diff --git a/applications/plugins/tictactoe_game/tictactoe_game.c b/applications/plugins/tictactoe_game/tictactoe_game.c deleted file mode 100644 index fe57d7c62..000000000 --- a/applications/plugins/tictactoe_game/tictactoe_game.c +++ /dev/null @@ -1,382 +0,0 @@ -#include -#include -#include -#include -#include - -#define TAG "TicTacToe" - -typedef enum { EventTypeTick, EventTypeKey } EventType; - -typedef struct { - FuriTimer* timer; - uint8_t selBoxX; - uint8_t selBoxY; - - uint8_t selX; - uint8_t selY; - - uint16_t scoreX; - uint16_t scoreO; - - char player; - - char field[3][3]; - bool fieldx[3][3]; - - uint8_t coords[3]; - - bool button_state; - -} TicTacToeState; - -typedef struct { - EventType type; - InputEvent input; -} GameEvent; - -void drawCross(Canvas* const canvas, uint8_t x, uint8_t y) { - canvas_draw_line(canvas, x, y, x + 9, y + 9); // top left - bottom right slash - canvas_draw_line(canvas, x + 9, y, x, y + 9); // down left - top right slash -} - -void drawCircle(Canvas* const canvas, uint8_t x, uint8_t y) { - canvas_draw_circle(canvas, x + 4, y + 5, 5); -} - -void player_switch(TicTacToeState* ts) { - if(ts->player == 'O') { - ts->player = 'X'; - } else if(ts->player == 'X') { - ts->player = 'O'; - } -} - -void tictactoe_draw(Canvas* canvas, TicTacToeState* ts) { - // Draws the game field - canvas_draw_frame(canvas, 0, 0, 64, 64); // frame - canvas_draw_line(canvas, 0, 21, 63, 21); // horizontal line - canvas_draw_line(canvas, 0, 42, 63, 42); // horizontal line - canvas_draw_line(canvas, 21, 0, 21, 63); // vertical line - canvas_draw_line(canvas, 42, 0, 42, 63); // vertical line - - // Draws the game field elements (X or O) - for(uint8_t i = 0; i <= 2; i++) { - for(uint8_t j = 0; j <= 2; j++) { - if(ts->field[i][j] == 'O') { - drawCircle(canvas, ts->coords[i], ts->coords[j]); - } else if(ts->field[i][j] == 'X') { - drawCross(canvas, ts->coords[i], ts->coords[j]); - } - } - } - - // Draws the selection box - if(ts->selX == 1) { - ts->selBoxX = 1; - } else if(ts->selX == 2) { - ts->selBoxX = 22; - } else if(ts->selX == 3) { - ts->selBoxX = 43; - } - - if(ts->selY == 1) { - ts->selBoxY = 1; - } else if(ts->selY == 2) { - ts->selBoxY = 22; - } else if(ts->selY == 3) { - ts->selBoxY = 43; - } - - canvas_set_color(canvas, ColorBlack); - canvas_draw_frame(canvas, ts->selBoxX, ts->selBoxY, 20, 20); - canvas_draw_frame(canvas, ts->selBoxX + 1, ts->selBoxY + 1, 18, 18); - - // Draws the sidebar - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 81, 10, "SCORE"); - canvas_draw_str(canvas, 75, 24, "X:"); - - char scoreXBuffer[10]; - snprintf(scoreXBuffer, sizeof(scoreXBuffer), "%d", ts->scoreX); - canvas_draw_str(canvas, 88, 24, scoreXBuffer); - canvas_draw_str(canvas, 75, 35, "O:"); - - char scoreOBuffer[10]; - snprintf(scoreOBuffer, sizeof(scoreOBuffer), "%d", ts->scoreO); - canvas_draw_str(canvas, 88, 35, scoreOBuffer); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 75, 46, "Player:"); - - if(ts->player == 'X') { - drawCross(canvas, 93, 50); - } else if(ts->player == 'O') { - drawCircle(canvas, 93, 50); - } -} - -void clear_game_field(TicTacToeState* ts) { - // Clears the game field arrays - for(uint8_t i = 0; i <= 2; i++) { - for(uint8_t j = 0; j <= 2; j++) { - ts->field[i][j] = ' '; - ts->fieldx[i][j] = false; - } - } - - ts->selX = 2; // Centers the selection box on X axis - ts->selY = 2; // Centers the selection box on Y axis -} - -void reset_game_data(TicTacToeState* ts) { - ts->scoreO = 0; - ts->scoreX = 0; - ts->player = 'X'; -} - -void draw_win(Canvas* canvas, char player, TicTacToeState* ts) { - // Handles the score table - if(player == 'X') { - ts->scoreX++; - } else if(player == 'O') { - ts->scoreO++; - } - - // Switches the players - player_switch(ts); - - // Draws the board with players switched - tictactoe_draw(canvas, ts); - - // Clear the game field - clear_game_field(ts); - - // Draw the new board - tictactoe_draw(canvas, ts); -} - -static void tictactoe_state_init(TicTacToeState* tictactoe_state) { - // Set the initial game state - tictactoe_state->selX = 2; - tictactoe_state->selY = 2; - tictactoe_state->player = 'X'; - tictactoe_state->coords[0] = 6; - tictactoe_state->coords[1] = 27; - tictactoe_state->coords[2] = 48; - tictactoe_state->button_state = false; - - clear_game_field(tictactoe_state); - - reset_game_data(tictactoe_state); -} - -static void tictactoe_draw_callback(Canvas* const canvas, void* ctx) { - TicTacToeState* ticst = acquire_mutex((ValueMutex*)ctx, 25); - if(ticst == NULL) { - return; - } - - if(ticst->selX > 3) { - ticst->selX = 3; - } else if(ticst->selX < 1) { - ticst->selX = 1; - } - - if(ticst->selY > 3) { - ticst->selY = 3; - } else if(ticst->selY < 1) { - ticst->selY = 1; - } - - // Assigns the game field elements their value (X or O) when the OK button is pressed - if(ticst->button_state) { - ticst->button_state = false; - for(uint8_t i = 0; i <= 2; i++) { - for(uint8_t j = 0; j <= 2; j++) { - if((ticst->selX == i + 1) && (ticst->selY == j + 1) && - (ticst->fieldx[i][j] == false)) { - if(ticst->player == 'X') { - ticst->field[i][j] = 'X'; - ticst->fieldx[i][j] = true; - player_switch(ticst); - } else if(ticst->player == 'O') { - ticst->field[i][j] = 'O'; - ticst->fieldx[i][j] = true; - player_switch(ticst); - } - } - } - } - } - - // Checks the game field for winning combinations - if((ticst->field[0][0] == 'X') && (ticst->field[1][0] == 'X') && (ticst->field[2][0] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[0][1] == 'X') && (ticst->field[1][1] == 'X') && - (ticst->field[2][1] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[0][2] == 'X') && (ticst->field[1][2] == 'X') && - (ticst->field[2][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[0][0] == 'X') && (ticst->field[0][1] == 'X') && - (ticst->field[0][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[1][0] == 'X') && (ticst->field[1][1] == 'X') && - (ticst->field[1][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[2][0] == 'X') && (ticst->field[2][1] == 'X') && - (ticst->field[2][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[0][0] == 'X') && (ticst->field[1][1] == 'X') && - (ticst->field[2][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[2][0] == 'X') && (ticst->field[1][1] == 'X') && - (ticst->field[0][2] == 'X')) { - draw_win(canvas, 'X', ticst); - } else if( - (ticst->field[0][0] == 'O') && (ticst->field[1][0] == 'O') && - (ticst->field[2][0] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[0][1] == 'O') && (ticst->field[1][1] == 'O') && - (ticst->field[2][1] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[0][2] == 'O') && (ticst->field[1][2] == 'O') && - (ticst->field[2][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[0][0] == 'O') && (ticst->field[0][1] == 'O') && - (ticst->field[0][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[1][0] == 'O') && (ticst->field[1][1] == 'O') && - (ticst->field[1][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[2][0] == 'O') && (ticst->field[2][1] == 'O') && - (ticst->field[2][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[0][0] == 'O') && (ticst->field[1][1] == 'O') && - (ticst->field[2][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->field[2][0] == 'O') && (ticst->field[1][1] == 'O') && - (ticst->field[0][2] == 'O')) { - draw_win(canvas, 'O', ticst); - } else if( - (ticst->fieldx[0][0] == true) && (ticst->fieldx[0][1] == true) && - (ticst->fieldx[0][2] == true) && (ticst->fieldx[1][0] == true) && - (ticst->fieldx[1][1] == true) && (ticst->fieldx[1][2] == true) && - (ticst->fieldx[2][0] == true) && (ticst->fieldx[2][1] == true) && - (ticst->fieldx[2][2] == true)) { - draw_win(canvas, 'T', ticst); - } - - tictactoe_draw(canvas, ticst); - - release_mutex((ValueMutex*)ctx, ticst); -} - -static void tictactoe_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - GameEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void tictactoe_update_timer_callback(FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - GameEvent event = {.type = EventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -int32_t tictactoe_game_app(void* p) { - UNUSED(p); - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(GameEvent)); - - TicTacToeState* tictactoe_state = malloc(sizeof(TicTacToeState)); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, tictactoe_state, sizeof(TicTacToeState))) { - FURI_LOG_E(TAG, "Cannot create mutex\r\n"); - furi_message_queue_free(event_queue); - free(tictactoe_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, tictactoe_draw_callback, &state_mutex); - view_port_input_callback_set(view_port, tictactoe_input_callback, event_queue); - - tictactoe_state->timer = - furi_timer_alloc(tictactoe_update_timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(tictactoe_state->timer, furi_kernel_get_tick_frequency() / 22); - - tictactoe_state_init(tictactoe_state); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - GameEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - TicTacToeState* tictactoe_state = (TicTacToeState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - // Key events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyBack: - processing = false; - break; - case InputKeyRight: - tictactoe_state->selX++; - break; - case InputKeyLeft: - tictactoe_state->selX--; - break; - case InputKeyUp: - tictactoe_state->selY--; - break; - case InputKeyDown: - tictactoe_state->selY++; - break; - case InputKeyOk: - tictactoe_state->button_state = true; - break; - default: - break; - } - } - } - } - - view_port_update(view_port); - release_mutex(&state_mutex, tictactoe_state); - } - - furi_timer_free(tictactoe_state->timer); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - free(tictactoe_state); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/trex_runner/.editorconfig b/applications/plugins/trex_runner/.editorconfig deleted file mode 100644 index 8b9972089..000000000 --- a/applications/plugins/trex_runner/.editorconfig +++ /dev/null @@ -1,30 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -root = true - -[*] - -# Change these settings to your own preference -indent_style = space -indent_size = 4 - -# We recommend you to keep these unchanged -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false - -[Makefile] -indent_style = tab - -[*.{yml,jade,js,css,lua,json}] -indent_size = 2 - -[*.go] -indent_style = tab -indent_size = 4 diff --git a/applications/plugins/trex_runner/.gitignore b/applications/plugins/trex_runner/.gitignore deleted file mode 100644 index 7b6e9d57b..000000000 --- a/applications/plugins/trex_runner/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.idea/ -/cmake-build-*/ diff --git a/applications/plugins/trex_runner/LICENSE b/applications/plugins/trex_runner/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/trex_runner/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/trex_runner/Makefile b/applications/plugins/trex_runner/Makefile deleted file mode 100644 index c9e3c6540..000000000 --- a/applications/plugins/trex_runner/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -FLIPPER_FIRMWARE_PATH ?= /home/gelin/work/github/flipperzero-firmware/ - -.PHONY: build -build: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner - cd $(FLIPPER_FIRMWARE_PATH) && ./fbt fap_t-rex-runner - -.PHONY: launch -launch: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner - cd $(FLIPPER_FIRMWARE_PATH) && ./fbt launch_app APPSRC=applications_user/t-rex-runner - -.PHONY: assets -assets: - rm assets_icons.* - $(MAKE) assets_icons.c - -assets_icons.c: $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner - cd $(FLIPPER_FIRMWARE_PATH) && ./scripts/assets.py icons applications_user/t-rex-runner/assets/ applications_user/t-rex-runner/ - -$(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner: - ln -s $(PWD) $(FLIPPER_FIRMWARE_PATH)/applications_user/t-rex-runner diff --git a/applications/plugins/trex_runner/README.md b/applications/plugins/trex_runner/README.md deleted file mode 100644 index 96ec3db00..000000000 --- a/applications/plugins/trex_runner/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# t-rex-runner -Flipper Zero port of Chrome's running T-rex game - -## Compiling - -You need a full source of the [Flipper Zero firmware](https://github.com/flipperdevices/flipperzero-firmware/tree/release), -take the `release` branch to build for the stable release. - -Copy or symlink this folder as `flipperzero-firmware/applications_user/t-rex-runner`. - -Run the build from the root of the firmware folder: -``` -./fbt firmware_t-rex-runner -``` - -If you have Flipper Zero attached to USB, you can immediately compile and run the app on device: -``` -./fbt launch_app APPSRC=applications_user/t-rex-runner -``` diff --git a/applications/plugins/trex_runner/application.fam b/applications/plugins/trex_runner/application.fam deleted file mode 100644 index e37bb23a1..000000000 --- a/applications/plugins/trex_runner/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="TRex_Runner", - name="T-Rex Runner", - apptype=FlipperAppType.EXTERNAL, - entry_point="trexrunner_app", - cdefines=["APP_TREXRUNNER"], - requires=["gui"], - stack_size=8 * 1024, - fap_category="Misc", - fap_icon="trexrunner_icon.png", - order=36, -) diff --git a/applications/plugins/trex_runner/assets/Dino.png b/applications/plugins/trex_runner/assets/Dino.png deleted file mode 100644 index 9e33092d6..000000000 Binary files a/applications/plugins/trex_runner/assets/Dino.png and /dev/null differ diff --git a/applications/plugins/trex_runner/assets/DinoRun0.png b/applications/plugins/trex_runner/assets/DinoRun0.png deleted file mode 100644 index f55faebce..000000000 Binary files a/applications/plugins/trex_runner/assets/DinoRun0.png and /dev/null differ diff --git a/applications/plugins/trex_runner/assets/DinoRun1.png b/applications/plugins/trex_runner/assets/DinoRun1.png deleted file mode 100644 index d1e738f5e..000000000 Binary files a/applications/plugins/trex_runner/assets/DinoRun1.png and /dev/null differ diff --git a/applications/plugins/trex_runner/assets/HorizonLine0.png b/applications/plugins/trex_runner/assets/HorizonLine0.png deleted file mode 100644 index b326cbb7f..000000000 Binary files a/applications/plugins/trex_runner/assets/HorizonLine0.png and /dev/null differ diff --git a/applications/plugins/trex_runner/assets/HorizonLine1.png b/applications/plugins/trex_runner/assets/HorizonLine1.png deleted file mode 100644 index f63a0a74e..000000000 Binary files a/applications/plugins/trex_runner/assets/HorizonLine1.png and /dev/null differ diff --git a/applications/plugins/trex_runner/assets_icons.c b/applications/plugins/trex_runner/assets_icons.c deleted file mode 100644 index b5c328e11..000000000 --- a/applications/plugins/trex_runner/assets_icons.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "assets_icons.h" - -#include - -const uint8_t _I_Dino_0[] = { - 0x01, 0x00, 0x3d, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec, - 0x01, 0x08, 0x14, 0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40, - 0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff, 0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40, - 0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01, 0xf1, 0xf8, 0x0c, 0x47, - 0xc1, 0x06, 0x80, 0x58, 0x20, 0x90, 0x09, 0x00, 0x08, 0x6c, 0x10, 0xc8, 0x00, -}; -const uint8_t* const _I_Dino[] = {_I_Dino_0}; - -const uint8_t _I_DinoRun0_0[] = { - 0x01, 0x00, 0x3b, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec, 0x01, 0x08, 0x14, - 0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40, 0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff, - 0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40, 0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01, - 0xf1, 0xf8, 0x0c, 0x47, 0xc1, 0x0c, 0x80, 0x58, 0x04, 0xa3, 0x20, 0x01, 0x08, 0x14, 0x80, -}; -const uint8_t* const _I_DinoRun0[] = {_I_DinoRun0_0}; - -const uint8_t _I_DinoRun1_0[] = { - 0x01, 0x00, 0x3b, 0x00, 0x80, 0x7e, 0x20, 0xf0, 0x0f, 0xe4, 0x3e, 0x01, 0xec, 0x01, 0x08, 0x14, - 0x80, 0x4b, 0x7c, 0x0a, 0x0f, 0xf2, 0x07, 0x01, 0x9f, 0x40, 0x30, 0x33, 0xf8, 0x07, 0x0f, 0xff, - 0x00, 0xf3, 0xef, 0xe0, 0x1f, 0xf0, 0x40, 0x80, 0x8b, 0xfd, 0x1f, 0x0b, 0x08, 0x08, 0x7f, 0x01, - 0xf1, 0xf8, 0x0c, 0x46, 0xc1, 0x06, 0x80, 0x70, 0x20, 0x82, 0x61, 0x01, 0x14, 0x32, 0x00, -}; -const uint8_t* const _I_DinoRun1[] = {_I_DinoRun1_0}; - -const uint8_t _I_HorizonLine0_0[] = { - 0x01, 0x00, 0x9c, 0x00, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0, - 0x0f, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0, 0x0f, 0x00, 0x78, - 0x03, 0xc0, 0x17, 0xff, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x04, 0x96, 0xbc, 0x01, 0xe0, - 0x0f, 0x00, 0x78, 0x03, 0xc0, 0x1e, 0x00, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0x78, 0x08, 0x18, 0x2e, - 0xa0, 0xe0, 0x97, 0x8e, 0x09, 0x7a, 0x3c, 0x36, 0xf1, 0xa6, 0xf0, 0x08, 0x91, 0x20, 0x05, 0x88, - 0x66, 0x01, 0x27, 0x80, 0x01, 0x95, 0x00, 0x23, 0x10, 0x60, 0x21, 0xc1, 0x20, 0x1e, 0x00, 0xfb, - 0x40, 0x40, 0xeb, 0x0e, 0x02, 0xa5, 0x8a, 0x01, 0x38, 0x2d, 0x78, 0x03, 0xc9, 0x86, 0x00, 0x48, - 0x40, 0x5b, 0x21, 0x80, 0x98, 0x0b, 0x91, 0x13, 0xe0, 0x48, 0x74, 0x9e, 0x1f, 0xaa, 0xe0, 0x1a, - 0x7a, 0x00, 0xe0, 0x5c, 0xfe, 0x00, 0x66, 0x74, 0x00, 0x0e, 0x20, 0x03, 0x28, 0x7b, 0x55, 0x21, - 0xe1, 0x27, 0x61, 0x08, 0x03, 0xd4, 0x50, 0x3a, 0x98, 0x78, 0xe0, 0xc0, 0x0f, 0x30, 0x26, 0x40, -}; -const uint8_t* const _I_HorizonLine0[] = {_I_HorizonLine0_0}; - -const uint8_t _I_HorizonLine1_0[] = { - 0x01, 0x00, 0xc6, 0x00, 0x00, 0x7f, 0x02, 0x1e, 0x11, 0xf0, 0x07, 0x80, 0x17, 0x01, 0x1f, 0x01, - 0x18, 0x03, 0xc0, 0x19, 0x60, 0x8c, 0x04, 0x7c, 0x01, 0xe7, 0x26, 0x88, 0x00, 0x8c, 0x01, 0xe0, - 0x0c, 0x9c, 0x4c, 0x02, 0x3e, 0x00, 0xf0, 0x02, 0xdc, 0x2c, 0x00, 0x23, 0x00, 0x78, 0x03, 0x21, - 0x9c, 0x00, 0x8f, 0x80, 0x3c, 0x00, 0xb1, 0x8c, 0x04, 0x06, 0x18, 0x02, 0x10, 0x96, 0x7f, 0xc0, - 0x1d, 0x07, 0xc0, 0x00, 0xc6, 0x07, 0xf8, 0x0a, 0xf8, 0x03, 0xc0, 0x03, 0x0f, 0x1c, 0x8c, 0x1c, - 0x79, 0xc6, 0xdf, 0x00, 0x1c, 0x1a, 0x18, 0x11, 0xf0, 0x07, 0x80, 0x3c, 0x01, 0xe0, 0x08, 0xfe, - 0x1b, 0xc4, 0x01, 0xe0, 0x0f, 0x00, 0x78, 0x02, 0x70, 0x10, 0x30, 0x5d, 0x12, 0x22, 0x38, 0x25, - 0xe8, 0xf0, 0xdb, 0xc6, 0x9b, 0xc0, 0x22, 0x44, 0x80, 0x16, 0x21, 0x98, 0x04, 0x9e, 0x00, 0x06, - 0x54, 0x07, 0xa4, 0x81, 0x0e, 0x09, 0x00, 0xf0, 0x07, 0xda, 0x02, 0x07, 0x58, 0x70, 0x15, 0x2c, - 0x50, 0x09, 0xc1, 0x6b, 0xc0, 0x1e, 0x4c, 0x30, 0x02, 0x42, 0x02, 0xd9, 0x0c, 0x04, 0xc0, 0x5c, - 0x88, 0x9f, 0x02, 0x43, 0xa4, 0xf0, 0xfd, 0x57, 0x00, 0xd3, 0xd0, 0x07, 0x02, 0xe7, 0xf0, 0x03, - 0x33, 0xa0, 0x00, 0x71, 0x00, 0x19, 0x43, 0xda, 0xa9, 0x0f, 0x09, 0x3b, 0x08, 0x40, 0x1e, 0xa2, - 0x81, 0xd4, 0xc3, 0xc7, 0x06, 0x00, 0x79, 0x81, 0x32, 0x00, -}; -const uint8_t* const _I_HorizonLine1[] = {_I_HorizonLine1_0}; - -const Icon I_Dino = - {.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_Dino}; -const Icon I_DinoRun0 = - {.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun0}; -const Icon I_DinoRun1 = - {.width = 20, .height = 22, .frame_count = 1, .frame_rate = 0, .frames = _I_DinoRun1}; -//const Icon I_HorizonLine0 = {.width=600,.height=12,.frame_count=1,.frame_rate=0,.frames=_I_HorizonLine0}; -//const Icon I_HorizonLine1 = {.width=600,.height=12,.frame_count=1,.frame_rate=0,.frames=_I_HorizonLine1}; diff --git a/applications/plugins/trex_runner/assets_icons.h b/applications/plugins/trex_runner/assets_icons.h deleted file mode 100644 index 05fe6f332..000000000 --- a/applications/plugins/trex_runner/assets_icons.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include - -extern const Icon I_Dino; -extern const Icon I_DinoRun0; -extern const Icon I_DinoRun1; -//extern const Icon I_HorizonLine0; -//extern const Icon I_HorizonLine1; diff --git a/applications/plugins/trex_runner/trexrunner.c b/applications/plugins/trex_runner/trexrunner.c deleted file mode 100644 index 699021b6a..000000000 --- a/applications/plugins/trex_runner/trexrunner.c +++ /dev/null @@ -1,155 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "assets_icons.h" - -#define DINO_START_X 0 -#define DINO_START_Y 42 - -#define FPS 60 - -#define DINO_RUNNING_MS_PER_FRAME 100 - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef struct { - FuriTimer* timer; - uint32_t last_tick; - const Icon* dino_icon; - int dino_frame_ms; -} GameState; - -static void timer_callback(void* ctx) { - GameState* game_state = acquire_mutex((ValueMutex*)ctx, 25); - if(game_state == NULL) { - return; - } - - uint32_t ticks_elapsed = furi_get_tick() - game_state->last_tick; - int delta_time_ms = ticks_elapsed * 1000 / furi_kernel_get_tick_frequency(); - - // dino update - game_state->dino_frame_ms += delta_time_ms; - // TODO: switch by dino state - if(game_state->dino_frame_ms >= DINO_RUNNING_MS_PER_FRAME) { - if(game_state->dino_icon == &I_DinoRun0) { - game_state->dino_icon = &I_DinoRun1; - } else { - game_state->dino_icon = &I_DinoRun0; - } - game_state->dino_frame_ms = 0; - } - - release_mutex((ValueMutex*)ctx, game_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void render_callback(Canvas* const canvas, void* ctx) { - const GameState* game_state = acquire_mutex((ValueMutex*)ctx, 25); - if(game_state == NULL) { - return; - } - - // canvas_draw_xbm(canvas, 0, 0, dino_width, dino_height, dino_bits); - canvas_draw_icon(canvas, DINO_START_X, DINO_START_Y, game_state->dino_icon); - - release_mutex((ValueMutex*)ctx, game_state); -} - -static void game_state_init(GameState* const game_state) { - game_state->last_tick = furi_get_tick(); - game_state->dino_frame_ms = 0; - game_state->dino_icon = &I_Dino; -} - -int32_t trexrunner_app(void* p) { - UNUSED(p); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - GameState* game_state = malloc(sizeof(GameState)); - game_state_init(game_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, game_state, sizeof(game_state))) { - FURI_LOG_E("T-rex runner", "cannot create mutex\r\n"); - free(game_state); - return 255; - } - // BEGIN IMPLEMENTATION - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - game_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, &state_mutex); - - furi_timer_start(game_state->timer, (uint32_t)furi_kernel_get_tick_frequency() / FPS); - - // Open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - // Minesweeper* minesweeper_state = (Minesweeper*)acquire_mutex_block(&state_mutex); - if(event_status == FuriStatusOk) { - // press events - if(event.type == EventTypeKey) { - if(event.input.type == InputTypeShort) { - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyLeft: - break; - case InputKeyRight: - break; - case InputKeyOk: - break; - case InputKeyBack: - // Exit the app - processing = false; - break; - } - } - } - } else { - // event timeout - ; - } - view_port_update(view_port); - release_mutex(&state_mutex, game_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - furi_timer_free(game_state->timer); - free(game_state); - - return 0; -} diff --git a/applications/plugins/trex_runner/trexrunner_icon.png b/applications/plugins/trex_runner/trexrunner_icon.png deleted file mode 100644 index 0b8329327..000000000 Binary files a/applications/plugins/trex_runner/trexrunner_icon.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/LICENSE b/applications/plugins/tuning_fork/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/tuning_fork/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/tuning_fork/README.md b/applications/plugins/tuning_fork/README.md deleted file mode 100644 index 5524eba3e..000000000 --- a/applications/plugins/tuning_fork/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Tuning Fork - -Inspired by [Metronome](https://github.com/panki27/Metronome) - -A tuning fork for the [Flipper Zero](https://flipperzero.one/) device. -Allows to play different notes in different pitches. - -![screenshot](img/tuning_fork.gif) - -## Features -- Tuning forks (440Hz, 432Hz, etc.) -- Scientific pitch (..., 256Hz, 512Hz, 1024Hz, ...) -- Guitar Standard (6 strings) -- Guitar Drop D (6 strings) -- Guitar D (6 strings) -- Guitar Drop C (6 strings) -- Guitar Standard (7 strings) -- Bass Standard (4 strings) -- Bass Standard Tenor (4 strings) -- Bass Standard (5 strings) -- Bass Standard Tenor (5 strings) -- Bass Drop D (4 strings) -- Bass D (4 strings) -- Bass Drop A (5 strings) - -## Compiling - -``` -./fbt firmware_tuning_fork -``` diff --git a/applications/plugins/tuning_fork/application.fam b/applications/plugins/tuning_fork/application.fam deleted file mode 100644 index 47cef5364..000000000 --- a/applications/plugins/tuning_fork/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="Tuning_Fork", - name="Tuning Fork", - apptype=FlipperAppType.EXTERNAL, - entry_point="tuning_fork_app", - cdefines=["APP_TUNING_FORM"], - requires=[ - "gui", - ], - fap_icon="tuning_fork_icon.png", - fap_category="Music", - stack_size=2 * 1024, - order=20, -) diff --git a/applications/plugins/tuning_fork/img/screenshot_1.png b/applications/plugins/tuning_fork/img/screenshot_1.png deleted file mode 100644 index 047279889..000000000 Binary files a/applications/plugins/tuning_fork/img/screenshot_1.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/img/screenshot_2.png b/applications/plugins/tuning_fork/img/screenshot_2.png deleted file mode 100644 index c31f37744..000000000 Binary files a/applications/plugins/tuning_fork/img/screenshot_2.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/img/tuning_fork.gif b/applications/plugins/tuning_fork/img/tuning_fork.gif deleted file mode 100644 index 27bfe8cbe..000000000 Binary files a/applications/plugins/tuning_fork/img/tuning_fork.gif and /dev/null differ diff --git a/applications/plugins/tuning_fork/notes.h b/applications/plugins/tuning_fork/notes.h deleted file mode 100644 index c00b4f8ed..000000000 --- a/applications/plugins/tuning_fork/notes.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef NOTES -#define NOTES - -#define C0 16.35f -#define Cs0 17.32f -#define Db0 17.32f -#define D0 18.35f -#define Ds0 19.45f -#define Eb0 19.45f -#define E0 20.60f -#define F0 21.83f -#define Fs0 23.12f -#define Gb0 23.12f -#define G0 24.50f -#define Gs0 25.96f -#define Ab0 25.96f -#define A0 27.50f -#define As0 29.14f -#define Bb0 29.14f -#define B0 30.868f -#define C1 32.70f -#define Cs1 34.65f -#define Db1 34.65f -#define D1 36.71f -#define Ds1 38.89f -#define Eb1 38.89f -#define E1 41.203f -#define F1 43.65f -#define Fs1 46.25f -#define Gb1 46.25f -#define G1 49.00f -#define Gs1 51.91f -#define Ab1 51.91f -#define A1 55.00f -#define As1 58.27f -#define Bb1 58.27f -#define B1 61.74f -#define C2 65.41f -#define Cs2 69.30f -#define Db2 69.30f -#define D2 73.416f -#define Ds2 77.78f -#define Eb2 77.78f -#define E2 82.41f -#define F2 87.31f -#define Fs2 92.50f -#define Gb2 92.50f -#define G2 97.999f -#define Gs2 103.83f -#define Ab2 103.83f -#define A2 110.00f -#define As2 116.54f -#define Bb2 116.54f -#define B2 123.47f -#define C3 130.813f -#define Cs3 138.59f -#define Db3 138.59f -#define D3 146.83f -#define Ds3 155.56f -#define Eb3 155.56f -#define E3 164.81f -#define F3 174.61f -#define Fs3 185.00f -#define Gb3 185.00f -#define G3 196.00f -#define Gs3 207.65f -#define Ab3 207.65f -#define A3 220.00f -#define As3 233.08f -#define Bb3 233.08f -#define B3 246.94f -#define C4 261.63f -#define Cs4 277.18f -#define Db4 277.18f -#define D4 293.66f -#define Ds4 311.13f -#define Eb4 311.13f -#define E4 329.63f -#define F4 349.23f -#define Fs4 369.99f -#define Gb4 369.99f -#define G4 392.00f -#define Gs4 415.30f -#define Ab4 415.30f -#define A4 440.00f -#define As4 466.16f -#define Bb4 466.16f -#define B4 493.88f -#define C5 523.25f -#define Cs5 554.37f -#define Db5 554.37f -#define D5 587.33f -#define Ds5 622.25f -#define Eb5 622.25f -#define E5 659.25f -#define F5 698.46f -#define Fs5 739.99f -#define Gb5 739.99f -#define G5 783.99f -#define Gs5 830.61f -#define Ab5 830.61f -#define A5 880.00f -#define As5 932.33f -#define Bb5 932.33f -#define B5 987.77f -#define C6 1046.50f -#define Cs6 1108.73f -#define Db6 1108.73f -#define D6 1174.66f -#define Ds6 1244.51f -#define Eb6 1244.51f -#define E6 1318.51f -#define F6 1396.91f -#define Fs6 1479.98f -#define Gb6 1479.98f -#define G6 1567.98f -#define Gs6 1661.22f -#define Ab6 1661.22f -#define A6 1760.00f -#define As6 1864.66f -#define Bb6 1864.66f -#define B6 1975.53f -#define C7 2093.00f -#define Cs7 2217.46f -#define Db7 2217.46f -#define D7 2349.32f -#define Ds7 2489.02f -#define Eb7 2489.02f -#define E7 2637.02f -#define F7 2793.83f -#define Fs7 2959.96f -#define Gb7 2959.96f -#define G7 3135.96f -#define Gs7 3322.44f -#define Ab7 3322.44f -#define A7 3520.00f -#define As7 3729.31f -#define Bb7 3729.31f -#define B7 3951.07f -#define C8 4186.01f -#define Cs8 4434.92f -#define Db8 4434.92f -#define D8 4698.63f -#define Ds8 4978.03f -#define Eb8 4978.03f -#define E8 5274.04f -#define F8 5587.65f -#define Fs8 5919.91f -#define Gb8 5919.91f -#define G8 6271.93f -#define Gs8 6644.88f -#define Ab8 6644.88f -#define A8 7040.00f -#define As8 7458.62f -#define Bb8 7458.62f -#define B8 7902.13f - -#endif //NOTES diff --git a/applications/plugins/tuning_fork/tuning_fork.c b/applications/plugins/tuning_fork/tuning_fork.c deleted file mode 100644 index ab39e1f14..000000000 --- a/applications/plugins/tuning_fork/tuning_fork.c +++ /dev/null @@ -1,402 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "notes.h" -#include "tunings.h" - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -enum Page { Tunings, Notes }; - -typedef struct { - bool playing; - enum Page page; - int current_tuning_note_index; - int current_tuning_index; - float volume; - TUNING tuning; -} TuningForkState; - -static TUNING current_tuning(TuningForkState* tuningForkState) { - return tuningForkState->tuning; -} - -static NOTE current_tuning_note(TuningForkState* tuningForkState) { - return current_tuning(tuningForkState).notes[tuningForkState->current_tuning_note_index]; -} - -static float current_tuning_note_freq(TuningForkState* tuningForkState) { - return current_tuning_note(tuningForkState).frequency; -} - -static void current_tuning_note_label(TuningForkState* tuningForkState, char* outNoteLabel) { - for(int i = 0; i < 20; ++i) { - outNoteLabel[i] = current_tuning_note(tuningForkState).label[i]; - } -} - -static void current_tuning_label(TuningForkState* tuningForkState, char* outTuningLabel) { - for(int i = 0; i < 20; ++i) { - outTuningLabel[i] = current_tuning(tuningForkState).label[i]; - } -} - -static void updateTuning(TuningForkState* tuning_fork_state) { - tuning_fork_state->tuning = TuningList[tuning_fork_state->current_tuning_index]; - tuning_fork_state->current_tuning_note_index = 0; -} - -static void next_tuning(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_index == TUNINGS_COUNT - 1) { - tuning_fork_state->current_tuning_index = 0; - } else { - tuning_fork_state->current_tuning_index += 1; - } - updateTuning(tuning_fork_state); -} - -static void prev_tuning(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_index - 1 < 0) { - tuning_fork_state->current_tuning_index = TUNINGS_COUNT - 1; - } else { - tuning_fork_state->current_tuning_index -= 1; - } - updateTuning(tuning_fork_state); -} - -static void next_note(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_note_index == - current_tuning(tuning_fork_state).notes_length - 1) { - tuning_fork_state->current_tuning_note_index = 0; - } else { - tuning_fork_state->current_tuning_note_index += 1; - } -} - -static void prev_note(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->current_tuning_note_index == 0) { - tuning_fork_state->current_tuning_note_index = - current_tuning(tuning_fork_state).notes_length - 1; - } else { - tuning_fork_state->current_tuning_note_index -= 1; - } -} - -static void increase_volume(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->volume < 1.0f) { - tuning_fork_state->volume += 0.1f; - } -} - -static void decrease_volume(TuningForkState* tuning_fork_state) { - if(tuning_fork_state->volume > 0.0f) { - tuning_fork_state->volume -= 0.1f; - } -} - -static void play(TuningForkState* tuning_fork_state) { - furi_hal_speaker_start(current_tuning_note_freq(tuning_fork_state), tuning_fork_state->volume); -} - -static void stop() { - furi_hal_speaker_stop(); -} - -static void replay(TuningForkState* tuning_fork_state) { - stop(); - play(tuning_fork_state); -} - -static void render_callback(Canvas* const canvas, void* ctx) { - TuningForkState* tuning_fork_state = acquire_mutex((ValueMutex*)ctx, 25); - if(tuning_fork_state == NULL) { - return; - } - - string_t tempStr; - string_init(tempStr); - - canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontPrimary); - - if(tuning_fork_state->page == Tunings) { - char tuningLabel[20]; - current_tuning_label(tuning_fork_state, tuningLabel); - string_printf(tempStr, "< %s >", tuningLabel); - canvas_draw_str_aligned( - canvas, 64, 28, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - } else { - char tuningLabel[20]; - current_tuning_label(tuning_fork_state, tuningLabel); - string_printf(tempStr, "%s", tuningLabel); - canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - - char tuningNoteLabel[20]; - current_tuning_note_label(tuning_fork_state, tuningNoteLabel); - string_printf(tempStr, "< %s >", tuningNoteLabel); - canvas_draw_str_aligned( - canvas, 64, 24, AlignCenter, AlignCenter, string_get_cstr(tempStr)); - string_reset(tempStr); - } - - canvas_set_font(canvas, FontSecondary); - elements_button_left(canvas, "Prev"); - elements_button_right(canvas, "Next"); - - if(tuning_fork_state->page == Notes) { - if(tuning_fork_state->playing) { - elements_button_center(canvas, "Stop "); - } else { - elements_button_center(canvas, "Play"); - } - } else { - elements_button_center(canvas, "Select"); - } - if(tuning_fork_state->page == Notes) { - elements_progress_bar(canvas, 8, 36, 112, tuning_fork_state->volume); - } - - string_clear(tempStr); - release_mutex((ValueMutex*)ctx, tuning_fork_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void tuning_fork_state_init(TuningForkState* const tuning_fork_state) { - tuning_fork_state->playing = false; - tuning_fork_state->page = Tunings; - tuning_fork_state->volume = 1.0f; - tuning_fork_state->tuning = GuitarStandard6; - tuning_fork_state->current_tuning_index = 2; - tuning_fork_state->current_tuning_note_index = 0; -} - -int32_t tuning_fork_app() { - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - TuningForkState* tuning_fork_state = malloc(sizeof(TuningForkState)); - tuning_fork_state_init(tuning_fork_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, tuning_fork_state, sizeof(TuningForkState))) { - FURI_LOG_E("TuningFork", "cannot create mutex\r\n"); - free(tuning_fork_state); - return 255; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - - TuningForkState* tuning_fork_state = (TuningForkState*)acquire_mutex_block(&state_mutex); - - if(event_status == FuriStatusOk) { - if(event.type == EventTypeKey) { - if(event.input.type == InputTypeShort) { - // push events - switch(event.input.key) { - case InputKeyUp: - if(tuning_fork_state->page == Notes) { - increase_volume(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyDown: - if(tuning_fork_state->page == Notes) { - decrease_volume(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - break; - case InputKeyOk: - if(tuning_fork_state->page == Tunings) { - tuning_fork_state->page = Notes; - } else { - tuning_fork_state->playing = !tuning_fork_state->playing; - if(tuning_fork_state->playing) { - play(tuning_fork_state); - } else { - stop(); - } - } - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - tuning_fork_state->current_tuning_note_index = 0; - stop(); - tuning_fork_state->page = Tunings; - } - break; - default: - break; - } - } else if(event.input.type == InputTypeLong) { - // hold events - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyOk: - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - stop(); - tuning_fork_state->page = Tunings; - tuning_fork_state->current_tuning_note_index = 0; - } - break; - default: - break; - } - } else if(event.input.type == InputTypeRepeat) { - // repeat events - switch(event.input.key) { - case InputKeyUp: - break; - case InputKeyDown: - break; - case InputKeyRight: - if(tuning_fork_state->page == Tunings) { - next_tuning(tuning_fork_state); - } else { - next_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyLeft: - if(tuning_fork_state->page == Tunings) { - prev_tuning(tuning_fork_state); - } else { - prev_note(tuning_fork_state); - if(tuning_fork_state->playing) { - replay(tuning_fork_state); - } - } - - break; - case InputKeyOk: - break; - case InputKeyBack: - if(tuning_fork_state->page == Tunings) { - processing = false; - } else { - tuning_fork_state->playing = false; - stop(); - tuning_fork_state->page = Tunings; - tuning_fork_state->current_tuning_note_index = 0; - } - break; - default: - break; - } - } - } - } else { - FURI_LOG_D("TuningFork", "FuriMessageQueue: event timeout"); - } - - view_port_update(view_port); - release_mutex(&state_mutex, tuning_fork_state); - } - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close("gui"); - view_port_free(view_port); - furi_message_queue_free(event_queue); - delete_mutex(&state_mutex); - furi_record_close(RECORD_NOTIFICATION); - free(tuning_fork_state); - - return 0; -} diff --git a/applications/plugins/tuning_fork/tuning_fork_icon.png b/applications/plugins/tuning_fork/tuning_fork_icon.png deleted file mode 100644 index 074d9d590..000000000 Binary files a/applications/plugins/tuning_fork/tuning_fork_icon.png and /dev/null differ diff --git a/applications/plugins/tuning_fork/tunings.h b/applications/plugins/tuning_fork/tunings.h deleted file mode 100644 index 14bf469fe..000000000 --- a/applications/plugins/tuning_fork/tunings.h +++ /dev/null @@ -1,151 +0,0 @@ -#include "notes.h" - -#ifndef TUNINGS -#define TUNINGS - -typedef struct { - char label[20]; - float frequency; -} NOTE; - -typedef struct { - char label[20]; - int notes_length; - NOTE notes[20]; -} TUNING; - -const TUNING TuningForks = { - "Tuning forks", - 6, - { - {"Common A4 (440)", 440.00f}, - {"Sarti's A4 (436)", 436.00f}, - {"1858 A4 (435)", 435.00f}, - {"Verdi's A4 (432)", 432.00f}, - {"1750-1820 A4 (423.5)", 423.50f}, - {"Verdi's C4 (256.00)", 256.00f}, - }}; - -const TUNING ScientificPitch = { - "Scientific pitch", - 12, - {{"C0 (16Hz)", 16.0f}, - {"C1 (32Hz)", 32.0f}, - {"C2 (64Hz)", 64.0f}, - {"C3 (128Hz)", 128.0f}, - {"C4 (256Hz)", 256.0f}, - {"C5 (512Hz)", 512.0f}, - {"C6 (1024Hz)", 1024.0f}, - {"C7 (2048Hz)", 2048.0f}, - {"C8 (4096Hz)", 4096.0f}, - {"C9 (8192Hz)", 8192.0f}, - {"C10 (16384Hz)", 16384.0f}, - {"C11 (32768Hz)", 32768.0f}}}; - -const TUNING GuitarStandard6 = { - "Guitar Standard 6", - 6, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", E2}}}; - -const TUNING GuitarDropD6 = { - "Guitar Drop D 6", - 6, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", D2}}}; - -const TUNING GuitarD6 = { - "Guitar D 6", - 6, - {{"String 1", D4}, - {"String 2", A3}, - {"String 3", F3}, - {"String 4", C3}, - {"String 5", G2}, - {"String 6", D2}}}; - -const TUNING GuitarDropC6 = { - "Guitar Drop C 6", - 6, - {{"String 1", D4}, - {"String 2", A3}, - {"String 3", F3}, - {"String 4", C3}, - {"String 5", G2}, - {"String 6", C2}}}; - -const TUNING GuitarStandard7 = { - "Guitar Standard 7", - 7, - {{"String 1", E4}, - {"String 2", B3}, - {"String 3", G3}, - {"String 4", D3}, - {"String 5", A2}, - {"String 6", E2}, - {"String 7", B1}}}; - -const TUNING BassStandard4 = { - "Bass Standard 4", - 4, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}}}; - -const TUNING BassStandardTenor4 = { - "Bass Stand Tenor 4", - 4, - {{"String 1", C3}, {"String 2", G2}, {"String 3", D2}, {"String 4", A1}}}; - -const TUNING BassStandard5 = { - "Bass Standard 5", - 5, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}, {"String 5", B0}}}; - -const TUNING BassStandardTenor5 = { - "Bass Stand Tenor 5", - 5, - {{"String 1", C3}, {"String 2", G2}, {"String 3", D2}, {"String 4", A1}, {"String 5", E1}}}; - -const TUNING BassDropD4 = { - "Bass Drop D 4", - 4, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", D1}}}; - -const TUNING BassD4 = { - "Bass D 4", - 4, - {{"String 1", F2}, {"String 2", C2}, {"String 3", G1}, {"String 4", D1}}}; - -const TUNING BassDropA5 = { - "Bass Drop A 5", - 5, - {{"String 1", G2}, {"String 2", D2}, {"String 3", A1}, {"String 4", E1}, {"String 5", A0}}}; - -#define TUNINGS_COUNT 14 - -TUNING TuningList[TUNINGS_COUNT] = { - ScientificPitch, - TuningForks, - - GuitarStandard6, - GuitarDropD6, - GuitarD6, - GuitarDropC6, - GuitarStandard7, - - BassStandard4, - BassStandardTenor4, - BassStandard5, - BassStandardTenor5, - BassDropD4, - BassD4, - BassDropA5}; - -#endif //TUNINGS diff --git a/applications/plugins/usb_midi/.gitattributes b/applications/plugins/usb_midi/.gitattributes deleted file mode 100644 index dfe077042..000000000 --- a/applications/plugins/usb_midi/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/applications/plugins/usb_midi/.gitignore b/applications/plugins/usb_midi/.gitignore deleted file mode 100644 index c6127b38c..000000000 --- a/applications/plugins/usb_midi/.gitignore +++ /dev/null @@ -1,52 +0,0 @@ -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf diff --git a/applications/plugins/usb_midi/application.fam b/applications/plugins/usb_midi/application.fam deleted file mode 100644 index 9eb971134..000000000 --- a/applications/plugins/usb_midi/application.fam +++ /dev/null @@ -1,14 +0,0 @@ -App( - appid="USB_Midi", - name="USB Midi", - apptype=FlipperAppType.EXTERNAL, - entry_point="usb_midi_app", - requires=[ - "gui", - ], - stack_size=4 * 1024, - order=20, - fap_icon="usb_midi.png", - fap_category="NeedsTesting", - # fap_icon_assets="icons", -) diff --git a/applications/plugins/usb_midi/midi/config.h b/applications/plugins/usb_midi/midi/config.h deleted file mode 100644 index c62c1b1ef..000000000 --- a/applications/plugins/usb_midi/midi/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -#define SYSEX_BUFFER_LEN 16 \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/message.c b/applications/plugins/usb_midi/midi/message.c deleted file mode 100644 index 7bee9816a..000000000 --- a/applications/plugins/usb_midi/midi/message.c +++ /dev/null @@ -1,144 +0,0 @@ -#include "message.h" - -/** Returns the data within the MidiEvent as a NoteOffEvent struct */ -NoteOffEvent AsNoteOff(MidiEvent* event) { - NoteOffEvent m; - m.channel = event->channel; - m.note = event->data[0]; - m.velocity = event->data[1]; - return m; -} - -/** Returns the data within the MidiEvent as a NoteOnEvent struct */ -NoteOnEvent AsNoteOn(MidiEvent* event) { - NoteOnEvent m; - m.channel = event->channel; - m.note = event->data[0]; - m.velocity = event->data[1]; - return m; -} - -/** Returns the data within the MidiEvent as a PolyphonicKeyPressureEvent struct */ -PolyphonicKeyPressureEvent AsPolyphonicKeyPressure(MidiEvent* event) { - PolyphonicKeyPressureEvent m; - m.channel = event->channel; - m.note = event->data[0]; - m.pressure = event->data[1]; - return m; -} - -/** Returns the data within the MidiEvent as a ControlChangeEvent struct.*/ -ControlChangeEvent AsControlChange(MidiEvent* event) { - ControlChangeEvent m; - m.channel = event->channel; - m.control_number = event->data[0]; - m.value = event->data[1]; - return m; -} - -/** Returns the data within the MidiEvent as a ProgramChangeEvent struct.*/ -ProgramChangeEvent AsProgramChange(MidiEvent* event) { - ProgramChangeEvent m; - m.channel = event->channel; - m.program = event->data[0]; - return m; -} - -/** Returns the data within the MidiEvent as a ProgramChangeEvent struct.*/ -ChannelPressureEvent AsChannelPressure(MidiEvent* event) { - ChannelPressureEvent m; - m.channel = event->channel; - m.pressure = event->data[0]; - return m; -} - -/** Returns the data within the MidiEvent as a PitchBendEvent struct.*/ -PitchBendEvent AsPitchBend(MidiEvent* event) { - PitchBendEvent m; - m.channel = event->channel; - m.value = ((uint16_t)(event->data[1]) << 7) + (event->data[0] - 8192); - return m; -} - -SystemExclusiveEvent AsSystemExclusive(MidiEvent* event) { - SystemExclusiveEvent m; - m.length = event->sysex_message_len; - for(int i = 0; i < SYSEX_BUFFER_LEN; i++) { - m.data[i] = 0; - if(i < m.length) { - m.data[i] = event->sysex_data[i]; - } - } - return m; -} - -MTCQuarterFrameEvent AsMTCQuarterFrame(MidiEvent* event) { - MTCQuarterFrameEvent m; - m.message_type = (event->data[0] & 0x70) >> 4; - m.value = (event->data[0]) & 0x0f; - return m; -} - -SongPositionPointerEvent AsSongPositionPointer(MidiEvent* event) { - SongPositionPointerEvent m; - m.position = ((uint16_t)(event->data[1]) << 7) | (event->data[0]); - return m; -} - -SongSelectEvent AsSongSelect(MidiEvent* event) { - SongSelectEvent m; - m.song = event->data[0]; - return m; -} - -AllSoundOffEvent AsAllSoundOff(MidiEvent* event) { - AllSoundOffEvent m; - m.channel = event->channel; - return m; -} - -ResetAllControllersEvent AsResetAllControllers(MidiEvent* event) { - ResetAllControllersEvent m; - m.channel = event->channel; - m.value = event->data[1]; - return m; -} - -LocalControlEvent AsLocalControl(MidiEvent* event) { - LocalControlEvent m; - m.channel = event->channel; - m.local_control_off = (event->data[1] == 0); - m.local_control_on = (event->data[1] == 127); - return m; -} - -AllNotesOffEvent AsAllNotesOff(MidiEvent* event) { - AllNotesOffEvent m; - m.channel = event->channel; - return m; -} - -OmniModeOffEvent AsOmniModeOff(MidiEvent* event) { - OmniModeOffEvent m; - m.channel = event->channel; - return m; -} - -OmniModeOnEvent AsOmniModeOn(MidiEvent* event) { - OmniModeOnEvent m; - m.channel = event->channel; - return m; -} - -MonoModeOnEvent AsMonoModeOn(MidiEvent* event) { - MonoModeOnEvent m; - m.channel = event->channel; - m.num_channels = event->data[1]; - return m; -} - -PolyModeOnEvent AsPolyModeOn(MidiEvent* event) { - PolyModeOnEvent m; - m.channel = event->channel; - return m; -} \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/message.h b/applications/plugins/usb_midi/midi/message.h deleted file mode 100644 index 88402c4a4..000000000 --- a/applications/plugins/usb_midi/midi/message.h +++ /dev/null @@ -1,251 +0,0 @@ -#pragma once -#include -#include -#include "config.h" - -typedef enum { - NoteOff, /**< & */ - NoteOn, /**< & */ - PolyphonicKeyPressure, /**< & */ - ControlChange, /**< & */ - ProgramChange, /**< & */ - ChannelPressure, /**< & */ - PitchBend, /**< & */ - SystemCommon, /**< & */ - SystemRealTime, /**< & */ - ChannelMode, /**< & */ - MessageLast, /**< & */ -} MidiMessageType; - -typedef enum { - SystemExclusive, /**< & */ - MTCQuarterFrame, /**< & */ - SongPositionPointer, /**< & */ - SongSelect, /**< & */ - SCUndefined0, /**< & */ - SCUndefined1, /**< & */ - TuneRequest, /**< & */ - SysExEnd, /**< & */ - SystemCommonLast, /**< & */ -} SystemCommonType; - -typedef enum { - TimingClock, /**< & */ - SRTUndefined0, /**< & */ - Start, /**< & */ - Continue, /**< & */ - Stop, /**< & */ - SRTUndefined1, /**< & */ - ActiveSensing, /**< & */ - Reset, /**< & */ - SystemRealTimeLast, /**< & */ -} SystemRealTimeType; - -typedef enum { - AllSoundOff, /**< & */ - ResetAllControllers, /**< & */ - LocalControl, /**< & */ - AllNotesOff, /**< & */ - OmniModeOff, /**< & */ - OmniModeOn, /**< & */ - MonoModeOn, /**< & */ - PolyModeOn, /**< & */ - ChannelModeLast, /**< & */ -} ChannelModeType; - -/** Struct containing note, and velocity data for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t note; /**< & */ - uint8_t velocity; /**< & */ -} NoteOffEvent; - -/** Struct containing note, and velocity data for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t note; /**< & */ - uint8_t velocity; /**< & */ -} NoteOnEvent; - -/** Struct containing note, and pressure data for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; - uint8_t note; - uint8_t pressure; -} PolyphonicKeyPressureEvent; - -/** Struct containing control number, and value for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t control_number; /**< & */ - uint8_t value; /**< & */ -} ControlChangeEvent; - -/** Struct containing new program number, for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t program; /**< & */ -} ProgramChangeEvent; - -/** Struct containing pressure (aftertouch), for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t pressure; /**< & */ -} ChannelPressureEvent; - -/** Struct containing pitch bend value for a given channel. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - int16_t value; /**< & */ -} PitchBendEvent; - -/** Struct containing sysex data. -Can be made from MidiEvent -*/ -typedef struct { - int length; - uint8_t data[SYSEX_BUFFER_LEN]; /**< & */ -} SystemExclusiveEvent; - -/** Struct containing QuarterFrame data. -Can be made from MidiEvent -*/ -typedef struct { - uint8_t message_type; /**< & */ - uint8_t value; /**< & */ -} MTCQuarterFrameEvent; - -/** Struct containing song position data. -Can be made from MidiEvent -*/ -typedef struct { - uint16_t position; /**< & */ -} SongPositionPointerEvent; - -/** Struct containing song select data. -Can be made from MidiEvent -*/ -typedef struct { - uint8_t song; /**< & */ -} SongSelectEvent; - -/** Struct containing sound off data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ -} AllSoundOffEvent; - -/** Struct containing ResetAllControllersEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t value; /**< & */ -} ResetAllControllersEvent; - -/** Struct containing LocalControlEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - bool local_control_off; /**< & */ - bool local_control_on; /**< & */ -} LocalControlEvent; - -/** Struct containing AllNotesOffEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ -} AllNotesOffEvent; - -/** Struct containing OmniModeOffEvent data. - * Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ -} OmniModeOffEvent; - -/** Struct containing OmniModeOnEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ -} OmniModeOnEvent; - -/** Struct containing MonoModeOnEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ - uint8_t num_channels; /**< & */ -} MonoModeOnEvent; - -/** Struct containing PolyModeOnEvent data. -Can be made from MidiEvent -*/ -typedef struct { - int channel; /**< & */ -} PolyModeOnEvent; - -/** Simple MidiEvent with message type, channel, and data[2] members. -*/ -typedef struct { - MidiMessageType type; - int channel; - uint8_t data[2]; - uint8_t sysex_data[SYSEX_BUFFER_LEN]; - uint8_t sysex_message_len; - SystemCommonType sc_type; - SystemRealTimeType srt_type; - ChannelModeType cm_type; -} MidiEvent; - -/** Returns the data within the MidiEvent as a NoteOffEvent struct */ -NoteOffEvent AsNoteOff(MidiEvent* event); - -/** Returns the data within the MidiEvent as a NoteOnEvent struct */ -NoteOnEvent AsNoteOn(MidiEvent* event); - -/** Returns the data within the MidiEvent as a PolyphonicKeyPressureEvent struct */ -PolyphonicKeyPressureEvent AsPolyphonicKeyPressure(MidiEvent* event); - -/** Returns the data within the MidiEvent as a ControlChangeEvent struct.*/ -ControlChangeEvent AsControlChange(MidiEvent* event); - -/** Returns the data within the MidiEvent as a ProgramChangeEvent struct.*/ -ProgramChangeEvent AsProgramChange(MidiEvent* event); - -/** Returns the data within the MidiEvent as a ProgramChangeEvent struct.*/ -ChannelPressureEvent AsChannelPressure(MidiEvent* event); - -/** Returns the data within the MidiEvent as a PitchBendEvent struct.*/ -PitchBendEvent AsPitchBend(MidiEvent* event); - -SystemExclusiveEvent AsSystemExclusive(MidiEvent* event); -MTCQuarterFrameEvent AsMTCQuarterFrame(MidiEvent* event); -SongPositionPointerEvent AsSongPositionPointer(MidiEvent* event); -SongSelectEvent AsSongSelect(MidiEvent* event); -AllSoundOffEvent AsAllSoundOff(MidiEvent* event); -ResetAllControllersEvent AsResetAllControllers(MidiEvent* event); -LocalControlEvent AsLocalControl(MidiEvent* event); -AllNotesOffEvent AsAllNotesOff(MidiEvent* event); -OmniModeOffEvent AsOmniModeOff(MidiEvent* event); -OmniModeOnEvent AsOmniModeOn(MidiEvent* event); -MonoModeOnEvent AsMonoModeOn(MidiEvent* event); -PolyModeOnEvent AsPolyModeOn(MidiEvent* event); \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/parser.c b/applications/plugins/usb_midi/midi/parser.c deleted file mode 100644 index 86120e007..000000000 --- a/applications/plugins/usb_midi/midi/parser.c +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include "parser.h" - -typedef enum { - ParserEmpty, - ParserHasStatus, - ParserHasData0, - ParserSysEx, -} ParserState; - -const uint8_t kStatusByteMask = 0x80; -const uint8_t kMessageMask = 0x70; -const uint8_t kDataByteMask = 0x7F; -const uint8_t kSystemCommonMask = 0xF0; -const uint8_t kChannelMask = 0x0F; -const uint8_t kRealTimeMask = 0xF8; -const uint8_t kSystemRealTimeMask = 0x07; - -struct MidiParser { - MidiMessageType status; - ParserState state; - MidiEvent incoming_message; -}; - -MidiParser* midi_parser_alloc(void) { - MidiParser* parser = malloc(sizeof(MidiParser)); - parser->incoming_message.type = MessageLast; - parser->state = ParserEmpty; - return parser; -} - -void midi_parser_free(MidiParser* parser) { - free(parser); -} - -bool midi_parser_parse(MidiParser* parser, uint8_t byte) { - bool parsed = false; - MidiEvent* event = &parser->incoming_message; - - switch(parser->state) { - case ParserEmpty: - // check byte for valid Status Byte - if(byte & kStatusByteMask) { - // Get MessageType, and Channel - event->channel = byte & kChannelMask; - event->type = (MidiMessageType)((byte & kMessageMask) >> 4); - - // Validate, and move on. - if(event->type < MessageLast) { - parser->state = ParserHasStatus; - // Mark this status byte as running_status - parser->status = event->type; - - if(parser->status == SystemCommon) { - event->channel = 0; - //system real time = 1111 1xxx - if(byte & 0x08) { - event->type = SystemRealTime; - parser->status = SystemRealTime; - event->srt_type = (SystemRealTimeType)(byte & kSystemRealTimeMask); - - //short circuit to start - parser->state = ParserEmpty; - //queue_.push(incoming_message_); - parsed = true; - } - //system common - else { - event->sc_type = (SystemCommonType)(byte & 0x07); - //sysex - if(event->sc_type == SystemExclusive) { - parser->state = ParserSysEx; - event->sysex_message_len = 0; - } - //short circuit - else if(event->sc_type > SongSelect) { - parser->state = ParserEmpty; - //queue_.push(incoming_message_); - parsed = true; - } - } - } - } - // Else we'll keep waiting for a valid incoming status byte - } else { - // Handle as running status - event->type = parser->status; - event->data[0] = byte & kDataByteMask; - parser->state = ParserHasData0; - } - break; - case ParserHasStatus: - if((byte & kStatusByteMask) == 0) { - event->data[0] = byte & kDataByteMask; - if(parser->status == ChannelPressure || parser->status == ProgramChange || - event->sc_type == MTCQuarterFrame || event->sc_type == SongSelect) { - //these are just one data byte, so we short circuit back to start - parser->state = ParserEmpty; - //queue_.push(incoming_message_); - parsed = true; - } else { - parser->state = ParserHasData0; - } - - //ChannelModeMessages (reserved Control Changes) - if(parser->status == ControlChange && event->data[0] > 119) { - event->type = ChannelMode; - parser->status = ChannelMode; - event->cm_type = (ChannelModeType)(event->data[0] - 120); - } - } else { - // invalid message go back to start ;p - parser->state = ParserEmpty; - } - break; - case ParserHasData0: - if((byte & kStatusByteMask) == 0) { - event->data[1] = byte & kDataByteMask; - // At this point the message is valid, and we can add this MidiEvent to the queue - //queue_.push(incoming_message_); - parsed = true; - } - // Regardless, of whether the data was valid or not we go back to empty - // because either the message is queued for handling or its not. - parser->state = ParserEmpty; - break; - case ParserSysEx: - // end of sysex - if(byte == 0xf7) { - parser->state = ParserEmpty; - //queue_.push(incoming_message_); - parsed = true; - } else { - if(event->sysex_message_len < SYSEX_BUFFER_LEN) { - event->sysex_data[event->sysex_message_len] = byte; - event->sysex_message_len++; - } - } - break; - default: - break; - } - - return parsed; -} - -MidiEvent* midi_parser_get_message(MidiParser* parser) { - return &parser->incoming_message; -} \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/parser.h b/applications/plugins/usb_midi/midi/parser.h deleted file mode 100644 index 93630f026..000000000 --- a/applications/plugins/usb_midi/midi/parser.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include -#include "message.h" - -typedef struct MidiParser MidiParser; - -MidiParser* midi_parser_alloc(void); - -void midi_parser_free(MidiParser* parser); - -bool midi_parser_parse(MidiParser* parser, uint8_t data); - -MidiEvent* midi_parser_get_message(MidiParser* parser); \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/usb_message.c b/applications/plugins/usb_midi/midi/usb_message.c deleted file mode 100644 index b6844c5f4..000000000 --- a/applications/plugins/usb_midi/midi/usb_message.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "usb_message.h" - -CodeIndex code_index_from_data(uint8_t data) { - return (CodeIndex)(data & 0b00001111); -} - -uint8_t cable_id_from_data(uint8_t data) { - return (data >> 4) & 0b00001111; -} - -uint8_t usb_message_data_size(CodeIndex code_index) { - uint8_t data_size = 0; - switch(code_index) { - case CodeIndexCommon1Byte: - /* case CodeIndexSysExEnd1Byte: */ - case CodeIndexSingleByte: - data_size = 1; - break; - case CodeIndexSysEx2Byte: - case CodeIndexSysExEnd2Byte: - case CodeIndexProgramChange: - case CodeIndexChannelPressure: - data_size = 2; - break; - case CodeIndexSysEx3Byte: - case CodeIndexSysExStart: - case CodeIndexSysExEnd3Byte: - case CodeIndexNoteOff: - case CodeIndexNoteOn: - case CodeIndexPolyKeyPress: - case CodeIndexControlChange: - case CodeIndexPitchBendChange: - data_size = 3; - break; - default: - break; - } - - return data_size; -} \ No newline at end of file diff --git a/applications/plugins/usb_midi/midi/usb_message.h b/applications/plugins/usb_midi/midi/usb_message.h deleted file mode 100644 index 852e9cb4f..000000000 --- a/applications/plugins/usb_midi/midi/usb_message.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include - -typedef enum { - CodeIndexMisc = 0x0, /**< Reserved, MIDI Size: 1, 2, 3 */ - CodeIndexCableEvent = 0x1, /**< Reserved, MIDI Size: 1, 2, 3 */ - CodeIndexSysEx2Byte = 0x2, /**< MIDI Size: 2 */ - CodeIndexSysEx3Byte = 0x3, /**< MIDI Size: 3 */ - CodeIndexSysExStart = 0x4, /**< MIDI Size: 3 */ - CodeIndexCommon1Byte = 0x5, /**< MIDI Size: 1 */ - CodeIndexSysExEnd1Byte = 0x5, /**< MIDI Size: 1 */ - CodeIndexSysExEnd2Byte = 0x6, /**< MIDI Size: 2 */ - CodeIndexSysExEnd3Byte = 0x7, /**< MIDI Size: 3 */ - CodeIndexNoteOff = 0x8, /**< MIDI Size: 3 */ - CodeIndexNoteOn = 0x9, /**< MIDI Size: 3 */ - CodeIndexPolyKeyPress = 0xA, /**< MIDI Size: 3 */ - CodeIndexControlChange = 0xB, /**< MIDI Size: 3 */ - CodeIndexProgramChange = 0xC, /**< MIDI Size: 2 */ - CodeIndexChannelPressure = 0xD, /**< MIDI Size: 2 */ - CodeIndexPitchBendChange = 0xE, /**< MIDI Size: 3 */ - CodeIndexSingleByte = 0xF, /**< MIDI Size: 1 */ -} CodeIndex; - -CodeIndex code_index_from_data(uint8_t data); - -uint8_t cable_id_from_data(uint8_t data); - -uint8_t usb_message_data_size(CodeIndex code_index); \ No newline at end of file diff --git a/applications/plugins/usb_midi/usb/cm3_usb_audio.h b/applications/plugins/usb_midi/usb/cm3_usb_audio.h deleted file mode 100644 index 3c767f929..000000000 --- a/applications/plugins/usb_midi/usb/cm3_usb_audio.h +++ /dev/null @@ -1,234 +0,0 @@ -/** @defgroup usb_audio_defines USB Audio Type Definitions - -@brief Defined Constants and Types for the USB Audio Type Definitions - -@ingroup USB_defines - -@version 1.0.0 - -@author @htmlonly © @endhtmlonly 2014 -Daniel Thompson -Seb Holzapfel - -@date 19 April 2014 - -LGPL License Terms @ref lgpl_license -*/ - -/* - * This file is part of the libopencm3 project. - * - * Copyright (C) 2014 Daniel Thompson - * Copyright (C) 2018 Seb Holzapfel - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -/**@{*/ - -#ifndef LIBOPENCM3_USB_AUDIO_H -#define LIBOPENCM3_USB_AUDIO_H - -#include - -/* - * Definitions from the USB_AUDIO_ or usb_audio_ namespace come from: - * "Universal Serial Bus Class Definitions for Audio Devices, Revision 1.0" - */ - -/* Table A-1: Audio Interface Class Code */ -#define USB_CLASS_AUDIO 0x01 - -/* Table A-2: Audio Interface Subclass Codes */ -#define USB_AUDIO_SUBCLASS_UNDEFINED 0x00 -#define USB_AUDIO_SUBCLASS_CONTROL 0x01 -#define USB_AUDIO_SUBCLASS_AUDIOSTREAMING 0x02 -#define USB_AUDIO_SUBCLASS_MIDISTREAMING 0x03 - -/* Table A-4: Audio Class-specific Descriptor Types */ -#define USB_AUDIO_DT_CS_UNDEFINED 0x20 -#define USB_AUDIO_DT_CS_DEVICE 0x21 -#define USB_AUDIO_DT_CS_CONFIGURATION 0x22 -#define USB_AUDIO_DT_CS_STRING 0x23 -#define USB_AUDIO_DT_CS_INTERFACE 0x24 -#define USB_AUDIO_DT_CS_ENDPOINT 0x25 - -/* Table A-5: Audio Class-Specific AC Interface Descriptor Subtypes */ -#define USB_AUDIO_TYPE_AC_DESCRIPTOR_UNDEFINED 0x00 -#define USB_AUDIO_TYPE_HEADER 0x01 -#define USB_AUDIO_TYPE_INPUT_TERMINAL 0x02 -#define USB_AUDIO_TYPE_OUTPUT_TERMINAL 0x03 -#define USB_AUDIO_TYPE_MIXER_UNIT 0x04 -#define USB_AUDIO_TYPE_SELECTOR_UNIT 0x05 -#define USB_AUDIO_TYPE_FEATURE_UNIT 0x06 -#define USB_AUDIO_TYPE_PROCESSING_UNIT 0x07 -#define USB_AUDIO_TYPE_EXTENSION_UNIT 0x08 - -/* Table 4-2: Class-Specific AC Interface Header Descriptor (head) */ -struct usb_audio_header_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint16_t bcdADC; - uint16_t wTotalLength; - uint8_t bInCollection; - /* ... */ -} __attribute__((packed)); - -/* Table 4-2: Class-Specific AC Interface Header Descriptor (body) */ -struct usb_audio_header_descriptor_body { - /* ... */ - uint8_t baInterfaceNr; -} __attribute__((packed)); - -/* Table 4-3: Input Terminal Descriptor */ -struct usb_audio_input_terminal_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bTerminalID; - uint16_t wTerminalType; - uint8_t bAssocTerminal; - uint8_t bNrChannels; - uint16_t wChannelConfig; - uint8_t iChannelNames; - uint8_t iTerminal; -} __attribute__((packed)); - -/* Table 4-3: Output Terminal Descriptor */ -struct usb_audio_output_terminal_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bTerminalID; - uint16_t wTerminalType; - uint8_t bAssocTerminal; - uint8_t bSourceID; - uint8_t iTerminal; -} __attribute__((packed)); - -/* Table 4-7: Feature Unit Descriptor (head) */ -struct usb_audio_feature_unit_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bUnitID; - uint8_t bSourceID; - uint8_t bControlSize; - uint16_t bmaControlMaster; /* device can assume 16-bit, given highest - * defined bit in spec is bit #9. - * (it is thus required bControlSize=2) */ - /* ... */ -} __attribute__((packed)); - -/* Table 4-7: Feature Unit Descriptor (body) */ -struct usb_audio_feature_unit_descriptor_body { - /* ... */ - uint16_t bmaControl; - /* ... */ -} __attribute__((packed)); - -/* Table 4-7: Feature Unit Descriptor (tail) */ -struct usb_audio_feature_unit_descriptor_tail { - /* ... */ - uint8_t iFeature; -} __attribute__((packed)); - -/* Table 4-7: Feature Unit Descriptor (2-channel) - * - * This structure is a convenience covering the (common) case where - * there are 2 channels associated with the feature unit - */ -struct usb_audio_feature_unit_descriptor_2ch { - struct usb_audio_feature_unit_descriptor_head head; - struct usb_audio_feature_unit_descriptor_body channel_control[2]; - struct usb_audio_feature_unit_descriptor_tail tail; -} __attribute__((packed)); - -/* Table 4-19: Class-Specific AS Interface Descriptor */ -struct usb_audio_stream_interface_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bTerminalLink; - uint8_t bDelay; - uint16_t wFormatTag; -} __attribute__((packed)); - -/* Table 4-20: Standard AS Isochronous Audio Data Endpoint Descriptor */ -struct usb_audio_stream_endpoint_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bEndpointAddress; - uint8_t bmAttributes; - uint16_t wMaxPacketSize; - uint8_t bInterval; - uint8_t bRefresh; - uint8_t bSynchAddress; -} __attribute__((packed)); - -/* Table 4-21: Class-Specific AS Isochronous Audio Data Endpoint Descriptor */ -struct usb_audio_stream_audio_endpoint_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bmAttributes; - uint8_t bLockDelayUnits; - uint16_t wLockDelay; -} __attribute__((packed)); - -/* - * Definitions from the USB_AUDIO_FORMAT_ or usb_audio_format_ namespace come from: - * "Universal Serial Bus Device Class Definition for Audio Data Formats, Revision 1.0" - */ - -/* Table 2-1: Type I Format Type Descriptor (head) */ -struct usb_audio_format_type1_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bFormatType; - uint8_t bNrChannels; - uint8_t bSubFrameSize; - uint8_t bBitResolution; - uint8_t bSamFreqType; - /* ... */ -} __attribute__((packed)); - -/* Table 2-2: Continuous Sampling Frequency */ -struct usb_audio_format_continuous_sampling_frequency { - /* ... */ - uint32_t tLowerSamFreq : 24; - uint32_t tUpperSamFreq : 24; -} __attribute__((packed)); - -/* Table 2-3: Discrete Number of Sampling Frequencies */ -struct usb_audio_format_discrete_sampling_frequency { - /* ... */ - uint32_t tSamFreq : 24; -} __attribute__((packed)); - -/* Table 2-1: Type I Format Type Descriptor (1 sampling frequency) - * - * This structure is a convenience covering the (common) case where - * only 1 discrete sampling frequency is used - */ -struct usb_audio_format_type1_descriptor_1freq { - struct usb_audio_format_type1_descriptor_head head; - struct usb_audio_format_discrete_sampling_frequency freqs[1]; -} __attribute__((packed)); - -#endif - -/**@}*/ diff --git a/applications/plugins/usb_midi/usb/cm3_usb_midi.h b/applications/plugins/usb_midi/usb/cm3_usb_midi.h deleted file mode 100644 index 8435c883e..000000000 --- a/applications/plugins/usb_midi/usb/cm3_usb_midi.h +++ /dev/null @@ -1,190 +0,0 @@ -/** @defgroup usb_audio_defines USB MIDI Type Definitions - -@brief Defined Constants and Types for the USB MIDI Type Definitions - -@ingroup USB_defines - -@version 1.0.0 - -@author @htmlonly © @endhtmlonly 2014 -Daniel Thompson - -@date 19 April 2014 - -LGPL License Terms @ref lgpl_license -*/ - -/* - * This file is part of the libopencm3 project. - * - * Copyright (C) 2014 Daniel Thompson - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This library 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - */ - -/**@{*/ - -#ifndef LIBOPENCM3_USB_MIDI_H -#define LIBOPENCM3_USB_MIDI_H - -#include - -/* - * Definitions from the USB_MIDI_ or usb_midi_ namespace come from: - * "Universal Serial Bus Class Definitions for MIDI Devices, Revision 1.0" - */ - -/* Appendix A.1: MS Class-Specific Interface Descriptor Subtypes */ -#define USB_MIDI_SUBTYPE_MS_DESCRIPTOR_UNDEFINED 0x00 -#define USB_MIDI_SUBTYPE_MS_HEADER 0x01 -#define USB_MIDI_SUBTYPE_MIDI_IN_JACK 0x02 -#define USB_MIDI_SUBTYPE_MIDI_OUT_JACK 0x03 -#define USB_MIDI_SUBTYPE_MIDI_ELEMENT 0x04 - -/* Appendix A.2: MS Class-Specific Endpoint Descriptor Subtypes */ -#define USB_MIDI_SUBTYPE_DESCRIPTOR_UNDEFINED 0x00 -#define USB_MIDI_SUBTYPE_MS_GENERAL 0x01 - -/* Appendix A.3: MS MIDI IN and OUT Jack types */ -#define USB_MIDI_JACK_TYPE_UNDEFINED 0x00 -#define USB_MIDI_JACK_TYPE_EMBEDDED 0x01 -#define USB_MIDI_JACK_TYPE_EXTERNAL 0x02 - -/* Appendix A.5.1 Endpoint Control Selectors */ -#define USB_MIDI_EP_CONTROL_UNDEFINED 0x00 -#define USB_MIDI_ASSOCIATION_CONTROL 0x01 - -/* Table 6-2: Class-Specific MS Interface Header Descriptor */ -struct usb_midi_header_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint16_t bcdMSC; - uint16_t wTotalLength; -} __attribute__((packed)); - -/* Table 6-3: MIDI IN Jack Descriptor */ -struct usb_midi_in_jack_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bJackType; - uint8_t bJackID; - uint8_t iJack; -} __attribute__((packed)); - -/* Table 6-4: MIDI OUT Jack Descriptor (head) */ -struct usb_midi_out_jack_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bJackType; - uint8_t bJackID; - uint8_t bNrInputPins; - /* ... */ -} __attribute__((packed)); - -/* Table 6.4: MIDI OUT Jack Descriptor (body) */ -struct usb_midi_out_jack_descriptor_body { - /* ... */ - uint8_t baSourceID; - uint8_t baSourcePin; - /* ... */ -} __attribute__((packed)); - -/* Table 6.4: MIDI OUT Jack Descriptor (tail) */ -struct usb_midi_out_jack_descriptor_tail { - /* ... */ - uint8_t iJack; -} __attribute__((packed)); - -/* Table 6.4: MIDI OUT Jack Descriptor (single) - * - * This structure is a convenience covering the (normal) case where - * there is only one input pin. - */ -struct usb_midi_out_jack_descriptor { - struct usb_midi_out_jack_descriptor_head head; - struct usb_midi_out_jack_descriptor_body source[1]; - struct usb_midi_out_jack_descriptor_tail tail; -} __attribute__((packed)); - -/* Table 6-5: MIDI Element Descriptor (head) */ -struct usb_midi_element_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubtype; - uint8_t bElementID; - uint8_t bNrInputPins; - /* ... */ -} __attribute__((packed)); - -/* Table 6-5: MIDI Element Descriptor (body) */ -struct usb_midi_element_descriptor_body { - /* ... */ - uint8_t baSourceID; - uint8_t baSourcePin; - /* ... */ -} __attribute__((packed)); - -/* Table 6-5: MIDI Element Descriptor (tail) */ -struct usb_midi_element_descriptor_tail { - /* ... */ - uint8_t bNrOutputPins; - uint8_t bInTerminalLink; - uint8_t bOutTerminalLink; - uint8_t bElCapsSize; - uint16_t bmElementCaps; /* host cannot assume this is 16-bit but device - can (since highest defined bitmap value in - v1.0 is bit 11) */ - uint8_t iElement; -} __attribute__((packed)); - -/* Table 6-5: MIDI Element Descriptor (single) - * - * This structure is a convenience covering the (common) case where - * there is only one input pin. - */ -struct usb_midi_element_descriptor { - struct usb_midi_element_descriptor_head head; - struct usb_midi_element_descriptor_body source[1]; - struct usb_midi_element_descriptor_tail tail; -} __attribute__((packed)); - -/* Table 6-7: Class-specific MS Bulk Data Endpoint Descriptor (head) */ -struct usb_midi_endpoint_descriptor_head { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bDescriptorSubType; - uint8_t bNumEmbMIDIJack; -} __attribute__((packed)); - -/* Table 6-7: Class-specific MS Bulk Data Endpoint Descriptor (body) */ -struct usb_midi_endpoint_descriptor_body { - uint8_t baAssocJackID; -} __attribute__((packed)); - -/* Table 6.7: Class-specific MS Bulk Data Endpoint Descriptor (single) - * - * This structure is a convenience covering the (normal) case where - * there is only one input pin. - */ -struct usb_midi_endpoint_descriptor { - struct usb_midi_endpoint_descriptor_head head; - struct usb_midi_endpoint_descriptor_body jack[1]; -} __attribute__((packed)); - -#endif - -/**@}*/ diff --git a/applications/plugins/usb_midi/usb/usb_midi_driver.c b/applications/plugins/usb_midi/usb/usb_midi_driver.c deleted file mode 100644 index 9abf77d12..000000000 --- a/applications/plugins/usb_midi/usb/usb_midi_driver.c +++ /dev/null @@ -1,428 +0,0 @@ -#include -#include -#include -#include - -#include "usb_midi_driver.h" -#include "cm3_usb_audio.h" -#include "cm3_usb_midi.h" - -// Appendix B. "Example: Simple MIDI Adapter" from "Universal Serial Bus Device Class Definition for MIDI Devices", Revision 1.0 - -#define USB_VID 0x6666 -#define USB_PID 0x5119 - -#define USB_EP0_SIZE 8 - -#define USB_MIDI_EP_SIZE 64 -#define USB_MIDI_EP_IN 0x81 -#define USB_MIDI_EP_OUT 0x01 - -#define EP_CFG_DECONFIGURE 0 -#define EP_CFG_CONFIGURE 1 - -enum { - USB_STR_ZERO, - USB_STR_MANUFACTURER, - USB_STR_PRODUCT, - USB_STR_SERIAL_NUMBER, -}; - -/* - B.1 Device Descriptor -*/ -static const struct usb_device_descriptor device_descriptor = { - .bLength = sizeof(struct usb_device_descriptor), - .bDescriptorType = USB_DTYPE_DEVICE, - .bcdUSB = VERSION_BCD(2, 0, 0), // was 0x0110, 1.10 - current revision of USBspecification. - .bDeviceClass = USB_CLASS_PER_INTERFACE, - .bDeviceSubClass = USB_SUBCLASS_NONE, - .bDeviceProtocol = USB_PROTO_NONE, - .bMaxPacketSize0 = USB_EP0_SIZE, - .idVendor = USB_VID, - .idProduct = USB_PID, - .bcdDevice = VERSION_BCD(1, 0, 0), - .iManufacturer = USB_STR_MANUFACTURER, - .iProduct = USB_STR_PRODUCT, - .iSerialNumber = USB_STR_SERIAL_NUMBER, - .bNumConfigurations = 1, -}; - -struct usb_audio_header_descriptor { - struct usb_audio_header_descriptor_head head; - struct usb_audio_header_descriptor_body body; -} __attribute__((packed)); - -struct usb_midi_jacks_descriptor { - struct usb_midi_header_descriptor header; - struct usb_midi_in_jack_descriptor in_embedded; - struct usb_midi_in_jack_descriptor in_external; - struct usb_midi_out_jack_descriptor out_embedded; - struct usb_midi_out_jack_descriptor out_external; -} __attribute__((packed)); - -struct MidiConfigDescriptor { - /* - B.2 Configuration Descriptor - */ - struct usb_config_descriptor config; - - /* - B.3 AudioControl Interface Descriptors - - The AudioControl interface describes the device structure (audio function topology) - and is used to manipulate the Audio Controls. This device has no audio function incorporated. - However, the AudioControl interface is mandatory and therefore both the standard AC interface - descriptor and the classspecific AC interface descriptor must be present. - The class-specific AC interface descriptor only contains the header descriptor. - */ - // B.3.1 Standard AC Interface Descriptor - struct usb_interface_descriptor audio_control_iface; - // B.3.2 Class-specific AC Interface Descriptor - struct usb_audio_header_descriptor audio_control_header; - - /* - B.4 MIDIStreaming Interface Descriptors - */ - // B.4.1 Standard MS Interface Descriptor - struct usb_interface_descriptor midi_streaming_iface; - // B.4.2 Class-specific MS Interface Descriptor - // B.4.3 MIDI IN Jack Descriptor - // B.4.4 MIDI OUT Jack Descriptor - struct usb_midi_jacks_descriptor midi_jacks; - - /* - B.5 Bulk OUT Endpoint Descriptors - */ - // B.5.1 Standard Bulk OUT Endpoint Descriptor - struct usb_endpoint_descriptor bulk_out; - // B.5.2 Class-specific MS Bulk OUT Endpoint Descriptor - struct usb_midi_endpoint_descriptor midi_bulk_out; - - /* - B.6 Bulk IN Endpoint Descriptors - */ - // B.6.1 Standard Bulk IN Endpoint Descriptor - struct usb_endpoint_descriptor bulk_in; - // B.6.2 Class-specific MS Bulk IN Endpoint Descriptor - struct usb_midi_endpoint_descriptor midi_bulk_in; -} __attribute__((packed)); - -static const struct MidiConfigDescriptor config_descriptor = { - .config = - { - .bLength = sizeof(struct usb_config_descriptor), - .bDescriptorType = USB_DTYPE_CONFIGURATION, - .wTotalLength = sizeof(struct MidiConfigDescriptor), - .bNumInterfaces = 2, /* control and data */ - .bConfigurationValue = 1, - .iConfiguration = 0, - .bmAttributes = USB_CFG_ATTR_RESERVED, - .bMaxPower = USB_CFG_POWER_MA(100), - }, - .audio_control_iface = - { - .bLength = sizeof(struct usb_interface_descriptor), - .bDescriptorType = USB_DTYPE_INTERFACE, - .bInterfaceNumber = 0, - .bAlternateSetting = 0, - .bNumEndpoints = 0, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_AUDIO_SUBCLASS_CONTROL, - .bInterfaceProtocol = USB_PROTO_NONE, - .iInterface = 0, - }, - .audio_control_header = - { - .head = - { - .bLength = sizeof(struct usb_audio_header_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_AUDIO_TYPE_HEADER, - .bcdADC = VERSION_BCD(1, 0, 0), - .wTotalLength = sizeof(struct usb_audio_header_descriptor), - .bInCollection = 1, - }, - .body = - { - .baInterfaceNr = 1, - }, - }, - .midi_streaming_iface = - { - .bLength = sizeof(struct usb_interface_descriptor), - .bDescriptorType = USB_DTYPE_INTERFACE, - .bInterfaceNumber = 1, - .bAlternateSetting = 0, - .bNumEndpoints = 2, - .bInterfaceClass = USB_CLASS_AUDIO, - .bInterfaceSubClass = USB_AUDIO_SUBCLASS_MIDISTREAMING, - .bInterfaceProtocol = USB_PROTO_NONE, - .iInterface = 0, - }, - .midi_jacks = - { - .header = - { - .bLength = sizeof(struct usb_midi_header_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_MIDI_SUBTYPE_MS_HEADER, - .bcdMSC = VERSION_BCD(1, 0, 0), - .wTotalLength = sizeof(struct usb_midi_jacks_descriptor), - }, - .in_embedded = - { - .bLength = sizeof(struct usb_midi_in_jack_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_MIDI_SUBTYPE_MIDI_IN_JACK, - .bJackType = USB_MIDI_JACK_TYPE_EMBEDDED, - .bJackID = 0x01, - .iJack = 0x00, - }, - .in_external = - { - .bLength = sizeof(struct usb_midi_in_jack_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_MIDI_SUBTYPE_MIDI_IN_JACK, - .bJackType = USB_MIDI_JACK_TYPE_EXTERNAL, - .bJackID = 0x02, - .iJack = 0x00, - }, - .out_embedded = - { - .head = - { - .bLength = sizeof(struct usb_midi_out_jack_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_MIDI_SUBTYPE_MIDI_OUT_JACK, - .bJackType = USB_MIDI_JACK_TYPE_EMBEDDED, - .bJackID = 0x03, - .bNrInputPins = 1, - }, - .source[0] = - { - .baSourceID = 0x02, - .baSourcePin = 0x01, - }, - .tail = - { - .iJack = 0x00, - }, - }, - .out_external = - { - .head = - { - .bLength = sizeof(struct usb_midi_out_jack_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_INTERFACE, - .bDescriptorSubtype = USB_MIDI_SUBTYPE_MIDI_OUT_JACK, - .bJackType = USB_MIDI_JACK_TYPE_EXTERNAL, - .bJackID = 0x04, - .bNrInputPins = 1, - }, - .source[0] = - { - .baSourceID = 0x01, - .baSourcePin = 0x01, - }, - .tail = - { - .iJack = 0x00, - }, - }, - }, - .bulk_out = - { - .bLength = sizeof(struct usb_endpoint_descriptor), - .bDescriptorType = USB_DTYPE_ENDPOINT, - .bEndpointAddress = USB_MIDI_EP_OUT, - .bmAttributes = USB_EPTYPE_BULK, - .wMaxPacketSize = USB_MIDI_EP_SIZE, - .bInterval = 0, - }, - .midi_bulk_out = - { - .head = - { - .bLength = sizeof(struct usb_midi_endpoint_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_ENDPOINT, - .bDescriptorSubType = USB_MIDI_SUBTYPE_MS_GENERAL, - .bNumEmbMIDIJack = 1, - }, - .jack[0] = - { - .baAssocJackID = 0x01, - }, - }, - .bulk_in = - { - .bLength = sizeof(struct usb_endpoint_descriptor), - .bDescriptorType = USB_DTYPE_ENDPOINT, - .bEndpointAddress = USB_MIDI_EP_IN, - .bmAttributes = USB_EPTYPE_BULK, - .wMaxPacketSize = USB_MIDI_EP_SIZE, - .bInterval = 0, - }, - .midi_bulk_in = - { - .head = - { - .bLength = sizeof(struct usb_midi_endpoint_descriptor), - .bDescriptorType = USB_AUDIO_DT_CS_ENDPOINT, - .bDescriptorSubType = USB_MIDI_SUBTYPE_MS_GENERAL, - .bNumEmbMIDIJack = 1, - }, - .jack[0] = - { - .baAssocJackID = 0x03, - }, - }, -}; - -static const struct usb_string_descriptor dev_manufacturer_string = - USB_STRING_DESC("Flipper Devices Inc."); - -static const struct usb_string_descriptor dev_product_string = - USB_STRING_DESC("Flipper MIDI Device"); - -static const struct usb_string_descriptor dev_serial_number_string = - USB_STRING_DESC("Serial Number"); - -static void midi_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx); -static void midi_deinit(usbd_device* dev); -static void midi_on_wakeup(usbd_device* dev); -static void midi_on_suspend(usbd_device* dev); -static usbd_respond midi_ep_config(usbd_device* dev, uint8_t cfg); -static usbd_respond midi_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_callback* callback); - -FuriHalUsbInterface midi_usb_interface = { - .init = midi_init, - .deinit = midi_deinit, - .wakeup = midi_on_wakeup, - .suspend = midi_on_suspend, - .dev_descr = (struct usb_device_descriptor*)&device_descriptor, - .cfg_descr = (void*)&config_descriptor, -}; - -typedef struct { - usbd_device* dev; - MidiRxCallback rx_callback; - void* context; - FuriSemaphore* semaphore_tx; - bool connected; -} MidiUsb; - -static MidiUsb midi_usb; - -void midi_usb_set_context(void* context) { - midi_usb.context = context; -} - -void midi_usb_set_rx_callback(MidiRxCallback callback) { - midi_usb.rx_callback = callback; -} - -size_t midi_usb_rx(uint8_t* buffer, size_t size) { - size_t len = usbd_ep_read(midi_usb.dev, USB_MIDI_EP_OUT, buffer, size); - return len; -} - -size_t midi_usb_tx(uint8_t* buffer, uint8_t size) { - if((midi_usb.semaphore_tx == NULL) || (midi_usb.connected == false)) return 0; - - furi_check(furi_semaphore_acquire(midi_usb.semaphore_tx, FuriWaitForever) == FuriStatusOk); - - if(midi_usb.connected) { - int32_t len = usbd_ep_write(midi_usb.dev, USB_MIDI_EP_IN, buffer, size); - return len; - } else { - return 0; - } -} - -static void midi_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx) { - UNUSED(intf); - UNUSED(ctx); - - midi_usb_interface.str_manuf_descr = (void*)&dev_manufacturer_string; - midi_usb_interface.str_prod_descr = (void*)&dev_product_string; - midi_usb_interface.str_serial_descr = (void*)&dev_serial_number_string; - midi_usb_interface.dev_descr->idVendor = USB_VID; - midi_usb_interface.dev_descr->idProduct = USB_PID; - - midi_usb.dev = dev; - if(midi_usb.semaphore_tx == NULL) midi_usb.semaphore_tx = furi_semaphore_alloc(1, 1); - - usbd_reg_config(dev, midi_ep_config); - usbd_reg_control(dev, midi_control); - - usbd_connect(dev, true); -} - -static void midi_deinit(usbd_device* dev) { - midi_usb.connected = false; - midi_usb.dev = NULL; - furi_semaphore_free(midi_usb.semaphore_tx); - - usbd_reg_config(dev, NULL); - usbd_reg_control(dev, NULL); -} - -static void midi_on_wakeup(usbd_device* dev) { - UNUSED(dev); - if(!midi_usb.connected) { - midi_usb.connected = true; - } -} - -static void midi_on_suspend(usbd_device* dev) { - UNUSED(dev); - if(midi_usb.connected) { - midi_usb.connected = false; - } -} - -static void midi_tx_rx(usbd_device* dev, uint8_t event, uint8_t ep) { - UNUSED(dev); - UNUSED(ep); - - switch(event) { - case usbd_evt_eptx: - furi_semaphore_release(midi_usb.semaphore_tx); - break; - case usbd_evt_eprx: - if(midi_usb.rx_callback != NULL) { - midi_usb.rx_callback(midi_usb.context); - } - break; - default: - break; - } -} - -static usbd_respond midi_ep_config(usbd_device* dev, uint8_t cfg) { - switch(cfg) { - case EP_CFG_DECONFIGURE: - usbd_ep_deconfig(dev, USB_MIDI_EP_OUT); - usbd_ep_deconfig(dev, USB_MIDI_EP_IN); - usbd_reg_endpoint(dev, USB_MIDI_EP_OUT, NULL); - usbd_reg_endpoint(dev, USB_MIDI_EP_IN, NULL); - return usbd_ack; - case EP_CFG_CONFIGURE: - usbd_ep_config(dev, USB_MIDI_EP_OUT, USB_EPTYPE_BULK, USB_MIDI_EP_SIZE); - usbd_ep_config(dev, USB_MIDI_EP_IN, USB_EPTYPE_BULK, USB_MIDI_EP_SIZE); - usbd_reg_endpoint(dev, USB_MIDI_EP_OUT, midi_tx_rx); - usbd_reg_endpoint(dev, USB_MIDI_EP_IN, midi_tx_rx); - return usbd_ack; - default: - return usbd_fail; - } -} - -static usbd_respond midi_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_callback* callback) { - UNUSED(dev); - UNUSED(req); - UNUSED(callback); - - return usbd_fail; -} \ No newline at end of file diff --git a/applications/plugins/usb_midi/usb/usb_midi_driver.h b/applications/plugins/usb_midi/usb/usb_midi_driver.h deleted file mode 100644 index d385efcb5..000000000 --- a/applications/plugins/usb_midi/usb/usb_midi_driver.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include - -extern FuriHalUsbInterface midi_usb_interface; - -typedef void (*MidiRxCallback)(void* context); - -void midi_usb_set_context(void* context); - -void midi_usb_set_rx_callback(MidiRxCallback callback); - -size_t midi_usb_rx(uint8_t* buffer, size_t size); - -size_t midi_usb_tx(uint8_t* buffer, uint8_t size); \ No newline at end of file diff --git a/applications/plugins/usb_midi/usb_midi.c b/applications/plugins/usb_midi/usb_midi.c deleted file mode 100644 index b1149a176..000000000 --- a/applications/plugins/usb_midi/usb_midi.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include "usb/usb_midi_driver.h" -#include "midi/parser.h" -#include "midi/usb_message.h" -#include - -float note_to_frequency(int note) { - float a = 440; - return (a / 32) * powf(2, ((note - 9) / 12.0)); -} - -typedef enum { - MidiThreadEventStop = (1 << 0), - MidiThreadEventRx = (1 << 1), - MidiThreadEventAll = MidiThreadEventStop | MidiThreadEventRx, -} MidiThreadEvent; - -static void midi_rx_callback(void* context) { - furi_assert(context); - FuriThreadId thread_id = (FuriThreadId)context; - furi_thread_flags_set(thread_id, MidiThreadEventRx); -} - -int32_t usb_midi_app(void* p) { - UNUSED(p); - - FuriHalUsbInterface* usb_config_prev; - usb_config_prev = furi_hal_usb_get_config(); - midi_usb_set_context(furi_thread_get_id(furi_thread_get_current())); - midi_usb_set_rx_callback(midi_rx_callback); - furi_hal_usb_set_config(&midi_usb_interface, NULL); - - MidiParser* parser = midi_parser_alloc(); - uint32_t events; - uint8_t current_note = 255; - - while(1) { - events = furi_thread_flags_wait(MidiThreadEventAll, FuriFlagWaitAny, FuriWaitForever); - - if(!(events & FuriFlagError)) { - if(events & MidiThreadEventRx) { - uint8_t buffer[64]; - size_t size = midi_usb_rx(buffer, sizeof(buffer)); - // loopback - // midi_usb_tx(buffer, size); - size_t start = 0; - while(start < size) { - CodeIndex code_index = code_index_from_data(buffer[start]); - uint8_t data_size = usb_message_data_size(code_index); - if(data_size == 0) break; - - start += 1; - for(size_t j = 0; j < data_size; j++) { - if(midi_parser_parse(parser, buffer[start + j])) { - MidiEvent* event = midi_parser_get_message(parser); - if(event->type == NoteOn) { - NoteOnEvent note_on = AsNoteOn(event); - current_note = note_on.note; - furi_hal_speaker_start( - note_to_frequency(note_on.note), note_on.velocity / 127.0f); - } else if(event->type == NoteOff) { - NoteOffEvent note_off = AsNoteOff(event); - if(note_off.note == current_note) { - furi_hal_speaker_stop(); - } - } - } - } - start += data_size; - } - } - } - } - - midi_parser_free(parser); - furi_hal_usb_set_config(usb_config_prev, NULL); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/usb_midi/usb_midi.png b/applications/plugins/usb_midi/usb_midi.png deleted file mode 100644 index 6d0ac6fed..000000000 Binary files a/applications/plugins/usb_midi/usb_midi.png and /dev/null differ diff --git a/applications/plugins/weather_station/application.fam b/applications/plugins/weather_station/application.fam deleted file mode 100644 index 7505900e5..000000000 --- a/applications/plugins/weather_station/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="Weather_Station", - name="Weather Station", - apptype=FlipperAppType.EXTERNAL, - entry_point="weather_station_app", - cdefines=["APP_WEATHER_STATION"], - requires=["gui"], - stack_size=4 * 1024, - order=50, - fap_icon="weather_station_10px.png", - fap_category="Tools", - fap_icon_assets="images", -) diff --git a/applications/plugins/weather_station/helpers/weather_station_event.h b/applications/plugins/weather_station/helpers/weather_station_event.h deleted file mode 100644 index b0486183d..000000000 --- a/applications/plugins/weather_station/helpers/weather_station_event.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -typedef enum { - //WSCustomEvent - WSCustomEventStartId = 100, - - WSCustomEventSceneSettingLock, - - WSCustomEventViewReceiverOK, - WSCustomEventViewReceiverConfig, - WSCustomEventViewReceiverBack, - WSCustomEventViewReceiverOffDisplay, - WSCustomEventViewReceiverUnlock, -} WSCustomEvent; diff --git a/applications/plugins/weather_station/helpers/weather_station_types.h b/applications/plugins/weather_station/helpers/weather_station_types.h deleted file mode 100644 index 16c195fa1..000000000 --- a/applications/plugins/weather_station/helpers/weather_station_types.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include -#include - -#define WS_VERSION_APP "0.6" -#define WS_DEVELOPED "SkorP" -#define WS_GITHUB "https://github.com/flipperdevices/flipperzero-firmware" - -#define WS_KEY_FILE_VERSION 1 -#define WS_KEY_FILE_TYPE "Flipper Weather Station Key File" - -/** WSRxKeyState state */ -typedef enum { - WSRxKeyStateIDLE, - WSRxKeyStateBack, - WSRxKeyStateStart, - WSRxKeyStateAddKey, -} WSRxKeyState; - -/** WSHopperState state */ -typedef enum { - WSHopperStateOFF, - WSHopperStateRunnig, - WSHopperStatePause, - WSHopperStateRSSITimeOut, -} WSHopperState; - -/** WSLock */ -typedef enum { - WSLockOff, - WSLockOn, -} WSLock; - -typedef enum { - WeatherStationViewVariableItemList, - WeatherStationViewSubmenu, - WeatherStationViewReceiver, - WeatherStationViewReceiverInfo, - WeatherStationViewWidget, -} WeatherStationView; - -/** WeatherStationTxRx state */ -typedef enum { - WSTxRxStateIDLE, - WSTxRxStateRx, - WSTxRxStateTx, - WSTxRxStateSleep, -} WSTxRxState; diff --git a/applications/plugins/weather_station/images/Humid_10x15.png b/applications/plugins/weather_station/images/Humid_10x15.png deleted file mode 100644 index 34b074e5f..000000000 Binary files a/applications/plugins/weather_station/images/Humid_10x15.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Humid_8x13.png b/applications/plugins/weather_station/images/Humid_8x13.png deleted file mode 100644 index 6d8c71b00..000000000 Binary files a/applications/plugins/weather_station/images/Humid_8x13.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Lock_7x8.png b/applications/plugins/weather_station/images/Lock_7x8.png deleted file mode 100644 index f7c9ca2c7..000000000 Binary files a/applications/plugins/weather_station/images/Lock_7x8.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Pin_back_arrow_10x8.png b/applications/plugins/weather_station/images/Pin_back_arrow_10x8.png deleted file mode 100644 index 3bafabd14..000000000 Binary files a/applications/plugins/weather_station/images/Pin_back_arrow_10x8.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Quest_7x8.png b/applications/plugins/weather_station/images/Quest_7x8.png deleted file mode 100644 index 6825247fb..000000000 Binary files a/applications/plugins/weather_station/images/Quest_7x8.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Scanning_123x52.png b/applications/plugins/weather_station/images/Scanning_123x52.png deleted file mode 100644 index ec785948d..000000000 Binary files a/applications/plugins/weather_station/images/Scanning_123x52.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Therm_7x16.png b/applications/plugins/weather_station/images/Therm_7x16.png deleted file mode 100644 index 7c55500b7..000000000 Binary files a/applications/plugins/weather_station/images/Therm_7x16.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Timer_11x11.png b/applications/plugins/weather_station/images/Timer_11x11.png deleted file mode 100644 index 21ad47f4b..000000000 Binary files a/applications/plugins/weather_station/images/Timer_11x11.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/Unlock_7x8.png b/applications/plugins/weather_station/images/Unlock_7x8.png deleted file mode 100644 index 9d82b4daf..000000000 Binary files a/applications/plugins/weather_station/images/Unlock_7x8.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/WarningDolphin_45x42.png b/applications/plugins/weather_station/images/WarningDolphin_45x42.png deleted file mode 100644 index d766ffbb4..000000000 Binary files a/applications/plugins/weather_station/images/WarningDolphin_45x42.png and /dev/null differ diff --git a/applications/plugins/weather_station/images/station_icon.png b/applications/plugins/weather_station/images/station_icon.png deleted file mode 100644 index b839eeb7a..000000000 Binary files a/applications/plugins/weather_station/images/station_icon.png and /dev/null differ diff --git a/applications/plugins/weather_station/protocols/acurite_592txr.c b/applications/plugins/weather_station/protocols/acurite_592txr.c deleted file mode 100644 index 5384a3c91..000000000 --- a/applications/plugins/weather_station/protocols/acurite_592txr.c +++ /dev/null @@ -1,306 +0,0 @@ -#include "acurite_592txr.h" - -#define TAG "WSProtocolAcurite_592TXR" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/acurite.c - * - * Acurite 592TXR Temperature Humidity sensor decoder - * Message Type 0x04, 7 bytes - * | Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | - * | --------- | --------- | --------- | --------- | --------- | --------- | --------- | - * | CCII IIII | IIII IIII | pB00 0100 | pHHH HHHH | p??T TTTT | pTTT TTTT | KKKK KKKK | - * - C: Channel 00: C, 10: B, 11: A, (01 is invalid) - * - I: Device ID (14 bits) - * - B: Battery, 1 is battery OK, 0 is battery low - * - M: Message type (6 bits), 0x04 - * - T: Temperature Celsius (11 - 14 bits?), + 1000 * 10 - * - H: Relative Humidity (%) (7 bits) - * - K: Checksum (8 bits) - * - p: Parity bit - * Notes: - * - Temperature - * - Encoded as Celsius + 1000 * 10 - * - only 11 bits needed for specified range -40 C to 70 C (-40 F - 158 F) - * - However 14 bits available for temperature, giving possible range of -100 C to 1538.4 C - * - @todo - check if high 3 bits ever used for anything else - * - */ - -static const SubGhzBlockConst ws_protocol_acurite_592txr_const = { - .te_short = 200, - .te_long = 400, - .te_delta = 90, - .min_count_bit_for_found = 56, -}; - -struct WSProtocolDecoderAcurite_592TXR { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - - uint16_t header_count; -}; - -struct WSProtocolEncoderAcurite_592TXR { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - Acurite_592TXRDecoderStepReset = 0, - Acurite_592TXRDecoderStepCheckPreambule, - Acurite_592TXRDecoderStepSaveDuration, - Acurite_592TXRDecoderStepCheckDuration, -} Acurite_592TXRDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_acurite_592txr_decoder = { - .alloc = ws_protocol_decoder_acurite_592txr_alloc, - .free = ws_protocol_decoder_acurite_592txr_free, - - .feed = ws_protocol_decoder_acurite_592txr_feed, - .reset = ws_protocol_decoder_acurite_592txr_reset, - - .get_hash_data = ws_protocol_decoder_acurite_592txr_get_hash_data, - .serialize = ws_protocol_decoder_acurite_592txr_serialize, - .deserialize = ws_protocol_decoder_acurite_592txr_deserialize, - .get_string = ws_protocol_decoder_acurite_592txr_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_acurite_592txr_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_acurite_592txr = { - .name = WS_PROTOCOL_ACURITE_592TXR_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_acurite_592txr_decoder, - .encoder = &ws_protocol_acurite_592txr_encoder, -}; - -void* ws_protocol_decoder_acurite_592txr_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderAcurite_592TXR* instance = malloc(sizeof(WSProtocolDecoderAcurite_592TXR)); - instance->base.protocol = &ws_protocol_acurite_592txr; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_acurite_592txr_free(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - free(instance); -} - -void ws_protocol_decoder_acurite_592txr_reset(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; -} - -static bool ws_protocol_acurite_592txr_check_crc(WSProtocolDecoderAcurite_592TXR* instance) { - uint8_t msg[] = { - instance->decoder.decode_data >> 48, - instance->decoder.decode_data >> 40, - instance->decoder.decode_data >> 32, - instance->decoder.decode_data >> 24, - instance->decoder.decode_data >> 16, - instance->decoder.decode_data >> 8}; - - if((subghz_protocol_blocks_add_bytes(msg, 6) == - (uint8_t)(instance->decoder.decode_data & 0xFF)) && - (!subghz_protocol_blocks_parity_bytes(&msg[2], 4))) { - return true; - } else { - return false; - } -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_acurite_592txr_remote_controller(WSBlockGeneric* instance) { - uint8_t channel[] = {3, 0, 2, 1}; - uint8_t channel_raw = ((instance->data >> 54) & 0x03); - instance->channel = channel[channel_raw]; - instance->id = (instance->data >> 40) & 0x3FFF; - instance->battery_low = !((instance->data >> 38) & 1); - instance->humidity = (instance->data >> 24) & 0x7F; - - uint16_t temp_raw = ((instance->data >> 9) & 0xF80) | ((instance->data >> 8) & 0x7F); - instance->temp = ((float)(temp_raw)-1000) / 10.0f; - - instance->btn = WS_NO_BTN; -} - -void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - - switch(instance->decoder.parser_step) { - case Acurite_592TXRDecoderStepReset: - if((level) && (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short * 3) < - ws_protocol_acurite_592txr_const.te_delta * 2)) { - instance->decoder.parser_step = Acurite_592TXRDecoderStepCheckPreambule; - instance->decoder.te_last = duration; - instance->header_count = 0; - } - break; - - case Acurite_592TXRDecoderStepCheckPreambule: - if(level) { - instance->decoder.te_last = duration; - } else { - if((DURATION_DIFF( - instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short * 3) < - ws_protocol_acurite_592txr_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short * 3) < - ws_protocol_acurite_592txr_const.te_delta * 2)) { - //Found preambule - instance->header_count++; - } else if((instance->header_count > 2) && (instance->header_count < 5)) { - if((DURATION_DIFF( - instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short) < - ws_protocol_acurite_592txr_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_long) < - ws_protocol_acurite_592txr_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_long) < - ws_protocol_acurite_592txr_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short) < - ws_protocol_acurite_592txr_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - } - } - break; - - case Acurite_592TXRDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = Acurite_592TXRDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - } - break; - - case Acurite_592TXRDecoderStepCheckDuration: - if(!level) { - if(duration >= ((uint32_t)ws_protocol_acurite_592txr_const.te_short * 5)) { - if((instance->decoder.decode_count_bit == - ws_protocol_acurite_592txr_const.min_count_bit_for_found) && - ws_protocol_acurite_592txr_check_crc(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_acurite_592txr_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - break; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_short) < - ws_protocol_acurite_592txr_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_long) < - ws_protocol_acurite_592txr_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_acurite_592txr_const.te_long) < - ws_protocol_acurite_592txr_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_acurite_592txr_const.te_short) < - ws_protocol_acurite_592txr_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = Acurite_592TXRDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_592TXRDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_acurite_592txr_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_acurite_592txr_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderAcurite_592TXR* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/acurite_592txr.h b/applications/plugins/weather_station/protocols/acurite_592txr.h deleted file mode 100644 index ac0371d89..000000000 --- a/applications/plugins/weather_station/protocols/acurite_592txr.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_ACURITE_592TXR_NAME "Acurite 592TXR" - -typedef struct WSProtocolDecoderAcurite_592TXR WSProtocolDecoderAcurite_592TXR; -typedef struct WSProtocolEncoderAcurite_592TXR WSProtocolEncoderAcurite_592TXR; - -extern const SubGhzProtocolDecoder ws_protocol_acurite_592txr_decoder; -extern const SubGhzProtocolEncoder ws_protocol_acurite_592txr_encoder; -extern const SubGhzProtocol ws_protocol_acurite_592txr; - -/** - * Allocate WSProtocolDecoderAcurite_592TXR. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderAcurite_592TXR* pointer to a WSProtocolDecoderAcurite_592TXR instance - */ -void* ws_protocol_decoder_acurite_592txr_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderAcurite_592TXR. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - */ -void ws_protocol_decoder_acurite_592txr_free(void* context); - -/** - * Reset decoder WSProtocolDecoderAcurite_592TXR. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - */ -void ws_protocol_decoder_acurite_592txr_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_acurite_592txr_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_acurite_592txr_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderAcurite_592TXR. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_acurite_592txr_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderAcurite_592TXR. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_acurite_592txr_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderAcurite_592TXR instance - * @param output Resulting text - */ -void ws_protocol_decoder_acurite_592txr_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/acurite_606tx.c b/applications/plugins/weather_station/protocols/acurite_606tx.c deleted file mode 100644 index 4cb5d18b8..000000000 --- a/applications/plugins/weather_station/protocols/acurite_606tx.c +++ /dev/null @@ -1,247 +0,0 @@ -#include "acurite_606tx.h" - -#define TAG "WSProtocolAcurite_606TX" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/5bef4e43133ac4c0e2d18d36f87c52b4f9458453/src/devices/acurite.c#L1644 - * - * 0000 1111 | 0011 0000 | 0101 1100 | 1110 0111 - * iiii iiii | buuu tttt | tttt tttt | cccc cccc - * - i: identification; changes on battery switch - * - c: lfsr_digest8; - * - u: unknown; - * - b: battery low; flag to indicate low battery voltage - * - t: Temperature; in °C - * - */ - -static const SubGhzBlockConst ws_protocol_acurite_606tx_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 32, -}; - -struct WSProtocolDecoderAcurite_606TX { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderAcurite_606TX { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - Acurite_606TXDecoderStepReset = 0, - Acurite_606TXDecoderStepSaveDuration, - Acurite_606TXDecoderStepCheckDuration, -} Acurite_606TXDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_acurite_606tx_decoder = { - .alloc = ws_protocol_decoder_acurite_606tx_alloc, - .free = ws_protocol_decoder_acurite_606tx_free, - - .feed = ws_protocol_decoder_acurite_606tx_feed, - .reset = ws_protocol_decoder_acurite_606tx_reset, - - .get_hash_data = ws_protocol_decoder_acurite_606tx_get_hash_data, - .serialize = ws_protocol_decoder_acurite_606tx_serialize, - .deserialize = ws_protocol_decoder_acurite_606tx_deserialize, - .get_string = ws_protocol_decoder_acurite_606tx_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_acurite_606tx_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_acurite_606tx = { - .name = WS_PROTOCOL_ACURITE_606TX_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_acurite_606tx_decoder, - .encoder = &ws_protocol_acurite_606tx_encoder, -}; - -void* ws_protocol_decoder_acurite_606tx_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderAcurite_606TX* instance = malloc(sizeof(WSProtocolDecoderAcurite_606TX)); - instance->base.protocol = &ws_protocol_acurite_606tx; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_acurite_606tx_free(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - free(instance); -} - -void ws_protocol_decoder_acurite_606tx_reset(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; -} - -static bool ws_protocol_acurite_606tx_check(WSProtocolDecoderAcurite_606TX* instance) { - if(!instance->decoder.decode_data) return false; - uint8_t msg[] = { - instance->decoder.decode_data >> 24, - instance->decoder.decode_data >> 16, - instance->decoder.decode_data >> 8}; - - uint8_t crc = subghz_protocol_blocks_lfsr_digest8(msg, 3, 0x98, 0xF1); - return (crc == (instance->decoder.decode_data & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_acurite_606tx_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 24) & 0xFF; - instance->battery_low = (instance->data >> 23) & 1; - - instance->channel = WS_NO_CHANNEL; - - if(!((instance->data >> 19) & 1)) { - instance->temp = (float)((instance->data >> 8) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 8) & 0x07FF) + 1) / -10.0f; - } - instance->btn = WS_NO_BTN; - instance->humidity = WS_NO_HUMIDITY; -} - -void ws_protocol_decoder_acurite_606tx_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - - switch(instance->decoder.parser_step) { - case Acurite_606TXDecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_acurite_606tx_const.te_short * 17) < - ws_protocol_acurite_606tx_const.te_delta * 8)) { - //Found syncPrefix - instance->decoder.parser_step = Acurite_606TXDecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case Acurite_606TXDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = Acurite_606TXDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; - } - break; - - case Acurite_606TXDecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(instance->decoder.te_last, ws_protocol_acurite_606tx_const.te_short) < - ws_protocol_acurite_606tx_const.te_delta) { - if((DURATION_DIFF(duration, ws_protocol_acurite_606tx_const.te_short) < - ws_protocol_acurite_606tx_const.te_delta) || - (duration > ws_protocol_acurite_606tx_const.te_long * 3)) { - //Found syncPostfix - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_acurite_606tx_const.min_count_bit_for_found) && - ws_protocol_acurite_606tx_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_acurite_606tx_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } else if( - DURATION_DIFF(duration, ws_protocol_acurite_606tx_const.te_long) < - ws_protocol_acurite_606tx_const.te_delta * 2) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = Acurite_606TXDecoderStepSaveDuration; - } else if( - DURATION_DIFF(duration, ws_protocol_acurite_606tx_const.te_long * 2) < - ws_protocol_acurite_606tx_const.te_delta * 4) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = Acurite_606TXDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_606TXDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_acurite_606tx_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_acurite_606tx_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_acurite_606tx_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_acurite_606tx_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderAcurite_606TX* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/acurite_606tx.h b/applications/plugins/weather_station/protocols/acurite_606tx.h deleted file mode 100644 index 5bab3bcb7..000000000 --- a/applications/plugins/weather_station/protocols/acurite_606tx.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_ACURITE_606TX_NAME "Acurite-606TX" - -typedef struct WSProtocolDecoderAcurite_606TX WSProtocolDecoderAcurite_606TX; -typedef struct WSProtocolEncoderAcurite_606TX WSProtocolEncoderAcurite_606TX; - -extern const SubGhzProtocolDecoder ws_protocol_acurite_606tx_decoder; -extern const SubGhzProtocolEncoder ws_protocol_acurite_606tx_encoder; -extern const SubGhzProtocol ws_protocol_acurite_606tx; - -/** - * Allocate WSProtocolDecoderAcurite_606TX. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderAcurite_606TX* pointer to a WSProtocolDecoderAcurite_606TX instance - */ -void* ws_protocol_decoder_acurite_606tx_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderAcurite_606TX. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - */ -void ws_protocol_decoder_acurite_606tx_free(void* context); - -/** - * Reset decoder WSProtocolDecoderAcurite_606TX. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - */ -void ws_protocol_decoder_acurite_606tx_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_acurite_606tx_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_acurite_606tx_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderAcurite_606TX. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_acurite_606tx_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderAcurite_606TX. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_acurite_606tx_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderAcurite_606TX instance - * @param output Resulting text - */ -void ws_protocol_decoder_acurite_606tx_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/acurite_609txc.c b/applications/plugins/weather_station/protocols/acurite_609txc.c deleted file mode 100644 index aeb0785eb..000000000 --- a/applications/plugins/weather_station/protocols/acurite_609txc.c +++ /dev/null @@ -1,247 +0,0 @@ -#include "acurite_609txc.h" - -#define TAG "WSProtocolAcurite_609TXC" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/5bef4e43133ac4c0e2d18d36f87c52b4f9458453/src/devices/acurite.c#L216 - * - * 0000 1111 | 0011 0000 | 0101 1100 | 0000 0000 | 1110 0111 - * iiii iiii | buuu tttt | tttt tttt | hhhh hhhh | cccc cccc - * - i: identification; changes on battery switch - * - c: checksum (sum of previous by bytes) - * - u: unknown - * - b: battery low; flag to indicate low battery voltage - * - t: temperature; in °C * 10, 12 bit with complement - * - h: humidity - * - */ - -static const SubGhzBlockConst ws_protocol_acurite_609txc_const = { - .te_short = 500, - .te_long = 1000, - .te_delta = 150, - .min_count_bit_for_found = 40, -}; - -struct WSProtocolDecoderAcurite_609TXC { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderAcurite_609TXC { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - Acurite_609TXCDecoderStepReset = 0, - Acurite_609TXCDecoderStepSaveDuration, - Acurite_609TXCDecoderStepCheckDuration, -} Acurite_609TXCDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_acurite_609txc_decoder = { - .alloc = ws_protocol_decoder_acurite_609txc_alloc, - .free = ws_protocol_decoder_acurite_609txc_free, - - .feed = ws_protocol_decoder_acurite_609txc_feed, - .reset = ws_protocol_decoder_acurite_609txc_reset, - - .get_hash_data = ws_protocol_decoder_acurite_609txc_get_hash_data, - .serialize = ws_protocol_decoder_acurite_609txc_serialize, - .deserialize = ws_protocol_decoder_acurite_609txc_deserialize, - .get_string = ws_protocol_decoder_acurite_609txc_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_acurite_609txc_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_acurite_609txc = { - .name = WS_PROTOCOL_ACURITE_609TXC_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_acurite_609txc_decoder, - .encoder = &ws_protocol_acurite_609txc_encoder, -}; - -void* ws_protocol_decoder_acurite_609txc_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderAcurite_609TXC* instance = malloc(sizeof(WSProtocolDecoderAcurite_609TXC)); - instance->base.protocol = &ws_protocol_acurite_609txc; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_acurite_609txc_free(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - free(instance); -} - -void ws_protocol_decoder_acurite_609txc_reset(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; -} - -static bool ws_protocol_acurite_609txc_check(WSProtocolDecoderAcurite_609TXC* instance) { - if(!instance->decoder.decode_data) return false; - uint8_t crc = (uint8_t)(instance->decoder.decode_data >> 32) + - (uint8_t)(instance->decoder.decode_data >> 24) + - (uint8_t)(instance->decoder.decode_data >> 16) + - (uint8_t)(instance->decoder.decode_data >> 8); - return (crc == (instance->decoder.decode_data & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_acurite_609txc_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 32) & 0xFF; - instance->battery_low = (instance->data >> 31) & 1; - - instance->channel = WS_NO_CHANNEL; - - // Temperature in Celsius is encoded as a 12 bit integer value - // multiplied by 10 using the 4th - 6th nybbles (bytes 1 & 2) - // negative values are recovered by sign extend from int16_t. - int16_t temp_raw = - (int16_t)(((instance->data >> 12) & 0xf000) | ((instance->data >> 16) << 4)); - instance->temp = (temp_raw >> 4) * 0.1f; - instance->humidity = (instance->data >> 8) & 0xff; - instance->btn = WS_NO_BTN; -} - -void ws_protocol_decoder_acurite_609txc_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - - switch(instance->decoder.parser_step) { - case Acurite_609TXCDecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_acurite_609txc_const.te_short * 17) < - ws_protocol_acurite_609txc_const.te_delta * 8)) { - //Found syncPrefix - instance->decoder.parser_step = Acurite_609TXCDecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case Acurite_609TXCDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = Acurite_609TXCDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; - } - break; - - case Acurite_609TXCDecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(instance->decoder.te_last, ws_protocol_acurite_609txc_const.te_short) < - ws_protocol_acurite_609txc_const.te_delta) { - if((DURATION_DIFF(duration, ws_protocol_acurite_609txc_const.te_short) < - ws_protocol_acurite_609txc_const.te_delta) || - (duration > ws_protocol_acurite_609txc_const.te_long * 3)) { - //Found syncPostfix - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_acurite_609txc_const.min_count_bit_for_found) && - ws_protocol_acurite_609txc_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_acurite_609txc_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } else if( - DURATION_DIFF(duration, ws_protocol_acurite_609txc_const.te_long) < - ws_protocol_acurite_609txc_const.te_delta * 2) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = Acurite_609TXCDecoderStepSaveDuration; - } else if( - DURATION_DIFF(duration, ws_protocol_acurite_609txc_const.te_long * 2) < - ws_protocol_acurite_609txc_const.te_delta * 4) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = Acurite_609TXCDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; - } - } else { - instance->decoder.parser_step = Acurite_609TXCDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_acurite_609txc_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_acurite_609txc_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_acurite_609txc_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_acurite_609txc_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderAcurite_609TXC* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 40), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/acurite_609txc.h b/applications/plugins/weather_station/protocols/acurite_609txc.h deleted file mode 100644 index f87c20e9b..000000000 --- a/applications/plugins/weather_station/protocols/acurite_609txc.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_ACURITE_609TXC_NAME "Acurite-609TXC" - -typedef struct WSProtocolDecoderAcurite_609TXC WSProtocolDecoderAcurite_609TXC; -typedef struct WSProtocolEncoderAcurite_609TXC WSProtocolEncoderAcurite_609TXC; - -extern const SubGhzProtocolDecoder ws_protocol_acurite_609txc_decoder; -extern const SubGhzProtocolEncoder ws_protocol_acurite_609txc_encoder; -extern const SubGhzProtocol ws_protocol_acurite_609txc; - -/** - * Allocate WSProtocolDecoderAcurite_609TXC. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderAcurite_609TXC* pointer to a WSProtocolDecoderAcurite_609TXC instance - */ -void* ws_protocol_decoder_acurite_609txc_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderAcurite_609TXC. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - */ -void ws_protocol_decoder_acurite_609txc_free(void* context); - -/** - * Reset decoder WSProtocolDecoderAcurite_609TXC. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - */ -void ws_protocol_decoder_acurite_609txc_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_acurite_609txc_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_acurite_609txc_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderAcurite_609TXC. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_acurite_609txc_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderAcurite_609TXC. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_acurite_609txc_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderAcurite_609TXC instance - * @param output Resulting text - */ -void ws_protocol_decoder_acurite_609txc_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/ambient_weather.c b/applications/plugins/weather_station/protocols/ambient_weather.c deleted file mode 100644 index 5ae22b790..000000000 --- a/applications/plugins/weather_station/protocols/ambient_weather.c +++ /dev/null @@ -1,276 +0,0 @@ -#include "ambient_weather.h" -#include - -#define TAG "WSProtocolAmbient_Weather" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/ambient_weather.c - * - * Decode Ambient Weather F007TH, F012TH, TF 30.3208.02, SwitchDoc F016TH. - * Devices supported: - * - Ambient Weather F007TH Thermo-Hygrometer. - * - Ambient Weather F012TH Indoor/Display Thermo-Hygrometer. - * - TFA senders 30.3208.02 from the TFA "Klima-Monitor" 30.3054, - * - SwitchDoc Labs F016TH. - * This decoder handles the 433mhz/868mhz thermo-hygrometers. - * The 915mhz (WH*) family of devices use different modulation/encoding. - * Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 - * xxxxMMMM IIIIIIII BCCCTTTT TTTTTTTT HHHHHHHH MMMMMMMM - * - x: Unknown 0x04 on F007TH/F012TH - * - M: Model Number?, 0x05 on F007TH/F012TH/SwitchDocLabs F016TH - * - I: ID byte (8 bits), volatie, changes at power up, - * - B: Battery Low - * - C: Channel (3 bits 1-8) - F007TH set by Dip switch, F012TH soft setting - * - T: Temperature 12 bits - Fahrenheit * 10 + 400 - * - H: Humidity (8 bits) - * - M: Message integrity check LFSR Digest-8, gen 0x98, key 0x3e, init 0x64 - * - * three repeats without gap - * full preamble is 0x00145 (the last bits might not be fixed, e.g. 0x00146) - * and on decoding also 0xffd45 - */ - -#define AMBIENT_WEATHER_PACKET_HEADER_1 0xFFD440000000000 //0xffd45 .. 0xffd46 -#define AMBIENT_WEATHER_PACKET_HEADER_2 0x001440000000000 //0x00145 .. 0x00146 -#define AMBIENT_WEATHER_PACKET_HEADER_MASK 0xFFFFC0000000000 - -static const SubGhzBlockConst ws_protocol_ambient_weather_const = { - .te_short = 500, - .te_long = 1000, - .te_delta = 120, - .min_count_bit_for_found = 48, -}; - -struct WSProtocolDecoderAmbient_Weather { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - ManchesterState manchester_saved_state; - uint16_t header_count; -}; - -struct WSProtocolEncoderAmbient_Weather { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -const SubGhzProtocolDecoder ws_protocol_ambient_weather_decoder = { - .alloc = ws_protocol_decoder_ambient_weather_alloc, - .free = ws_protocol_decoder_ambient_weather_free, - - .feed = ws_protocol_decoder_ambient_weather_feed, - .reset = ws_protocol_decoder_ambient_weather_reset, - - .get_hash_data = ws_protocol_decoder_ambient_weather_get_hash_data, - .serialize = ws_protocol_decoder_ambient_weather_serialize, - .deserialize = ws_protocol_decoder_ambient_weather_deserialize, - .get_string = ws_protocol_decoder_ambient_weather_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_ambient_weather_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_ambient_weather = { - .name = WS_PROTOCOL_AMBIENT_WEATHER_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_ambient_weather_decoder, - .encoder = &ws_protocol_ambient_weather_encoder, -}; - -void* ws_protocol_decoder_ambient_weather_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderAmbient_Weather* instance = malloc(sizeof(WSProtocolDecoderAmbient_Weather)); - instance->base.protocol = &ws_protocol_ambient_weather; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_ambient_weather_free(void* context) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - free(instance); -} - -void ws_protocol_decoder_ambient_weather_reset(void* context) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - manchester_advance( - instance->manchester_saved_state, - ManchesterEventReset, - &instance->manchester_saved_state, - NULL); -} - -static bool ws_protocol_ambient_weather_check_crc(WSProtocolDecoderAmbient_Weather* instance) { - uint8_t msg[] = { - instance->decoder.decode_data >> 40, - instance->decoder.decode_data >> 32, - instance->decoder.decode_data >> 24, - instance->decoder.decode_data >> 16, - instance->decoder.decode_data >> 8}; - - uint8_t crc = subghz_protocol_blocks_lfsr_digest8(msg, 5, 0x98, 0x3e) ^ 0x64; - return (crc == (uint8_t)(instance->decoder.decode_data & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_ambient_weather_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 32) & 0xFF; - instance->battery_low = (instance->data >> 31) & 1; - instance->channel = ((instance->data >> 28) & 0x07) + 1; - instance->temp = ws_block_generic_fahrenheit_to_celsius( - ((float)((instance->data >> 16) & 0x0FFF) - 400.0f) / 10.0f); - instance->humidity = (instance->data >> 8) & 0xFF; - instance->btn = WS_NO_BTN; - - // ToDo maybe it won't be needed - /* - Sanity checks to reduce false positives and other bad data - Packets with Bad data often pass the MIC check. - - humidity > 100 (such as 255) and - - temperatures > 140 F (such as 369.5 F and 348.8 F - Specs in the F007TH and F012TH manuals state the range is: - - Temperature: -40 to 140 F - - Humidity: 10 to 99% - @todo - sanity check b[0] "model number" - - 0x45 - F007TH and F012TH - - 0x?5 - SwitchDocLabs F016TH temperature sensor (based on comment b[0] & 0x0f == 5) - - ? - TFA 30.3208.02 - if (instance->humidity < 0 || instance->humidity > 100) { - ERROR; - } - - if (instance->temp < -40.0 || instance->temp > 140.0) { - ERROR; - } - */ -} - -void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - - ManchesterEvent event = ManchesterEventReset; - if(!level) { - if(DURATION_DIFF(duration, ws_protocol_ambient_weather_const.te_short) < - ws_protocol_ambient_weather_const.te_delta) { - event = ManchesterEventShortLow; - } else if( - DURATION_DIFF(duration, ws_protocol_ambient_weather_const.te_long) < - ws_protocol_ambient_weather_const.te_delta * 2) { - event = ManchesterEventLongLow; - } - } else { - if(DURATION_DIFF(duration, ws_protocol_ambient_weather_const.te_short) < - ws_protocol_ambient_weather_const.te_delta) { - event = ManchesterEventShortHigh; - } else if( - DURATION_DIFF(duration, ws_protocol_ambient_weather_const.te_long) < - ws_protocol_ambient_weather_const.te_delta * 2) { - event = ManchesterEventLongHigh; - } - } - if(event != ManchesterEventReset) { - bool data; - bool data_ok = manchester_advance( - instance->manchester_saved_state, event, &instance->manchester_saved_state, &data); - - if(data_ok) { - instance->decoder.decode_data = (instance->decoder.decode_data << 1) | !data; - } - - if(((instance->decoder.decode_data & AMBIENT_WEATHER_PACKET_HEADER_MASK) == - AMBIENT_WEATHER_PACKET_HEADER_1) || - ((instance->decoder.decode_data & AMBIENT_WEATHER_PACKET_HEADER_MASK) == - AMBIENT_WEATHER_PACKET_HEADER_2)) { - if(ws_protocol_ambient_weather_check_crc(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = - ws_protocol_ambient_weather_const.min_count_bit_for_found; - ws_protocol_ambient_weather_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - } - } else { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - manchester_advance( - instance->manchester_saved_state, - ManchesterEventReset, - &instance->manchester_saved_state, - NULL); - } -} - -uint8_t ws_protocol_decoder_ambient_weather_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_ambient_weather_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_ambient_weather_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_ambient_weather_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderAmbient_Weather* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/ambient_weather.h b/applications/plugins/weather_station/protocols/ambient_weather.h deleted file mode 100644 index 04cc5819c..000000000 --- a/applications/plugins/weather_station/protocols/ambient_weather.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_AMBIENT_WEATHER_NAME "Ambient_Weather" - -typedef struct WSProtocolDecoderAmbient_Weather WSProtocolDecoderAmbient_Weather; -typedef struct WSProtocolEncoderAmbient_Weather WSProtocolEncoderAmbient_Weather; - -extern const SubGhzProtocolDecoder ws_protocol_ambient_weather_decoder; -extern const SubGhzProtocolEncoder ws_protocol_ambient_weather_encoder; -extern const SubGhzProtocol ws_protocol_ambient_weather; - -/** - * Allocate WSProtocolDecoderAmbient_Weather. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderAmbient_Weather* pointer to a WSProtocolDecoderAmbient_Weather instance - */ -void* ws_protocol_decoder_ambient_weather_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderAmbient_Weather. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - */ -void ws_protocol_decoder_ambient_weather_free(void* context); - -/** - * Reset decoder WSProtocolDecoderAmbient_Weather. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - */ -void ws_protocol_decoder_ambient_weather_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_ambient_weather_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderAmbient_Weather. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_ambient_weather_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderAmbient_Weather. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_ambient_weather_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderAmbient_Weather instance - * @param output Resulting text - */ -void ws_protocol_decoder_ambient_weather_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/auriol_hg0601a.c b/applications/plugins/weather_station/protocols/auriol_hg0601a.c deleted file mode 100644 index d5f89fc8b..000000000 --- a/applications/plugins/weather_station/protocols/auriol_hg0601a.c +++ /dev/null @@ -1,258 +0,0 @@ -#include "auriol_hg0601a.h" - -#define TAG "WSProtocolAuriol_TH" - -/* - * -Auriol HG06061A-DCF-TX sensor. - -Data layout: - DDDDDDDD-B0-NN-TT-TTTTTTTTTT-CCCC-HHHHHHHH -Exmpl.: 11110100-10-01-00-0001001100-1111-01011101 - -- D: id, 8 bit -- B: where B is the battery status: 1=OK, 0=LOW, 1 bit -- 0: just zero :) -- N: NN is the channel: 00=CH1, 01=CH2, 11=CH3, 2bit -- T: temperature, 12 bit: 2's complement, scaled by 10 -- C: 4 bit: seems to be 0xf constantly, a separator between temp and humidity -- H: humidity sensor, humidity is 8 bits - - * The sensor sends 37 bits 10 times, - * the packets are ppm modulated (distance coding) with a pulse of ~500 us - * followed by a short gap of ~1000 us for a 0 bit or a long ~2000 us gap for a - * 1 bit, the sync gap is ~4000 us. - * - */ - -#define AURIOL_TH_CONST_DATA 0b1110 - -static const SubGhzBlockConst ws_protocol_auriol_th_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 37, -}; - -struct WSProtocolDecoderAuriol_TH { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderAuriol_TH { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - auriol_THDecoderStepReset = 0, - auriol_THDecoderStepSaveDuration, - auriol_THDecoderStepCheckDuration, -} auriol_THDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_auriol_th_decoder = { - .alloc = ws_protocol_decoder_auriol_th_alloc, - .free = ws_protocol_decoder_auriol_th_free, - - .feed = ws_protocol_decoder_auriol_th_feed, - .reset = ws_protocol_decoder_auriol_th_reset, - - .get_hash_data = ws_protocol_decoder_auriol_th_get_hash_data, - .serialize = ws_protocol_decoder_auriol_th_serialize, - .deserialize = ws_protocol_decoder_auriol_th_deserialize, - .get_string = ws_protocol_decoder_auriol_th_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_auriol_th_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_auriol_th = { - .name = WS_PROTOCOL_AURIOL_TH_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_auriol_th_decoder, - .encoder = &ws_protocol_auriol_th_encoder, -}; - -void* ws_protocol_decoder_auriol_th_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderAuriol_TH* instance = malloc(sizeof(WSProtocolDecoderAuriol_TH)); - instance->base.protocol = &ws_protocol_auriol_th; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_auriol_th_free(void* context) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - free(instance); -} - -void ws_protocol_decoder_auriol_th_reset(void* context) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - instance->decoder.parser_step = auriol_THDecoderStepReset; -} - -static bool ws_protocol_auriol_th_check(WSProtocolDecoderAuriol_TH* instance) { - uint8_t type = (instance->decoder.decode_data >> 8) & 0x0F; - - if((type == AURIOL_TH_CONST_DATA) && ((instance->decoder.decode_data >> 4) != 0xffffffff)) { - return true; - } else { - return false; - } - return true; -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_auriol_th_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 31) & 0xFF; - instance->battery_low = ((instance->data >> 30) & 1); - instance->channel = ((instance->data >> 25) & 0x03) + 1; - instance->btn = WS_NO_BTN; - if(!((instance->data >> 23) & 1)) { - instance->temp = (float)((instance->data >> 13) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 13) & 0x07FF) + 1) / -10.0f; - } - - instance->humidity = (instance->data >> 1) & 0x7F; -} - -void ws_protocol_decoder_auriol_th_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - - switch(instance->decoder.parser_step) { - case auriol_THDecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_auriol_th_const.te_short * 8) < - ws_protocol_auriol_th_const.te_delta)) { - //Found sync - instance->decoder.parser_step = auriol_THDecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case auriol_THDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = auriol_THDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = auriol_THDecoderStepReset; - } - break; - - case auriol_THDecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(duration, ws_protocol_auriol_th_const.te_short * 8) < - ws_protocol_auriol_th_const.te_delta) { - //Found sync - instance->decoder.parser_step = auriol_THDecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_auriol_th_const.min_count_bit_for_found) && - ws_protocol_auriol_th_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_auriol_th_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - instance->decoder.parser_step = auriol_THDecoderStepCheckDuration; - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - - break; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_auriol_th_const.te_short) < - ws_protocol_auriol_th_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_auriol_th_const.te_short * 2) < - ws_protocol_auriol_th_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = auriol_THDecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_auriol_th_const.te_short) < - ws_protocol_auriol_th_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_auriol_th_const.te_short * 4) < - ws_protocol_auriol_th_const.te_delta * 2)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = auriol_THDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = auriol_THDecoderStepReset; - } - } else { - instance->decoder.parser_step = auriol_THDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_auriol_th_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_auriol_th_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_auriol_th_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_auriol_th_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderAuriol_TH* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/auriol_hg0601a.h b/applications/plugins/weather_station/protocols/auriol_hg0601a.h deleted file mode 100644 index c23007c1a..000000000 --- a/applications/plugins/weather_station/protocols/auriol_hg0601a.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_AURIOL_TH_NAME "Auriol HG06061" //HG06061A-DCF-TX - -typedef struct WSProtocolDecoderAuriol_TH WSProtocolDecoderAuriol_TH; -typedef struct WSProtocolEncoderAuriol_TH WSProtocolEncoderAuriol_TH; - -extern const SubGhzProtocolDecoder ws_protocol_auriol_th_decoder; -extern const SubGhzProtocolEncoder ws_protocol_auriol_th_encoder; -extern const SubGhzProtocol ws_protocol_auriol_th; - -/** - * Allocate WSProtocolDecoderAuriol_TH. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderAuriol_TH* pointer to a WSProtocolDecoderAuriol_TH instance - */ -void* ws_protocol_decoder_auriol_th_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderAuriol_TH. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - */ -void ws_protocol_decoder_auriol_th_free(void* context); - -/** - * Reset decoder WSProtocolDecoderAuriol_TH. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - */ -void ws_protocol_decoder_auriol_th_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_auriol_th_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_auriol_th_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderAuriol_TH. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_auriol_th_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderAuriol_TH. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_auriol_th_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderAuriol_TH instance - * @param output Resulting text - */ -void ws_protocol_decoder_auriol_th_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/gt_wt_02.c b/applications/plugins/weather_station/protocols/gt_wt_02.c deleted file mode 100644 index cbe119192..000000000 --- a/applications/plugins/weather_station/protocols/gt_wt_02.c +++ /dev/null @@ -1,265 +0,0 @@ -#include "gt_wt_02.h" - -#define TAG "WSProtocolGT_WT02" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/gt_wt_02.c - * - * GT-WT-02 sensor on 433.92MHz. - * Example and frame description provided by https://github.com/ludwich66 - * [01] {37} 34 00 ed 47 60 : 00110100 00000000 11101101 01000111 01100000 - * code, BatOK,not-man-send, Channel1, +23,7C, 35% - * [01] {37} 34 8f 87 15 90 : 00110100 10001111 10000111 00010101 10010000 - * code, BatOK,not-man-send, Channel1,-12,1C, 10% - * Humidity: - * - the working range is 20-90 % - * - if "LL" in display view it sends 10 % - * - if "HH" in display view it sends 110% - * SENSOR: GT-WT-02 (ALDI Globaltronics..) - * TYP IIIIIIII BMCCTTTT TTTTTTTT HHHHHHHX XXXXX - * TYPE Description: - * - I = Random Device Code, changes with battery reset - * - B = Battery 0=OK 1=LOW - * - M = Manual Send Button Pressed 0=not pressed 1=pressed - * - C = Channel 00=CH1, 01=CH2, 10=CH3 - * - T = Temperature, 12 Bit 2's complement, scaled by 10 - * - H = Humidity = 7 Bit bin2dez 00-99, Display LL=10%, Display HH=110% (Range 20-90%) - * - X = Checksum, sum modulo 64 - * A Lidl AURIO (from 12/2018) with PCB marking YJ-T12 V02 has two extra bits in front. - * -*/ - -static const SubGhzBlockConst ws_protocol_gt_wt_02_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 37, -}; - -struct WSProtocolDecoderGT_WT02 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderGT_WT02 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - GT_WT02DecoderStepReset = 0, - GT_WT02DecoderStepSaveDuration, - GT_WT02DecoderStepCheckDuration, -} GT_WT02DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_gt_wt_02_decoder = { - .alloc = ws_protocol_decoder_gt_wt_02_alloc, - .free = ws_protocol_decoder_gt_wt_02_free, - - .feed = ws_protocol_decoder_gt_wt_02_feed, - .reset = ws_protocol_decoder_gt_wt_02_reset, - - .get_hash_data = ws_protocol_decoder_gt_wt_02_get_hash_data, - .serialize = ws_protocol_decoder_gt_wt_02_serialize, - .deserialize = ws_protocol_decoder_gt_wt_02_deserialize, - .get_string = ws_protocol_decoder_gt_wt_02_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_gt_wt_02_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_gt_wt_02 = { - .name = WS_PROTOCOL_GT_WT_02_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_gt_wt_02_decoder, - .encoder = &ws_protocol_gt_wt_02_encoder, -}; - -void* ws_protocol_decoder_gt_wt_02_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderGT_WT02* instance = malloc(sizeof(WSProtocolDecoderGT_WT02)); - instance->base.protocol = &ws_protocol_gt_wt_02; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_gt_wt_02_free(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - free(instance); -} - -void ws_protocol_decoder_gt_wt_02_reset(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - instance->decoder.parser_step = GT_WT02DecoderStepReset; -} - -static bool ws_protocol_gt_wt_02_check(WSProtocolDecoderGT_WT02* instance) { - if(!instance->decoder.decode_data) return false; - uint8_t sum = (instance->decoder.decode_data >> 5) & 0xe; - uint64_t temp_data = instance->decoder.decode_data >> 9; - for(uint8_t i = 0; i < 7; i++) { - sum += (temp_data >> (i * 4)) & 0xF; - } - return ((uint8_t)(instance->decoder.decode_data & 0x3F) == (sum & 0x3F)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_gt_wt_02_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 29) & 0xFF; - instance->battery_low = (instance->data >> 28) & 1; - instance->btn = (instance->data >> 27) & 1; - instance->channel = ((instance->data >> 25) & 0x3) + 1; - - if(!((instance->data >> 24) & 1)) { - instance->temp = (float)((instance->data >> 13) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 13) & 0x07FF) + 1) / -10.0f; - } - - instance->humidity = (instance->data >> 6) & 0x7F; - if(instance->humidity <= 10) // actually the sensors sends 10 below working range of 20% - instance->humidity = 0; - else if(instance->humidity > 90) // actually the sensors sends 110 above working range of 90% - instance->humidity = 100; -} - -void ws_protocol_decoder_gt_wt_02_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - - switch(instance->decoder.parser_step) { - case GT_WT02DecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_gt_wt_02_const.te_short * 18) < - ws_protocol_gt_wt_02_const.te_delta * 8)) { - //Found syncPrefix - instance->decoder.parser_step = GT_WT02DecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case GT_WT02DecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = GT_WT02DecoderStepCheckDuration; - } else { - instance->decoder.parser_step = GT_WT02DecoderStepReset; - } - break; - - case GT_WT02DecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_02_const.te_short) < - ws_protocol_gt_wt_02_const.te_delta) { - if(DURATION_DIFF(duration, ws_protocol_gt_wt_02_const.te_short * 18) < - ws_protocol_gt_wt_02_const.te_delta * 8) { - //Found syncPostfix - instance->decoder.parser_step = GT_WT02DecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_gt_wt_02_const.min_count_bit_for_found) && - ws_protocol_gt_wt_02_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_gt_wt_02_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } else if(instance->decoder.decode_count_bit == 1) { - instance->decoder.parser_step = GT_WT02DecoderStepSaveDuration; - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } else if( - DURATION_DIFF(duration, ws_protocol_gt_wt_02_const.te_long) < - ws_protocol_gt_wt_02_const.te_delta * 2) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = GT_WT02DecoderStepSaveDuration; - } else if( - DURATION_DIFF(duration, ws_protocol_gt_wt_02_const.te_long * 2) < - ws_protocol_gt_wt_02_const.te_delta * 4) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = GT_WT02DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = GT_WT02DecoderStepReset; - } - } else { - instance->decoder.parser_step = GT_WT02DecoderStepReset; - } - } else { - instance->decoder.parser_step = GT_WT02DecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_gt_wt_02_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_gt_wt_02_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_gt_wt_02_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_gt_wt_02_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderGT_WT02* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/gt_wt_02.h b/applications/plugins/weather_station/protocols/gt_wt_02.h deleted file mode 100644 index f17d5baa0..000000000 --- a/applications/plugins/weather_station/protocols/gt_wt_02.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_GT_WT_02_NAME "GT-WT02" - -typedef struct WSProtocolDecoderGT_WT02 WSProtocolDecoderGT_WT02; -typedef struct WSProtocolEncoderGT_WT02 WSProtocolEncoderGT_WT02; - -extern const SubGhzProtocolDecoder ws_protocol_gt_wt_02_decoder; -extern const SubGhzProtocolEncoder ws_protocol_gt_wt_02_encoder; -extern const SubGhzProtocol ws_protocol_gt_wt_02; - -/** - * Allocate WSProtocolDecoderGT_WT02. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderGT_WT02* pointer to a WSProtocolDecoderGT_WT02 instance - */ -void* ws_protocol_decoder_gt_wt_02_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderGT_WT02. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - */ -void ws_protocol_decoder_gt_wt_02_free(void* context); - -/** - * Reset decoder WSProtocolDecoderGT_WT02. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - */ -void ws_protocol_decoder_gt_wt_02_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_gt_wt_02_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_gt_wt_02_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderGT_WT02. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_gt_wt_02_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderGT_WT02. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_gt_wt_02_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderGT_WT02 instance - * @param output Resulting text - */ -void ws_protocol_decoder_gt_wt_02_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/gt_wt_03.c b/applications/plugins/weather_station/protocols/gt_wt_03.c deleted file mode 100644 index 7831cf069..000000000 --- a/applications/plugins/weather_station/protocols/gt_wt_03.c +++ /dev/null @@ -1,340 +0,0 @@ -#include "gt_wt_03.h" - -#define TAG "WSProtocolGT_WT03" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/gt_wt_03.c - * - * - * Globaltronics GT-WT-03 sensor on 433.92MHz. - * The 01-set sensor has 60 ms packet gap with 10 repeats. - * The 02-set sensor has no packet gap with 23 repeats. - * Example: - * {41} 17 cf be fa 6a 80 [ S1 C1 26,1 C 78.9 F 48% Bat-Good Manual-Yes ] - * {41} 17 cf be fa 6a 80 [ S1 C1 26,1 C 78.9 F 48% Bat-Good Manual-Yes Batt-Changed ] - * {41} 17 cf fe fa ea 80 [ S1 C1 26,1 C 78.9 F 48% Bat-Good Manual-No Batt-Changed ] - * {41} 01 cf 6f 11 b2 80 [ S2 C2 23,8 C 74.8 F 48% Bat-LOW Manual-No ] - * {41} 01 c8 d0 2b 76 80 [ S2 C3 -4,4 C 24.1 F 55% Bat-Good Manual-No Batt-Changed ] - * Format string: - * ID:8h HUM:8d B:b M:b C:2d TEMP:12d CHK:8h 1x - * Data layout: - * TYP IIIIIIII HHHHHHHH BMCCTTTT TTTTTTTT XXXXXXXX - * - I: Random Device Code: changes with battery reset - * - H: Humidity: 8 Bit 00-99, Display LL=10%, Display HH=110% (Range 20-95%) - * - B: Battery: 0=OK 1=LOW - * - M: Manual Send Button Pressed: 0=not pressed, 1=pressed - * - C: Channel: 00=CH1, 01=CH2, 10=CH3 - * - T: Temperature: 12 Bit 2's complement, scaled by 10, range-50.0 C (-50.1 shown as Lo) to +70.0 C (+70.1 C is shown as Hi) - * - X: Checksum, xor shifting key per byte - * Humidity: - * - the working range is 20-95 % - * - if "LL" in display view it sends 10 % - * - if "HH" in display view it sends 110% - * Checksum: - * Per byte xor the key for each 1-bit, shift per bit. Key list per bit, starting at MSB: - * - 0x00 [07] - * - 0x80 [06] - * - 0x40 [05] - * - 0x20 [04] - * - 0x10 [03] - * - 0x88 [02] - * - 0xc4 [01] - * - 0x62 [00] - * Note: this can also be seen as lower byte of a Galois/Fibonacci LFSR-16, gen 0x00, init 0x3100 (or 0x62 if reversed) resetting at every byte. - * Battery voltages: - * - U=<2,65V +- ~5% Battery indicator - * - U=>2.10C +- 5% plausible readings - * - U=2,00V +- ~5% Temperature offset -5°C Humidity offset unknown - * - U=<1,95V +- ~5% does not initialize anymore - * - U=1,90V +- 5% temperature offset -15°C - * - U=1,80V +- 5% Display is showing refresh pattern - * - U=1.75V +- ~5% TX causes cut out - * - */ - -static const SubGhzBlockConst ws_protocol_gt_wt_03_const = { - .te_short = 285, - .te_long = 570, - .te_delta = 120, - .min_count_bit_for_found = 41, -}; - -struct WSProtocolDecoderGT_WT03 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - - uint16_t header_count; -}; - -struct WSProtocolEncoderGT_WT03 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - GT_WT03DecoderStepReset = 0, - GT_WT03DecoderStepCheckPreambule, - GT_WT03DecoderStepSaveDuration, - GT_WT03DecoderStepCheckDuration, -} GT_WT03DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_gt_wt_03_decoder = { - .alloc = ws_protocol_decoder_gt_wt_03_alloc, - .free = ws_protocol_decoder_gt_wt_03_free, - - .feed = ws_protocol_decoder_gt_wt_03_feed, - .reset = ws_protocol_decoder_gt_wt_03_reset, - - .get_hash_data = ws_protocol_decoder_gt_wt_03_get_hash_data, - .serialize = ws_protocol_decoder_gt_wt_03_serialize, - .deserialize = ws_protocol_decoder_gt_wt_03_deserialize, - .get_string = ws_protocol_decoder_gt_wt_03_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_gt_wt_03_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_gt_wt_03 = { - .name = WS_PROTOCOL_GT_WT_03_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_gt_wt_03_decoder, - .encoder = &ws_protocol_gt_wt_03_encoder, -}; - -void* ws_protocol_decoder_gt_wt_03_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderGT_WT03* instance = malloc(sizeof(WSProtocolDecoderGT_WT03)); - instance->base.protocol = &ws_protocol_gt_wt_03; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_gt_wt_03_free(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - free(instance); -} - -void ws_protocol_decoder_gt_wt_03_reset(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - instance->decoder.parser_step = GT_WT03DecoderStepReset; -} - -static bool ws_protocol_gt_wt_03_check_crc(WSProtocolDecoderGT_WT03* instance) { - uint8_t msg[] = { - instance->decoder.decode_data >> 33, - instance->decoder.decode_data >> 25, - instance->decoder.decode_data >> 17, - instance->decoder.decode_data >> 9}; - - uint8_t sum = 0; - for(unsigned k = 0; k < sizeof(msg); ++k) { - uint8_t data = msg[k]; - uint16_t key = 0x3100; - for(int i = 7; i >= 0; --i) { - // XOR key into sum if data bit is set - if((data >> i) & 1) sum ^= key & 0xff; - // roll the key right - key = (key >> 1); - } - } - return ((sum ^ (uint8_t)((instance->decoder.decode_data >> 1) & 0xFF)) == 0x2D); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_gt_wt_03_remote_controller(WSBlockGeneric* instance) { - instance->id = instance->data >> 33; - instance->humidity = (instance->data >> 25) & 0xFF; - - if(instance->humidity <= 10) { // actually the sensors sends 10 below working range of 20% - instance->humidity = 0; - } else if(instance->humidity > 95) { // actually the sensors sends 110 above working range of 90% - instance->humidity = 100; - } - - instance->battery_low = (instance->data >> 24) & 1; - instance->btn = (instance->data >> 23) & 1; - instance->channel = ((instance->data >> 21) & 0x03) + 1; - - if(!((instance->data >> 20) & 1)) { - instance->temp = (float)((instance->data >> 9) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f; - } -} - -void ws_protocol_decoder_gt_wt_03_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - - switch(instance->decoder.parser_step) { - case GT_WT03DecoderStepReset: - if((level) && (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_short * 3) < - ws_protocol_gt_wt_03_const.te_delta * 2)) { - instance->decoder.parser_step = GT_WT03DecoderStepCheckPreambule; - instance->decoder.te_last = duration; - instance->header_count = 0; - } - break; - - case GT_WT03DecoderStepCheckPreambule: - if(level) { - instance->decoder.te_last = duration; - } else { - if((DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_short * 3) < - ws_protocol_gt_wt_03_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_short * 3) < - ws_protocol_gt_wt_03_const.te_delta * 2)) { - //Found preambule - instance->header_count++; - } else if(instance->header_count == 4) { - if((DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_short) < - ws_protocol_gt_wt_03_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_long) < - ws_protocol_gt_wt_03_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = GT_WT03DecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_long) < - ws_protocol_gt_wt_03_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_short) < - ws_protocol_gt_wt_03_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = GT_WT03DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = GT_WT03DecoderStepReset; - } - } else { - instance->decoder.parser_step = GT_WT03DecoderStepReset; - } - } - break; - - case GT_WT03DecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = GT_WT03DecoderStepCheckDuration; - } else { - instance->decoder.parser_step = GT_WT03DecoderStepReset; - } - break; - - case GT_WT03DecoderStepCheckDuration: - if(!level) { - if(((DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_short * 3) < - ws_protocol_gt_wt_03_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_short * 3) < - ws_protocol_gt_wt_03_const.te_delta * 2))) { - if((instance->decoder.decode_count_bit == - ws_protocol_gt_wt_03_const.min_count_bit_for_found) && - ws_protocol_gt_wt_03_check_crc(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_gt_wt_03_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - instance->header_count = 1; - instance->decoder.parser_step = GT_WT03DecoderStepCheckPreambule; - break; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_short) < - ws_protocol_gt_wt_03_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_long) < - ws_protocol_gt_wt_03_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = GT_WT03DecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_gt_wt_03_const.te_long) < - ws_protocol_gt_wt_03_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_gt_wt_03_const.te_short) < - ws_protocol_gt_wt_03_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = GT_WT03DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = GT_WT03DecoderStepReset; - } - } else { - instance->decoder.parser_step = GT_WT03DecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_gt_wt_03_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_gt_wt_03_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_gt_wt_03_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_gt_wt_03_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderGT_WT03* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/gt_wt_03.h b/applications/plugins/weather_station/protocols/gt_wt_03.h deleted file mode 100644 index fd9536e34..000000000 --- a/applications/plugins/weather_station/protocols/gt_wt_03.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_GT_WT_03_NAME "GT-WT03" - -typedef struct WSProtocolDecoderGT_WT03 WSProtocolDecoderGT_WT03; -typedef struct WSProtocolEncoderGT_WT03 WSProtocolEncoderGT_WT03; - -extern const SubGhzProtocolDecoder ws_protocol_gt_wt_03_decoder; -extern const SubGhzProtocolEncoder ws_protocol_gt_wt_03_encoder; -extern const SubGhzProtocol ws_protocol_gt_wt_03; - -/** - * Allocate WSProtocolDecoderGT_WT03. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderGT_WT03* pointer to a WSProtocolDecoderGT_WT03 instance - */ -void* ws_protocol_decoder_gt_wt_03_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderGT_WT03. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - */ -void ws_protocol_decoder_gt_wt_03_free(void* context); - -/** - * Reset decoder WSProtocolDecoderGT_WT03. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - */ -void ws_protocol_decoder_gt_wt_03_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_gt_wt_03_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_gt_wt_03_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderGT_WT03. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_gt_wt_03_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderGT_WT03. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_gt_wt_03_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderGT_WT03 instance - * @param output Resulting text - */ -void ws_protocol_decoder_gt_wt_03_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/infactory.c b/applications/plugins/weather_station/protocols/infactory.c deleted file mode 100644 index 2d444d981..000000000 --- a/applications/plugins/weather_station/protocols/infactory.c +++ /dev/null @@ -1,296 +0,0 @@ -#include "infactory.h" - -#define TAG "WSProtocolInfactory" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/infactory.c - * - * Analysis using Genuino (see http://gitlab.com/hp-uno, e.g. uno_log_433): - * Observed On-Off-Key (OOK) data pattern: - * preamble syncPrefix data...(40 bit) syncPostfix - * HHLL HHLL HHLL HHLL HLLLLLLLLLLLLLLLL (HLLLL HLLLLLLLL HLLLL HLLLLLLLL ....) HLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL - * Breakdown: - * - four preamble pairs '1'/'0' each with a length of ca. 1000us - * - syncPre, syncPost, data0, data1 have a '1' start pulse of ca. 500us - * - syncPre pulse before dataPtr has a '0' pulse length of ca. 8000us - * - data0 (0-bits) have then a '0' pulse length of ca. 2000us - * - data1 (1-bits) have then a '0' pulse length of ca. 4000us - * - syncPost after dataPtr has a '0' pulse length of ca. 16000us - * This analysis is the reason for the new r_device definitions below. - * NB: pulse_slicer_ppm does not use .gap_limit if .tolerance is set. - * - * Outdoor sensor, transmits temperature and humidity data - * - inFactory NC-3982-913/NX-5817-902, Pearl (for FWS-686 station) - * - nor-tec 73383 (weather station + sensor), Schou Company AS, Denmark - * - DAY 73365 (weather station + sensor), Schou Company AS, Denmark - * Known brand names: inFactory, nor-tec, GreenBlue, DAY. Manufacturer in China. - * Transmissions includes an id. Every 60 seconds the sensor transmits 6 packets: - * 0000 1111 | 0011 0000 | 0101 1100 | 1110 0111 | 0110 0001 - * iiii iiii | cccc ub?? | tttt tttt | tttt hhhh | hhhh ??nn - * - i: identification; changes on battery switch - * - c: CRC-4; CCITT checksum, see below for computation specifics - * - u: unknown; (sometimes set at power-on, but not always) - * - b: battery low; flag to indicate low battery voltage - * - h: Humidity; BCD-encoded, each nibble is one digit, 'A0' means 100%rH - * - t: Temperature; in °F as binary number with one decimal place + 90 °F offset - * - n: Channel; Channel number 1 - 3 - * - */ - -static const SubGhzBlockConst ws_protocol_infactory_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 40, -}; - -struct WSProtocolDecoderInfactory { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - - uint16_t header_count; -}; - -struct WSProtocolEncoderInfactory { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - InfactoryDecoderStepReset = 0, - InfactoryDecoderStepCheckPreambule, - InfactoryDecoderStepSaveDuration, - InfactoryDecoderStepCheckDuration, -} InfactoryDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_infactory_decoder = { - .alloc = ws_protocol_decoder_infactory_alloc, - .free = ws_protocol_decoder_infactory_free, - - .feed = ws_protocol_decoder_infactory_feed, - .reset = ws_protocol_decoder_infactory_reset, - - .get_hash_data = ws_protocol_decoder_infactory_get_hash_data, - .serialize = ws_protocol_decoder_infactory_serialize, - .deserialize = ws_protocol_decoder_infactory_deserialize, - .get_string = ws_protocol_decoder_infactory_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_infactory_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_infactory = { - .name = WS_PROTOCOL_INFACTORY_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_infactory_decoder, - .encoder = &ws_protocol_infactory_encoder, -}; - -void* ws_protocol_decoder_infactory_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderInfactory* instance = malloc(sizeof(WSProtocolDecoderInfactory)); - instance->base.protocol = &ws_protocol_infactory; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_infactory_free(void* context) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - free(instance); -} - -void ws_protocol_decoder_infactory_reset(void* context) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - instance->decoder.parser_step = InfactoryDecoderStepReset; -} - -static bool ws_protocol_infactory_check_crc(WSProtocolDecoderInfactory* instance) { - uint8_t msg[] = { - instance->decoder.decode_data >> 32, - (((instance->decoder.decode_data >> 24) & 0x0F) | (instance->decoder.decode_data & 0x0F) - << 4), - instance->decoder.decode_data >> 16, - instance->decoder.decode_data >> 8, - instance->decoder.decode_data}; - - uint8_t crc = - subghz_protocol_blocks_crc4(msg, 4, 0x13, 0); // Koopmann 0x9, CCITT-4; FP-4; ITU-T G.704 - crc ^= msg[4] >> 4; // last nibble is only XORed - return (crc == ((instance->decoder.decode_data >> 28) & 0x0F)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_infactory_remote_controller(WSBlockGeneric* instance) { - instance->id = instance->data >> 32; - instance->battery_low = (instance->data >> 26) & 1; - instance->btn = WS_NO_BTN; - instance->temp = ws_block_generic_fahrenheit_to_celsius( - ((float)((instance->data >> 12) & 0x0FFF) - 900.0f) / 10.0f); - instance->humidity = - (((instance->data >> 8) & 0x0F) * 10) + ((instance->data >> 4) & 0x0F); // BCD, 'A0'=100%rH - instance->channel = instance->data & 0x03; -} - -void ws_protocol_decoder_infactory_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - - switch(instance->decoder.parser_step) { - case InfactoryDecoderStepReset: - if((level) && (DURATION_DIFF(duration, ws_protocol_infactory_const.te_short * 2) < - ws_protocol_infactory_const.te_delta * 2)) { - instance->decoder.parser_step = InfactoryDecoderStepCheckPreambule; - instance->decoder.te_last = duration; - instance->header_count = 0; - } - break; - - case InfactoryDecoderStepCheckPreambule: - if(level) { - instance->decoder.te_last = duration; - } else { - if((DURATION_DIFF(instance->decoder.te_last, ws_protocol_infactory_const.te_short * 2) < - ws_protocol_infactory_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_infactory_const.te_short * 2) < - ws_protocol_infactory_const.te_delta * 2)) { - //Found preambule - instance->header_count++; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_infactory_const.te_short) < - ws_protocol_infactory_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_infactory_const.te_short * 16) < - ws_protocol_infactory_const.te_delta * 8)) { - //Found syncPrefix - if(instance->header_count > 3) { - instance->decoder.parser_step = InfactoryDecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - } else { - instance->decoder.parser_step = InfactoryDecoderStepReset; - } - } - break; - - case InfactoryDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = InfactoryDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = InfactoryDecoderStepReset; - } - break; - - case InfactoryDecoderStepCheckDuration: - if(!level) { - if(duration >= ((uint32_t)ws_protocol_infactory_const.te_short * 30)) { - //Found syncPostfix - if((instance->decoder.decode_count_bit == - ws_protocol_infactory_const.min_count_bit_for_found) && - ws_protocol_infactory_check_crc(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_infactory_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - instance->decoder.parser_step = InfactoryDecoderStepReset; - break; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_infactory_const.te_short) < - ws_protocol_infactory_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_infactory_const.te_long) < - ws_protocol_infactory_const.te_delta * 2)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = InfactoryDecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_infactory_const.te_short) < - ws_protocol_infactory_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_infactory_const.te_long * 2) < - ws_protocol_infactory_const.te_delta * 4)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = InfactoryDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = InfactoryDecoderStepReset; - } - } else { - instance->decoder.parser_step = InfactoryDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_infactory_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_infactory_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_infactory_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_infactory_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderInfactory* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/infactory.h b/applications/plugins/weather_station/protocols/infactory.h deleted file mode 100644 index 2792ab987..000000000 --- a/applications/plugins/weather_station/protocols/infactory.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_INFACTORY_NAME "inFactory-TH" - -typedef struct WSProtocolDecoderInfactory WSProtocolDecoderInfactory; -typedef struct WSProtocolEncoderInfactory WSProtocolEncoderInfactory; - -extern const SubGhzProtocolDecoder ws_protocol_infactory_decoder; -extern const SubGhzProtocolEncoder ws_protocol_infactory_encoder; -extern const SubGhzProtocol ws_protocol_infactory; - -/** - * Allocate WSProtocolDecoderInfactory. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderInfactory* pointer to a WSProtocolDecoderInfactory instance - */ -void* ws_protocol_decoder_infactory_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderInfactory. - * @param context Pointer to a WSProtocolDecoderInfactory instance - */ -void ws_protocol_decoder_infactory_free(void* context); - -/** - * Reset decoder WSProtocolDecoderInfactory. - * @param context Pointer to a WSProtocolDecoderInfactory instance - */ -void ws_protocol_decoder_infactory_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderInfactory instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_infactory_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderInfactory instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_infactory_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderInfactory. - * @param context Pointer to a WSProtocolDecoderInfactory instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_infactory_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderInfactory. - * @param context Pointer to a WSProtocolDecoderInfactory instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_infactory_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderInfactory instance - * @param output Resulting text - */ -void ws_protocol_decoder_infactory_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c deleted file mode 100644 index e4b612250..000000000 --- a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.c +++ /dev/null @@ -1,297 +0,0 @@ -#include "lacrosse_tx141thbv2.h" - -#define TAG "WSProtocolLaCrosse_TX141THBv2" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/lacrosse_tx141x.c - * - * iiii iiii | bkcc tttt | tttt tttt | hhhh hhhh | cccc cccc | u - * - i: identification; changes on battery switch - * - c: lfsr_digest8_reflect; - * - u: unknown; - * - b: battery low; flag to indicate low battery voltage - * - h: Humidity; - * - t: Temperature; in °F as binary number with one decimal place + 50 °F offset - * - n: Channel; Channel number 1 - 3 - */ - -static const SubGhzBlockConst ws_protocol_lacrosse_tx141thbv2_const = { - .te_short = 250, - .te_long = 500, - .te_delta = 120, - .min_count_bit_for_found = 41, -}; - -struct WSProtocolDecoderLaCrosse_TX141THBv2 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - - uint16_t header_count; -}; - -struct WSProtocolEncoderLaCrosse_TX141THBv2 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - LaCrosse_TX141THBv2DecoderStepReset = 0, - LaCrosse_TX141THBv2DecoderStepCheckPreambule, - LaCrosse_TX141THBv2DecoderStepSaveDuration, - LaCrosse_TX141THBv2DecoderStepCheckDuration, -} LaCrosse_TX141THBv2DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_lacrosse_tx141thbv2_decoder = { - .alloc = ws_protocol_decoder_lacrosse_tx141thbv2_alloc, - .free = ws_protocol_decoder_lacrosse_tx141thbv2_free, - - .feed = ws_protocol_decoder_lacrosse_tx141thbv2_feed, - .reset = ws_protocol_decoder_lacrosse_tx141thbv2_reset, - - .get_hash_data = ws_protocol_decoder_lacrosse_tx141thbv2_get_hash_data, - .serialize = ws_protocol_decoder_lacrosse_tx141thbv2_serialize, - .deserialize = ws_protocol_decoder_lacrosse_tx141thbv2_deserialize, - .get_string = ws_protocol_decoder_lacrosse_tx141thbv2_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_lacrosse_tx141thbv2_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_lacrosse_tx141thbv2 = { - .name = WS_PROTOCOL_LACROSSE_TX141THBV2_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_lacrosse_tx141thbv2_decoder, - .encoder = &ws_protocol_lacrosse_tx141thbv2_encoder, -}; - -void* ws_protocol_decoder_lacrosse_tx141thbv2_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = - malloc(sizeof(WSProtocolDecoderLaCrosse_TX141THBv2)); - instance->base.protocol = &ws_protocol_lacrosse_tx141thbv2; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_lacrosse_tx141thbv2_free(void* context) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - free(instance); -} - -void ws_protocol_decoder_lacrosse_tx141thbv2_reset(void* context) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; -} - -static bool - ws_protocol_lacrosse_tx141thbv2_check_crc(WSProtocolDecoderLaCrosse_TX141THBv2* instance) { - if(!instance->decoder.decode_data) return false; - uint8_t msg[] = { - instance->decoder.decode_data >> 33, - instance->decoder.decode_data >> 25, - instance->decoder.decode_data >> 17, - instance->decoder.decode_data >> 9}; - - uint8_t crc = subghz_protocol_blocks_lfsr_digest8_reflect(msg, 4, 0x31, 0xF4); - return (crc == ((instance->decoder.decode_data >> 1) & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_lacrosse_tx141thbv2_remote_controller(WSBlockGeneric* instance) { - instance->id = instance->data >> 33; - instance->battery_low = (instance->data >> 32) & 1; - instance->btn = (instance->data >> 31) & 1; - instance->channel = ((instance->data >> 29) & 0x03) + 1; - instance->temp = ((float)((instance->data >> 17) & 0x0FFF) - 500.0f) / 10.0f; - instance->humidity = (instance->data >> 9) & 0xFF; -} - -void ws_protocol_decoder_lacrosse_tx141thbv2_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - - switch(instance->decoder.parser_step) { - case LaCrosse_TX141THBv2DecoderStepReset: - if((level) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_short * 3) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta * 2)) { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepCheckPreambule; - instance->decoder.te_last = duration; - instance->header_count = 0; - } - break; - - case LaCrosse_TX141THBv2DecoderStepCheckPreambule: - if(level) { - instance->decoder.te_last = duration; - } else { - if((DURATION_DIFF( - instance->decoder.te_last, - ws_protocol_lacrosse_tx141thbv2_const.te_short * 3) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_short * 3) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta * 2)) { - //Found preambule - instance->header_count++; - } else if(instance->header_count == 4) { - if((DURATION_DIFF( - instance->decoder.te_last, - ws_protocol_lacrosse_tx141thbv2_const.te_short) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_long) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, - ws_protocol_lacrosse_tx141thbv2_const.te_long) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_short) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta)) { - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; - } - } else { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; - } - } - break; - - case LaCrosse_TX141THBv2DecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepCheckDuration; - } else { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; - } - break; - - case LaCrosse_TX141THBv2DecoderStepCheckDuration: - if(!level) { - if(((DURATION_DIFF( - instance->decoder.te_last, - ws_protocol_lacrosse_tx141thbv2_const.te_short * 3) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta * 2) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_short * 3) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta * 2))) { - if((instance->decoder.decode_count_bit == - ws_protocol_lacrosse_tx141thbv2_const.min_count_bit_for_found) && - ws_protocol_lacrosse_tx141thbv2_check_crc(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_lacrosse_tx141thbv2_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - instance->header_count = 1; - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepCheckPreambule; - break; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_lacrosse_tx141thbv2_const.te_short) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_long) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_lacrosse_tx141thbv2_const.te_long) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_lacrosse_tx141thbv2_const.te_short) < - ws_protocol_lacrosse_tx141thbv2_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; - } - } else { - instance->decoder.parser_step = LaCrosse_TX141THBv2DecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_lacrosse_tx141thbv2_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_lacrosse_tx141thbv2_deserialize( - void* context, - FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_lacrosse_tx141thbv2_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_lacrosse_tx141thbv2_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderLaCrosse_TX141THBv2* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.h b/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.h deleted file mode 100644 index 941b01058..000000000 --- a/applications/plugins/weather_station/protocols/lacrosse_tx141thbv2.h +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_LACROSSE_TX141THBV2_NAME "TX141THBv2" - -typedef struct WSProtocolDecoderLaCrosse_TX141THBv2 WSProtocolDecoderLaCrosse_TX141THBv2; -typedef struct WSProtocolEncoderLaCrosse_TX141THBv2 WSProtocolEncoderLaCrosse_TX141THBv2; - -extern const SubGhzProtocolDecoder ws_protocol_lacrosse_tx141thbv2_decoder; -extern const SubGhzProtocolEncoder ws_protocol_lacrosse_tx141thbv2_encoder; -extern const SubGhzProtocol ws_protocol_lacrosse_tx141thbv2; - -/** - * Allocate WSProtocolDecoderLaCrosse_TX141THBv2. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderLaCrosse_TX141THBv2* pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - */ -void* ws_protocol_decoder_lacrosse_tx141thbv2_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderLaCrosse_TX141THBv2. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - */ -void ws_protocol_decoder_lacrosse_tx141thbv2_free(void* context); - -/** - * Reset decoder WSProtocolDecoderLaCrosse_TX141THBv2. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - */ -void ws_protocol_decoder_lacrosse_tx141thbv2_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_lacrosse_tx141thbv2_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_lacrosse_tx141thbv2_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderLaCrosse_TX141THBv2. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_lacrosse_tx141thbv2_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderLaCrosse_TX141THBv2. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_lacrosse_tx141thbv2_deserialize( - void* context, - FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderLaCrosse_TX141THBv2 instance - * @param output Resulting text - */ -void ws_protocol_decoder_lacrosse_tx141thbv2_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/nexus_th.c b/applications/plugins/weather_station/protocols/nexus_th.c deleted file mode 100644 index 38f2fe895..000000000 --- a/applications/plugins/weather_station/protocols/nexus_th.c +++ /dev/null @@ -1,264 +0,0 @@ -#include "nexus_th.h" - -#define TAG "WSProtocolNexus_TH" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/nexus.c - * - * Nexus sensor protocol with ID, temperature and optional humidity - * also FreeTec (Pearl) NC-7345 sensors for FreeTec Weatherstation NC-7344, - * also infactory/FreeTec (Pearl) NX-3980 sensors for infactory/FreeTec NX-3974 station, - * also Solight TE82S sensors for Solight TE76/TE82/TE83/TE84 stations, - * also TFA 30.3209.02 temperature/humidity sensor. - * The sensor sends 36 bits 12 times, - * the packets are ppm modulated (distance coding) with a pulse of ~500 us - * followed by a short gap of ~1000 us for a 0 bit or a long ~2000 us gap for a - * 1 bit, the sync gap is ~4000 us. - * The data is grouped in 9 nibbles: - * [id0] [id1] [flags] [temp0] [temp1] [temp2] [const] [humi0] [humi1] - * - The 8-bit id changes when the battery is changed in the sensor. - * - flags are 4 bits B 0 C C, where B is the battery status: 1=OK, 0=LOW - * - and CC is the channel: 0=CH1, 1=CH2, 2=CH3 - * - temp is 12 bit signed scaled by 10 - * - const is always 1111 (0x0F) - * - humidity is 8 bits - * The sensors can be bought at Clas Ohlsen (Nexus) and Pearl (infactory/FreeTec). - * - */ - -#define NEXUS_TH_CONST_DATA 0b1111 - -static const SubGhzBlockConst ws_protocol_nexus_th_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 36, -}; - -struct WSProtocolDecoderNexus_TH { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderNexus_TH { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - Nexus_THDecoderStepReset = 0, - Nexus_THDecoderStepSaveDuration, - Nexus_THDecoderStepCheckDuration, -} Nexus_THDecoderStep; - -const SubGhzProtocolDecoder ws_protocol_nexus_th_decoder = { - .alloc = ws_protocol_decoder_nexus_th_alloc, - .free = ws_protocol_decoder_nexus_th_free, - - .feed = ws_protocol_decoder_nexus_th_feed, - .reset = ws_protocol_decoder_nexus_th_reset, - - .get_hash_data = ws_protocol_decoder_nexus_th_get_hash_data, - .serialize = ws_protocol_decoder_nexus_th_serialize, - .deserialize = ws_protocol_decoder_nexus_th_deserialize, - .get_string = ws_protocol_decoder_nexus_th_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_nexus_th_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_nexus_th = { - .name = WS_PROTOCOL_NEXUS_TH_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_nexus_th_decoder, - .encoder = &ws_protocol_nexus_th_encoder, -}; - -void* ws_protocol_decoder_nexus_th_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderNexus_TH* instance = malloc(sizeof(WSProtocolDecoderNexus_TH)); - instance->base.protocol = &ws_protocol_nexus_th; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_nexus_th_free(void* context) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - free(instance); -} - -void ws_protocol_decoder_nexus_th_reset(void* context) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - instance->decoder.parser_step = Nexus_THDecoderStepReset; -} - -static bool ws_protocol_nexus_th_check(WSProtocolDecoderNexus_TH* instance) { - uint8_t type = (instance->decoder.decode_data >> 8) & 0x0F; - - if((type == NEXUS_TH_CONST_DATA) && ((instance->decoder.decode_data >> 4) != 0xffffffff)) { - return true; - } else { - return false; - } - return true; -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_nexus_th_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 28) & 0xFF; - instance->battery_low = !((instance->data >> 27) & 1); - instance->channel = ((instance->data >> 24) & 0x03) + 1; - instance->btn = WS_NO_BTN; - if(!((instance->data >> 23) & 1)) { - instance->temp = (float)((instance->data >> 12) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 12) & 0x07FF) + 1) / -10.0f; - } - - instance->humidity = instance->data & 0xFF; - if(instance->humidity > 95) - instance->humidity = 95; - else if(instance->humidity < 20) - instance->humidity = 20; -} - -void ws_protocol_decoder_nexus_th_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - - switch(instance->decoder.parser_step) { - case Nexus_THDecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_nexus_th_const.te_short * 8) < - ws_protocol_nexus_th_const.te_delta * 4)) { - //Found sync - instance->decoder.parser_step = Nexus_THDecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case Nexus_THDecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = Nexus_THDecoderStepCheckDuration; - } else { - instance->decoder.parser_step = Nexus_THDecoderStepReset; - } - break; - - case Nexus_THDecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(duration, ws_protocol_nexus_th_const.te_short * 8) < - ws_protocol_nexus_th_const.te_delta * 4) { - //Found sync - instance->decoder.parser_step = Nexus_THDecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_nexus_th_const.min_count_bit_for_found) && - ws_protocol_nexus_th_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_nexus_th_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - instance->decoder.parser_step = Nexus_THDecoderStepCheckDuration; - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - - break; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_nexus_th_const.te_short) < - ws_protocol_nexus_th_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_nexus_th_const.te_short * 2) < - ws_protocol_nexus_th_const.te_delta * 2)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = Nexus_THDecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_nexus_th_const.te_short) < - ws_protocol_nexus_th_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_nexus_th_const.te_short * 4) < - ws_protocol_nexus_th_const.te_delta * 4)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = Nexus_THDecoderStepSaveDuration; - } else { - instance->decoder.parser_step = Nexus_THDecoderStepReset; - } - } else { - instance->decoder.parser_step = Nexus_THDecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_nexus_th_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_nexus_th_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_nexus_th_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_nexus_th_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderNexus_TH* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/nexus_th.h b/applications/plugins/weather_station/protocols/nexus_th.h deleted file mode 100644 index 5450f0040..000000000 --- a/applications/plugins/weather_station/protocols/nexus_th.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_NEXUS_TH_NAME "Nexus-TH" - -typedef struct WSProtocolDecoderNexus_TH WSProtocolDecoderNexus_TH; -typedef struct WSProtocolEncoderNexus_TH WSProtocolEncoderNexus_TH; - -extern const SubGhzProtocolDecoder ws_protocol_nexus_th_decoder; -extern const SubGhzProtocolEncoder ws_protocol_nexus_th_encoder; -extern const SubGhzProtocol ws_protocol_nexus_th; - -/** - * Allocate WSProtocolDecoderNexus_TH. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderNexus_TH* pointer to a WSProtocolDecoderNexus_TH instance - */ -void* ws_protocol_decoder_nexus_th_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderNexus_TH. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - */ -void ws_protocol_decoder_nexus_th_free(void* context); - -/** - * Reset decoder WSProtocolDecoderNexus_TH. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - */ -void ws_protocol_decoder_nexus_th_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_nexus_th_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_nexus_th_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderNexus_TH. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_nexus_th_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderNexus_TH. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_nexus_th_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderNexus_TH instance - * @param output Resulting text - */ -void ws_protocol_decoder_nexus_th_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/oregon2.c b/applications/plugins/weather_station/protocols/oregon2.c deleted file mode 100644 index 8779e9596..000000000 --- a/applications/plugins/weather_station/protocols/oregon2.c +++ /dev/null @@ -1,423 +0,0 @@ -#include "oregon2.h" - -#include -#include -#include -#include -#include "ws_generic.h" - -#include -#include - -#define TAG "WSProtocolOregon2" - -static const SubGhzBlockConst ws_oregon2_const = { - .te_long = 1000, - .te_short = 500, - .te_delta = 200, - .min_count_bit_for_found = 32, -}; - -#define OREGON2_PREAMBLE_BITS 19 -#define OREGON2_PREAMBLE_MASK 0b1111111111111111111 -#define OREGON2_SENSOR_ID(d) (((d) >> 16) & 0xFFFF) -#define OREGON2_CHECKSUM_BITS 8 - -// 15 ones + 0101 (inverted A) -#define OREGON2_PREAMBLE 0b1111111111111110101 - -// bit indicating the low battery -#define OREGON2_FLAG_BAT_LOW 0x4 - -/// Documentation for Oregon Scientific protocols can be found here: -/// http://wmrx00.sourceforge.net/Arduino/OregonScientific-RF-Protocols.pdf -// Sensors ID -#define ID_THGR122N 0x1d20 -#define ID_THGR968 0x1d30 -#define ID_BTHR918 0x5d50 -#define ID_BHTR968 0x5d60 -#define ID_RGR968 0x2d10 -#define ID_THR228N 0xec40 -#define ID_THN132N 0xec40 // same as THR228N but different packet size -#define ID_RTGN318 0x0cc3 // warning: id is from 0x0cc3 and 0xfcc3 -#define ID_RTGN129 0x0cc3 // same as RTGN318 but different packet size -#define ID_THGR810 0xf824 // This might be ID_THGR81, but what's true is lost in (git) history -#define ID_THGR810a 0xf8b4 // unconfirmed version -#define ID_THN802 0xc844 -#define ID_PCR800 0x2914 -#define ID_PCR800a 0x2d14 // Different PCR800 ID - AU version I think -#define ID_WGR800 0x1984 -#define ID_WGR800a 0x1994 // unconfirmed version -#define ID_WGR968 0x3d00 -#define ID_UV800 0xd874 -#define ID_THN129 0xcc43 // THN129 Temp only -#define ID_RTHN129 0x0cd3 // RTHN129 Temp, clock sensors -#define ID_RTHN129_1 0x9cd3 -#define ID_RTHN129_2 0xacd3 -#define ID_RTHN129_3 0xbcd3 -#define ID_RTHN129_4 0xccd3 -#define ID_RTHN129_5 0xdcd3 -#define ID_BTHGN129 0x5d53 // Baro, Temp, Hygro sensor -#define ID_UVR128 0xec70 -#define ID_THGR328N 0xcc23 // Temp & Hygro sensor similar to THR228N with 5 channel instead of 3 -#define ID_RTGR328N_1 0xdcc3 // RTGR328N_[1-5] RFclock(date &time)&Temp&Hygro sensor -#define ID_RTGR328N_2 0xccc3 -#define ID_RTGR328N_3 0xbcc3 -#define ID_RTGR328N_4 0xacc3 -#define ID_RTGR328N_5 0x9cc3 -#define ID_RTGR328N_6 0x8ce3 // RTGR328N_6&7 RFclock(date &time)&Temp&Hygro sensor like THGR328N -#define ID_RTGR328N_7 0x8ae3 - -struct WSProtocolDecoderOregon2 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - ManchesterState manchester_state; - bool prev_bit; - bool have_bit; - - uint8_t var_bits; - uint32_t var_data; -}; - -typedef struct WSProtocolDecoderOregon2 WSProtocolDecoderOregon2; - -typedef enum { - Oregon2DecoderStepReset = 0, - Oregon2DecoderStepFoundPreamble, - Oregon2DecoderStepVarData, -} Oregon2DecoderStep; - -void* ws_protocol_decoder_oregon2_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderOregon2* instance = malloc(sizeof(WSProtocolDecoderOregon2)); - instance->base.protocol = &ws_protocol_oregon2; - instance->generic.protocol_name = instance->base.protocol->name; - instance->generic.humidity = WS_NO_HUMIDITY; - instance->generic.temp = WS_NO_TEMPERATURE; - instance->generic.btn = WS_NO_BTN; - instance->generic.channel = WS_NO_CHANNEL; - instance->generic.battery_low = WS_NO_BATT; - instance->generic.id = WS_NO_ID; - return instance; -} - -void ws_protocol_decoder_oregon2_free(void* context) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - free(instance); -} - -void ws_protocol_decoder_oregon2_reset(void* context) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - instance->decoder.parser_step = Oregon2DecoderStepReset; - instance->decoder.decode_data = 0UL; - instance->decoder.decode_count_bit = 0; - manchester_advance( - instance->manchester_state, ManchesterEventReset, &instance->manchester_state, NULL); - instance->have_bit = false; - instance->var_data = 0; - instance->var_bits = 0; -} - -static ManchesterEvent level_and_duration_to_event(bool level, uint32_t duration) { - bool is_long = false; - - if(DURATION_DIFF(duration, ws_oregon2_const.te_long) < ws_oregon2_const.te_delta) { - is_long = true; - } else if(DURATION_DIFF(duration, ws_oregon2_const.te_short) < ws_oregon2_const.te_delta) { - is_long = false; - } else { - return ManchesterEventReset; - } - - if(level) - return is_long ? ManchesterEventLongHigh : ManchesterEventShortHigh; - else - return is_long ? ManchesterEventLongLow : ManchesterEventShortLow; -} - -// From sensor id code return amount of bits in variable section -// https://temofeev.ru/info/articles/o-dekodirovanii-protokola-pogodnykh-datchikov-oregon-scientific -static uint8_t oregon2_sensor_id_var_bits(uint16_t sensor_id) { - switch(sensor_id) { - case ID_THR228N: - case ID_RTHN129_1: - case ID_RTHN129_2: - case ID_RTHN129_3: - case ID_RTHN129_4: - case ID_RTHN129_5: - return 16; - case ID_THGR122N: - return 24; - default: - return 0; - } -} - -static void ws_oregon2_decode_const_data(WSBlockGeneric* ws_block) { - ws_block->id = OREGON2_SENSOR_ID(ws_block->data); - - uint8_t ch_bits = (ws_block->data >> 12) & 0xF; - ws_block->channel = 1; - while(ch_bits > 1) { - ws_block->channel++; - ch_bits >>= 1; - } - - ws_block->battery_low = (ws_block->data & OREGON2_FLAG_BAT_LOW) ? 1 : 0; -} - -uint16_t bcd_decode_short(uint32_t data) { - return (data & 0xF) * 10 + ((data >> 4) & 0xF); -} - -static float ws_oregon2_decode_temp(uint32_t data) { - int32_t temp_val; - temp_val = bcd_decode_short(data >> 4); - temp_val *= 10; - temp_val += (data >> 12) & 0xF; - if(data & 0xF) temp_val = -temp_val; - return (float)temp_val / 10.0; -} - -static void ws_oregon2_decode_var_data(WSBlockGeneric* ws_b, uint16_t sensor_id, uint32_t data) { - switch(sensor_id) { - case ID_THR228N: - case ID_RTHN129_1: - case ID_RTHN129_2: - case ID_RTHN129_3: - case ID_RTHN129_4: - case ID_RTHN129_5: - ws_b->temp = ws_oregon2_decode_temp(data); - ws_b->humidity = WS_NO_HUMIDITY; - return; - case ID_THGR122N: - ws_b->humidity = bcd_decode_short(data); - ws_b->temp = ws_oregon2_decode_temp(data >> 8); - return; - default: - break; - } -} - -void ws_protocol_decoder_oregon2_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - // oregon v2.1 signal is inverted - ManchesterEvent event = level_and_duration_to_event(!level, duration); - bool data; - - // low-level bit sequence decoding - if(event == ManchesterEventReset) { - instance->decoder.parser_step = Oregon2DecoderStepReset; - instance->have_bit = false; - instance->decoder.decode_data = 0UL; - instance->decoder.decode_count_bit = 0; - } - if(manchester_advance(instance->manchester_state, event, &instance->manchester_state, &data)) { - if(instance->have_bit) { - if(!instance->prev_bit && data) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - } else if(instance->prev_bit && !data) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - } else { - ws_protocol_decoder_oregon2_reset(context); - } - instance->have_bit = false; - } else { - instance->prev_bit = data; - instance->have_bit = true; - } - } - - switch(instance->decoder.parser_step) { - case Oregon2DecoderStepReset: - // waiting for fixed oregon2 preamble - if(instance->decoder.decode_count_bit >= OREGON2_PREAMBLE_BITS && - ((instance->decoder.decode_data & OREGON2_PREAMBLE_MASK) == OREGON2_PREAMBLE)) { - instance->decoder.parser_step = Oregon2DecoderStepFoundPreamble; - instance->decoder.decode_count_bit = 0; - instance->decoder.decode_data = 0UL; - } - break; - case Oregon2DecoderStepFoundPreamble: - // waiting for fixed oregon2 data - if(instance->decoder.decode_count_bit == 32) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - instance->decoder.decode_data = 0UL; - instance->decoder.decode_count_bit = 0; - - // reverse nibbles in decoded data - instance->generic.data = (instance->generic.data & 0x55555555) << 1 | - (instance->generic.data & 0xAAAAAAAA) >> 1; - instance->generic.data = (instance->generic.data & 0x33333333) << 2 | - (instance->generic.data & 0xCCCCCCCC) >> 2; - - ws_oregon2_decode_const_data(&instance->generic); - instance->var_bits = - oregon2_sensor_id_var_bits(OREGON2_SENSOR_ID(instance->generic.data)); - - if(!instance->var_bits) { - // sensor is not supported, stop decoding, but showing the decoded fixed part - instance->decoder.parser_step = Oregon2DecoderStepReset; - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } else { - instance->decoder.parser_step = Oregon2DecoderStepVarData; - } - } - break; - case Oregon2DecoderStepVarData: - // waiting for variable (sensor-specific data) - if(instance->decoder.decode_count_bit == instance->var_bits + OREGON2_CHECKSUM_BITS) { - instance->var_data = instance->decoder.decode_data & 0xFFFFFFFF; - - // reverse nibbles in var data - instance->var_data = (instance->var_data & 0x55555555) << 1 | - (instance->var_data & 0xAAAAAAAA) >> 1; - instance->var_data = (instance->var_data & 0x33333333) << 2 | - (instance->var_data & 0xCCCCCCCC) >> 2; - - ws_oregon2_decode_var_data( - &instance->generic, - OREGON2_SENSOR_ID(instance->generic.data), - instance->var_data >> OREGON2_CHECKSUM_BITS); - - instance->decoder.parser_step = Oregon2DecoderStepReset; - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - break; - } -} - -uint8_t ws_protocol_decoder_oregon2_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_oregon2_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - if(!ws_block_generic_serialize(&instance->generic, flipper_format, preset)) return false; - uint32_t temp = instance->var_bits; - if(!flipper_format_write_uint32(flipper_format, "VarBits", &temp, 1)) { - FURI_LOG_E(TAG, "Error adding VarBits"); - return false; - } - if(!flipper_format_write_hex( - flipper_format, - "VarData", - (const uint8_t*)&instance->var_data, - sizeof(instance->var_data))) { - FURI_LOG_E(TAG, "Error adding VarData"); - return false; - } - return true; -} - -bool ws_protocol_decoder_oregon2_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - bool ret = false; - uint32_t temp_data; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(!flipper_format_read_uint32(flipper_format, "VarBits", &temp_data, 1)) { - FURI_LOG_E(TAG, "Missing VarLen"); - break; - } - instance->var_bits = (uint8_t)temp_data; - if(!flipper_format_read_hex( - flipper_format, - "VarData", - (uint8_t*)&instance->var_data, - sizeof(instance->var_data))) { - FURI_LOG_E(TAG, "Missing VarData"); - break; - } - if(instance->generic.data_count_bit != ws_oregon2_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key: %d", instance->generic.data_count_bit); - break; - } - ret = true; - } while(false); - return ret; -} - -static void oregon2_append_check_sum(uint32_t fix_data, uint32_t var_data, FuriString* output) { - uint8_t sum = fix_data & 0xF; - uint8_t ref_sum = var_data & 0xFF; - var_data >>= 8; - - for(uint8_t i = 1; i < 8; i++) { - fix_data >>= 4; - var_data >>= 4; - sum += (fix_data & 0xF) + (var_data & 0xF); - } - - // swap calculated sum nibbles - sum = (((sum >> 4) & 0xF) | (sum << 4)) & 0xFF; - if(sum == ref_sum) - furi_string_cat_printf(output, "Sum ok: 0x%hhX", ref_sum); - else - furi_string_cat_printf(output, "Sum err: 0x%hhX vs 0x%hhX", ref_sum, sum); -} - -void ws_protocol_decoder_oregon2_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderOregon2* instance = context; - furi_string_cat_printf( - output, - "%s\r\n" - "ID: 0x%04lX, ch: %d, bat: %d, rc: 0x%02lX\r\n", - instance->generic.protocol_name, - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (uint32_t)(instance->generic.data >> 4) & 0xFF); - - if(instance->var_bits > 0) { - furi_string_cat_printf( - output, - "Temp:%d.%d C Hum:%d%%", - (int16_t)instance->generic.temp, - abs( - ((int16_t)(instance->generic.temp * 10) - - (((int16_t)instance->generic.temp) * 10))), - instance->generic.humidity); - oregon2_append_check_sum((uint32_t)instance->generic.data, instance->var_data, output); - } -} - -const SubGhzProtocolDecoder ws_protocol_oregon2_decoder = { - .alloc = ws_protocol_decoder_oregon2_alloc, - .free = ws_protocol_decoder_oregon2_free, - - .feed = ws_protocol_decoder_oregon2_feed, - .reset = ws_protocol_decoder_oregon2_reset, - - .get_hash_data = ws_protocol_decoder_oregon2_get_hash_data, - .serialize = ws_protocol_decoder_oregon2_serialize, - .deserialize = ws_protocol_decoder_oregon2_deserialize, - .get_string = ws_protocol_decoder_oregon2_get_string, -}; - -const SubGhzProtocol ws_protocol_oregon2 = { - .name = WS_PROTOCOL_OREGON2_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_oregon2_decoder, -}; diff --git a/applications/plugins/weather_station/protocols/oregon2.h b/applications/plugins/weather_station/protocols/oregon2.h deleted file mode 100644 index cfe938e6d..000000000 --- a/applications/plugins/weather_station/protocols/oregon2.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include - -#define WS_PROTOCOL_OREGON2_NAME "Oregon2" -extern const SubGhzProtocol ws_protocol_oregon2; diff --git a/applications/plugins/weather_station/protocols/oregon_v1.c b/applications/plugins/weather_station/protocols/oregon_v1.c deleted file mode 100644 index d1cc4c7a7..000000000 --- a/applications/plugins/weather_station/protocols/oregon_v1.c +++ /dev/null @@ -1,331 +0,0 @@ -#include "oregon_v1.h" -#include - -#define TAG "WSProtocolOregon_V1" - -/* - * Help - * https://github.dev/merbanan/rtl_433/blob/bb1be7f186ac0fdb7dc5d77693847d96fb95281e/src/devices/oregon_scientific_v1.c - * - * OSv1 protocol. - * - * MC with nominal bit width of 2930 us. - * Pulses are somewhat longer than nominal half-bit width, 1748 us / 3216 us, - * Gaps are somewhat shorter than nominal half-bit width, 1176 us / 2640 us. - * After 12 preamble bits there is 4200 us gap, 5780 us pulse, 5200 us gap. - * And next 32 bit data - * - * Care must be taken with the gap after the sync pulse since it - * is outside of the normal clocking. Because of this a data stream - * beginning with a 0 will have data in this gap. - * - * - * Data is in reverse order of bits - * RevBit(data32bit)=> tib23atad - * - * tib23atad => xxxxxxxx | busuTTTT | ttttzzzz | ccuuiiii - * - * - i: ID - * - x: CRC; - * - u: unknown; - * - b: battery low; flag to indicate low battery voltage - * - s: temperature sign - * - T: BCD, Temperature; in C * 10 - * - t: BCD, Temperature; in C * 1 - * - z: BCD, Temperature; in C * 0.1 - * - c: Channel 00=CH1, 01=CH2, 10=CH3 - * - */ - -#define OREGON_V1_HEADER_OK 0xFF - -static const SubGhzBlockConst ws_protocol_oregon_v1_const = { - .te_short = 1465, - .te_long = 2930, - .te_delta = 350, - .min_count_bit_for_found = 32, -}; - -struct WSProtocolDecoderOregon_V1 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - ManchesterState manchester_state; - uint16_t header_count; - uint8_t first_bit; -}; - -struct WSProtocolEncoderOregon_V1 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - Oregon_V1DecoderStepReset = 0, - Oregon_V1DecoderStepFoundPreamble, - Oregon_V1DecoderStepParse, -} Oregon_V1DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_oregon_v1_decoder = { - .alloc = ws_protocol_decoder_oregon_v1_alloc, - .free = ws_protocol_decoder_oregon_v1_free, - - .feed = ws_protocol_decoder_oregon_v1_feed, - .reset = ws_protocol_decoder_oregon_v1_reset, - - .get_hash_data = ws_protocol_decoder_oregon_v1_get_hash_data, - .serialize = ws_protocol_decoder_oregon_v1_serialize, - .deserialize = ws_protocol_decoder_oregon_v1_deserialize, - .get_string = ws_protocol_decoder_oregon_v1_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_oregon_v1_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_oregon_v1 = { - .name = WS_PROTOCOL_OREGON_V1_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_oregon_v1_decoder, - .encoder = &ws_protocol_oregon_v1_encoder, -}; - -void* ws_protocol_decoder_oregon_v1_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderOregon_V1* instance = malloc(sizeof(WSProtocolDecoderOregon_V1)); - instance->base.protocol = &ws_protocol_oregon_v1; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_oregon_v1_free(void* context) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - free(instance); -} - -void ws_protocol_decoder_oregon_v1_reset(void* context) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - instance->decoder.parser_step = Oregon_V1DecoderStepReset; -} - -static bool ws_protocol_oregon_v1_check(WSProtocolDecoderOregon_V1* instance) { - if(!instance->decoder.decode_data) return false; - uint64_t data = subghz_protocol_blocks_reverse_key(instance->decoder.decode_data, 32); - uint16_t crc = (data & 0xff) + ((data >> 8) & 0xff) + ((data >> 16) & 0xff); - crc = (crc & 0xff) + ((crc >> 8) & 0xff); - return (crc == ((data >> 24) & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_oregon_v1_remote_controller(WSBlockGeneric* instance) { - uint64_t data = subghz_protocol_blocks_reverse_key(instance->data, 32); - - instance->id = data & 0xFF; - instance->channel = ((data >> 6) & 0x03) + 1; - - float temp_raw = - ((data >> 8) & 0x0F) * 0.1f + ((data >> 12) & 0x0F) + ((data >> 16) & 0x0F) * 10.0f; - if(!((data >> 21) & 1)) { - instance->temp = temp_raw; - } else { - instance->temp = -temp_raw; - } - - instance->battery_low = !(instance->data >> 23) & 1; - - instance->btn = WS_NO_BTN; - instance->humidity = WS_NO_HUMIDITY; -} - -void ws_protocol_decoder_oregon_v1_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - ManchesterEvent event = ManchesterEventReset; - switch(instance->decoder.parser_step) { - case Oregon_V1DecoderStepReset: - if((level) && (DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta)) { - instance->decoder.parser_step = Oregon_V1DecoderStepFoundPreamble; - instance->decoder.te_last = duration; - instance->header_count = 0; - } - break; - case Oregon_V1DecoderStepFoundPreamble: - if(level) { - //keep high levels, if they suit our durations - if((DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta) || - (DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short * 4) < - ws_protocol_oregon_v1_const.te_delta)) { - instance->decoder.te_last = duration; - } else { - instance->decoder.parser_step = Oregon_V1DecoderStepReset; - } - } else if( - //checking low levels - (DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta) && - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta)) { - // Found header - instance->header_count++; - } else if( - (DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short * 3) < - ws_protocol_oregon_v1_const.te_delta) && - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta)) { - // check header - if(instance->header_count > 7) { - instance->header_count = OREGON_V1_HEADER_OK; - } - } else if( - (instance->header_count == OREGON_V1_HEADER_OK) && - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_oregon_v1_const.te_short * 4) < - ws_protocol_oregon_v1_const.te_delta)) { - //found all the necessary patterns - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 1; - manchester_advance( - instance->manchester_state, - ManchesterEventReset, - &instance->manchester_state, - NULL); - instance->decoder.parser_step = Oregon_V1DecoderStepParse; - if(duration < ws_protocol_oregon_v1_const.te_short * 4) { - instance->first_bit = 1; - } else { - instance->first_bit = 0; - } - } else { - instance->decoder.parser_step = Oregon_V1DecoderStepReset; - } - break; - case Oregon_V1DecoderStepParse: - if(level) { - if(DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta) { - event = ManchesterEventShortHigh; - } else if( - DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_long) < - ws_protocol_oregon_v1_const.te_delta) { - event = ManchesterEventLongHigh; - } else { - instance->decoder.parser_step = Oregon_V1DecoderStepReset; - } - } else { - if(DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_short) < - ws_protocol_oregon_v1_const.te_delta) { - event = ManchesterEventShortLow; - } else if( - DURATION_DIFF(duration, ws_protocol_oregon_v1_const.te_long) < - ws_protocol_oregon_v1_const.te_delta) { - event = ManchesterEventLongLow; - } else if(duration >= ((uint32_t)ws_protocol_oregon_v1_const.te_long * 2)) { - if(instance->decoder.decode_count_bit == - ws_protocol_oregon_v1_const.min_count_bit_for_found) { - if(instance->first_bit) { - instance->decoder.decode_data = ~instance->decoder.decode_data | (1 << 31); - } - if(ws_protocol_oregon_v1_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_oregon_v1_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - manchester_advance( - instance->manchester_state, - ManchesterEventReset, - &instance->manchester_state, - NULL); - } else { - instance->decoder.parser_step = Oregon_V1DecoderStepReset; - } - } - if(event != ManchesterEventReset) { - bool data; - bool data_ok = manchester_advance( - instance->manchester_state, event, &instance->manchester_state, &data); - - if(data_ok) { - instance->decoder.decode_data = (instance->decoder.decode_data << 1) | !data; - instance->decoder.decode_count_bit++; - } - } - - break; - } -} - -uint8_t ws_protocol_decoder_oregon_v1_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_oregon_v1_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_oregon_v1_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_oregon_v1_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderOregon_V1* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/oregon_v1.h b/applications/plugins/weather_station/protocols/oregon_v1.h deleted file mode 100644 index c9aa5af48..000000000 --- a/applications/plugins/weather_station/protocols/oregon_v1.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_OREGON_V1_NAME "Oregon-v1" - -typedef struct WSProtocolDecoderOregon_V1 WSProtocolDecoderOregon_V1; -typedef struct WSProtocolEncoderOregon_V1 WSProtocolEncoderOregon_V1; - -extern const SubGhzProtocolDecoder ws_protocol_oregon_v1_decoder; -extern const SubGhzProtocolEncoder ws_protocol_oregon_v1_encoder; -extern const SubGhzProtocol ws_protocol_oregon_v1; - -/** - * Allocate WSProtocolDecoderOregon_V1. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderOregon_V1* pointer to a WSProtocolDecoderOregon_V1 instance - */ -void* ws_protocol_decoder_oregon_v1_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderOregon_V1. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - */ -void ws_protocol_decoder_oregon_v1_free(void* context); - -/** - * Reset decoder WSProtocolDecoderOregon_V1. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - */ -void ws_protocol_decoder_oregon_v1_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_oregon_v1_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_oregon_v1_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderOregon_V1. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_oregon_v1_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderOregon_V1. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_oregon_v1_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderOregon_V1 instance - * @param output Resulting text - */ -void ws_protocol_decoder_oregon_v1_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/protocol_items.c b/applications/plugins/weather_station/protocols/protocol_items.c deleted file mode 100644 index 99c8344f4..000000000 --- a/applications/plugins/weather_station/protocols/protocol_items.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "protocol_items.h" - -const SubGhzProtocol* weather_station_protocol_registry_items[] = { - &ws_protocol_infactory, - &ws_protocol_thermopro_tx4, - &ws_protocol_nexus_th, - &ws_protocol_gt_wt_02, - &ws_protocol_gt_wt_03, - &ws_protocol_acurite_606tx, - &ws_protocol_acurite_609txc, - &ws_protocol_lacrosse_tx141thbv2, - &ws_protocol_oregon2, - &ws_protocol_acurite_592txr, - &ws_protocol_ambient_weather, - &ws_protocol_auriol_th, - &ws_protocol_oregon_v1, - &ws_protocol_tx_8300, -}; - -const SubGhzProtocolRegistry weather_station_protocol_registry = { - .items = weather_station_protocol_registry_items, - .size = COUNT_OF(weather_station_protocol_registry_items)}; \ No newline at end of file diff --git a/applications/plugins/weather_station/protocols/protocol_items.h b/applications/plugins/weather_station/protocols/protocol_items.h deleted file mode 100644 index 9d5d096f8..000000000 --- a/applications/plugins/weather_station/protocols/protocol_items.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "../weather_station_app_i.h" - -#include "infactory.h" -#include "thermopro_tx4.h" -#include "nexus_th.h" -#include "gt_wt_02.h" -#include "gt_wt_03.h" -#include "acurite_606tx.h" -#include "acurite_609txc.h" -#include "lacrosse_tx141thbv2.h" -#include "oregon2.h" -#include "acurite_592txr.h" -#include "ambient_weather.h" -#include "auriol_hg0601a.h" -#include "oregon_v1.h" -#include "tx_8300.h" - -extern const SubGhzProtocolRegistry weather_station_protocol_registry; diff --git a/applications/plugins/weather_station/protocols/thermopro_tx4.c b/applications/plugins/weather_station/protocols/thermopro_tx4.c deleted file mode 100644 index 0882bc33d..000000000 --- a/applications/plugins/weather_station/protocols/thermopro_tx4.c +++ /dev/null @@ -1,259 +0,0 @@ -#include "thermopro_tx4.h" - -#define TAG "WSProtocolThermoPRO_TX4" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/thermopro_tx2.c - * - * The sensor sends 37 bits 6 times, before the first packet there is a sync pulse. - * The packets are ppm modulated (distance coding) with a pulse of ~500 us - * followed by a short gap of ~2000 us for a 0 bit or a long ~4000 us gap for a - * 1 bit, the sync gap is ~9000 us. - * The data is grouped in 9 nibbles - * [type] [id0] [id1] [flags] [temp0] [temp1] [temp2] [humi0] [humi1] - * - type: 4 bit fixed 1001 (9) or 0110 (5) - * - id: 8 bit a random id that is generated when the sensor starts, could include battery status - * the same batteries often generate the same id - * - flags(3): is 1 when the battery is low, otherwise 0 (ok) - * - flags(2): is 1 when the sensor sends a reading when pressing the button on the sensor - * - flags(1,0): the channel number that can be set by the sensor (1, 2, 3, X) - * - temp: 12 bit signed scaled by 10 - * - humi: 8 bit always 11001100 (0xCC) if no humidity sensor is available - * - */ - -#define THERMO_PRO_TX4_TYPE_1 0b1001 -#define THERMO_PRO_TX4_TYPE_2 0b0110 - -static const SubGhzBlockConst ws_protocol_thermopro_tx4_const = { - .te_short = 500, - .te_long = 2000, - .te_delta = 150, - .min_count_bit_for_found = 37, -}; - -struct WSProtocolDecoderThermoPRO_TX4 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; -}; - -struct WSProtocolEncoderThermoPRO_TX4 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - ThermoPRO_TX4DecoderStepReset = 0, - ThermoPRO_TX4DecoderStepSaveDuration, - ThermoPRO_TX4DecoderStepCheckDuration, -} ThermoPRO_TX4DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_thermopro_tx4_decoder = { - .alloc = ws_protocol_decoder_thermopro_tx4_alloc, - .free = ws_protocol_decoder_thermopro_tx4_free, - - .feed = ws_protocol_decoder_thermopro_tx4_feed, - .reset = ws_protocol_decoder_thermopro_tx4_reset, - - .get_hash_data = ws_protocol_decoder_thermopro_tx4_get_hash_data, - .serialize = ws_protocol_decoder_thermopro_tx4_serialize, - .deserialize = ws_protocol_decoder_thermopro_tx4_deserialize, - .get_string = ws_protocol_decoder_thermopro_tx4_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_thermopro_tx4_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_thermopro_tx4 = { - .name = WS_PROTOCOL_THERMOPRO_TX4_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_thermopro_tx4_decoder, - .encoder = &ws_protocol_thermopro_tx4_encoder, -}; - -void* ws_protocol_decoder_thermopro_tx4_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderThermoPRO_TX4* instance = malloc(sizeof(WSProtocolDecoderThermoPRO_TX4)); - instance->base.protocol = &ws_protocol_thermopro_tx4; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_thermopro_tx4_free(void* context) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - free(instance); -} - -void ws_protocol_decoder_thermopro_tx4_reset(void* context) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepReset; -} - -static bool ws_protocol_thermopro_tx4_check(WSProtocolDecoderThermoPRO_TX4* instance) { - uint8_t type = instance->decoder.decode_data >> 33; - - if((type == THERMO_PRO_TX4_TYPE_1) || (type == THERMO_PRO_TX4_TYPE_2)) { - return true; - } else { - return false; - } -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_thermopro_tx4_remote_controller(WSBlockGeneric* instance) { - instance->id = (instance->data >> 25) & 0xFF; - instance->battery_low = (instance->data >> 24) & 1; - instance->btn = (instance->data >> 23) & 1; - instance->channel = ((instance->data >> 21) & 0x03) + 1; - - if(!((instance->data >> 20) & 1)) { - instance->temp = (float)((instance->data >> 9) & 0x07FF) / 10.0f; - } else { - instance->temp = (float)((~(instance->data >> 9) & 0x07FF) + 1) / -10.0f; - } - - instance->humidity = (instance->data >> 1) & 0xFF; -} - -void ws_protocol_decoder_thermopro_tx4_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - - switch(instance->decoder.parser_step) { - case ThermoPRO_TX4DecoderStepReset: - if((!level) && (DURATION_DIFF(duration, ws_protocol_thermopro_tx4_const.te_short * 18) < - ws_protocol_thermopro_tx4_const.te_delta * 10)) { - //Found sync - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - } - break; - - case ThermoPRO_TX4DecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepCheckDuration; - } else { - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepReset; - } - break; - - case ThermoPRO_TX4DecoderStepCheckDuration: - if(!level) { - if(DURATION_DIFF(duration, ws_protocol_thermopro_tx4_const.te_short * 18) < - ws_protocol_thermopro_tx4_const.te_delta * 10) { - //Found sync - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepReset; - if((instance->decoder.decode_count_bit == - ws_protocol_thermopro_tx4_const.min_count_bit_for_found) && - ws_protocol_thermopro_tx4_check(instance)) { - instance->generic.data = instance->decoder.decode_data; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_thermopro_tx4_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepCheckDuration; - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 0; - - break; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_thermopro_tx4_const.te_short) < - ws_protocol_thermopro_tx4_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_thermopro_tx4_const.te_long) < - ws_protocol_thermopro_tx4_const.te_delta * 2)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepSaveDuration; - } else if( - (DURATION_DIFF( - instance->decoder.te_last, ws_protocol_thermopro_tx4_const.te_short) < - ws_protocol_thermopro_tx4_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_thermopro_tx4_const.te_long * 2) < - ws_protocol_thermopro_tx4_const.te_delta * 4)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepReset; - } - } else { - instance->decoder.parser_step = ThermoPRO_TX4DecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_thermopro_tx4_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_thermopro_tx4_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != - ws_protocol_thermopro_tx4_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_thermopro_tx4_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderThermoPRO_TX4* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/thermopro_tx4.h b/applications/plugins/weather_station/protocols/thermopro_tx4.h deleted file mode 100644 index 1feae58d3..000000000 --- a/applications/plugins/weather_station/protocols/thermopro_tx4.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_THERMOPRO_TX4_NAME "ThermoPRO-TX4" - -typedef struct WSProtocolDecoderThermoPRO_TX4 WSProtocolDecoderThermoPRO_TX4; -typedef struct WSProtocolEncoderThermoPRO_TX4 WSProtocolEncoderThermoPRO_TX4; - -extern const SubGhzProtocolDecoder ws_protocol_thermopro_tx4_decoder; -extern const SubGhzProtocolEncoder ws_protocol_thermopro_tx4_encoder; -extern const SubGhzProtocol ws_protocol_thermopro_tx4; - -/** - * Allocate WSProtocolDecoderThermoPRO_TX4. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderThermoPRO_TX4* pointer to a WSProtocolDecoderThermoPRO_TX4 instance - */ -void* ws_protocol_decoder_thermopro_tx4_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderThermoPRO_TX4. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - */ -void ws_protocol_decoder_thermopro_tx4_free(void* context); - -/** - * Reset decoder WSProtocolDecoderThermoPRO_TX4. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - */ -void ws_protocol_decoder_thermopro_tx4_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_thermopro_tx4_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_thermopro_tx4_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderThermoPRO_TX4. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_thermopro_tx4_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderThermoPRO_TX4. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_thermopro_tx4_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderThermoPRO_TX4 instance - * @param output Resulting text - */ -void ws_protocol_decoder_thermopro_tx4_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/tx_8300.c b/applications/plugins/weather_station/protocols/tx_8300.c deleted file mode 100644 index ee0412ba9..000000000 --- a/applications/plugins/weather_station/protocols/tx_8300.c +++ /dev/null @@ -1,293 +0,0 @@ -#include "tx_8300.h" - -#define TAG "WSProtocolTX_8300" - -/* - * Help - * https://github.com/merbanan/rtl_433/blob/master/src/devices/ambientweather_tx8300.c - * - * Ambient Weather TX-8300 (also sold as TFA 30.3211.02). - * 1970us pulse with variable gap (third pulse 3920 us). - * Above 79% humidity, gap after third pulse is 5848 us. - * - Bit 1 : 1970us pulse with 3888 us gap - * - Bit 0 : 1970us pulse with 1936 us gap - * 74 bit (2 bit preamble and 72 bit data => 9 bytes => 18 nibbles) - * The preamble seems to be a repeat counter (00, and 01 seen), - * the first 4 bytes are data, - * the second 4 bytes the same data inverted, - * the last byte is a checksum. - * Preamble format (2 bits): - * [1 bit (0)] [1 bit rolling count] - * Payload format (32 bits): - * HHHHhhhh ??CCNIII IIIITTTT ttttuuuu - * - H = First BCD digit humidity (the MSB might be distorted by the demod) - * - h = Second BCD digit humidity, invalid humidity seems to be 0x0e - * - ? = Likely battery flag, 2 bits - * - C = Channel, 2 bits - * - N = Negative temperature sign bit - * - I = ID, 7-bit - * - T = First BCD digit temperature - * - t = Second BCD digit temperature - * - u = Third BCD digit temperature - * The Checksum seems to covers the 4 data bytes and is something like Fletcher-8. - **/ - -#define TX_8300_PACKAGE_SIZE 32 - -static const SubGhzBlockConst ws_protocol_tx_8300_const = { - .te_short = 1940, - .te_long = 3880, - .te_delta = 250, - .min_count_bit_for_found = 72, -}; - -struct WSProtocolDecoderTX_8300 { - SubGhzProtocolDecoderBase base; - - SubGhzBlockDecoder decoder; - WSBlockGeneric generic; - uint32_t package_1; - uint32_t package_2; -}; - -struct WSProtocolEncoderTX_8300 { - SubGhzProtocolEncoderBase base; - - SubGhzProtocolBlockEncoder encoder; - WSBlockGeneric generic; -}; - -typedef enum { - TX_8300DecoderStepReset = 0, - TX_8300DecoderStepCheckPreambule, - TX_8300DecoderStepSaveDuration, - TX_8300DecoderStepCheckDuration, -} TX_8300DecoderStep; - -const SubGhzProtocolDecoder ws_protocol_tx_8300_decoder = { - .alloc = ws_protocol_decoder_tx_8300_alloc, - .free = ws_protocol_decoder_tx_8300_free, - - .feed = ws_protocol_decoder_tx_8300_feed, - .reset = ws_protocol_decoder_tx_8300_reset, - - .get_hash_data = ws_protocol_decoder_tx_8300_get_hash_data, - .serialize = ws_protocol_decoder_tx_8300_serialize, - .deserialize = ws_protocol_decoder_tx_8300_deserialize, - .get_string = ws_protocol_decoder_tx_8300_get_string, -}; - -const SubGhzProtocolEncoder ws_protocol_tx_8300_encoder = { - .alloc = NULL, - .free = NULL, - - .deserialize = NULL, - .stop = NULL, - .yield = NULL, -}; - -const SubGhzProtocol ws_protocol_tx_8300 = { - .name = WS_PROTOCOL_TX_8300_NAME, - .type = SubGhzProtocolWeatherStation, - .flag = SubGhzProtocolFlag_433 | SubGhzProtocolFlag_315 | SubGhzProtocolFlag_868 | - SubGhzProtocolFlag_AM | SubGhzProtocolFlag_Decodable, - - .decoder = &ws_protocol_tx_8300_decoder, - .encoder = &ws_protocol_tx_8300_encoder, -}; - -void* ws_protocol_decoder_tx_8300_alloc(SubGhzEnvironment* environment) { - UNUSED(environment); - WSProtocolDecoderTX_8300* instance = malloc(sizeof(WSProtocolDecoderTX_8300)); - instance->base.protocol = &ws_protocol_tx_8300; - instance->generic.protocol_name = instance->base.protocol->name; - return instance; -} - -void ws_protocol_decoder_tx_8300_free(void* context) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - free(instance); -} - -void ws_protocol_decoder_tx_8300_reset(void* context) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - instance->decoder.parser_step = TX_8300DecoderStepReset; -} - -static bool ws_protocol_tx_8300_check_crc(WSProtocolDecoderTX_8300* instance) { - if(!instance->package_2) return false; - if(instance->package_1 != ~instance->package_2) return false; - - uint16_t x = 0; - uint16_t y = 0; - for(int i = 0; i < 32; i += 4) { - x += (instance->package_1 >> i) & 0x0F; - y += (instance->package_1 >> i) & 0x05; - } - uint8_t crc = (~x & 0xF) << 4 | (~y & 0xF); - return (crc == ((instance->decoder.decode_data) & 0xFF)); -} - -/** - * Analysis of received data - * @param instance Pointer to a WSBlockGeneric* instance - */ -static void ws_protocol_tx_8300_remote_controller(WSBlockGeneric* instance) { - instance->humidity = (((instance->data >> 28) & 0x0F) * 10) + ((instance->data >> 24) & 0x0F); - instance->btn = WS_NO_BTN; - if(!((instance->data >> 22) & 0x03)) - instance->battery_low = 0; - else - instance->battery_low = 1; - instance->channel = (instance->data >> 20) & 0x03; - instance->id = (instance->data >> 12) & 0x7F; - - float temp_raw = ((instance->data >> 8) & 0x0F) * 10.0f + ((instance->data >> 4) & 0x0F) + - (instance->data & 0x0F) * 0.1f; - if(!((instance->data >> 19) & 1)) { - instance->temp = temp_raw; - } else { - instance->temp = -temp_raw; - } -} - -void ws_protocol_decoder_tx_8300_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - - switch(instance->decoder.parser_step) { - case TX_8300DecoderStepReset: - if((level) && (DURATION_DIFF(duration, ws_protocol_tx_8300_const.te_short * 2) < - ws_protocol_tx_8300_const.te_delta)) { - instance->decoder.parser_step = TX_8300DecoderStepCheckPreambule; - } - break; - - case TX_8300DecoderStepCheckPreambule: - if((!level) && ((DURATION_DIFF(duration, ws_protocol_tx_8300_const.te_short * 2) < - ws_protocol_tx_8300_const.te_delta) || - (DURATION_DIFF(duration, ws_protocol_tx_8300_const.te_short * 3) < - ws_protocol_tx_8300_const.te_delta))) { - instance->decoder.parser_step = TX_8300DecoderStepSaveDuration; - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 1; - instance->package_1 = 0; - instance->package_2 = 0; - } else { - instance->decoder.parser_step = TX_8300DecoderStepReset; - } - break; - - case TX_8300DecoderStepSaveDuration: - if(level) { - instance->decoder.te_last = duration; - instance->decoder.parser_step = TX_8300DecoderStepCheckDuration; - } else { - instance->decoder.parser_step = TX_8300DecoderStepReset; - } - break; - - case TX_8300DecoderStepCheckDuration: - if(!level) { - if(duration >= ((uint32_t)ws_protocol_tx_8300_const.te_short * 5)) { - //Found syncPostfix - if((instance->decoder.decode_count_bit == - ws_protocol_tx_8300_const.min_count_bit_for_found) && - ws_protocol_tx_8300_check_crc(instance)) { - instance->generic.data = instance->package_1; - instance->generic.data_count_bit = instance->decoder.decode_count_bit; - ws_protocol_tx_8300_remote_controller(&instance->generic); - if(instance->base.callback) - instance->base.callback(&instance->base, instance->base.context); - } - instance->decoder.decode_data = 0; - instance->decoder.decode_count_bit = 1; - instance->decoder.parser_step = TX_8300DecoderStepReset; - break; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_tx_8300_const.te_short) < - ws_protocol_tx_8300_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_tx_8300_const.te_long) < - ws_protocol_tx_8300_const.te_delta * 2)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 1); - instance->decoder.parser_step = TX_8300DecoderStepSaveDuration; - } else if( - (DURATION_DIFF(instance->decoder.te_last, ws_protocol_tx_8300_const.te_short) < - ws_protocol_tx_8300_const.te_delta) && - (DURATION_DIFF(duration, ws_protocol_tx_8300_const.te_short) < - ws_protocol_tx_8300_const.te_delta)) { - subghz_protocol_blocks_add_bit(&instance->decoder, 0); - instance->decoder.parser_step = TX_8300DecoderStepSaveDuration; - } else { - instance->decoder.parser_step = TX_8300DecoderStepReset; - } - - if(instance->decoder.decode_count_bit == TX_8300_PACKAGE_SIZE) { - instance->package_1 = instance->decoder.decode_data; - instance->decoder.decode_data = 0; - } else if(instance->decoder.decode_count_bit == TX_8300_PACKAGE_SIZE * 2) { - instance->package_2 = instance->decoder.decode_data; - instance->decoder.decode_data = 0; - } - - } else { - instance->decoder.parser_step = TX_8300DecoderStepReset; - } - break; - } -} - -uint8_t ws_protocol_decoder_tx_8300_get_hash_data(void* context) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - return subghz_protocol_blocks_get_hash_data( - &instance->decoder, (instance->decoder.decode_count_bit / 8) + 1); -} - -bool ws_protocol_decoder_tx_8300_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - return ws_block_generic_serialize(&instance->generic, flipper_format, preset); -} - -bool ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - bool ret = false; - do { - if(!ws_block_generic_deserialize(&instance->generic, flipper_format)) { - break; - } - if(instance->generic.data_count_bit != ws_protocol_tx_8300_const.min_count_bit_for_found) { - FURI_LOG_E(TAG, "Wrong number of bits in key"); - break; - } - ret = true; - } while(false); - return ret; -} - -void ws_protocol_decoder_tx_8300_get_string(void* context, FuriString* output) { - furi_assert(context); - WSProtocolDecoderTX_8300* instance = context; - furi_string_printf( - output, - "%s %dbit\r\n" - "Key:0x%lX%08lX\r\n" - "Sn:0x%lX Ch:%d Bat:%d\r\n" - "Temp:%3.1f C Hum:%d%%", - instance->generic.protocol_name, - instance->generic.data_count_bit, - (uint32_t)(instance->generic.data >> 32), - (uint32_t)(instance->generic.data), - instance->generic.id, - instance->generic.channel, - instance->generic.battery_low, - (double)instance->generic.temp, - instance->generic.humidity); -} diff --git a/applications/plugins/weather_station/protocols/tx_8300.h b/applications/plugins/weather_station/protocols/tx_8300.h deleted file mode 100644 index ec198e80f..000000000 --- a/applications/plugins/weather_station/protocols/tx_8300.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include "ws_generic.h" -#include - -#define WS_PROTOCOL_TX_8300_NAME "TX8300" - -typedef struct WSProtocolDecoderTX_8300 WSProtocolDecoderTX_8300; -typedef struct WSProtocolEncoderTX_8300 WSProtocolEncoderTX_8300; - -extern const SubGhzProtocolDecoder ws_protocol_tx_8300_decoder; -extern const SubGhzProtocolEncoder ws_protocol_tx_8300_encoder; -extern const SubGhzProtocol ws_protocol_tx_8300; - -/** - * Allocate WSProtocolDecoderTX_8300. - * @param environment Pointer to a SubGhzEnvironment instance - * @return WSProtocolDecoderTX_8300* pointer to a WSProtocolDecoderTX_8300 instance - */ -void* ws_protocol_decoder_tx_8300_alloc(SubGhzEnvironment* environment); - -/** - * Free WSProtocolDecoderTX_8300. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - */ -void ws_protocol_decoder_tx_8300_free(void* context); - -/** - * Reset decoder WSProtocolDecoderTX_8300. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - */ -void ws_protocol_decoder_tx_8300_reset(void* context); - -/** - * Parse a raw sequence of levels and durations received from the air. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - * @param level Signal level true-high false-low - * @param duration Duration of this level in, us - */ -void ws_protocol_decoder_tx_8300_feed(void* context, bool level, uint32_t duration); - -/** - * Getting the hash sum of the last randomly received parcel. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - * @return hash Hash sum - */ -uint8_t ws_protocol_decoder_tx_8300_get_hash_data(void* context); - -/** - * Serialize data WSProtocolDecoderTX_8300. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_protocol_decoder_tx_8300_serialize( - void* context, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSProtocolDecoderTX_8300. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_protocol_decoder_tx_8300_deserialize(void* context, FlipperFormat* flipper_format); - -/** - * Getting a textual representation of the received data. - * @param context Pointer to a WSProtocolDecoderTX_8300 instance - * @param output Resulting text - */ -void ws_protocol_decoder_tx_8300_get_string(void* context, FuriString* output); diff --git a/applications/plugins/weather_station/protocols/ws_generic.c b/applications/plugins/weather_station/protocols/ws_generic.c deleted file mode 100644 index cd5bf6557..000000000 --- a/applications/plugins/weather_station/protocols/ws_generic.c +++ /dev/null @@ -1,215 +0,0 @@ -#include "ws_generic.h" -#include -#include -#include "../helpers/weather_station_types.h" - -#define TAG "WSBlockGeneric" - -void ws_block_generic_get_preset_name(const char* preset_name, FuriString* preset_str) { - const char* preset_name_temp; - if(!strcmp(preset_name, "AM270")) { - preset_name_temp = "FuriHalSubGhzPresetOok270Async"; - } else if(!strcmp(preset_name, "AM650")) { - preset_name_temp = "FuriHalSubGhzPresetOok650Async"; - } else if(!strcmp(preset_name, "FM238")) { - preset_name_temp = "FuriHalSubGhzPreset2FSKDev238Async"; - } else if(!strcmp(preset_name, "FM476")) { - preset_name_temp = "FuriHalSubGhzPreset2FSKDev476Async"; - } else { - preset_name_temp = "FuriHalSubGhzPresetCustom"; - } - furi_string_set(preset_str, preset_name_temp); -} - -bool ws_block_generic_serialize( - WSBlockGeneric* instance, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset) { - furi_assert(instance); - bool res = false; - FuriString* temp_str; - temp_str = furi_string_alloc(); - do { - stream_clean(flipper_format_get_raw_stream(flipper_format)); - if(!flipper_format_write_header_cstr( - flipper_format, WS_KEY_FILE_TYPE, WS_KEY_FILE_VERSION)) { - FURI_LOG_E(TAG, "Unable to add header"); - break; - } - - if(!flipper_format_write_uint32(flipper_format, "Frequency", &preset->frequency, 1)) { - FURI_LOG_E(TAG, "Unable to add Frequency"); - break; - } - - ws_block_generic_get_preset_name(furi_string_get_cstr(preset->name), temp_str); - if(!flipper_format_write_string_cstr( - flipper_format, "Preset", furi_string_get_cstr(temp_str))) { - FURI_LOG_E(TAG, "Unable to add Preset"); - break; - } - if(!strcmp(furi_string_get_cstr(temp_str), "FuriHalSubGhzPresetCustom")) { - if(!flipper_format_write_string_cstr( - flipper_format, "Custom_preset_module", "CC1101")) { - FURI_LOG_E(TAG, "Unable to add Custom_preset_module"); - break; - } - if(!flipper_format_write_hex( - flipper_format, "Custom_preset_data", preset->data, preset->data_size)) { - FURI_LOG_E(TAG, "Unable to add Custom_preset_data"); - break; - } - } - if(!flipper_format_write_string_cstr(flipper_format, "Protocol", instance->protocol_name)) { - FURI_LOG_E(TAG, "Unable to add Protocol"); - break; - } - - uint32_t temp_data = instance->id; - if(!flipper_format_write_uint32(flipper_format, "Id", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Id"); - break; - } - - temp_data = instance->data_count_bit; - if(!flipper_format_write_uint32(flipper_format, "Bit", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Bit"); - break; - } - - uint8_t key_data[sizeof(uint64_t)] = {0}; - for(size_t i = 0; i < sizeof(uint64_t); i++) { - key_data[sizeof(uint64_t) - i - 1] = (instance->data >> i * 8) & 0xFF; - } - - if(!flipper_format_write_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { - FURI_LOG_E(TAG, "Unable to add Data"); - break; - } - - temp_data = instance->battery_low; - if(!flipper_format_write_uint32(flipper_format, "Batt", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Battery_low"); - break; - } - - temp_data = instance->humidity; - if(!flipper_format_write_uint32(flipper_format, "Hum", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Humidity"); - break; - } - - //DATE AGE set - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - uint32_t curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - - temp_data = curr_ts; - if(!flipper_format_write_uint32(flipper_format, "Ts", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add timestamp"); - break; - } - - temp_data = instance->channel; - if(!flipper_format_write_uint32(flipper_format, "Ch", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Channel"); - break; - } - - temp_data = instance->btn; - if(!flipper_format_write_uint32(flipper_format, "Btn", &temp_data, 1)) { - FURI_LOG_E(TAG, "Unable to add Btn"); - break; - } - - float temp = instance->temp; - if(!flipper_format_write_float(flipper_format, "Temp", &temp, 1)) { - FURI_LOG_E(TAG, "Unable to add Temperature"); - break; - } - - res = true; - } while(false); - furi_string_free(temp_str); - return res; -} - -bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format) { - furi_assert(instance); - bool res = false; - uint32_t temp_data = 0; - - do { - if(!flipper_format_rewind(flipper_format)) { - FURI_LOG_E(TAG, "Rewind error"); - break; - } - - if(!flipper_format_read_uint32(flipper_format, "Id", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Id"); - break; - } - instance->id = (uint32_t)temp_data; - - if(!flipper_format_read_uint32(flipper_format, "Bit", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Bit"); - break; - } - instance->data_count_bit = (uint8_t)temp_data; - - uint8_t key_data[sizeof(uint64_t)] = {0}; - if(!flipper_format_read_hex(flipper_format, "Data", key_data, sizeof(uint64_t))) { - FURI_LOG_E(TAG, "Missing Data"); - break; - } - - for(uint8_t i = 0; i < sizeof(uint64_t); i++) { - instance->data = instance->data << 8 | key_data[i]; - } - - if(!flipper_format_read_uint32(flipper_format, "Batt", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Battery_low"); - break; - } - instance->battery_low = (uint8_t)temp_data; - - if(!flipper_format_read_uint32(flipper_format, "Hum", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Humidity"); - break; - } - instance->humidity = (uint8_t)temp_data; - - if(!flipper_format_read_uint32(flipper_format, "Ts", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing timestamp"); - break; - } - instance->timestamp = (uint32_t)temp_data; - - if(!flipper_format_read_uint32(flipper_format, "Ch", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Channel"); - break; - } - instance->channel = (uint8_t)temp_data; - - if(!flipper_format_read_uint32(flipper_format, "Btn", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Btn"); - break; - } - instance->btn = (uint8_t)temp_data; - - float temp; - if(!flipper_format_read_float(flipper_format, "Temp", (float*)&temp, 1)) { - FURI_LOG_E(TAG, "Missing Temperature"); - break; - } - instance->temp = temp; - - res = true; - } while(0); - - return res; -} - -float ws_block_generic_fahrenheit_to_celsius(float fahrenheit) { - return (fahrenheit - 32.0f) / 1.8f; -} \ No newline at end of file diff --git a/applications/plugins/weather_station/protocols/ws_generic.h b/applications/plugins/weather_station/protocols/ws_generic.h deleted file mode 100644 index 657f8a1fc..000000000 --- a/applications/plugins/weather_station/protocols/ws_generic.h +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once - -#include -#include -#include - -#include -#include "furi.h" -#include "furi_hal.h" -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define WS_NO_ID 0xFFFFFFFF -#define WS_NO_BATT 0xFF -#define WS_NO_HUMIDITY 0xFF -#define WS_NO_CHANNEL 0xFF -#define WS_NO_BTN 0xFF -#define WS_NO_TEMPERATURE -273.0f - -typedef struct WSBlockGeneric WSBlockGeneric; - -struct WSBlockGeneric { - const char* protocol_name; - uint64_t data; - uint32_t id; - uint8_t data_count_bit; - uint8_t battery_low; - uint8_t humidity; - uint32_t timestamp; - uint8_t channel; - uint8_t btn; - float temp; -}; - -/** - * Get name preset. - * @param preset_name name preset - * @param preset_str Output name preset - */ -void ws_block_generic_get_preset_name(const char* preset_name, FuriString* preset_str); - -/** - * Serialize data WSBlockGeneric. - * @param instance Pointer to a WSBlockGeneric instance - * @param flipper_format Pointer to a FlipperFormat instance - * @param preset The modulation on which the signal was received, SubGhzRadioPreset - * @return true On success - */ -bool ws_block_generic_serialize( - WSBlockGeneric* instance, - FlipperFormat* flipper_format, - SubGhzRadioPreset* preset); - -/** - * Deserialize data WSBlockGeneric. - * @param instance Pointer to a WSBlockGeneric instance - * @param flipper_format Pointer to a FlipperFormat instance - * @return true On success - */ -bool ws_block_generic_deserialize(WSBlockGeneric* instance, FlipperFormat* flipper_format); - -float ws_block_generic_fahrenheit_to_celsius(float fahrenheit); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/applications/plugins/weather_station/scenes/weather_station_receiver.c b/applications/plugins/weather_station/scenes/weather_station_receiver.c deleted file mode 100644 index 670c8c386..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_receiver.c +++ /dev/null @@ -1,207 +0,0 @@ -#include "../weather_station_app_i.h" -#include "../views/weather_station_receiver.h" - -static const NotificationSequence subghs_sequence_rx = { - &message_green_255, - - &message_vibro_on, - &message_note_c6, - &message_delay_50, - &message_sound_off, - &message_vibro_off, - - &message_delay_50, - NULL, -}; - -static const NotificationSequence subghs_sequence_rx_locked = { - &message_green_255, - - &message_display_backlight_on, - - &message_vibro_on, - &message_note_c6, - &message_delay_50, - &message_sound_off, - &message_vibro_off, - - &message_delay_500, - - &message_display_backlight_off, - NULL, -}; - -static void weather_station_scene_receiver_update_statusbar(void* context) { - WeatherStationApp* app = context; - FuriString* history_stat_str; - history_stat_str = furi_string_alloc(); - if(!ws_history_get_text_space_left(app->txrx->history, history_stat_str)) { - FuriString* frequency_str; - FuriString* modulation_str; - - frequency_str = furi_string_alloc(); - modulation_str = furi_string_alloc(); - - ws_get_frequency_modulation(app, frequency_str, modulation_str); - - ws_view_receiver_add_data_statusbar( - app->ws_receiver, - furi_string_get_cstr(frequency_str), - furi_string_get_cstr(modulation_str), - furi_string_get_cstr(history_stat_str)); - - furi_string_free(frequency_str); - furi_string_free(modulation_str); - } else { - ws_view_receiver_add_data_statusbar( - app->ws_receiver, furi_string_get_cstr(history_stat_str), "", ""); - } - furi_string_free(history_stat_str); -} - -void weather_station_scene_receiver_callback(WSCustomEvent event, void* context) { - furi_assert(context); - WeatherStationApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, event); -} - -static void weather_station_scene_receiver_add_to_history_callback( - SubGhzReceiver* receiver, - SubGhzProtocolDecoderBase* decoder_base, - void* context) { - furi_assert(context); - WeatherStationApp* app = context; - FuriString* str_buff; - str_buff = furi_string_alloc(); - - if(ws_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) == - WSHistoryStateAddKeyNewDada) { - furi_string_reset(str_buff); - - ws_history_get_text_item_menu( - app->txrx->history, str_buff, ws_history_get_item(app->txrx->history) - 1); - ws_view_receiver_add_item_to_menu( - app->ws_receiver, - furi_string_get_cstr(str_buff), - ws_history_get_type_protocol( - app->txrx->history, ws_history_get_item(app->txrx->history) - 1)); - - weather_station_scene_receiver_update_statusbar(app); - notification_message(app->notifications, &sequence_blink_green_10); - if(app->lock != WSLockOn) { - notification_message(app->notifications, &subghs_sequence_rx); - } else { - notification_message(app->notifications, &subghs_sequence_rx_locked); - } - } - subghz_receiver_reset(receiver); - furi_string_free(str_buff); - app->txrx->rx_key_state = WSRxKeyStateAddKey; -} - -void weather_station_scene_receiver_on_enter(void* context) { - WeatherStationApp* app = context; - - FuriString* str_buff; - str_buff = furi_string_alloc(); - - if(app->txrx->rx_key_state == WSRxKeyStateIDLE) { - ws_preset_init(app, "AM650", subghz_setting_get_default_frequency(app->setting), NULL, 0); - ws_history_reset(app->txrx->history); - app->txrx->rx_key_state = WSRxKeyStateStart; - } - - ws_view_receiver_set_lock(app->ws_receiver, app->lock); - - //Load history to receiver - ws_view_receiver_exit(app->ws_receiver); - for(uint8_t i = 0; i < ws_history_get_item(app->txrx->history); i++) { - furi_string_reset(str_buff); - ws_history_get_text_item_menu(app->txrx->history, str_buff, i); - ws_view_receiver_add_item_to_menu( - app->ws_receiver, - furi_string_get_cstr(str_buff), - ws_history_get_type_protocol(app->txrx->history, i)); - app->txrx->rx_key_state = WSRxKeyStateAddKey; - } - furi_string_free(str_buff); - weather_station_scene_receiver_update_statusbar(app); - - ws_view_receiver_set_callback(app->ws_receiver, weather_station_scene_receiver_callback, app); - subghz_receiver_set_rx_callback( - app->txrx->receiver, weather_station_scene_receiver_add_to_history_callback, app); - - if(app->txrx->txrx_state == WSTxRxStateRx) { - ws_rx_end(app); - }; - if((app->txrx->txrx_state == WSTxRxStateIDLE) || (app->txrx->txrx_state == WSTxRxStateSleep)) { - ws_begin( - app, - subghz_setting_get_preset_data_by_name( - app->setting, furi_string_get_cstr(app->txrx->preset->name))); - - ws_rx(app, app->txrx->preset->frequency); - } - - ws_view_receiver_set_idx_menu(app->ws_receiver, app->txrx->idx_menu_chosen); - view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewReceiver); -} - -bool weather_station_scene_receiver_on_event(void* context, SceneManagerEvent event) { - WeatherStationApp* app = context; - bool consumed = false; - if(event.type == SceneManagerEventTypeCustom) { - switch(event.event) { - case WSCustomEventViewReceiverBack: - // Stop CC1101 Rx - if(app->txrx->txrx_state == WSTxRxStateRx) { - ws_rx_end(app); - ws_sleep(app); - }; - app->txrx->hopper_state = WSHopperStateOFF; - app->txrx->idx_menu_chosen = 0; - subghz_receiver_set_rx_callback(app->txrx->receiver, NULL, app); - - app->txrx->rx_key_state = WSRxKeyStateIDLE; - ws_preset_init( - app, "AM650", subghz_setting_get_default_frequency(app->setting), NULL, 0); - scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, WeatherStationSceneStart); - consumed = true; - break; - case WSCustomEventViewReceiverOK: - app->txrx->idx_menu_chosen = ws_view_receiver_get_idx_menu(app->ws_receiver); - scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiverInfo); - consumed = true; - break; - case WSCustomEventViewReceiverConfig: - app->txrx->idx_menu_chosen = ws_view_receiver_get_idx_menu(app->ws_receiver); - scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiverConfig); - consumed = true; - break; - case WSCustomEventViewReceiverOffDisplay: - notification_message(app->notifications, &sequence_display_backlight_off); - consumed = true; - break; - case WSCustomEventViewReceiverUnlock: - app->lock = WSLockOff; - consumed = true; - break; - default: - break; - } - } else if(event.type == SceneManagerEventTypeTick) { - if(app->txrx->hopper_state != WSHopperStateOFF) { - ws_hopper_update(app); - weather_station_scene_receiver_update_statusbar(app); - } - if(app->txrx->txrx_state == WSTxRxStateRx) { - notification_message(app->notifications, &sequence_blink_cyan_10); - } - } - return consumed; -} - -void weather_station_scene_receiver_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/weather_station/scenes/weather_station_scene.c b/applications/plugins/weather_station/scenes/weather_station_scene.c deleted file mode 100644 index f9306e5f4..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "../weather_station_app_i.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const weather_station_scene_on_enter_handlers[])(void*) = { -#include "weather_station_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const weather_station_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "weather_station_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const weather_station_scene_on_exit_handlers[])(void* context) = { -#include "weather_station_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers weather_station_scene_handlers = { - .on_enter_handlers = weather_station_scene_on_enter_handlers, - .on_event_handlers = weather_station_scene_on_event_handlers, - .on_exit_handlers = weather_station_scene_on_exit_handlers, - .scene_num = WeatherStationSceneNum, -}; diff --git a/applications/plugins/weather_station/scenes/weather_station_scene.h b/applications/plugins/weather_station/scenes/weather_station_scene.h deleted file mode 100644 index 8cee4ee60..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) WeatherStationScene##id, -typedef enum { -#include "weather_station_scene_config.h" - WeatherStationSceneNum, -} WeatherStationScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers weather_station_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "weather_station_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "weather_station_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "weather_station_scene_config.h" -#undef ADD_SCENE diff --git a/applications/plugins/weather_station/scenes/weather_station_scene_about.c b/applications/plugins/weather_station/scenes/weather_station_scene_about.c deleted file mode 100644 index d916dc76f..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene_about.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "../weather_station_app_i.h" -#include "../helpers/weather_station_types.h" - -void weather_station_scene_about_widget_callback( - GuiButtonType result, - InputType type, - void* context) { - WeatherStationApp* app = context; - if(type == InputTypeShort) { - view_dispatcher_send_custom_event(app->view_dispatcher, result); - } -} - -void weather_station_scene_about_on_enter(void* context) { - WeatherStationApp* app = context; - - FuriString* temp_str; - temp_str = furi_string_alloc(); - furi_string_printf(temp_str, "\e#%s\n", "Information"); - - furi_string_cat_printf(temp_str, "Version: %s\n", WS_VERSION_APP); - furi_string_cat_printf(temp_str, "Developed by: %s\n", WS_DEVELOPED); - furi_string_cat_printf(temp_str, "Github: %s\n\n", WS_GITHUB); - - furi_string_cat_printf(temp_str, "\e#%s\n", "Description"); - furi_string_cat_printf( - temp_str, "Reading messages from\nweather stations that work\nwith SubGhz sensors\n\n"); - - furi_string_cat_printf(temp_str, "Supported protocols:\n"); - size_t i = 0; - const char* protocol_name = - subghz_environment_get_protocol_name_registry(app->txrx->environment, i++); - do { - furi_string_cat_printf(temp_str, "%s\n", protocol_name); - protocol_name = subghz_environment_get_protocol_name_registry(app->txrx->environment, i++); - } while(protocol_name != NULL); - - widget_add_text_box_element( - app->widget, - 0, - 0, - 128, - 14, - AlignCenter, - AlignBottom, - "\e#\e! \e!\n", - false); - widget_add_text_box_element( - app->widget, - 0, - 2, - 128, - 14, - AlignCenter, - AlignBottom, - "\e#\e! Weather station \e!\n", - false); - widget_add_text_scroll_element(app->widget, 0, 16, 128, 50, furi_string_get_cstr(temp_str)); - furi_string_free(temp_str); - - view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewWidget); -} - -bool weather_station_scene_about_on_event(void* context, SceneManagerEvent event) { - WeatherStationApp* app = context; - bool consumed = false; - UNUSED(app); - UNUSED(event); - - return consumed; -} - -void weather_station_scene_about_on_exit(void* context) { - WeatherStationApp* app = context; - - // Clear views - widget_reset(app->widget); -} diff --git a/applications/plugins/weather_station/scenes/weather_station_scene_config.h b/applications/plugins/weather_station/scenes/weather_station_scene_config.h deleted file mode 100644 index 0ba8ec013..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene_config.h +++ /dev/null @@ -1,5 +0,0 @@ -ADD_SCENE(weather_station, start, Start) -ADD_SCENE(weather_station, about, About) -ADD_SCENE(weather_station, receiver, Receiver) -ADD_SCENE(weather_station, receiver_config, ReceiverConfig) -ADD_SCENE(weather_station, receiver_info, ReceiverInfo) diff --git a/applications/plugins/weather_station/scenes/weather_station_scene_receiver_config.c b/applications/plugins/weather_station/scenes/weather_station_scene_receiver_config.c deleted file mode 100644 index fcd8f6d3e..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene_receiver_config.c +++ /dev/null @@ -1,223 +0,0 @@ -#include "../weather_station_app_i.h" - -enum WSSettingIndex { - WSSettingIndexFrequency, - WSSettingIndexHopping, - WSSettingIndexModulation, - WSSettingIndexLock, -}; - -#define HOPPING_COUNT 2 -const char* const hopping_text[HOPPING_COUNT] = { - "OFF", - "ON", -}; -const uint32_t hopping_value[HOPPING_COUNT] = { - WSHopperStateOFF, - WSHopperStateRunnig, -}; - -uint8_t weather_station_scene_receiver_config_next_frequency(const uint32_t value, void* context) { - furi_assert(context); - WeatherStationApp* app = context; - uint8_t index = 0; - for(uint8_t i = 0; i < subghz_setting_get_frequency_count(app->setting); i++) { - if(value == subghz_setting_get_frequency(app->setting, i)) { - index = i; - break; - } else { - index = subghz_setting_get_frequency_default_index(app->setting); - } - } - return index; -} - -uint8_t weather_station_scene_receiver_config_next_preset(const char* preset_name, void* context) { - furi_assert(context); - WeatherStationApp* app = context; - uint8_t index = 0; - for(uint8_t i = 0; i < subghz_setting_get_preset_count(app->setting); i++) { - if(!strcmp(subghz_setting_get_preset_name(app->setting, i), preset_name)) { - index = i; - break; - } else { - // index = subghz_setting_get_frequency_default_index(app ->setting); - } - } - return index; -} - -uint8_t weather_station_scene_receiver_config_hopper_value_index( - const uint32_t value, - const uint32_t values[], - uint8_t values_count, - void* context) { - furi_assert(context); - UNUSED(values_count); - WeatherStationApp* app = context; - - if(value == values[0]) { - return 0; - } else { - variable_item_set_current_value_text( - (VariableItem*)scene_manager_get_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig), - " -----"); - return 1; - } -} - -static void weather_station_scene_receiver_config_set_frequency(VariableItem* item) { - WeatherStationApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - if(app->txrx->hopper_state == WSHopperStateOFF) { - char text_buf[10] = {0}; - snprintf( - text_buf, - sizeof(text_buf), - "%lu.%02lu", - subghz_setting_get_frequency(app->setting, index) / 1000000, - (subghz_setting_get_frequency(app->setting, index) % 1000000) / 10000); - variable_item_set_current_value_text(item, text_buf); - app->txrx->preset->frequency = subghz_setting_get_frequency(app->setting, index); - } else { - variable_item_set_current_value_index( - item, subghz_setting_get_frequency_default_index(app->setting)); - } -} - -static void weather_station_scene_receiver_config_set_preset(VariableItem* item) { - WeatherStationApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - variable_item_set_current_value_text( - item, subghz_setting_get_preset_name(app->setting, index)); - ws_preset_init( - app, - subghz_setting_get_preset_name(app->setting, index), - app->txrx->preset->frequency, - subghz_setting_get_preset_data(app->setting, index), - subghz_setting_get_preset_data_size(app->setting, index)); -} - -static void weather_station_scene_receiver_config_set_hopping_running(VariableItem* item) { - WeatherStationApp* app = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); - - variable_item_set_current_value_text(item, hopping_text[index]); - if(hopping_value[index] == WSHopperStateOFF) { - char text_buf[10] = {0}; - snprintf( - text_buf, - sizeof(text_buf), - "%lu.%02lu", - subghz_setting_get_default_frequency(app->setting) / 1000000, - (subghz_setting_get_default_frequency(app->setting) % 1000000) / 10000); - variable_item_set_current_value_text( - (VariableItem*)scene_manager_get_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig), - text_buf); - app->txrx->preset->frequency = subghz_setting_get_default_frequency(app->setting); - variable_item_set_current_value_index( - (VariableItem*)scene_manager_get_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig), - subghz_setting_get_frequency_default_index(app->setting)); - } else { - variable_item_set_current_value_text( - (VariableItem*)scene_manager_get_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig), - " -----"); - variable_item_set_current_value_index( - (VariableItem*)scene_manager_get_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig), - subghz_setting_get_frequency_default_index(app->setting)); - } - - app->txrx->hopper_state = hopping_value[index]; -} - -static void - weather_station_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) { - furi_assert(context); - WeatherStationApp* app = context; - if(index == WSSettingIndexLock) { - view_dispatcher_send_custom_event(app->view_dispatcher, WSCustomEventSceneSettingLock); - } -} - -void weather_station_scene_receiver_config_on_enter(void* context) { - WeatherStationApp* app = context; - VariableItem* item; - uint8_t value_index; - - item = variable_item_list_add( - app->variable_item_list, - "Frequency:", - subghz_setting_get_frequency_count(app->setting), - weather_station_scene_receiver_config_set_frequency, - app); - value_index = - weather_station_scene_receiver_config_next_frequency(app->txrx->preset->frequency, app); - scene_manager_set_scene_state( - app->scene_manager, WeatherStationSceneReceiverConfig, (uint32_t)item); - variable_item_set_current_value_index(item, value_index); - char text_buf[10] = {0}; - snprintf( - text_buf, - sizeof(text_buf), - "%lu.%02lu", - subghz_setting_get_frequency(app->setting, value_index) / 1000000, - (subghz_setting_get_frequency(app->setting, value_index) % 1000000) / 10000); - variable_item_set_current_value_text(item, text_buf); - - item = variable_item_list_add( - app->variable_item_list, - "Hopping:", - HOPPING_COUNT, - weather_station_scene_receiver_config_set_hopping_running, - app); - value_index = weather_station_scene_receiver_config_hopper_value_index( - app->txrx->hopper_state, hopping_value, HOPPING_COUNT, app); - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text(item, hopping_text[value_index]); - - item = variable_item_list_add( - app->variable_item_list, - "Modulation:", - subghz_setting_get_preset_count(app->setting), - weather_station_scene_receiver_config_set_preset, - app); - value_index = weather_station_scene_receiver_config_next_preset( - furi_string_get_cstr(app->txrx->preset->name), app); - variable_item_set_current_value_index(item, value_index); - variable_item_set_current_value_text( - item, subghz_setting_get_preset_name(app->setting, value_index)); - - variable_item_list_add(app->variable_item_list, "Lock Keyboard", 1, NULL, NULL); - variable_item_list_set_enter_callback( - app->variable_item_list, - weather_station_scene_receiver_config_var_list_enter_callback, - app); - - view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewVariableItemList); -} - -bool weather_station_scene_receiver_config_on_event(void* context, SceneManagerEvent event) { - WeatherStationApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == WSCustomEventSceneSettingLock) { - app->lock = WSLockOn; - scene_manager_previous_scene(app->scene_manager); - consumed = true; - } - } - return consumed; -} - -void weather_station_scene_receiver_config_on_exit(void* context) { - WeatherStationApp* app = context; - variable_item_list_set_selected_item(app->variable_item_list, 0); - variable_item_list_reset(app->variable_item_list); -} diff --git a/applications/plugins/weather_station/scenes/weather_station_scene_receiver_info.c b/applications/plugins/weather_station/scenes/weather_station_scene_receiver_info.c deleted file mode 100644 index b26661be3..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene_receiver_info.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "../weather_station_app_i.h" -#include "../views/weather_station_receiver.h" - -void weather_station_scene_receiver_info_callback(WSCustomEvent event, void* context) { - furi_assert(context); - WeatherStationApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, event); -} - -static void weather_station_scene_receiver_info_add_to_history_callback( - SubGhzReceiver* receiver, - SubGhzProtocolDecoderBase* decoder_base, - void* context) { - furi_assert(context); - WeatherStationApp* app = context; - - if(ws_history_add_to_history(app->txrx->history, decoder_base, app->txrx->preset) == - WSHistoryStateAddKeyUpdateData) { - ws_view_receiver_info_update( - app->ws_receiver_info, - ws_history_get_raw_data(app->txrx->history, app->txrx->idx_menu_chosen)); - subghz_receiver_reset(receiver); - - notification_message(app->notifications, &sequence_blink_green_10); - app->txrx->rx_key_state = WSRxKeyStateAddKey; - } -} - -void weather_station_scene_receiver_info_on_enter(void* context) { - WeatherStationApp* app = context; - - subghz_receiver_set_rx_callback( - app->txrx->receiver, weather_station_scene_receiver_info_add_to_history_callback, app); - ws_view_receiver_info_update( - app->ws_receiver_info, - ws_history_get_raw_data(app->txrx->history, app->txrx->idx_menu_chosen)); - view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewReceiverInfo); -} - -bool weather_station_scene_receiver_info_on_event(void* context, SceneManagerEvent event) { - WeatherStationApp* app = context; - bool consumed = false; - UNUSED(app); - UNUSED(event); - return consumed; -} - -void weather_station_scene_receiver_info_on_exit(void* context) { - UNUSED(context); -} diff --git a/applications/plugins/weather_station/scenes/weather_station_scene_start.c b/applications/plugins/weather_station/scenes/weather_station_scene_start.c deleted file mode 100644 index 56dd6fa86..000000000 --- a/applications/plugins/weather_station/scenes/weather_station_scene_start.c +++ /dev/null @@ -1,58 +0,0 @@ -#include "../weather_station_app_i.h" - -typedef enum { - SubmenuIndexWeatherStationReceiver, - SubmenuIndexWeatherStationAbout, -} SubmenuIndex; - -void weather_station_scene_start_submenu_callback(void* context, uint32_t index) { - WeatherStationApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, index); -} - -void weather_station_scene_start_on_enter(void* context) { - UNUSED(context); - WeatherStationApp* app = context; - Submenu* submenu = app->submenu; - - submenu_add_item( - submenu, - "Read Weather Station", - SubmenuIndexWeatherStationReceiver, - weather_station_scene_start_submenu_callback, - app); - submenu_add_item( - submenu, - "About", - SubmenuIndexWeatherStationAbout, - weather_station_scene_start_submenu_callback, - app); - - submenu_set_selected_item( - submenu, scene_manager_get_scene_state(app->scene_manager, WeatherStationSceneStart)); - - view_dispatcher_switch_to_view(app->view_dispatcher, WeatherStationViewSubmenu); -} - -bool weather_station_scene_start_on_event(void* context, SceneManagerEvent event) { - WeatherStationApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexWeatherStationAbout) { - scene_manager_next_scene(app->scene_manager, WeatherStationSceneAbout); - consumed = true; - } else if(event.event == SubmenuIndexWeatherStationReceiver) { - scene_manager_next_scene(app->scene_manager, WeatherStationSceneReceiver); - consumed = true; - } - scene_manager_set_scene_state(app->scene_manager, WeatherStationSceneStart, event.event); - } - - return consumed; -} - -void weather_station_scene_start_on_exit(void* context) { - WeatherStationApp* app = context; - submenu_reset(app->submenu); -} diff --git a/applications/plugins/weather_station/views/weather_station_receiver.c b/applications/plugins/weather_station/views/weather_station_receiver.c deleted file mode 100644 index 654fb5a3b..000000000 --- a/applications/plugins/weather_station/views/weather_station_receiver.c +++ /dev/null @@ -1,436 +0,0 @@ -#include "weather_station_receiver.h" -#include "../weather_station_app_i.h" -#include -#include - -#include -#include -#include - -#define FRAME_HEIGHT 12 -#define MAX_LEN_PX 112 -#define MENU_ITEMS 4u -#define UNLOCK_CNT 3 - -typedef struct { - FuriString* item_str; - uint8_t type; -} WSReceiverMenuItem; - -ARRAY_DEF(WSReceiverMenuItemArray, WSReceiverMenuItem, M_POD_OPLIST) - -#define M_OPL_WSReceiverMenuItemArray_t() ARRAY_OPLIST(WSReceiverMenuItemArray, M_POD_OPLIST) - -struct WSReceiverHistory { - WSReceiverMenuItemArray_t data; -}; - -typedef struct WSReceiverHistory WSReceiverHistory; - -static const Icon* ReceiverItemIcons[] = { - [SubGhzProtocolTypeUnknown] = &I_Quest_7x8, - [SubGhzProtocolTypeStatic] = &I_Unlock_7x8, - [SubGhzProtocolTypeDynamic] = &I_Lock_7x8, - [SubGhzProtocolWeatherStation] = &I_station_icon, -}; - -typedef enum { - WSReceiverBarShowDefault, - WSReceiverBarShowLock, - WSReceiverBarShowToUnlockPress, - WSReceiverBarShowUnlock, -} WSReceiverBarShow; - -struct WSReceiver { - WSLock lock; - uint8_t lock_count; - FuriTimer* timer; - View* view; - WSReceiverCallback callback; - void* context; -}; - -typedef struct { - FuriString* frequency_str; - FuriString* preset_str; - FuriString* history_stat_str; - WSReceiverHistory* history; - uint16_t idx; - uint16_t list_offset; - uint16_t history_item; - WSReceiverBarShow bar_show; -} WSReceiverModel; - -void ws_view_receiver_set_lock(WSReceiver* ws_receiver, WSLock lock) { - furi_assert(ws_receiver); - ws_receiver->lock_count = 0; - if(lock == WSLockOn) { - ws_receiver->lock = lock; - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { model->bar_show = WSReceiverBarShowLock; }, - true); - furi_timer_start(ws_receiver->timer, pdMS_TO_TICKS(1000)); - } else { - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { model->bar_show = WSReceiverBarShowDefault; }, - true); - } -} - -void ws_view_receiver_set_callback( - WSReceiver* ws_receiver, - WSReceiverCallback callback, - void* context) { - furi_assert(ws_receiver); - furi_assert(callback); - ws_receiver->callback = callback; - ws_receiver->context = context; -} - -static void ws_view_receiver_update_offset(WSReceiver* ws_receiver) { - furi_assert(ws_receiver); - - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - size_t history_item = model->history_item; - uint16_t bounds = history_item > 3 ? 2 : history_item; - - if(history_item > 3 && model->idx >= (int16_t)(history_item - 1)) { - model->list_offset = model->idx - 3; - } else if(model->list_offset < model->idx - bounds) { - model->list_offset = - CLAMP(model->list_offset + 1, (int16_t)(history_item - bounds), 0); - } else if(model->list_offset > model->idx - bounds) { - model->list_offset = CLAMP(model->idx - 1, (int16_t)(history_item - bounds), 0); - } - }, - true); -} - -void ws_view_receiver_add_item_to_menu(WSReceiver* ws_receiver, const char* name, uint8_t type) { - furi_assert(ws_receiver); - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - WSReceiverMenuItem* item_menu = WSReceiverMenuItemArray_push_raw(model->history->data); - item_menu->item_str = furi_string_alloc_set(name); - item_menu->type = type; - if((model->idx == model->history_item - 1)) { - model->history_item++; - model->idx++; - } else { - model->history_item++; - } - }, - true); - ws_view_receiver_update_offset(ws_receiver); -} - -void ws_view_receiver_add_data_statusbar( - WSReceiver* ws_receiver, - const char* frequency_str, - const char* preset_str, - const char* history_stat_str) { - furi_assert(ws_receiver); - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - furi_string_set_str(model->frequency_str, frequency_str); - furi_string_set_str(model->preset_str, preset_str); - furi_string_set_str(model->history_stat_str, history_stat_str); - }, - true); -} - -static void ws_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 0, 0 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT); - - canvas_set_color(canvas, ColorWhite); - canvas_draw_dot(canvas, 0, 0 + idx * FRAME_HEIGHT); - canvas_draw_dot(canvas, 1, 0 + idx * FRAME_HEIGHT); - canvas_draw_dot(canvas, 0, (0 + idx * FRAME_HEIGHT) + 1); - - canvas_draw_dot(canvas, 0, (0 + idx * FRAME_HEIGHT) + 11); - canvas_draw_dot(canvas, scrollbar ? 121 : 126, 0 + idx * FRAME_HEIGHT); - canvas_draw_dot(canvas, scrollbar ? 121 : 126, (0 + idx * FRAME_HEIGHT) + 11); -} - -void ws_view_receiver_draw(Canvas* canvas, WSReceiverModel* model) { - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - - elements_button_left(canvas, "Config"); - canvas_draw_line(canvas, 46, 51, 125, 51); - - bool scrollbar = model->history_item > 4; - FuriString* str_buff; - str_buff = furi_string_alloc(); - - WSReceiverMenuItem* item_menu; - - for(size_t i = 0; i < MIN(model->history_item, MENU_ITEMS); ++i) { - size_t idx = CLAMP((uint16_t)(i + model->list_offset), model->history_item, 0); - item_menu = WSReceiverMenuItemArray_get(model->history->data, idx); - furi_string_set(str_buff, item_menu->item_str); - elements_string_fit_width(canvas, str_buff, scrollbar ? MAX_LEN_PX - 6 : MAX_LEN_PX); - if(model->idx == idx) { - ws_view_receiver_draw_frame(canvas, i, scrollbar); - } else { - canvas_set_color(canvas, ColorBlack); - } - canvas_draw_icon(canvas, 4, 2 + i * FRAME_HEIGHT, ReceiverItemIcons[item_menu->type]); - canvas_draw_str(canvas, 14, 9 + i * FRAME_HEIGHT, furi_string_get_cstr(str_buff)); - furi_string_reset(str_buff); - } - if(scrollbar) { - elements_scrollbar_pos(canvas, 128, 0, 49, model->idx, model->history_item); - } - furi_string_free(str_buff); - - canvas_set_color(canvas, ColorBlack); - - if(model->history_item == 0) { - canvas_draw_icon(canvas, 0, 0, &I_Scanning_123x52); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 63, 46, "Scanning..."); - canvas_draw_line(canvas, 46, 51, 125, 51); - canvas_set_font(canvas, FontSecondary); - } - - switch(model->bar_show) { - case WSReceiverBarShowLock: - canvas_draw_icon(canvas, 64, 55, &I_Lock_7x8); - canvas_draw_str(canvas, 74, 62, "Locked"); - break; - case WSReceiverBarShowToUnlockPress: - canvas_draw_str(canvas, 44, 62, furi_string_get_cstr(model->frequency_str)); - canvas_draw_str(canvas, 79, 62, furi_string_get_cstr(model->preset_str)); - canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str)); - canvas_set_font(canvas, FontSecondary); - elements_bold_rounded_frame(canvas, 14, 8, 99, 48); - elements_multiline_text(canvas, 65, 26, "To unlock\npress:"); - canvas_draw_icon(canvas, 65, 42, &I_Pin_back_arrow_10x8); - canvas_draw_icon(canvas, 80, 42, &I_Pin_back_arrow_10x8); - canvas_draw_icon(canvas, 95, 42, &I_Pin_back_arrow_10x8); - canvas_draw_icon(canvas, 16, 13, &I_WarningDolphin_45x42); - canvas_draw_dot(canvas, 17, 61); - break; - case WSReceiverBarShowUnlock: - canvas_draw_icon(canvas, 64, 55, &I_Unlock_7x8); - canvas_draw_str(canvas, 74, 62, "Unlocked"); - break; - default: - canvas_draw_str(canvas, 44, 62, furi_string_get_cstr(model->frequency_str)); - canvas_draw_str(canvas, 79, 62, furi_string_get_cstr(model->preset_str)); - canvas_draw_str(canvas, 96, 62, furi_string_get_cstr(model->history_stat_str)); - break; - } -} - -static void ws_view_receiver_timer_callback(void* context) { - furi_assert(context); - WSReceiver* ws_receiver = context; - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { model->bar_show = WSReceiverBarShowDefault; }, - true); - if(ws_receiver->lock_count < UNLOCK_CNT) { - ws_receiver->callback(WSCustomEventViewReceiverOffDisplay, ws_receiver->context); - } else { - ws_receiver->lock = WSLockOff; - ws_receiver->callback(WSCustomEventViewReceiverUnlock, ws_receiver->context); - } - ws_receiver->lock_count = 0; -} - -bool ws_view_receiver_input(InputEvent* event, void* context) { - furi_assert(context); - WSReceiver* ws_receiver = context; - - if(ws_receiver->lock == WSLockOn) { - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { model->bar_show = WSReceiverBarShowToUnlockPress; }, - true); - if(ws_receiver->lock_count == 0) { - furi_timer_start(ws_receiver->timer, pdMS_TO_TICKS(1000)); - } - if(event->key == InputKeyBack && event->type == InputTypeShort) { - ws_receiver->lock_count++; - } - if(ws_receiver->lock_count >= UNLOCK_CNT) { - ws_receiver->callback(WSCustomEventViewReceiverUnlock, ws_receiver->context); - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { model->bar_show = WSReceiverBarShowUnlock; }, - true); - ws_receiver->lock = WSLockOff; - furi_timer_start(ws_receiver->timer, pdMS_TO_TICKS(650)); - } - - return true; - } - - if(event->key == InputKeyBack && event->type == InputTypeShort) { - ws_receiver->callback(WSCustomEventViewReceiverBack, ws_receiver->context); - } else if( - event->key == InputKeyUp && - (event->type == InputTypeShort || event->type == InputTypeRepeat)) { - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - if(model->idx != 0) model->idx--; - }, - true); - } else if( - event->key == InputKeyDown && - (event->type == InputTypeShort || event->type == InputTypeRepeat)) { - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - if(model->idx != model->history_item - 1) model->idx++; - }, - true); - } else if(event->key == InputKeyLeft && event->type == InputTypeShort) { - ws_receiver->callback(WSCustomEventViewReceiverConfig, ws_receiver->context); - } else if(event->key == InputKeyOk && event->type == InputTypeShort) { - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - if(model->history_item != 0) { - ws_receiver->callback(WSCustomEventViewReceiverOK, ws_receiver->context); - } - }, - false); - } - - ws_view_receiver_update_offset(ws_receiver); - - return true; -} - -void ws_view_receiver_enter(void* context) { - furi_assert(context); -} - -void ws_view_receiver_exit(void* context) { - furi_assert(context); - WSReceiver* ws_receiver = context; - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - furi_string_reset(model->frequency_str); - furi_string_reset(model->preset_str); - furi_string_reset(model->history_stat_str); - for - M_EACH(item_menu, model->history->data, WSReceiverMenuItemArray_t) { - furi_string_free(item_menu->item_str); - item_menu->type = 0; - } - WSReceiverMenuItemArray_reset(model->history->data); - model->idx = 0; - model->list_offset = 0; - model->history_item = 0; - }, - false); - furi_timer_stop(ws_receiver->timer); -} - -WSReceiver* ws_view_receiver_alloc() { - WSReceiver* ws_receiver = malloc(sizeof(WSReceiver)); - - // View allocation and configuration - ws_receiver->view = view_alloc(); - - ws_receiver->lock = WSLockOff; - ws_receiver->lock_count = 0; - view_allocate_model(ws_receiver->view, ViewModelTypeLocking, sizeof(WSReceiverModel)); - view_set_context(ws_receiver->view, ws_receiver); - view_set_draw_callback(ws_receiver->view, (ViewDrawCallback)ws_view_receiver_draw); - view_set_input_callback(ws_receiver->view, ws_view_receiver_input); - view_set_enter_callback(ws_receiver->view, ws_view_receiver_enter); - view_set_exit_callback(ws_receiver->view, ws_view_receiver_exit); - - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - model->frequency_str = furi_string_alloc(); - model->preset_str = furi_string_alloc(); - model->history_stat_str = furi_string_alloc(); - model->bar_show = WSReceiverBarShowDefault; - model->history = malloc(sizeof(WSReceiverHistory)); - WSReceiverMenuItemArray_init(model->history->data); - }, - true); - ws_receiver->timer = - furi_timer_alloc(ws_view_receiver_timer_callback, FuriTimerTypeOnce, ws_receiver); - return ws_receiver; -} - -void ws_view_receiver_free(WSReceiver* ws_receiver) { - furi_assert(ws_receiver); - - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - furi_string_free(model->frequency_str); - furi_string_free(model->preset_str); - furi_string_free(model->history_stat_str); - for - M_EACH(item_menu, model->history->data, WSReceiverMenuItemArray_t) { - furi_string_free(item_menu->item_str); - item_menu->type = 0; - } - WSReceiverMenuItemArray_clear(model->history->data); - free(model->history); - }, - false); - furi_timer_free(ws_receiver->timer); - view_free(ws_receiver->view); - free(ws_receiver); -} - -View* ws_view_receiver_get_view(WSReceiver* ws_receiver) { - furi_assert(ws_receiver); - return ws_receiver->view; -} - -uint16_t ws_view_receiver_get_idx_menu(WSReceiver* ws_receiver) { - furi_assert(ws_receiver); - uint32_t idx = 0; - with_view_model( - ws_receiver->view, WSReceiverModel * model, { idx = model->idx; }, false); - return idx; -} - -void ws_view_receiver_set_idx_menu(WSReceiver* ws_receiver, uint16_t idx) { - furi_assert(ws_receiver); - with_view_model( - ws_receiver->view, - WSReceiverModel * model, - { - model->idx = idx; - if(model->idx > 2) model->list_offset = idx - 2; - }, - true); - ws_view_receiver_update_offset(ws_receiver); -} diff --git a/applications/plugins/weather_station/views/weather_station_receiver.h b/applications/plugins/weather_station/views/weather_station_receiver.h deleted file mode 100644 index 30c6516d5..000000000 --- a/applications/plugins/weather_station/views/weather_station_receiver.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include "../helpers/weather_station_types.h" -#include "../helpers/weather_station_event.h" - -typedef struct WSReceiver WSReceiver; - -typedef void (*WSReceiverCallback)(WSCustomEvent event, void* context); - -void ws_view_receiver_set_lock(WSReceiver* ws_receiver, WSLock keyboard); - -void ws_view_receiver_set_callback( - WSReceiver* ws_receiver, - WSReceiverCallback callback, - void* context); - -WSReceiver* ws_view_receiver_alloc(); - -void ws_view_receiver_free(WSReceiver* ws_receiver); - -View* ws_view_receiver_get_view(WSReceiver* ws_receiver); - -void ws_view_receiver_add_data_statusbar( - WSReceiver* ws_receiver, - const char* frequency_str, - const char* preset_str, - const char* history_stat_str); - -void ws_view_receiver_add_item_to_menu(WSReceiver* ws_receiver, const char* name, uint8_t type); - -uint16_t ws_view_receiver_get_idx_menu(WSReceiver* ws_receiver); - -void ws_view_receiver_set_idx_menu(WSReceiver* ws_receiver, uint16_t idx); - -void ws_view_receiver_exit(void* context); diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.c b/applications/plugins/weather_station/views/weather_station_receiver_info.c deleted file mode 100644 index a7a92f3b4..000000000 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.c +++ /dev/null @@ -1,226 +0,0 @@ -#include "weather_station_receiver.h" -#include "../weather_station_app_i.h" -#include "Weather_Station_icons.h" -#include "../protocols/ws_generic.h" -#include -#include - -#define abs(x) ((x) > 0 ? (x) : -(x)) - -struct WSReceiverInfo { - View* view; - FuriTimer* timer; -}; - -typedef struct { - uint32_t curr_ts; - FuriString* protocol_name; - WSBlockGeneric* generic; -} WSReceiverInfoModel; - -void ws_view_receiver_info_update(WSReceiverInfo* ws_receiver_info, FlipperFormat* fff) { - furi_assert(ws_receiver_info); - furi_assert(fff); - - with_view_model( - ws_receiver_info->view, - WSReceiverInfoModel * model, - { - flipper_format_rewind(fff); - flipper_format_read_string(fff, "Protocol", model->protocol_name); - - ws_block_generic_deserialize(model->generic, fff); - - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - }, - true); -} - -void ws_view_receiver_info_draw(Canvas* canvas, WSReceiverInfoModel* model) { - char buffer[64]; - canvas_clear(canvas); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - - snprintf( - buffer, - sizeof(buffer), - "%s %db", - furi_string_get_cstr(model->protocol_name), - model->generic->data_count_bit); - canvas_draw_str(canvas, 0, 8, buffer); - - if(model->generic->channel != WS_NO_CHANNEL) { - snprintf(buffer, sizeof(buffer), "Ch: %01d", model->generic->channel); - canvas_draw_str(canvas, 106, 8, buffer); - } - - if(model->generic->id != WS_NO_ID) { - snprintf(buffer, sizeof(buffer), "Sn: 0x%02lX", model->generic->id); - canvas_draw_str(canvas, 0, 20, buffer); - } - - if(model->generic->btn != WS_NO_BTN) { - snprintf(buffer, sizeof(buffer), "Btn: %01d", model->generic->btn); - canvas_draw_str(canvas, 57, 20, buffer); - } - - if(model->generic->battery_low != WS_NO_BATT) { - snprintf( - buffer, sizeof(buffer), "Batt: %s", (!model->generic->battery_low ? "ok" : "low")); - canvas_draw_str_aligned(canvas, 126, 17, AlignRight, AlignCenter, buffer); - } - - snprintf(buffer, sizeof(buffer), "Data: 0x%llX", model->generic->data); - canvas_draw_str(canvas, 0, 32, buffer); - - elements_bold_rounded_frame(canvas, 0, 38, 127, 25); - canvas_set_font(canvas, FontPrimary); - - if(model->generic->temp != WS_NO_TEMPERATURE) { - canvas_draw_icon(canvas, 6, 43, &I_Therm_7x16); - snprintf(buffer, sizeof(buffer), "%3.1f C", (double)model->generic->temp); - uint8_t temp_x1 = 47; - uint8_t temp_x2 = 38; - if(model->generic->temp < -9.0) { - temp_x1 = 49; - temp_x2 = 40; - } - canvas_draw_str_aligned(canvas, temp_x1, 47, AlignRight, AlignTop, buffer); - canvas_draw_circle(canvas, temp_x2, 46, 1); - } - - if(model->generic->humidity != WS_NO_HUMIDITY) { - canvas_draw_icon(canvas, 53, 44, &I_Humid_8x13); - snprintf(buffer, sizeof(buffer), "%d%%", model->generic->humidity); - canvas_draw_str(canvas, 64, 55, buffer); - } - - if((int)model->generic->timestamp > 0 && model->curr_ts) { - int ts_diff = (int)model->curr_ts - (int)model->generic->timestamp; - - canvas_draw_icon(canvas, 91, 46, &I_Timer_11x11); - - if(ts_diff > 60) { - int tmp_sec = ts_diff; - int cnt_min = 1; - for(int i = 1; tmp_sec > 60; i++) { - tmp_sec = tmp_sec - 60; - cnt_min = i; - } - - if(model->curr_ts % 2 == 0) { - canvas_draw_str_aligned(canvas, 105, 51, AlignLeft, AlignCenter, "Old"); - } else { - if(cnt_min >= 59) { - canvas_draw_str_aligned(canvas, 105, 51, AlignLeft, AlignCenter, "Old"); - } else { - snprintf(buffer, sizeof(buffer), "%dm", cnt_min); - canvas_draw_str_aligned(canvas, 114, 51, AlignCenter, AlignCenter, buffer); - } - } - - } else { - snprintf(buffer, sizeof(buffer), "%d", ts_diff); - canvas_draw_str_aligned(canvas, 112, 51, AlignCenter, AlignCenter, buffer); - } - } -} - -bool ws_view_receiver_info_input(InputEvent* event, void* context) { - furi_assert(context); - //WSReceiverInfo* ws_receiver_info = context; - - if(event->key == InputKeyBack) { - return false; - } - - return true; -} - -static void ws_view_receiver_info_enter(void* context) { - furi_assert(context); - WSReceiverInfo* ws_receiver_info = context; - - furi_timer_start(ws_receiver_info->timer, 1000); -} - -static void ws_view_receiver_info_exit(void* context) { - furi_assert(context); - WSReceiverInfo* ws_receiver_info = context; - - furi_timer_stop(ws_receiver_info->timer); - - with_view_model( - ws_receiver_info->view, - WSReceiverInfoModel * model, - { furi_string_reset(model->protocol_name); }, - false); -} - -static void ws_view_receiver_info_timer(void* context) { - WSReceiverInfo* ws_receiver_info = context; - // Force redraw - with_view_model( - ws_receiver_info->view, - WSReceiverInfoModel * model, - { - FuriHalRtcDateTime curr_dt; - furi_hal_rtc_get_datetime(&curr_dt); - model->curr_ts = furi_hal_rtc_datetime_to_timestamp(&curr_dt); - }, - true); -} - -WSReceiverInfo* ws_view_receiver_info_alloc() { - WSReceiverInfo* ws_receiver_info = malloc(sizeof(WSReceiverInfo)); - - // View allocation and configuration - ws_receiver_info->view = view_alloc(); - - view_allocate_model(ws_receiver_info->view, ViewModelTypeLocking, sizeof(WSReceiverInfoModel)); - view_set_context(ws_receiver_info->view, ws_receiver_info); - view_set_draw_callback(ws_receiver_info->view, (ViewDrawCallback)ws_view_receiver_info_draw); - view_set_input_callback(ws_receiver_info->view, ws_view_receiver_info_input); - view_set_enter_callback(ws_receiver_info->view, ws_view_receiver_info_enter); - view_set_exit_callback(ws_receiver_info->view, ws_view_receiver_info_exit); - - with_view_model( - ws_receiver_info->view, - WSReceiverInfoModel * model, - { - model->generic = malloc(sizeof(WSBlockGeneric)); - model->protocol_name = furi_string_alloc(); - }, - true); - - ws_receiver_info->timer = - furi_timer_alloc(ws_view_receiver_info_timer, FuriTimerTypePeriodic, ws_receiver_info); - - return ws_receiver_info; -} - -void ws_view_receiver_info_free(WSReceiverInfo* ws_receiver_info) { - furi_assert(ws_receiver_info); - - furi_timer_free(ws_receiver_info->timer); - - with_view_model( - ws_receiver_info->view, - WSReceiverInfoModel * model, - { - furi_string_free(model->protocol_name); - free(model->generic); - }, - false); - - view_free(ws_receiver_info->view); - free(ws_receiver_info); -} - -View* ws_view_receiver_info_get_view(WSReceiverInfo* ws_receiver_info) { - furi_assert(ws_receiver_info); - return ws_receiver_info->view; -} diff --git a/applications/plugins/weather_station/views/weather_station_receiver_info.h b/applications/plugins/weather_station/views/weather_station_receiver_info.h deleted file mode 100644 index 705434a23..000000000 --- a/applications/plugins/weather_station/views/weather_station_receiver_info.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include "../helpers/weather_station_types.h" -#include "../helpers/weather_station_event.h" -#include - -typedef struct WSReceiverInfo WSReceiverInfo; - -void ws_view_receiver_info_update(WSReceiverInfo* ws_receiver_info, FlipperFormat* fff); - -WSReceiverInfo* ws_view_receiver_info_alloc(); - -void ws_view_receiver_info_free(WSReceiverInfo* ws_receiver_info); - -View* ws_view_receiver_info_get_view(WSReceiverInfo* ws_receiver_info); diff --git a/applications/plugins/weather_station/weather_station_10px.png b/applications/plugins/weather_station/weather_station_10px.png deleted file mode 100644 index 7d5cc318c..000000000 Binary files a/applications/plugins/weather_station/weather_station_10px.png and /dev/null differ diff --git a/applications/plugins/weather_station/weather_station_app.c b/applications/plugins/weather_station/weather_station_app.c deleted file mode 100644 index b17f2acfc..000000000 --- a/applications/plugins/weather_station/weather_station_app.c +++ /dev/null @@ -1,178 +0,0 @@ -#include "weather_station_app_i.h" - -#include -#include -#include "protocols/protocol_items.h" - -static bool weather_station_app_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - WeatherStationApp* app = context; - return scene_manager_handle_custom_event(app->scene_manager, event); -} - -static bool weather_station_app_back_event_callback(void* context) { - furi_assert(context); - WeatherStationApp* app = context; - return scene_manager_handle_back_event(app->scene_manager); -} - -static void weather_station_app_tick_event_callback(void* context) { - furi_assert(context); - WeatherStationApp* app = context; - scene_manager_handle_tick_event(app->scene_manager); -} - -WeatherStationApp* weather_station_app_alloc() { - WeatherStationApp* app = malloc(sizeof(WeatherStationApp)); - - // GUI - app->gui = furi_record_open(RECORD_GUI); - - // View Dispatcher - app->view_dispatcher = view_dispatcher_alloc(); - app->scene_manager = scene_manager_alloc(&weather_station_scene_handlers, app); - view_dispatcher_enable_queue(app->view_dispatcher); - - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - view_dispatcher_set_custom_event_callback( - app->view_dispatcher, weather_station_app_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - app->view_dispatcher, weather_station_app_back_event_callback); - view_dispatcher_set_tick_event_callback( - app->view_dispatcher, weather_station_app_tick_event_callback, 100); - - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - // Open Notification record - app->notifications = furi_record_open(RECORD_NOTIFICATION); - - // Variable Item List - app->variable_item_list = variable_item_list_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - WeatherStationViewVariableItemList, - variable_item_list_get_view(app->variable_item_list)); - - // SubMenu - app->submenu = submenu_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, WeatherStationViewSubmenu, submenu_get_view(app->submenu)); - - // Widget - app->widget = widget_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, WeatherStationViewWidget, widget_get_view(app->widget)); - - // Receiver - app->ws_receiver = ws_view_receiver_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - WeatherStationViewReceiver, - ws_view_receiver_get_view(app->ws_receiver)); - - // Receiver Info - app->ws_receiver_info = ws_view_receiver_info_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - WeatherStationViewReceiverInfo, - ws_view_receiver_info_get_view(app->ws_receiver_info)); - - //init setting - app->setting = subghz_setting_alloc(); - - //ToDo FIX file name setting - subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user")); - - //init Worker & Protocol & History - app->lock = WSLockOff; - app->txrx = malloc(sizeof(WeatherStationTxRx)); - app->txrx->preset = malloc(sizeof(SubGhzRadioPreset)); - app->txrx->preset->name = furi_string_alloc(); - ws_preset_init(app, "AM650", subghz_setting_get_default_frequency(app->setting), NULL, 0); - - app->txrx->hopper_state = WSHopperStateOFF; - app->txrx->history = ws_history_alloc(); - app->txrx->worker = subghz_worker_alloc(); - app->txrx->environment = subghz_environment_alloc(); - subghz_environment_set_protocol_registry( - app->txrx->environment, (void*)&weather_station_protocol_registry); - app->txrx->receiver = subghz_receiver_alloc_init(app->txrx->environment); - - subghz_receiver_set_filter(app->txrx->receiver, SubGhzProtocolFlag_Decodable); - subghz_worker_set_overrun_callback( - app->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset); - subghz_worker_set_pair_callback( - app->txrx->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode); - subghz_worker_set_context(app->txrx->worker, app->txrx->receiver); - - furi_hal_power_suppress_charge_enter(); - - scene_manager_next_scene(app->scene_manager, WeatherStationSceneStart); - - return app; -} - -void weather_station_app_free(WeatherStationApp* app) { - furi_assert(app); - - //CC1101 off - ws_sleep(app); - - // Submenu - view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewSubmenu); - submenu_free(app->submenu); - - // Variable Item List - view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewVariableItemList); - variable_item_list_free(app->variable_item_list); - - // Widget - view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewWidget); - widget_free(app->widget); - - // Receiver - view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewReceiver); - ws_view_receiver_free(app->ws_receiver); - - // Receiver Info - view_dispatcher_remove_view(app->view_dispatcher, WeatherStationViewReceiverInfo); - ws_view_receiver_info_free(app->ws_receiver_info); - - //setting - subghz_setting_free(app->setting); - - //Worker & Protocol & History - subghz_receiver_free(app->txrx->receiver); - subghz_environment_free(app->txrx->environment); - ws_history_free(app->txrx->history); - subghz_worker_free(app->txrx->worker); - furi_string_free(app->txrx->preset->name); - free(app->txrx->preset); - free(app->txrx); - - // View dispatcher - view_dispatcher_free(app->view_dispatcher); - scene_manager_free(app->scene_manager); - - // Notifications - furi_record_close(RECORD_NOTIFICATION); - app->notifications = NULL; - - // Close records - furi_record_close(RECORD_GUI); - - furi_hal_power_suppress_charge_exit(); - - free(app); -} - -int32_t weather_station_app(void* p) { - UNUSED(p); - WeatherStationApp* weather_station_app = weather_station_app_alloc(); - - view_dispatcher_run(weather_station_app->view_dispatcher); - - weather_station_app_free(weather_station_app); - - return 0; -} diff --git a/applications/plugins/weather_station/weather_station_app_i.c b/applications/plugins/weather_station/weather_station_app_i.c deleted file mode 100644 index 052bb8533..000000000 --- a/applications/plugins/weather_station/weather_station_app_i.c +++ /dev/null @@ -1,159 +0,0 @@ -#include "weather_station_app_i.h" - -#define TAG "WeatherStation" -#include - -void ws_preset_init( - void* context, - const char* preset_name, - uint32_t frequency, - uint8_t* preset_data, - size_t preset_data_size) { - furi_assert(context); - WeatherStationApp* app = context; - furi_string_set(app->txrx->preset->name, preset_name); - app->txrx->preset->frequency = frequency; - app->txrx->preset->data = preset_data; - app->txrx->preset->data_size = preset_data_size; -} - -bool ws_set_preset(WeatherStationApp* app, const char* preset) { - if(!strcmp(preset, "FuriHalSubGhzPresetOok270Async")) { - furi_string_set(app->txrx->preset->name, "AM270"); - } else if(!strcmp(preset, "FuriHalSubGhzPresetOok650Async")) { - furi_string_set(app->txrx->preset->name, "AM650"); - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev238Async")) { - furi_string_set(app->txrx->preset->name, "FM238"); - } else if(!strcmp(preset, "FuriHalSubGhzPreset2FSKDev476Async")) { - furi_string_set(app->txrx->preset->name, "FM476"); - } else if(!strcmp(preset, "FuriHalSubGhzPresetCustom")) { - furi_string_set(app->txrx->preset->name, "CUSTOM"); - } else { - FURI_LOG_E(TAG, "Unknown preset"); - return false; - } - return true; -} - -void ws_get_frequency_modulation( - WeatherStationApp* app, - FuriString* frequency, - FuriString* modulation) { - furi_assert(app); - if(frequency != NULL) { - furi_string_printf( - frequency, - "%03ld.%02ld", - app->txrx->preset->frequency / 1000000 % 1000, - app->txrx->preset->frequency / 10000 % 100); - } - if(modulation != NULL) { - furi_string_printf(modulation, "%.2s", furi_string_get_cstr(app->txrx->preset->name)); - } -} - -void ws_begin(WeatherStationApp* app, uint8_t* preset_data) { - furi_assert(app); - UNUSED(preset_data); - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(preset_data); - furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); - app->txrx->txrx_state = WSTxRxStateIDLE; -} - -uint32_t ws_rx(WeatherStationApp* app, uint32_t frequency) { - furi_assert(app); - if(!furi_hal_subghz_is_frequency_valid(frequency)) { - furi_crash("WeatherStation: Incorrect RX frequency."); - } - furi_assert( - app->txrx->txrx_state != WSTxRxStateRx && app->txrx->txrx_state != WSTxRxStateSleep); - - furi_hal_subghz_idle(); - uint32_t value = furi_hal_subghz_set_frequency_and_path(frequency); - furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); - furi_hal_subghz_flush_rx(); - furi_hal_subghz_rx(); - - furi_hal_subghz_start_async_rx(subghz_worker_rx_callback, app->txrx->worker); - subghz_worker_start(app->txrx->worker); - app->txrx->txrx_state = WSTxRxStateRx; - return value; -} - -void ws_idle(WeatherStationApp* app) { - furi_assert(app); - furi_assert(app->txrx->txrx_state != WSTxRxStateSleep); - furi_hal_subghz_idle(); - app->txrx->txrx_state = WSTxRxStateIDLE; -} - -void ws_rx_end(WeatherStationApp* app) { - furi_assert(app); - furi_assert(app->txrx->txrx_state == WSTxRxStateRx); - if(subghz_worker_is_running(app->txrx->worker)) { - subghz_worker_stop(app->txrx->worker); - furi_hal_subghz_stop_async_rx(); - } - furi_hal_subghz_idle(); - app->txrx->txrx_state = WSTxRxStateIDLE; -} - -void ws_sleep(WeatherStationApp* app) { - furi_assert(app); - furi_hal_subghz_sleep(); - app->txrx->txrx_state = WSTxRxStateSleep; -} - -void ws_hopper_update(WeatherStationApp* app) { - furi_assert(app); - - switch(app->txrx->hopper_state) { - case WSHopperStateOFF: - return; - break; - case WSHopperStatePause: - return; - break; - case WSHopperStateRSSITimeOut: - if(app->txrx->hopper_timeout != 0) { - app->txrx->hopper_timeout--; - return; - } - break; - default: - break; - } - float rssi = -127.0f; - if(app->txrx->hopper_state != WSHopperStateRSSITimeOut) { - // See RSSI Calculation timings in CC1101 17.3 RSSI - rssi = furi_hal_subghz_get_rssi(); - - // Stay if RSSI is high enough - if(rssi > -90.0f) { - app->txrx->hopper_timeout = 10; - app->txrx->hopper_state = WSHopperStateRSSITimeOut; - return; - } - } else { - app->txrx->hopper_state = WSHopperStateRunnig; - } - // Select next frequency - if(app->txrx->hopper_idx_frequency < - subghz_setting_get_hopper_frequency_count(app->setting) - 1) { - app->txrx->hopper_idx_frequency++; - } else { - app->txrx->hopper_idx_frequency = 0; - } - - if(app->txrx->txrx_state == WSTxRxStateRx) { - ws_rx_end(app); - }; - if(app->txrx->txrx_state == WSTxRxStateIDLE) { - subghz_receiver_reset(app->txrx->receiver); - app->txrx->preset->frequency = - subghz_setting_get_hopper_frequency(app->setting, app->txrx->hopper_idx_frequency); - ws_rx(app, app->txrx->preset->frequency); - } -} diff --git a/applications/plugins/weather_station/weather_station_app_i.h b/applications/plugins/weather_station/weather_station_app_i.h deleted file mode 100644 index 41e248112..000000000 --- a/applications/plugins/weather_station/weather_station_app_i.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "helpers/weather_station_types.h" - -#include "scenes/weather_station_scene.h" -#include -#include -#include -#include -#include -#include -#include -#include "views/weather_station_receiver.h" -#include "views/weather_station_receiver_info.h" -#include "weather_station_history.h" - -#include -#include -#include -#include -#include - -typedef struct WeatherStationApp WeatherStationApp; - -struct WeatherStationTxRx { - SubGhzWorker* worker; - - SubGhzEnvironment* environment; - SubGhzReceiver* receiver; - SubGhzRadioPreset* preset; - WSHistory* history; - uint16_t idx_menu_chosen; - WSTxRxState txrx_state; - WSHopperState hopper_state; - uint8_t hopper_timeout; - uint8_t hopper_idx_frequency; - WSRxKeyState rx_key_state; -}; - -typedef struct WeatherStationTxRx WeatherStationTxRx; - -struct WeatherStationApp { - Gui* gui; - ViewDispatcher* view_dispatcher; - WeatherStationTxRx* txrx; - SceneManager* scene_manager; - NotificationApp* notifications; - VariableItemList* variable_item_list; - Submenu* submenu; - Widget* widget; - WSReceiver* ws_receiver; - WSReceiverInfo* ws_receiver_info; - WSLock lock; - SubGhzSetting* setting; -}; - -void ws_preset_init( - void* context, - const char* preset_name, - uint32_t frequency, - uint8_t* preset_data, - size_t preset_data_size); -bool ws_set_preset(WeatherStationApp* app, const char* preset); -void ws_get_frequency_modulation( - WeatherStationApp* app, - FuriString* frequency, - FuriString* modulation); -void ws_begin(WeatherStationApp* app, uint8_t* preset_data); -uint32_t ws_rx(WeatherStationApp* app, uint32_t frequency); -void ws_idle(WeatherStationApp* app); -void ws_rx_end(WeatherStationApp* app); -void ws_sleep(WeatherStationApp* app); -void ws_hopper_update(WeatherStationApp* app); diff --git a/applications/plugins/weather_station/weather_station_history.c b/applications/plugins/weather_station/weather_station_history.c deleted file mode 100644 index b37009c46..000000000 --- a/applications/plugins/weather_station/weather_station_history.c +++ /dev/null @@ -1,245 +0,0 @@ -#include "weather_station_history.h" -#include -#include -#include -#include "protocols/ws_generic.h" - -#include - -#define WS_HISTORY_MAX 50 -#define TAG "WSHistory" - -typedef struct { - FuriString* item_str; - FlipperFormat* flipper_string; - uint8_t type; - uint32_t id; - SubGhzRadioPreset* preset; -} WSHistoryItem; - -ARRAY_DEF(WSHistoryItemArray, WSHistoryItem, M_POD_OPLIST) - -#define M_OPL_WSHistoryItemArray_t() ARRAY_OPLIST(WSHistoryItemArray, M_POD_OPLIST) - -typedef struct { - WSHistoryItemArray_t data; -} WSHistoryStruct; - -struct WSHistory { - uint32_t last_update_timestamp; - uint16_t last_index_write; - uint8_t code_last_hash_data; - FuriString* tmp_string; - WSHistoryStruct* history; -}; - -WSHistory* ws_history_alloc(void) { - WSHistory* instance = malloc(sizeof(WSHistory)); - instance->tmp_string = furi_string_alloc(); - instance->history = malloc(sizeof(WSHistoryStruct)); - WSHistoryItemArray_init(instance->history->data); - return instance; -} - -void ws_history_free(WSHistory* instance) { - furi_assert(instance); - furi_string_free(instance->tmp_string); - for - M_EACH(item, instance->history->data, WSHistoryItemArray_t) { - furi_string_free(item->item_str); - furi_string_free(item->preset->name); - free(item->preset); - flipper_format_free(item->flipper_string); - item->type = 0; - } - WSHistoryItemArray_clear(instance->history->data); - free(instance->history); - free(instance); -} - -uint32_t ws_history_get_frequency(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - return item->preset->frequency; -} - -SubGhzRadioPreset* ws_history_get_radio_preset(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - return item->preset; -} - -const char* ws_history_get_preset(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - return furi_string_get_cstr(item->preset->name); -} - -void ws_history_reset(WSHistory* instance) { - furi_assert(instance); - furi_string_reset(instance->tmp_string); - for - M_EACH(item, instance->history->data, WSHistoryItemArray_t) { - furi_string_free(item->item_str); - furi_string_free(item->preset->name); - free(item->preset); - flipper_format_free(item->flipper_string); - item->type = 0; - } - WSHistoryItemArray_reset(instance->history->data); - instance->last_index_write = 0; - instance->code_last_hash_data = 0; -} - -uint16_t ws_history_get_item(WSHistory* instance) { - furi_assert(instance); - return instance->last_index_write; -} - -uint8_t ws_history_get_type_protocol(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - return item->type; -} - -const char* ws_history_get_protocol_name(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - flipper_format_rewind(item->flipper_string); - if(!flipper_format_read_string(item->flipper_string, "Protocol", instance->tmp_string)) { - FURI_LOG_E(TAG, "Missing Protocol"); - furi_string_reset(instance->tmp_string); - } - return furi_string_get_cstr(instance->tmp_string); -} - -FlipperFormat* ws_history_get_raw_data(WSHistory* instance, uint16_t idx) { - furi_assert(instance); - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - if(item->flipper_string) { - return item->flipper_string; - } else { - return NULL; - } -} -bool ws_history_get_text_space_left(WSHistory* instance, FuriString* output) { - furi_assert(instance); - if(instance->last_index_write == WS_HISTORY_MAX) { - if(output != NULL) furi_string_printf(output, "Memory is FULL"); - return true; - } - if(output != NULL) - furi_string_printf(output, "%02u/%02u", instance->last_index_write, WS_HISTORY_MAX); - return false; -} - -void ws_history_get_text_item_menu(WSHistory* instance, FuriString* output, uint16_t idx) { - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, idx); - furi_string_set(output, item->item_str); -} - -WSHistoryStateAddKey - ws_history_add_to_history(WSHistory* instance, void* context, SubGhzRadioPreset* preset) { - furi_assert(instance); - furi_assert(context); - - if(instance->last_index_write >= WS_HISTORY_MAX) return WSHistoryStateAddKeyOverflow; - - SubGhzProtocolDecoderBase* decoder_base = context; - if((instance->code_last_hash_data == - subghz_protocol_decoder_base_get_hash_data(decoder_base)) && - ((furi_get_tick() - instance->last_update_timestamp) < 500)) { - instance->last_update_timestamp = furi_get_tick(); - return WSHistoryStateAddKeyTimeOut; - } - - instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base); - instance->last_update_timestamp = furi_get_tick(); - - FlipperFormat* fff = flipper_format_string_alloc(); - uint32_t id = 0; - subghz_protocol_decoder_base_serialize(decoder_base, fff, preset); - - do { - if(!flipper_format_rewind(fff)) { - FURI_LOG_E(TAG, "Rewind error"); - break; - } - if(!flipper_format_read_uint32(fff, "Id", (uint32_t*)&id, 1)) { - FURI_LOG_E(TAG, "Missing Id"); - break; - } - } while(false); - flipper_format_free(fff); - - //Update record if found - bool sensor_found = false; - for(size_t i = 0; i < WSHistoryItemArray_size(instance->history->data); i++) { - WSHistoryItem* item = WSHistoryItemArray_get(instance->history->data, i); - if(item->id == id) { - sensor_found = true; - Stream* flipper_string_stream = flipper_format_get_raw_stream(item->flipper_string); - stream_clean(flipper_string_stream); - subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset); - return WSHistoryStateAddKeyUpdateData; - } - } - - // or add new record - if(!sensor_found) { - WSHistoryItem* item = WSHistoryItemArray_push_raw(instance->history->data); - item->preset = malloc(sizeof(SubGhzRadioPreset)); - item->type = decoder_base->protocol->type; - item->preset->frequency = preset->frequency; - item->preset->name = furi_string_alloc(); - furi_string_set(item->preset->name, preset->name); - item->preset->data = preset->data; - item->preset->data_size = preset->data_size; - item->id = id; - - item->item_str = furi_string_alloc(); - item->flipper_string = flipper_format_string_alloc(); - subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset); - - do { - if(!flipper_format_rewind(item->flipper_string)) { - FURI_LOG_E(TAG, "Rewind error"); - break; - } - if(!flipper_format_read_string( - item->flipper_string, "Protocol", instance->tmp_string)) { - FURI_LOG_E(TAG, "Missing Protocol"); - break; - } - - if(!flipper_format_rewind(item->flipper_string)) { - FURI_LOG_E(TAG, "Rewind error"); - break; - } - uint8_t key_data[sizeof(uint64_t)] = {0}; - if(!flipper_format_read_hex(item->flipper_string, "Data", key_data, sizeof(uint64_t))) { - FURI_LOG_E(TAG, "Missing Data"); - break; - } - uint64_t data = 0; - for(uint8_t i = 0; i < sizeof(uint64_t); i++) { - data = (data << 8) | key_data[i]; - } - uint32_t temp_data = 0; - if(!flipper_format_read_uint32(item->flipper_string, "Ch", (uint32_t*)&temp_data, 1)) { - FURI_LOG_E(TAG, "Missing Channel"); - break; - } - if(temp_data != WS_NO_CHANNEL) { - furi_string_cat_printf(instance->tmp_string, " Ch:%X", (uint8_t)temp_data); - } - - furi_string_printf( - item->item_str, "%s %llX", furi_string_get_cstr(instance->tmp_string), data); - - } while(false); - instance->last_index_write++; - return WSHistoryStateAddKeyNewDada; - } - return WSHistoryStateAddKeyUnknown; -} diff --git a/applications/plugins/weather_station/weather_station_history.h b/applications/plugins/weather_station/weather_station_history.h deleted file mode 100644 index 11601fe79..000000000 --- a/applications/plugins/weather_station/weather_station_history.h +++ /dev/null @@ -1,112 +0,0 @@ - -#pragma once - -#include -#include -#include -#include -#include - -typedef struct WSHistory WSHistory; - -/** History state add key */ -typedef enum { - WSHistoryStateAddKeyUnknown, - WSHistoryStateAddKeyTimeOut, - WSHistoryStateAddKeyNewDada, - WSHistoryStateAddKeyUpdateData, - WSHistoryStateAddKeyOverflow, -} WSHistoryStateAddKey; - -/** Allocate WSHistory - * - * @return WSHistory* - */ -WSHistory* ws_history_alloc(void); - -/** Free WSHistory - * - * @param instance - WSHistory instance - */ -void ws_history_free(WSHistory* instance); - -/** Clear history - * - * @param instance - WSHistory instance - */ -void ws_history_reset(WSHistory* instance); - -/** Get frequency to history[idx] - * - * @param instance - WSHistory instance - * @param idx - record index - * @return frequency - frequency Hz - */ -uint32_t ws_history_get_frequency(WSHistory* instance, uint16_t idx); - -SubGhzRadioPreset* ws_history_get_radio_preset(WSHistory* instance, uint16_t idx); - -/** Get preset to history[idx] - * - * @param instance - WSHistory instance - * @param idx - record index - * @return preset - preset name - */ -const char* ws_history_get_preset(WSHistory* instance, uint16_t idx); - -/** Get history index write - * - * @param instance - WSHistory instance - * @return idx - current record index - */ -uint16_t ws_history_get_item(WSHistory* instance); - -/** Get type protocol to history[idx] - * - * @param instance - WSHistory instance - * @param idx - record index - * @return type - type protocol - */ -uint8_t ws_history_get_type_protocol(WSHistory* instance, uint16_t idx); - -/** Get name protocol to history[idx] - * - * @param instance - WSHistory instance - * @param idx - record index - * @return name - const char* name protocol - */ -const char* ws_history_get_protocol_name(WSHistory* instance, uint16_t idx); - -/** Get string item menu to history[idx] - * - * @param instance - WSHistory instance - * @param output - FuriString* output - * @param idx - record index - */ -void ws_history_get_text_item_menu(WSHistory* instance, FuriString* output, uint16_t idx); - -/** Get string the remaining number of records to history - * - * @param instance - WSHistory instance - * @param output - FuriString* output - * @return bool - is FUUL - */ -bool ws_history_get_text_space_left(WSHistory* instance, FuriString* output); - -/** Add protocol to history - * - * @param instance - WSHistory instance - * @param context - SubGhzProtocolCommon context - * @param preset - SubGhzRadioPreset preset - * @return WSHistoryStateAddKey; - */ -WSHistoryStateAddKey - ws_history_add_to_history(WSHistory* instance, void* context, SubGhzRadioPreset* preset); - -/** Get SubGhzProtocolCommonLoad to load into the protocol decoder bin data - * - * @param instance - WSHistory instance - * @param idx - record index - * @return SubGhzProtocolCommonLoad* - */ -FlipperFormat* ws_history_get_raw_data(WSHistory* instance, uint16_t idx); diff --git a/applications/plugins/wifi_deauther_v1/FlipperZeroWiFiDeauthModuleDefines.h b/applications/plugins/wifi_deauther_v1/FlipperZeroWiFiDeauthModuleDefines.h deleted file mode 100644 index a8e0e8d61..000000000 --- a/applications/plugins/wifi_deauther_v1/FlipperZeroWiFiDeauthModuleDefines.h +++ /dev/null @@ -1,7 +0,0 @@ -#define WIFI_MODULE_INIT_VERSION "WFDM_0.1" - -#define MODULE_CONTEXT_INITIALIZATION WIFI_MODULE_INIT_VERSION - -#define FLIPPERZERO_SERIAL_BAUD 230400 - -#define NA 0 diff --git a/applications/plugins/wifi_deauther_v1/application.fam b/applications/plugins/wifi_deauther_v1/application.fam deleted file mode 100644 index 6ce0f4435..000000000 --- a/applications/plugins/wifi_deauther_v1/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="ESP8266_Deauther", - name="[ESP8266] Deauther", - apptype=FlipperAppType.EXTERNAL, - entry_point="esp8266_deauth_app", - cdefines=["APP_ESP8266_deauth"], - requires=["gui"], - stack_size=2 * 1024, - order=20, - fap_icon="wifi_10px.png", - fap_category="GPIO", -) diff --git a/applications/plugins/wifi_deauther_v1/esp8266_deauth.c b/applications/plugins/wifi_deauther_v1/esp8266_deauth.c deleted file mode 100644 index 3cc61a588..000000000 --- a/applications/plugins/wifi_deauther_v1/esp8266_deauth.c +++ /dev/null @@ -1,538 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include -//#include - -#include - -#include "FlipperZeroWiFiDeauthModuleDefines.h" - -#define DEAUTH_APP_DEBUG 0 - -#if DEAUTH_APP_DEBUG -#define APP_NAME_TAG "WiFi_Deauther" -#define DEAUTH_APP_LOG_I(format, ...) FURI_LOG_I(APP_NAME_TAG, format, ##__VA_ARGS__) -#define DEAUTH_APP_LOG_D(format, ...) FURI_LOG_D(APP_NAME_TAG, format, ##__VA_ARGS__) -#define DEAUTH_APP_LOG_E(format, ...) FURI_LOG_E(APP_NAME_TAG, format, ##__VA_ARGS__) -#else -#define DEAUTH_APP_LOG_I(format, ...) -#define DEAUTH_APP_LOG_D(format, ...) -#define DEAUTH_APP_LOG_E(format, ...) -#endif // WIFI_APP_DEBUG - -#define DISABLE_CONSOLE !DEAUTH_APP_DEBUG -#define ENABLE_MODULE_POWER 1 -#define ENABLE_MODULE_DETECTION 1 - -typedef enum EEventType // app internally defined event types -{ EventTypeKey // flipper input.h type -} EEventType; - -typedef struct SPluginEvent { - EEventType m_type; - InputEvent m_input; -} SPluginEvent; - -typedef enum EAppContext { - Undefined, - WaitingForModule, - Initializing, - ModuleActive, -} EAppContext; - -typedef enum EWorkerEventFlags { - WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event - WorkerEventStop = (1 << 1), - WorkerEventRx = (1 << 2), -} EWorkerEventFlags; - -typedef struct SGpioButtons { - GpioPin const* pinButtonUp; - GpioPin const* pinButtonDown; - GpioPin const* pinButtonOK; - GpioPin const* pinButtonBack; -} SGpioButtons; - -typedef struct SWiFiDeauthApp { - Gui* m_gui; - FuriThread* m_worker_thread; - //NotificationApp* m_notification; - FuriStreamBuffer* m_rx_stream; - SGpioButtons m_GpioButtons; - - bool m_wifiDeauthModuleInitialized; - bool m_wifiDeauthModuleAttached; - - EAppContext m_context; - - uint8_t m_backBuffer[128 * 8 * 8]; - //uint8_t m_renderBuffer[128 * 8 * 8]; - - uint8_t* m_backBufferPtr; - //uint8_t* m_m_renderBufferPtr; - - //uint8_t* m_originalBuffer; - //uint8_t** m_originalBufferLocation; - size_t m_canvasSize; - - bool m_needUpdateGUI; -} SWiFiDeauthApp; - -/////// INIT STATE /////// -static void esp8266_deauth_app_init(SWiFiDeauthApp* const app) { - app->m_context = Undefined; - - app->m_canvasSize = 128 * 8 * 8; - memset(app->m_backBuffer, DEAUTH_APP_DEBUG ? 0xFF : 0x00, app->m_canvasSize); - //memset(app->m_renderBuffer, DEAUTH_APP_DEBUG ? 0xFF : 0x00, app->m_canvasSize); - - //app->m_originalBuffer = NULL; - //app->m_originalBufferLocation = NULL; - - //app->m_m_renderBufferPtr = app->m_renderBuffer; - app->m_backBufferPtr = app->m_backBuffer; - - app->m_GpioButtons.pinButtonUp = &gpio_ext_pc3; - app->m_GpioButtons.pinButtonDown = &gpio_ext_pb2; - app->m_GpioButtons.pinButtonOK = &gpio_ext_pb3; - app->m_GpioButtons.pinButtonBack = &gpio_ext_pa4; - - app->m_needUpdateGUI = false; - -#if ENABLE_MODULE_POWER - app->m_wifiDeauthModuleInitialized = false; -#else - app->m_wifiDeauthModuleInitialized = true; -#endif // ENABLE_MODULE_POWER - -#if ENABLE_MODULE_DETECTION - app->m_wifiDeauthModuleAttached = false; -#else - app->m_wifiDeauthModuleAttached = true; -#endif -} - -static void esp8266_deauth_module_render_callback(Canvas* const canvas, void* ctx) { - SWiFiDeauthApp* app = acquire_mutex((ValueMutex*)ctx, 25); - if(app == NULL) { - return; - } - - //if(app->m_needUpdateGUI) - //{ - // app->m_needUpdateGUI = false; - - // //app->m_canvasSize = canvas_get_buffer_size(canvas); - // //app->m_originalBuffer = canvas_get_buffer(canvas); - // //app->m_originalBufferLocation = &u8g2_GetBufferPtr(&canvas->fb); - // //u8g2_GetBufferPtr(&canvas->fb) = app->m_m_renderBufferPtr; - //} - - //uint8_t* exchangeBuffers = app->m_m_renderBufferPtr; - //app->m_m_renderBufferPtr = app->m_backBufferPtr; - //app->m_backBufferPtr = exchangeBuffers; - - //if(app->m_needUpdateGUI) - //{ - // //memcpy(app->m_renderBuffer, app->m_backBuffer, app->m_canvasSize); - // app->m_needUpdateGUI = false; - //} - - switch(app->m_context) { - case Undefined: { - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - - const char* strInitializing = "Something wrong"; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, - strInitializing); - } break; - case WaitingForModule: -#if ENABLE_MODULE_DETECTION - furi_assert(!app->m_wifiDeauthModuleAttached); - if(!app->m_wifiDeauthModuleAttached) { - canvas_clear(canvas); - canvas_set_font(canvas, FontSecondary); - - const char* strInitializing = "Attach WiFi Deauther module"; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, - strInitializing); - } -#endif - break; - case Initializing: -#if ENABLE_MODULE_POWER - { - furi_assert(!app->m_wifiDeauthModuleInitialized); - if(!app->m_wifiDeauthModuleInitialized) { - canvas_set_font(canvas, FontPrimary); - - const char* strInitializing = "Initializing..."; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / 2) - - (u8g2_GetMaxCharHeight(&canvas->fb) / 2), - strInitializing); - } - } -#endif // ENABLE_MODULE_POWER - break; - case ModuleActive: { - uint8_t* buffer = canvas_get_buffer(canvas); - app->m_canvasSize = canvas_get_buffer_size(canvas); - memcpy(buffer, app->m_backBuffer, app->m_canvasSize); - } break; - default: - break; - } - - release_mutex((ValueMutex*)ctx, app); -} - -static void - esp8266_deauth_module_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - SPluginEvent event = {.m_type = EventTypeKey, .m_input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) { - furi_assert(context); - - SWiFiDeauthApp* app = context; - - DEAUTH_APP_LOG_I("uart_echo_on_irq_cb"); - - if(ev == UartIrqEventRXNE) { - DEAUTH_APP_LOG_I("ev == UartIrqEventRXNE"); - furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0); - furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx); - } -} - -static int32_t uart_worker(void* context) { - furi_assert(context); - DEAUTH_APP_LOG_I("[UART] Worker thread init"); - - SWiFiDeauthApp* app = acquire_mutex((ValueMutex*)context, 25); - if(app == NULL) { - return 1; - } - - FuriStreamBuffer* rx_stream = app->m_rx_stream; - - release_mutex((ValueMutex*)context, app); - -#if ENABLE_MODULE_POWER - bool initialized = false; - - FuriString* receivedString; - receivedString = furi_string_alloc(); -#endif // ENABLE_MODULE_POWER - - while(true) { - uint32_t events = furi_thread_flags_wait( - WorkerEventStop | WorkerEventRx, FuriFlagWaitAny, FuriWaitForever); - furi_check((events & FuriFlagError) == 0); - - if(events & WorkerEventStop) break; - if(events & WorkerEventRx) { - DEAUTH_APP_LOG_I("[UART] Received data"); - SWiFiDeauthApp* app = acquire_mutex((ValueMutex*)context, 25); - if(app == NULL) { - return 1; - } - - size_t dataReceivedLength = 0; - int index = 0; - do { - const uint8_t dataBufferSize = 64; - uint8_t dataBuffer[dataBufferSize]; - dataReceivedLength = - furi_stream_buffer_receive(rx_stream, dataBuffer, dataBufferSize, 25); - if(dataReceivedLength > 0) { -#if ENABLE_MODULE_POWER - if(!initialized) { - if(!(dataReceivedLength > strlen(MODULE_CONTEXT_INITIALIZATION))) { - DEAUTH_APP_LOG_I("[UART] Found possible init candidate"); - for(uint16_t i = 0; i < dataReceivedLength; i++) { - furi_string_push_back(receivedString, dataBuffer[i]); - } - } - } else -#endif // ENABLE_MODULE_POWER - { - DEAUTH_APP_LOG_I("[UART] Data copied to backbuffer"); - memcpy(app->m_backBuffer + index, dataBuffer, dataReceivedLength); - index += dataReceivedLength; - app->m_needUpdateGUI = true; - } - } - - } while(dataReceivedLength > 0); - -#if ENABLE_MODULE_POWER - if(!app->m_wifiDeauthModuleInitialized) { - if(furi_string_cmp_str(receivedString, MODULE_CONTEXT_INITIALIZATION) == 0) { - DEAUTH_APP_LOG_I("[UART] Initialized"); - initialized = true; - app->m_wifiDeauthModuleInitialized = true; - app->m_context = ModuleActive; - furi_string_free(receivedString); - } else { - DEAUTH_APP_LOG_I("[UART] Not an initialization command"); - furi_string_reset(receivedString); - } - } -#endif // ENABLE_MODULE_POWER - - release_mutex((ValueMutex*)context, app); - } - } - - return 0; -} - -int32_t esp8266_deauth_app(void* p) { - UNUSED(p); - - DEAUTH_APP_LOG_I("Init"); - - // FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue); - // furi_timer_start(timer, furi_kernel_get_tick_frequency()); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(SPluginEvent)); - - SWiFiDeauthApp* app = malloc(sizeof(SWiFiDeauthApp)); - - esp8266_deauth_app_init(app); - - furi_hal_gpio_init_simple(app->m_GpioButtons.pinButtonUp, GpioModeOutputPushPull); - furi_hal_gpio_init_simple(app->m_GpioButtons.pinButtonDown, GpioModeOutputPushPull); - furi_hal_gpio_init_simple(app->m_GpioButtons.pinButtonOK, GpioModeOutputPushPull); - furi_hal_gpio_init_simple(app->m_GpioButtons.pinButtonBack, GpioModeOutputPushPull); - - furi_hal_gpio_write(app->m_GpioButtons.pinButtonUp, true); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonDown, true); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonOK, true); - furi_hal_gpio_write( - app->m_GpioButtons.pinButtonBack, false); // GPIO15 - Boot fails if pulled HIGH - -#if ENABLE_MODULE_DETECTION - furi_hal_gpio_init( - &gpio_ext_pc0, - GpioModeInput, - GpioPullUp, - GpioSpeedLow); // Connect to the Flipper's ground just to be sure - //furi_hal_gpio_add_int_callback(pinD0, input_isr_d0, this); - app->m_context = WaitingForModule; -#else -#if ENABLE_MODULE_POWER - app->m_context = Initializing; - furi_hal_power_enable_otg(); -#else - app->m_context = ModuleActive; -#endif -#endif // ENABLE_MODULE_DETECTION - - ValueMutex app_data_mutex; - if(!init_mutex(&app_data_mutex, app, sizeof(SWiFiDeauthApp))) { - DEAUTH_APP_LOG_E("cannot create mutex\r\n"); - free(app); - return 255; - } - - DEAUTH_APP_LOG_I("Mutex created"); - - //app->m_notification = furi_record_open("notification"); - - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, esp8266_deauth_module_render_callback, &app_data_mutex); - view_port_input_callback_set(view_port, esp8266_deauth_module_input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - //notification_message(app->notification, &sequence_set_only_blue_255); - - app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1); - - app->m_worker_thread = furi_thread_alloc(); - furi_thread_set_name(app->m_worker_thread, "WiFiDeauthModuleUARTWorker"); - furi_thread_set_stack_size(app->m_worker_thread, 1 * 1024); - furi_thread_set_context(app->m_worker_thread, &app_data_mutex); - furi_thread_set_callback(app->m_worker_thread, uart_worker); - furi_thread_start(app->m_worker_thread); - DEAUTH_APP_LOG_I("UART thread allocated"); - - // Enable uart listener -#if DISABLE_CONSOLE - furi_hal_console_disable(); -#endif - furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD); - furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_on_irq_cb, app); - DEAUTH_APP_LOG_I("UART Listener created"); - - SPluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - SWiFiDeauthApp* app = (SWiFiDeauthApp*)acquire_mutex_block(&app_data_mutex); - -#if ENABLE_MODULE_DETECTION - if(!app->m_wifiDeauthModuleAttached) { - if(furi_hal_gpio_read(&gpio_ext_pc0) == false) { - DEAUTH_APP_LOG_I("Module Attached"); - app->m_wifiDeauthModuleAttached = true; -#if ENABLE_MODULE_POWER - app->m_context = Initializing; - furi_hal_power_enable_otg(); -#else - app->m_context = ModuleActive; -#endif - } - } -#endif // ENABLE_MODULE_DETECTION - - if(event_status == FuriStatusOk) { - if(event.m_type == EventTypeKey) { - if(app->m_wifiDeauthModuleInitialized) { - if(app->m_context == ModuleActive) { - switch(event.m_input.key) { - case InputKeyUp: - if(event.m_input.type == InputTypePress) { - DEAUTH_APP_LOG_I("Up Press"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonUp, false); - } else if(event.m_input.type == InputTypeRelease) { - DEAUTH_APP_LOG_I("Up Release"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonUp, true); - } - break; - case InputKeyDown: - if(event.m_input.type == InputTypePress) { - DEAUTH_APP_LOG_I("Down Press"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonDown, false); - } else if(event.m_input.type == InputTypeRelease) { - DEAUTH_APP_LOG_I("Down Release"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonDown, true); - } - break; - case InputKeyOk: - if(event.m_input.type == InputTypePress) { - DEAUTH_APP_LOG_I("OK Press"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonOK, false); - } else if(event.m_input.type == InputTypeRelease) { - DEAUTH_APP_LOG_I("OK Release"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonOK, true); - } - break; - case InputKeyBack: - if(event.m_input.type == InputTypePress) { - DEAUTH_APP_LOG_I("Back Press"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonBack, false); - } else if(event.m_input.type == InputTypeRelease) { - DEAUTH_APP_LOG_I("Back Release"); - furi_hal_gpio_write(app->m_GpioButtons.pinButtonBack, true); - } else if(event.m_input.type == InputTypeLong) { - DEAUTH_APP_LOG_I("Back Long"); - processing = false; - } - break; - default: - break; - } - } - } else { - if(event.m_input.key == InputKeyBack) { - if(event.m_input.type == InputTypeShort || - event.m_input.type == InputTypeLong) { - processing = false; - } - } - } - } - } - -#if ENABLE_MODULE_DETECTION - if(app->m_wifiDeauthModuleAttached && furi_hal_gpio_read(&gpio_ext_pc0) == true) { - DEAUTH_APP_LOG_D("Module Disconnected - Exit"); - processing = false; - app->m_wifiDeauthModuleAttached = false; - app->m_wifiDeauthModuleInitialized = false; - } -#endif - - view_port_update(view_port); - release_mutex(&app_data_mutex, app); - } - - DEAUTH_APP_LOG_I("Start exit app"); - - furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventStop); - furi_thread_join(app->m_worker_thread); - furi_thread_free(app->m_worker_thread); - - DEAUTH_APP_LOG_I("Thread Deleted"); - - // Reset GPIO pins to default state - furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_init(&gpio_ext_pc3, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_init(&gpio_ext_pb2, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_init(&gpio_ext_pb3, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - furi_hal_gpio_init(&gpio_ext_pa4, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - -#if DISABLE_CONSOLE - furi_hal_console_enable(); -#endif - - //*app->m_originalBufferLocation = app->m_originalBuffer; - - view_port_enabled_set(view_port, false); - - gui_remove_view_port(gui, view_port); - - // Close gui record - furi_record_close(RECORD_GUI); - furi_record_close("notification"); - app->m_gui = NULL; - - view_port_free(view_port); - - furi_message_queue_free(event_queue); - - furi_stream_buffer_free(app->m_rx_stream); - - delete_mutex(&app_data_mutex); - - // Free rest - free(app); - - DEAUTH_APP_LOG_I("App freed"); - -#if ENABLE_MODULE_POWER - furi_hal_power_disable_otg(); -#endif - - return 0; -} diff --git a/applications/plugins/wifi_deauther_v1/wifi_10px.png b/applications/plugins/wifi_deauther_v1/wifi_10px.png deleted file mode 100644 index c13534660..000000000 Binary files a/applications/plugins/wifi_deauther_v1/wifi_10px.png and /dev/null differ diff --git a/applications/plugins/wifi_deauther_v2/LICENSE b/applications/plugins/wifi_deauther_v2/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/wifi_deauther_v2/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/wifi_deauther_v2/README.md b/applications/plugins/wifi_deauther_v2/README.md deleted file mode 100644 index 40fff1324..000000000 --- a/applications/plugins/wifi_deauther_v2/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# flipperzero_esp8266_deautherv2 -Flipper Zero esp8266 deauther app. - - -Based off the WiFi Marauder App from 0xchocolate. - -Thanks to Roguemaster for fixing some issues I had with the code and didnt get a chance to get to. I have now uploaded these changes into the source. - -I have also successfully built this with unleashed souce as well and included the FAP file here. unleashed version unlshd-020. - -https://github.com/0xchocolate/flipperzero-firmware-with-wifi-marauder-companion - -https://github.com/RogueMaster/flipperzero-firmware-wPlugins/tree/unleashed/applications/wifi_marauder_companion - -uses the Version 2 of the ESP8266 Deauther code. -https://github.com/SpacehuhnTech/esp8266_deauther/tree/v2/esp8266_deauther - -This is done so you can use the original deauther v2 firmware on the esp8266. -you can just flash the latest binary. - -also a shout out to https://github.com/SequoiaSan/FlipperZero-Wifi-ESP8266-Deauther-Module -This is already in the Roguemaster firmware and just needs to be enabled and compiled. unfortunatly I could not get this past the menu when I compiled his deauther source for the nodemcu. Nice menu though. - -I used a nodeMCU board. Wiring is simple. follow the wiring guide on https://github.com/SequoiaSan/FlipperZero-WiFi-Scanner_Module -On mine I connected one G to ground, VIN to 5V, RX to U_TX, TX to U_RX. - -NodeMCU---FlipperZero - -G---------GND - -VIN-------5V - -RX--------U_TX - -TX--------U_RX - - - -Video in action (old version). -https://youtu.be/_RFzZyPkeR0 - -New video and install instructions. -https://youtu.be/CKK7t0TaRVQ - -If you want to disable the built in WiFi access and web interface (only use flipper to send serial commands) then select "set webinterface false", "save settings" and "reboot". When it starts back up you wont see the pwned AP any more. - -I installed this into Roguemaster to test. - -git clone --recursive https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git -cd flipperzero-firmware-wPlugins/ - -copy folder into applications. -add "APPS_wifi_deauther", to the meta/application.fam file. - -compile -./fbt resources icons -./fbt updater_package diff --git a/applications/plugins/wifi_deauther_v2/application.fam b/applications/plugins/wifi_deauther_v2/application.fam deleted file mode 100644 index 8fd4602c4..000000000 --- a/applications/plugins/wifi_deauther_v2/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="ESP8266_Wifi_Deauther", - name="[ESP8266] WiFi (Deauther) v2", - apptype=FlipperAppType.EXTERNAL, - entry_point="wifi_deauther_app", - cdefines=["APP_WIFI_deauther"], - requires=["gui"], - stack_size=1 * 1024, - order=30, - fap_icon="wifi_10px.png", - fap_category="GPIO", -) diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.c b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.c deleted file mode 100644 index a974beea9..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "wifi_deauther_scene.h" - -// Generate scene on_enter handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, -void (*const wifi_deauther_scene_on_enter_handlers[])(void*) = { -#include "wifi_deauther_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_event handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, -bool (*const wifi_deauther_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { -#include "wifi_deauther_scene_config.h" -}; -#undef ADD_SCENE - -// Generate scene on_exit handlers array -#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, -void (*const wifi_deauther_scene_on_exit_handlers[])(void* context) = { -#include "wifi_deauther_scene_config.h" -}; -#undef ADD_SCENE - -// Initialize scene handlers configuration structure -const SceneManagerHandlers wifi_deauther_scene_handlers = { - .on_enter_handlers = wifi_deauther_scene_on_enter_handlers, - .on_event_handlers = wifi_deauther_scene_on_event_handlers, - .on_exit_handlers = wifi_deauther_scene_on_exit_handlers, - .scene_num = WifideautherSceneNum, -}; diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.h b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.h deleted file mode 100644 index a6ef08553..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -// Generate scene id and total number -#define ADD_SCENE(prefix, name, id) WifideautherScene##id, -typedef enum { -#include "wifi_deauther_scene_config.h" - WifideautherSceneNum, -} WifideautherScene; -#undef ADD_SCENE - -extern const SceneManagerHandlers wifi_deauther_scene_handlers; - -// Generate scene on_enter handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); -#include "wifi_deauther_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_event handlers declaration -#define ADD_SCENE(prefix, name, id) \ - bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); -#include "wifi_deauther_scene_config.h" -#undef ADD_SCENE - -// Generate scene on_exit handlers declaration -#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); -#include "wifi_deauther_scene_config.h" -#undef ADD_SCENE diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_config.h b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_config.h deleted file mode 100644 index 5f21cdc50..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_config.h +++ /dev/null @@ -1,3 +0,0 @@ -ADD_SCENE(wifi_deauther, start, Start) -ADD_SCENE(wifi_deauther, console_output, ConsoleOutput) -ADD_SCENE(wifi_deauther, text_input, TextInput) diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_console_output.c b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_console_output.c deleted file mode 100644 index a9b738b06..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_console_output.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "../wifi_deauther_app_i.h" - -void wifi_deauther_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* context) { - furi_assert(context); - WifideautherApp* app = context; - - // If text box store gets too big, then truncate it - app->text_box_store_strlen += len; - if(app->text_box_store_strlen >= WIFI_deauther_TEXT_BOX_STORE_SIZE - 1) { - furi_string_right(app->text_box_store, app->text_box_store_strlen / 2); - app->text_box_store_strlen = furi_string_size(app->text_box_store); - } - - // Null-terminate buf and append to text box store - buf[len] = '\0'; - furi_string_cat_printf(app->text_box_store, "%s", buf); - - view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventRefreshConsoleOutput); -} - -void wifi_deauther_scene_console_output_on_enter(void* context) { - WifideautherApp* app = context; - - // Register callback to receive data - wifi_deauther_uart_set_handle_rx_data_cb( - app->uart, wifi_deauther_console_output_handle_rx_data_cb); // setup callback for rx thread - - // Give a small delay to allow UART to settle. - furi_delay_ms(600); - - TextBox* text_box = app->text_box; - text_box_reset(app->text_box); - text_box_set_font(text_box, TextBoxFontText); - if(app->focus_console_start) { - text_box_set_focus(text_box, TextBoxFocusStart); - } else { - text_box_set_focus(text_box, TextBoxFocusEnd); - } - if(app->is_command) { - furi_string_reset(app->text_box_store); - app->text_box_store_strlen = 0; - - } else { // "View Log" menu action - text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store)); - } - - scene_manager_set_scene_state(app->scene_manager, WifideautherSceneConsoleOutput, 0); - view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewConsoleOutput); - - // Send command with newline '\n' - if(app->is_command && app->selected_tx_string) { - wifi_deauther_uart_tx( - (uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string)); - wifi_deauther_uart_tx((uint8_t*)("\n"), 1); - } -} - -bool wifi_deauther_scene_console_output_on_event(void* context, SceneManagerEvent event) { - WifideautherApp* app = context; - - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store)); - consumed = true; - } else if(event.type == SceneManagerEventTypeTick) { - consumed = true; - } - - return consumed; -} - -void wifi_deauther_scene_console_output_on_exit(void* context) { - WifideautherApp* app = context; - - // Unregister rx callback - wifi_deauther_uart_set_handle_rx_data_cb(app->uart, NULL); - - // Automatically stop the scan when exiting view - if(app->is_command) { - wifi_deauther_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n")); - } -} \ No newline at end of file diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_start.c b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_start.c deleted file mode 100644 index 2519c9a07..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_start.c +++ /dev/null @@ -1,172 +0,0 @@ -#include "../wifi_deauther_app_i.h" - -// For each command, define whether additional arguments are needed -// (enabling text input to fill them out), and whether the console -// text box should focus at the start of the output or the end -typedef enum { NO_ARGS = 0, INPUT_ARGS, TOGGLE_ARGS } InputArgs; - -typedef enum { FOCUS_CONSOLE_END = 0, FOCUS_CONSOLE_START, FOCUS_CONSOLE_TOGGLE } FocusConsole; - -#define SHOW_STOPSCAN_TIP (true) -#define NO_TIP (false) - -#define MAX_OPTIONS (6) -typedef struct { - const char* item_string; - const char* options_menu[MAX_OPTIONS]; - int num_options_menu; - const char* actual_commands[MAX_OPTIONS]; - InputArgs needs_keyboard; - FocusConsole focus_console; - bool show_stopscan_tip; -} WifideautherItem; - -// NUM_MENU_ITEMS defined in wifi_deauther_app_i.h - if you add an entry here, increment it! -const WifideautherItem MenuItems[NUM_MENU_ITEMS] = { - {"View Log from", {"start", "end"}, 2, {}, NO_ARGS, FOCUS_CONSOLE_TOGGLE, NO_TIP}, - {"Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, - {"Stop", {""}, 1, {"stop all"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, - {"Scan", - {"All", "SSIDs", "Stations"}, - 3, - {"scan", "scan aps", "scan stations"}, - NO_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, - {"Show", - {"SSIDs", "Stations", "All", "Selected"}, - 4, - {"show ap", "show station", "show all", "show selected"}, - NO_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, - {"Select", - {"All", "SSIDs", "Stations"}, - 3, - {"select all", "select aps", "select stations"}, - INPUT_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, - {"Deselect", - {"All", "SSIDs", "Stations"}, - 3, - {"deselect all", "deselect aps", "deselect stations"}, - INPUT_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, - {"Attack", - {"deauth", "deauthall", "beacon", "probe"}, - 4, - {"attack deauth", "attack deauthall", "attack beacon", "attack probe"}, - NO_ARGS, - FOCUS_CONSOLE_END, - SHOW_STOPSCAN_TIP}, - {"Settings", - {"Get", "Remove AP", "Set SSID", "Set Pass", "Save"}, - 5, - {"get settings", - "set webinterface false", - "set ssid: pwned", - "set password: deauther", - "save settings"}, - INPUT_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, - {"Sysinfo", {""}, 1, {"sysinfo"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, - {"Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, -}; - -static void wifi_deauther_scene_start_var_list_enter_callback(void* context, uint32_t index) { - furi_assert(context); - WifideautherApp* app = context; - if(app->selected_option_index[index] < MenuItems[index].num_options_menu) { - app->selected_tx_string = - MenuItems[index].actual_commands[app->selected_option_index[index]]; - } - app->is_command = (1 <= index); - app->is_custom_tx_string = false; - app->selected_menu_index = index; - app->focus_console_start = (MenuItems[index].focus_console == FOCUS_CONSOLE_TOGGLE) ? - (app->selected_option_index[index] == 0) : - MenuItems[index].focus_console; - app->show_stopscan_tip = MenuItems[index].show_stopscan_tip; - - bool needs_keyboard = (MenuItems[index].needs_keyboard == TOGGLE_ARGS) ? - (app->selected_option_index[index] != 0) : - MenuItems[index].needs_keyboard; - if(needs_keyboard) { - view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartKeyboard); - } else { - view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartConsole); - } -} - -static void wifi_deauther_scene_start_var_list_change_callback(VariableItem* item) { - furi_assert(item); - - WifideautherApp* app = variable_item_get_context(item); - furi_assert(app); - - const WifideautherItem* menu_item = &MenuItems[app->selected_menu_index]; - uint8_t item_index = variable_item_get_current_value_index(item); - furi_assert(item_index < menu_item->num_options_menu); - variable_item_set_current_value_text(item, menu_item->options_menu[item_index]); - app->selected_option_index[app->selected_menu_index] = item_index; -} - -void wifi_deauther_scene_start_on_enter(void* context) { - WifideautherApp* app = context; - VariableItemList* var_item_list = app->var_item_list; - - variable_item_list_set_enter_callback( - var_item_list, wifi_deauther_scene_start_var_list_enter_callback, app); - - VariableItem* item; - for(int i = 0; i < NUM_MENU_ITEMS; ++i) { - item = variable_item_list_add( - var_item_list, - MenuItems[i].item_string, - MenuItems[i].num_options_menu, - wifi_deauther_scene_start_var_list_change_callback, - app); - if(MenuItems[i].num_options_menu) { - variable_item_set_current_value_index(item, app->selected_option_index[i]); - variable_item_set_current_value_text( - item, MenuItems[i].options_menu[app->selected_option_index[i]]); - } - } - - variable_item_list_set_selected_item( - var_item_list, scene_manager_get_scene_state(app->scene_manager, WifideautherSceneStart)); - - view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewVarItemList); -} - -bool wifi_deauther_scene_start_on_event(void* context, SceneManagerEvent event) { - UNUSED(context); - WifideautherApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == WifideautherEventStartKeyboard) { - scene_manager_set_scene_state( - app->scene_manager, WifideautherSceneStart, app->selected_menu_index); - scene_manager_next_scene(app->scene_manager, WifideautherAppViewTextInput); - } else if(event.event == WifideautherEventStartConsole) { - scene_manager_set_scene_state( - app->scene_manager, WifideautherSceneStart, app->selected_menu_index); - scene_manager_next_scene(app->scene_manager, WifideautherAppViewConsoleOutput); - } - consumed = true; - } else if(event.type == SceneManagerEventTypeTick) { - app->selected_menu_index = variable_item_list_get_selected_item_index(app->var_item_list); - consumed = true; - } - - return consumed; -} - -void wifi_deauther_scene_start_on_exit(void* context) { - WifideautherApp* app = context; - variable_item_list_reset(app->var_item_list); -} diff --git a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_text_input.c b/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_text_input.c deleted file mode 100644 index 2968f4de1..000000000 --- a/applications/plugins/wifi_deauther_v2/scenes/wifi_deauther_scene_text_input.c +++ /dev/null @@ -1,90 +0,0 @@ -#include "../wifi_deauther_app_i.h" - -void wifi_deauther_scene_text_input_callback(void* context) { - WifideautherApp* app = context; - - view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartConsole); -} - -void wifi_deauther_scene_text_input_on_enter(void* context) { - WifideautherApp* app = context; - - if(false == app->is_custom_tx_string) { - // Fill text input with selected string so that user can add to it - size_t length = strlen(app->selected_tx_string); - furi_assert(length < WIFI_deauther_TEXT_INPUT_STORE_SIZE); - bzero(app->text_input_store, WIFI_deauther_TEXT_INPUT_STORE_SIZE); - strncpy(app->text_input_store, app->selected_tx_string, length); - - // Add space - because flipper keyboard currently doesn't have a space - app->text_input_store[length] = ' '; - app->text_input_store[length + 1] = '\0'; - app->is_custom_tx_string = true; - } - - // Setup view - TextInput* text_input = app->text_input; - // Add help message to header - if(0 == strncmp("select aps", app->selected_tx_string, strlen("select aps"))) { - text_input_set_header_text(text_input, "Enter SSID ID to attack"); - } else if(0 == strncmp("select stations", app->selected_tx_string, strlen("select stations"))) { - text_input_set_header_text(text_input, "Enter Station ID to attack"); - } - if(0 == strncmp("deselect aps", app->selected_tx_string, strlen("deselect aps"))) { - text_input_set_header_text(text_input, "Enter SSID ID to remove"); - } else if( - 0 == strncmp("deselect stations", app->selected_tx_string, strlen("deselect stations"))) { - text_input_set_header_text(text_input, "Enter Station ID to remove"); - } else if(0 == strncmp("get settings", app->selected_tx_string, strlen("get settings"))) { - text_input_set_header_text(text_input, "Get setting. Enter for all"); - } else if( - 0 == - strncmp( - "set webinterface false", app->selected_tx_string, strlen("set webinterface false"))) { - text_input_set_header_text(text_input, "Disable PWNED management AP"); - } else if(0 == strncmp("set ssid: pwned", app->selected_tx_string, strlen("set ssid: pwned"))) { - text_input_set_header_text(text_input, "Change management SSID"); - } else if( - 0 == - strncmp( - "set password: deauther", app->selected_tx_string, strlen("set password: deauther"))) { - text_input_set_header_text(text_input, "Change management PWD"); - } else if(0 == strncmp("save settings", app->selected_tx_string, strlen("save settings"))) { - text_input_set_header_text(text_input, "Save Settings"); - } else { - text_input_set_header_text(text_input, "Add command arguments"); - } - text_input_set_result_callback( - text_input, - wifi_deauther_scene_text_input_callback, - app, - app->text_input_store, - WIFI_deauther_TEXT_INPUT_STORE_SIZE, - false); - - view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewTextInput); -} - -///* -bool wifi_deauther_scene_text_input_on_event(void* context, SceneManagerEvent event) { - WifideautherApp* app = context; - bool consumed = false; - - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == WifideautherEventStartConsole) { - // Point to custom string to send - app->selected_tx_string = app->text_input_store; - scene_manager_next_scene(app->scene_manager, WifideautherAppViewConsoleOutput); - consumed = true; - } - } - - return consumed; -} - -void wifi_deauther_scene_text_input_on_exit(void* context) { - WifideautherApp* app = context; - - text_input_reset(app->text_input); -} -//*/ \ No newline at end of file diff --git a/applications/plugins/wifi_deauther_v2/wifi_10px.png b/applications/plugins/wifi_deauther_v2/wifi_10px.png deleted file mode 100644 index c13534660..000000000 Binary files a/applications/plugins/wifi_deauther_v2/wifi_10px.png and /dev/null differ diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_app.c b/applications/plugins/wifi_deauther_v2/wifi_deauther_app.c deleted file mode 100644 index 28fb28d88..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_app.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "wifi_deauther_app_i.h" - -#include -#include -#include - -static bool wifi_deauther_app_custom_event_callback(void* context, uint32_t event) { - furi_assert(context); - WifideautherApp* app = context; - return scene_manager_handle_custom_event(app->scene_manager, event); -} - -static bool wifi_deauther_app_back_event_callback(void* context) { - furi_assert(context); - WifideautherApp* app = context; - return scene_manager_handle_back_event(app->scene_manager); -} - -static void wifi_deauther_app_tick_event_callback(void* context) { - furi_assert(context); - WifideautherApp* app = context; - scene_manager_handle_tick_event(app->scene_manager); -} - -WifideautherApp* wifi_deauther_app_alloc() { - WifideautherApp* app = malloc(sizeof(WifideautherApp)); - - app->gui = furi_record_open(RECORD_GUI); - - app->view_dispatcher = view_dispatcher_alloc(); - app->scene_manager = scene_manager_alloc(&wifi_deauther_scene_handlers, app); - view_dispatcher_enable_queue(app->view_dispatcher); - view_dispatcher_set_event_callback_context(app->view_dispatcher, app); - - view_dispatcher_set_custom_event_callback( - app->view_dispatcher, wifi_deauther_app_custom_event_callback); - view_dispatcher_set_navigation_event_callback( - app->view_dispatcher, wifi_deauther_app_back_event_callback); - view_dispatcher_set_tick_event_callback( - app->view_dispatcher, wifi_deauther_app_tick_event_callback, 100); - - view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); - - app->var_item_list = variable_item_list_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, - WifideautherAppViewVarItemList, - variable_item_list_get_view(app->var_item_list)); - - for(int i = 0; i < NUM_MENU_ITEMS; ++i) { - app->selected_option_index[i] = 0; - } - - app->text_box = text_box_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, WifideautherAppViewConsoleOutput, text_box_get_view(app->text_box)); - app->text_box_store = furi_string_alloc(); - furi_string_reserve(app->text_box_store, WIFI_deauther_TEXT_BOX_STORE_SIZE); - - app->text_input = text_input_alloc(); - view_dispatcher_add_view( - app->view_dispatcher, WifideautherAppViewTextInput, text_input_get_view(app->text_input)); - - scene_manager_next_scene(app->scene_manager, WifideautherSceneStart); - - return app; -} - -void wifi_deauther_app_free(WifideautherApp* app) { - furi_assert(app); - - // Views - view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewVarItemList); - view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewConsoleOutput); - view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewTextInput); - text_box_free(app->text_box); - furi_string_free(app->text_box_store); - text_input_free(app->text_input); - - // View dispatcher - view_dispatcher_free(app->view_dispatcher); - scene_manager_free(app->scene_manager); - - wifi_deauther_uart_free(app->uart); - - // Close records - furi_record_close(RECORD_GUI); - - free(app); -} - -int32_t wifi_deauther_app(void* p) { - furi_hal_power_enable_otg(); - furi_delay_ms(600); - UNUSED(p); - WifideautherApp* wifi_deauther_app = wifi_deauther_app_alloc(); - - wifi_deauther_app->uart = wifi_deauther_uart_init(wifi_deauther_app); - - view_dispatcher_run(wifi_deauther_app->view_dispatcher); - - wifi_deauther_app_free(wifi_deauther_app); - furi_hal_power_disable_otg(); - - return 0; -} diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_app.h b/applications/plugins/wifi_deauther_v2/wifi_deauther_app.h deleted file mode 100644 index bb2f6fbfb..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_app.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct WifideautherApp WifideautherApp; - -#ifdef __cplusplus -} -#endif diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_app_i.h b/applications/plugins/wifi_deauther_v2/wifi_deauther_app_i.h deleted file mode 100644 index bab52f385..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_app_i.h +++ /dev/null @@ -1,69 +0,0 @@ -#pragma once - -#include "wifi_deauther_app.h" -#include "scenes/wifi_deauther_scene.h" -#include "wifi_deauther_custom_event.h" -#include "wifi_deauther_uart.h" - -#include -#include -#include -#include -#include -#include - -#define NUM_MENU_ITEMS (11) - -#define WIFI_deauther_TEXT_BOX_STORE_SIZE (4096) -#define WIFI_deauther_TEXT_INPUT_STORE_SIZE (512) - -struct WifideautherApp { - Gui* gui; - ViewDispatcher* view_dispatcher; - SceneManager* scene_manager; - - char text_input_store[WIFI_deauther_TEXT_INPUT_STORE_SIZE + 1]; - FuriString* text_box_store; - size_t text_box_store_strlen; - TextBox* text_box; - TextInput* text_input; - //Widget* widget; - - VariableItemList* var_item_list; - - WifideautherUart* uart; - int selected_menu_index; - int selected_option_index[NUM_MENU_ITEMS]; - const char* selected_tx_string; - bool is_command; - bool is_custom_tx_string; - bool focus_console_start; - bool show_stopscan_tip; -}; - -// Supported commands: -// https://github.com/justcallmekoko/ESP32deauther/wiki/cli -// Scan -// -> If list is empty, then start a new scanap. (Tap any button to stop.) -// -> If there's a list, provide option to rescan and dump list of targets to select. -// -> Press BACK to go back to top-level. -// Attack -// -> Beacon -// -> Deauth -// -> Probe -// -> Rickroll -// Sniff -// -> Beacon -// -> Deauth -// -> ESP -// -> PMKID -// -> Pwnagotchi -// Channel -// Update -// Reboot - -typedef enum { - WifideautherAppViewVarItemList, - WifideautherAppViewConsoleOutput, - WifideautherAppViewTextInput, -} WifideautherAppView; diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_custom_event.h b/applications/plugins/wifi_deauther_v2/wifi_deauther_custom_event.h deleted file mode 100644 index 142961b1d..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_custom_event.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -typedef enum { - WifideautherEventRefreshConsoleOutput = 0, - WifideautherEventStartConsole, - WifideautherEventStartKeyboard, -} WifideautherCustomEvent; diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.c b/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.c deleted file mode 100644 index 10e73c323..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.c +++ /dev/null @@ -1,98 +0,0 @@ -#include "wifi_deauther_app_i.h" -#include "wifi_deauther_uart.h" - -#include - -#define UART_CH (FuriHalUartIdUSART1) -#define BAUDRATE (115200) - -struct WifideautherUart { - WifideautherApp* app; - FuriThread* rx_thread; - StreamBufferHandle_t rx_stream; - uint8_t rx_buf[RX_BUF_SIZE + 1]; - void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context); -}; - -typedef enum { - WorkerEvtStop = (1 << 0), - WorkerEvtRxDone = (1 << 1), -} WorkerEvtFlags; - -void wifi_deauther_uart_set_handle_rx_data_cb( - WifideautherUart* uart, - void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context)) { - furi_assert(uart); - uart->handle_rx_data_cb = handle_rx_data_cb; -} - -#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone) - -void wifi_deauther_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) { - WifideautherUart* uart = (WifideautherUart*)context; - BaseType_t xHigherPriorityTaskWoken = pdFALSE; - - if(ev == UartIrqEventRXNE) { - xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken); - furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone); - portYIELD_FROM_ISR(xHigherPriorityTaskWoken); - } -} - -static int32_t uart_worker(void* context) { - WifideautherUart* uart = (void*)context; - - uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1); - - while(1) { - uint32_t events = - furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever); - furi_check((events & FuriFlagError) == 0); - if(events & WorkerEvtStop) break; - if(events & WorkerEvtRxDone) { - size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0); - if(len > 0) { - if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app); - } - } - } - - vStreamBufferDelete(uart->rx_stream); - - return 0; -} - -void wifi_deauther_uart_tx(uint8_t* data, size_t len) { - furi_hal_uart_tx(UART_CH, data, len); -} - -WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) { - WifideautherUart* uart = malloc(sizeof(WifideautherUart)); - - furi_hal_console_disable(); - furi_hal_uart_set_br(UART_CH, BAUDRATE); - furi_hal_uart_set_irq_cb(UART_CH, wifi_deauther_uart_on_irq_cb, uart); - - uart->app = app; - uart->rx_thread = furi_thread_alloc(); - furi_thread_set_name(uart->rx_thread, "WifideautherUartRxThread"); - furi_thread_set_stack_size(uart->rx_thread, 1024); - furi_thread_set_context(uart->rx_thread, uart); - furi_thread_set_callback(uart->rx_thread, uart_worker); - - furi_thread_start(uart->rx_thread); - return uart; -} - -void wifi_deauther_uart_free(WifideautherUart* uart) { - furi_assert(uart); - - furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtStop); - furi_thread_join(uart->rx_thread); - furi_thread_free(uart->rx_thread); - - furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL); - furi_hal_console_enable(); - - free(uart); -} \ No newline at end of file diff --git a/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.h b/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.h deleted file mode 100644 index 534c2fdf7..000000000 --- a/applications/plugins/wifi_deauther_v2/wifi_deauther_uart.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "furi_hal.h" - -#define RX_BUF_SIZE (320) - -typedef struct WifideautherUart WifideautherUart; - -void wifi_deauther_uart_set_handle_rx_data_cb( - WifideautherUart* uart, - void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context)); -void wifi_deauther_uart_tx(uint8_t* data, size_t len); -WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app); -void wifi_deauther_uart_free(WifideautherUart* uart); diff --git a/applications/plugins/wifi_scanner/FlipperZeroWiFiModuleDefines.h b/applications/plugins/wifi_scanner/FlipperZeroWiFiModuleDefines.h deleted file mode 100644 index 7b28ebd64..000000000 --- a/applications/plugins/wifi_scanner/FlipperZeroWiFiModuleDefines.h +++ /dev/null @@ -1,17 +0,0 @@ -#define WIFI_MODULE_INIT_VERSION "WFSM_0.1" - -#define MODULE_CONTEXT_INITIALIZATION WIFI_MODULE_INIT_VERSION -#define MODULE_CONTEXT_MONITOR "monitor" -#define MODULE_CONTEXT_SCAN "scan" -#define MODULE_CONTEXT_SCAN_ANIMATION "scan_anim" -#define MODULE_CONTEXT_MONITOR_ANIMATION "monitor_anim" - -#define MODULE_CONTROL_COMMAND_NEXT 'n' -#define MODULE_CONTROL_COMMAND_PREVIOUS 'p' -#define MODULE_CONTROL_COMMAND_SCAN 's' -#define MODULE_CONTROL_COMMAND_MONITOR 'm' -#define MODULE_CONTROL_COMMAND_RESTART 'r' - -#define FLIPPERZERO_SERIAL_BAUD 115200 - -#define NA 0 diff --git a/applications/plugins/wifi_scanner/application.fam b/applications/plugins/wifi_scanner/application.fam deleted file mode 100644 index bc7d352eb..000000000 --- a/applications/plugins/wifi_scanner/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="WiFi_Scanner", - name="[WiFi] Scanner", - apptype=FlipperAppType.EXTERNAL, - entry_point="wifi_scanner_app", - cdefines=["APP_WIFI_SCANNER"], - requires=["gui"], - stack_size=2 * 1024, - order=70, - fap_icon="wifi_10px.png", - fap_category="GPIO", -) diff --git a/applications/plugins/wifi_scanner/wifi_10px.png b/applications/plugins/wifi_scanner/wifi_10px.png deleted file mode 100644 index c13534660..000000000 Binary files a/applications/plugins/wifi_scanner/wifi_10px.png and /dev/null differ diff --git a/applications/plugins/wifi_scanner/wifi_scanner.c b/applications/plugins/wifi_scanner/wifi_scanner.c deleted file mode 100644 index 826048e26..000000000 --- a/applications/plugins/wifi_scanner/wifi_scanner.c +++ /dev/null @@ -1,855 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "FlipperZeroWiFiModuleDefines.h" - -#define WIFI_APP_DEBUG 0 - -#if WIFI_APP_DEBUG -#define APP_NAME_TAG "WiFi_Scanner" -#define WIFI_APP_LOG_I(format, ...) FURI_LOG_I(APP_NAME_TAG, format, ##__VA_ARGS__) -#define WIFI_APP_LOG_D(format, ...) FURI_LOG_D(APP_NAME_TAG, format, ##__VA_ARGS__) -#define WIFI_APP_LOG_E(format, ...) FURI_LOG_E(APP_NAME_TAG, format, ##__VA_ARGS__) -#else -#define WIFI_APP_LOG_I(format, ...) -#define WIFI_APP_LOG_D(format, ...) -#define WIFI_APP_LOG_E(format, ...) -#endif // WIFI_APP_DEBUG - -#define DISABLE_CONSOLE !WIFI_APP_DEBUG - -#define ENABLE_MODULE_POWER 1 -#define ENABLE_MODULE_DETECTION 1 - -#define ANIMATION_TIME 350 - -typedef enum EChunkArrayData { - EChunkArrayData_Context = 0, - EChunkArrayData_SSID, - EChunkArrayData_EncryptionType, - EChunkArrayData_RSSI, - EChunkArrayData_BSSID, - EChunkArrayData_Channel, - EChunkArrayData_IsHidden, - EChunkArrayData_CurrentAPIndex, - EChunkArrayData_TotalAps, - EChunkArrayData_ENUM_MAX -} EChunkArrayData; - -typedef enum EEventType // app internally defined event types -{ EventTypeKey // flipper input.h type -} EEventType; - -typedef struct SPluginEvent { - EEventType m_type; - InputEvent m_input; -} SPluginEvent; - -typedef struct EAccessPointDesc { - FuriString* m_accessPointName; - int16_t m_rssi; - FuriString* m_secType; - FuriString* m_bssid; - unsigned short m_channel; - bool m_isHidden; -} EAccessPointDesc; - -typedef enum EAppContext { - Undefined, - WaitingForModule, - Initializing, - ScanMode, - MonitorMode, - ScanAnimation, - MonitorAnimation -} EAppContext; - -typedef enum EWorkerEventFlags { - WorkerEventReserved = (1 << 0), // Reserved for StreamBuffer internal event - WorkerEventStop = (1 << 1), - WorkerEventRx = (1 << 2), -} EWorkerEventFlags; - -typedef struct SWiFiScannerApp { - Gui* m_gui; - FuriThread* m_worker_thread; - NotificationApp* m_notification; - FuriStreamBuffer* m_rx_stream; - - bool m_wifiModuleInitialized; - bool m_wifiModuleAttached; - - EAppContext m_context; - - EAccessPointDesc m_currentAccesspointDescription; - - unsigned short m_totalAccessPoints; - unsigned short m_currentIndexAccessPoint; - - uint32_t m_prevAnimationTime; - uint32_t m_animationTime; - uint8_t m_animtaionCounter; -} SWiFiScannerApp; - -/////// INIT STATE /////// -static void wifi_scanner_app_init(SWiFiScannerApp* const app) { - app->m_context = Undefined; - - app->m_totalAccessPoints = 0; - app->m_currentIndexAccessPoint = 0; - - app->m_currentAccesspointDescription.m_accessPointName = furi_string_alloc(); - furi_string_set(app->m_currentAccesspointDescription.m_accessPointName, "N/A\n"); - app->m_currentAccesspointDescription.m_channel = 0; - app->m_currentAccesspointDescription.m_bssid = furi_string_alloc(); - furi_string_set(app->m_currentAccesspointDescription.m_bssid, "N/A\n"); - app->m_currentAccesspointDescription.m_secType = furi_string_alloc(); - furi_string_set(app->m_currentAccesspointDescription.m_secType, "N/A\n"); - app->m_currentAccesspointDescription.m_rssi = 0; - app->m_currentAccesspointDescription.m_isHidden = false; - - app->m_prevAnimationTime = 0; - app->m_animationTime = ANIMATION_TIME; - app->m_animtaionCounter = 0; - - app->m_wifiModuleInitialized = false; - -#if ENABLE_MODULE_DETECTION - app->m_wifiModuleAttached = false; -#else - app->m_wifiModuleAttached = true; -#endif -} - -int16_t dBmtoPercentage(int16_t dBm) { - const int16_t RSSI_MAX = -50; // define maximum strength of signal in dBm - const int16_t RSSI_MIN = -100; // define minimum strength of signal in dBm - - int16_t quality; - if(dBm <= RSSI_MIN) { - quality = 0; - } else if(dBm >= RSSI_MAX) { - quality = 100; - } else { - quality = 2 * (dBm + 100); - } - - return quality; -} - -void DrawSignalStrengthBar(Canvas* canvas, int rssi, int x, int y, int width, int height) { - int16_t percents = dBmtoPercentage(rssi); - - u8g2_DrawHLine(&canvas->fb, x, y, width); - u8g2_DrawHLine(&canvas->fb, x, y + height, width); - - if(rssi != NA && height > 0) { - uint8_t barHeight = floor((height / 100.f) * percents); - canvas_draw_box(canvas, x, y + height - barHeight, width, barHeight); - } -} - -static void wifi_module_render_callback(Canvas* const canvas, void* ctx) { - SWiFiScannerApp* app = acquire_mutex((ValueMutex*)ctx, 25); - if(app == NULL) { - return; - } - - canvas_clear(canvas); - - { - switch(app->m_context) { - case Undefined: { - canvas_set_font(canvas, FontPrimary); - - const char* strError = "Something wrong"; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strError) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, - strError); - } break; - case WaitingForModule: -#if ENABLE_MODULE_DETECTION - furi_assert(!app->m_wifiModuleAttached); - if(!app->m_wifiModuleAttached) { - canvas_set_font(canvas, FontSecondary); - - const char* strConnectModule = "Attach WiFi scanner module"; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strConnectModule) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / - 2) /* - (u8g2_GetMaxCharHeight(&canvas->fb) / 2)*/, - strConnectModule); - } -#endif - break; - case Initializing: { - furi_assert(!app->m_wifiModuleInitialized); - if(!app->m_wifiModuleInitialized) { - canvas_set_font(canvas, FontPrimary); - - const char* strInitializing = "Initializing..."; - canvas_draw_str( - canvas, - (u8g2_GetDisplayWidth(&canvas->fb) / 2) - - (canvas_string_width(canvas, strInitializing) / 2), - (u8g2_GetDisplayHeight(&canvas->fb) / 2) - - (u8g2_GetMaxCharHeight(&canvas->fb) / 2), - strInitializing); - } - } break; - case ScanMode: { - uint8_t offsetY = 0; - uint8_t offsetX = 0; - canvas_draw_frame( - canvas, - 0, - 0, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); - - //canvas_set_font(canvas, FontPrimary); - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - uint8_t fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); - - offsetX += 5; - offsetY += fontHeight; - canvas_draw_str( - canvas, - offsetX, - offsetY, - app->m_currentAccesspointDescription.m_isHidden ? - "(Hidden SSID)" : - furi_string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName)); - - offsetY += fontHeight; - - canvas_draw_str( - canvas, - offsetX, - offsetY, - furi_string_get_cstr(app->m_currentAccesspointDescription.m_bssid)); - - canvas_set_font(canvas, FontSecondary); - //u8g2_SetFont(&canvas->fb, u8g2_font_tinytim_tf); - fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); - - offsetY += fontHeight + 1; - - char string[15]; - snprintf( - string, sizeof(string), "RSSI: %d", app->m_currentAccesspointDescription.m_rssi); - canvas_draw_str(canvas, offsetX, offsetY, string); - - offsetY += fontHeight + 1; - - snprintf( - string, sizeof(string), "CHNL: %d", app->m_currentAccesspointDescription.m_channel); - canvas_draw_str(canvas, offsetX, offsetY, string); - - offsetY += fontHeight + 1; - - snprintf( - string, - sizeof(string), - "ENCR: %s", - furi_string_get_cstr(app->m_currentAccesspointDescription.m_secType)); - canvas_draw_str(canvas, offsetX, offsetY, string); - - offsetY += fontHeight; - offsetY -= fontHeight; - - u8g2_SetFont(&canvas->fb, u8g2_font_courB08_tn); - snprintf( - string, - sizeof(string), - "%d/%d", - app->m_currentIndexAccessPoint, - app->m_totalAccessPoints); - offsetX = u8g2_GetDisplayWidth(&canvas->fb) - canvas_string_width(canvas, string) - 5; - canvas_draw_str(canvas, offsetX, offsetY, string); - - canvas_draw_frame( - canvas, - offsetX - 6, - offsetY - u8g2_GetMaxCharHeight(&canvas->fb) - 3, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); - - u8g2_SetFont(&canvas->fb, u8g2_font_open_iconic_arrow_2x_t); - if(app->m_currentIndexAccessPoint != app->m_totalAccessPoints) { - //canvas_draw_triangle(canvas, offsetX - 5 - 20, offsetY + 5, 4, 4, CanvasDirectionBottomToTop); - canvas_draw_str(canvas, offsetX - 0 - 35, offsetY + 5, "\x4C"); - } - - if(app->m_currentIndexAccessPoint != 1) { - //canvas_draw_triangle(canvas, offsetX - 6 - 35, offsetY + 5, 4, 4, CanvasDirectionTopToBottom); - canvas_draw_str(canvas, offsetX - 4 - 20, offsetY + 5, "\x4F"); - } - } break; - case MonitorMode: { - uint8_t offsetY = 0; - uint8_t offsetX = 0; - - canvas_draw_frame( - canvas, - 0, - 0, - u8g2_GetDisplayWidth(&canvas->fb), - u8g2_GetDisplayHeight(&canvas->fb)); - - //canvas_set_font(canvas, FontBigNumbers); - u8g2_SetFont(&canvas->fb, u8g2_font_inb27_mr); - uint8_t fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); - uint8_t fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); - - if(app->m_currentAccesspointDescription.m_rssi == NA) { - offsetX += floor(u8g2_GetDisplayWidth(&canvas->fb) / 2) - fontWidth - 10; - offsetY += fontHeight - 5; - - canvas_draw_str(canvas, offsetX, offsetY, "N/A"); - } else { - offsetX += floor(u8g2_GetDisplayWidth(&canvas->fb) / 2) - 2 * fontWidth; - offsetY += fontHeight - 5; - - char rssi[8]; - snprintf(rssi, sizeof(rssi), "%d", app->m_currentAccesspointDescription.m_rssi); - canvas_draw_str(canvas, offsetX, offsetY, rssi); - } - - //canvas_set_font(canvas, FontPrimary); - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - fontHeight = u8g2_GetMaxCharHeight(&canvas->fb); - fontWidth = u8g2_GetMaxCharWidth(&canvas->fb); - - offsetX = 5; - offsetY = u8g2_GetDisplayHeight(&canvas->fb) - 7 - fontHeight; - canvas_draw_str( - canvas, - offsetX, - offsetY, - furi_string_get_cstr(app->m_currentAccesspointDescription.m_accessPointName)); - - offsetY += fontHeight + 2; - - canvas_draw_str( - canvas, - offsetX, - offsetY, - furi_string_get_cstr(app->m_currentAccesspointDescription.m_bssid)); - - DrawSignalStrengthBar( - canvas, app->m_currentAccesspointDescription.m_rssi, 5, 5, 12, 25); - DrawSignalStrengthBar( - canvas, - app->m_currentAccesspointDescription.m_rssi, - u8g2_GetDisplayWidth(&canvas->fb) - 5 - 12, - 5, - 12, - 25); - } break; - case ScanAnimation: { - uint32_t currentTime = furi_get_tick(); - if(currentTime - app->m_prevAnimationTime > app->m_animationTime) { - app->m_prevAnimationTime = currentTime; - app->m_animtaionCounter += 1; - app->m_animtaionCounter = app->m_animtaionCounter % 3; - } - - uint8_t offsetX = 10; - uint8_t mutliplier = 2; - - for(uint8_t i = 0; i < 3; ++i) { - canvas_draw_disc( - canvas, - offsetX + 30 + 25 * i, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, - 5 * (app->m_animtaionCounter == i ? mutliplier : 1)); - } - - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - //canvas_set_font(canvas, FontPrimary); - const char* message = "Scanning"; - canvas_draw_str( - canvas, - u8g2_GetDisplayWidth(&canvas->fb) / 2 - canvas_string_width(canvas, message) / 2, - 55, - message); - } break; - case MonitorAnimation: { - uint32_t currentTime = furi_get_tick(); - if(currentTime - app->m_prevAnimationTime > app->m_animationTime) { - app->m_prevAnimationTime = currentTime; - app->m_animtaionCounter += 1; - app->m_animtaionCounter = app->m_animtaionCounter % 2; - } - - uint8_t offsetX = 10; - uint8_t mutliplier = 2; - - canvas_draw_disc( - canvas, - offsetX + 30, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, - 5 * (app->m_animtaionCounter == 0 ? mutliplier : 1)); - canvas_draw_disc( - canvas, - offsetX + 55, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, - 5 * (app->m_animtaionCounter == 1 ? mutliplier : 1)); - canvas_draw_disc( - canvas, - offsetX + 80, - u8g2_GetDisplayHeight(&canvas->fb) / 2 - 7, - 5 * (app->m_animtaionCounter == 0 ? mutliplier : 1)); - - u8g2_SetFont(&canvas->fb, u8g2_font_7x13B_tr); - //canvas_set_font(canvas, FontPrimary); - const char* message = "Monitor Mode"; - canvas_draw_str( - canvas, - u8g2_GetDisplayWidth(&canvas->fb) / 2 - canvas_string_width(canvas, message) / 2, - 55, - message); - } break; - default: - break; - } - } - release_mutex((ValueMutex*)ctx, app); -} - -static void wifi_module_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - - SPluginEvent event = {.m_type = EventTypeKey, .m_input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) { - furi_assert(context); - - SWiFiScannerApp* app = context; - - WIFI_APP_LOG_I("uart_echo_on_irq_cb"); - - if(ev == UartIrqEventRXNE) { - WIFI_APP_LOG_I("ev == UartIrqEventRXNE"); - furi_stream_buffer_send(app->m_rx_stream, &data, 1, 0); - furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventRx); - } -} - -static int32_t uart_worker(void* context) { - furi_assert(context); - - SWiFiScannerApp* app = acquire_mutex((ValueMutex*)context, 25); - if(app == NULL) { - return 1; - } - - FuriStreamBuffer* rx_stream = app->m_rx_stream; - - release_mutex((ValueMutex*)context, app); - - while(true) { - uint32_t events = furi_thread_flags_wait( - WorkerEventStop | WorkerEventRx, FuriFlagWaitAny, FuriWaitForever); - furi_check((events & FuriFlagError) == 0); - - if(events & WorkerEventStop) break; - if(events & WorkerEventRx) { - size_t length = 0; - FuriString* receivedString; - receivedString = furi_string_alloc(); - do { - uint8_t data[64]; - length = furi_stream_buffer_receive(rx_stream, data, 64, 25); - if(length > 0) { - WIFI_APP_LOG_I("Received Data - length: %i", length); - - for(uint16_t i = 0; i < length; i++) { - furi_string_push_back(receivedString, data[i]); - } - - //notification_message(app->notification, &sequence_set_only_red_255); - } - } while(length > 0); - if(furi_string_size(receivedString) > 0) { - FuriString* chunk; - chunk = furi_string_alloc(); - size_t begin = 0; - size_t end = 0; - size_t stringSize = furi_string_size(receivedString); - - WIFI_APP_LOG_I("Received string: %s", furi_string_get_cstr(receivedString)); - - FuriString* chunksArray[EChunkArrayData_ENUM_MAX]; - for(uint8_t i = 0; i < EChunkArrayData_ENUM_MAX; ++i) { - chunksArray[i] = furi_string_alloc(); - } - - uint8_t index = 0; - do { - end = furi_string_search_char(receivedString, '+', begin); - - if(end == FURI_STRING_FAILURE) { - end = stringSize; - } - - WIFI_APP_LOG_I("size: %i, begin: %i, end: %i", stringSize, begin, end); - - furi_string_set_strn( - chunk, &furi_string_get_cstr(receivedString)[begin], end - begin); - - WIFI_APP_LOG_I("String chunk: %s", furi_string_get_cstr(chunk)); - - furi_string_set(chunksArray[index++], chunk); - - begin = end + 1; - } while(end < stringSize); - furi_string_free(chunk); - - app = acquire_mutex((ValueMutex*)context, 25); - if(app == NULL) { - return 1; - } - - if(!app->m_wifiModuleInitialized) { - if(furi_string_cmp_str( - chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_INITIALIZATION) == - 0) { - app->m_wifiModuleInitialized = true; - app->m_context = ScanAnimation; - } - - } else { - if(furi_string_cmp_str( - chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_MONITOR) == 0) { - app->m_context = MonitorMode; - } else if( - furi_string_cmp_str( - chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_SCAN) == 0) { - app->m_context = ScanMode; - } else if( - furi_string_cmp_str( - chunksArray[EChunkArrayData_Context], MODULE_CONTEXT_SCAN_ANIMATION) == - 0) { - app->m_context = ScanAnimation; - } else if( - furi_string_cmp_str( - chunksArray[EChunkArrayData_Context], - MODULE_CONTEXT_MONITOR_ANIMATION) == 0) { - app->m_context = MonitorAnimation; - } - - if(app->m_context == MonitorMode || app->m_context == ScanMode) { - furi_string_set( - app->m_currentAccesspointDescription.m_accessPointName, - chunksArray[EChunkArrayData_SSID]); - furi_string_set( - app->m_currentAccesspointDescription.m_secType, - chunksArray[EChunkArrayData_EncryptionType]); - app->m_currentAccesspointDescription.m_rssi = - atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_RSSI])); - furi_string_set( - app->m_currentAccesspointDescription.m_bssid, - chunksArray[EChunkArrayData_BSSID]); - app->m_currentAccesspointDescription.m_channel = - atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_Channel])); - app->m_currentAccesspointDescription.m_isHidden = - atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_IsHidden])); - - app->m_currentIndexAccessPoint = atoi( - furi_string_get_cstr(chunksArray[EChunkArrayData_CurrentAPIndex])); - app->m_totalAccessPoints = - atoi(furi_string_get_cstr(chunksArray[EChunkArrayData_TotalAps])); - } - } - - release_mutex((ValueMutex*)context, app); - - // Clear string array - for(index = 0; index < EChunkArrayData_ENUM_MAX; ++index) { - furi_string_free(chunksArray[index]); - } - } - furi_string_free(receivedString); - } - } - - return 0; -} - -typedef enum ESerialCommand { - ESerialCommand_Next, - ESerialCommand_Previous, - ESerialCommand_Scan, - ESerialCommand_MonitorMode, - ESerialCommand_Restart -} ESerialCommand; - -void send_serial_command(ESerialCommand command) { -#if !DISABLE_CONSOLE - return; -#endif - - uint8_t data[1] = {0}; - - switch(command) { - case ESerialCommand_Next: - data[0] = MODULE_CONTROL_COMMAND_NEXT; - break; - case ESerialCommand_Previous: - data[0] = MODULE_CONTROL_COMMAND_PREVIOUS; - break; - case ESerialCommand_Scan: - data[0] = MODULE_CONTROL_COMMAND_SCAN; - break; - case ESerialCommand_MonitorMode: - data[0] = MODULE_CONTROL_COMMAND_MONITOR; - break; - case ESerialCommand_Restart: - data[0] = MODULE_CONTROL_COMMAND_RESTART; - break; - default: - return; - }; - - furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1); -} - -int32_t wifi_scanner_app(void* p) { - UNUSED(p); - - WIFI_APP_LOG_I("Init"); - - // FuriTimer* timer = furi_timer_alloc(blink_test_update, FuriTimerTypePeriodic, event_queue); - // furi_timer_start(timer, furi_kernel_get_tick_frequency()); - - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(SPluginEvent)); - - SWiFiScannerApp* app = malloc(sizeof(SWiFiScannerApp)); - - wifi_scanner_app_init(app); - -#if ENABLE_MODULE_DETECTION - furi_hal_gpio_init( - &gpio_ext_pc0, - GpioModeInput, - GpioPullUp, - GpioSpeedLow); // Connect to the Flipper's ground just to be sure - //furi_hal_gpio_add_int_callback(pinD0, input_isr_d0, this); - app->m_context = WaitingForModule; -#else - app->m_context = Initializing; -#if ENABLE_MODULE_POWER - furi_hal_power_enable_otg(); -#endif // ENABLE_MODULE_POWER -#endif // ENABLE_MODULE_DETECTION - - ValueMutex app_data_mutex; - if(!init_mutex(&app_data_mutex, app, sizeof(SWiFiScannerApp))) { - WIFI_APP_LOG_E("cannot create mutex\r\n"); - free(app); - return 255; - } - - WIFI_APP_LOG_I("Mutex created"); - - app->m_notification = furi_record_open("notification"); - - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, wifi_module_render_callback, &app_data_mutex); - view_port_input_callback_set(view_port, wifi_module_input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - //notification_message(app->notification, &sequence_set_only_blue_255); - - app->m_rx_stream = furi_stream_buffer_alloc(1 * 1024, 1); - - app->m_worker_thread = furi_thread_alloc(); - furi_thread_set_name(app->m_worker_thread, "WiFiModuleUARTWorker"); - furi_thread_set_stack_size(app->m_worker_thread, 1024); - furi_thread_set_context(app->m_worker_thread, &app_data_mutex); - furi_thread_set_callback(app->m_worker_thread, uart_worker); - furi_thread_start(app->m_worker_thread); - WIFI_APP_LOG_I("UART thread allocated"); - - // Enable uart listener -#if DISABLE_CONSOLE - furi_hal_console_disable(); -#endif - furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD); - furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_on_irq_cb, app); - WIFI_APP_LOG_I("UART Listener created"); - - // Because we assume that module was on before we launched the app. We need to ensure that module will be in initial state on app start - send_serial_command(ESerialCommand_Restart); - - SPluginEvent event; - for(bool processing = true; processing;) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - SWiFiScannerApp* app = (SWiFiScannerApp*)acquire_mutex_block(&app_data_mutex); - -#if ENABLE_MODULE_DETECTION - if(!app->m_wifiModuleAttached) { - if(furi_hal_gpio_read(&gpio_ext_pc0) == false) { - WIFI_APP_LOG_I("Module Attached"); - app->m_wifiModuleAttached = true; - app->m_context = Initializing; -#if ENABLE_MODULE_POWER - furi_hal_power_enable_otg(); -#endif - } - } -#endif // ENABLE_MODULE_DETECTION - - if(event_status == FuriStatusOk) { - if(event.m_type == EventTypeKey) { - if(app->m_wifiModuleInitialized) { - if(app->m_context == ScanMode) { - switch(event.m_input.key) { - case InputKeyUp: - case InputKeyLeft: - if(event.m_input.type == InputTypeShort) { - WIFI_APP_LOG_I("Previous"); - send_serial_command(ESerialCommand_Previous); - } else if(event.m_input.type == InputTypeRepeat) { - WIFI_APP_LOG_I("Previous Repeat"); - send_serial_command(ESerialCommand_Previous); - } - break; - case InputKeyDown: - case InputKeyRight: - if(event.m_input.type == InputTypeShort) { - WIFI_APP_LOG_I("Next"); - send_serial_command(ESerialCommand_Next); - } else if(event.m_input.type == InputTypeRepeat) { - WIFI_APP_LOG_I("Next Repeat"); - send_serial_command(ESerialCommand_Next); - } - break; - default: - break; - } - } - - switch(event.m_input.key) { - case InputKeyOk: - if(event.m_input.type == InputTypeShort) { - if(app->m_context == ScanMode) { - WIFI_APP_LOG_I("Monitor Mode"); - send_serial_command(ESerialCommand_MonitorMode); - } - } else if(event.m_input.type == InputTypeLong) { - WIFI_APP_LOG_I("Scan"); - send_serial_command(ESerialCommand_Scan); - } - break; - case InputKeyBack: - if(event.m_input.type == InputTypeShort) { - switch(app->m_context) { - case MonitorMode: - send_serial_command(ESerialCommand_Scan); - break; - case ScanMode: - processing = false; - break; - default: - break; - } - } else if(event.m_input.type == InputTypeLong) { - processing = false; - } - break; - default: - break; - } - } else { - if(event.m_input.key == InputKeyBack) { - if(event.m_input.type == InputTypeShort || - event.m_input.type == InputTypeLong) { - processing = false; - } - } - } - } - } - -#if ENABLE_MODULE_DETECTION - if(app->m_wifiModuleAttached && furi_hal_gpio_read(&gpio_ext_pc0) == true) { - WIFI_APP_LOG_D("Module Disconnected - Exit"); - processing = false; - app->m_wifiModuleAttached = false; - app->m_wifiModuleInitialized = false; - } -#endif - - view_port_update(view_port); - release_mutex(&app_data_mutex, app); - } - - WIFI_APP_LOG_I("Start exit app"); - - furi_thread_flags_set(furi_thread_get_id(app->m_worker_thread), WorkerEventStop); - furi_thread_join(app->m_worker_thread); - furi_thread_free(app->m_worker_thread); - - WIFI_APP_LOG_I("Thread Deleted"); - - // Reset GPIO pins to default state - furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); - -#if DISABLE_CONSOLE - furi_hal_console_enable(); -#endif - - view_port_enabled_set(view_port, false); - - gui_remove_view_port(gui, view_port); - - // Close gui record - furi_record_close(RECORD_GUI); - furi_record_close("notification"); - app->m_gui = NULL; - - view_port_free(view_port); - - furi_message_queue_free(event_queue); - - furi_stream_buffer_free(app->m_rx_stream); - - delete_mutex(&app_data_mutex); - - // Free rest - free(app); - - WIFI_APP_LOG_I("App freed"); - -#if ENABLE_MODULE_POWER - furi_hal_power_disable_otg(); -#endif - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/wii_ec_anal/LICENSE b/applications/plugins/wii_ec_anal/LICENSE deleted file mode 100644 index 95e544a06..000000000 --- a/applications/plugins/wii_ec_anal/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 BlueChip - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/wii_ec_anal/README.md b/applications/plugins/wii_ec_anal/README.md deleted file mode 100644 index 8d439c7e0..000000000 --- a/applications/plugins/wii_ec_anal/README.md +++ /dev/null @@ -1,234 +0,0 @@ -# [FlipperZero] Wii Extension Controller Protocol Analyser -This Protocol Analyser offers a full Test and Calibrate system for Wii Extension Controllers. - -__Disclaimer:__ *Use of this plugin, and notably connecting an Extension Controller to the FlipperZero is performed entirely at your own risk.* - -# Notes -This plugin has (todate) only been tested with official Nintendo Nunchucks and Classic Controllers - namely Nunchucks and Classic Controllers. - -# Encryption -This plugin has SOME code to handle encryption, but it it unused, untested, and some of it is known to un-work. - -This plugin (currently) only works with Extension Controllers which implement the encryption-bypass strategy. IE. `i2c_write(0xf0, 0x55) ; i2c_write(0xfb, 0x00)` - -If you need this functionality, either raise an Issue or, better still, a Pull Request. - -# Screen: SPLASH -
-The SPLASH Screen is displayed when the Plugin starts. It can be cleared by pressing any key, else it will auto-clear after 3.5 seconds. - -# Screen: WAIT -   

-The WAIT screen will display which pins you need to connect between the flipper and the Wii Extension Controller. - -__Disclaimer:__ Use of this plugin, and notably connecting the Controller to the FlipperZero is performed entirely at your own risk. - -Looking in to the exposed side of the Extension Controller plug, with the notch on the bottom - -| EC Pin # | EC Position | EC Pin ID | Pin Function | FZ GPIO Pin Name | FZ GPIO Pin # | -| :---: | :---: | :---: | :---: | :---: | :---: | -| 1 | top-left | +3v3 | Power | 3v3 | 9 | -| 2 | bottom-left | SCL | i2c clock | C0 | 16 | -| 3 | top-centre | EN | ¿detect? | | | -| 4 | bottom-centre | -x- | -none- | | | -| 5 | top-right | SDA | i2c data | C1 | 15 | -| 6 | bottom-right | Gnd | Power | Gnd | 18 | - -Keys: -* Left - Show splash screen -* Back - exit plugin - -The easiest way to connect a Wii Extension Controller to a FlipperZero is arguably with a ["WiiChuck"](https://www.ebay.co.uk/sch/?_nkw=wiichuck) or a ["Nunchucky"](https://www.solarbotics.com/product/31040)

- - - - - -
WiiChuckNunchucky
- -### ** WARNING ** -Neither the WiiChuck, nor the Nunchucky have a pin polarisation mechanism.
-If you plug the adaptor in the wrong way around you WILL apply voltage to the Controller the wrong way round!!
-I have no idea if THIS WILL PERMANENTLY KILL THE CONTROLLER ...Who wants to try it? - -On all the WiiChucks I have seen: -* The WiiChuck has THREE connectors on one side, and TWO connectors on the other. -* The side with TWO connectors should go against the side of the Controller plug with the big indent. -``` -+-------------+ -| _________ | -| | = = = | | -| |_=_____=_| | <-- notice missing pin -| ___ | -| | | | <-- notice indent -+----+ +----+ -``` -
- -...BUT I *highly* recommend you check the pins on your adaptor to make sure everything goes well. - -I believe the unconnected pin on the top is a "presence detect" function, but I have not (yet) verified this.
-This feature is NOT required by this plugin, as the detection is performed by means of an i2c handshake. - -When a device is connected it will be immediately recognised. If it is not, either: -* The Controller is not correctly connected
-...This may be as simple as a broken wire. -* The controller board in the Controller is faulty.
-...Repair of which is beyond the scope of this document. - -To get the list of "known" Controllers, run `./info.sh`
-As of writing this, that returns: -```c -[PID_UNKNOWN ] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "Unknown Perhipheral", SCENE_DUMP, -[PID_NUNCHUCK ] = { {0x00, 0x00, 0xA4, 0x20, 0x00, 0x00}, "Nunchuck", SCENE_NUNCHUCK, -[PID_CLASSIC ] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x01}, "Classic Controller", SCENE_CLASSIC, -[PID_BALANCE ] = { {0x00, 0x00, 0xA4, 0x20, 0x04, 0x02}, "Balance Board", SCENE_DUMP, -[PID_GH_GUITAR ] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x03}, "Guitar Hero Guitar", SCENE_DUMP, -[PID_GH_DRUMS ] = { {0x01, 0x00, 0xA4, 0x20, 0x01, 0x03}, "Guitar Hero World Tour Drums", SCENE_DUMP, -[PID_TURNTABLE ] = { {0x03, 0x00, 0xA4, 0x20, 0x01, 0x03}, "DJ Hero Turntable", SCENE_DUMP, -[PID_TAIKO_DRUMS] = { {0x00, 0x00, 0xA4, 0x20, 0x01, 0x11}, "Taiko Drum Controller)", SCENE_DUMP, - -``` - -You can see that there are EIGHT known devices. One is the default for an unknown controller; SEVEN devices are known by name; and TWO (of those seven) have bespoke "scenes" (ie. SCENE_NUNCHUCK & SCENE_CLASSIC). - -# Screen: NUNCHUCK - MAIN -
-When you connect a Nunchuck, you will see a screen displaying: -* Accelerometer{X,Y,Z} values -* Joystick{X,Y} values -* Joystick graphic -* Button{C,Z} - -Keys: -* Left - Go to the DUMP screen -* Right - Go to the NUNCHUCK_ACC accelerometers screen -* Up/Down/OK - [qv. Peak Meters] -* Short-Back - Reset controller -* Long-Back - Exit plugin - -# Screen: NUNCHUCK - ACCELEROMETERS - -   
- -| Axis | Movement | Lower | Higher | -| :---: | :---: | :---: | :---: | -| X | Left / Right | Left | Right | -| Y | Fwd / Bkwd | Fwd | Bkwd | -| Z | Down / Up | Down | Up | - -* Movement in the direction of an axis changes that axis reading -* Twisting/tilting around an axis changes the other two readings -* EG. - * Move left (along the X axis) will effect X - * Turn left (a rotation around the Y axis) will effect X and Z - -Keys: -* Left - go to the main NUNCHUCK screen -* Up - * Auto-Pause Disabled --> Enable Auto-Pause - * Paused at the end of a page --> Restart scanner - * Running with Auto-Pause Enabled --> Disable Auto-Pause -* Nunchuck-Z - Toggle pause -* Nunchuck-C - Toggle auto-pause -* Long-OK - Enter Software Calibration mode [qv. Calibration] - * Calibration mode on the Accelerometer screen will ONLY calibrate the accelerometer -* Short-OK - Leave Software Calibration mode *and* Calibrate CENTRE position(s) -* Short-Back - Reset controller -* Long-Back - Exit plugin - -NB. Code DOES exist to scroll the display, but the LCD refresh rate is too low, and it looks awful - -# Screen: CLASSIC -
-When you connect a Classic Controller [Pro], you will see a screen displaying a Classic Controller -* The Classic Controller will animate in line with controller events -* The scan rate is set to 30fps, but in reality there is a bit of lag with the LCD screen, so YMMV. - -Keys: -* Left - go to the DUMP screen -* Right - show analogue readings (Left to hide them again) -* Up/Down/OK - [qv. Peak Meters] -* Short-Back - Reset controller -* Long-Back - Exit plugin - -# Screen: DUMP -
-The Dump screen will show you the raw readings from the device.
-If you connect a device which does not have a bespoke `_decode()` function (etc.), you will see (only) this screen. -* SID - String ID - human-readable name (from the `info` table) -* PID - Peripheral ID - The 6 bytes which identify the device. -* Cal - Calibration data - 16 bytes -* The bottom row of hex shows the SIX bytes of Controller data - * Below each hex digit is the binary representation of that digit - * By example. With a Nunchuck connected, click the Z button, and watch the bit on the far right - -Keys: -* Right - return to controller-specific screen (if there is one) -* Short-Back - Reset controller -* Long-Back - Exit plugin - -# Peak Meters (Calibration values) - -On any Controller-specific screen with a Peak/Trough menu displayed: -* Up - [toggle] only show peak values -* Down - [toggle] only show trough values -* Long-OK - Enter Software Calibration mode [qv. Calibration] -* Short-OK - Leave Software Calibration mode / Calibrate CENTRE position(s) - -# Calibration -
- -* __This project handles Calibration of Analogue Controls, but has NO understanding of Accelerometer values (yet).__ - -Digital buttons do NOT require Calibration. - -Some Calibration data is calculated at the factory, and stored in memory (¿OTP?) on the Controller. - -Each device has a different way to interpret the Calibration Data.
-EG. A Nunchuck has one joystick, and an accelerometer ...whereas a Classic Controller has 2 joysticks and 2 analogue buttons. - -I have personally found the calibration data to be inaccurate (when compared to actual readings), I guess Controllers drift over the years‽ -If the factory-values LIMIT movement, this is easily resolved - by expanding them on-the-fly.
-BUT, I have seen Controllers with factory calibration data that suggests the limits are FURTHER than the joystick can reach ...and this requires a full re-calibration of the Controller! - -Probably the best way to calibrate is to: -* Take a/some reading(s) while the Controller is 'at rest', IE. perfectly still and level. -* Move the Controller to all extremes and store the extreme {peak/trough} values. - -Nintendo (allegedly) take the 'at rest' reading immediately after the Controller is connected, and a 're-calibration' can be performed at any time by pressing {`A`, `B`, `+`, `-`} at the same time, for at least 3 seconds. Although I have no details on what this actually does. - -### This tool calibrates as such: -* When the Controller is first recognised - * The factory Calibration data is used to decide the Centre/Middle position and extreme values (eg. far-left & far-right) for each analogue Control -* Long-OK button press (on the FlipperZero) ...Do NOT touch ANY of the analogue controllers while you are pressing Long-OK - * Start the calibrate button flashing - * Take the current reading as the Centre position - * Set the range limits to "no range" - * You must now move the Control between its extremes, so the code can work out the new Calibration/range/peak+trough values - * When done, press Short-OK to end Software Calibration mode -* Short-OK button press (on the FlipperZero) ...Do NOT touch ANY of the analogue controllers while you are pressing Short-OK - * Stop the calibrate button flashing - * Calibrate the centre position of all analogue controls (accelerometers not supported (yet)) - -# Screen: DEBUG -
-On any screen (except SPLASH) you may press Long-Down to enter Debug mode. - -You can (at any time) attach to the FlipperZero (via USB) with a serial console {`minicom`, `putty`, whatever} and start the `log` function to see the debug messages. - -When you enter the DEBUG screen, the real-time scanner will be stopped. And the following keys made available: -* Up - Attempt to initialise the attached Controller -* OK - Take a reading from the attached Controller -* Long-Down - Restart the real-time scanner and return to the WAIT screen - -You can limit the messages at compile-time [see `./info.sh`], or at runtime [FZ->Settings->System->LogLevel]
- -[This is probably irrelevant since the introduction of FAP support]
-If you have memory issues, limiting the messages at compile-time will make the plugin smaller.
-But (¿obviously?) the more you limit the messsages, the less debug information will be sent to the logger. - -# TODO - -* FZ Bug: At the time of writing this, there are problems with the i2c FZ functions [qv `i2c_workaround.c`] - diff --git a/applications/plugins/wii_ec_anal/README.txt b/applications/plugins/wii_ec_anal/README.txt deleted file mode 100644 index e7ebe7a4c..000000000 --- a/applications/plugins/wii_ec_anal/README.txt +++ /dev/null @@ -1,67 +0,0 @@ - ,-------. ----( Files )--- - `-------' - - README.md - User Manual : Body [github markdown] - _images/ - User Manual : Images - _images/GIMP/ - User Manual : GIMP image masters - - LICENSE - Tech Docs : MIT Licence file - README.txt - Tech Docs : Dev notes - notes.txt - Tech Docs : Random dev notes - info.sh - Tech Docs : Retrieve info from source code - - application.fam - FAP : Header file - WiiEC.png - FAP : Icon {10x10} - - gfx/ - Analyser : Images [generated by bc_image_tool] - wii_anal.c|h - Analyser : Main application - wii_anal_ec.c|h - Analyser : Extension controller actions - wii_anal_keys.c|h - Analyser : Keyboard handling - wii_anal_lcd.c|h - Analyser : LCD handling - - i2c_workaround.h - Temporary workaround for i2c bug in FZ code - err.h - Errors - bc_logging.h - Logging macros - especially LOG_LEVEL - - wii_i2c.c|h - i2c functionality - - wii_ec.c|h - Extension Controller basic functions - wii_ec_macros.h - Bespoke Extension Controller handy-dandy MACROs - wii_ec_classic.c|h - EC: Classic Controller Pro scene - wii_ec_nunchuck.c|h - EC: Nunchuck scene - wii_ec_udraw.c|h - EC: UDraw scene - not written - - ,----------------------------------. ----( Adding a new Extension Controller )--- - `----------------------------------' - -//! I'll finish this when I write the UDraw code - -Create a new Extension Controller called "mydev" - -Create wii_ec_mydev.c and wii_ec_mydev.h - -In wii_ec_mydev.c|h - Create the functions [& prototypes] - bool mydev_init (wiiEC_t* const) ; // Additional initialisation code - void mydev_decode (wiiEC_t* const) ; // Decode controller input data - void mydev_msg (wiiEC_t* const, FuriMessageQueue* const) ; // Put event messages in the event queue - void mydev_calib (wiiEC_t* const, ecCalib_t) ; // Controller calibration function - void mydev_show (Canvas* const, state_t* const) ; // Scene LCD display - bool mydev_key (const eventMsg_t* const, state_t* const) ; // Scene key controls - -In wii_ec.h - Include the new header - #include "wii_ec_mydev.h" - Add a perhipheral id to enum ecPid - PID_MYDEV - -In wii_anal.h - As a scene name to enum scene - SCENE_MYDEV - -In wii_ec.c - Add the device definition to the ecId[] array - [PID_MYDEV] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, "My Device", SCENE_MYDEV, - mydev_init, mydev_decode, mydev_msg, mydev_calib, mydev_show, mydev_key }, diff --git a/applications/plugins/wii_ec_anal/WiiEC.png b/applications/plugins/wii_ec_anal/WiiEC.png deleted file mode 100644 index 6e1afcb0c..000000000 Binary files a/applications/plugins/wii_ec_anal/WiiEC.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_image_tool/LICENSE b/applications/plugins/wii_ec_anal/_image_tool/LICENSE deleted file mode 100644 index 95e544a06..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 BlueChip - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/applications/plugins/wii_ec_anal/_image_tool/README b/applications/plugins/wii_ec_anal/_image_tool/README deleted file mode 100644 index 979605a08..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/README +++ /dev/null @@ -1,30 +0,0 @@ -1. Prepare the image - a. Open your *black and white* image in GIMP - b. File -> Export As - filename: EXAMPLE.c - Type : "C source code" - [Export] - prefixed name: gimp_image - Comment : - [x] Use GLib types - [ ] <> - Opacity : 100% - [Export] - -2. Prepare conversion tool [stored in (eg.) /path/] - a. cp _convert*.* /path/ - b. cp EXAMPLE.c /path/ - -3. Run the conversion tool - a. cd /path/ - b. ./_convert.sh EXAMPLE.c - -4. All being well, you will see an ascii version of your image. - If not, then you're gonna have to submit a bug report - -5. You should now have a directory called img_/ - In that directory should be - img_EXAMPLE.c - The data for your new image - img_*.c - The data for other images - images.h - A header for ALL images that have been created in this directory - images.c - A sample FlipperZero show() function [not optimised] diff --git a/applications/plugins/wii_ec_anal/_image_tool/_convert.c b/applications/plugins/wii_ec_anal/_image_tool/_convert.c deleted file mode 100644 index 57deeb083..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/_convert.c +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char* argv[]) { - const unsigned char* pp = NULL; - uint32_t pix = 0; - int bit = 0; - - uint8_t b = 0; - uint8_t bcnt = 0; - - unsigned int lcnt = 0; - static const int lmax = 16; // max hex values per line - - uint8_t* buf = NULL; - uint8_t* bp = NULL; - unsigned int blen = 0; - - uint8_t* cmp = NULL; - uint8_t* cp = NULL; - unsigned int clen = 0; - uint8_t ctag = 0xFF; - uint32_t tag[256] = {0}; - uint32_t tmax = UINT32_MAX; - - unsigned int x, y, z; - - const char* name = argv[1]; - FILE* fh = fopen(argv[2], "wb"); - - uint32_t white = 0xFF; - - int rv = 0; // assume success - - // allocate buffers - blen = ((img.w * img.h) + 0x7) >> 3; - bp = (buf = calloc(blen + 1, 1)); - cp = (cmp = calloc(blen + 4, 1)); - - // sanity check - if(!fh || !buf || !cmp) { - printf("! fopen() or malloc() fail.\n"); - rv = 255; - goto bail; - } - - // Find white value - for(x = 1; x < img.bpp; x++) white = (white << 8) | 0xFF; - - // build bit pattern - // create the comment as we go - for(pp = img.b, y = 0; y < img.h; y++) { - fprintf(fh, "// "); - for(x = 0; x < img.w; x++) { - // read pixel - for(pix = 0, z = 0; z < img.bpp; pix = (pix << 8) | *pp++, z++) - ; - // get bit and draw - if(pix < white) { - b = (b << 1) | 1; - fprintf(fh, "##"); - } else { - b <<= 1; - fprintf(fh, ".."); - } - // got byte - if((++bcnt) == 8) { - *bp++ = b; - tag[b]++; - bcnt = (b = 0); - } - } - fprintf(fh, "\n"); - } - fprintf(fh, "\n"); - // padding - if(bcnt) { - b <<= (bcnt = 8 - bcnt); - *bp++ = b; - tag[b]++; - } - // Kill the compression - *bp = ~bp[-1]; // https://youtube.com/clip/Ugkx-JZIr16hETy7hz_H6yIdKPtxVe8C5w_V - - // Byte run length compression - // Find a good tag - for(x = 0; tmax && (x < 256); x++) { - if(tag[x] < tmax) { - tmax = tag[x]; - ctag = x; - } - } - - // compress the data - for(bp = buf, x = 0; (clen < blen) && (x < blen); x++) { - // need at least 4 the same to be worth it - // must compress tag (if it occurs) - if((bp[x] == bp[x + 1]) && (bp[x] == bp[x + 2]) && (bp[x] == bp[x + 3]) || - (bp[x] == ctag)) { - for(y = 1; (y < 255) && (bp[x] == bp[x + y]); y++) - ; - *cp++ = ctag; // tag - *cp++ = y; // length - *cp++ = bp[x]; // byte - x += y - 1; - clen += 3; - } else { - *cp++ = bp[x]; - clen++; - } - } - - // create struct - fprintf(fh, "#include \"images.h\"\n\n"); - fprintf(fh, "const image_t img_%s = { %d, %d, ", name, img.w, img.h); - - if(clen < blen) { // dump compressed? - fprintf( - fh, - "true, %d, 0x%02X, { // orig:%d, comp:%.2f%%\n\t", - clen, - ctag, - blen, - 100.0 - ((clen * 100.0) / blen)); - for(x = 0; x < clen; x++) - if(x == clen - 1) - fprintf(fh, "0x%02X\n}};\n", cmp[x]); - else - fprintf(fh, "0x%02X%s", cmp[x], (!((x + 1) % 16)) ? ",\n\t" : ", "); - - } else { // dump UNcompressed - fprintf(fh, "false, %d, 0, {\n\t", blen); - for(x = 0; x < blen; x++) - if(x == blen - 1) - fprintf(fh, "0x%02X\n}};\n", buf[x]); - else - fprintf(fh, "0x%02X%s", buf[x], (!((x + 1) % 16)) ? ",\n\t" : ", "); - } - -bail: - if(fh) fclose(fh); - if(buf) free(buf); - if(cmp) free(cmp); - - return rv; -} diff --git a/applications/plugins/wii_ec_anal/_image_tool/_convert.sh b/applications/plugins/wii_ec_anal/_image_tool/_convert.sh deleted file mode 100644 index aaa7977b5..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/_convert.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash - -[ -z $1 ] && { - echo "Specify an image" - echo "gimp -> export -> c source file -> [x] gunit names" - exit 2 -} - -echo $* - -for N in $* ; do - - [ ! -f $N ] && { - echo "!! File missing $N" - continue - } - - # filename (sans extension) - FN=$(basename -- "$N") - EXT="${FN##*.}" - NAME="${FN%.*}" - - OUTDIR=img_/ - mkdir -p ${OUTDIR} - - HDR=${OUTDIR}/images.h - SRC=${OUTDIR}/images.c - - OUT=${OUTDIR}/img_${NAME}.c - - echo -e "\n¦${N}¦ == ¦${NAME}¦ -> ¦${OUT}¦" - - TESTX=test_${NAME} - TESTC=test_${NAME}.c - - # compile name - CONV=${NAME}_ - - # clean up gimp output - sed -e "s/gimp_image/img/g" \ - -e 's/guint8/unsigned char/g' \ - -e 's/width/w/g' \ - -e 's/height/h/g' \ - -e 's/bytes_per_pixel/bpp/g' \ - -e 's/pixel_data/b/g' \ - -e 's/guint/unsigned int/g' \ - $N \ - | grep -v ^/ \ - | grep -v ^$ \ - > ${CONV}.c - - # append conversion code - cat _convert.c >> ${CONV}.c - - # compile & run converter - rm -f ${CONV} - gcc ${CONV}.c -DIMGTEST -o ${CONV} - ./${CONV} ${NAME} ${OUT} - rm -f ${CONV} ${CONV}.c - - # (create &) update header - [[ ! -f ${HDR} ]] && cp _convert_images.h ${HDR} - sed -i "/ img_${NAME};/d" ${HDR} - sed -i "s#//\[TAG\]#//\[TAG\]\nextern const image_t img_${NAME};#" ${HDR} - - # sample FZ code - [[ ! -f images.c ]] && cp _convert_images.c ${SRC} - - # test - ROOT=${PWD} - pushd ${OUTDIR} >/dev/null - sed "s/zzz/${NAME}/" ${ROOT}/_convert_test.c > ${TESTC} - rm -f ${TESTX} - gcc ${TESTC} ${OUT##*/} -DIMGTEST -o ${TESTX} - ./${TESTX} - rm -f ${TESTX} ${TESTC} - popd >/dev/null - -done diff --git a/applications/plugins/wii_ec_anal/_image_tool/_convert_images.c b/applications/plugins/wii_ec_anal/_image_tool/_convert_images.c deleted file mode 100644 index e8ab899f7..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/_convert_images.c +++ /dev/null @@ -1,137 +0,0 @@ -#include // GUI (screen/keyboard) API - -#include "images.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -static Canvas* _canvas; -static uint8_t _tlx; -static uint8_t _tly; - -static uint8_t _x; -static uint8_t _y; - -static const image_t* _img; - -static bool _blk; -static Color _set; -static Color _clr; - -//+============================================================================ -static void _showByteSet(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if(b & m) // plot only SET bits - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -static void _showByteClr(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if(!(b & m)) // plot only CLR bits - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -static void _showByteAll(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if((!!(b & m)) ^ _blk) { // Change colour only when required - canvas_set_color(_canvas, ((b & m) ? _set : _clr)); - _blk = !_blk; - } - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -// available modes are SHOW_SET_BLK - plot image pixels that are SET in BLACK -// SHOW_XOR - same as SET_BLACK -// SHOW_SET_WHT - plot image pixels that are SET in WHITE -// SHOW_CLR_BLK - plot image pixels that are CLEAR in BLACK -// SHOW_CLR_WHT - plot image pixels that are CLEAR in WHITE -// SHOW_ALL - plot all images pixels as they are -// SHOW_ALL_INV - plot all images pixels inverted -// -void show( - Canvas* const canvas, - const uint8_t tlx, - const uint8_t tly, - const image_t* img, - const showMode_t mode) { - void (*fnShow)(const uint8_t) = NULL; - - const uint8_t* bp = img->data; - - // code size optimisation - switch(mode & SHOW_INV_) { - case SHOW_NRM_: - _set = ColorBlack; - _clr = ColorWhite; - break; - - case SHOW_INV_: - _set = ColorWhite; - _clr = ColorBlack; - break; - - case SHOW_BLK_: - canvas_set_color(canvas, ColorBlack); - break; - - case SHOW_WHT_: - canvas_set_color(canvas, ColorWhite); - break; - } - switch(mode & SHOW_INV_) { - case SHOW_NRM_: - case SHOW_INV_: - fnShow = _showByteAll; - canvas_set_color(canvas, ColorWhite); - _blk = 0; - break; - - case SHOW_BLK_: - case SHOW_WHT_: - switch(mode & SHOW_ALL_) { - case SHOW_SET_: - fnShow = _showByteSet; - break; - case SHOW_CLR_: - fnShow = _showByteClr; - break; - } - break; - } - furi_check(fnShow); - - // I want nested functions! - _canvas = canvas; - _img = img; - _tlx = tlx; - _tly = tly; - _x = 0; - _y = 0; - - // Compressed - if(img->c) { - for(unsigned int i = 0; i < img->len; i++, bp++) { - // Compressed data? {tag, length, value} - if(*bp == img->tag) { - for(uint16_t c = 0; c < bp[1]; c++) fnShow(bp[2]); - bp += 3 - 1; - i += 3 - 1; - - // Uncompressed byte - } else { - fnShow(*bp); - } - } - - // Not compressed - } else { - for(unsigned int i = 0; i < img->len; i++, bp++) fnShow(*bp); - } -} diff --git a/applications/plugins/wii_ec_anal/_image_tool/_convert_images.h b/applications/plugins/wii_ec_anal/_image_tool/_convert_images.h deleted file mode 100644 index 1743cb409..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/_convert_images.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef IMAGES_H_ -#define IMAGES_H_ - -#include -#include - -//----------------------------------------------------------------------------- ---------------------------------------- -typedef enum showMode { - // {INV:--:WHT:BLK::--:--:CLR:SET} - SHOW_SET_ = 0x01, - SHOW_CLR_ = 0x02, - SHOW_ALL_ = SHOW_SET_ | SHOW_CLR_, - - SHOW_BLK_ = 0x10, - SHOW_WHT_ = 0x20, - SHOW_NRM_ = 0x00, - SHOW_INV_ = SHOW_BLK_ | SHOW_WHT_, - - SHOW_SET_BLK = SHOW_SET_ | SHOW_BLK_, - SHOW_SET_WHT = SHOW_SET_ | SHOW_WHT_, - - SHOW_CLR_BLK = SHOW_CLR_ | SHOW_BLK_, - SHOW_CLR_WHT = SHOW_CLR_ | SHOW_WHT_, - - SHOW_ALL = SHOW_ALL_ | SHOW_NRM_, - SHOW_ALL_INV = SHOW_ALL_ | SHOW_INV_, -} showMode_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -typedef struct image { - uint8_t w; // width - uint8_t h; // height - bool c; // compressed? - uint16_t len; // image data length - uint8_t tag; // rle tag - uint8_t data[]; // image data -} image_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -//[TAG] - -//----------------------------------------------------------------------------- ---------------------------------------- -#ifndef IMGTEST -#include -void show( - Canvas* const canvas, - const uint8_t tlx, - const uint8_t tly, - const image_t* img, - const showMode_t mode); -#endif - -#endif //IMAGES_H_ diff --git a/applications/plugins/wii_ec_anal/_image_tool/_convert_test.c b/applications/plugins/wii_ec_anal/_image_tool/_convert_test.c deleted file mode 100644 index fdc2ee946..000000000 --- a/applications/plugins/wii_ec_anal/_image_tool/_convert_test.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#include "images.h" - -//----------------------------------------------------------------------------- -// This will be the plot function out of your graphics library -// -#define PLOT(x, y, c) \ - do { \ - printf("%s", (c ? "#" : ".")); \ - if(x == img->w - 1) printf("\n"); \ - } while(0) - -//+============================================================================ -// The pain we endure to avoid code duplication cleanly -// -#define PLOTBYTE(b) \ - do { \ - for(uint8_t m = 0x80; m; m >>= 1) { \ - PLOT(x, y, (b & m)); \ - if(((++x) == img->w) && !(x = 0) && ((++y) == img->h)) break; \ - } \ - } while(0) - -void show(const image_t* img) { - // Some variables - const uint8_t* bp = img->data; - unsigned int x = 0; - unsigned int y = 0; - - // Compressed - if(img->c) { - for(unsigned int i = 0; i < img->len; i++, bp++) { - // Compressed data? {tag, length, value} - if(*bp == img->tag) { - for(uint16_t c = 0; c < bp[1]; c++) PLOTBYTE(bp[2]); - bp += 3 - 1; - i += 3 - 1; - - // Uncompressed byte - } else { - PLOTBYTE(*bp); - } - } - - // Not compressed - } else { - for(unsigned int i = 0; i < img->len; i++, bp++) PLOTBYTE(*bp); - } -} - -#undef PLOTBYTE - -//+============================================================================ -int main(void) { - show(&img_zzz); - return 0; -} diff --git a/applications/plugins/wii_ec_anal/_images/CLASSIC.png b/applications/plugins/wii_ec_anal/_images/CLASSIC.png deleted file mode 100644 index aa5318b33..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/CLASSIC.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/CLASSIC_N.png b/applications/plugins/wii_ec_anal/_images/CLASSIC_N.png deleted file mode 100644 index 24f4ac225..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/CLASSIC_N.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/DEBUG.png b/applications/plugins/wii_ec_anal/_images/DEBUG.png deleted file mode 100644 index bca35c693..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/DEBUG.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/DUMP.png b/applications/plugins/wii_ec_anal/_images/DUMP.png deleted file mode 100644 index dc9328aab..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/DUMP.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/Nunchuck_acc.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/Nunchuck_acc.xcf deleted file mode 100644 index 67f70139e..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/Nunchuck_acc.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/RIP.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/RIP.xcf deleted file mode 100644 index 0058fe9c8..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/RIP.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/Wiring.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/Wiring.xcf deleted file mode 100644 index aa8078db8..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/Wiring.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/classic.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/classic.xcf deleted file mode 100644 index 6fd152675..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/classic.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/csLogo.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/csLogo.xcf deleted file mode 100644 index f4e33844a..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/csLogo.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/fonts.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/fonts.xcf deleted file mode 100644 index d05d03fc7..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/fonts.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/frame.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/frame.xcf deleted file mode 100644 index 31705cf72..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/frame.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/port.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/port.xcf deleted file mode 100644 index 10fcd2de2..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/port.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/GIMP/social.xcf b/applications/plugins/wii_ec_anal/_images/GIMP/social.xcf deleted file mode 100644 index 377eaa63b..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/GIMP/social.xcf and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/NUNCHUCK.png b/applications/plugins/wii_ec_anal/_images/NUNCHUCK.png deleted file mode 100644 index bc31ae386..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/NUNCHUCK.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_acc.png b/applications/plugins/wii_ec_anal/_images/NUNCHUCK_acc.png deleted file mode 100644 index 895c85e4c..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_acc.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_anal.png b/applications/plugins/wii_ec_anal/_images/NUNCHUCK_anal.png deleted file mode 100644 index e821d7ee2..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_anal.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.gif b/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.gif deleted file mode 100644 index 72d807a54..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.gif and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.png b/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.png deleted file mode 100644 index f9d34bb93..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/NUNCHUCK_cal.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/Nunchucky.png b/applications/plugins/wii_ec_anal/_images/Nunchucky.png deleted file mode 100644 index 3af395da6..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/Nunchucky.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/RIP.png b/applications/plugins/wii_ec_anal/_images/RIP.png deleted file mode 100644 index 0acfe0c00..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/RIP.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/SPLASH.png b/applications/plugins/wii_ec_anal/_images/SPLASH.png deleted file mode 100644 index a5c3f093a..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/SPLASH.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/WAIT.png b/applications/plugins/wii_ec_anal/_images/WAIT.png deleted file mode 100644 index 776edc3f1..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/WAIT.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/WiiChuck.png b/applications/plugins/wii_ec_anal/_images/WiiChuck.png deleted file mode 100644 index 532ce3096..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/WiiChuck.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/Wiring.png b/applications/plugins/wii_ec_anal/_images/Wiring.png deleted file mode 100644 index 300c07ee4..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/Wiring.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/plug.png b/applications/plugins/wii_ec_anal/_images/plug.png deleted file mode 100644 index c418f43b1..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/plug.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/_images/social.png b/applications/plugins/wii_ec_anal/_images/social.png deleted file mode 100644 index 1d3eddcc5..000000000 Binary files a/applications/plugins/wii_ec_anal/_images/social.png and /dev/null differ diff --git a/applications/plugins/wii_ec_anal/application.fam b/applications/plugins/wii_ec_anal/application.fam deleted file mode 100644 index 42ed7e979..000000000 --- a/applications/plugins/wii_ec_anal/application.fam +++ /dev/null @@ -1,36 +0,0 @@ -# qv. https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppManifests.md - -App( - # --- App Info - appid="Wii_EC_Analyser", - name="Wii EC Analyser", - - # --- Entry point - apptype=FlipperAppType.EXTERNAL, - entry_point="wii_ec_anal", - - # --- Interaction - cdefines=["APP_WII_EC_ANAL"], - requires=[ - "gui", - ], - -# conflicts="", -# sdk_headers="", - - # --- Run-time info - stack_size=2 * 1024, - order=20, - - # --- FAP details - sources=["wii_*.c", "gfx/*.c"], - -# fap_weburl="https://github.com/csBlueChip/FlipperZero_plugin_WiiChuck/", -# fap_author="BlueChip", - -# fap_description="Wii Extension Controller Protocol Analyser", -# fap_version=(1,0), - - fap_icon="WiiEC.png", - fap_category="Misc", -) diff --git a/applications/plugins/wii_ec_anal/bc_logging.h b/applications/plugins/wii_ec_anal/bc_logging.h deleted file mode 100644 index 73dda80bd..000000000 --- a/applications/plugins/wii_ec_anal/bc_logging.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef BC_LOGGING_H_ -#define BC_LOGGING_H_ - -#include -#include "err.h" // appName - -//! WARNING: There is a bug in Furi such that if you crank LOG_LEVEL up to 6=TRACE -//! AND you have menu->settings->system->logLevel = trace -//! THEN this program will cause the FZ to crash when the plugin exits! -#define LOG_LEVEL 4 - -//----------------------------------------------------------------------------- ---------------------------------------- -// The FlipperZero Settings->System menu allows you to set the logging level at RUN-time -// ... LOG_LEVEL lets you limit it at COMPILE-time -// -// FURI logging has 6 levels (numbered 1 thru 6} -// 1. None -// 2. Errors FURI_LOG_E -// 3. Warnings FURI_LOG_W -// 4. Information FURI_LOG_I -// 5. Debug FURI_LOG_D -// 6. Trace FURI_LOG_T -// -// --> furi/core/log.h -// - -// The FlipperZero Settings->System menu allows you to set the logging level at RUN-time -// This lets you limit it at COMPILE-time -#ifndef LOG_LEVEL -#define LOG_LEVEL 6 // default = full logging -#endif - -#if(LOG_LEVEL < 2) -#undef FURI_LOG_E -#define FURI_LOG_E(tag, fmt, ...) -#endif - -#if(LOG_LEVEL < 3) -#undef FURI_LOG_W -#define FURI_LOG_W(tag, fmt, ...) -#endif - -#if(LOG_LEVEL < 4) -#undef FURI_LOG_I -#define FURI_LOG_I(tag, fmt, ...) -#endif - -#if(LOG_LEVEL < 5) -#undef FURI_LOG_D -#define FURI_LOG_D(tag, fmt, ...) -#endif - -#if(LOG_LEVEL < 6) -#undef FURI_LOG_T -#define FURI_LOG_T(tag, fmt, ...) -#endif - -//---------------------------------------------------------- -// Logging helper macros -// -#define ERROR(fmt, ...) FURI_LOG_E(appName, fmt __VA_OPT__(, ) __VA_ARGS__) -#define WARN(fmt, ...) FURI_LOG_W(appName, fmt __VA_OPT__(, ) __VA_ARGS__) -#define INFO(fmt, ...) FURI_LOG_I(appName, fmt __VA_OPT__(, ) __VA_ARGS__) -#define DEBUG(fmt, ...) FURI_LOG_D(appName, fmt __VA_OPT__(, ) __VA_ARGS__) -#define TRACE(fmt, ...) FURI_LOG_T(appName, fmt __VA_OPT__(, ) __VA_ARGS__) - -#define ENTER TRACE("(+) %s", __func__) -#define LEAVE TRACE("(-) %s", __func__) - -#endif //BC_LOGGING_H_ diff --git a/applications/plugins/wii_ec_anal/err.h b/applications/plugins/wii_ec_anal/err.h deleted file mode 100644 index 5a25c93f8..000000000 --- a/applications/plugins/wii_ec_anal/err.h +++ /dev/null @@ -1,72 +0,0 @@ -// Avoid circular/nested/mulitple inclusion -#ifndef ERR_H_ -#define ERR_H_ - -//----------------------------------------------------------------------------- ---------------------------------------- -// Application name -// -static const char* const appName = "Wii_i2c"; //$ Name used in log files - -//----------------------------------------------------------------------------- ---------------------------------------- -// Error codes and messages -// - -// You should only ever (need to) edit this list -// ...Watch out for extraneous whitespace after the terminating backslashes -#define FOREACH_ES(esPrial) \ - /* The first line MUST define 'ERR_OK = 0' */ \ - esPrial(0, ERR_OK, "OK (no error)") \ - \ - esPrial(1, ERR_MALLOC_QUEUE, "malloc() fail - queue") esPrial( \ - 2, \ - ERR_MALLOC_STATE, \ - "malloc() fail - state") esPrial(3, ERR_MALLOC_TEXT, "malloc() fail - text") \ - esPrial(4, ERR_MALLOC_VIEW, "malloc() fail - viewport") esPrial( \ - 5, ERR_NO_MUTEX, "Cannot create mutex") esPrial(6, ERR_NO_GUI, "Cannot open GUI") \ - esPrial(7, ERR_NO_TIMER, "Cannot create timer") esPrial( \ - 8, ERR_NO_NOTIFY, "Cannot acquire notifications handle") \ - \ - esPrial(10, ERR_MUTEX_BLOCK, "Mutex block failed") esPrial( \ - 11, ERR_MUTEX_RELEASE, "Mutex release failed") \ - \ - esPrial(20, ERR_QUEUE_RTOS, "queue - Undefined RTOS error") \ - esPrial(21, DEBUG_QUEUE_TIMEOUT, "queue - Timeout") esPrial( \ - 22, ERR_QUEUE_RESOURCE, "queue - Resource not available") \ - esPrial(23, ERR_QUEUE_BADPRM, "queue - Bad parameter") esPrial( \ - 24, ERR_QUEUE_NOMEM, "queue - Out of memory") \ - esPrial(25, ERR_QUEUE_ISR, "queue - Banned in ISR") esPrial( \ - 26, ERR_QUEUE_UNK, "queue - Unknown") \ - \ - esPrial(30, WARN_SCAN_START, "Scan - Already started") \ - esPrial(31, WARN_SCAN_STOP, "Scan - Already stopped") \ - esPrial( \ - 32, \ - ERR_TIMER_START, \ - "Scan - Cannot start timer") \ - esPrial( \ - 33, \ - ERR_TIMER_STOP, \ - "Scan - Cannot stop timer") //[EOT] - -// Declare list extraction macros -#define ES_ENUM(num, ename, string) ename = num, -#define ES_STRING(num, ename, string) string "\r\n", - -// Build the enum -typedef enum err { FOREACH_ES(ES_ENUM) } err_t; - -// You need to '#define ERR_C_' in precisely ONE source file -#ifdef ERR_C_ -// Build the string list -const char* const wii_errs[] = {FOREACH_ES(ES_STRING)}; -#else -// Give access to string list -extern const char* const wii_errs[]; -#endif - -// This is a header file, clean up -#undef ES_ENUM -#undef ES_STRING -#undef FOREACH_ES - -#endif // ERR_H_ diff --git a/applications/plugins/wii_ec_anal/gfx/images.c b/applications/plugins/wii_ec_anal/gfx/images.c deleted file mode 100644 index e8ab899f7..000000000 --- a/applications/plugins/wii_ec_anal/gfx/images.c +++ /dev/null @@ -1,137 +0,0 @@ -#include // GUI (screen/keyboard) API - -#include "images.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -static Canvas* _canvas; -static uint8_t _tlx; -static uint8_t _tly; - -static uint8_t _x; -static uint8_t _y; - -static const image_t* _img; - -static bool _blk; -static Color _set; -static Color _clr; - -//+============================================================================ -static void _showByteSet(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if(b & m) // plot only SET bits - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -static void _showByteClr(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if(!(b & m)) // plot only CLR bits - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -static void _showByteAll(const uint8_t b) { - for(uint8_t m = 0x80; m; m >>= 1) { - if((!!(b & m)) ^ _blk) { // Change colour only when required - canvas_set_color(_canvas, ((b & m) ? _set : _clr)); - _blk = !_blk; - } - canvas_draw_dot(_canvas, (_tlx + _x), (_tly + _y)); - if(((++_x) == _img->w) && !(_x = 0) && ((++_y) == _img->h)) break; - } -} - -//+============================================================================ -// available modes are SHOW_SET_BLK - plot image pixels that are SET in BLACK -// SHOW_XOR - same as SET_BLACK -// SHOW_SET_WHT - plot image pixels that are SET in WHITE -// SHOW_CLR_BLK - plot image pixels that are CLEAR in BLACK -// SHOW_CLR_WHT - plot image pixels that are CLEAR in WHITE -// SHOW_ALL - plot all images pixels as they are -// SHOW_ALL_INV - plot all images pixels inverted -// -void show( - Canvas* const canvas, - const uint8_t tlx, - const uint8_t tly, - const image_t* img, - const showMode_t mode) { - void (*fnShow)(const uint8_t) = NULL; - - const uint8_t* bp = img->data; - - // code size optimisation - switch(mode & SHOW_INV_) { - case SHOW_NRM_: - _set = ColorBlack; - _clr = ColorWhite; - break; - - case SHOW_INV_: - _set = ColorWhite; - _clr = ColorBlack; - break; - - case SHOW_BLK_: - canvas_set_color(canvas, ColorBlack); - break; - - case SHOW_WHT_: - canvas_set_color(canvas, ColorWhite); - break; - } - switch(mode & SHOW_INV_) { - case SHOW_NRM_: - case SHOW_INV_: - fnShow = _showByteAll; - canvas_set_color(canvas, ColorWhite); - _blk = 0; - break; - - case SHOW_BLK_: - case SHOW_WHT_: - switch(mode & SHOW_ALL_) { - case SHOW_SET_: - fnShow = _showByteSet; - break; - case SHOW_CLR_: - fnShow = _showByteClr; - break; - } - break; - } - furi_check(fnShow); - - // I want nested functions! - _canvas = canvas; - _img = img; - _tlx = tlx; - _tly = tly; - _x = 0; - _y = 0; - - // Compressed - if(img->c) { - for(unsigned int i = 0; i < img->len; i++, bp++) { - // Compressed data? {tag, length, value} - if(*bp == img->tag) { - for(uint16_t c = 0; c < bp[1]; c++) fnShow(bp[2]); - bp += 3 - 1; - i += 3 - 1; - - // Uncompressed byte - } else { - fnShow(*bp); - } - } - - // Not compressed - } else { - for(unsigned int i = 0; i < img->len; i++, bp++) fnShow(*bp); - } -} diff --git a/applications/plugins/wii_ec_anal/gfx/images.h b/applications/plugins/wii_ec_anal/gfx/images.h deleted file mode 100644 index d21909176..000000000 --- a/applications/plugins/wii_ec_anal/gfx/images.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef IMAGES_H_ -#define IMAGES_H_ - -#include -#include - -//----------------------------------------------------------------------------- ---------------------------------------- -typedef enum showMode { - // {INV:--:WHT:BLK::--:--:CLR:SET} - SHOW_SET_ = 0x01, - SHOW_CLR_ = 0x02, - SHOW_ALL_ = SHOW_SET_ | SHOW_CLR_, - - SHOW_BLK_ = 0x10, - SHOW_WHT_ = 0x20, - SHOW_NRM_ = 0x00, - SHOW_INV_ = SHOW_BLK_ | SHOW_WHT_, - - SHOW_SET_BLK = SHOW_SET_ | SHOW_BLK_, - SHOW_SET_WHT = SHOW_SET_ | SHOW_WHT_, - - SHOW_CLR_BLK = SHOW_CLR_ | SHOW_BLK_, - SHOW_CLR_WHT = SHOW_CLR_ | SHOW_WHT_, - - SHOW_ALL = SHOW_ALL_ | SHOW_NRM_, - SHOW_ALL_INV = SHOW_ALL_ | SHOW_INV_, -} showMode_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -typedef struct image { - uint8_t w; // width - uint8_t h; // height - bool c; // compressed? - uint16_t len; // image data length - uint8_t tag; // rle tag - uint8_t data[]; // image data -} image_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -//[TAG] -extern const image_t img_csLogo_Small; -extern const image_t img_3x5_v; -extern const image_t img_3x5_9; -extern const image_t img_3x5_8; -extern const image_t img_3x5_7; -extern const image_t img_3x5_6; -extern const image_t img_3x5_5; -extern const image_t img_3x5_4; -extern const image_t img_3x5_3; -extern const image_t img_3x5_2; -extern const image_t img_3x5_1; -extern const image_t img_3x5_0; -extern const image_t img_key_Ui; -extern const image_t img_key_OKi; -extern const image_t img_RIP; -extern const image_t img_cc_trg_R4; -extern const image_t img_cc_trg_R3; -extern const image_t img_cc_trg_R2; -extern const image_t img_cc_trg_R1; -extern const image_t img_cc_trg_L4; -extern const image_t img_cc_trg_L3; -extern const image_t img_cc_trg_L2; -extern const image_t img_cc_trg_L1; -extern const image_t img_cc_Joy; -extern const image_t img_cc_Main; -extern const image_t img_cc_Cable; -extern const image_t img_key_Back; -extern const image_t img_key_OK; -extern const image_t img_6x8_Z; -extern const image_t img_6x8_Y; -extern const image_t img_6x8_X; -extern const image_t img_key_U; -extern const image_t img_key_D; -extern const image_t img_csLogo_FULL; -extern const image_t img_6x8_7; -extern const image_t img_key_R; -extern const image_t img_key_L; -extern const image_t img_5x7_7; -extern const image_t img_5x7_F; -extern const image_t img_5x7_E; -extern const image_t img_5x7_D; -extern const image_t img_5x7_C; -extern const image_t img_5x7_B; -extern const image_t img_5x7_A; -extern const image_t img_5x7_9; -extern const image_t img_5x7_8; -extern const image_t img_5x7_6; -extern const image_t img_5x7_5; -extern const image_t img_5x7_4; -extern const image_t img_5x7_3; -extern const image_t img_5x7_2; -extern const image_t img_5x7_1; -extern const image_t img_5x7_0; -extern const image_t img_6x8_v; -extern const image_t img_6x8_n; -extern const image_t img_6x8_G; -extern const image_t img_6x8_F; -extern const image_t img_6x8_E; -extern const image_t img_6x8_d; -extern const image_t img_6x8_C; -extern const image_t img_6x8_B; -extern const image_t img_6x8_A; -extern const image_t img_6x8_9; -extern const image_t img_6x8_8; -extern const image_t img_6x8_6; -extern const image_t img_6x8_5; -extern const image_t img_6x8_4; -extern const image_t img_6x8_3; -extern const image_t img_6x8_2; -extern const image_t img_6x8_1; -extern const image_t img_6x8_0; -extern const image_t img_ecp_SDA; -extern const image_t img_ecp_SCL; -extern const image_t img_ecp_port; -extern const image_t img_cc_pad_UD1; -extern const image_t img_cc_pad_LR1; -extern const image_t img_cc_btn_Y1; -extern const image_t img_cc_btn_X1; -extern const image_t img_cc_btn_B1; -extern const image_t img_cc_btn_A1; -extern const image_t img_6x8_D; - -//----------------------------------------------------------------------------- ---------------------------------------- -#ifndef IMGTEST -#include -void show( - Canvas* const canvas, - const uint8_t tlx, - const uint8_t tly, - const image_t* img, - const showMode_t mode); -#endif - -#endif //IMAGES_H_ diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_0.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_0.c deleted file mode 100644 index 8fc8e0e14..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_0.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ##..## -// ##..## -// ##..## -// ###### - -#include "images.h" - -const image_t img_3x5_0 = {3, 5, false, 2, 0, {0xF6, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_1.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_1.c deleted file mode 100644 index 8b7d4cf80..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_1.c +++ /dev/null @@ -1,9 +0,0 @@ -// ####.. -// ..##.. -// ..##.. -// ..##.. -// ###### - -#include "images.h" - -const image_t img_3x5_1 = {3, 5, false, 2, 0, {0xC9, 0x2E}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_2.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_2.c deleted file mode 100644 index 89a81c75e..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_2.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ....## -// ###### -// ##.... -// ###### - -#include "images.h" - -const image_t img_3x5_2 = {3, 5, false, 2, 0, {0xE7, 0xCE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_3.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_3.c deleted file mode 100644 index 97ff0478a..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_3.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ....## -// ..#### -// ....## -// ###### - -#include "images.h" - -const image_t img_3x5_3 = {3, 5, false, 2, 0, {0xE5, 0x9E}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_4.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_4.c deleted file mode 100644 index 2bbd9ef42..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_4.c +++ /dev/null @@ -1,9 +0,0 @@ -// ##.... -// ##..## -// ###### -// ....## -// ....## - -#include "images.h" - -const image_t img_3x5_4 = {3, 5, false, 2, 0, {0x97, 0x92}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_5.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_5.c deleted file mode 100644 index e0466f37a..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_5.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ##.... -// ###### -// ....## -// ###### - -#include "images.h" - -const image_t img_3x5_5 = {3, 5, false, 2, 0, {0xF3, 0x9E}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_6.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_6.c deleted file mode 100644 index 1b62caf72..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_6.c +++ /dev/null @@ -1,9 +0,0 @@ -// ####.. -// ##.... -// ###### -// ##..## -// ###### - -#include "images.h" - -const image_t img_3x5_6 = {3, 5, false, 2, 0, {0xD3, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_7.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_7.c deleted file mode 100644 index acfe57cf8..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_7.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ....## -// ..##.. -// ..##.. -// ..##.. - -#include "images.h" - -const image_t img_3x5_7 = {3, 5, false, 2, 0, {0xE5, 0x24}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_8.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_8.c deleted file mode 100644 index 31f32af52..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_8.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ##..## -// ###### -// ##..## -// ###### - -#include "images.h" - -const image_t img_3x5_8 = {3, 5, false, 2, 0, {0xF7, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_9.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_9.c deleted file mode 100644 index 4b1ba1e09..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_9.c +++ /dev/null @@ -1,9 +0,0 @@ -// ###### -// ##..## -// ###### -// ....## -// ..#### - -#include "images.h" - -const image_t img_3x5_9 = {3, 5, false, 2, 0, {0xF7, 0x96}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_3x5_v.c b/applications/plugins/wii_ec_anal/gfx/img_3x5_v.c deleted file mode 100644 index 2282e1697..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_3x5_v.c +++ /dev/null @@ -1,9 +0,0 @@ -// ...... -// ...... -// ##..## -// ##..## -// ..##.. - -#include "images.h" - -const image_t img_3x5_v = {3, 5, false, 2, 0, {0x02, 0xD4}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_0.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_0.c deleted file mode 100644 index 7ae2186b3..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_0.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ##....#### -// ##..##..## -// ####....## -// ##......## -// ..######.. - -#include "images.h" - -const image_t img_5x7_0 = {5, 7, false, 5, 0, {0x74, 0x67, 0x5C, 0xC5, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_1.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_1.c deleted file mode 100644 index c1a9cec74..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..####.... -// ##..##.... -// ....##.... -// ....##.... -// ....##.... -// ....##.... -// ########## - -#include "images.h" - -const image_t img_5x7_1 = {5, 7, false, 5, 0, {0x65, 0x08, 0x42, 0x13, 0xE0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_2.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_2.c deleted file mode 100644 index 7fab90010..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_2.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ........## -// ......##.. -// ....##.... -// ..##...... -// ########## - -#include "images.h" - -const image_t img_5x7_2 = {5, 7, false, 5, 0, {0x74, 0x42, 0x22, 0x23, 0xE0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_3.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_3.c deleted file mode 100644 index 2099bf795..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_3.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ........## -// ....####.. -// ........## -// ##......## -// ..######.. - -#include "images.h" - -const image_t img_5x7_3 = {5, 7, false, 5, 0, {0x74, 0x42, 0x60, 0xC5, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_4.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_4.c deleted file mode 100644 index 1eee4f07d..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_4.c +++ /dev/null @@ -1,11 +0,0 @@ -// ##........ -// ##........ -// ##....##.. -// ##....##.. -// ########## -// ......##.. -// ......##.. - -#include "images.h" - -const image_t img_5x7_4 = {5, 7, false, 5, 0, {0x84, 0x25, 0x2F, 0x88, 0x40}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_5.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_5.c deleted file mode 100644 index be1e54681..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_5.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########## -// ##........ -// ##........ -// ########.. -// ........## -// ........## -// ########.. - -#include "images.h" - -const image_t img_5x7_5 = {5, 7, false, 5, 0, {0xFC, 0x21, 0xE0, 0x87, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_6.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_6.c deleted file mode 100644 index da155c1b5..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_6.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##........ -// ##........ -// ########.. -// ##......## -// ##......## -// ..######.. - -#include "images.h" - -const image_t img_5x7_6 = {5, 7, false, 5, 0, {0x74, 0x21, 0xE8, 0xC5, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_7.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_7.c deleted file mode 100644 index fde7e8ea2..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_7.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########## -// ........## -// ......##.. -// ......##.. -// ....##.... -// ....##.... -// ....##.... - -#include "images.h" - -const image_t img_5x7_7 = {5, 7, false, 5, 0, {0xF8, 0x44, 0x22, 0x10, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_8.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_8.c deleted file mode 100644 index aff178282..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_8.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ##......## -// ..######.. -// ##......## -// ##......## -// ..######.. - -#include "images.h" - -const image_t img_5x7_8 = {5, 7, false, 5, 0, {0x74, 0x62, 0xE8, 0xC5, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_9.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_9.c deleted file mode 100644 index 2417c57e8..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_9.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ##......## -// ..######## -// ........## -// ........## -// ..######.. - -#include "images.h" - -const image_t img_5x7_9 = {5, 7, false, 5, 0, {0x74, 0x62, 0xF0, 0x85, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_A.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_A.c deleted file mode 100644 index 910c034a2..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_A.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ##......## -// ########## -// ##......## -// ##......## -// ##......## - -#include "images.h" - -const image_t img_5x7_A = {5, 7, false, 5, 0, {0x74, 0x63, 0xF8, 0xC6, 0x20}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_B.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_B.c deleted file mode 100644 index 93808fee2..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_B.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########.. -// ##......## -// ##......## -// ##..####.. -// ##......## -// ##......## -// ########.. - -#include "images.h" - -const image_t img_5x7_B = {5, 7, false, 5, 0, {0xF4, 0x63, 0x68, 0xC7, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_C.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_C.c deleted file mode 100644 index 1438eaf44..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_C.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##......## -// ##........ -// ##........ -// ##........ -// ##......## -// ..######.. - -#include "images.h" - -const image_t img_5x7_C = {5, 7, false, 5, 0, {0x74, 0x61, 0x08, 0x45, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_D.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_D.c deleted file mode 100644 index 9c6b590ee..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_D.c +++ /dev/null @@ -1,11 +0,0 @@ -// ..######.. -// ##..##..## -// ....##..## -// ....##..## -// ....##..## -// ##..##..## -// ..######.. - -#include "images.h" - -const image_t img_5x7_D = {5, 7, false, 5, 0, {0x75, 0x4A, 0x52, 0xD5, 0xC0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_E.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_E.c deleted file mode 100644 index bc15fb240..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_E.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########## -// ##........ -// ##........ -// ######.... -// ##........ -// ##........ -// ########## - -#include "images.h" - -const image_t img_5x7_E = {5, 7, false, 5, 0, {0xFC, 0x21, 0xC8, 0x43, 0xE0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_5x7_F.c b/applications/plugins/wii_ec_anal/gfx/img_5x7_F.c deleted file mode 100644 index e4ad0db69..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_5x7_F.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########## -// ##........ -// ##........ -// ######.... -// ##........ -// ##........ -// ##........ - -#include "images.h" - -const image_t img_5x7_F = {5, 7, false, 5, 0, {0xFC, 0x21, 0xC8, 0x42, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_0.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_0.c deleted file mode 100644 index 952cf34d8..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_0.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ####....#### -// ####....#### -// ####....#### -// ####....#### -// ############ -// ..########.. - -#include "images.h" - -const image_t img_6x8_0 = {6, 8, false, 6, 0, {0x7B, 0xFC, 0xF3, 0xCF, 0x3F, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_1.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_1.c deleted file mode 100644 index 846a6876c..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_1.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..######.... -// ########.... -// ....####.... -// ....####.... -// ....####.... -// ....####.... -// ############ -// ############ - -#include "images.h" - -const image_t img_6x8_1 = {6, 8, false, 6, 0, {0x73, 0xC3, 0x0C, 0x30, 0xCF, 0xFF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_2.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_2.c deleted file mode 100644 index 4534bb67c..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_2.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ........#### -// ......###### -// ....####.... -// ..####...... -// ############ -// ############ - -#include "images.h" - -const image_t img_6x8_2 = {6, 8, false, 6, 0, {0x7B, 0xF0, 0xC7, 0x31, 0x8F, 0xFF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_3.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_3.c deleted file mode 100644 index 7e79eb03a..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_3.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ........#### -// ....######## -// ....######## -// ........#### -// ############ -// ..########.. - -#include "images.h" - -const image_t img_6x8_3 = {6, 8, false, 6, 0, {0x7B, 0xF0, 0xCF, 0x3C, 0x3F, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_4.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_4.c deleted file mode 100644 index 324b036ce..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_4.c +++ /dev/null @@ -1,12 +0,0 @@ -// ####........ -// ####........ -// ####..####.. -// ####..####.. -// ############ -// ############ -// ......####.. -// ......####.. - -#include "images.h" - -const image_t img_6x8_4 = {6, 8, false, 6, 0, {0xC3, 0x0D, 0xB6, 0xFF, 0xF1, 0x86}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_5.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_5.c deleted file mode 100644 index cdfda5f2b..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_5.c +++ /dev/null @@ -1,12 +0,0 @@ -// ############ -// ############ -// ####........ -// ##########.. -// ############ -// ........#### -// ############ -// ##########.. - -#include "images.h" - -const image_t img_6x8_5 = {6, 8, false, 6, 0, {0xFF, 0xFC, 0x3E, 0xFC, 0x3F, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_6.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_6.c deleted file mode 100644 index 781a060f1..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_6.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ##########.. -// ####........ -// ##########.. -// ############ -// ####....#### -// ############ -// ..########.. - -#include "images.h" - -const image_t img_6x8_6 = {6, 8, false, 6, 0, {0x7B, 0xEC, 0x3E, 0xFF, 0x3F, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_7.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_7.c deleted file mode 100644 index fec5f4bf4..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_7.c +++ /dev/null @@ -1,12 +0,0 @@ -// ############ -// ############ -// ........#### -// ......####.. -// ......####.. -// ....####.... -// ....####.... -// ....####.... - -#include "images.h" - -const image_t img_6x8_7 = {6, 8, false, 6, 0, {0xFF, 0xF0, 0xC6, 0x18, 0xC3, 0x0C}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_8.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_8.c deleted file mode 100644 index a5b21c375..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_8.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ####....#### -// ..########.. -// ############ -// ####....#### -// ############ -// ..########.. - -#include "images.h" - -const image_t img_6x8_8 = {6, 8, false, 6, 0, {0x7B, 0xFC, 0xDE, 0xFF, 0x3F, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_9.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_9.c deleted file mode 100644 index f7707c0df..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_9.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ####....#### -// ############ -// ..########## -// ........#### -// ..########## -// ..########.. - -#include "images.h" - -const image_t img_6x8_9 = {6, 8, false, 6, 0, {0x7B, 0xFC, 0xFF, 0x7C, 0x37, 0xDE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_A.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_A.c deleted file mode 100644 index 1bb65c902..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_A.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########.. -// ############ -// ####....#### -// ####....#### -// ############ -// ############ -// ####....#### -// ####....#### - -#include "images.h" - -const image_t img_6x8_A = {6, 8, false, 6, 0, {0x7B, 0xFC, 0xF3, 0xFF, 0xFC, 0xF3}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_B.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_B.c deleted file mode 100644 index 00e012d53..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_B.c +++ /dev/null @@ -1,12 +0,0 @@ -// ##########.. -// ############ -// ####....#### -// ##########.. -// ##########.. -// ####....#### -// ############ -// ##########.. - -#include "images.h" - -const image_t img_6x8_B = {6, 8, false, 6, 0, {0xFB, 0xFC, 0xFE, 0xFB, 0x3F, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_C.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_C.c deleted file mode 100644 index 694901009..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_C.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########## -// ############ -// ####........ -// ####........ -// ####........ -// ####........ -// ############ -// ..########## - -#include "images.h" - -const image_t img_6x8_C = {6, 8, false, 6, 0, {0x7F, 0xFC, 0x30, 0xC3, 0x0F, 0xDF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_D.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_D.c deleted file mode 100644 index a95e760eb..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_D.c +++ /dev/null @@ -1,12 +0,0 @@ -// ##########.. -// ############ -// ..####..#### -// ..####..#### -// ..####..#### -// ..####..#### -// ############ -// ##########.. - -#include "images.h" - -const image_t img_6x8_D = {6, 8, false, 6, 0, {0xFB, 0xF6, 0xDB, 0x6D, 0xBF, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_E.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_E.c deleted file mode 100644 index f49503f00..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_E.c +++ /dev/null @@ -1,12 +0,0 @@ -// ############ -// ############ -// ####........ -// ########.... -// ########.... -// ####........ -// ############ -// ############ - -#include "images.h" - -const image_t img_6x8_E = {6, 8, false, 6, 0, {0xFF, 0xFC, 0x3C, 0xF3, 0x0F, 0xFF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_F.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_F.c deleted file mode 100644 index 0037b2544..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_F.c +++ /dev/null @@ -1,12 +0,0 @@ -// ############ -// ############ -// ####........ -// ########.... -// ########.... -// ####........ -// ####........ -// ####........ - -#include "images.h" - -const image_t img_6x8_F = {6, 8, false, 6, 0, {0xFF, 0xFC, 0x3C, 0xF3, 0x0C, 0x30}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_G.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_G.c deleted file mode 100644 index f30bc9952..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_G.c +++ /dev/null @@ -1,12 +0,0 @@ -// ..########## -// ############ -// ####........ -// ####........ -// ####..###### -// ####....#### -// ############ -// ..########## - -#include "images.h" - -const image_t img_6x8_G = {6, 8, false, 6, 0, {0x7F, 0xFC, 0x30, 0xDF, 0x3F, 0xDF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_X.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_X.c deleted file mode 100644 index 4735e82a1..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_X.c +++ /dev/null @@ -1,12 +0,0 @@ -// ####....#### -// ####....#### -// ..####..##.. -// ....######.. -// ..######.... -// ..##..####.. -// ####....#### -// ####....#### - -#include "images.h" - -const image_t img_6x8_X = {6, 8, false, 6, 0, {0xCF, 0x36, 0x8E, 0x71, 0x6C, 0xF3}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_Y.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_Y.c deleted file mode 100644 index 508e786bd..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_Y.c +++ /dev/null @@ -1,12 +0,0 @@ -// ####....#### -// ####....#### -// ####....#### -// ####....#### -// ..########.. -// ....####.... -// ....####.... -// ....####.... - -#include "images.h" - -const image_t img_6x8_Y = {6, 8, false, 6, 0, {0xCF, 0x3C, 0xF3, 0x78, 0xC3, 0x0C}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_Z.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_Z.c deleted file mode 100644 index c42d560ac..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_Z.c +++ /dev/null @@ -1,12 +0,0 @@ -// ############ -// ############ -// ........#### -// ......####.. -// ....####.... -// ..####...... -// ############ -// ############ - -#include "images.h" - -const image_t img_6x8_Z = {6, 8, false, 6, 0, {0xFF, 0xF0, 0xC6, 0x31, 0x8F, 0xFF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_d_.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_d_.c deleted file mode 100644 index 1f8123a6c..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_d_.c +++ /dev/null @@ -1,12 +0,0 @@ -// ........#### -// ........#### -// ........#### -// ..########## -// ############ -// ####....#### -// ############ -// ..########## - -#include "images.h" - -const image_t img_6x8_d = {6, 8, false, 6, 0, {0x0C, 0x30, 0xDF, 0xFF, 0x3F, 0xDF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_n_.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_n_.c deleted file mode 100644 index 15d403d28..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_n_.c +++ /dev/null @@ -1,12 +0,0 @@ -// ............ -// ............ -// ..########.. -// ############ -// ####....#### -// ####....#### -// ####....#### -// ####....#### - -#include "images.h" - -const image_t img_6x8_n = {6, 8, false, 6, 0, {0x00, 0x07, 0xBF, 0xCF, 0x3C, 0xF3}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_6x8_v_.c b/applications/plugins/wii_ec_anal/gfx/img_6x8_v_.c deleted file mode 100644 index 1229701a1..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_6x8_v_.c +++ /dev/null @@ -1,12 +0,0 @@ -// ............ -// ............ -// ##........## -// ####....#### -// ####....#### -// ############ -// ..########.. -// ....####.... - -#include "images.h" - -const image_t img_6x8_v = {6, 8, false, 6, 0, {0x00, 0x08, 0x73, 0xCF, 0xF7, 0x8C}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_RIP.c b/applications/plugins/wii_ec_anal/gfx/img_RIP.c deleted file mode 100644 index c20877ef0..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_RIP.c +++ /dev/null @@ -1,130 +0,0 @@ -// ################################################################################################################################################################################################################################################################ -// ################################################################################################################################################################################################################################################################ -// ####........................................................................................................................................................................................................................................................#### -// ####..##..##........................................................................................................................................................................................................................................##..##..#### -// ####....##....................##############..........########........##################........................##############......##..........##......##############......##############......##############......##############....................##....#### -// ####..##..##..................##############............######..........################........................##############....######......######....##############......##############......##############......##############..................##..##..#### -// ####....................................######..........##..##......................######....................####........######..######......######..####........######..######......######..............######..######......######........................#### -// ####........................######......######..........##..##..........######......##..##....................######......##..##..##..##......##..##..######......######..######......######..######......######..######......##..##........................#### -// ####........................######......##..##..........##..##..........######......##..##....................##..##......######..##..##......##..##..######......##..##..##..##......##..##..######......##..##..##..##......##..##........................#### -// ####........................##..##......##..##..........##..##..........##..##......##..##....................##..##..............##..##......##..##..##..##......##..##..##..##......##..##..##..##......##..##..##..##......##..##........................#### -// ####........................##..##......##..##..........##..##..........##..##......##..##....................##..##..............##..##......##..##..##..##......##..##..##..##......##..##..##..##......##..##..##..##......######........................#### -// ####........................##..##......######..........##..##..........##..##......######....................##..##..............##..##......##..##..##..##......######..##..##..##..##..##..##..##......######..##..##....................................#### -// ####........................##..##########..............##..##..........##..##########........................##..##..............######......######..##..##########......##..##......##..##..##..##########......##..##....................................#### -// ####........................##..##########..............##..##..........##..##########........................##..##................##############....##..##########......##..##......##..##..##..##########......##..##..########..........................#### -// ####........................##..##....######............##..##..........##..##................................##..##..................####..####......##..##......######..##..##..##..##..##..##..##....######....##..##..##########........................#### -// ####........................##..##....##..##............##..##..........##..##................................##..##....................##..##........##..##......##..##..##..##......##..##..##..##....##..##....##..##......##..##........................#### -// ####........................##..##....##..##............##..##..........##..##................................##..##....................##..##........##..##......##..##..##..##......##..##..##..##....##..##....##..##......##..##........................#### -// ####........................##..##....##..##............##..##..........##..##................................######......######........##..##........##..##......##..##..##..##......##..##..##..##....##..##....######......##..##........................#### -// ####........................##..##....##..##............##..##..........##..##................................######......##..##........##..##........######......######..######......######..##..##....##..##....######......##..##........................#### -// ####........................##..##....##..##............##..##..........##..##................................####........######........######........######......######..######......######..##..##....##..##....####........######........................#### -// ####........................######....######....####....######..####....######..####............................##############..........######..........##############......##############....######....######......##############..........................#### -// ####........................######......######..####..########..####..########..####............................##############........##########........##############......##############....######......######....##############..........................#### -// ####........................................................................................................................................................................................................................................................#### -// ####........................................................................................................................................................................................................................................................#### -// ####..........................................................................................................................................................................................####......####..............##############....................#### -// ####......................................................................................................................................##................................................##....##..##....##........####..............####................#### -// ####..........######..##..##..######......######..##..##..######..######..######..####..####..######......##......##..######..##....##..##..######......######..######......................####..##..####..##......##......................##..............#### -// ####............##....##..##..##..........##......##..##..##........##....##......##..##..##..##..........##......##..##..##..####..##........##........##..##..##............................####......####......##......##########..........##............#### -// ####............##....######..####........######....##....######....##....####....##..##..##..######......##..##..##..##..##..##..####........##........####....####..............................##..##........##......##..........##........##............#### -// ####............##....##..##..##..............##....##........##....##....##......##......##......##......##..##..##..##..##..##....##........##........##..##..##..................................##..........##....##..............##......##............#### -// ####............##....##..##..######......######....##....######....##....######..##......##..######......####..####..######..##....##........##........######..######............................######........##....##......####....##......##............#### -// ####............................................................................................................................................................................................##......##......##....##....##....##..##......##............#### -// ####..........................................................................................................................................................................................##........##......##....##....##..##....##......##............#### -// ####..........................................................................................................................................................................................##........##......##....##....##........##......##............#### -// ####..........######..##..##..######......######..######..####..####..######......##......##..######..######..##..##..######..##..##..######......##..##..######..##..##........................##........######......##......########......##..............#### -// ####............##....##..##..##..........##......##..##..##..##..##..##..........##......##....##......##....##..##..##..##..##..##....##........##..##..##..##..##..##........................##..............##......##..................####............#### -// ####............##....######..####........######..######..##..##..##..####........##..##..##....##......##....######..##..##..##..##....##..........##....##..##..##..##..........................##..............##########..............##....##..........#### -// ####............##....##..##..##..............##..##..##..##......##..##..........##..##..##....##......##....##..##..##..##..##..##....##..........##....##..##..##..##..........................##......................################........##........#### -// ####............##....##..##..######......######..##..##..##......##..######......####..####..######....##....##..##..######..######....##..........##....######..######............................####..........................................##........#### -// ####....................................................................................................................................................................................................##########################################..........#### -// ####........................................................................................................................................................................................................................................................#### -// ####........................................................................................................................................................................................................................................................#### -// ####......................................##########......##############......##############......##############............................##############......##############......##############......##############......................................#### -// ####......................................##########......##############......##############......##############............................##############......##############......##############......##############......................................#### -// ####......................................##..##..##....######......######..######......######..######......######........................######......######..######......######..######......######..######......######....................................#### -// ####..........................................##..##....######......######..##..##......######..######......######........................##..##......##..##..######......######..##..##......##..##..##..##......##..##....................................#### -// ####..........................................##..##....##..##......##..##..######......##..##..##..##......##..##........................######......##..##..##..##......##..##..######......##..##..######......##..##....................................#### -// ####..........................................##..##....##..##......##..##..............##..##..##..##......##..##....................................##..##..##..##......##..##..............##..##..............##..##....................................#### -// ####..........................................##..##....##..##......##..##..............##..##..##..##....####..##....................................##..##..##..##....####..##..............##..##..............##..##....................................#### -// ####..........................................##..##....######......##..##..............######..##..##....####..##....................................######..##..##....####..##..............######..............######....................................#### -// ####..........................................######........##########..##..............######..##..##..##..##..##....################........############....##..##..##..##..##......############........############......................................#### -// ####..........................................######........##########..##..........######......##..##..##..##..##....##............##......############......##..##..##..##..##....############........############........................................#### -// ####..........................................##..##................##..##..........######......##..####....##..##....################....######..............##..####....##..##..######..............######................................................#### -// ####..........................................##..##................##..##..........##..##......##..####....##..##........................##..##..............##..####....##..##..##..##..............##..##................................................#### -// ####..........................................##..##................##..##..........##..##......##..##......##..##........................##..##..............##..##......##..##..##..##..............##..##................................................#### -// ####..........................................##..##................##..##..........##..##......##..##......##..##........................##..##..............##..##......##..##..##..##..............##..##................................................#### -// ####..........................................##..##................######..........##..##......######......######........................##..##..............######......######..##..##..............##..##................................................#### -// ####..........................................##..##................######..........##..##......######......######........................##..##........####..######......######..##..##........####..##..##........####....................................#### -// ####..##..##..............................##############....############............######........##############..........................##################....##############....##################..##################............................##..##..#### -// ####....##..............................##################..############............######........##############..........................##################....##############....##################..##################..............................##....#### -// ####..##..##........................................................................................................................................................................................................................................##..##..#### -// ####........................................................................................................................................................................................................................................................#### -// ################################################################################################################################################################################################################################################################ -// ################################################################################################################################################################################################################################################################ - -#include "images.h" - -const image_t img_RIP = { - 128, - 64, - true, - 837, - 0x06, - {// orig:1024, comp:18.26% - 0x06, 0x20, 0xFF, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0xD4, 0x06, 0x0E, 0x00, 0x2B, 0xC8, 0x01, - 0xFC, 0x1E, 0x1F, 0xF0, 0x00, 0xFE, 0x20, 0x8F, 0xE3, 0xF8, 0xFE, 0x3F, 0x80, 0x13, 0xD4, - 0x01, 0xFC, 0x0E, 0x0F, 0xF0, 0x00, 0xFE, 0x71, 0xCF, 0xE3, 0xF8, 0xFE, 0x3F, 0x80, 0x2B, - 0xC0, 0x00, 0x0E, 0x0A, 0x00, 0x38, 0x01, 0x87, 0x71, 0xD8, 0x77, 0x1C, 0x07, 0x71, 0xC0, - 0x03, 0xC0, 0x03, 0x8E, 0x0A, 0x0E, 0x28, 0x01, 0xC5, 0x51, 0x5C, 0x77, 0x1D, 0xC7, 0x71, - 0x40, 0x03, 0xC0, 0x03, 0x8A, 0x0A, 0x0E, 0x28, 0x01, 0x47, 0x51, 0x5C, 0x55, 0x15, 0xC5, - 0x51, 0x40, 0x03, 0xC0, 0x02, 0x8A, 0x0A, 0x0A, 0x28, 0x01, 0x40, 0x51, 0x54, 0x55, 0x15, - 0x45, 0x51, 0x40, 0x03, 0xC0, 0x02, 0x8A, 0x0A, 0x0A, 0x28, 0x01, 0x40, 0x51, 0x54, 0x55, - 0x15, 0x45, 0x51, 0xC0, 0x03, 0xC0, 0x02, 0x8E, 0x0A, 0x0A, 0x38, 0x01, 0x40, 0x51, 0x54, - 0x75, 0x55, 0x47, 0x50, 0x00, 0x03, 0xC0, 0x02, 0xF8, 0x0A, 0x0B, 0xE0, 0x01, 0x40, 0x71, - 0xD7, 0xC5, 0x15, 0x7C, 0x50, 0x00, 0x03, 0xC0, 0x02, 0xF8, 0x0A, 0x0B, 0xE0, 0x01, 0x40, - 0x3F, 0x97, 0xC5, 0x15, 0x7C, 0x57, 0x80, 0x03, 0xC0, 0x02, 0x9C, 0x0A, 0x0A, 0x00, 0x01, - 0x40, 0x1B, 0x14, 0x75, 0x55, 0x4E, 0x57, 0xC0, 0x03, 0xC0, 0x02, 0x94, 0x0A, 0x0A, 0x00, - 0x01, 0x40, 0x0A, 0x14, 0x55, 0x15, 0x4A, 0x51, 0x40, 0x03, 0xC0, 0x02, 0x94, 0x0A, 0x0A, - 0x00, 0x01, 0x40, 0x0A, 0x14, 0x55, 0x15, 0x4A, 0x51, 0x40, 0x03, 0xC0, 0x02, 0x94, 0x0A, - 0x0A, 0x00, 0x01, 0xC7, 0x0A, 0x14, 0x55, 0x15, 0x4A, 0x71, 0x40, 0x03, 0xC0, 0x02, 0x94, - 0x0A, 0x0A, 0x00, 0x01, 0xC5, 0x0A, 0x1C, 0x77, 0x1D, 0x4A, 0x71, 0x40, 0x03, 0xC0, 0x02, - 0x94, 0x0A, 0x0A, 0x00, 0x01, 0x87, 0x0E, 0x1C, 0x77, 0x1D, 0x4A, 0x61, 0xC0, 0x03, 0xC0, - 0x03, 0x9C, 0xCE, 0xCE, 0xC0, 0x00, 0xFE, 0x0E, 0x0F, 0xE3, 0xF9, 0xCE, 0x3F, 0x80, 0x03, - 0xC0, 0x03, 0x8E, 0xDE, 0xDE, 0xC0, 0x00, 0xFE, 0x1F, 0x0F, 0xE3, 0xF9, 0xC7, 0x3F, 0x80, - 0x03, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0xC0, 0x06, 0x0A, 0x00, - 0x01, 0x8C, 0x07, 0xF0, 0x03, 0xC0, 0x06, 0x07, 0x00, 0x04, 0x00, 0x00, 0x02, 0x52, 0x18, - 0x0C, 0x03, 0xC1, 0xD5, 0xC7, 0x57, 0x77, 0x6D, 0xC4, 0x5D, 0x2B, 0x8E, 0xE0, 0x03, 0x5A, - 0x20, 0x02, 0x03, 0xC0, 0x95, 0x04, 0x54, 0x24, 0x55, 0x04, 0x55, 0xA1, 0x0A, 0x80, 0x01, - 0x8C, 0x47, 0xC1, 0x03, 0xC0, 0x9D, 0x87, 0x27, 0x26, 0x55, 0xC5, 0x55, 0x61, 0x0C, 0xC0, - 0x00, 0x50, 0x88, 0x21, 0x03, 0xC0, 0x95, 0x01, 0x21, 0x24, 0x44, 0x45, 0x55, 0x21, 0x0A, - 0x80, 0x00, 0x20, 0x90, 0x11, 0x03, 0xC0, 0x95, 0xC7, 0x27, 0x27, 0x45, 0xC6, 0xDD, 0x21, - 0x0E, 0xE0, 0x00, 0x70, 0x91, 0x91, 0x03, 0xC0, 0x06, 0x0B, 0x00, 0x88, 0x92, 0x51, 0x03, - 0xC0, 0x06, 0x0A, 0x00, 0x01, 0x08, 0x92, 0x91, 0x03, 0xC0, 0x06, 0x0A, 0x00, 0x01, 0x08, - 0x92, 0x11, 0x03, 0xC1, 0xD5, 0xC7, 0x76, 0xDC, 0x45, 0xDD, 0x5D, 0x5C, 0x57, 0x50, 0x00, - 0x87, 0x11, 0xE2, 0x03, 0xC0, 0x95, 0x04, 0x55, 0x50, 0x44, 0x89, 0x55, 0x48, 0x55, 0x50, - 0x00, 0x80, 0x88, 0x03, 0x03, 0xC0, 0x9D, 0x87, 0x75, 0x58, 0x54, 0x89, 0xD5, 0x48, 0x25, - 0x50, 0x00, 0x40, 0x7C, 0x04, 0x83, 0xC0, 0x95, 0x01, 0x54, 0x50, 0x54, 0x89, 0x55, 0x48, - 0x25, 0x50, 0x00, 0x40, 0x07, 0xF8, 0x43, 0xC0, 0x95, 0xC7, 0x54, 0x5C, 0x6D, 0xC9, 0x5D, - 0xC8, 0x27, 0x70, 0x00, 0x30, 0x00, 0x00, 0x43, 0xC0, 0x06, 0x0B, 0x00, 0x0F, 0xFF, 0xFF, - 0x83, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0xC0, 0x00, 0x07, 0xC7, - 0xF1, 0xFC, 0x7F, 0x00, 0x03, 0xF8, 0xFE, 0x3F, 0x8F, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x07, - 0xC7, 0xF1, 0xFC, 0x7F, 0x00, 0x03, 0xF8, 0xFE, 0x3F, 0x8F, 0xE0, 0x00, 0x03, 0xC0, 0x00, - 0x05, 0x4E, 0x3B, 0x8E, 0xE3, 0x80, 0x07, 0x1D, 0xC7, 0x71, 0xDC, 0x70, 0x00, 0x03, 0xC0, - 0x00, 0x01, 0x4E, 0x3A, 0x8E, 0xE3, 0x80, 0x05, 0x15, 0xC7, 0x51, 0x54, 0x50, 0x00, 0x03, - 0xC0, 0x00, 0x01, 0x4A, 0x2B, 0x8A, 0xA2, 0x80, 0x07, 0x15, 0x45, 0x71, 0x5C, 0x50, 0x00, - 0x03, 0xC0, 0x00, 0x01, 0x4A, 0x28, 0x0A, 0xA2, 0x80, 0x00, 0x15, 0x45, 0x01, 0x40, 0x50, - 0x00, 0x03, 0xC0, 0x00, 0x01, 0x4A, 0x28, 0x0A, 0xA6, 0x80, 0x00, 0x15, 0x4D, 0x01, 0x40, - 0x50, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x4E, 0x28, 0x0E, 0xA6, 0x80, 0x00, 0x1D, 0x4D, 0x01, - 0xC0, 0x70, 0x00, 0x03, 0xC0, 0x00, 0x01, 0xC3, 0xE8, 0x0E, 0xAA, 0x9F, 0xE1, 0xF9, 0x55, - 0x1F, 0x87, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x01, 0xC3, 0xE8, 0x38, 0xAA, 0x90, 0x23, 0xF1, - 0x55, 0x3F, 0x0F, 0xC0, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, 0x28, 0x38, 0xB2, 0x9F, 0xE7, - 0x01, 0x65, 0x70, 0x1C, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, 0x28, 0x28, 0xB2, 0x80, - 0x05, 0x01, 0x65, 0x50, 0x14, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, 0x28, 0x28, 0xA2, - 0x80, 0x05, 0x01, 0x45, 0x50, 0x14, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, 0x28, 0x28, - 0xA2, 0x80, 0x05, 0x01, 0x45, 0x50, 0x14, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, 0x38, - 0x28, 0xE3, 0x80, 0x05, 0x01, 0xC7, 0x50, 0x14, 0x00, 0x00, 0x03, 0xC0, 0x00, 0x01, 0x40, - 0x38, 0x28, 0xE3, 0x80, 0x05, 0x0D, 0xC7, 0x50, 0xD4, 0x30, 0x00, 0x03, 0xD4, 0x00, 0x07, - 0xF3, 0xF0, 0x38, 0x7F, 0x00, 0x07, 0xFC, 0xFE, 0x7F, 0xDF, 0xF0, 0x00, 0x2B, 0xC8, 0x00, - 0x0F, 0xFB, 0xF0, 0x38, 0x7F, 0x00, 0x07, 0xFC, 0xFE, 0x7F, 0xDF, 0xF0, 0x00, 0x13, 0xD4, - 0x06, 0x0E, 0x00, 0x2B, 0xC0, 0x06, 0x0E, 0x00, 0x03, 0x06, 0x20, 0xFF}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_Cable.c b/applications/plugins/wii_ec_anal/gfx/img_cc_Cable.c deleted file mode 100644 index f4ac26173..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_Cable.c +++ /dev/null @@ -1,25 +0,0 @@ -// ####..## -// ##..#### -// ####..## -// ##..#### -// ####..## -// ##..#### -// ####..## -// ##..#### -// ####..## -// ##..#### -// ####..## - -#include "images.h" - -const image_t img_cc_Cable = { - 4, - 11, - true, - 4, - 0x00, - {// orig:6, comp:33.33% - 0x00, - 0x05, - 0xDB, - 0xD0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_Joy.c b/applications/plugins/wii_ec_anal/gfx/img_cc_Joy.c deleted file mode 100644 index 5054103b3..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_Joy.c +++ /dev/null @@ -1,25 +0,0 @@ -// ................##................ -// ............##########............ -// ....############..############.... -// ....######..............######.... -// ....####..................####.... -// ....##......................##.... -// ..####......................####.. -// ..####......................####.. -// ####..........................#### -// ..####......................####.. -// ..####......................####.. -// ....##......................##.... -// ....####..................####.... -// ....######..............######.... -// ....############..############.... -// ............##########............ -// ................##................ - -#include "images.h" - -const image_t img_cc_Joy = {17, 17, false, 37, 0, {0x00, 0x80, 0x01, 0xF0, 0x0F, 0xDF, 0x87, 0x01, - 0xC3, 0x00, 0x61, 0x00, 0x11, 0x80, 0x0C, 0xC0, - 0x06, 0xC0, 0x01, 0xB0, 0x01, 0x98, 0x00, 0xC4, - 0x00, 0x43, 0x00, 0x61, 0xC0, 0x70, 0xFD, 0xF8, - 0x07, 0xC0, 0x00, 0x80, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_Main.c b/applications/plugins/wii_ec_anal/gfx/img_cc_Main.c deleted file mode 100644 index b29a9ab57..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_Main.c +++ /dev/null @@ -1,100 +0,0 @@ -// ..................................................##################................................................................................................##################.................................................. -// ......................................############................##............##########....................................................##########............##................############...................................... -// ..................................####............................##..........##..........##......................####......................##..........##..........##............................####.................................. -// ................................##................................##############..........####################################################..........##############................................##................................ -// ............................######................................##..........##..........##......................####......................##..........##..........##................................######............................ -// ..........................##..##....................################..........##..........##......................####......................##..........##..........################....................##..##.......................... -// ........................##....##........############............................##########....................................................##########............................############........##....##........................ -// ......................##......##########........................................................................................................................................................##########......##...................... -// ....................##..........########################################################################################################################################################################..........##.................... -// ..................##......########....................................................................................................................................................................########......##.................. -// ................##....######................................................................................................................................................................................######....##................ -// ..............##....####........................................................................................................................................................................................####....##.............. -// ............##########............................................................................................................................................................................................##########............ -// ............######......................................................................................####......####..####..####....................................................................................######............ -// ..........######......................##################................................................####..##..####..................................................................######..........................######.......... -// ..........####........................##################................................................####..##..####..####..####....................................................##########..........................####.......... -// ........####..........................####..........####................................................####..##..####..####..####..................................................####......####..........................####........ -// ......######..........................####..........####..................................................####..####....####..####................................................####..........####........................######...... -// ......####............................####....##....####........................................................................................................................####....##..##....####........................####...... -// ......##..............................####....##....####........................................................................................................................####......##......####..........................####.... -// ....####..............................####....##....####........................................................................................................................####....##..##....####..........................####.... -// ....##..................##################..........##################............................................................................................######..........####..........####..........######..............##.... -// ..####..................##################..........##################..........................................................................................##########..........####......####..........##########............####.. -// ..##....................####......................................####..........................########........########........########......................####......####..........##########..........####......####............##.. -// ..##....................####......................................####........................####....####....####....####....####....####..................####..........####..........######..........####....##....####..........##.. -// ####....................####....######..................######....####........................##........##....##........##....##........##................####....##..##....####......................####....##..##....####........#### -// ##......................####......................................####........................##........##....##........##....##........##................####....######....####......................####....######....####..........## -// ##......................####......................................####........................####....####....####....####....####....####................####........##....####......................####....##..##....####..........## -// ##......................##################..........##################..........................########........########........########....................####....##....####..........######..........####..........####............## -// ##......................##################..........##################........................................................................................####......####..........##########..........####......####..............## -// ##....................................####....##....####........................................................................................................##########..........####......####..........##########................## -// ##....................................####....##....####..........................................................................................................######..........####..##......####..........######..................## -// ##....................................####....##....####........................................................................................................................####....##........####................................## -// ##....................................####..........####........................................................................................................................####....####......####................................## -// ##....................................####..........####........................................................................................................................####....##..##....####................................## -// ####..................................##################..........................................................................................................................####....####..####................................#### -// ..##..................................##################............................................................................................................................####......####..................................##.. -// ..##..................................................................................................................................................................................##########....................................##.. -// ..####..................................................................................................................................................................................######....................................####.. -// ....##............................................................................................................................................................................................................................##.... -// ....##............................................................................................................................................................................................................................##.... -// ....####........................................................................................................................................................................................................................####.... -// ......##........................................................................................................................................................................................................................##...... -// ......####....................................................................................................................................................................................................................####...... -// ........####................................................................................................................................................................................................................####........ -// ..........####............................................................................................................................................................................................................####.......... -// ............####........................................................................................................................................................................................................####............ -// ..............####....................................................................................................................................................................................................####.............. -// ................######............................................................................................................................................................................................######................ -// ....................####........................................................................................................................................................................................####.................... -// ......................######................................................................................................................................................................................######...................... -// ..........................########....................................................................................................................................................................########.......................... -// ................................########################################################################################################################################################################................................ - -#include "images.h" - -const image_t img_cc_Main = { - 116, - 53, - true, - 542, - 0x05, - {// orig:769, comp:29.52% - 0x00, 0x00, 0x00, 0x7F, 0xC0, 0x05, 0x05, 0x00, 0x3F, 0xE0, 0x05, 0x04, 0x00, 0x01, 0xF8, - 0x04, 0x0F, 0x80, 0x00, 0x00, 0x1F, 0x02, 0x01, 0xF8, 0x05, 0x04, 0x00, 0x60, 0x00, 0x41, - 0x04, 0x00, 0x60, 0x02, 0x08, 0x20, 0x00, 0x60, 0x00, 0x00, 0x00, 0x08, 0x00, 0x07, 0xF0, - 0x7F, 0xFF, 0xFF, 0xE0, 0xFE, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x41, 0x04, - 0x00, 0x60, 0x02, 0x08, 0x20, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x50, 0x03, 0xFC, 0x10, 0x40, - 0x06, 0x00, 0x20, 0x83, 0xFC, 0x00, 0xA0, 0x00, 0x00, 0x09, 0x0F, 0xC0, 0x00, 0xF8, 0x00, - 0x00, 0x01, 0xF0, 0x00, 0x3F, 0x09, 0x00, 0x00, 0x01, 0x1F, 0x05, 0x09, 0x00, 0x0F, 0x88, - 0x00, 0x00, 0x20, 0x05, 0x0A, 0xFF, 0xF0, 0x40, 0x00, 0x04, 0x78, 0x05, 0x09, 0x00, 0x01, - 0xE2, 0x00, 0x00, 0x9C, 0x05, 0x0A, 0x00, 0x03, 0x90, 0x00, 0x13, 0x05, 0x0B, 0x00, 0x0C, - 0x80, 0x03, 0xE0, 0x05, 0x0B, 0x00, 0x7C, 0x00, 0x38, 0x05, 0x05, 0x00, 0xC6, 0xD8, 0x05, - 0x04, 0x00, 0x01, 0xC0, 0x07, 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x0D, 0x60, 0x00, 0x00, 0x00, - 0x0E, 0x00, 0x0E, 0x00, 0x60, 0x01, 0xFF, 0x00, 0x00, 0x00, 0xD6, 0xD8, 0x00, 0x00, 0x01, - 0xF0, 0x00, 0x60, 0x0C, 0x00, 0x18, 0x30, 0x00, 0x00, 0x0D, 0x6D, 0x80, 0x00, 0x00, 0x31, - 0x80, 0x03, 0x01, 0xC0, 0x01, 0x83, 0x00, 0x00, 0x00, 0x6C, 0xD8, 0x00, 0x00, 0x06, 0x0C, - 0x00, 0x38, 0x18, 0x00, 0x19, 0x30, 0x05, 0x07, 0x00, 0xCA, 0x60, 0x01, 0x81, 0x00, 0x01, - 0x93, 0x05, 0x07, 0x00, 0x0C, 0x46, 0x00, 0x0C, 0x30, 0x00, 0x19, 0x30, 0x05, 0x07, 0x00, - 0xCA, 0x60, 0x00, 0xC2, 0x00, 0xFF, 0x83, 0xFE, 0x05, 0x05, 0x00, 0x07, 0x06, 0x0C, 0x1C, - 0x04, 0x60, 0x0F, 0xF8, 0x3F, 0xE0, 0x05, 0x05, 0x00, 0xF8, 0x31, 0x83, 0xE0, 0x64, 0x00, - 0xC0, 0x00, 0x06, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x18, 0xC1, 0xF0, 0x63, 0x02, 0x40, 0x0C, - 0x00, 0x00, 0x60, 0x01, 0x99, 0x99, 0x98, 0x03, 0x06, 0x0E, 0x0C, 0x98, 0x2C, 0x00, 0xCE, - 0x00, 0xE6, 0x00, 0x10, 0x90, 0x90, 0x80, 0x65, 0x30, 0x01, 0x94, 0xC3, 0x80, 0x0C, 0x00, - 0x00, 0x60, 0x01, 0x09, 0x09, 0x08, 0x06, 0x73, 0x00, 0x19, 0xCC, 0x18, 0x00, 0xC0, 0x00, - 0x06, 0x00, 0x19, 0x99, 0x99, 0x80, 0x61, 0x30, 0x01, 0x94, 0xC1, 0x80, 0x0F, 0xF8, 0x3F, - 0xE0, 0x00, 0xF0, 0xF0, 0xF0, 0x03, 0x26, 0x0E, 0x0C, 0x18, 0x18, 0x00, 0xFF, 0x83, 0xFE, - 0x05, 0x05, 0x00, 0x18, 0xC1, 0xF0, 0x63, 0x01, 0x80, 0x00, 0x19, 0x30, 0x05, 0x06, 0x00, - 0xF8, 0x31, 0x83, 0xE0, 0x18, 0x00, 0x01, 0x93, 0x05, 0x06, 0x00, 0x07, 0x06, 0x8C, 0x1C, - 0x01, 0x80, 0x00, 0x19, 0x30, 0x05, 0x07, 0x00, 0xC8, 0x60, 0x00, 0x18, 0x00, 0x01, 0x83, - 0x05, 0x07, 0x00, 0x0C, 0xC6, 0x00, 0x01, 0x80, 0x00, 0x18, 0x30, 0x05, 0x07, 0x00, 0xCA, - 0x60, 0x00, 0x1C, 0x00, 0x01, 0xFF, 0x05, 0x07, 0x00, 0x06, 0x6C, 0x00, 0x03, 0x40, 0x00, - 0x1F, 0xF0, 0x05, 0x07, 0x00, 0x31, 0x80, 0x00, 0x24, 0x05, 0x0A, 0x00, 0x01, 0xF0, 0x00, - 0x02, 0x60, 0x05, 0x0A, 0x00, 0x0E, 0x00, 0x00, 0x62, 0x05, 0x0D, 0x00, 0x04, 0x20, 0x05, - 0x0D, 0x00, 0x43, 0x05, 0x0D, 0x00, 0x0C, 0x10, 0x05, 0x0D, 0x00, 0x81, 0x80, 0x05, 0x0C, - 0x00, 0x18, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x00, 0x60, 0x05, 0x0C, 0x00, 0x60, 0x03, 0x05, - 0x0C, 0x00, 0x0C, 0x00, 0x18, 0x05, 0x0B, 0x00, 0x01, 0x80, 0x00, 0xE0, 0x05, 0x0B, 0x00, - 0x70, 0x00, 0x03, 0x05, 0x0B, 0x00, 0x0C, 0x00, 0x00, 0x1C, 0x05, 0x0A, 0x00, 0x03, 0x80, - 0x00, 0x00, 0x78, 0x05, 0x09, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x05, 0x0A, 0xFF, 0xF0, - 0x00, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_A1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_btn_A1.c deleted file mode 100644 index 0889b2a08..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_A1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ############## -// ######..###### -// ####..##..#### -// ####......#### -// ####..##..#### -// ############## -// ############## - -#include "images.h" - -const image_t img_cc_btn_A1 = {7, 7, false, 7, 0, {0xFF, 0xDF, 0x5E, 0x3D, 0x7F, 0xFF, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_B1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_btn_B1.c deleted file mode 100644 index bbf5fba1a..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_B1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ############## -// ####..######## -// ####..######## -// ####....###### -// ####..##..#### -// ######....#### -// ############## - -#include "images.h" - -const image_t img_cc_btn_B1 = {7, 7, false, 7, 0, {0xFF, 0xBF, 0x7E, 0x7D, 0x7C, 0xFF, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_X1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_btn_X1.c deleted file mode 100644 index 2352ba695..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_X1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ############## -// ############## -// ####..##..#### -// ######..###### -// ####..##..#### -// ############## -// ############## - -#include "images.h" - -const image_t img_cc_btn_X1 = {7, 7, false, 7, 0, {0xFF, 0xFF, 0x5F, 0x7D, 0x7F, 0xFF, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_Y1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_btn_Y1.c deleted file mode 100644 index d7192e3e7..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_btn_Y1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ############## -// ############## -// ####..##..#### -// ####......#### -// ########..#### -// ######..###### -// ############## - -#include "images.h" - -const image_t img_cc_btn_Y1 = {7, 7, false, 7, 0, {0xFF, 0xFF, 0x5E, 0x3F, 0x7D, 0xFF, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_pad_LR1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_pad_LR1.c deleted file mode 100644 index 300ed5eee..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_pad_LR1.c +++ /dev/null @@ -1,9 +0,0 @@ -// ############## -// ############## -// ####......#### -// ############## -// ############## - -#include "images.h" - -const image_t img_cc_pad_LR1 = {7, 5, false, 5, 0, {0xFF, 0xFF, 0x1F, 0xFF, 0xE0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_pad_UD1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_pad_UD1.c deleted file mode 100644 index feb32d283..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_pad_UD1.c +++ /dev/null @@ -1,11 +0,0 @@ -// ########## -// ########## -// ####..#### -// ####..#### -// ####..#### -// ########## -// ########## - -#include "images.h" - -const image_t img_cc_pad_UD1 = {5, 7, false, 5, 0, {0xFF, 0xF7, 0xBD, 0xFF, 0xE0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L1.c deleted file mode 100644 index c70e35334..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L1.c +++ /dev/null @@ -1,16 +0,0 @@ -// ......##############....##....##.. -// ..####..##....##....##....##....## -// ##....##....##....##....##....##.. -// ##..##....##....##....##....##.... -// ..##....##....##....############## -// ##....##############.............. - -#include "images.h" - -const image_t img_cc_trg_L1 = { - 17, - 6, - false, - 13, - 0, - {0x1F, 0xC9, 0x34, 0x92, 0x64, 0x92, 0x54, 0x92, 0x44, 0x93, 0xFC, 0xFE, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L2.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L2.c deleted file mode 100644 index 47561ab98..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L2.c +++ /dev/null @@ -1,28 +0,0 @@ -// ......##############..##..##..##.. -// ..####..##..##..##..##..##..##..## -// ####..##..##..##..##..##..##..##.. -// ##..##..##..##..##..##..##..##..## -// ..##..##..##..##..################ -// ##..##..############.............. - -#include "images.h" - -const image_t img_cc_trg_L2 = { - 17, - 6, - true, - 12, - 0x01, - {// orig:13, comp:7.69% - 0x1F, - 0xD5, - 0x35, - 0x55, - 0x75, - 0x01, - 0x04, - 0x55, - 0x57, - 0xFD, - 0x7E, - 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L3.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L3.c deleted file mode 100644 index 0b51bed35..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L3.c +++ /dev/null @@ -1,16 +0,0 @@ -// ......############..####..####..## -// ..######..####..####..####..####.. -// ######..####..####..####..####..## -// ####..####..####..####..####..#### -// ##..####..####..################## -// ..####..############.............. - -#include "images.h" - -const image_t img_cc_trg_L3 = { - 17, - 6, - false, - 13, - 0, - {0x1F, 0xB6, 0xBB, 0x6D, 0xBB, 0x6D, 0xBB, 0x6D, 0xBB, 0x6F, 0xFB, 0x7E, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L4.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L4.c deleted file mode 100644 index 062caca77..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_L4.c +++ /dev/null @@ -1,24 +0,0 @@ -// ......############################ -// ..################################ -// ################################## -// ################################## -// ################################## -// ####################.............. - -#include "images.h" - -const image_t img_cc_trg_L4 = { - 17, - 6, - true, - 8, - 0x01, - {// orig:13, comp:38.46% - 0x1F, - 0xFF, - 0xBF, - 0x01, - 0x08, - 0xFF, - 0xFE, - 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R1.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R1.c deleted file mode 100644 index 6f08886d3..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R1.c +++ /dev/null @@ -1,16 +0,0 @@ -// ..##....##....##############...... -// ##....##....##....##....##..####.. -// ..##....##....##....##....##....## -// ....##....##....##....##....##..## -// ##############....##....##....##.. -// ..............##############....## - -#include "images.h" - -const image_t img_cc_trg_R1 = { - 17, - 6, - false, - 13, - 0, - {0x49, 0xFC, 0x49, 0x25, 0x92, 0x49, 0x24, 0x92, 0x5F, 0xE4, 0x90, 0x0F, 0xE4}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R2.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R2.c deleted file mode 100644 index d85e45761..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R2.c +++ /dev/null @@ -1,16 +0,0 @@ -// ..##..##..##..##############...... -// ##..##..##..##..##..##..##..####.. -// ..##..##..##..##..##..##..##..#### -// ##..##..##..##..##..##..##..##..## -// ################..##..##..##..##.. -// ..............############..##..## - -#include "images.h" - -const image_t img_cc_trg_R2 = { - 17, - 6, - false, - 13, - 0, - {0x55, 0xFC, 0x55, 0x55, 0x95, 0x55, 0x75, 0x55, 0x5F, 0xF5, 0x50, 0x0F, 0xD4}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R3.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R3.c deleted file mode 100644 index 082d160e2..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R3.c +++ /dev/null @@ -1,16 +0,0 @@ -// ##..####..####..############...... -// ..####..####..####..####..######.. -// ##..####..####..####..####..###### -// ####..####..####..####..####..#### -// ##################..####..####..## -// ..............############..####.. - -#include "images.h" - -const image_t img_cc_trg_R3 = { - 17, - 6, - false, - 13, - 0, - {0xB6, 0xFC, 0x36, 0xDB, 0xAD, 0xB6, 0xFB, 0x6D, 0xBF, 0xFB, 0x68, 0x0F, 0xD8}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R4.c b/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R4.c deleted file mode 100644 index 0395058b8..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_cc_trg_R4.c +++ /dev/null @@ -1,27 +0,0 @@ -// ############################...... -// ################################.. -// ################################## -// ################################## -// ################################## -// ..............#################### - -#include "images.h" - -const image_t img_cc_trg_R4 = { - 17, - 6, - true, - 11, - 0x00, - {// orig:13, comp:15.38% - 0xFF, - 0xFC, - 0x7F, - 0xFF, - 0xBF, - 0x00, - 0x05, - 0xFF, - 0xF8, - 0x0F, - 0xFC}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_csLogo_FULL.c b/applications/plugins/wii_ec_anal/gfx/img_csLogo_FULL.c deleted file mode 100644 index a8c030fa2..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_csLogo_FULL.c +++ /dev/null @@ -1,89 +0,0 @@ -// ....##########################################........##..........##........##############........##############........##############........##############............................................................................................ -// ....##########################################......######......######......##############........##############........##############........##############............................................................................................ -// ############..............................######....######......######....####........######....######......######................######....######......######..............######..######..######...................................................... -// ############..............................##..##....##..##......##..##....######......######....######......######....######......######....######......##..##..............##......##........##........................................................ -// ############..............................##..##....##..##......##..##....######......##..##....##..##......##..##....######......##..##....##..##......##..##..............####....######....##........................................................ -// ####....####..............................##..##....##..##......##..##....##..##......##..##....##..##......##..##....##..##......##..##....##..##......##..##..............##..........##....##........................................................ -// ############..............................######....##..##......##..##....##..##......##..##....##..##......##..##....##..##......##..##....##..##......######..............######..######....##..##.................................................... -// ############........................................##..##......##..##....##..##......######....##..##..##..##..##....##..##......######....##..##...................................................................................................... -// ####....####........................................######......######....##..##########........##..##......##..##....##..##########........##..##........................####..######..######..##...................................................... -// ######..####........####..............................##############......##..##########........##..##......##..##....##..##########........##..##..########................##..##..##..##..##..##..##.................................................. -// ####..######........####................................####..####........##..##......######....##..##..##..##..##....##..##....######......##..##..##########..............##..######..######..######.................................................. -// ######..####................####..........................##..##..........##..##......##..##....##..##......##..##....##..##....##..##......##..##......##..##..............##......##..##..##......##.................................................. -// ####..######..............##....##........................##..##..........##..##......##..##....##..##......##..##....##..##....##..##......##..##......##..##............######....##..######......##..................................##.............. -// ######..####..............##....##........................##..##..........##..##......##..##....##..##......##..##....##..##....##..##......######......##..##........................................................................##..##............ -// ####..######................####..........................##..##..........######......######....######......######....##..##....##..##......######......##..##..................................................................######......##.......... -// ####....####..............................................######..........######......######....######......######....##..##....##..##......####........######..................................................................####....##....##........ -// ####....####..............................................######............##############........##############......######....######........##############....................................................................##....##..##....##...... -// ####....####............................................##########..........##############........##############......######......######......##############..............................................................######....##......##....##.... -// ####....####..............................................................................................................................................................................................................####........##..##..##....##.. -// ####....####..............................................................................................................................................................................................................##....##......##......##....## -// ####....####....................##############........##..........##........##############......##################......##############........##############........##############..................................######....##..........##..##....#### -// ####....####....................##############......######......######......##############......##################......##############........##############........##############..................................####....##......##......##....###### -// ####..######..................####........######....######......######....####........######....####..######..####....####....##########....##################....####........######................................##........##..##..##........######## -// ######..####..................######......##..##....##..##......##..##....######......##..##..........##..##..........######................######..##..######....######......##..##..........................######....##......##......##....########.. -// ####..######..................##..##......##..##....##..##......##..##....##..##......##..##..........##..##..........##..##................##..##..##..##..##....##..##......##..##..........................####....##..##..........##....##########.. -// ######..####..................##..##......##..##....##..##......##..##....##..##......##..##..........##..##..........##..##................##..##..##..##..##....##..##......##..##..........................##....##......##......##....############## -// ####..######..................##..##......######....##..##......##..##....##..##......######..........##..##..........##..##................##..##..##..##..##....##..##......######....................######............##..##........########....#### -// ######..####..................######................##..##......##..##....######......................##..##..........##..##....######......##..##..##..##..##....######................................####....................##....##########........ -// ####....####....................############........######......######......############..............##..##..........##..########..........##..##..##..##..##......############........................##....##..............##....##############...... -// ############........................##########........##############............##########............##..##..........##..########..........##..##..##..##..##..........##########....................##....##..##..........##....########....####...... -// ############..............................######........####..####....................######..........##..##..........##..##....######......##..##..##..##..##................######................##..##........##............##########.............. -// ####....####..................######......##..##..........##..##..........######......##..##..........##..##..........##..##................##..##......##..##....######......##..##................####............##..##....##############............ -// ############..................##..##......##..##..........##..##..........##..##......##..##..........##..##..........##..##................##..##..##..##..##....##..##......##..##................####....##........##....########....####............ -// ############..........####....##..##......##..##..........##..##..........##..##......##..##..........##..##..........##..##................##..##......##..##....##..##......##..##..................##########....##....##########.................... -// ############..........####....##..##......######..........##..##..........##..##......######..........##..##..........######................##..##......##..##....##..##......######....................######..........##############.................. -// ############..........####....######........####..........######..........######........####..........##..##..........####....##########....##..##......##..##....######........####......................####........########....####.................. -// ....######################......##############............######............##############............######............##############......######......######......##############..........................######..##########.......................... -// ....######################......##############..........##########..........##############............######............##############......######......######......##############............................##################........................ -// ................................................................................................................................................................................................................########....####........................ -// ..................................................................................................................................................................................................................####.................................. - -#include "images.h" - -const image_t img_csLogo_FULL = { - 124, - 40, - true, - 571, - 0x0B, - {// orig:620, comp:7.90% - 0x3F, 0xFF, 0xFE, 0x10, 0x43, 0xF8, 0x7F, 0x0F, 0xE1, 0xFC, 0x0B, 0x05, 0x00, 0x03, 0xFF, - 0xFF, 0xE3, 0x8E, 0x3F, 0x87, 0xF0, 0xFE, 0x1F, 0xC0, 0x0B, 0x05, 0x00, 0xFC, 0x00, 0x07, - 0x38, 0xE6, 0x1C, 0xE3, 0x80, 0x73, 0x8E, 0x03, 0xBB, 0x80, 0x00, 0x00, 0x0F, 0xC0, 0x00, - 0x52, 0x8A, 0x71, 0xCE, 0x39, 0xC7, 0x38, 0xA0, 0x22, 0x10, 0x00, 0x00, 0x00, 0xFC, 0x00, - 0x05, 0x28, 0xA7, 0x14, 0xA2, 0x9C, 0x52, 0x8A, 0x03, 0x39, 0x00, 0x00, 0x00, 0x0C, 0xC0, - 0x00, 0x52, 0x8A, 0x51, 0x4A, 0x29, 0x45, 0x28, 0xA0, 0x20, 0x90, 0x00, 0x00, 0x00, 0xFC, - 0x00, 0x07, 0x28, 0xA5, 0x14, 0xA2, 0x94, 0x52, 0x8E, 0x03, 0xB9, 0x40, 0x00, 0x00, 0x0F, - 0xC0, 0x00, 0x02, 0x8A, 0x51, 0xCA, 0xA9, 0x47, 0x28, 0x0B, 0x06, 0x00, 0xCC, 0x00, 0x00, - 0x38, 0xE5, 0xF0, 0xA2, 0x97, 0xC2, 0x80, 0x06, 0xEE, 0x80, 0x00, 0x00, 0x0E, 0xC3, 0x00, - 0x01, 0xFC, 0x5F, 0x0A, 0x29, 0x7C, 0x2B, 0xC0, 0x2A, 0xAA, 0x00, 0x00, 0x00, 0xDC, 0x30, - 0x00, 0x0D, 0x85, 0x1C, 0xAA, 0x94, 0xE2, 0xBE, 0x02, 0xEE, 0xE0, 0x00, 0x00, 0x0E, 0xC0, - 0x30, 0x00, 0x50, 0x51, 0x4A, 0x29, 0x4A, 0x28, 0xA0, 0x22, 0xA2, 0x00, 0x00, 0x00, 0xDC, - 0x04, 0x80, 0x05, 0x05, 0x14, 0xA2, 0x94, 0xA2, 0x8A, 0x07, 0x2E, 0x20, 0x00, 0x08, 0x0E, - 0xC0, 0x48, 0x00, 0x50, 0x51, 0x4A, 0x29, 0x4A, 0x38, 0xA0, 0x00, 0x00, 0x00, 0x01, 0x40, - 0xDC, 0x03, 0x00, 0x05, 0x07, 0x1C, 0xE3, 0x94, 0xA3, 0x8A, 0x0B, 0x04, 0x00, 0xE2, 0x0C, - 0xC0, 0x00, 0x00, 0x70, 0x71, 0xCE, 0x39, 0x4A, 0x30, 0xE0, 0x00, 0x00, 0x00, 0x0C, 0x90, - 0xCC, 0x00, 0x00, 0x07, 0x03, 0xF8, 0x7F, 0x1C, 0xE1, 0xFC, 0x0B, 0x04, 0x00, 0x94, 0x8C, - 0xC0, 0x00, 0x00, 0xF8, 0x3F, 0x87, 0xF1, 0xC7, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x72, 0x24, - 0xCC, 0x0B, 0x0C, 0x00, 0x06, 0x15, 0x2C, 0xC0, 0x0B, 0x0C, 0x00, 0x48, 0x89, 0xCC, 0x00, - 0xFE, 0x10, 0x43, 0xF8, 0xFF, 0x8F, 0xE1, 0xFC, 0x3F, 0x80, 0x00, 0x39, 0x05, 0x3C, 0xC0, - 0x0F, 0xE3, 0x8E, 0x3F, 0x8F, 0xF8, 0xFE, 0x1F, 0xC3, 0xF8, 0x00, 0x03, 0x22, 0x27, 0xDC, - 0x01, 0x87, 0x38, 0xE6, 0x1C, 0xDD, 0x99, 0xF3, 0xFE, 0x61, 0xC0, 0x00, 0x21, 0x50, 0xFE, - 0xC0, 0x1C, 0x52, 0x8A, 0x71, 0x41, 0x41, 0xC0, 0x3A, 0xE7, 0x14, 0x00, 0x1C, 0x88, 0x9E, - 0xDC, 0x01, 0x45, 0x28, 0xA5, 0x14, 0x14, 0x14, 0x02, 0xAA, 0x51, 0x40, 0x01, 0x94, 0x13, - 0xEE, 0xC0, 0x14, 0x52, 0x8A, 0x51, 0x41, 0x41, 0x40, 0x2A, 0xA5, 0x14, 0x00, 0x12, 0x22, - 0x7F, 0xDC, 0x01, 0x47, 0x28, 0xA5, 0x1C, 0x14, 0x14, 0x02, 0xAA, 0x51, 0xC0, 0x0E, 0x05, - 0x0F, 0x3E, 0xC0, 0x1C, 0x02, 0x8A, 0x70, 0x01, 0x41, 0x4E, 0x2A, 0xA7, 0x00, 0x00, 0xC0, - 0x09, 0xF0, 0xCC, 0x00, 0xFC, 0x38, 0xE3, 0xF0, 0x14, 0x17, 0x82, 0xAA, 0x3F, 0x00, 0x09, - 0x01, 0x3F, 0x8F, 0xC0, 0x03, 0xE1, 0xFC, 0x0F, 0x81, 0x41, 0x78, 0x2A, 0xA0, 0xF8, 0x01, - 0x28, 0x27, 0x98, 0xFC, 0x00, 0x07, 0x0D, 0x80, 0x1C, 0x14, 0x14, 0xE2, 0xAA, 0x01, 0xC0, - 0x28, 0x40, 0xF8, 0x0C, 0xC0, 0x1C, 0x50, 0x50, 0x71, 0x41, 0x41, 0x40, 0x28, 0xA7, 0x14, - 0x03, 0x02, 0x9F, 0xC0, 0xFC, 0x01, 0x45, 0x05, 0x05, 0x14, 0x14, 0x14, 0x02, 0xAA, 0x51, - 0x40, 0x32, 0x13, 0xCC, 0x0F, 0xC1, 0x94, 0x50, 0x50, 0x51, 0x41, 0x41, 0x40, 0x28, 0xA5, - 0x14, 0x01, 0xF2, 0x7C, 0x00, 0xFC, 0x19, 0x47, 0x05, 0x05, 0x1C, 0x14, 0x1C, 0x02, 0x8A, - 0x51, 0xC0, 0x0E, 0x0F, 0xE0, 0x0F, 0xC1, 0x9C, 0x30, 0x70, 0x70, 0xC1, 0x41, 0x9F, 0x28, - 0xA7, 0x0C, 0x00, 0x61, 0xE6, 0x00, 0x3F, 0xF8, 0xFE, 0x07, 0x03, 0xF8, 0x1C, 0x0F, 0xE3, - 0x8E, 0x3F, 0x80, 0x03, 0xBE, 0x00, 0x03, 0xFF, 0x8F, 0xE0, 0xF8, 0x3F, 0x81, 0xC0, 0xFE, - 0x38, 0xE3, 0xF8, 0x00, 0x1F, 0xF0, 0x0B, 0x0E, 0x00, 0xF3, 0x0B, 0x0E, 0x00, 0x06, 0x00, - 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_csLogo_Small.c b/applications/plugins/wii_ec_anal/gfx/img_csLogo_Small.c deleted file mode 100644 index 71debc2ff..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_csLogo_Small.c +++ /dev/null @@ -1,22 +0,0 @@ -// ################## -// ################## -// ####..........#### -// ####..........#### -// ####..##.......... -// ####......######## -// ####......##....## -// ####......##...... -// ####......######## -// ####............## -// ########..##....## -// ########..######## - -#include "images.h" - -const image_t img_csLogo_Small = { - 9, - 12, - false, - 14, - 0, - {0xFF, 0xFF, 0xF0, 0x78, 0x3D, 0x06, 0x3F, 0x13, 0x88, 0xC7, 0xE0, 0x7D, 0x3E, 0xF0}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_ecp_SCL.c b/applications/plugins/wii_ec_anal/gfx/img_ecp_SCL.c deleted file mode 100644 index e3622a626..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_ecp_SCL.c +++ /dev/null @@ -1,17 +0,0 @@ -// ....##############......######## -// ....##############......######## -// ....####......####......####.... -// ....####......####......####.... -// ....####......####......####.... -// ########......##############.... -// ########......##############.... - -#include "images.h" - -const image_t img_ecp_SCL = { - 16, - 7, - false, - 14, - 0, - {0x3F, 0x8F, 0x3F, 0x8F, 0x31, 0x8C, 0x31, 0x8C, 0x31, 0x8C, 0xF1, 0xFC, 0xF1, 0xFC}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_ecp_SDA.c b/applications/plugins/wii_ec_anal/gfx/img_ecp_SDA.c deleted file mode 100644 index 5ce0cbec4..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_ecp_SDA.c +++ /dev/null @@ -1,19 +0,0 @@ -// ......##.......................... -// ....####.......................... -// ..####............................ -// ######################............ -// ######################....##...... -// ..####....................####.... -// ....####....................####.. -// ......##....###################### -// ............###################### -// ............................####.. -// ..........................####.... -// ..........................##...... - -#include "images.h" - -const image_t img_ecp_SDA = {17, 12, false, 26, 0, {0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x1F, - 0xFC, 0x0F, 0xFE, 0x43, 0x00, 0x30, 0xC0, - 0x0C, 0x27, 0xFF, 0x03, 0xFF, 0x80, 0x01, - 0x80, 0x01, 0x80, 0x00, 0x80}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_ecp_port.c b/applications/plugins/wii_ec_anal/gfx/img_ecp_port.c deleted file mode 100644 index 60f535458..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_ecp_port.c +++ /dev/null @@ -1,72 +0,0 @@ -// ....................##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..## -// ..................##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. -// ................##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..## -// ..............##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. -// ............##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..## -// ..........##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##.. -// ........##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..##..## -// ......######################################################################################################################..##..##..##.. -// ......########################################################################################################################..##..##..## -// ......####..............................................................................................................####..##..##..##.. -// ......####..............................................................................................................######..##..##..## -// ......####..............................................................................................................####..##..##..##.. -// ......####..............................................................................................................######..##..##..## -// ......####..............................................................................................................####..##..##..##.. -// ......####........##############################################################################################........######..##..##..## -// ......####........##############################################################################################........####..##..##..##.. -// ......####........####........####..........####........####..........####........####..........####........####........######..##..##..## -// ......####........####........####..........####........####..........####........####..........####........####........####..##..##..##.. -// ......####........####........##################........##################........##################........####........######..##..##..## -// ......####........####........##################........##################........##################........####........####..##..##..##.. -// ......####........####......................................................................................####........######..##..##..## -// ..########........####......................................................................................####........####..##########.. -// ##########........####......................................................................................####........################## -// ##########........####......................................................................................####........####..##########.. -// ..########........####......................................................................................####........################## -// ......####........####........##################..................................##################........####........####..##..##..##.. -// ......####........####........##################..................................##################........####........######..##..##..## -// ......####........####........####..........####........##################........####..........####........####........####..##..##..##.. -// ......####........####........####..........####........##..............##........####..........####........####........######..##..##..## -// ......####........##############################################################################################........####..##..##..##.. -// ......####........##############################################################################################........######..##..##..## -// ......####..............................................................................................................####..##..##..##.. -// ......####..............................................................................................................######..##..##..## -// ......####..............................................................................................................####..##..##..##.. -// ......####....................................######################################....................................######..##..##..## -// ......####....................................######################################....................................####..##..##..##.. -// ......####....................................####..##..##..##..................####....................................######..##..##.... -// ......####....................................######..##..##....................####....................................####..##..##...... -// ......####....................................####..##..##......................####....................................######..##........ -// ......####....................................######..##........................####....................................####..##.......... -// ......############################################..##..........................##############################################............ -// ......##############################################............................############################################.............. - -#include "images.h" - -const image_t img_ecp_port = { - 69, - 42, - true, - 290, - 0x04, - {// orig:363, comp:20.11% - 0x00, 0x2A, 0x04, 0x06, 0xAA, 0xA8, 0x02, 0x04, 0x07, 0xAA, 0x80, 0x2A, 0x04, 0x07, 0xAA, - 0x02, 0x04, 0x07, 0xAA, 0xA0, 0x2A, 0x04, 0x07, 0xAA, 0x82, 0x04, 0x07, 0xAA, 0xA8, 0x2A, - 0x04, 0x07, 0xAA, 0xA3, 0x04, 0x07, 0xFF, 0xAA, 0x1F, 0x04, 0x06, 0xFF, 0xFE, 0xA8, 0xC0, - 0x04, 0x06, 0x00, 0x6A, 0x86, 0x04, 0x06, 0x00, 0x03, 0xAA, 0x30, 0x04, 0x06, 0x00, 0x1A, - 0xA1, 0x80, 0x04, 0x06, 0x00, 0xEA, 0x8C, 0x04, 0x06, 0x00, 0x06, 0xA8, 0x61, 0x04, 0x05, - 0xFF, 0xFC, 0x3A, 0xA3, 0x0F, 0x04, 0x05, 0xFF, 0xE1, 0xAA, 0x18, 0x61, 0x83, 0x0C, 0x18, - 0x60, 0xC3, 0x0E, 0xA8, 0xC3, 0x0C, 0x18, 0x60, 0xC3, 0x06, 0x18, 0x6A, 0x86, 0x18, 0x7F, - 0xC3, 0xFE, 0x1F, 0xF0, 0xC3, 0xAA, 0x30, 0xC3, 0xFE, 0x1F, 0xF0, 0xFF, 0x86, 0x1A, 0xA1, - 0x86, 0x04, 0x05, 0x00, 0x30, 0xEA, 0xBC, 0x30, 0x04, 0x04, 0x00, 0x01, 0x86, 0xFB, 0xE1, - 0x80, 0x04, 0x04, 0x00, 0x0C, 0x3F, 0xFF, 0x0C, 0x04, 0x05, 0x00, 0x61, 0xBE, 0x78, 0x60, - 0x04, 0x04, 0x00, 0x03, 0x0F, 0xF8, 0xC3, 0x0F, 0xF8, 0x00, 0x03, 0xFE, 0x18, 0x6A, 0x86, - 0x18, 0x7F, 0xC0, 0x00, 0x1F, 0xF0, 0xC3, 0xAA, 0x30, 0xC3, 0x06, 0x1F, 0xF0, 0xC1, 0x86, - 0x1A, 0xA1, 0x86, 0x18, 0x30, 0x80, 0x86, 0x0C, 0x30, 0xEA, 0x8C, 0x3F, 0x04, 0x05, 0xFF, - 0x86, 0xA8, 0x61, 0x04, 0x05, 0xFF, 0xFC, 0x3A, 0xA3, 0x04, 0x06, 0x00, 0x01, 0xAA, 0x18, - 0x04, 0x06, 0x00, 0x0E, 0xA8, 0xC0, 0x04, 0x06, 0x00, 0x6A, 0x86, 0x00, 0x00, 0x7F, 0xFF, - 0xF0, 0x00, 0x03, 0xAA, 0x30, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x00, 0x1A, 0xA1, 0x80, 0x00, - 0x1A, 0xA0, 0x0C, 0x00, 0x00, 0xEA, 0x0C, 0x00, 0x00, 0xEA, 0x00, 0x60, 0x00, 0x06, 0xA0, - 0x60, 0x00, 0x06, 0xA0, 0x03, 0x00, 0x00, 0x3A, 0x03, 0x00, 0x00, 0x3A, 0x00, 0x18, 0x00, - 0x01, 0xA0, 0x1F, 0xFF, 0xFF, 0xA0, 0x00, 0xFF, 0xFF, 0xFE, 0x00, 0xFF, 0xFF, 0xFE, 0x00, - 0x07, 0xFF, 0xFF, 0xE0, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_Back.c b/applications/plugins/wii_ec_anal/gfx/img_key_Back.c deleted file mode 100644 index 23c17fe2b..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_Back.c +++ /dev/null @@ -1,14 +0,0 @@ -// ..##############.. -// ################## -// ######..########## -// ####........###### -// ######..####..#### -// ############..#### -// ########....###### -// ################## -// ....############.. - -#include "images.h" - -const image_t img_key_Back = - {9, 9, false, 11, 0, {0x7F, 0x7F, 0xFB, 0xF8, 0x7E, 0xDF, 0xEF, 0xCF, 0xFF, 0x3F, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_D.c b/applications/plugins/wii_ec_anal/gfx/img_key_D.c deleted file mode 100644 index 689b9148c..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_D.c +++ /dev/null @@ -1,13 +0,0 @@ -// ..##############.. -// ################## -// ################## -// ####..........#### -// ######......###### -// ########..######## -// ################## -// ..##############.. - -#include "images.h" - -const image_t img_key_D = - {9, 8, false, 9, 0, {0x7F, 0x7F, 0xFF, 0xF8, 0x3E, 0x3F, 0xBF, 0xFE, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_L.c b/applications/plugins/wii_ec_anal/gfx/img_key_L.c deleted file mode 100644 index a5fca1a21..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_L.c +++ /dev/null @@ -1,14 +0,0 @@ -// ..############.. -// ################ -// ########..###### -// ######....###### -// ####......###### -// ######....###### -// ########..###### -// ################ -// ..############.. - -#include "images.h" - -const image_t img_key_L = - {8, 9, false, 9, 0, {0x7E, 0xFF, 0xF7, 0xE7, 0xC7, 0xE7, 0xF7, 0xFF, 0x7E}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_OK.c b/applications/plugins/wii_ec_anal/gfx/img_key_OK.c deleted file mode 100644 index 926d91c2e..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_OK.c +++ /dev/null @@ -1,14 +0,0 @@ -// ..##############.. -// ################## -// ######......###### -// ####..........#### -// ####..........#### -// ####..........#### -// ######......###### -// ################## -// ....############.. - -#include "images.h" - -const image_t img_key_OK = - {9, 9, false, 11, 0, {0x7F, 0x7F, 0xF8, 0xF8, 0x3C, 0x1E, 0x0F, 0x8F, 0xFF, 0x3F, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_OKi.c b/applications/plugins/wii_ec_anal/gfx/img_key_OKi.c deleted file mode 100644 index aa6f9e692..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_OKi.c +++ /dev/null @@ -1,14 +0,0 @@ -// ..##############.. -// ####..........#### -// ##....######....## -// ##..##########..## -// ##..##########..## -// ##..##########..## -// ##....######....## -// ####..........#### -// ..##############.. - -#include "images.h" - -const image_t img_key_OKi = - {9, 9, false, 11, 0, {0x7F, 0x60, 0xE7, 0x37, 0xDB, 0xED, 0xF6, 0x73, 0x83, 0x7F, 0x00}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_R.c b/applications/plugins/wii_ec_anal/gfx/img_key_R.c deleted file mode 100644 index 8b97c7b48..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_R.c +++ /dev/null @@ -1,14 +0,0 @@ -// ..############.. -// ################ -// ######..######## -// ######....###### -// ######......#### -// ######....###### -// ######..######## -// ################ -// ..############.. - -#include "images.h" - -const image_t img_key_R = - {8, 9, false, 9, 0, {0x7E, 0xFF, 0xEF, 0xE7, 0xE3, 0xE7, 0xEF, 0xFF, 0x7E}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_U.c b/applications/plugins/wii_ec_anal/gfx/img_key_U.c deleted file mode 100644 index 65f4cd9e0..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_U.c +++ /dev/null @@ -1,13 +0,0 @@ -// ..##############.. -// ################## -// ########..######## -// ######......###### -// ####..........#### -// ################## -// ################## -// ..##############.. - -#include "images.h" - -const image_t img_key_U = - {9, 8, false, 9, 0, {0x7F, 0x7F, 0xFD, 0xFC, 0x7C, 0x1F, 0xFF, 0xFE, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/gfx/img_key_Ui.c b/applications/plugins/wii_ec_anal/gfx/img_key_Ui.c deleted file mode 100644 index 30c60c66e..000000000 --- a/applications/plugins/wii_ec_anal/gfx/img_key_Ui.c +++ /dev/null @@ -1,13 +0,0 @@ -// ..##############.. -// ####..........#### -// ##......##......## -// ##....######....## -// ##..##########..## -// ##..............## -// ####..........#### -// ..##############.. - -#include "images.h" - -const image_t img_key_Ui = - {9, 8, false, 9, 0, {0x7F, 0x60, 0xE2, 0x33, 0x9B, 0xEC, 0x07, 0x06, 0xFE}}; diff --git a/applications/plugins/wii_ec_anal/i2c_workaround.h b/applications/plugins/wii_ec_anal/i2c_workaround.h deleted file mode 100644 index b24efaf48..000000000 --- a/applications/plugins/wii_ec_anal/i2c_workaround.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - As of the date of releasing this code, there is (seemingly) a bug in the FZ i2c library code - It is described here: https://github.com/flipperdevices/flipperzero-firmware/issues/1670 - - This is a short-term workaround so I can keep developing while we get to the bottom of the issue - - FYI. *something* in the following code is the fix - -void furi_hal_i2c_acquire (FuriHalI2cBusHandle* handle) -{ - // 1. Disable the power/backlight (it uses i2c) - furi_hal_power_insomnia_enter(); - // 2. Lock bus access - handle->bus->callback(handle->bus, FuriHalI2cBusEventLock); - // 3. Ensuree that no active handle set - furi_check(handle->bus->current_handle == NULL); - // 4. Set current handle - handle->bus->current_handle = handle; - // 5. Activate bus - handle->bus->callback(handle->bus, FuriHalI2cBusEventActivate); - // 6. Activate handle - handle->callback(handle, FuriHalI2cBusHandleEventActivate); -} - -void furi_hal_i2c_release (FuriHalI2cBusHandle* handle) -{ - // Ensure that current handle is our handle - furi_check(handle->bus->current_handle == handle); - // 6. Deactivate handle - handle->callback(handle, FuriHalI2cBusHandleEventDeactivate); - // 5. Deactivate bus - handle->bus->callback(handle->bus, FuriHalI2cBusEventDeactivate); - // 3,4. Reset current handle - handle->bus->current_handle = NULL; - // 2. Unlock bus - handle->bus->callback(handle->bus, FuriHalI2cBusEventUnlock); - // 1. Re-enable the power system - furi_hal_power_insomnia_exit(); -} - -*/ - -#ifndef I2C_WORKAROUND_H_ -#define I2C_WORKAROUND_H_ - -#include - -#define ENABLE_WORKAROUND 1 - -#if ENABLE_WORKAROUND == 1 -//+============================================================================ ======================================== -static inline bool furi_hal_Wi2c_is_device_ready( - FuriHalI2cBusHandle* const bus, - const uint8_t addr, - const uint32_t tmo) { - furi_hal_i2c_acquire(bus); - bool rv = furi_hal_i2c_is_device_ready(bus, addr, tmo); - furi_hal_i2c_release(bus); - return rv; -} - -//+============================================================================ -static inline bool furi_hal_Wi2c_tx( - FuriHalI2cBusHandle* const bus, - const uint8_t addr, - const void* buf, - const size_t len, - const uint32_t tmo) { - furi_hal_i2c_acquire(bus); - bool rv = furi_hal_i2c_tx(bus, addr, buf, len, tmo); - furi_hal_i2c_release(bus); - return rv; -} - -//+============================================================================ -static inline bool furi_hal_Wi2c_rx( - FuriHalI2cBusHandle* const bus, - const uint8_t addr, - void* buf, - const size_t len, - const uint32_t tmo) { - furi_hal_i2c_acquire(bus); - bool rv = furi_hal_i2c_rx(bus, addr, buf, len, tmo); - furi_hal_i2c_release(bus); - return rv; -} - -//+============================================================================ -static inline bool furi_hal_Wi2c_trx( - FuriHalI2cBusHandle* const bus, - const uint8_t addr, - const void* tx, - const size_t txlen, - void* rx, - const size_t rxlen, - const uint32_t tmo) { - bool rv = furi_hal_Wi2c_tx(bus, addr, tx, txlen, tmo); - if(rv) rv = furi_hal_Wi2c_rx(bus, addr, rx, rxlen, tmo); - return rv; -} - -//----------------------------------------------------------------------------- ---------------------------------------- -#define furi_hal_i2c_is_device_ready(...) furi_hal_Wi2c_is_device_ready(__VA_ARGS__) -#define furi_hal_i2c_tx(...) furi_hal_Wi2c_tx(__VA_ARGS__) -#define furi_hal_i2c_rx(...) furi_hal_Wi2c_rx(__VA_ARGS__) -#define furi_hal_i2c_trx(...) furi_hal_Wi2c_trx(__VA_ARGS__) - -#endif //ENABLE_WORKAROUND - -//+============================================================================ ======================================== -// Some devices take a moment to respond to read requests -// The puts a delay between the address being set and the data being read -// -static inline bool furi_hal_i2c_trxd( - FuriHalI2cBusHandle* const bus, - const uint8_t addr, - const void* tx, - const size_t txlen, - void* rx, - const size_t rxlen, - const uint32_t tmo, - const uint32_t us) { - bool rv = furi_hal_i2c_tx(bus, addr, tx, txlen, tmo); - if(rv) { - furi_delay_us(us); - rv = furi_hal_i2c_rx(bus, addr, rx, rxlen, tmo); - } - return rv; -} - -#endif //I2C_WORKAROUND_H_ diff --git a/applications/plugins/wii_ec_anal/info.sh b/applications/plugins/wii_ec_anal/info.sh deleted file mode 100644 index e009eb118..000000000 --- a/applications/plugins/wii_ec_anal/info.sh +++ /dev/null @@ -1,11 +0,0 @@ -echo "MARKED AS TODO" -echo "==============" -grep //! *.c *.h - -echo -e "\nSUPPORTED CONTROLLERS" -echo "=====================" -grep '\[PID_.*{ {' wii_ec.c | head -n -3 | sed 's/\s*\(.*\)/\1/' - -echo -e "\nLOGGING" -echo "=======" -grep LOG_LEVEL *.h | grep -v '#if ' diff --git a/applications/plugins/wii_ec_anal/notes.txt b/applications/plugins/wii_ec_anal/notes.txt deleted file mode 100644 index 61b6e29af..000000000 --- a/applications/plugins/wii_ec_anal/notes.txt +++ /dev/null @@ -1,87 +0,0 @@ -//+============================================================================ ======================================== -// Select font -// A full list of u8g2 fonts can be found here: -// https://github.com/olikraus/u8g2/wiki/fntlistall -// ...and here are the ones available in FZ (currently: all of them): -// grep -P '.*u8g2.*\[[0-9]*\]' lib/u8g2/u8g2_fonts.c | sed 's/.*\(u8g2_.*\)\[.*/\1/' -// -#if 0 //! Extra fonts is just too memory hungry -#include -void setFont (Canvas* const canvas, const uint8_t* font) -{ - u8g2_SetFontMode(&canvas->fb, 1); // no idea - but canvas.c does it - u8g2_SetFont(&canvas->fb, font); -} -#endif - -litui : @BlueChip for posterity, the function to break at is flipper_application_spawn. At that point, you can set new breakpoints in your fap code and continue. - -/* - -This is wrong on quite a few levels! -https://training.ti.com/introduction-i2c-reserved-addresses - -void doit (void) -{ - furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); - printf("Scanning external i2c on PC0(SCL)/PC1(SDA)\r\n" - "Clock: 100khz, 7bit address\r\n" - "\r\n"); - printf(" | 0 1 2 3 4 5 6 7 8 9 A B C D E F\r\n"); - printf("--+--------------------------------\r\n"); - for(uint8_t row = 0; row < 0x8; row++) { - printf("%x | ", row); - for(uint8_t column = 0; column <= 0xF; column++) { - bool ret = furi_hal_i2c_is_device_ready( - &furi_hal_i2c_handle_external, ((row << 4) + column) << 1, 2); - printf("%c ", ret ? '#' : '-'); - } - printf("\r\n"); - } - furi_hal_i2c_release(&furi_hal_i2c_handle_external); -} -*/ - - -region locking : firmware/targets/f7/furi_hal/furi_hal_region.c - - -# if 0 //! scrolling works beautifully, but the LCD refresh can't keep up :( - // Waveform - if (cnt) { // start - for (int a = ACC_1; a < ACC_N; a++) { - canvas_draw_dot(canvas, x,y[a]+v[a][idx]); - for (int i = 1; i < aw -cnt; i++) { - canvas_draw_line(canvas, x+i,y[a]+v[a][i-1] , x+i,y[a]+v[a][i]); - } - } - } else { // scroll - for (int a = ACC_1; a < ACC_N; a++) { - for (int i = 0; i < aw; i++) { - int off = (idx +i) %aw; - int prev = off ? off-1 : aw-1; - canvas_draw_line(canvas, x+i,y[a]+v[a][prev] , x+i,y[a]+v[a][off]); - } - } - } - -# else - int end = idx ? idx : aw; - for (int a = ACC_1; a < ACC_N; a++) { - canvas_draw_dot(canvas, x,y[a]+v[a][idx]); - if (state->apause) { - for (int i = 1; i < end; i++) - canvas_draw_line(canvas, x+i,y[a]+v[a][i-1] , x+i,y[a]+v[a][i]); - } else { - for (int i = 1; i < end; i++) - canvas_draw_line(canvas, x+i,y[a]+v[a][i-1] , x+i,y[a]+v[a][i]); - for (int i = end+10; i < aw -cnt; i++) - canvas_draw_line(canvas, x+i,y[a]+v[a][i-1] , x+i,y[a]+v[a][i]); - } - } - - // Wipe bar - if (end < aw) canvas_draw_line(canvas, x+end,y[0], x+end,y[2]+ah-1); - if (++end < aw) canvas_draw_line(canvas, x+end,y[0], x+end,y[2]+ah-1); - if (++end < aw) canvas_draw_line(canvas, x+end,y[0], x+end,y[2]+ah-1); -# endif diff --git a/applications/plugins/wii_ec_anal/wii_anal.c b/applications/plugins/wii_ec_anal/wii_anal.c deleted file mode 100644 index f0af1c9c5..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal.c +++ /dev/null @@ -1,543 +0,0 @@ -//----------------------------------------------------------------------------- ---------------------------------------- -// Includes -// - -// System libs -#include // malloc -#include // uint32_t -#include // __VA_ARGS__ -#include -#include - -// FlipperZero libs -#include // Core API -#include // GUI (screen/keyboard) API -#include // GUI Input extensions -#include - -// Do this first! -#define ERR_C_ // Do this in precisely ONE file -#include "err.h" // Error numbers & messages - -#include "bc_logging.h" - -// Local headers -#include "wii_anal.h" // Various enums and struct declarations -#include "wii_i2c.h" // Wii i2c functions -#include "wii_ec.h" // Wii Extension Controller functions (eg. draw) -#include "wii_anal_keys.h" // key mappings -#include "gfx/images.h" // Images -#include "wii_anal_lcd.h" // Drawing functions -#include "wii_anal_ec.h" // Wii controller events - -#include "wii_anal_ver.h" // Version number - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// OOOOO // SSSSS CCCCC AAA L L BBBB AAA CCCC K K SSSSS -// O O /// S C A A L L B B A A C K K S -// O O /// SSSSS C AAAAA L L BBBB AAAAA C KKK SSSSS -// O O /// S C A A L L B B A A C K K S -// OOOOO // SSSSS CCCCC A A LLLLL LLLLL BBBB A A CCCC K K SSSSS -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//+============================================================================ ======================================== -// OS Callback : Timer tick -// We register this function to be called when the OS signals a timer 'tick' event -// -static void cbTimer(FuriMessageQueue* queue) { - ENTER; - furi_assert(queue); - - eventMsg_t message = {.id = EVID_TICK}; - furi_message_queue_put(queue, &message, 0); - - LEAVE; - return; -} - -//+============================================================================ ======================================== -// OS Callback : Keypress -// We register this function to be called when the OS detects a keypress -// -static void cbInput(InputEvent* event, FuriMessageQueue* queue) { - ENTER; - furi_assert(queue); - furi_assert(event); - - // Put an "input" event message on the message queue - eventMsg_t message = {.id = EVID_KEY, .input = *event}; - furi_message_queue_put(queue, &message, FuriWaitForever); - - LEAVE; - return; -} - -//+============================================================================ -// Show version number -// -static void showVer(Canvas* const canvas) { - show(canvas, 0, 59, &img_3x5_v, SHOW_SET_BLK); - show(canvas, 4, 59, VER_MAJ, SHOW_SET_BLK); - canvas_draw_frame(canvas, 8, 62, 2, 2); - show(canvas, 11, 59, VER_MIN, SHOW_SET_BLK); -} - -//+============================================================================ -// OS Callback : Draw request -// We register this function to be called when the OS requests that the screen is redrawn -// -// We actually instruct the OS to perform this request, after we update the interface -// I guess it's possible that this instruction may able be issued by other threads !? -// -static void cbDraw(Canvas* const canvas, void* ctx) { - ENTER; - furi_assert(canvas); - furi_assert(ctx); - - state_t* state = NULL; - - // Try to acquire the mutex for the plugin state variables, timeout = 25mS - if(!(state = (state_t*)acquire_mutex((ValueMutex*)ctx, 25))) return; - - switch(state->scene) { - //--------------------------------------------------------------------- - case SCENE_SPLASH: - show(canvas, 2, 0, &img_csLogo_FULL, SHOW_SET_BLK); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str_aligned(canvas, 64, 43, AlignCenter, AlignTop, "Wii Extension Controller"); - canvas_draw_str_aligned(canvas, 64, 55, AlignCenter, AlignTop, "Protocol Analyser"); - - showVer(canvas); - - break; - - //--------------------------------------------------------------------- - case SCENE_RIP: - show(canvas, 0, 0, &img_RIP, SHOW_SET_BLK); - break; - - //--------------------------------------------------------------------- - case SCENE_WAIT: -#define xo 2 - - show(canvas, 3 + xo, 10, &img_ecp_port, SHOW_SET_BLK); - - BOX_TL(22 + xo, 6, 82 + xo, 23); // 3v3 - BOX_TL(48 + xo, 21, 82 + xo, 23); // C1 - BOX_BL(22 + xo, 41, 82 + xo, 58); // C0 - BOX_BL(48 + xo, 41, 82 + xo, 44); // Gnd - - show(canvas, 90 + xo, 3, &img_6x8_3, SHOW_SET_BLK); // 3v3 - show(canvas, 97 + xo, 3, &img_6x8_v, SHOW_SET_BLK); - show(canvas, 104 + xo, 3, &img_6x8_3, SHOW_SET_BLK); - - show(canvas, 90 + xo, 18, &img_6x8_C, SHOW_SET_BLK); // C1 <-> - show(canvas, 98 + xo, 18, &img_6x8_1, SHOW_SET_BLK); - show(canvas, 107 + xo, 16, &img_ecp_SDA, SHOW_SET_BLK); - - show(canvas, 90 + xo, 40, &img_6x8_G, SHOW_SET_BLK); // Gnd - show(canvas, 97 + xo, 40, &img_6x8_n, SHOW_SET_BLK); - show(canvas, 104 + xo, 40, &img_6x8_d, SHOW_SET_BLK); - - show(canvas, 90 + xo, 54, &img_6x8_C, SHOW_SET_BLK); // C0 _-_- - show(canvas, 98 + xo, 54, &img_6x8_0, SHOW_SET_BLK); - show(canvas, 108 + xo, 54, &img_ecp_SCL, SHOW_SET_BLK); - - show(canvas, 0, 0, &img_csLogo_Small, SHOW_SET_BLK); - showVer(canvas); - -#undef xo - break; - - //--------------------------------------------------------------------- - case SCENE_DEBUG: - canvas_set_font(canvas, FontSecondary); - - show(canvas, 0, 0, &img_key_U, SHOW_SET_BLK); - canvas_draw_str_aligned(canvas, 11, 0, AlignLeft, AlignTop, "Initialise Perhipheral"); - - show(canvas, 0, 11, &img_key_OK, SHOW_SET_BLK); - canvas_draw_str_aligned(canvas, 11, 11, AlignLeft, AlignTop, "Read values [see log]"); - - show(canvas, 0, 23, &img_key_D, SHOW_SET_BLK); - canvas_draw_str_aligned(canvas, 11, 22, AlignLeft, AlignTop, "Restart Scanner"); - - show(canvas, 0, 33, &img_key_Back, SHOW_SET_BLK); - canvas_draw_str_aligned(canvas, 11, 33, AlignLeft, AlignTop, "Exit"); - - break; - - //--------------------------------------------------------------------- - default: - if(state->ec.pidx >= PID_ERROR) { - ERROR("%s : bad PID = %d", __func__, state->ec.pidx); - } else { - if((state->scene == SCENE_DUMP) || !ecId[state->ec.pidx].show) - ecId[PID_UNKNOWN].show(canvas, state); - else - ecId[state->ec.pidx].show(canvas, state); - } - break; - } - - // Release the mutex - release_mutex((ValueMutex*)ctx, state); - - LEAVE; - return; -} - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// SSSSS TTTTT AAA TTTTT EEEEE V V AAA RRRR IIIII AAA BBBB L EEEEE SSSSS -// S T A A T E V V A A R R I A A B B L E S -// SSSSS T AAAAA T EEE V V AAAAA RRRR I AAAAA BBBB L EEE SSSSS -// S T A A T E V V A A R R I A A B B L E S -// SSSSS T A A T EEEEE V A A R R IIIII A A BBBB LLLLL EEEEE SSSSS -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//+============================================================================ ======================================== -// Initialise plugin state variables -// -static inline bool stateInit(state_t* const state) { - ENTER; - furi_assert(state); - - bool rv = true; // assume success - - // Enable the main loop - state->run = true; - - // Timer - state->timerEn = false; - state->timer = NULL; - state->timerHz = furi_kernel_get_tick_frequency(); - state->fps = 30; - - // Scene - state->scene = SCENE_SPLASH; - state->scenePrev = SCENE_NONE; - state->scenePegg = SCENE_NONE; - - state->hold = 0; // show hold meters (-1=lowest, 0=current, +1=highest} - state->calib = CAL_TRACK; - state->pause = false; // animation running - state->apause = false; // auto-pause animation - - // Notifications - state->notify = NULL; - - // Perhipheral - state->ec.init = false; - state->ec.pidx = PID_UNKNOWN; - state->ec.sid = ecId[state->ec.pidx].name; - - // Controller data - memset(state->ec.pid, 0xC5, PID_LEN); // Cyborg 5ystems - memset(state->ec.calF, 0xC5, CAL_LEN); - memset(state->ec.joy, 0xC5, JOY_LEN); - - // Encryption details - state->ec.encrypt = false; - memset(state->ec.encKey, 0x00, ENC_LEN); - - // Seed the PRNG - // CYCCNT --> lib/STM32CubeWB/Drivers/CMSIS/Include/core_cm7.h - // srand(DWT->CYCCNT); - - LEAVE; - return rv; -} - -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// MM MM AAA IIIII N N -// M M M A A I NN N -// M M M AAAAA I N N N -// M M A A I N NN -// M M A A IIIII N N -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -//+============================================================================ ======================================== -// Enable/Disable scanning -// -void timerEn(state_t* state, bool on) { - ENTER; - furi_assert(state); - - // ENable scanning - if(on) { - if(state->timerEn) { - WARN(wii_errs[WARN_SCAN_START]); - } else { - // Set the timer to fire at 'fps' times/second - if(furi_timer_start(state->timer, state->timerHz / state->fps) == FuriStatusOk) { - state->timerEn = true; - INFO("%s : monitor started", __func__); - } else { - ERROR(wii_errs[ERR_TIMER_START]); - } - } - - // DISable scanning - } else { - if(!state->timerEn) { - WARN(wii_errs[WARN_SCAN_STOP]); - } else { - // Stop the timer - if(furi_timer_stop(state->timer) == FuriStatusOk) { - state->timerEn = false; - INFO("%s : monitor stopped", __func__); - } else { - ERROR(wii_errs[ERR_TIMER_STOP]); - } - } - } - - LEAVE; - return; -} - -//+============================================================================ ======================================== -// Plugin entry point -// -int32_t wii_ec_anal(void) { - ENTER; - - // ===== Variables ===== - err_t error = 0; // assume success - Gui* gui = NULL; - ViewPort* vpp = NULL; - state_t* state = NULL; - ValueMutex mutex = {0}; - FuriMessageQueue* queue = NULL; - const uint32_t queueSz = 20; // maximum messages in queue - uint32_t tmo = (3.5f * 1000); // timeout splash screen after N seconds - - // The queue will contain plugin event-messages - // --> local - eventMsg_t msg = {0}; - - INFO("BEGIN"); - - // ===== Message queue ===== - // 1. Create a message queue (for up to 8 (keyboard) event messages) - if(!(queue = furi_message_queue_alloc(queueSz, sizeof(msg)))) { - ERROR(wii_errs[(error = ERR_MALLOC_QUEUE)]); - goto bail; - } - - // ===== Create GUI Interface ===== - // 2. Create a GUI interface - if(!(gui = furi_record_open("gui"))) { - ERROR(wii_errs[(error = ERR_NO_GUI)]); - goto bail; - } - - // ===== Plugin state variables ===== - // 3. Allocate space on the heap for the plugin state variables - if(!(state = malloc(sizeof(state_t)))) { - ERROR(wii_errs[(error = ERR_MALLOC_STATE)]); - goto bail; - } - // 4. Initialise the plugin state variables - if(!stateInit(state)) { - // error message(s) is/are output by stateInit() - error = 15; - goto bail; - } - // 5. Create a mutex for (reading/writing) the plugin state variables - if(!init_mutex(&mutex, state, sizeof(state))) { - ERROR(wii_errs[(error = ERR_NO_MUTEX)]); - goto bail; - } - - // ===== Viewport ===== - // 6. Allocate space on the heap for the viewport - if(!(vpp = view_port_alloc())) { - ERROR(wii_errs[(error = ERR_MALLOC_VIEW)]); - goto bail; - } - // 7a. Register a callback for input events - view_port_input_callback_set(vpp, cbInput, queue); - // 7b. Register a callback for draw events - view_port_draw_callback_set(vpp, cbDraw, &mutex); - - // ===== Start GUI Interface ===== - // 8. Attach the viewport to the GUI - gui_add_view_port(gui, vpp, GuiLayerFullscreen); - - // ===== Timer ===== - // 9. Allocate a timer - if(!(state->timer = furi_timer_alloc(cbTimer, FuriTimerTypePeriodic, queue))) { - ERROR(wii_errs[(error = ERR_NO_TIMER)]); - goto bail; - } - - // === System Notifications === - // 10. Acquire a handle for the system notification queue - if(!(state->notify = furi_record_open(RECORD_NOTIFICATION))) { - ERROR(wii_errs[(error = ERR_NO_NOTIFY)]); - goto bail; - } - patBacklight(state); // Turn on the backlight [qv. remote FAP launch] - - INFO("INITIALISED"); - - // ==================== Main event loop ==================== - - if(state->run) do { - bool redraw = false; - FuriStatus status = FuriStatusErrorTimeout; - - // Wait for a message - // while ((status = furi_message_queue_get(queue, &msg, tmo)) == FuriStatusErrorTimeout) ; - status = furi_message_queue_get(queue, &msg, tmo); - - // Clear splash screen - if((state->scene == SCENE_SPLASH) && - (state->scenePrev == SCENE_NONE) && // Initial splash - ((status == FuriStatusErrorTimeout) || // timeout - ((msg.id == EVID_KEY) && (msg.input.type == InputTypeShort))) // or key-short - ) { - tmo = 60 * 1000; // increase message-wait timeout to 60secs - timerEn(state, true); // start scanning the i2c bus - status = FuriStatusOk; // pass status check - msg.id = EVID_NONE; // valid msg ID - sceneSet(state, SCENE_WAIT); // move to wait screen - } - - // Check for queue errors - if(status != FuriStatusOk) { - switch(status) { - case FuriStatusErrorTimeout: - DEBUG(wii_errs[DEBUG_QUEUE_TIMEOUT]); - continue; - case FuriStatusError: - ERROR(wii_errs[(error = ERR_QUEUE_RTOS)]); - goto bail; - case FuriStatusErrorResource: - ERROR(wii_errs[(error = ERR_QUEUE_RESOURCE)]); - goto bail; - case FuriStatusErrorParameter: - ERROR(wii_errs[(error = ERR_QUEUE_BADPRM)]); - goto bail; - case FuriStatusErrorNoMemory: - ERROR(wii_errs[(error = ERR_QUEUE_NOMEM)]); - goto bail; - case FuriStatusErrorISR: - ERROR(wii_errs[(error = ERR_QUEUE_ISR)]); - goto bail; - default: - ERROR(wii_errs[(error = ERR_QUEUE_UNK)]); - goto bail; - } - } - // Read successful - - // *** Try to lock the plugin state variables *** - if(!(state = (state_t*)acquire_mutex_block(&mutex))) { - ERROR(wii_errs[(error = ERR_MUTEX_BLOCK)]); - goto bail; - } - - // *** Handle events *** - switch(msg.id) { - //--------------------------------------------- - case EVID_TICK: // Timer events - //! I would prefer to have ecPoll() called by cbTimer() - //! ...but how does cbTimer() get the required access to the state variables? Namely: 'state->ec' - //! So, for now, the timer pushes a message to call ecPoll() - //! which, in turn, will push WIIEC event meesages! - ecPoll(&state->ec, queue); - break; - - //--------------------------------------------- - case EVID_WIIEC: // WiiMote Perhipheral - if(evWiiEC(&msg, state)) redraw = true; - break; - - //--------------------------------------------- - case EVID_KEY: // Key events - patBacklight(state); - if(evKey(&msg, state)) redraw = true; - break; - - //--------------------------------------------- - case EVID_NONE: - break; - - //--------------------------------------------- - default: // Unknown event - WARN("Unknown message.ID [%d]", msg.id); - break; - } - - // *** Update the GUI screen via the viewport *** - if(redraw) view_port_update(vpp); - - // *** Try to release the plugin state variables *** - if(!release_mutex(&mutex, state)) { - ERROR(wii_errs[(error = ERR_MUTEX_RELEASE)]); - goto bail; - } - } while(state->run); - - // ===== Game Over ===== - INFO("USER EXIT"); - -bail: - // 10. Release system notification queue - if(state->notify) { - furi_record_close(RECORD_NOTIFICATION); - state->notify = NULL; - } - - // 9. Stop the timer - if(state->timer) { - (void)furi_timer_stop(state->timer); - furi_timer_free(state->timer); - state->timer = NULL; - state->timerEn = false; - } - - // 8. Detach the viewport - gui_remove_view_port(gui, vpp); - - // 7. No need to unreqgister the callbacks - // ...they will go when the viewport is destroyed - - // 6. Destroy the viewport - if(vpp) { - view_port_enabled_set(vpp, false); - view_port_free(vpp); - vpp = NULL; - } - - // 5. Free the mutex - if(mutex.mutex) { - delete_mutex(&mutex); - mutex.mutex = NULL; - } - - // 4. Free up state pointer(s) - // none - - // 3. Free the plugin state variables - if(state) { - free(state); - state = NULL; - } - - // 2. Close the GUI - furi_record_close("gui"); - - // 1. Destroy the message queue - if(queue) { - furi_message_queue_free(queue); - queue = NULL; - } - - INFO("CLEAN EXIT ... Exit code: %d", error); - LEAVE; - return (int32_t)error; -} diff --git a/applications/plugins/wii_ec_anal/wii_anal.h b/applications/plugins/wii_ec_anal/wii_anal.h deleted file mode 100644 index 3aae61fdc..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef WII_ANAL_H_ -#define WII_ANAL_H_ - -#include // Core API -#include // GUI Input extensions -#include - -//----------------------------------------------------------------------------- ---------------------------------------- -// GUI scenes -// -typedef enum scene { - SCENE_NONE = 0, - SCENE_SPLASH = 1, - SCENE_RIP = 2, - SCENE_WAIT = 3, - SCENE_DEBUG = 4, - SCENE_DUMP = 5, - SCENE_CLASSIC = 6, - SCENE_CLASSIC_N = 7, - SCENE_NUNCHUCK = 8, - SCENE_NUNCHUCK_ACC = 9, -} scene_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -#include "wii_i2c.h" -#include "wii_ec.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -// A list of event IDs handled by this plugin -// -typedef enum eventID { - EVID_NONE, - EVID_UNKNOWN, - - // A full list of events can be found with: `grep -r --color "void.*set_.*_callback" applications/gui/*` - // ...A free gift to you from the makers of well written code that conforms to a good coding standard - EVID_KEY, // keypad - EVID_TICK, // tick - EVID_WIIEC, // wii extension controller -} eventID_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -// An item in the event message-queue -// -typedef struct eventMsg { - eventID_t id; - union { - InputEvent input; // --> applications/input/input.h - wiiEcEvent_t wiiEc; // --> local - }; -} eventMsg_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -// State variables for this plugin -// An instance of this is allocated on the heap, and the pointer is passed back to the OS -// Access to this memory is controlled by mutex -// -typedef struct state { - bool run; // true : plugin is running - - bool timerEn; // controller scanning enabled - FuriTimer* timer; // the timer - uint32_t timerHz; // system ticks per second - int fps; // poll/refresh [frames]-per-second - - int cnvW; // canvas width - int cnvH; // canvas height - scene_t scene; // current scene - scene_t scenePrev; // previous scene - scene_t scenePegg; // previous scene for easter eggs - int flash; // flash counter (flashing icons) - - int hold; // hold type: {-1=tough-peak, 0=none, +1=peak-hold} - ecCalib_t calib; // Software calibration mode - - bool pause; // Accelerometer animation pause - bool apause; // Accelerometer animation auto-pause - - NotificationApp* notify; // OS nitifcation queue (for patting the backlight watchdog timer) - - wiiEC_t ec; // Extension Controller details -} state_t; - -//============================================================================= ======================================== -// Function prototypes -// -void timerEn(state_t* state, bool on); - -#endif //WII_ANAL_H_ diff --git a/applications/plugins/wii_ec_anal/wii_anal_ec.c b/applications/plugins/wii_ec_anal/wii_anal_ec.c deleted file mode 100644 index dab167bc0..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_ec.c +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include - -#include "wii_anal.h" -#include "wii_anal_lcd.h" -#include "wii_anal_keys.h" - -//+============================================================================ ======================================== -// Handle Wii Extension Controller events -// -bool evWiiEC(const eventMsg_t* const msg, state_t* const state) { - bool redraw = false; - -#if LOG_LEVEL >= 4 - { - const char* s = NULL; - switch(msg->wiiEc.type) { - case WIIEC_NONE: - s = "Error"; - break; - case WIIEC_CONN: - s = "Connect"; - break; - case WIIEC_DISCONN: - s = "Disconnect"; - break; - case WIIEC_PRESS: - s = "Press"; - break; - case WIIEC_RELEASE: - s = "Release"; - break; - case WIIEC_ANALOG: - s = "Analog"; - break; - case WIIEC_ACCEL: - s = "Accel"; - break; - default: - s = "Bug"; - break; - } - INFO( - "WIIP : %s '%c' = %d", - s, - (isprint((int)msg->wiiEc.in) ? msg->wiiEc.in : '_'), - msg->wiiEc.val); - if((msg->wiiEc.type == WIIEC_CONN) || (msg->wiiEc.type == WIIEC_DISCONN)) - INFO("...%d=\"%s\"", msg->wiiEc.val, ecId[msg->wiiEc.val].name); - } -#endif - - switch(msg->wiiEc.type) { - case WIIEC_CONN: - patBacklight(state); - state->hold = 0; - state->calib = CAL_TRACK; - sceneSet(state, ecId[msg->wiiEc.val].scene); - redraw = true; - -#if 1 // Workaround for Classic Controller Pro, which shows 00's for Factory Calibration Data!? - if(state->ec.pidx == PID_CLASSIC_PRO) { - // Simulate a Long-OK keypress, to start Software Calibration mode - eventMsg_t msg = {// .id = EVID_KEY, - .input.type = InputTypeLong, - .input.key = InputKeyOk}; - key_calib(&msg, state); - } -#endif - break; - - case WIIEC_DISCONN: - patBacklight(state); - sceneSet(state, SCENE_WAIT); - redraw = true; - break; - - case WIIEC_PRESS: - if(state->scene == SCENE_NUNCHUCK_ACC) switch(msg->wiiEc.in) { - case 'z': // un-pause - state->pause = !state->pause; - break; - case 'c': // toggle auto-pause - state->pause = false; - state->apause = !state->apause; - break; - default: - break; - } - -#if 1 //! factory calibration method not known for classic triggers - this will set the digital switch point - if((state->ec.pidx == PID_CLASSIC) || (state->ec.pidx == PID_CLASSIC_PRO)) { - if(msg->wiiEc.in == 'l') state->ec.calS.classic[2].trgZL = msg->wiiEc.val; - if(msg->wiiEc.in == 'r') state->ec.calS.classic[2].trgZR = msg->wiiEc.val; - } -#endif - __attribute__((fallthrough)); - - case WIIEC_RELEASE: - patBacklight(state); - redraw = true; - break; - - case WIIEC_ANALOG: - case WIIEC_ACCEL: - ecCalibrate(&state->ec, state->calib); - redraw = true; - break; - - default: - break; - } - - return redraw; -} diff --git a/applications/plugins/wii_ec_anal/wii_anal_ec.h b/applications/plugins/wii_ec_anal/wii_anal_ec.h deleted file mode 100644 index eec6b523c..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_ec.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef WII_ANAL_EC_H_ -#define WII_ANAL_EC_H_ - -#include - -//============================================================================= ======================================== -// Function prototypes -// -typedef struct eventMsg eventMsg_t; -typedef struct state state_t; - -bool evWiiEC(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_ANAL_EC_H_ diff --git a/applications/plugins/wii_ec_anal/wii_anal_keys.c b/applications/plugins/wii_ec_anal/wii_anal_keys.c deleted file mode 100644 index 8c5c99b4e..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_keys.c +++ /dev/null @@ -1,299 +0,0 @@ -#include - -#include "bc_logging.h" - -#include "wii_anal.h" - -//+============================================================================ ======================================== -// Stop Calibration mode -// -static void calStop(state_t* const state) { - state->hold = 0; // stop calibration mode - state->calib &= ~(CAL_RANGE | CAL_NOTJOY); // ... -} - -//+============================================================================ ======================================== -// Change to another scene -// -void sceneSet(state_t* const state, const scene_t scene) { - calStop(state); // Stop software calibration - state->scenePrev = state->scene; // Remember where we came from - state->scene = scene; // Go to new scene - INFO("Scene : %d -> %d", state->scenePrev, state->scene); -} - -//+============================================================================ ======================================== -// Change to an easter egg scene -// -static void sceneSetEgg(state_t* const state, const scene_t scene) { - calStop(state); // Stop software calibration - state->scenePegg = state->scene; // Remember where we came from - state->scene = scene; // Go to new scene - INFO("Scene* : %d => %d", state->scenePegg, state->scene); -} - -//+============================================================================ ======================================== -// Several EC screens have 'peak-hold' and 'calibration' features -// Enabling peak-hold on screen with no peak meters will have no effect -// So, to avoid code duplication... -// -bool key_calib(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyUp: //# hold = (state->hold == +1) ? 0 : +1; // toggle peak hold - used = true; - break; - - case InputKeyDown: //# hold = (state->hold == -1) ? 0 : -1; // toggle trough hold - used = true; - break; - - case InputKeyOk: //# calib & CAL_RANGE) - calStop(state); // STOP softare calibration - else - ecCalibrate(&state->ec, CAL_CENTRE); // perform centre calibration - used = true; - break; - - default: - break; - } - break; - - case InputTypeLong: //# >! After INPUT_LONG_PRESS interval, asynch to InputTypeRelease - switch(msg->input.key) { - case InputKeyOk: //# >O [ LONG-OK ] - ecCalibrate(&state->ec, CAL_RESET | CAL_CENTRE); // START software calibration - state->hold = 0; - state->calib |= CAL_RANGE; - state->flash = 8; // start with flash ON - used = true; - break; - - default: - break; - } - break; - - default: - break; - } - - return used; -} - -//+============================================================================ ======================================== -// WAIT screen -// -static inline bool wait_key(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - if(msg->input.type == InputTypeShort) { - switch(msg->input.key) { - case InputKeyLeft: //# run = false; - used = true; - break; - - default: - break; - } - } - - return used; -} - -//+============================================================================ ======================================== -// DEBUG screen -// -static inline bool debug_key(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyUp: { //# ec, NULL); // Initialise the controller //! NULL = no encryption - (void)init; // in case INFO is optimised out - INFO("%s : %s", __func__, (init ? "init OK" : "init fail")); - used = true; - break; - } - - case InputKeyOk: //# ec) == 0) { // Read the controller - INFO( - "%s : joy: {%02X,%02X,%02X,%02X,%02X,%02X}", - __func__, - state->ec.joy[0], - state->ec.joy[1], - state->ec.joy[2], - state->ec.joy[3], - state->ec.joy[4], - state->ec.joy[5]); - } - used = true; - break; - - case InputKeyDown: //# scenePrev); - used = true; - break; - - case InputKeyBack: //# run = false; - used = true; - break; - - default: - break; //# input.key == InputKeyBack) && (state->scenePrev == SCENE_NONE)) state->run = false; - - // ANY-other-KEY press - if(msg->input.type == InputTypeShort) { - timerEn(state, true); // Restart the timer - state->scene = state->scenePegg; - } - - return true; -} - -//+============================================================================ ======================================== -// "_pre" allows the plugin to use the key before the active scene gets a chance -// -static inline bool key_pre(const eventMsg_t* const msg, state_t* const state) { - (void)msg; - (void)state; - - return false; -} - -//+============================================================================ ======================================== -// "_post" allows the plugin to use a key if it was not used by the active scene -// -static inline bool key_post(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - if(msg->input.key == InputKeyBack) { - if(msg->input.type == InputTypeShort) { //# ec.init = false; // reset/disconnect the controller - sceneSet(state, SCENE_WAIT); - used = true; - - } else if(msg->input.type == InputTypeLong) { //# >B [LONG-BACK] - state->run = false; // Signal the plugin to exit - used = true; - } - } - - // Easter eggs - switch(state->scene) { - case SCENE_SPLASH: // Scenes that do NOT offer Easter eggs - case SCENE_RIP: - case SCENE_DEBUG: - break; - default: - if(msg->input.type == InputTypeLong) { - switch(msg->input.key) { - case InputKeyDown: //# >D [LONG-DOWN] - timerEn(state, false); // Stop the timer - sceneSetEgg(state, SCENE_DEBUG); - used = true; - break; - - case InputKeyLeft: //# >L [ LONG-LEFT ] - timerEn(state, false); // Stop the timer - sceneSetEgg(state, SCENE_SPLASH); - used = true; - break; - - case InputKeyUp: //# >U [ LONG-UP ] - timerEn(state, false); // Stop the timer - sceneSetEgg(state, SCENE_RIP); - used = true; - break; - - default: - break; - } - } - break; - } - - return used; -} - -//+============================================================================ ======================================== -// Handle a key press event -// -bool evKey(const eventMsg_t* const msg, state_t* const state) { - furi_assert(msg); - furi_assert(state); - - bool used = key_pre(msg, state); - - if(!used) switch(state->scene) { - case SCENE_SPLASH: //... - case SCENE_RIP: - used = splash_key(msg, state); - break; - - case SCENE_WAIT: - used = wait_key(msg, state); - break; - case SCENE_DEBUG: - used = debug_key(msg, state); - break; - - default: - if(state->ec.pidx >= PID_ERROR) { - ERROR("%s : bad PID = %d", __func__, state->ec.pidx); - } else { - if((state->scene == SCENE_DUMP) || !ecId[state->ec.pidx].keys) - ecId[PID_UNKNOWN].keys(msg, state); - else - ecId[state->ec.pidx].keys(msg, state); - } - break; - - case SCENE_NONE: - break; - } - - if(!used) used = key_post(msg, state); - - return used; -} diff --git a/applications/plugins/wii_ec_anal/wii_anal_keys.h b/applications/plugins/wii_ec_anal/wii_anal_keys.h deleted file mode 100644 index c10fcd1ef..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_keys.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef WII_ANAL_KEYS_H_ -#define WII_ANAL_KEYS_H_ - -//============================================================================= ======================================== -// Function prototypes -// -#include // bool -typedef struct eventMsg eventMsg_t; -typedef struct state state_t; -typedef enum scene scene_t; - -void sceneSet(state_t* const state, const scene_t scene); -bool key_calib(const eventMsg_t* const msg, state_t* const state); -bool evKey(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_ANAL_KEYS_H_ diff --git a/applications/plugins/wii_ec_anal/wii_anal_lcd.c b/applications/plugins/wii_ec_anal/wii_anal_lcd.c deleted file mode 100644 index 921a3708e..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_lcd.c +++ /dev/null @@ -1,282 +0,0 @@ -#include "wii_anal.h" -#include "gfx/images.h" // Images - -//----------------------------------------------------------------------------- ---------------------------------------- -// A couple of monospaced hex fonts -// -const image_t* img_6x8[16] = { - &img_6x8_0, - &img_6x8_1, - &img_6x8_2, - &img_6x8_3, - &img_6x8_4, - &img_6x8_5, - &img_6x8_6, - &img_6x8_7, - &img_6x8_8, - &img_6x8_9, - &img_6x8_A, - &img_6x8_B, - &img_6x8_C, - &img_6x8_D, - &img_6x8_E, - &img_6x8_F, -}; - -const image_t* img_5x7[16] = { - &img_5x7_0, - &img_5x7_1, - &img_5x7_2, - &img_5x7_3, - &img_5x7_4, - &img_5x7_5, - &img_5x7_6, - &img_5x7_7, - &img_5x7_8, - &img_5x7_9, - &img_5x7_A, - &img_5x7_B, - &img_5x7_C, - &img_5x7_D, - &img_5x7_E, - &img_5x7_F, -}; - -//+============================================================================ ======================================== -// void backlightOn (void) -// { -// // Acquire a handle for the system notification queue -// // Do this ONCE ... at plugin startup -// NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION); -// -// // Pat the backlight watchdog -// // Send the (predefined) message sequence {backlight_on, end} -// // --> applications/notification/*.c -// notification_message(notifications, &sequence_display_backlight_on); -// -// // Release the handle for the system notification queue -// // Do this ONCE ... at plugin quit -// furi_record_close(RECORD_NOTIFICATION); -// } -void patBacklight(state_t* state) { - notification_message(state->notify, &sequence_display_backlight_on); -} - -//============================================================================= ======================================== -// Show a hex number in an inverted box (for ananlogue readings) -// -void showHex( - Canvas* const canvas, - uint8_t x, - uint8_t y, - const uint32_t val, - const uint8_t cnt, - const int b) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, x++, y++, 1 + (cnt * (6 + 1)), 10); - - // thicken border - if(b == 2) canvas_draw_frame(canvas, x - 2, y - 2, 1 + (cnt * (6 + 1)) + 2, 10 + 2); - - for(int i = (cnt - 1) * 4; i >= 0; i -= 4, x += 6 + 1) - show(canvas, x, y, img_6x8[(val >> i) & 0xF], SHOW_SET_WHT); -} - -//============================================================================= ======================================== -// Show the up/down "peak hold" controls in the bottom right -// -void showPeakHold(state_t* const state, Canvas* const canvas, const int hold) { - switch(hold) { - case 0: - show(canvas, 119, 51, &img_key_U, SHOW_CLR_BLK); - show(canvas, 119, 56, &img_key_D, SHOW_CLR_BLK); - break; - case +1: - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 120, 52, 7, 6); - show(canvas, 119, 51, &img_key_U, SHOW_CLR_WHT); - show(canvas, 119, 56, &img_key_D, SHOW_CLR_BLK); - break; - case -1: - show(canvas, 119, 51, &img_key_U, SHOW_CLR_BLK); - canvas_draw_box(canvas, 120, 57, 7, 6); - show(canvas, 119, 56, &img_key_D, SHOW_CLR_WHT); - break; - default: - break; - } - canvas_set_color(canvas, ColorBlack); - canvas_draw_frame(canvas, 119, 51, 9, 13); - - // calibration indicator - show( - canvas, - 108, - 55, - ((state->calib & CAL_RANGE) && (++state->flash & 8)) ? &img_key_OKi : &img_key_OK, - SHOW_SET_BLK); -} - -//============================================================================= ======================================== -// This code performs a FULL calibration on the device EVERY time it draws a joystick -//...This is NOT a good way forward for anything other than a test tool. -// -// Realistically you would do all the maths when the controller is connected -// or, if you prefer (and it IS a good thing), have a "calibrate controller" menu option -// ...and then just use a lookup table, or trivial formual -// -// THIS algorithm chops the joystick in to one of 9 zones -// Eg. {FullLeft, Left3, Left2, Left1, Middle, Right1, Right2, Right3, FullRight} -// FullLeft and FullRight have a deadzone of N [qv. xDead] ..a total of N+1 positions -// Middle has a deadzone of N EACH WAY ...a total of 2N+1 positions -// -// If the remaining range does not divide evenly in to three zones, -// the first remainder is added to zone3, -// and the second remainder (if there is one) is added to zone2 -// ...giving finer control near the centre of the joystick -// -// The value of the deadzone is based on the number of bits in the -// joystcik {x,y} values - the larger the range, the larger the deadzone. -// -// 03 15 29 -// |<<| Calibration points |==| |>>| -// 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F -// |---| |________________________| |------| |______________________________| |---| -// |r=2| | range = 9 | | r=3 | | range = 11 | |r=2| -// Zones: |-4 | |-3 |-2 |-1 | |0 | |+1 |+2 |+3 | |+4 | -// -// This is not "the right way to do it" ...this is "one way to do it" -// Consider you application, and what the user is trying to achieve -// Aim a gun - probably need to be more accurate -// Turn and object - this is probably good enough -// Start slowly & pick up speed - how about a log or sine curve? -// -void showJoy( - Canvas* const canvas, - const uint8_t x, - const uint8_t y, // x,y is the CENTRE of the Joystick - const uint8_t xMin, - const uint8_t xMid, - const uint8_t xMax, - const uint8_t yMin, - const uint8_t yMid, - const uint8_t yMax, - const uint8_t xPos, - const uint8_t yPos, - const uint8_t bits) { - int xOff = 0; // final offset of joystick hat image - int yOff = 0; - - int xDead = (bits < 7) ? (1 << 0) : (1 << 3); // dead zone (centre & limits) - int yDead = xDead; - - // This code is NOT optimised ...and it's still barely readable! - if((xPos >= (xMid - xDead)) && (xPos <= (xMid + xDead))) - xOff = 0; // centre [most likely] - else if(xPos <= (xMin + xDead)) - xOff = -4; // full left - else if(xPos >= (xMax - xDead)) - xOff = +4; // full right - else if(xPos < (xMid - xDead)) { // part left - // very much hard-coded for 3 interim positions - int lo = (xMin + xDead) + 1; // lowest position - int hi = (xMid - xDead) - 1; // highest position - - // this is the only duplicated bit of code - int range = (hi - lo) + 1; // range covered - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - - // int hi1 = hi; // lowest value for zone #-1 - // int lo1 = hi1 -div +1; // highest value for zone #-1 - // int hi2 = lo1 -1; // lowest value for zone #-2 - // int lo2 = hi2 -div +1 -(rem==2); // highest value for zone #-2 expand out remainder - // int hi3 = lo2 -1; // lowest value for zone #-3 - // int lo3 = hi3 -div +1 -(rem>=1); // highest value for zone #-3 expand out remainder - - int lo1 = hi - div + 1; // (in brevity) - int hi3 = hi - div - div - (rem == 2); // ... - - if(xPos <= hi3) - xOff = -3; // zone #-3 - else if(xPos >= lo1) - xOff = -1; // zone #-1 - else - xOff = -2; // zone #-2 - - } else /*if (xPos > (xMid +xDead))*/ { // part right - // very much hard-coded for 3 interim positions - int lo = (xMid + xDead) + 1; // lowest position - int hi = (xMax - xDead) - 1; // highest position - - int range = (hi - lo) + 1; // range covered - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - - // int lo1 = lo; // lowest value for zone #+1 - // int hi1 = lo +div -1; // highest value for zone #+1 - // int lo2 = hi1 +1; // lowest value for zone #+2 - // int hi2 = lo2 +div -1 +(rem==2); // highest value for zone #+2 expand out remainder - // int lo3 = hi2 +1; // lowest value for zone #+3 - // int hi3 = lo3 +div -1 +(rem>=1); // highest value for zone #+3 expand out remainder - - int hi1 = lo + div - 1; // (in brevity) - int lo3 = lo + div + div + (rem == 2); // ... - - if(xPos <= hi1) - xOff = 1; // zone #1 - else if(xPos >= lo3) - xOff = 3; // zone #3 - else - xOff = 2; // zone #2 - } - - // All this to print a 3x3 square (in the right place) - LOL! - if((yPos >= (yMid - yDead)) && (yPos <= (yMid + yDead))) - yOff = 0; // centre [most likely] - else if(yPos <= (yMin + yDead)) - yOff = +4; // full down - else if(yPos >= (yMax - yDead)) - yOff = -4; // full up - else if(yPos < (yMid - yDead)) { // part down - int lo = (yMin + yDead) + 1; // lowest position - int hi = (yMid - yDead) - 1; // highest position - - int range = (hi - lo) + 1; // range covered - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - - int lo1 = hi - div + 1; // (in brevity) - int hi3 = hi - div - div - (rem == 2); // ... - - if(yPos <= hi3) - yOff = +3; // zone #3 - else if(yPos >= lo1) - yOff = +1; // zone #1 - else - yOff = +2; // zone #2 - - } else /*if (yPos > (yMid +yDead))*/ { // part up - int lo = (yMid + yDead) + 1; // lowest position - int hi = (yMax - yDead) - 1; // highest position - - int range = (hi - lo) + 1; // range covered - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - - int hi1 = lo + div - 1; // (in brevity) - int lo3 = lo + div + div + (rem == 2); // ... - - if(yPos <= hi1) - yOff = -1; // zone #-1 - else if(yPos >= lo3) - yOff = -3; // zone #-3 - else - yOff = -2; // zone #-2 - } - - show(canvas, x - (img_cc_Joy.w / 2), y - (img_cc_Joy.h / 2), &img_cc_Joy, SHOW_SET_BLK); - - // All ^that^ for v-this-v - LOL!! - canvas_draw_box(canvas, (x - 1) + xOff, (y - 1) + yOff, 3, 3); -} diff --git a/applications/plugins/wii_ec_anal/wii_anal_lcd.h b/applications/plugins/wii_ec_anal/wii_anal_lcd.h deleted file mode 100644 index e52a3adc6..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_lcd.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef WII_ANAL_LCD_H_ -#define WII_ANAL_LCD_H_ - -//----------------------------------------------------------------------------- ---------------------------------------- -// A couple of monospaced hex fonts -// -#include "gfx/images.h" - -extern const image_t* img_6x8[]; -extern const image_t* img_5x7[]; - -//============================================================================= ======================================== -// macros to draw only two sides of a box -// these are used for drawing the wires on the WAIT screen -// -#define BOX_TL(x1, y1, x2, y2) \ - do { \ - canvas_draw_frame(canvas, x1, y1, x2 - x1 + 1, 2); \ - canvas_draw_frame(canvas, x1, y1 + 2, 2, y2 - y1 + 1 - 2); \ - } while(0) - -#define BOX_BL(x1, y1, x2, y2) \ - do { \ - canvas_draw_frame(canvas, x1, y2 - 1, x2 - x1 + 1, 2); \ - canvas_draw_frame(canvas, x1, y1, 2, y2 - y1 + 1 - 2); \ - } while(0) - -//============================================================================= ======================================== -// Function prototypes -// -void patBacklight(state_t* state); - -void showHex( - Canvas* const canvas, - uint8_t x, - uint8_t y, - const uint32_t val, - const uint8_t cnt, - const int b); - -void showPeakHold(state_t* const state, Canvas* const canvas, const int hold); - -void showJoy( - Canvas* const canvas, - const uint8_t x, - const uint8_t y, // x,y is the CENTRE of the Joystick - const uint8_t xMin, - const uint8_t xMid, - const uint8_t xMax, - const uint8_t yMin, - const uint8_t yMid, - const uint8_t yMax, - const uint8_t xPos, - const uint8_t yPos, - const uint8_t bits); - -#endif //WII_ANAL_LCD_H_ diff --git a/applications/plugins/wii_ec_anal/wii_anal_ver.h b/applications/plugins/wii_ec_anal/wii_anal_ver.h deleted file mode 100644 index 3f2c8c0e6..000000000 --- a/applications/plugins/wii_ec_anal/wii_anal_ver.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef WII_ANAL_VER_H_ -#define WII_ANAL_VER_H_ - -#include "gfx/images.h" - -#define VER_MAJ &img_3x5_1 -#define VER_MIN &img_3x5_0 - -#endif //WII_ANAL_VER_H_ diff --git a/applications/plugins/wii_ec_anal/wii_ec.c b/applications/plugins/wii_ec_anal/wii_ec.c deleted file mode 100644 index 00dcbf922..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec.c +++ /dev/null @@ -1,298 +0,0 @@ -#include -#include // Core API - -#include "wii_anal.h" -#include "wii_i2c.h" -#include "wii_ec.h" -#include "bc_logging.h" - -#include "gfx/images.h" // Images -#include "wii_anal_lcd.h" // Drawing functions -#include "wii_anal_keys.h" // key mappings - -//----------------------------------------------------------------------------- ---------------------------------------- -// List of known perhipherals -// -// More perhipheral ID codes here: https://wiibrew.org/wiki/Wiimote/Extension_Controllers#The_New_Way -// -const ecId_t ecId[PID_CNT] = { - [PID_UNKNOWN] = - {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - "Unknown Perhipheral", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - ec_show, - ec_key}, - - // If you're wise, ONLY edit this bit - [PID_NUNCHUCK] = - {{0x00, 0x00, 0xA4, 0x20, 0x00, 0x00}, - "Nunchuck", - SCENE_NUNCHUCK, - NULL, - nunchuck_decode, - nunchuck_msg, - nunchuck_calib, - nunchuck_show, - nunchuck_key}, - - [PID_NUNCHUCK_R2] = - {{0xFF, 0x00, 0xA4, 0x20, 0x00, 0x00}, - "Nunchuck (rev2)", - SCENE_NUNCHUCK, - NULL, - nunchuck_decode, - nunchuck_msg, - nunchuck_calib, - nunchuck_show, - nunchuck_key}, - - [PID_CLASSIC] = - {{0x00, 0x00, 0xA4, 0x20, 0x01, 0x01}, - "Classic Controller", - SCENE_CLASSIC, - NULL, - classic_decode, - classic_msg, - classic_calib, - classic_show, - classic_key}, - - [PID_CLASSIC_PRO] = - {{0x01, 0x00, 0xA4, 0x20, 0x01, 0x01}, - "Classic Controller Pro", - SCENE_CLASSIC, - NULL, - classic_decode, - classic_msg, - classic_calib, - classic_show, - classic_key}, - - [PID_BALANCE] = - {{0x00, 0x00, 0xA4, 0x20, 0x04, 0x02}, - "Balance Board", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, - - [PID_GH_GUITAR] = - {{0x00, 0x00, 0xA4, 0x20, 0x01, 0x03}, - "Guitar Hero Guitar", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, - - [PID_GH_DRUMS] = - {{0x01, 0x00, 0xA4, 0x20, 0x01, 0x03}, - "Guitar Hero World Tour Drums", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, - - [PID_TURNTABLE] = - {{0x03, 0x00, 0xA4, 0x20, 0x01, 0x03}, - "DJ Hero Turntable", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, - - [PID_TAIKO_DRUMS] = - {{0x00, 0x00, 0xA4, 0x20, 0x01, 0x11}, - "Taiko Drum Controller)", - SCENE_DUMP, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, // Taiko no Tatsujin TaTaCon (Drum controller) - - [PID_UDRAW] = - {{0xFF, 0x00, 0xA4, 0x20, 0x00, 0x13}, - "uDraw Tablet", - SCENE_DUMP, - udraw_init, - NULL, - NULL, - NULL, - NULL, - NULL}, //! same as drawsome? - // ----- - - [PID_ERROR] = - {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - "Read Error", - SCENE_NONE, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL}, - - [PID_NULL] = {{0}, NULL, SCENE_NONE, NULL, NULL, NULL, NULL, NULL, NULL} // last entry -}; - -//+============================================================================ ======================================== -void ecDecode(wiiEC_t* pec) { - if(ecId[pec->pidx].decode) ecId[pec->pidx].decode(pec); -} - -//+============================================================================ ======================================== -void ecCalibrate(wiiEC_t* const pec, ecCalib_t c) { - if(ecId[pec->pidx].calib) ecId[pec->pidx].calib(pec, c); -} - -//+============================================================================ ======================================== -void ecPoll(wiiEC_t* const pec, FuriMessageQueue* const queue) { - ENTER; - furi_assert(queue); - - if(!pec->init) { - // Attempt to initialise - if(ecInit(pec, NULL)) { //! need a way to auto-start with encryption enabled - eventMsg_t msg = { - .id = EVID_WIIEC, .wiiEc = {.type = WIIEC_CONN, .in = '<', .val = pec->pidx}}; - furi_message_queue_put(queue, &msg, 0); - } - - } else { - // Attempt to read - switch(ecRead(pec)) { - case 2: { // device gone - eventMsg_t msg = { - .id = EVID_WIIEC, .wiiEc = {.type = WIIEC_DISCONN, .in = '>', .val = pec->pidx}}; - furi_message_queue_put(queue, &msg, 0); - break; - } - - case 0: { // read OK - void (*fn)(wiiEC_t*, FuriMessageQueue*) = ecId[pec->pidx].check; - if(fn) fn(pec, queue); - break; - } - - case 3: // read fail - // this is probably temporary just ignore it - break; - - default: // bug: unknown - case 1: // bug: not initialised - should never happen - ERROR("%s : read bug", __func__); - break; - } - } - - LEAVE; - return; -} - -//+============================================================================ ======================================== -// This is the screen drawn for an unknown controller -// It is also available by pressing LEFT (at least once) on a "known controller" screen -// -void ec_show(Canvas* const canvas, state_t* const state) { - wiiEC_t* pec = &state->ec; - int h = 11; // line height - int x = 1; // (initial) offset for bits - int y = -h; // previous y value - int yb = 0; // y for bit patterns - int c2 = 17; // column 2 - - // Headings - canvas_set_font(canvas, FontSecondary); - canvas_set_color(canvas, ColorBlack); - - canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, "SID:"); - canvas_draw_str_aligned(canvas, c2, 0, AlignLeft, AlignTop, pec->sid); - - canvas_draw_str_aligned(canvas, 0, 11, AlignLeft, AlignTop, "PID:"); - canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, "Cal:"); - - // PID - x = c2; - for(int i = 0; i < 6; i++) { - show(canvas, x, 11, img_5x7[pec->pid[i] >> 4], SHOW_SET_BLK); - x += 5 + 1; - show(canvas, x, 11, img_5x7[pec->pid[i] & 0xF], SHOW_SET_BLK); - x += 5 + 1 + 2; - } - - // Calibrations data - y = 11; - for(int j = 0; j <= 8; j += 8) { - x = c2; - y += 11; - for(int i = 0; i < 8; i++) { - show(canvas, x, y, img_5x7[pec->calF[i + j] >> 4], SHOW_SET_BLK); - x += 5 + 1; - show(canvas, x, y, img_5x7[pec->calF[i + j] & 0xF], SHOW_SET_BLK); - x += 5 + 1 + 2; - } - } - - // Reading - x = 1; - y++; - yb = (y += h) + h + 2; - - canvas_draw_line(canvas, x, y - 1, x, yb + 4); - x += 2; - - for(int i = 0; i < JOY_LEN; i++) { - show(canvas, x + 1, y, img_6x8[pec->joy[i] >> 4], SHOW_SET_BLK); - show(canvas, x + 11, y, img_6x8[pec->joy[i] & 0xF], SHOW_SET_BLK); - - // bits - for(int m = 0x80; m; m >>= 1) { - x += 2 * !!(m & 0x08); // nybble step - canvas_draw_box(canvas, x, yb + (2 * !(pec->joy[i] & m)), 2, 2); - x += 2; // bit step - } - - // byte step - x += 1; - canvas_draw_line(canvas, x, y - 1, x, yb + 4); - x += 2; - } - - // Scene navigation - if(state->scenePrev != SCENE_WAIT) show(canvas, 120, 0, &img_key_R, SHOW_SET_BLK); -} - -//+============================================================================ ======================================== -// The DUMP screen is -// -bool ec_key(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - if(state->scenePrev != SCENE_WAIT) { - //# input.type == InputTypeShort) && (msg->input.key == InputKeyRight)) { - sceneSet(state, state->scenePrev); - used = true; - } - } - - return used; -} diff --git a/applications/plugins/wii_ec_anal/wii_ec.h b/applications/plugins/wii_ec_anal/wii_ec.h deleted file mode 100644 index a28453740..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef WII_EC_H_ -#define WII_EC_H_ - -#include - -#include - -#include "wii_ec_nunchuck.h" -#include "wii_ec_classic.h" -#include "wii_ec_udraw.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -// Crypto key (PSK), base register : {0x40..0x4F}[2][8] -#define ENC_LEN (2 * 8) - -// Controller State data, base register : {0x00..0x05}[6] -#define JOY_LEN (6) - -// Calibration data, base register : {0x20..0x2F}[16] -#define CAL_LEN (16) - -// Controller ID, base register : {0xFA..0xFF}[6] -#define PID_LEN (6) - -//----------------------------------------------------------------------------- ---------------------------------------- -// Perhipheral specific parameters union -// -typedef union ecDec { - ecDecNunchuck_t nunchuck; - ecDecClassic_t classic; -} ecDec_t; - -//----------------------------------------------------------------------------- -typedef union ecCal { - // 0=lowest seen ; 1=min ; 2=mid ; 3=max ; 4=highest seen - ecCalNunchuck_t nunchuck[5]; - ecCalClassic_t classic[5]; -} ecCal_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -// Wii Extension Controller events -// -typedef enum wiiEcEventType { - WIIEC_NONE, - WIIEC_CONN, // Connect - WIIEC_DISCONN, // Disconnect - WIIEC_PRESS, // Press button - WIIEC_RELEASE, // Release button - WIIEC_ANALOG, // Analogue change (Joystick/Trigger) - WIIEC_ACCEL, // Accelerometer change -} wiiEcEventType_t; - -//----------------------------------------------------------------------------- -typedef struct wiiEcEvent { - wiiEcEventType_t type; // event type - char in; // input (see device specific options) - uint32_t val; // new value - meaningless for digital button presses -} wiiEcEvent_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -// Known perhipheral types -// -typedef enum ecPid { - PID_UNKNOWN = 0, - PID_FIRST = 1, - PID_NUNCHUCK = PID_FIRST, - - // If you're wise, ONLY edit this section - PID_NUNCHUCK_R2, - PID_CLASSIC, - PID_CLASSIC_PRO, - PID_BALANCE, - PID_GH_GUITAR, - PID_GH_DRUMS, - PID_TURNTABLE, - PID_TAIKO_DRUMS, - PID_UDRAW, //! same as drawsome? - // ----- - - PID_ERROR, - PID_NULL, - PID_CNT, -} ecPid_t; - -//----------------------------------------------------------------------------- -// Calibration strategies -// -typedef enum ecCalib { - CAL_FACTORY = 0x01, // (re)set to factory defaults - CAL_TRACK = 0x02, // track maximum and minimum values seen - CAL_RESET = 0x04, // initialise ready for software calibration - CAL_RANGE = 0x08, // perform software calibration step - CAL_CENTRE = 0x10, // reset centre point of joystick - CAL_NOTJOY = 0x20, // do NOT calibrate the joystick -} ecCalib_t; - -//----------------------------------------------------------------------------- -// ecId table entry -// -typedef struct ecId { - uint8_t id[6]; // 6 byte ID string returned by Extension Controller - char* name; // Friendly name - scene_t scene; // Default scene - bool (*init)(wiiEC_t*); // Additional initialisation code - void (*decode)(wiiEC_t*); // Decode function - void (*check)(wiiEC_t*, FuriMessageQueue*); // check (for action) function - void (*calib)(wiiEC_t*, ecCalib_t); // calibrate analogue controllers [SOFTWARE] - void (*show)(Canvas* const, state_t* const); // Draw scene - bool (*keys)(const eventMsg_t* const, state_t* const); // Interpret keys -} ecId_t; - -//----------------------------------------------------------------------------- -// List of known perhipherals -// -// More perhipheral ID codes here: https://wiibrew.org/wiki/Wiimote/Extension_Controllers#The_New_Way -// -extern const ecId_t ecId[PID_CNT]; - -//----------------------------------------------------------------------------- ---------------------------------------- -// Data pertaining to a single Perhipheral instance -// -typedef struct wiiEC { - // Perhipheral state - bool init; // Initialised? - - uint8_t pid[PID_LEN]; // PID string - eg. {0x00, 0x00, 0xA4, 0x20, 0x00, 0x00} - ecPid_t pidx; // Index in to ecId table - const char* sid; // just for convenience - - bool encrypt; // encryption enabled? - uint8_t encKey[ENC_LEN]; // encryption key - - uint8_t calF[CAL_LEN]; // factory calibration data (not software) - uint8_t joy[JOY_LEN]; // Perhipheral raw data - - ecDec_t dec[2]; // device specific decode (two, so we can spot changes) - int decN; // which decode set is most recent {0, 1} - ecCal_t calS; // software calibration data -} wiiEC_t; - -//----------------------------------------------------------------------------- ---------------------------------------- -// Function prototypes -// -// top level calls will work out which sub-function to call -// top level check() function will handle connect/disconnect messages -// - -#include // Canvas -typedef struct wiiEC wiiEC_t; -typedef enum ecCalib ecCalib_t; -typedef struct state state_t; -typedef struct eventMsg eventMsg_t; - -void ecDecode(wiiEC_t* const pec); -void ecPoll(wiiEC_t* const pec, FuriMessageQueue* const queue); -void ecCalibrate(wiiEC_t* const pec, ecCalib_t c); - -void ec_show(Canvas* const canvas, state_t* const state); -bool ec_key(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_EC_H_ diff --git a/applications/plugins/wii_ec_anal/wii_ec_classic.c b/applications/plugins/wii_ec_anal/wii_ec_classic.c deleted file mode 100644 index 5bd3398ca..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec_classic.c +++ /dev/null @@ -1,439 +0,0 @@ -#include -#include // Core API - -#include "wii_anal.h" -#include "wii_ec.h" -#include "bc_logging.h" - -//#include "gfx/images.h" // Images -#include "wii_anal_lcd.h" // Drawing functions -#include "wii_anal_keys.h" // key mappings - -// ** If you want to see what this source code looks like with all the MACROs expanded -// ** grep -v '#include ' wii_i2c_classic.c | gcc -E -o /dev/stdout -xc - -#include "wii_ec_macros.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -// Classic Controller ... Classic Controller Pro is electronically the same -// -// ANA{l} ANA{r} -// BTN{l} BTN{L} BTN{R} BTN{r} -// ,--------. ,-, ,-, .--------, -// .----------------------------------------------------------. -// | | -// | BTN{W} BTN{x} | -// | BTN{A} BTN{D} BTN{-} BTN{h} BTN{+} BTN{y} BTN{a} | -// | BTN{S} BTN{b} | -// | | -// | ANA{y} ANA{Y} | -// | ANA{x} ANA{X} | -// | | -// `----------------------------------------------------------' - -//+============================================================================ ======================================== -// https://wiibrew.org/wiki/Wiimote/Extension_Controllers/Classic_Controller -// I think a LOT of drugs went in to "designing" this layout -// ...And yes, the left-joystick has an extra 'bit' of precision! -// ...Also: trgZ{L|R} WILL continue to increase after btnZ{L|R} has gone active -// -void classic_decode(wiiEC_t* const pec) { - ecDecClassic_t* p = &pec->dec[(pec->decN = !pec->decN)].classic; - uint8_t* joy = pec->joy; - - p->trgZL = ((joy[2] >> 2) & 0x18) | ((joy[3] >> 5) & 0x07); // {5} - p->btnZL = !(joy[4] & 0x20); // !{1} - - p->trgZR = joy[3] & 0x1F; // {5} - p->btnZR = !(joy[4] & 0x02); // !{1} - - p->btnL = !(joy[5] & 0x80); // !{1} - p->btnR = !(joy[5] & 0x04); // !{1} - - p->padU = !(joy[5] & 0x01); // !{1} - p->padD = !(joy[4] & 0x40); // !{1} - p->padL = !(joy[5] & 0x02); // !{1} - p->padR = !(joy[4] & 0x80); // !{1} - - p->btnM = !(joy[4] & 0x10); // !{1} - p->btnH = !(joy[4] & 0x08); // !{1} - p->btnP = !(joy[4] & 0x04); // !{1} - - p->btnX = !(joy[5] & 0x08); // !{1} - p->btnY = !(joy[5] & 0x20); // !{1} - - p->btnA = !(joy[5] & 0x10); // !{1} - p->btnB = !(joy[5] & 0x40); // !{1} - - p->joyLX = joy[0] & 0x3F; // {6} - p->joyLY = joy[1] & 0x3F; // {6} - - p->joyRX = ((joy[0] >> 3) & 0x18) | ((joy[1] >> 5) & 0x06) | ((joy[2] >> 7) & 0x01); // {5} - p->joyRY = joy[2] & 0x1F; // {5} - - DEBUG( - ">%d> ZL{%02X}%c, L:%c, R:%c, ZR{%02X}%c", - pec->decN, - p->trgZL, - (p->btnZL ? '#' : '.'), - (p->btnL ? '#' : '.'), - (p->btnR ? '#' : '.'), - p->trgZR, - (p->btnZR ? '#' : '.')); - DEBUG( - ">%d> D:{%c,%c,%c,%c}, H:{%c,%c,%c}, B:{%c,%c,%c,%c}", - pec->decN, - (p->padU ? 'U' : '.'), - (p->padD ? 'D' : '.'), - (p->padL ? 'L' : '.'), - (p->padR ? 'R' : '.'), - (p->btnM ? '-' : '.'), - (p->btnH ? 'H' : '.'), - (p->btnP ? '+' : '.'), - (p->btnX ? 'X' : '.'), - (p->btnY ? 'Y' : '.'), - (p->btnA ? 'A' : '.'), - (p->btnB ? 'B' : '.')); - DEBUG( - ">%d> JoyL{x:%02X, y:%02X}, JoyR{x:%02X, y:%02X}", - pec->decN, - p->joyLX, - p->joyLY, - p->joyRX, - p->joyRY); -} - -//+============================================================================ ======================================== -// Give each button a unique character identifier -// -void classic_msg(wiiEC_t* const pec, FuriMessageQueue* const queue) { - ecDecClassic_t* new = &pec->dec[pec->decN].classic; - ecDecClassic_t* old = &pec->dec[!pec->decN].classic; - - eventMsg_t msg = { - .id = EVID_WIIEC, - .wiiEc = { - .type = WIIEC_NONE, - .in = ' ', - .val = 0, - }}; - - ANALOG(trgZL, 'l'); // FIVE bit value - ANABTN(btnZL, trgZL, 'l'); - - BUTTON(btnL, 'L'); - BUTTON(btnR, 'R'); - - ANALOG(trgZR, 'r'); // FIVE bit value - ANABTN(btnZR, trgZR, 'r'); - - BUTTON(padU, 'W'); - BUTTON(padL, 'A'); - BUTTON(padD, 'S'); - BUTTON(padR, 'D'); - - BUTTON(btnM, '-'); - BUTTON(btnH, 'h'); - BUTTON(btnP, '+'); - - BUTTON(btnX, 'x'); - BUTTON(btnY, 'y'); - BUTTON(btnA, 'a'); - BUTTON(btnB, 'b'); - - ANALOG(joyLX, 'x'); // SIX bit values - ANALOG(joyLY, 'y'); - - ANALOG(joyRX, 'X'); // FIVE bit values - ANALOG(joyRY, 'Y'); -} - -//+============================================================================ ======================================== -// https://web.archive.org/web/20090415045219/http://www.wiili.org/index.php/Wiimote/Extension_Controllers/Classic_Controller#Calibration_data -// -// Calibration data -// 0..2 left analog stick X axis {maximum, minimum, center} ... JoyL is 6bits, so >>2 to compare to readings -// 3..5 left analog stick Y axis {maximum, minimum, center} ... JoyL is 6bits, so >>2 to compare to readings -// 6..8 right analog stick X axis {maximum, minimum, center} ... JoyR is 5bits, so >>3 to compare to readings -// 9..11 right analog stick Y axis {maximum, minimum, center} ... JoyR is 5bits, so >>3 to compare to readings -// 12..15 somehow describe the shoulder {5bit} button values!? -// -void classic_calib(wiiEC_t* const pec, ecCalib_t c) { - ecDecClassic_t* src = &pec->dec[pec->decN].classic; // from input - ecCalClassic_t* dst = pec->calS.classic; // to calibration data - - if(c & CAL_RESET) { // initialise ready for software calibration - // LO is set to the MAXIMUM value (so it can be reduced) - // HI is set to ZERO (so it can be increased) - RESET_LO_HI(trgZL, 5); // 5bit value - RESET_LO_HI(trgZR, 5); // 5bit value - - RESET_LO_MID_HI(joyLX, 6); // 6bit value - RESET_LO_MID_HI(joyLY, 6); // 6bit value - - RESET_LO_MID_HI(joyRX, 5); // 5bit value - RESET_LO_MID_HI(joyRY, 5); // 5bit value - } - if(c & CAL_FACTORY) { // (re)set to factory defaults - //! strategy for factory calibration for classic controller [pro] triggers is (currently) unknown - //! FACTORY_LO( trgZL, pec->calF[12..15]); - //! FACTORY_MID(trgZL, pec->calF[12..15]); - //! FACTORY_HI( trgZL, pec->calF[12..15]); - - //! FACTORY_LO( trgZR, pec->calF[12..15]); - //! FACTORY_MID(trgZR, pec->calF[12..15]); - //! FACTORY_HI( trgZR, pec->calF[12..15]); - -#if 1 - FACTORY_LO(trgZL, 0x03); - FACTORY_LO(trgZR, 0x03); - - FACTORY_MID(trgZL, 0x1B); //! these will be set every time the digital switch changes to ON - FACTORY_MID(trgZR, 0x1B); -#endif - - FACTORY_LO(joyLX, pec->calF[1] >> 2); - FACTORY_MID(joyLX, pec->calF[2] >> 2); - FACTORY_HI(joyLX, pec->calF[0] >> 2); - - FACTORY_LO(joyLY, pec->calF[4] >> 2); - FACTORY_MID(joyLY, pec->calF[5] >> 2); - FACTORY_HI(joyLY, pec->calF[3] >> 2); - - FACTORY_LO(joyRX, pec->calF[7] >> 3); - FACTORY_MID(joyRX, pec->calF[8] >> 3); - FACTORY_HI(joyRX, pec->calF[6] >> 3); - - FACTORY_LO(joyRY, pec->calF[10] >> 3); - FACTORY_MID(joyRY, pec->calF[11] >> 3); - FACTORY_HI(joyRY, pec->calF[9] >> 3); - } - if(c & CAL_TRACK) { // track maximum and minimum values seen - TRACK_LO_HI(trgZL); - TRACK_LO_HI(trgZR); - - TRACK_LO_HI(joyLX); - TRACK_LO_HI(joyLY); - - TRACK_LO_HI(joyRX); - TRACK_LO_HI(joyRY); - } - if(c & CAL_RANGE) { // perform software calibration step - RANGE_LO_HI(trgZL); - RANGE_LO_HI(trgZR); - - RANGE_LO_HI(joyLX); - RANGE_LO_HI(joyLY); - - RANGE_LO_HI(joyRX); - RANGE_LO_HI(joyRY); - } - if(c & CAL_CENTRE) { // reset centre point of joystick - CENTRE(joyLX); - CENTRE(joyLY); - - CENTRE(joyRX); - CENTRE(joyRY); - } -} - -//+============================================================================ ======================================== -// bits that are common to both screens -// -static void classic_show_(Canvas* const canvas, state_t* const state) { - ecDecClassic_t* d = &state->ec.dec[state->ec.decN].classic; - ecCalClassic_t* js = state->ec.calS.classic; - - static const int dead = 1; // trigger deadzone - const image_t* img = NULL; // trigger image - - show(canvas, 6, 0, &img_cc_Main, SHOW_SET_BLK); - show(canvas, 62, 53, &img_cc_Cable, SHOW_SET_BLK); - - // classic triggers - if(d->trgZL >= js[2].trgZL) - img = &img_cc_trg_L4; - else if(d->trgZL <= js[1].trgZL + dead) - img = NULL; - else { - // copied from the joystick calibration code - int lo = js[1].trgZL + dead + 1; - int hi = js[2].trgZL - 1; - int range = hi - lo + 1; - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - int hi1 = lo + div - 1; // (in brevity) - int lo3 = lo + div + div + (rem == 2); // ... - - if(d->trgZL <= hi1) - img = &img_cc_trg_L1; // zone #1 - else if(d->trgZL >= lo3) - img = &img_cc_trg_L3; // zone #3 - else - img = &img_cc_trg_L2; // zone #2 - } - if(img) show(canvas, 22, 1, img, SHOW_SET_BLK); - - if(d->trgZR >= js[2].trgZR) - img = &img_cc_trg_R4; - else if(d->trgZR <= js[1].trgZR + dead) - img = NULL; - else { - // copied from the joystick calibration code - int lo = js[1].trgZR + dead + 1; - int hi = js[2].trgZR - 1; - int range = hi - lo + 1; - int div = range / 3; // each division (base amount, eg. 17/3==5) - int rem = range - (div * 3); // remainder (ie. range%3) - int hi1 = lo + div - 1; // (in brevity) - int lo3 = lo + div + div + (rem == 2); // ... - - if(d->trgZR <= hi1) - img = &img_cc_trg_R1; // zone #1 - else if(d->trgZR >= lo3) - img = &img_cc_trg_R3; // zone #3 - else - img = &img_cc_trg_R2; // zone #2 - } - if(img) show(canvas, 89, 1, img, SHOW_SET_BLK); - - if(d->padU) show(canvas, 27, 16, &img_cc_pad_UD1, SHOW_ALL); - if(d->padL) show(canvas, 20, 23, &img_cc_pad_LR1, SHOW_ALL); - if(d->padD) show(canvas, 27, 28, &img_cc_pad_UD1, SHOW_ALL); - if(d->padR) show(canvas, 32, 23, &img_cc_pad_LR1, SHOW_ALL); - - if(d->btnX) show(canvas, 96, 16, &img_cc_btn_X1, SHOW_ALL); - if(d->btnY) show(canvas, 85, 23, &img_cc_btn_Y1, SHOW_ALL); - if(d->btnA) show(canvas, 107, 23, &img_cc_btn_A1, SHOW_ALL); - if(d->btnB) show(canvas, 96, 30, &img_cc_btn_B1, SHOW_ALL); - - canvas_set_color(canvas, ColorBlack); - if(d->btnL) canvas_draw_box(canvas, 46, 2, 5, 4); - if(d->btnR) canvas_draw_box(canvas, 77, 2, 5, 4); - - if(d->btnM) canvas_draw_box(canvas, 54, 24, 4, 4); - if(d->btnH) canvas_draw_box(canvas, 62, 24, 4, 4); - if(d->btnP) canvas_draw_box(canvas, 70, 24, 4, 4); - - // Show joysticks - showJoy( - canvas, - 48, - 42, - js[1].joyLX, - js[2].joyLX, - js[3].joyLX, - js[1].joyLY, - js[2].joyLY, - js[3].joyLY, - d->joyLX, - d->joyLY, - 6); - showJoy( - canvas, - 78, - 42, - js[1].joyRX, - js[2].joyRX, - js[3].joyRX, - js[1].joyRY, - js[2].joyRY, - js[3].joyRY, - d->joyRX, - d->joyRY, - 5); - - show(canvas, 0, 55, &img_key_L, SHOW_SET_BLK); -} - -//+============================================================================ ======================================== -static void classic_showN(Canvas* const canvas, state_t* const state) { - ecCalClassic_t* c = (state->hold) ? - &state->ec.calS.classic[(state->hold < 0) ? 0 : 4] : - (ecCalClassic_t*)(&state->ec.dec[state->ec.decN].classic); //! danger - - classic_show_(canvas, state); - - showHex(canvas, 0, 0, c->trgZL, 2, 1); // 5bits - showHex(canvas, 113, 0, c->trgZR, 2, 1); // 5bits - - showHex(canvas, 24, 41, c->joyLX, 2, 1); // 6bits - showHex(canvas, 41, 54, c->joyLY, 2, 1); // 6bits - - showHex(canvas, 88, 41, c->joyRX, 2, 1); // 5bits - showHex(canvas, 71, 54, c->joyRY, 2, 1); // 5bits - - showPeakHold(state, canvas, state->hold); // peak keys -} - -//+============================================================================ ======================================== -void classic_show(Canvas* const canvas, state_t* const state) { - // Classic controllers have TWO scenes - if(state->scene == SCENE_CLASSIC_N) return classic_showN(canvas, state); - - // Default scene - classic_show_(canvas, state); - show(canvas, 9, 55, &img_key_R, SHOW_SET_BLK); - - show( - canvas, - 119, - 55, - ((state->calib & CAL_RANGE) && (++state->flash & 8)) ? &img_key_OKi : &img_key_OK, - SHOW_SET_BLK); -} - -//+============================================================================ ======================================== -static bool classic_keyN(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - if((msg->input.type == InputTypeShort) && (msg->input.key == InputKeyLeft)) { - sceneSet(state, SCENE_CLASSIC); - used = true; - } - - // Calibration keys - if(!used) used = key_calib(msg, state); - - return used; -} - -//+============================================================================ ======================================== -bool classic_key(const eventMsg_t* const msg, state_t* const state) { - // Classic controllers have TWO scenes - if(state->scene == SCENE_CLASSIC_N) return classic_keyN(msg, state); - - // Default scene - int used = false; // assume key is NOT-handled - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyUp: //# -#include - -//----------------------------------------------------------------------------- ---------------------------------------- -// Classic Controller ... Classic Controller Pro is electronically the same -// -// ANA{l} ANA{r} -// BTN{l} BTN{L} BTN{R} BTN{r} -// ,--------. ,-, ,-, .--------, -// .----------------------------------------------------------. -// | | -// | BTN{W} BTN{x} | -// | BTN{A} BTN{D} BTN{-} BTN{h} BTN{+} BTN{y} BTN{a} | -// | BTN{S} BTN{b} | -// | | -// | ANA{y} ANA{Y} | -// | ANA{x} ANA{X} | -// | | -// `----------------------------------------------------------' -// - -//----------------------------------------------------------------------------- ---------------------------------------- -// Controllers which have calibration must have their calibratable controls here -//! Is there a better way to get the start of the decode struct to match the calibration struct ? -#define CLASSIC_ANALOGUE \ - uint8_t trgZL, trgZR; /* ANA{l, l} lowercase=trigger 5bit values {5} */ \ - uint8_t joyLX, joyLY; /* ANA{x, y} left=lowercase 6bit values {6}<-- */ \ - uint8_t joyRX, joyRY; /* ANA{X, Y} 5bit values {5} */ - -//----------------------------------------------------------------------------- -// Calibratable controls -// -typedef struct ecCalClassic { - CLASSIC_ANALOGUE -} ecCalClassic_t; - -//----------------------------------------------------------------------------- -// All controls -// -typedef struct ecDecClassic { - CLASSIC_ANALOGUE // MUST be first - - // Digital controls - bool btnZL, - btnZR; // BTN{l, l} - - bool btnL, btnR; // BTN{L, R} upperrcase=shoulder - - bool padU, padL, padD, padR; // BTN{W, A, S, D} - - bool btnM, btnH, btnP; // BTN{-, h, +} - - bool btnX, btnY; // BTN{x, y} - bool btnA, btnB; // BTN{a, b} - -} ecDecClassic_t; - -#undef CLASSIC_ANALOGUE - -//============================================================================= ======================================== -// Function prototypes -// -#include // Canvas -typedef struct wiiEC wiiEC_t; -typedef enum ecCalib ecCalib_t; -typedef struct state state_t; -typedef struct eventMsg eventMsg_t; - -void classic_decode(wiiEC_t* const pec); -void classic_msg(wiiEC_t* const pec, FuriMessageQueue* const queue); -void classic_calib(wiiEC_t* const pec, ecCalib_t c); - -void classic_show(Canvas* const canvas, state_t* const state); -bool classic_key(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_EC_CLASSIC_H_ diff --git a/applications/plugins/wii_ec_anal/wii_ec_macros.h b/applications/plugins/wii_ec_anal/wii_ec_macros.h deleted file mode 100644 index 00ab9825b..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec_macros.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef WII_EC_MACROS_H_ -#define WII_EC_MACROS_H_ - -//----------------------------------------------------------------------------- ---------------------------------------- -// CHECK MACROS -// -// I don't generally like this style of coding - it just (generally) makes things nightmarish to debug -// However, on this occasion I think it's a good choice (to make adding controllers LESS bug-prone) -// - -//if (furi_message_queue_get_count(queue) > 18) WARN("queue high %d", furi_message_queue_get_count(queue)); -#define MSGQ(lbl) \ - do { \ - msg.wiiEc.in = lbl; \ - furi_message_queue_put(queue, &msg, 0); \ - } while(0) - -// A 'standard' "button" is an independent SPST switch -// Eg. Nunchuck 'Z' button -// The "value" will always be 0 -#define BUTTON(btn, lbl) \ - do { \ - if(new->btn != old->btn) { \ - msg.wiiEc.type = (new->btn) ? WIIEC_PRESS : WIIEC_RELEASE; \ - msg.wiiEc.val = 0; \ - MSGQ(lbl); \ - } \ - } while(0) - -// An "analogue button" is an SPST coupled with an ananlogue 'switch' -// Eg. The "bottom out" switches on the triggers of the classic controller -// The "value" will be the value of the associated analogue controller -#define ANABTN(btn, ana, lbl) \ - do { \ - if(new->btn != old->btn) { \ - msg.wiiEc.type = (new->btn) ? WIIEC_PRESS : WIIEC_RELEASE; \ - msg.wiiEc.val = new->ana; \ - MSGQ(lbl); \ - } \ - } while(0) - -#define ANALOG(ana, lbl) \ - do { \ - if(new->ana != old->ana) { \ - msg.wiiEc.type = WIIEC_ANALOG; \ - msg.wiiEc.val = new->ana; \ - MSGQ(lbl); \ - } \ - } while(0) - -#define ACCEL(acc, lbl) \ - do { \ - if(new->acc != old->acc) { \ - msg.wiiEc.type = WIIEC_ACCEL; \ - msg.wiiEc.val = new->acc; \ - MSGQ(lbl); \ - } \ - } while(0) - -//----------------------------------------------------------------------------- ---------------------------------------- -// CALIBRATION MACROS -// -// Again ...I totally agree with anyone who says "MACRO coding" is (gernally) a poor choice of programming style -// But something about this code is making it soooo appealing -// -// ... v=variable, n=number -// -#define FACTORY_LO(v, n) \ - do { \ - (dst[1].v) = n; \ - } while(0) -#define FACTORY_MID(v, n) \ - do { \ - (dst[2].v) = n; \ - } while(0) -#define FACTORY_HI(v, n) \ - do { \ - (dst[3].v) = n; \ - } while(0) - -#define TRACK_LO(v) \ - do { \ - if((src->v) < (dst[0].v)) (dst[0].v) = (src->v); \ - } while(0) -#define TRACK_HI(v) \ - do { \ - if((src->v) > (dst[4].v)) (dst[4].v) = (src->v); \ - } while(0) -#define TRACK_LO_HI(v) \ - do { \ - TRACK_LO(v); \ - TRACK_HI(v); \ - } while(0) - -#define RESET_LO(v, b) \ - do { \ - (dst[0].v) = (dst[1].v) = ((1 << (b)) - 1); \ - } while(0) -#define RESET_HI(v) \ - do { \ - (dst[4].v) = (dst[3].v) = 0; \ - } while(0) -#define RESET_MID(v) \ - do { \ - (dst[2].v) = (src->v); \ - } while(0) -#define RESET_LO_HI(v, b) \ - do { \ - RESET_LO(v, b); \ - RESET_HI(v); \ - } while(0) -#define RESET_LO_MID_HI(v, b) \ - do { \ - RESET_LO(v, b); \ - RESET_MID(v); \ - RESET_HI(v); \ - } while(0) - -#define RANGE_LO(v) \ - do { \ - if((src->v) < (dst[1].v)) (dst[1].v) = (src->v); \ - } while(0) -#define RANGE_HI(v) \ - do { \ - if((src->v) > (dst[3].v)) (dst[3].v) = (src->v); \ - } while(0) -#define RANGE_LO_HI(v) \ - do { \ - RANGE_LO(v); \ - RANGE_HI(v); \ - } while(0) - -#define CENTRE(v) \ - do { \ - (dst[2].v) = (src->v); \ - } while(0) - -#endif //WII_EC_MACROS_H_ diff --git a/applications/plugins/wii_ec_anal/wii_ec_nunchuck.c b/applications/plugins/wii_ec_anal/wii_ec_nunchuck.c deleted file mode 100644 index d88d535b6..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec_nunchuck.c +++ /dev/null @@ -1,476 +0,0 @@ -#include -#include // Core API - -#include "wii_anal.h" -#include "wii_i2c.h" -#include "bc_logging.h" - -#include "gfx/images.h" // Images -#include "wii_anal_lcd.h" // Drawing functions -#include "wii_anal_keys.h" // key mappings - -// ** If you want to see what this source code looks like with all the MACROs expanded -// ** grep -v '#include ' wii_ec_nunchuck.c | gcc -E -o /dev/stdout -xc - -#include "wii_ec_macros.h" - -//+============================================================================ ======================================== -// Standard Nunchuck : 2 buttons, 1 analogue joystick, 1 3-axis accelerometer -// -void nunchuck_decode(wiiEC_t* const pec) { - ecDecNunchuck_t* p = &pec->dec[(pec->decN = !pec->decN)].nunchuck; - uint8_t* joy = pec->joy; - - p->btnC = !(joy[5] & 0x02); // !{1} - p->btnZ = !(joy[5] & 0x01); // !{1} - - p->joyX = joy[0]; // {8} - p->joyY = joy[1]; // {8} - - p->accX = ((uint16_t)joy[2] << 2) | ((joy[5] >> 2) & 0x03); // {10} - p->accY = ((uint16_t)joy[3] << 2) | ((joy[5] >> 4) & 0x03); // {10} - p->accZ = ((uint16_t)joy[4] << 2) | ((joy[5] >> 6) & 0x03); // {10} - - DEBUG( - ">%d> C:%c, Z:%c, Joy{x:%02X, y:%02X}, Acc{x:%03X, y:%03X, z:%03X}", - pec->decN, - (p->btnC ? '#' : '.'), - (p->btnZ ? '#' : '.'), - p->joyX, - p->joyY, - p->accX, - p->accY, - p->accZ); -} - -//+============================================================================ ======================================== -// Give each button a unique character identifier -// -void nunchuck_msg(wiiEC_t* const pec, FuriMessageQueue* const queue) { - ecDecNunchuck_t* new = &pec->dec[pec->decN].nunchuck; - ecDecNunchuck_t* old = &pec->dec[!pec->decN].nunchuck; - - eventMsg_t msg = { - .id = EVID_WIIEC, - .wiiEc = { - .type = WIIEC_NONE, - .in = ' ', - .val = 0, - }}; - - BUTTON(btnC, 'c'); - BUTTON(btnZ, 'z'); - - ANALOG(joyX, 'x'); - ANALOG(joyY, 'y'); - - ACCEL(accX, 'x'); - ACCEL(accY, 'y'); - ACCEL(accZ, 'z'); -} - -//+============================================================================ ======================================== -// https://www.hackster.io/infusion/using-a-wii-nunchuk-with-arduino-597254#toc-5--read-actual-calibration-data-from-the-device-14 -// -void nunchuck_calib(wiiEC_t* const pec, ecCalib_t c) { - ecDecNunchuck_t* src = &pec->dec[pec->decN].nunchuck; // from input - ecCalNunchuck_t* dst = pec->calS.nunchuck; // to calibration data - - if(c & CAL_RESET) { // initialise ready for software calibration - // LO is set to the MAXIMUM value (so it can be reduced) - // HI is set to ZERO (so it can be increased) - RESET_LO_HI(accX, 10); // 10bit value - RESET_LO_HI(accY, 10); // 10bit value - RESET_LO_HI(accZ, 10); // 10bit value - - RESET_LO_HI(joyX, 8); // 8bit value - RESET_LO_HI(joyY, 8); // 8bit value - } - if(c & CAL_FACTORY) { // (re)set to factory defaults - //! "[4] LSB of Zero value of X,Y,Z axes" ...helpful! - //! ...Well, my test nunchuck has bits set in the bottom 6 bits, so let's guess ;) - - // No value available - annecdotal tests suggest 8 is reasonable - FACTORY_LO(accX, 8); - FACTORY_LO(accY, 8); - FACTORY_LO(accZ, 8); - - // @ 0G - FACTORY_MID(accX, ((pec->calF[0] << 2) | ((pec->calF[3] >> 4) & 0x3))); - FACTORY_MID(accY, ((pec->calF[1] << 2) | ((pec->calF[3] >> 2) & 0x3))); - FACTORY_MID(accZ, ((pec->calF[2] << 2) | ((pec->calF[3]) & 0x3))); - - // @ 1G - FACTORY_HI(accX, ((pec->calF[4] << 2) | ((pec->calF[7] >> 4) & 0x3))); - FACTORY_HI(accY, ((pec->calF[5] << 2) | ((pec->calF[7] >> 2) & 0x3))); - FACTORY_HI(accZ, ((pec->calF[6] << 2) | ((pec->calF[7]) & 0x3))); - - // Joysticks - FACTORY_LO(joyX, pec->calF[9]); - FACTORY_MID(joyX, pec->calF[10]); - FACTORY_HI(joyX, pec->calF[8]); - - FACTORY_LO(joyY, pec->calF[12]); - FACTORY_MID(joyY, pec->calF[13]); - FACTORY_HI(joyY, pec->calF[11]); - } - if(c & CAL_TRACK) { // track maximum and minimum values seen - TRACK_LO_HI(accX); - TRACK_LO_HI(accY); - TRACK_LO_HI(accZ); - - TRACK_LO_HI(joyX); - TRACK_LO_HI(joyY); - } - if(c & CAL_RANGE) { // perform software calibration step - RANGE_LO_HI(accX); - RANGE_LO_HI(accY); - RANGE_LO_HI(accZ); - - if(!(c & CAL_NOTJOY)) { // double negative! - RANGE_LO_HI(joyX); - RANGE_LO_HI(joyY); - } - } - if(c & CAL_CENTRE) { // reset centre point of joystick - CENTRE(accX); - CENTRE(accY); - CENTRE(accZ); - - CENTRE(joyX); - CENTRE(joyY); - } -} - -//============================================================================= ======================================== -// Accelerometer screen ...might this be useful for other controllers? -// -// https://bootlin.com/labs/doc/nunchuk.pdf -// X : Move Left/Right : -left / +right -// Y : Move Fwd/Bkwd : -fwd / +bkwd -// Z : Move Down/Up : -down / +up -// -// Movement in the direction of an axis changes that axis reading -// Twisting/tilting around an axis changes the other two readings -// -// EG. Move left will effect X ; turn left will effect Y & Z -// -#define aw 110 // axis width -#define ah 15 // height {0......7......14} -#define am 7 // midpoint { 7 } -#define ar 7 // range {1234567 1234567} - -enum { - ACC_X = 0, - ACC_Y = 1, - ACC_Z = 2, - ACC_CNT = 3, - ACC_1 = ACC_X, // first - ACC_N = ACC_Z, // last -}; - -//+============================================================================ -static void nunchuck_showAcc(Canvas* const canvas, state_t* const state) { - ecDecNunchuck_t* d = &state->ec.dec[state->ec.decN].nunchuck; - ecCalNunchuck_t* lo = &state->ec.calS.nunchuck[1]; - ecCalNunchuck_t* mid = &state->ec.calS.nunchuck[2]; - ecCalNunchuck_t* hi = &state->ec.calS.nunchuck[3]; - - int y[ACC_CNT] = {0, 0 + (ah + 4), 0 + ((ah + 4) * 2)}; - int x = 10; - - static uint16_t v[ACC_CNT][aw] = {0}; - // static uint16_t tv[ACC_CNT][aw] = {0}; - - static uint16_t idx = 0; - static uint16_t cnt = aw - 1; - - // Only record when scanner NOT-paused - if(!state->pause) { - uint16_t dead = (1 << 5); - - // Find axes y-offsets - for(int a = ACC_1; a <= ACC_N; a++) { - uint16_t* dp = NULL; // data value (current reading) - uint16_t* lp = NULL; // lo value - uint16_t* mp = NULL; // mid value - uint16_t* hp = NULL; // hi value - uint16_t* vp = NULL; // value (result) - - switch(a) { - case ACC_X: - dp = &d->accX; // data (input) - lp = &lo->accX; // low \. - mp = &mid->accX; // mid > calibration - hp = &hi->accX; // high / - vp = &v[ACC_X][idx]; // value (where to store the result) - break; - case ACC_Y: - dp = &d->accY; - lp = &lo->accY; - mp = &mid->accY; - hp = &hi->accY; - vp = &v[ACC_Y][idx]; - break; - case ACC_Z: - dp = &d->accZ; - lp = &lo->accZ; - mp = &mid->accZ; - hp = &hi->accZ; - vp = &v[ACC_Z][idx]; - break; - default: - break; - } - - // Again - qv. the joysick calibration: - // This is not the "right way" to do this, it is just "one way" to do it - // ...mid point and extreme zones have a deadzone - // ...the rest is evenly divided by the amount of space on the graph - if((*dp >= (*mp - dead)) && (*dp <= (*mp + dead))) - *vp = ar; - else if(*dp >= (*hp - dead)) - *vp = ah - 1; - else if(*dp <= (*lp + dead)) - *vp = 0; - else if(*dp < *mp) { - uint16_t min = ((*lp + dead) + 1); - uint16_t max = ((*mp - dead) - 1); - float range = (max - min) + 1; - float m = range / (ar - 1); // 6 evenly(/fairly) divided zones - *vp = ((int)((*dp - min) / m)) + 1; - - } else { //if (*dp > *mp) - uint16_t min = ((*mp + dead) + 1); - uint16_t max = ((*hp - dead) - 1); - float range = (max - min) + 1; - float m = range / (ar - 1); // 6 evenly(/fairly) divided zones - *vp = ((int)((*dp - min) / m)) + 1 + ar; - } - } - - //! If we decide to offer "export to CSV" - //! I suggest we keep a second array of true-values, rather than do all the maths every time - //! Also - the data will need to me moved to the 'state' table - so a.n.other function can save it off - // tv[ACC_X][idx] = d->accX; - // tv[ACC_Y][idx] = d->accY; - // tv[ACC_Z][idx] = d->accZ; - - // Prepare for the next datapoint - if(++idx >= aw) idx = 0; - if(cnt) cnt--; - } - - // Auto-pause - if(state->apause && !idx) state->pause = true; - - // *** Draw axes *** - show(canvas, 0, y[ACC_X] + ((ah - img_6x8_X.h) / 2), &img_6x8_X, SHOW_SET_BLK); - show(canvas, 0, y[ACC_Y] + ((ah - img_6x8_Y.h) / 2), &img_6x8_Y, SHOW_SET_BLK); - show(canvas, 0, y[ACC_Z] + ((ah - img_6x8_Z.h) / 2), &img_6x8_Z, SHOW_SET_BLK); - - canvas_set_color(canvas, ColorBlack); - for(int a = ACC_1; a <= ACC_N; a++) { - canvas_draw_line(canvas, x - 1, y[a], x - 1, y[a] + ah); - canvas_draw_line(canvas, x, y[a] + ah, x + aw - 1, y[a] + ah); - - // Mid & Peak lines - for(int i = 1; i < aw; i += 3) { - canvas_draw_dot(canvas, x + i, y[a]); - canvas_draw_dot(canvas, x + i, y[a] + (ah / 2)); - } - } - - // Data (wiper display - see notes.txt for scrolling algorithm) - int end = idx ? idx : aw; - for(int a = ACC_1; a <= ACC_N; a++) { - canvas_draw_dot(canvas, x, y[a] + v[a][idx]); - for(int i = 1; i < end; i++) - canvas_draw_line(canvas, x + i, y[a] + v[a][i - 1], x + i, y[a] + v[a][i]); - if(!state->apause) - for(int i = end + 10; i < aw - cnt; i++) - canvas_draw_line(canvas, x + i, y[a] + v[a][i - 1], x + i, y[a] + v[a][i]); - } - // Wipe bar - if(end < aw) canvas_draw_line(canvas, x + end, y[0], x + end, y[2] + ah - 1); - if(++end < aw) canvas_draw_line(canvas, x + end, y[0], x + end, y[2] + ah - 1); - if(++end < aw) canvas_draw_line(canvas, x + end, y[0], x + end, y[2] + ah - 1); - - // *** Mode buttons *** - show(canvas, 0, 55, &img_key_L, SHOW_SET_BLK); // mode key - - if((state->calib & CAL_RANGE) || state->pause) state->flash++; - - // -pause- ...yeah, this got a little out of hand! LOL! - if(state->pause || state->apause) { - if(state->pause && state->apause && !idx) { - if(state->flash & 8) { - show(canvas, 108, 56, &img_key_U, SHOW_SET_BLK); - } else { - show(canvas, 108, 56, &img_key_Ui, SHOW_SET_BLK); - canvas_draw_line(canvas, x + aw, y[0], x + aw, y[2] + ah - 1); - } - } else { - show(canvas, 108, 56, &img_key_Ui, SHOW_SET_BLK); - } - } else { - show(canvas, 108, 56, &img_key_U, SHOW_SET_BLK); // pause - } - - // -calibration- - if(state->calib & CAL_RANGE) { - show(canvas, 119, 55, (state->flash & 8) ? &img_key_OKi : &img_key_OK, SHOW_SET_BLK); - } else { - show(canvas, 119, 55, &img_key_OK, SHOW_SET_BLK); - } -} - -#undef aw -#undef ah -#undef am -#undef ar - -//+============================================================================ ======================================== -// Default nunchuck screen -// -void nunchuck_show(Canvas* const canvas, state_t* const state) { - // Nunchucks have TWO scenes - if(state->scene == SCENE_NUNCHUCK_ACC) return nunchuck_showAcc(canvas, state); - - // Default scene - ecDecNunchuck_t* d = &state->ec.dec[state->ec.decN].nunchuck; - ecCalNunchuck_t* c = (state->hold) ? &state->ec.calS.nunchuck[(state->hold < 0) ? 0 : 4] : - (ecCalNunchuck_t*)d; //! danger will robinson! - ecCalNunchuck_t* js = state->ec.calS.nunchuck; - - // X, Y, Z - show(canvas, 42, 0, &img_6x8_X, SHOW_SET_BLK); - show(canvas, 73, 0, &img_6x8_Y, SHOW_SET_BLK); - show(canvas, 104, 0, &img_6x8_Z, SHOW_SET_BLK); - - canvas_draw_str_aligned(canvas, 0, 14, AlignLeft, AlignTop, "Accel"); - canvas_draw_str_aligned(canvas, 0, 28, AlignLeft, AlignTop, "Joy"); - - // accel values - showHex(canvas, 34, 12, c->accX, 3, 2); - showHex(canvas, 65, 12, c->accY, 3, 2); - showHex(canvas, 96, 12, c->accZ, 3, 2); - // Joy values - showHex(canvas, 38, 27, c->joyX, 2, 2); - showHex(canvas, 69, 27, c->joyY, 2, 2); - - showJoy( - canvas, - 103, - 32, - js[1].joyX, - js[2].joyX, - js[3].joyX, - js[1].joyY, - js[2].joyY, - js[3].joyY, - d->joyX, - d->joyY, - 8); - - // buttons - canvas_set_color(canvas, ColorBlack); - canvas_draw_str_aligned(canvas, 0, 44, AlignLeft, AlignTop, "Button"); - - if(!d->btnC) { - canvas_draw_rframe(canvas, 36, 42, 18, 12, 6); - show(canvas, 42, 44, &img_6x8_C, SHOW_SET_BLK); - } else { - canvas_draw_rbox(canvas, 36, 42, 18, 12, 6); - show(canvas, 42, 44, &img_6x8_C, SHOW_SET_WHT); - canvas_set_color(canvas, ColorBlack); - } - - if(!d->btnZ) { - canvas_draw_rframe(canvas, 64, 40, 24, 16, 2); - show(canvas, 73, 44, &img_6x8_Z, SHOW_SET_BLK); - } else { - canvas_draw_rbox(canvas, 64, 40, 24, 16, 2); - show(canvas, 73, 44, &img_6x8_Z, SHOW_SET_WHT); - } - - // Navigation - showPeakHold(state, canvas, state->hold); // peak keys - show(canvas, 0, 55, &img_key_L, SHOW_SET_BLK); // mode keys - show(canvas, 9, 55, &img_key_R, SHOW_SET_BLK); -} - -//+============================================================================ ======================================== -static bool nunchuck_keyAcc(const eventMsg_t* const msg, state_t* const state) { - int used = false; // assume key is NOT-handled - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyDown: //# pause) - state->pause = false; // Paused? Restart - else - state->apause = !state->apause; // No? toggle auto-pause - used = true; - break; - - case InputKeyLeft: //# calib &= ~CAL_NOTJOY; // DO calibrate joystick in NUNCHUCK mode - used = true; - break; - - default: - break; //# scene == SCENE_NUNCHUCK_ACC) return nunchuck_keyAcc(msg, state); - - // Default scene - int used = false; // assume key is NOT-handled - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyLeft: //# calib |= CAL_NOTJOY; // do NOT calibrate joystick in _ACC mode - used = true; - break; - default: - break; //# -#include - -//----------------------------------------------------------------------------- -// Controllers which have calibration must have their calibratable controls here -//! Is there a better way to get the start of the decode struct to match the calibration struct ? -#define NUNCHUCK_ANALOGUE \ - uint8_t joyX, joyY; \ - uint16_t accX, accY, accZ; - -//----------------------------------------------------------------------------- -// Calibratable controls -// -typedef struct ecCalNunchuck { - NUNCHUCK_ANALOGUE -} ecCalNunchuck_t; - -//----------------------------------------------------------------------------- -// All controls -// -typedef struct ecDecNunchuck { - NUNCHUCK_ANALOGUE // MUST be first - - // Digital controls - bool btnC, - btnZ; // BTN{c, z} -} ecDecNunchuck_t; - -#undef NUNCHUCK_ANALOGUE - -//============================================================================= -// Function prototypes -// -#include // Canvas -typedef struct wiiEC wiiEC_t; -typedef enum ecCalib ecCalib_t; -typedef struct state state_t; -typedef struct eventMsg eventMsg_t; - -void nunchuck_decode(wiiEC_t* const pec); -void nunchuck_msg(wiiEC_t* const pec, FuriMessageQueue* const queue); -void nunchuck_calib(wiiEC_t* const pec, ecCalib_t c); - -void nunchuck_show(Canvas* const canvas, state_t* const state); -bool nunchuck_key(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_EC_NUNCHUCK_H_ diff --git a/applications/plugins/wii_ec_anal/wii_ec_udraw.c b/applications/plugins/wii_ec_anal/wii_ec_udraw.c deleted file mode 100644 index 82987b205..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec_udraw.c +++ /dev/null @@ -1,149 +0,0 @@ -//! udraw support is NOT written - this is just notes about the init function -#include -#include // Core API - -#include "wii_anal.h" -#include "wii_ec.h" -#include "bc_logging.h" - -#include "i2c_workaround.h" //! temporary workaround for a bug in furi i2c [see header] - -// ** If you want to see what this source code looks like with all the MACROs expanded -// ** grep -v '#include ' wii_ec_udraw.c | gcc -E -o /dev/stdout -xc - -#include "wii_ec_macros.h" - -//+============================================================================ ======================================== -// https://github.com/madhephaestus/WiiChuck/blob/master/src/Drawsome.cpp#L3 -// Gratuitously stolen ... never tested (don't own one) - just bought one on ebay -// although it seems like the UK version is a "uDraw" and MIGHT contain a different chipset :/ -// -// read 6 bytes starting from 0x20 -// read 6 bytes starting from 0x28 -// read 6 bytes starting from 0x30 -// read 6 bytes starting from 0x38 -// read 6 bytes starting from 0x00 (#1) -// read 6 bytes starting from 0x00 (#2) -// write 1 byte [0x01] to 0xFB -// read 6 bytes starting from 0x00 (#3) -// read 6 bytes starting from 0x00 (#4) -// -bool udraw_init(wiiEC_t* const pec) { - ENTER; - bool rv = true; - - (void)pec; - /* -//! this is the Drawsome code, NOT the uDraw code !! - static const uint8_t reg[9] = {0x20, 0x28, 0x30, 0x38, 0x00, 0x00, 0xFB, 0x00, 0x00}; // 0..8 - const uint8_t* p = reg; - uint8_t buf[6] = {0}; - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 0 - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 1 - furi_delay_ms(100); - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 2 - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 3 - furi_delay_ms(100); - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 4 - furi_delay_ms(100); - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 5 - furi_delay_ms(100); - - buf[0] = *p++; - buf[1] = 0x01; - if (!furi_hal_i2c_tx(bus,addr, buf,2, timeout)) goto fail ; // 6 - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 7 - furi_delay_ms(100); - - if (!furi_hal_i2c_trxd(bus,addr, p++,1, buf,sizeof(buf), timeout,300)) goto fail ; // 8 - furi_delay_ms(100); - - TRACE("%s : OK #%d", __func__, (p-reg)); - goto done; - -fail: - ERROR("%s : fail #%d", __func__, (p -reg) -1); - rv = false; - -done: -*/ - LEAVE; - return rv; -} - -//+============================================================================ ======================================== -bool udraw_key(const eventMsg_t* const msg, state_t* const state) { - (void)state; - bool run = true; - - switch(msg->input.type) { - case InputTypeShort: //# input.key) { - case InputKeyUp: //# ! After INPUT_LONG_PRESS interval, asynch to InputTypeRelease - switch(msg->input.key) { - case InputKeyUp: //# >U [ LONG-UP ] - case InputKeyDown: //# >D [ LONG-DOWN ] - case InputKeyLeft: //# >L [ LONG-LEFT ] - case InputKeyRight: //# >R [ LONG-RIGHT ] - case InputKeyOk: //# >O [ LONG-OK ] - case InputKeyBack: //# >B [ LONG-BACK ] - default: - break; //# >? - } - break; - case InputTypePress: //# +! After debounce - switch(msg->input.key) { - case InputKeyUp: //# +U [ SHORT-UP ] - case InputKeyDown: //# +D [ SHORT-DOWN ] - case InputKeyLeft: //# +L [ SHORT-LEFT ] - case InputKeyRight: //# +R [ SHORT-RIGHT ] - case InputKeyOk: //# +O [ SHORT-OK ] - case InputKeyBack: //# +B [ SHORT-BACK ] - default: - break; //# +? - } - break; - case InputTypeRepeat: //# *! With INPUT_REPEATE_PRESS period after InputTypeLong event - switch(msg->input.key) { - case InputKeyUp: //# *U [ REPEAT-UP ] - case InputKeyDown: //# *D [ REPEAT-DOWN ] - case InputKeyLeft: //# *L [ REPEAT-LEFT ] - case InputKeyRight: //# *R [ REPEAT-RIGHT ] - case InputKeyOk: //# *O [ REPEAT-OK ] - case InputKeyBack: //# *B [ REPEAT-BACK ] - default: - break; //# *? - } - break; - case InputTypeRelease: //# -! After debounce - switch(msg->input.key) { - case InputKeyUp: //# -U [ RELEASE-UP ] - case InputKeyDown: //# -D [ RELEASE-DOWN ] - case InputKeyLeft: //# -L [ RELEASE-LEFT ] - case InputKeyRight: //# -R [ RELEASE-RIGHT ] - case InputKeyOk: //# -O [ RELEASE-OK ] - case InputKeyBack: //# -B [ RELEASE-BACK ] - default: - break; //# -? - } - break; - default: - return true; - } - - return run; -} diff --git a/applications/plugins/wii_ec_anal/wii_ec_udraw.h b/applications/plugins/wii_ec_anal/wii_ec_udraw.h deleted file mode 100644 index 9283fd95d..000000000 --- a/applications/plugins/wii_ec_anal/wii_ec_udraw.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef WII_EC_UDRAW_H_ -#define WII_EC_UDRAW_H_ - -#include -#include - -//============================================================================= ======================================= -// Function prototypes -// -typedef struct wiiEC wiiEC_t; -typedef enum ecCalib ecCalib_t; -typedef struct eventMsg eventMsg_t; -typedef struct state state_t; - -bool udraw_init(wiiEC_t* const pec); -bool udraw_key(const eventMsg_t* const msg, state_t* const state); - -#endif //WII_EC_UDRAW_H_ diff --git a/applications/plugins/wii_ec_anal/wii_i2c.c b/applications/plugins/wii_ec_anal/wii_i2c.c deleted file mode 100644 index f5d6840d9..000000000 --- a/applications/plugins/wii_ec_anal/wii_i2c.c +++ /dev/null @@ -1,301 +0,0 @@ -//----------------------------------------------------------------------------- ---------------------------------------- -// Biblio: [standing on the shoulders of giants] -// https://bootlin.com/labs/doc/nunchuk.pdf -// https://www.hackster.io/infusion/using-a-wii-nunchuk-with-arduino-597254#toc-i2c-protocol-9 -// https://web.archive.org/web/20220000000000*/https://www.hackster.io/infusion/using-a-wii-nunchuk-with-arduino-597254 -// https://github.com/madhephaestus/WiiChuck/blob/master/src/Accessory.cpp#L14 -// https://wiibrew.org/wiki/Wiimote/Extension_Controllers -// https://www.best-microcontroller-projects.com/i2c-tutorial.html -// -// WiiMote Extension Controller: -// Bus Address : 0x52 -// Register autoincrements after each (byte is) read -// 0x00..0x05 ( 6 bytes) ... [r] Controller Data -// 0x20..0x2F (16 bytes) ... [r] Calibration Data -// 0x30..0x3F (16 bytes) ... [r] (A copy of the) Calibration Data -// 0x40..0x4F (16 bytes) ... [w] Encryption key(s) -// 0xFA..0xFF ( 6 bytes) ... [r] Perhipheral ID - -//----------------------------------------------------------------------------- ---------------------------------------- -#include -#include -#include - -#include -#include -#include - -#include "i2c_workaround.h" //! temporary workaround for a bug in furi i2c [see header] - -#include "wii_anal.h" -#include "wii_i2c.h" -#include "wii_ec.h" - -#include "bc_logging.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -// Wii Extension Controller i2c Bus address -static const uint8_t ec_i2cAddr = 0x52; - -// Initialise for UNencrypted comms -static const uint8_t regInit1 = 0xF0; -static const uint8_t regInit2 = 0xFB; -static const uint8_t cmdInit1[] = {regInit1, 0x55}; -static const uint8_t cmdInit2[] = {regInit2, 0x00}; - -// Initialise for ENcrypted comms -static const uint8_t regInitEnc = 0x40; -static const uint8_t cmdInitEnc[] = {regInitEnc, 0x00}; - -// Crypto key (PSK), base register : {0x40..0x4F}[2][8] -static const uint8_t regEnc = 0x40; // ENC_LEN - -// Controller State data, base register : {0x00..0x05}[6] -static const uint8_t regJoy = 0x00; // JOY_LEN - -// Calibration data, base register : {0x20..0x2F}[16] -static const uint8_t regCal = 0x20; // CAL_LEN - -// Controller ID, base register : {0xFA..0xFF}[6] -static const uint8_t regPid = 0xFA; // PID_LEN - -//+============================================================================ ======================================== -// Hexdump a buffer to the logfile -// -#if LOG_LEVEL >= 4 // INFO - -static void dump(const uint8_t* buf, const unsigned int len, const char* id) { - // snprintf() would be useful! - char s[128] = {0}; - char* p = NULL; - - strcpy(s, id); - p = s + strlen(s); - *p++ = ':'; - *p++ = ' '; - *p++ = '{'; - - for(unsigned int i = 0; i < len; i++) { - uint8_t hi = (buf[i] & 0xF0) >> 4; - uint8_t lo = (buf[i] & 0x0F); - - hi = hi + ((hi > 9) ? ('A' - 10) : '0'); - lo = lo + ((lo > 9) ? ('A' - 10) : '0'); - - *p++ = (char)hi; - *p++ = (char)lo; - *p++ = ','; - } - *p = '\0'; - *--p = '}'; - INFO(s); -} - -#else -#define dump(...) -#endif - -//+============================================================================ ======================================== -// -//! -W-A-R-N-I-N-G- : THIS ENCRYPTION CODE SHOULD NEVER BE REQUIRED ... AS SUCH, I'VE NEVER TESTED IT -// -static void decrypt(uint8_t* buf, const uint8_t* encKey, const uint8_t reg, unsigned int len) { -#if 1 // Use standard algorithm - // decrypted_byte = (encrypted_byte XOR encKey[1][address%8]) + encKey[2][address%8] - for(uint8_t* p = buf; p < buf + len; p++) - *p = (*p ^ encKey[(reg + (p - buf)) % 8]) + encKey[8 + ((reg + (p - buf)) % 8)]; - -#else //! This is (I think) a shortcut for an all-zero key [not tested] - (void)encKey; - (void)reg; - for(uint8_t* p = buf; p < buf + len; p++) *p = (*p ^ 0x17) + 0x17; -#endif -} - -//+============================================================================ ======================================== -// Read the Extension Controller state -// ...and decode it in to something sane -// -// Returns: {0:OK, >0:Error} -// -int ecRead(wiiEC_t* pec) { - ENTER; - int rv = 0; // assume success - - if(!pec->init) { - WARN("%s : device not initialised", __func__); - rv = 1; - goto bail; - } - - if(!furi_hal_i2c_is_device_ready(i2cBus, i2cAddr, i2cTimeout)) { - INFO("%s : device disconnected", __func__); - pec->init = false; - rv = 2; - goto bail; - } - - if(!furi_hal_i2c_trxd( - i2cBus, i2cAddr, ®Joy, 1, pec->joy, JOY_LEN, i2cTimeout, i2cReadWait)) { - ERROR("%s : trxd fail", __func__); - rv = 3; - goto bail; - } - - if(pec->encrypt) decrypt(pec->joy, pec->encKey, regJoy, JOY_LEN); - - // Decode the readings (according to Controller type) - ecDecode(pec); - -bail: - LEAVE; - return rv; -} - -//+============================================================================ ======================================== -// Initialise an Extension Controller -// -//! To disable encryption, pass a NULL encryption key <-- this is currently ALWAYS the case -// -bool ecInit(wiiEC_t* pec, const uint8_t* encKey) { - ENTER; - - bool rv = false; // assume failure - -#if 0 //! i2c workaround - //! I think this is done during OS startup - long before the plugin starts - furi_hal_i2c_init(); -#endif - -#if 0 //! i2c workaround - // May become relevant when the i2c issues are resolved - // Take control of the i2c bus [which returns void !?] - // --> firmware/targets/f7/furi_hal/furi_hal_i2c.c - furi_hal_i2c_acquire(i2cBus); -#endif - - pec->init = false; // assume failure - - // === See if the device is alive === - if(!furi_hal_i2c_is_device_ready(i2cBus, i2cAddr, i2cTimeout)) { - TRACE("%s : waiting for device", __func__); - goto bail; - } - INFO("%s : device connected", __func__); - - // === Initialise the device === - pec->init = false; // This goes true AFTER the (optional) controller-specific init code - - // === Start the Extension Controller === - if(encKey) { //! start in encrypted mode - - //! todo - should this happen here, or AFTER we've got the ID ? - - } else { - if(!furi_hal_i2c_tx(i2cBus, i2cAddr, cmdInit1, sizeof(cmdInit1), i2cTimeout)) { - ERROR("%s : init fail (dec1)", __func__); - goto bail; - } - TRACE("%s : init OK1", __func__); - - if(!furi_hal_i2c_tx(i2cBus, i2cAddr, cmdInit2, sizeof(cmdInit2), i2cTimeout)) { - ERROR("%s : init fail (dec2)", __func__); - goto bail; - } - TRACE("%s : init OK2", __func__); - } - - // === Retrieve the Extension Controller ID === - if(!furi_hal_i2c_trx(i2cBus, i2cAddr, ®Pid, 1, pec->pid, PID_LEN, i2cTimeout)) { - ERROR("%s : T(R)x fail (pid)", __func__); - goto bail; - } - if(pec->encrypt) decrypt(pec->joy, pec->encKey, regJoy, JOY_LEN); - dump(pec->pid, PID_LEN, "pid"); // debug INFO - - // Find the StringID in the lookup table - for(pec->pidx = PID_FIRST; pec->pidx < PID_ERROR; pec->pidx++) - if(memcmp(pec->pid, ecId[pec->pidx].id, PID_LEN) == 0) break; - if(pec->pidx == PID_ERROR) pec->pidx = PID_UNKNOWN; - pec->sid = ecId[pec->pidx].name; - INFO("sid: %s", pec->sid); - - // === (optionally) Enable encryption === - if(!encKey) { - pec->encrypt = false; - - } else { // Controller WILL encrypt ALL tranmissions - //! this encryption code fails - should it be done earlier? - //! as it is probably never of any use, I'm kinda loathed to spend time on it - //! https://github.com/madhephaestus/WiiChuck/blob/master/src/Accessory.cpp#L138 - uint8_t encTx[1 + ENC_LEN] = {0}; - uint8_t* ep = encTx; - - pec->encrypt = true; - - // ** Start the Controller in ENcrytped mode - if(!furi_hal_i2c_tx(i2cBus, i2cAddr, cmdInitEnc, sizeof(cmdInitEnc), i2cTimeout)) { - ERROR("%s : init fail (enc)", __func__); - goto bail; - } - - // Copy the (symmetric) encryption key to the controller state table - if(pec->encKey != encKey) memcpy(pec->encKey, encKey, ENC_LEN); - - // Build the encryption key packet - *ep++ = regEnc; - memcpy(ep, pec->encKey, ENC_LEN); - - // ** Send encryption key (PSK) - if(!furi_hal_i2c_tx(i2cBus, i2cAddr, encTx, (1 + ENC_LEN), i2cTimeout)) { - ERROR("%s : key fail", __func__); - goto bail; - } - - TRACE("%s : init OK (enc)", __func__); - } - - // === Some devices [eg. Drawsome/uDraw] require additional init code === - if(ecId[pec->init].init && (ecId[pec->init].init(pec) == false)) goto bail; - pec->init = true; - - // === Read calibration data === - if(!furi_hal_i2c_trx(i2cBus, i2cAddr, ®Cal, 1, pec->calF, CAL_LEN, i2cTimeout)) { - ERROR("%s : trx fail (cal)", __func__); - goto bail; - } - if(pec->encrypt) decrypt(pec->joy, pec->encKey, regJoy, JOY_LEN); - dump(pec->calF, CAL_LEN, "cal"); - - ecCalibrate(pec, CAL_RESET | CAL_FACTORY); // Load factory default calibration - - // === Initialise decode buffers === - pec->decN = 0; // read in to decode[1] (yes, N=0 -> read in to dec[1]) - switch(ecRead(pec)) { - case 0: // read OK - memcpy(&pec->dec[0], &pec->dec[1], sizeof(pec->dec[0])); - dump(pec->joy, JOY_LEN, "joy"); - break; - - default: // bug: unknown - case 1: // bug: not initialised - should never happen - ERROR("%s : read bug", __func__); - break; - - case 2: // device gone - case 3: // read fail - // Logging done by ecRead() - pec->init = false; - goto bail; - } - - rv = true; // yay :) - -bail: -#if 0 //! i2c workaround - furi_hal_i2c_release(i2cBus); -#endif - - LEAVE; - return rv; -} diff --git a/applications/plugins/wii_ec_anal/wii_i2c.h b/applications/plugins/wii_ec_anal/wii_i2c.h deleted file mode 100644 index efebefcf9..000000000 --- a/applications/plugins/wii_ec_anal/wii_i2c.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef WII_I2C_H_ -#define WII_I2C_H_ - -#include - -//#include "wii_ec.h" - -//----------------------------------------------------------------------------- ---------------------------------------- -// i2c bus details -// -// https://www.best-microcontroller-projects.com/i2c-tutorial.html -// https://web.archive.org/web/20220000000000*/https://www.best-microcontroller-projects.com/i2c-tutorial.html -// https://training.ti.com/introduction-i2c-reserved-addresses -// -// After the (special) START "bit"... -// the first 8bits (byte) of i2c data are the 7bit i2c Address, -// FOLLOWED by 1bit to signify a READ or WRITE {0=write, 1=read} -// The data is transmitted BIG-Endian, IE. MSb first [human readable] -// So the address actually lives in the TOP (MSb's) of the first "byte", (with bit0 being used as the read/write flag) -// -// The read() and write() functions on the FZ will set the LSb appropriately, -// BUT they do NOT shift the address left to make room for it! -// So the address you give to read/write() MUST be given as (7bitAddress << 1) -// -// When we read: After we send the read command, we wait for i2cReadWait uS before reading the data -// - -// firmware/targets/f7/furi_hal/furi_hal_i2c_types.h -#define i2cBus (&furi_hal_i2c_handle_external) // FZ external i2c bus -#define i2cAddr (ec_i2cAddr << 1) -#define i2cTimeout (3) // in mS -#define i2cReadWait (300) //! 300uS: how low can we take this? - -//----------------------------------------------------------------------------- ---------------------------------------- -// public functions -// -typedef struct wiiEC wiiEC_t; - -bool ecInit(wiiEC_t* const pec, const uint8_t* encKey); -int ecRead(wiiEC_t* const pec); - -#endif //WII_I2C_H_ diff --git a/applications/plugins/yatzee/LICENSE b/applications/plugins/yatzee/LICENSE deleted file mode 100644 index f288702d2..000000000 --- a/applications/plugins/yatzee/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) 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; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/applications/plugins/yatzee/README.md b/applications/plugins/yatzee/README.md deleted file mode 100644 index 7483879e2..000000000 --- a/applications/plugins/yatzee/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# flipperzero-yatzee -Yahtzee game for flipperzero - -Code is bad, I should feel bad, but it works and now I can play Yahtzee on my flipper while I shit at work. - -Installation: - -Download fap from releases. Copy fap to flipper sd at ext > apps > Games - - -Controls: - -- Up to Roll -- Left/Right to move cursor -- OK to Hold a die -- Moving cursor past the dice will move the cursor up to the scorecard. Moving the scores cursor will show you the potential score you would get. - - -Rules & Scoring: - -- Between rolls, move the cursor and use the OK button to select which dice you will hold for the next roll -- 3 rolls per round and then you are forced to select a score. -- To score, move cursor with Left/Right up to the scorecard, when desired score to count is underlined, press the Down button to confirm. - -- 1-6 add up the corresponding dice of that number in your roll. -- 3 of a Kind (3k) = total of dice when 3 of a kind is rolled -- 4 of a Kind (4k) = total of dice when 4 of a kind is rolled -- Full House (Fh) = 25 -- Small Straight (Sm) = 30 -- Large Straight (Lg) = 40 -- Chance (Ch) = total of all dice in roll -- Yatzee (Yz) = 50 for the first yatzee. Successive Yatzees do not show in the score card, but add 100 each to the total score -- Game ends when every scoring value has been selected once. -- If sub score is at least 63, 35 points are added to the total score. - -Todo -- Redo the scorecard now that I understand a little better how this works - - Would like to make it a grid with 4 rows, and 4 columns - - Rows 0 and 2 will have the scores 'names' - - Rows 1 and 3 will be empty until filled by a score. - - Column 3 will span all rows and show each bonus yatzee as an icon like a star or something. - - Once grided score card is implemented, identify a better mechanism to show that a score has already been counted- instead of the '.' that shows up now. - - Maybe invert the grid color to show which score is being selected by the cursor. -- If upper score >= 63, add a pop-up message at the end game to give a visual indication that a bonus for the top row is being. -- Redo button mapping so that - - the middle button can be used to both hold on dice or confirm score. Leaves the down arrow open for something else. - - Would be nice if up/down could be used to move through the scorecard and left/right move through the dice, but then theres not enough buttons for ROLL so idk yet. -- Learn more about C so that I can move stuff to a header file like everyone else does. diff --git a/applications/plugins/yatzee/application.fam b/applications/plugins/yatzee/application.fam deleted file mode 100644 index 183021854..000000000 --- a/applications/plugins/yatzee/application.fam +++ /dev/null @@ -1,13 +0,0 @@ -App( - appid="Yatzee", - name="Yatzee", - apptype=FlipperAppType.EXTERNAL, - entry_point="yatzee_main", - requires=["gui"], - stack_size=4 * 1024, - order=99, - fap_icon="images/yatzee_icon_10px.png", - fap_category="Games", - fap_icon_assets="images", - -) diff --git a/applications/plugins/yatzee/images/die_1.png b/applications/plugins/yatzee/images/die_1.png deleted file mode 100644 index 84f86cbb4..000000000 Binary files a/applications/plugins/yatzee/images/die_1.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/die_2.png b/applications/plugins/yatzee/images/die_2.png deleted file mode 100644 index bfdc37c36..000000000 Binary files a/applications/plugins/yatzee/images/die_2.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/die_3.png b/applications/plugins/yatzee/images/die_3.png deleted file mode 100644 index 4c0db3f26..000000000 Binary files a/applications/plugins/yatzee/images/die_3.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/die_4.png b/applications/plugins/yatzee/images/die_4.png deleted file mode 100644 index 682f26d3a..000000000 Binary files a/applications/plugins/yatzee/images/die_4.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/die_5.png b/applications/plugins/yatzee/images/die_5.png deleted file mode 100644 index c251d3a78..000000000 Binary files a/applications/plugins/yatzee/images/die_5.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/die_6.png b/applications/plugins/yatzee/images/die_6.png deleted file mode 100644 index 77e300d88..000000000 Binary files a/applications/plugins/yatzee/images/die_6.png and /dev/null differ diff --git a/applications/plugins/yatzee/images/yatzee_icon_10px.png b/applications/plugins/yatzee/images/yatzee_icon_10px.png deleted file mode 100644 index 38dfd172f..000000000 Binary files a/applications/plugins/yatzee/images/yatzee_icon_10px.png and /dev/null differ diff --git a/applications/plugins/yatzee/yatzee.c b/applications/plugins/yatzee/yatzee.c deleted file mode 100644 index 304a604c1..000000000 --- a/applications/plugins/yatzee/yatzee.c +++ /dev/null @@ -1,827 +0,0 @@ -#include "Yatzee_icons.h" - -#include -#include - -#include -#include -#include - -#include -#include - -#define BASE_X 18 -#define BASE_Y 44 -#define DICE_OFFSET 12 -#define HOLD "*" -#define MAX_DICE 5 -#define NUM_SCORES 13 - -bool new_game = true; -bool game_over = false; -bool bonus_added = false; -int8_t num_bonus_yatzees = 0; - -// struct to hold image posistion for dice -typedef struct { - // +-----x - // | - // | - // y - uint8_t x; - uint8_t y; -} ImagePosition; - -typedef struct { - char* name; - uint32_t value; - bool used; - int8_t row; - int8_t col; - uint8_t (*fn)(); // pointer to function that calculates score -} Score; - -typedef struct { - uint8_t index; - uint8_t value; - bool isHeld; -} Die; - -typedef struct { - int index; - char* symbol; -} Cursor; - -// locations for the dice images -ImagePosition position[5] = { - {.x = BASE_X - DICE_OFFSET, .y = BASE_Y}, - {.x = BASE_X * 2 - DICE_OFFSET, .y = BASE_Y}, - {.x = BASE_X * 3 - DICE_OFFSET, .y = BASE_Y}, - {.x = BASE_X * 4 - DICE_OFFSET, .y = BASE_Y}, - {.x = BASE_X * 5 - DICE_OFFSET, .y = BASE_Y}, -}; - -// these are the positions that the score cursor will cycle through -ImagePosition score_positions[13] = { - {.x = 15, .y = 0}, - {.x = 15, .y = 9}, - {.x = 15, .y = 18}, - {.x = 15, .y = 27}, - {.x = 44, .y = 0}, - {.x = 44, .y = 9}, - {.x = 44, .y = 18}, - {.x = 44, .y = 27}, - {.x = 77, .y = 0}, - {.x = 77, .y = 9}, - {.x = 77, .y = 18}, - {.x = 77, .y = 27}, - {.x = 91, .y = 21}, -}; - -// cursor to select dice -Cursor cursor = {.index = 0, .symbol = "^"}; - -// cursor to select score -Cursor scoreCursor = {.index = -1, .symbol = "_"}; - -// setup array to store dice info -Die die[5] = { - {.index = 0, .value = 1, .isHeld = false}, - {.index = 1, .value = 1, .isHeld = false}, - {.index = 2, .value = 1, .isHeld = false}, - {.index = 3, .value = 1, .isHeld = false}, - {.index = 4, .value = 1, .isHeld = false}, -}; - -uint8_t upperScore = 0; -int32_t lowerScore = 0; -int32_t totalScore = 0; -uint8_t roll = 0; -uint8_t totalrolls = 0; - -// ############################################# -// # The following methods add the score for # -// # whichever number is mentioned. # -// ############################################# -static uint8_t ones() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 1) { - sum++; - } - } - return sum; -} - -static uint8_t twos() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 2) { - sum = sum + 2; - } - } - return sum; -} - -static uint8_t threes() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 3) { - sum = sum + 3; - } - } - return sum; -} - -static uint8_t fours() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 4) { - sum = sum + 4; - } - } - return sum; -} - -static uint8_t fives() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 5) { - sum = sum + 5; - } - } - return sum; -} - -static uint8_t sixes() { - uint8_t sum = 0; - for(uint8_t i = 0; i < 5; i++) { - if(die[i].value == 6) { - sum = sum + 6; - } - } - return sum; -} - -// #################################################### -// # Helper methods for the special score types # -// # defined before them so they can be used # -// # since this whole thing is a linear mess # -// # lol. # -// # add_dice: # -// # inputs: none # -// # output: int8_t value of roll # -// # check_if_score_used: -// # inputs: Score -// # output: true if score.used = true -// # # # # # # # # # # # # # # # # # # # # # # # # # # -int8_t add_dice() { - int8_t sum = 0; - for(int8_t i = 0; i < MAX_DICE; i++) { - sum += die[i].value; - } - return sum; -} - -bool check_if_score_used(Score score) { - if(score.used == true) { - return true; - } else { - return false; - } -} - -// ############################################# -// # Methods to calculate scores for the fancy # -// # scoring types: 3 of a kind, 4 of a kind, # -// # Full house, small straight, large straight# -// # chance & yatzee. # -// ############################################# -static uint8_t threekind() { - int8_t score = 0; - for(int8_t num = 1; num < 7; num++) { - int8_t sum = 0; - - for(int8_t i = 0; i < MAX_DICE; i++) { - if(die[i].value == num) { - sum++; - } - if(sum > 2) { - score = add_dice(); - } - } - } - return score; -} - -static uint8_t fourkind() { - int8_t score = 0; - for(int8_t num = 1; num < 7; num++) { - int8_t sum = 0; - - for(int8_t i = 0; i < MAX_DICE; i++) { - if(die[i].value == num) { - sum++; - } - if(sum > 3) { - score = add_dice(); - } - } - } - return score; -} - -static uint8_t fullhouse() { - bool check1 = false; - bool check2 = false; - int8_t val1 = 0; - int8_t val2 = 0; - UNUSED(val2); - UNUSED(val1); - - //check 1 for three of a kind - for(int8_t num = 1; num < 7; num++) { - int8_t sum = 0; - - for(int8_t i = 0; i < MAX_DICE; i++) { - if(die[i].value == num) { - sum++; - } - if(sum > 2) { - val1 = die[i].value; - check1 = true; - } - } - } - - // return if check 1 failed - if(check1 == false) { - return 0; - } - - // check 2 for two of a kind. - for(int8_t num = 1; num < 7; num++) { - if(num == val1) { - continue; - } - int8_t sum = 0; - - for(int8_t i = 0; i < MAX_DICE; i++) { - if(die[i].value == num) { - sum++; - } - if(sum > 1) { - val2 = die[i].value; - check2 = true; - } - } - if(check1 && check2) { - return 25; - } - } - return 0; -} - -// # # # # # # # # # # # # # # # # # # # # # # # # # # # -// # I'm dumb so I asked ChatGPT to write the # -// # smallstraight function for me. Then I adapted it # -// # fo the largestraight function. # -// # # # # # # # # # # # # # # # # # # # # # # # # # # # -static uint8_t smallstraight() { - // Create a new array with the frequencies of the different die faces - int8_t frequencies[6] = {0}; - - for(int8_t i = 0; i < 5; i++) { - int8_t face = die[i].value; - frequencies[face - 1]++; - } - - // Check if there is a sequence of 4 consecutive die faces with at least one die - bool found_small_straight = false; - for(int i = 0; i < 3 && !found_small_straight; i++) { - if(frequencies[i] > 0 && frequencies[i + 1] > 0 && frequencies[i + 2] > 0 && - frequencies[i + 3] > 0) { - found_small_straight = true; - } - } - - if(found_small_straight) { - return 30; - } else { - return 0; - } -} - -static uint8_t largestraight() { - // Create a new array with the frequencies of the different die faces - int8_t frequencies[6] = {0}; - - for(int8_t i = 0; i < 5; i++) { - int8_t face = die[i].value; - frequencies[face - 1]++; - } - - // Check if there is a sequence of 4 consecutive die faces with at least one die - bool found_large_straight = false; - for(int i = 0; i < 3 && !found_large_straight; i++) { - if(frequencies[i] > 0 && frequencies[i + 1] > 0 && frequencies[i + 2] > 0 && - frequencies[i + 3] > 0 && frequencies[i + 4] > 0) { - found_large_straight = true; - } - } - - if(found_large_straight) { - return 40; - } else { - return 0; - } -} - -static uint8_t chance() { - // chance allows your roll to count for the raw number of pips showing - int8_t sum = 0; - for(int8_t i = 0; i < MAX_DICE; i++) { - sum += die[i].value; - } - return sum; -} - -static uint8_t yatzee() { - // checks if all die.values are equal to the first die - int8_t val = die[0].value; - for(int8_t i = 1; i < MAX_DICE; i++) { - // if value is the same as the first die, continue to next - if(die[i].value == val) { - continue; - } else { - // if any value is not equal to the first die, - // this is not a yatzee and we return 0 - return 0; - } - } - return 50; -} - -// # # # # # # # # # # # # # # # # # # # # # # # # # # -// # Method to return true if yatzee returns 50 # -// # # -// # # # # # # # # # # # # # # # # # # # # # # # # # # -// static bool check_for_bonus_yatzee() { -// if (yatzee()==50){ -// return true; -// } else { -// return false; -// } -// } - -// Scorecard defined here so that we can use pointers to the functions -// defined above -Score scorecard[13] = { - {.name = "1", .value = 0, .used = false, .row = 0, .col = 0, .fn = &ones}, - {.name = "2", .value = 0, .used = false, .row = 1, .col = 0, .fn = &twos}, - {.name = "3", .value = 0, .used = false, .row = 2, .col = 0, .fn = &threes}, - {.name = "4", .value = 0, .used = false, .row = 3, .col = 0, .fn = &fours}, - {.name = "5", .value = 0, .used = false, .row = 0, .col = 1, .fn = &fives}, - {.name = "6", .value = 0, .used = false, .row = 1, .col = 1, .fn = &sixes}, - {.name = "3k", .value = 0, .used = false, .row = 2, .col = 1, .fn = &threekind}, - {.name = "4k", .value = 0, .used = false, .row = 3, .col = 1, .fn = &fourkind}, - {.name = "Fh", .value = 0, .used = false, .row = 0, .col = 2, .fn = &fullhouse}, - {.name = "Sm", .value = 0, .used = false, .row = 1, .col = 2, .fn = &smallstraight}, - {.name = "Lg", .value = 0, .used = false, .row = 2, .col = 2, .fn = &largestraight}, - {.name = "Ch", .value = 0, .used = false, .row = 3, .col = 2, .fn = &chance}, - {.name = "Yz", .value = 0, .used = false, .row = 2, .col = 3, .fn = &yatzee}, -}; - -// ############################################# -// # begin draw callback # -// # # -// ############################################# -// define the callback for telling ViewPort how to update the screen -// not sure what ctx is but it seems important -static void app_draw_callback(Canvas* canvas, void* ctx) { - UNUSED(ctx); - canvas_set_font(canvas, FontSecondary); //define a font so we can put letters on the screen - int8_t selectorOffsetX = 8; - int8_t selectorOffsetY = 16; - char buffer[36]; - char bigbuffer[256]; - - canvas_clear(canvas); - - // if new_game, show user instructions - if(new_game) { - canvas_set_font(canvas, FontPrimary); - elements_multiline_text_aligned(canvas, 64, 0, AlignCenter, AlignTop, "Yatzee!"); - canvas_set_font(canvas, FontSecondary); - snprintf( - bigbuffer, - sizeof(bigbuffer), - "Up: Roll\nLeft/Right: Move cursor\nOK: Hold Die\nDown: Score"); - elements_multiline_text_aligned(canvas, 0, 8, AlignLeft, AlignTop, bigbuffer); - elements_button_center(canvas, "Start!"); - return; - - } else { - // draw border lines - canvas_draw_line(canvas, 0, 37, 104, 37); - canvas_draw_line(canvas, 104, 0, 104, 64); - - // iterate through dice and draw icon that correlates to die[n].value, and the x,y position indicated by position[die[i].index] - for(int8_t i = 0; i < 5; i++) { - if(die[i].value == 1) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_1); - } else if(die[i].value == 2) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_2); - } else if(die[i].value == 3) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_3); - } else if(die[i].value == 4) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_4); - } else if(die[i].value == 5) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_5); - } else if(die[i].value == 6) { - canvas_draw_icon( - canvas, - position[die[i].index].x % 128, - position[die[i].index].y % 64, - &I_die_6); - } - } - - // Puts an '*' above the die if hold is selected. - int8_t holdOffsetX = 8; - int8_t holdOffsetY = -5; - for(int8_t i = 0; i < 5; i++) { - if(die[i].isHeld == 1) { - elements_multiline_text_aligned( - canvas, - position[die[i].index].x + holdOffsetX, - position[die[i].index].y + holdOffsetY, - AlignCenter, - AlignTop, - HOLD); - } - } - - // Update die cursor location - if(cursor.index != -1) { - elements_multiline_text_aligned( - canvas, - position[cursor.index].x + selectorOffsetX, - position[cursor.index].y + selectorOffsetY, - AlignCenter, - AlignTop, - cursor.symbol); - } - - // Update score cursor location - if(scoreCursor.index != -1) { - elements_multiline_text_aligned( - canvas, - score_positions[scoreCursor.index].x, - score_positions[scoreCursor.index].y + 1, - AlignLeft, - AlignTop, - scoreCursor.symbol); - } - - // Update Roll - - // Scores are updated in groups on screen to help with formatting - // first group is scorecard[0:7], second group is [8:12] - // Cycle through first 8 scores, if cursor at score, update to show possible score - // otherwise, show current scores value. - for(int8_t i = 0; i < 8; i++) { - if(scoreCursor.index == i && scorecard[i].used == false) { - int possiblescore = (int)(*scorecard[i].fn)(); - - snprintf(buffer, sizeof(buffer), "%s: %3u ", scorecard[i].name, possiblescore); - canvas_draw_str_aligned( - canvas, - 23 + 29 * scorecard[i].col, - 9 * scorecard[i].row, - AlignRight, - AlignTop, - buffer); - } else { - uint8_t currentscore = scorecard[i].value; - snprintf(buffer, sizeof(buffer), "%s: %3u ", scorecard[i].name, currentscore); - canvas_draw_str_aligned( - canvas, - 23 + 29 * scorecard[i].col, - 9 * scorecard[i].row, - AlignRight, - AlignTop, - buffer); - } - if(scorecard[i].used) { - canvas_draw_dot(canvas, 23 + 29 * scorecard[i].col, 3 + 9 * scorecard[i].row); - } - } - - // cycle through lower scores - // NUM_SCORES minus one because the yatzee is 12 and is handled separately - for(int8_t i = 8; i < NUM_SCORES - 1; i++) { - if(scoreCursor.index == i && scorecard[i].used == false) { - int possiblescore = (int)(*scorecard[i].fn)(); - - snprintf(buffer, sizeof(buffer), " %s: %3u ", scorecard[i].name, possiblescore); - canvas_draw_str_aligned( - canvas, - 31 + 27 * scorecard[i].col, - 9 * scorecard[i].row, - AlignRight, - AlignTop, - buffer); - } else { - uint8_t currentscore = scorecard[i].value; - snprintf(buffer, sizeof(buffer), " %s: %3u ", scorecard[i].name, currentscore); - canvas_draw_str_aligned( - canvas, - 31 + 27 * scorecard[i].col, - 9 * scorecard[i].row, - AlignRight, - AlignTop, - buffer); - } - if(scorecard[i].used) { - canvas_draw_dot(canvas, 31 + 27 * scorecard[i].col, 3 + 9 * scorecard[i].row); - } - } - - // update yatzee score - if(scoreCursor.index == 12 && scorecard[12].used == false) { - int possiblescore = (int)(*scorecard[12].fn)(); - - snprintf(buffer, sizeof(buffer), "Yz\n%u", possiblescore); - elements_multiline_text_aligned(canvas, 93, 10, AlignCenter, AlignTop, buffer); - } else { - snprintf(buffer, sizeof(buffer), "Yz\n%ld", scorecard[12].value); - elements_multiline_text_aligned(canvas, 93, 10, AlignCenter, AlignTop, buffer); - } - - // Scores and roll number updated - - // sub score shows the 1-6 scores only. If this is >63 at the end of the game, - // a 35 point bonus is added to the total score - snprintf(buffer, sizeof(buffer), "Sub\n%u", upperScore); - elements_multiline_text_aligned(canvas, 117, 0, AlignCenter, AlignTop, buffer); - - snprintf(buffer, sizeof(buffer), "Total\n%ld", totalScore); - elements_multiline_text_aligned(canvas, 117, 22, AlignCenter, AlignTop, buffer); - - if(totalrolls == 0) { - snprintf(buffer, sizeof(buffer), "Roll\n%s", " "); - elements_multiline_text_aligned(canvas, 117, 64, AlignCenter, AlignBottom, buffer); - } else { - snprintf(buffer, sizeof(buffer), "Roll\n%u", totalrolls); - elements_multiline_text_aligned(canvas, 117, 64, AlignCenter, AlignBottom, buffer); - } - - // Check for then handle end of game - - // add num_bonus_yatzees to total rounds so that multiple - // yatzees can be scored without impacting the number of rounds before - // the game is over - int8_t total_rounds = num_bonus_yatzees; - // add up number of scores counted so far - for(int8_t i = 0; i < NUM_SCORES; i++) { - if(scorecard[i].used) { - total_rounds++; - } - } - - // if total rounds is 13 + the number of bonus rounds, - // thats it, game over. - if(total_rounds == NUM_SCORES + num_bonus_yatzees) { - // if scores of 1-6 add up to 63, a 35 point bonus is bonus_added - // bonus_added = true keeps the game loop from - // adding bonuses indefinetly - if(upperScore >= 63 && bonus_added == false) { - totalScore += 35; - bonus_added = true; - } - // set game over to true and tell the user the game is over - game_over = true; - elements_button_center(canvas, "Game Over"); - } - } -} - -// define the callback for helping ViewPort get InputEvent and place it in the event_queue defined in the main method -static void app_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); - - FuriMessageQueue* event_queue = ctx; - furi_message_queue_put(event_queue, input_event, FuriWaitForever); -} - -// roll them diiiiceeee -static void roll_dice() { - // increment roll count - totalrolls++; - for(uint8_t i = 0; i < MAX_DICE; i++) { - // dont reroll if the dice is being held - if(die[i].isHeld == false) { - die[i].value = 1 + rand() % 6; - } - } - // if 3 rolls have been used, force user to select a score. - if(totalrolls == 3) { - scoreCursor.index = 0; - } -} - -static void clear_board() { - // reset board after adding score - totalrolls = 0; - for(int8_t i = 0; i < MAX_DICE; i++) { - die[i].isHeld = false; - } - scoreCursor.index = -1; - cursor.index = 0; -} - -static void add_score() { - // return when scoring is not possible - if(cursor.index != -1 || totalrolls == 0 || - (scorecard[scoreCursor.index].used && - strcmp(scorecard[scoreCursor.index].name, "Yz") != 0)) { - return; - } - - // extra yatzee scores - if(scoreCursor.index == 12 && scorecard[scoreCursor.index].used) { - uint8_t yatzee_score = (*scorecard[12].fn)(); - scorecard[12].value += 2 * yatzee_score; - lowerScore += 100; - num_bonus_yatzees++; - } - - // upper score - for(int8_t i = 0; i < 6; i++) { - if(scoreCursor.index == i && scorecard[scoreCursor.index].used == false) { - scorecard[i].value = (*scorecard[i].fn)(); - upperScore += scorecard[i].value; - scorecard[i].used = true; - } - } - - // lower score - for(int8_t i = 6; i < 13; i++) { - if(scoreCursor.index == i && scorecard[scoreCursor.index].used == false) { - scorecard[i].value = (*scorecard[i].fn)(); - lowerScore += scorecard[i].value; - scorecard[i].used = true; - } - } - - // recalculate total score - totalScore = lowerScore + upperScore; - clear_board(); -} - -// Entry Point -int32_t yatzee_main(void* p) { - UNUSED(p); - - // Initialize event queue to handle incoming events like button presses - // Use FuriMessageQueue as type as defined in furi api - // InputEvents are supported by app_input_callback - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); - - // Initialize viewport - ViewPort* view_port = view_port_alloc(); - - // Set system callbacks - view_port_draw_callback_set(view_port, app_draw_callback, view_port); - view_port_input_callback_set(view_port, app_input_callback, event_queue); - - // Open GUI & register viewport - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - // hold input event - InputEvent event; - - // Create a loop for the app to run in and handle InputEvents - bool isRunning = true; - - while(isRunning) { - if(totalrolls == 3) { - cursor.index = -1; - } - if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) { - if((event.type == InputTypePress) || event.type == InputTypeRepeat) { - switch(event.key) { - case InputKeyLeft: - if(cursor.index == -1) { - if(scoreCursor.index == 0 && totalrolls == 3) { - scoreCursor.index = NUM_SCORES - 1; - } else if(scoreCursor.index == 0) { - scoreCursor.index = -1; - cursor.index = 4; - } else { - scoreCursor.index--; - } - } else { - if(cursor.index == 0) { - cursor.index = -1; - scoreCursor.index = NUM_SCORES - 1; - } else { - cursor.index--; - } - } - break; - case InputKeyRight: - // cursor.index == -1 means that scoreCursor is active - if(cursor.index == -1) { - if(scoreCursor.index == NUM_SCORES - 1 && totalrolls == 3) { - scoreCursor.index = 0; - } else if(scoreCursor.index == NUM_SCORES - 1) { - scoreCursor.index = -1; - cursor.index = 0; - } else { - scoreCursor.index++; - } - // if cursor.index is not -1, then dice cursor is active - } else { - if(cursor.index == 4) { - cursor.index = -1; - scoreCursor.index = 0; - } else { - cursor.index++; - } - } - break; - case InputKeyUp: - - if(totalrolls < 3) { - roll_dice(); - } - // if (check_for_bonus_yatzee() && scorecard[13].used) { - // num_bonus_yatzees++; - // totalScore+=100; - // - // clear_board(); - // } - break; - case InputKeyDown: - add_score(); - break; - case InputKeyOk: - if(new_game) { - new_game = false; - break; - } - if(game_over) { - isRunning = false; - } - if(cursor.index == -1 || totalrolls == 0) { - break; - } - if(die[cursor.index].isHeld == false) { - die[cursor.index].isHeld = true; - } else { - die[cursor.index].isHeld = false; - } - break; - default: - isRunning = false; - break; - } - } - } - // after every event, update view_port - // uses app_draw_callback which is set before the game loop begins. - view_port_update(view_port); - } - - // cleanup - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - furi_message_queue_free(event_queue); - furi_record_close(RECORD_GUI); - - return 0; -} \ No newline at end of file diff --git a/applications/plugins/zombiez/application.fam b/applications/plugins/zombiez/application.fam deleted file mode 100644 index 3245187d2..000000000 --- a/applications/plugins/zombiez/application.fam +++ /dev/null @@ -1,12 +0,0 @@ -App( - appid="Zombiez", - name="Zombiez", - apptype=FlipperAppType.EXTERNAL, - entry_point="zombiez_game_app", - cdefines=["APP_ZOMBIEZ_GAME"], - requires=["gui"], - stack_size=2 * 1024, - order=280, - fap_icon="zombie_10px.png", - fap_category="Games", -) diff --git a/applications/plugins/zombiez/zombie_10px.png b/applications/plugins/zombiez/zombie_10px.png deleted file mode 100644 index 37363ec04..000000000 Binary files a/applications/plugins/zombiez/zombie_10px.png and /dev/null differ diff --git a/applications/plugins/zombiez/zombiez.c b/applications/plugins/zombiez/zombiez.c deleted file mode 100644 index bd2a5c97d..000000000 --- a/applications/plugins/zombiez/zombiez.c +++ /dev/null @@ -1,400 +0,0 @@ -#include -#include -#include -#include - -//ORIGINAL REPO: https://github.com/Dooskington/flipperzero-zombiez -//AUTHORS: https://github.com/Dooskington | https://github.com/DevMilanIan - -#include "zombiez.h" - -#define ZOMBIES_MAX 3 -#define ZOMBIES_WIDTH 5 -#define ZOMBIES_HEIGHT 8 -#define PROJECTILES_MAX 10 - -#define MIN_Y 5 -#define MAX_Y 58 -#define WALL_X 16 -#define PLAYER_START_X 8 -#define PLAYER_START_Y (MAX_Y - MIN_Y) / 2 - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - EventType type; - InputEvent input; -} PluginEvent; - -typedef enum { GameStatePlaying, GameStateGameOver } GameState; - -typedef struct { - int x; - int y; -} Point; - -typedef struct { - Point position; - int hp; -} Player; - -typedef struct { - Point position; - int hp; -} Zombie; - -typedef struct { - Point position; -} Projectile; - -typedef struct { - GameState game_state; - Player player; - - size_t zombies_count; - Zombie* zombies[ZOMBIES_MAX]; - - size_t projectiles_count; - Projectile* projectiles[PROJECTILES_MAX]; - - uint16_t score; - bool input_shoot; -} PluginState; - -static void render_callback(Canvas* const canvas, void* ctx) { - const PluginState* plugin_state = acquire_mutex((ValueMutex*)ctx, 25); - if(plugin_state == NULL) { - return; - } - - canvas_draw_frame(canvas, 0, 0, 128, 64); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned( - canvas, - plugin_state->player.position.x, - plugin_state->player.position.y, - AlignCenter, - AlignCenter, - "@"); - - canvas_draw_line(canvas, WALL_X, 0, WALL_X, 64); - canvas_draw_line(canvas, WALL_X + 2, 4, WALL_X + 2, 59); - - for(int i = 0; i < PROJECTILES_MAX; ++i) { - Projectile* p = plugin_state->projectiles[i]; - if(p != NULL) { - canvas_draw_disc(canvas, p->position.x, p->position.y, 3); - } - } - - for(int i = 0; i < ZOMBIES_MAX; ++i) { - Zombie* z = plugin_state->zombies[i]; - if(z != NULL) { - for(int h = 0; h < ZOMBIES_HEIGHT; h++) { - for(int w = 0; w < ZOMBIES_WIDTH; w++) { - // Switch animation - int zIdx = 0; - if(z->position.x % 2 == 0) { - zIdx = 1; - } - - // Draw zombie pixels - if(zombie_array[zIdx][h][w] == 1) { - int x = z->position.x + w; - int y = z->position.y + h; - - canvas_draw_dot(canvas, x, y); - } - } - } - } - } - - int heart; - if((plugin_state->player.hp - 10) > 5) { // 16, 17, 18, 19, 20 - heart = 0; - } else if((plugin_state->player.hp - 5) > 5) { // 11, 12, 13, 14, 15 - heart = 1; - } else if((plugin_state->player.hp - 3) > 2) { // 6, 7, 8, 9, 10 - heart = 2; - } else if(plugin_state->player.hp > 0) { // 1, 2, 3, 4, 5 - heart = 3; - } else { // 0 - heart = 4; - } - // visual representation of health - for(int h = 0; h < 5; h++) { - for(int w = 0; w < 5; w++) { - if(heart_array[heart][h][w] == 1) { - int x = 124 - w; - int y = 56 + h; - - canvas_draw_dot(canvas, x, y); - } - } - } - - // buffer hp + score - char hpBuffer[8]; - char scoreBuffer[14]; - - if(plugin_state->game_state == GameStatePlaying) { - // display ammo / reload - if(plugin_state->projectiles_count >= PROJECTILES_MAX) { - canvas_draw_str_aligned(canvas, 24, 10, AlignLeft, AlignCenter, "RELOAD"); - } else { - for(uint8_t i = 0; i < (PROJECTILES_MAX - plugin_state->projectiles_count); i++) { - canvas_draw_box(canvas, 24 + (4 * i), 6, 2, 4); - } - } - // display hp + score - snprintf(hpBuffer, sizeof(hpBuffer), "%u", plugin_state->player.hp); - canvas_draw_str_aligned(canvas, 118, 62, AlignRight, AlignBottom, hpBuffer); - - snprintf(scoreBuffer, sizeof(scoreBuffer), "%u", plugin_state->score); - canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, scoreBuffer); - } - // Game Over banner - if(plugin_state->game_state == GameStateGameOver) { - // Screen is 128x64 px - canvas_set_color(canvas, ColorWhite); - canvas_draw_box(canvas, 34, 20, 62, 24); - - canvas_set_color(canvas, ColorBlack); - canvas_draw_frame(canvas, 34, 20, 62, 24); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 37, 31, "Game Over"); - - canvas_set_font(canvas, FontSecondary); - snprintf(scoreBuffer, sizeof(scoreBuffer), "Score: %u", plugin_state->score); - canvas_draw_str_aligned(canvas, 64, 41, AlignCenter, AlignBottom, scoreBuffer); - } - - //char* info = (char*)malloc(16 * sizeof(char)); - //asprintf(&info, "%d, %d", plugin_state->x, plugin_state->y); - //canvas_draw_str_aligned(canvas, 32, 16, AlignLeft, AlignBottom, info); - //free(info); - - release_mutex((ValueMutex*)ctx, plugin_state); -} - -static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { - furi_assert(event_queue); - PluginEvent event = {.type = EventTypeKey, .input = *input_event}; - furi_message_queue_put(event_queue, &event, FuriWaitForever); -} - -static void tick(PluginState* const plugin_state) { - if(plugin_state->input_shoot && (plugin_state->projectiles_count < PROJECTILES_MAX)) { - Projectile* p = (Projectile*)malloc(sizeof(Projectile)); - p->position.x = plugin_state->player.position.x; - p->position.y = plugin_state->player.position.y; - - size_t idx = plugin_state->projectiles_count; - plugin_state->projectiles[idx] = p; - plugin_state->projectiles_count += 1; - } - - for(int i = 0; i < ZOMBIES_MAX; ++i) { - if(!plugin_state->zombies[i]) { - Zombie* z = (Zombie*)malloc(sizeof(Zombie)); - //z->hp = 20; - z->position.x = 126; - z->position.y = MIN_Y + (rand() % (MAX_Y - MIN_Y)); - - plugin_state->zombies[i] = z; - plugin_state->zombies_count += 1; - } - } - - for(int i = 0; i < PROJECTILES_MAX; ++i) { - Projectile* p = plugin_state->projectiles[i]; - if(p != NULL) { - p->position.x += 2; - - for(int i = 0; i < ZOMBIES_MAX; ++i) { - Zombie* z = plugin_state->zombies[i]; - if(z != NULL) { - if( // projectile close enough to zombie - (((z->position.x - p->position.x) <= 2) && - ((z->position.y - p->position.y) <= 4)) && - (((p->position.x - z->position.x) <= 2) && - ((p->position.y - z->position.y) <= 6))) { - //z->hp -= 5; - //if(z->hp <= 0) { - plugin_state->zombies_count -= 1; - free(z); - plugin_state->zombies[i] = NULL; - plugin_state->score++; - //if(plugin_state->score % 15 == 0) DOLPHIN_DEED(getRandomDeed()); - //} - } else if(z->position.x <= WALL_X && z->position.x > 0) { // zombie got to the wall - plugin_state->zombies_count -= 1; - free(z); - plugin_state->zombies[i] = NULL; - if(plugin_state->player.hp > 0) { - plugin_state->player.hp--; - } else { - plugin_state->game_state = GameStateGameOver; - } - } else { - if(furi_get_tick() % 2 == 0) z->position.x--; - } - } - } - - if(p->position.x >= 128) { - free(p); - plugin_state->projectiles[i] = NULL; - } - } - } - - plugin_state->input_shoot = false; -} - -static void timer_callback(void* ctx) { - furi_assert(ctx); - FuriMessageQueue* event_queue = ctx; - PluginEvent event = {.type = EventTypeTick}; - furi_message_queue_put(event_queue, &event, 0); -} - -static void zombiez_state_init(PluginState* const plugin_state) { - plugin_state->player.position.x = PLAYER_START_X; - plugin_state->player.position.y = PLAYER_START_Y; - plugin_state->player.hp = 20; - - plugin_state->projectiles_count = 0; - plugin_state->zombies_count = 0; - plugin_state->score = 0; - - for(int i = 0; i < PROJECTILES_MAX; i++) { - plugin_state->projectiles[i] = NULL; - } - - for(int i = 0; i < ZOMBIES_MAX; i++) { - plugin_state->zombies[i] = NULL; - } - - plugin_state->game_state = GameStatePlaying; - plugin_state->input_shoot = false; -} - -int32_t zombiez_game_app(void* p) { - UNUSED(p); - uint32_t return_code = 0; - FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent)); - - PluginState* plugin_state = malloc(sizeof(PluginState)); - zombiez_state_init(plugin_state); - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, plugin_state, sizeof(PluginState))) { - FURI_LOG_E("Zombiez", "cannot create mutex\r\n"); - return_code = 255; - goto free_and_exit; - } - - // Set system callbacks - ViewPort* view_port = view_port_alloc(); - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - FuriTimer* timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, event_queue); - furi_timer_start(timer, furi_kernel_get_tick_frequency() / 22); - - // Open GUI and register view_port - Gui* gui = furi_record_open(RECORD_GUI); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - PluginEvent event; - bool isRunning = true; - while(isRunning) { - FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100); - PluginState* plugin_state = (PluginState*)acquire_mutex_block(&state_mutex); - if(event_status == FuriStatusOk) { - if(event.type == EventTypeKey) { - if(event.input.type == InputTypePress) { - switch(event.input.key) { - case InputKeyUp: - if(plugin_state->player.position.y > MIN_Y && - plugin_state->game_state == GameStatePlaying) { - plugin_state->player.position.y--; - } - break; - case InputKeyDown: - if(plugin_state->player.position.y < MAX_Y && - plugin_state->game_state == GameStatePlaying) { - plugin_state->player.position.y++; - } - break; - case InputKeyOk: - if(plugin_state->projectiles_count < PROJECTILES_MAX && - plugin_state->game_state == GameStatePlaying) { - plugin_state->input_shoot = true; - } - break; - case InputKeyBack: - break; - default: - break; - } - } else if( - event.input.type == InputTypeRepeat && - plugin_state->game_state == GameStatePlaying) { - switch(event.input.key) { - case InputKeyUp: - if(plugin_state->player.position.y > (MIN_Y + 1)) { - plugin_state->player.position.y -= 4; - } - break; - case InputKeyDown: - if(plugin_state->player.position.y < (MAX_Y - 1)) { - plugin_state->player.position.y += 4; - } - break; - default: - break; - } - } else if(event.input.type == InputTypeLong) { - if(event.input.key == InputKeyOk) { - if(plugin_state->game_state == GameStateGameOver) { - zombiez_state_init(plugin_state); - } else if(plugin_state->projectiles_count >= PROJECTILES_MAX) { - plugin_state->projectiles_count = 0; - plugin_state->player.hp++; - } - } else if(event.input.key == InputKeyBack) { - isRunning = false; - } - } - } else if(event.type == EventTypeTick) { - tick(plugin_state); - } - } else { - // event timeout - } - - view_port_update(view_port); - release_mutex(&state_mutex, plugin_state); - } - - furi_timer_free(timer); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - furi_record_close(RECORD_GUI); - view_port_free(view_port); - delete_mutex(&state_mutex); - -free_and_exit: - free(plugin_state); - furi_message_queue_free(event_queue); - - return return_code; -} \ No newline at end of file diff --git a/applications/plugins/zombiez/zombiez.h b/applications/plugins/zombiez/zombiez.h deleted file mode 100644 index eea71d707..000000000 --- a/applications/plugins/zombiez/zombiez.h +++ /dev/null @@ -1,62 +0,0 @@ -#include - -uint8_t zombie_array[2][8][5] = { - { - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {1, 1, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 1, 0, 0}, - {0, 0, 1, 0, 0}, - }, - { - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {1, 1, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 1, 1, 1}, - {0, 0, 0, 0, 1}, - {0, 0, 0, 0, 1}, - }, -}; - -uint8_t heart_array[5][5][5] = { - { - {0, 1, 0, 1, 0}, - {1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1}, - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 0}, - }, - { - {0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}, - {1, 1, 1, 1, 1}, - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 0}, - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 1, 1, 1}, - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 0}, - }, - { - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 1, 1, 1, 0}, - {0, 0, 1, 0, 0}, - }, - { - {1, 0, 0, 0, 1}, - {0, 1, 0, 1, 0}, - {0, 0, 1, 0, 0}, - {0, 1, 0, 1, 0}, - {1, 0, 0, 0, 1}, - }, -}; \ No newline at end of file diff --git a/applications/settings/dolphin_passport/passport.c b/applications/settings/dolphin_passport/passport.c index 3eb2ce5ad..96e0ad331 100644 --- a/applications/settings/dolphin_passport/passport.c +++ b/applications/settings/dolphin_passport/passport.c @@ -13,13 +13,7 @@ #define BUTTHURT_MAX 14 static const Icon* const portrait_happy[7] = { - &I_passport_happy1_46x49, - &I_passport_happy2_46x49, - &I_passport_happy3_46x49, - &I_G0ku, - &I_g0ku_1, - &I_g0ku_2, - &I_g0ku_3}; + &I_flipper}; // static const Icon* const portrait_ok[MOODS_TOTAL] = { // &I_passport_okay1_46x49, // &I_passport_okay2_46x49, diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_0.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_0.png deleted file mode 100644 index 229a40c8f..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_1.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_1.png deleted file mode 100644 index a715f970b..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_10.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_10.png deleted file mode 100644 index 0beebf5b1..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_11.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_11.png deleted file mode 100644 index 197e199c7..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_12.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_12.png deleted file mode 100644 index 685121ab8..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_13.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_13.png deleted file mode 100644 index 92e50da56..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_14.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_14.png deleted file mode 100644 index b3d46b0f9..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_15.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_15.png deleted file mode 100644 index 1b7a1ec6a..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_16.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_16.png deleted file mode 100644 index 53037d1eb..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_17.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_17.png deleted file mode 100644 index 15f4d80d3..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_18.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_18.png deleted file mode 100644 index 7a0fade55..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_2.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_2.png deleted file mode 100644 index 1ce573813..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_3.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_3.png deleted file mode 100644 index 51187a21d..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_4.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_4.png deleted file mode 100644 index 507fb5467..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_5.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_5.png deleted file mode 100644 index 286f05d67..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_6.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_6.png deleted file mode 100644 index c00a10a94..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_7.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_7.png deleted file mode 100644 index 2aae7a752..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_8.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_8.png deleted file mode 100644 index b0ef16af0..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_9.png b/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_9.png deleted file mode 100644 index b71982261..000000000 Binary files a/assets/dolphin/external/Kuronons_RMCFW_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/Kuronons_RMCFW_128x64/meta.txt b/assets/dolphin/external/Kuronons_RMCFW_128x64/meta.txt deleted file mode 100644 index 3154d0aef..000000000 --- a/assets/dolphin/external/Kuronons_RMCFW_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 54 -Active frames: 0 -Frames order: 0 0 0 0 1 1 1 2 2 3 4 4 5 6 7 7 8 8 9 10 10 10 11 11 11 11 11 11 12 12 13 13 14 14 15 15 15 15 15 16 16 17 18 18 18 18 18 18 18 18 18 18 18 18 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/L1_Halloween_128x64/frame_0.png b/assets/dolphin/external/L1_Halloween_128x64/frame_0.png deleted file mode 100644 index f69a43f5e..000000000 Binary files a/assets/dolphin/external/L1_Halloween_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Halloween_128x64/frame_1.png b/assets/dolphin/external/L1_Halloween_128x64/frame_1.png deleted file mode 100644 index d2f2bc4b2..000000000 Binary files a/assets/dolphin/external/L1_Halloween_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Halloween_128x64/frame_2.png b/assets/dolphin/external/L1_Halloween_128x64/frame_2.png deleted file mode 100644 index 5d7c9ed8b..000000000 Binary files a/assets/dolphin/external/L1_Halloween_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Halloween_128x64/frame_3.png b/assets/dolphin/external/L1_Halloween_128x64/frame_3.png deleted file mode 100644 index be199f1df..000000000 Binary files a/assets/dolphin/external/L1_Halloween_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Halloween_128x64/meta.txt b/assets/dolphin/external/L1_Halloween_128x64/meta.txt deleted file mode 100644 index 9762d4caa..000000000 --- a/assets/dolphin/external/L1_Halloween_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 4 -Active frames: 0 -Frames order: 0 1 2 3 -Active cycles: 0 -Frame rate: 3 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_0.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_0.png deleted file mode 100644 index 909cc3303..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_1.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_1.png deleted file mode 100644 index fdc1805d1..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_10.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_10.png deleted file mode 100644 index 3a43c6b84..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_11.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_11.png deleted file mode 100644 index 20ea12eb0..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_12.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_12.png deleted file mode 100644 index a05abd80f..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_2.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_2.png deleted file mode 100644 index fc7e0364a..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_3.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_3.png deleted file mode 100644 index 06f08ae67..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_4.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_4.png deleted file mode 100644 index bcc7f28a9..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_5.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_5.png deleted file mode 100644 index 7d945dd06..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_6.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_6.png deleted file mode 100644 index c0b1a4fe2..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_7.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_7.png deleted file mode 100644 index 19c8181d0..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_8.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_8.png deleted file mode 100644 index c0b316950..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_9.png b/assets/dolphin/external/L1_Happy_holidays_128x64/frame_9.png deleted file mode 100644 index 929a207ef..000000000 Binary files a/assets/dolphin/external/L1_Happy_holidays_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Happy_holidays_128x64/meta.txt b/assets/dolphin/external/L1_Happy_holidays_128x64/meta.txt deleted file mode 100644 index a2c733397..000000000 --- a/assets/dolphin/external/L1_Happy_holidays_128x64/meta.txt +++ /dev/null @@ -1,23 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 18 -Frames order: 0 1 2 1 0 1 2 1 0 1 2 3 4 5 6 5 4 7 2 8 9 10 11 10 9 10 11 12 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 1 - -Slot: 0 -X: 11 -Y: 19 -Text: HAPPY\nHOLIDAYS! -AlignH: Right -AlignV: Center -StartFrame: 22 -EndFrame: 27 diff --git a/assets/dolphin/external/L1_New_year_128x64/frame_0.png b/assets/dolphin/external/L1_New_year_128x64/frame_0.png deleted file mode 100644 index 6c3f44f76..000000000 Binary files a/assets/dolphin/external/L1_New_year_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L1_New_year_128x64/frame_1.png b/assets/dolphin/external/L1_New_year_128x64/frame_1.png deleted file mode 100644 index dfdb5e945..000000000 Binary files a/assets/dolphin/external/L1_New_year_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L1_New_year_128x64/frame_2.png b/assets/dolphin/external/L1_New_year_128x64/frame_2.png deleted file mode 100644 index 9bb503077..000000000 Binary files a/assets/dolphin/external/L1_New_year_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L1_New_year_128x64/frame_3.png b/assets/dolphin/external/L1_New_year_128x64/frame_3.png deleted file mode 100644 index dc6597be9..000000000 Binary files a/assets/dolphin/external/L1_New_year_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L1_New_year_128x64/meta.txt b/assets/dolphin/external/L1_New_year_128x64/meta.txt deleted file mode 100644 index 06c2ee6a9..000000000 --- a/assets/dolphin/external/L1_New_year_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 4 -Active frames: 0 -Frames order: 0 1 2 3 -Active cycles: 0 -Frame rate: 2 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_0.png b/assets/dolphin/external/L1_Painting_128x64/frame_0.png deleted file mode 100644 index b2f9bc775..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_1.png b/assets/dolphin/external/L1_Painting_128x64/frame_1.png deleted file mode 100644 index 02ac533ce..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_10.png b/assets/dolphin/external/L1_Painting_128x64/frame_10.png deleted file mode 100644 index ae3148c32..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_11.png b/assets/dolphin/external/L1_Painting_128x64/frame_11.png deleted file mode 100644 index 89d003d07..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_2.png b/assets/dolphin/external/L1_Painting_128x64/frame_2.png deleted file mode 100644 index 8bfe6b33c..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_3.png b/assets/dolphin/external/L1_Painting_128x64/frame_3.png deleted file mode 100644 index 1c6fc2144..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_4.png b/assets/dolphin/external/L1_Painting_128x64/frame_4.png deleted file mode 100644 index d39cddea1..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_5.png b/assets/dolphin/external/L1_Painting_128x64/frame_5.png deleted file mode 100644 index 4f21a268a..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_6.png b/assets/dolphin/external/L1_Painting_128x64/frame_6.png deleted file mode 100644 index 3f492eab5..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_7.png b/assets/dolphin/external/L1_Painting_128x64/frame_7.png deleted file mode 100644 index 336cffcb4..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_8.png b/assets/dolphin/external/L1_Painting_128x64/frame_8.png deleted file mode 100644 index a44a7315d..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/frame_9.png b/assets/dolphin/external/L1_Painting_128x64/frame_9.png deleted file mode 100644 index 7cd425291..000000000 Binary files a/assets/dolphin/external/L1_Painting_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Painting_128x64/meta.txt b/assets/dolphin/external/L1_Painting_128x64/meta.txt deleted file mode 100644 index 46528d598..000000000 --- a/assets/dolphin/external/L1_Painting_128x64/meta.txt +++ /dev/null @@ -1,50 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 9 -Active frames: 13 -Frames order: 0 1 2 3 4 5 2 3 4 10 6 7 8 7 8 7 8 7 8 9 10 11 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 2 - -Slot: 0 -X: 57 -Y: 24 -Text: $20 to put this -AlignH: Left -AlignV: Center -StartFrame: 11 -EndFrame: 14 - -Slot: 0 -X: 57 -Y: 21 -Text: in my blowhole -AlignH: Left -AlignV: Center -StartFrame: 15 -EndFrame: 18 - -Slot: 1 -X: 57 -Y: 24 -Text: How many dicks -AlignH: Left -AlignV: Center -StartFrame: 11 -EndFrame: 14 - -Slot: 0 -X: 57 -Y: 21 -Text: we drawing today? -AlignH: Left -AlignV: Center -StartFrame: 15 -EndFrame: 18 diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_0.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_0.png deleted file mode 100644 index f10393867..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_1.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_1.png deleted file mode 100644 index 96fd173b4..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_10.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_10.png deleted file mode 100644 index cd4c7442c..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_2.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_2.png deleted file mode 100644 index 81d28fcf8..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_3.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_3.png deleted file mode 100644 index cc3670d9a..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_4.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_4.png deleted file mode 100644 index a0cc88f8e..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_5.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_5.png deleted file mode 100644 index 25213cde0..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_6.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_6.png deleted file mode 100644 index ea9099759..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_7.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_7.png deleted file mode 100644 index 54d1543a7..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_8.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_8.png deleted file mode 100644 index f1d240ced..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/frame_9.png b/assets/dolphin/external/L1_Purple_rain_128x64/frame_9.png deleted file mode 100644 index b5abae076..000000000 Binary files a/assets/dolphin/external/L1_Purple_rain_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L1_Purple_rain_128x64/meta.txt b/assets/dolphin/external/L1_Purple_rain_128x64/meta.txt deleted file mode 100644 index c60148050..000000000 --- a/assets/dolphin/external/L1_Purple_rain_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 11 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_0.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_0.png deleted file mode 100644 index e8a8fcd06..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_1.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_1.png deleted file mode 100644 index 82fa5a8cc..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_2.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_2.png deleted file mode 100644 index 1120d8539..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_3.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_3.png deleted file mode 100644 index e78ff10dd..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_4.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_4.png deleted file mode 100644 index 59cb890f8..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_5.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_5.png deleted file mode 100644 index da89112ca..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_6.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_6.png deleted file mode 100644 index 49f040bb5..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_7.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_7.png deleted file mode 100644 index de0efa639..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_8.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_8.png deleted file mode 100644 index 5d9841fe2..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/frame_9.png b/assets/dolphin/external/L2_FlipperCity_128x64/frame_9.png deleted file mode 100644 index 1c6f7c903..000000000 Binary files a/assets/dolphin/external/L2_FlipperCity_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L2_FlipperCity_128x64/meta.txt b/assets/dolphin/external/L2_FlipperCity_128x64/meta.txt deleted file mode 100644 index 5ba9eab4a..000000000 --- a/assets/dolphin/external/L2_FlipperCity_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_0.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_0.png deleted file mode 100644 index 912090032..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_1.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_1.png deleted file mode 100644 index 0b99a32ff..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_10.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_10.png deleted file mode 100644 index 9da72ac1d..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_11.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_11.png deleted file mode 100644 index 8d54da6c6..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_12.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_12.png deleted file mode 100644 index 84046a46c..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_13.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_13.png deleted file mode 100644 index 3e1c9c329..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_14.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_14.png deleted file mode 100644 index f4f6ccd66..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_15.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_15.png deleted file mode 100644 index 5dc1a6525..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_16.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_16.png deleted file mode 100644 index bec472921..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_17.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_17.png deleted file mode 100644 index 82e5176c8..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_18.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_18.png deleted file mode 100644 index 3b5e60dfd..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_19.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_19.png deleted file mode 100644 index 5f76c7d23..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_19.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_2.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_2.png deleted file mode 100644 index 84d6aaf35..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_20.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_20.png deleted file mode 100644 index 2f8394fd5..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_20.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_3.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_3.png deleted file mode 100644 index 48adde113..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_4.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_4.png deleted file mode 100644 index 5889835b7..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_5.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_5.png deleted file mode 100644 index 7f980f57f..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_6.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_6.png deleted file mode 100644 index 497136000..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_7.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_7.png deleted file mode 100644 index 03d67134a..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_8.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_8.png deleted file mode 100644 index 9f523cace..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/frame_9.png b/assets/dolphin/external/L2_Wake_up_128x64/frame_9.png deleted file mode 100644 index 5a565b1af..000000000 Binary files a/assets/dolphin/external/L2_Wake_up_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L2_Wake_up_128x64/meta.txt b/assets/dolphin/external/L2_Wake_up_128x64/meta.txt deleted file mode 100644 index 06c710f03..000000000 --- a/assets/dolphin/external/L2_Wake_up_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 18 -Frames order: 0 1 0 1 0 1 0 2 3 4 0 5 6 7 8 9 10 11 10 12 13 14 15 16 17 18 19 20 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 0 \ No newline at end of file diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_0.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_0.png deleted file mode 100644 index 6f058ed55..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_1.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_1.png deleted file mode 100644 index ab34e0fa9..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_10.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_10.png deleted file mode 100644 index 382e161fa..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_11.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_11.png deleted file mode 100644 index 5638a1a27..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_2.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_2.png deleted file mode 100644 index 0f39e356a..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_3.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_3.png deleted file mode 100644 index fc5f2d2c4..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_4.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_4.png deleted file mode 100644 index bbab8543d..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_5.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_5.png deleted file mode 100644 index dabadecab..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_6.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_6.png deleted file mode 100644 index 098c2f528..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_7.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_7.png deleted file mode 100644 index c3b82a23e..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_8.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_8.png deleted file mode 100644 index 8067df06e..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_9.png b/assets/dolphin/external/L3_FlipperMustache_128x64/frame_9.png deleted file mode 100644 index 03875fb30..000000000 Binary files a/assets/dolphin/external/L3_FlipperMustache_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/L3_FlipperMustache_128x64/meta.txt b/assets/dolphin/external/L3_FlipperMustache_128x64/meta.txt deleted file mode 100644 index 8440c67d5..000000000 --- a/assets/dolphin/external/L3_FlipperMustache_128x64/meta.txt +++ /dev/null @@ -1,34 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 2 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 -Active cycles: 8 -Frame rate: 3 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 1 - -Slot: 0 -X: 60 -Y: 30 -Text: Some hack\nwe made -AlignH: Left -AlignV: Center -StartFrame: 10 -EndFrame: 17 - -Slot: 0 -X: 60 -Y: 30 -Text: It's a firmware\nupgrade! -AlignH: Left -AlignV: Center -StartFrame: 18 -EndFrame: 25 - - diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_0.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_0.png deleted file mode 100644 index 9a494e199..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_1.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_1.png deleted file mode 100644 index 197f91281..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_10.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_10.png deleted file mode 100644 index 4467b9c9a..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_11.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_11.png deleted file mode 100644 index f22773f20..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_12.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_12.png deleted file mode 100644 index 6dd18469b..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_13.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_13.png deleted file mode 100644 index 842bec2ed..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_14.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_14.png deleted file mode 100644 index 706fbe717..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_15.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_15.png deleted file mode 100644 index 6fa5a2ada..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_16.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_16.png deleted file mode 100644 index 380298283..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_17.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_17.png deleted file mode 100644 index a936578fd..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_18.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_18.png deleted file mode 100644 index 23bfd352f..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_19.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_19.png deleted file mode 100644 index 7aa3762f0..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_19.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_2.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_2.png deleted file mode 100644 index bb80ea33e..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_20.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_20.png deleted file mode 100644 index bf7e09ec1..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_20.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_21.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_21.png deleted file mode 100644 index eb657d3c6..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_21.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_22.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_22.png deleted file mode 100644 index ac75c38f6..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_22.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_23.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_23.png deleted file mode 100644 index 8111a5d8a..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_23.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_24.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_24.png deleted file mode 100644 index 1774bd5c7..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_24.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_25.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_25.png deleted file mode 100644 index 11e24b271..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_25.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_26.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_26.png deleted file mode 100644 index 2b9857523..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_26.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_27.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_27.png deleted file mode 100644 index 46f4685a7..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_27.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_28.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_28.png deleted file mode 100644 index 43c39460d..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_28.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_29.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_29.png deleted file mode 100644 index 6645f1ffe..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_29.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_3.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_3.png deleted file mode 100644 index 2ce685140..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_30.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_30.png deleted file mode 100644 index 61a1151b0..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_30.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_31.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_31.png deleted file mode 100644 index 2f66d4885..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_31.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_32.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_32.png deleted file mode 100644 index fc15964dd..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_32.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_33.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_33.png deleted file mode 100644 index d0392432b..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_33.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_34.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_34.png deleted file mode 100644 index 31c3582d3..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_34.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_35.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_35.png deleted file mode 100644 index 3bc9219c0..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_35.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_36.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_36.png deleted file mode 100644 index 87402cafd..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_36.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_37.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_37.png deleted file mode 100644 index 7332421b1..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_37.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_38.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_38.png deleted file mode 100644 index 2c7181f77..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_38.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_39.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_39.png deleted file mode 100644 index 44cd04e16..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_39.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_4.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_4.png deleted file mode 100644 index b2e4a2d8c..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_40.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_40.png deleted file mode 100644 index acdda1376..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_40.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_41.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_41.png deleted file mode 100644 index b946e9c79..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_41.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_42.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_42.png deleted file mode 100644 index f001cfb44..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_42.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_43.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_43.png deleted file mode 100644 index a81dd6549..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_43.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_44.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_44.png deleted file mode 100644 index 802967665..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_44.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_45.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_45.png deleted file mode 100644 index 7193364ee..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_45.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_46.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_46.png deleted file mode 100644 index 42e44c79f..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_46.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_47.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_47.png deleted file mode 100644 index cd43b8dd0..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_47.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_48.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_48.png deleted file mode 100644 index 25c9ada3c..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_48.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_49.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_49.png deleted file mode 100644 index 353ea2dd3..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_49.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_5.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_5.png deleted file mode 100644 index 397c1af52..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_6.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_6.png deleted file mode 100644 index 5b46eca2c..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_7.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_7.png deleted file mode 100644 index e0ff86f75..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_8.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_8.png deleted file mode 100644 index 365707573..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_9.png b/assets/dolphin/external/Sasquach_Blaster_128x64/frame_9.png deleted file mode 100644 index 9e9c4068c..000000000 Binary files a/assets/dolphin/external/Sasquach_Blaster_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Blaster_128x64/meta.txt b/assets/dolphin/external/Sasquach_Blaster_128x64/meta.txt deleted file mode 100644 index 4d5cb4433..000000000 --- a/assets/dolphin/external/Sasquach_Blaster_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 50 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_0.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_0.png deleted file mode 100644 index cdec5596d..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_1.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_1.png deleted file mode 100644 index 01818b6a6..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_10.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_10.png deleted file mode 100644 index 0e15ba631..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_11.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_11.png deleted file mode 100644 index b3ad788c0..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_12.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_12.png deleted file mode 100644 index 6adc432a7..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_13.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_13.png deleted file mode 100644 index 930327f3f..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_14.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_14.png deleted file mode 100644 index 0bda5f482..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_15.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_15.png deleted file mode 100644 index f736e4bdc..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_16.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_16.png deleted file mode 100644 index 30594b5f2..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_17.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_17.png deleted file mode 100644 index 568893834..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_18.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_18.png deleted file mode 100644 index 5a9cbd9f8..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_19.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_19.png deleted file mode 100644 index 3c4f222f6..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_19.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_2.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_2.png deleted file mode 100644 index e5b5cac21..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_20.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_20.png deleted file mode 100644 index fd3759ed4..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_20.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_21.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_21.png deleted file mode 100644 index 191eb20ae..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_21.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_22.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_22.png deleted file mode 100644 index 21dff779e..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_22.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_23.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_23.png deleted file mode 100644 index 9ff2aae69..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_23.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_24.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_24.png deleted file mode 100644 index da7fea8d1..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_24.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_25.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_25.png deleted file mode 100644 index 0e3a314c9..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_25.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_26.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_26.png deleted file mode 100644 index f8890e09d..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_26.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_27.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_27.png deleted file mode 100644 index 611012fea..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_27.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_28.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_28.png deleted file mode 100644 index 83a0faa0c..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_28.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_29.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_29.png deleted file mode 100644 index aabb57287..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_29.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_3.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_3.png deleted file mode 100644 index 485f1ea5b..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_30.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_30.png deleted file mode 100644 index 6fe6ad15d..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_30.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_31.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_31.png deleted file mode 100644 index 1f4958e35..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_31.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_32.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_32.png deleted file mode 100644 index 878689820..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_32.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_33.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_33.png deleted file mode 100644 index 608957f77..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_33.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_34.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_34.png deleted file mode 100644 index 9e0e5ce7e..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_34.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_35.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_35.png deleted file mode 100644 index d3eed2554..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_35.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_36.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_36.png deleted file mode 100644 index 9e841b0f5..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_36.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_37.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_37.png deleted file mode 100644 index 649f0d405..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_37.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_38.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_38.png deleted file mode 100644 index 5f67c3653..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_38.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_39.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_39.png deleted file mode 100644 index 6bc64a134..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_39.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_4.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_4.png deleted file mode 100644 index 0d5178db7..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_40.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_40.png deleted file mode 100644 index 8eda64c64..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_40.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_41.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_41.png deleted file mode 100644 index f145f9d80..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_41.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_42.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_42.png deleted file mode 100644 index 5d7ad776d..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_42.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_43.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_43.png deleted file mode 100644 index 5ec728639..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_43.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_44.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_44.png deleted file mode 100644 index cd8e8139c..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_44.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_45.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_45.png deleted file mode 100644 index 0ea0af39c..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_45.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_46.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_46.png deleted file mode 100644 index 5f10dbbfc..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_46.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_5.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_5.png deleted file mode 100644 index ecc510827..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_6.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_6.png deleted file mode 100644 index 65b403718..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_7.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_7.png deleted file mode 100644 index 8eeed972c..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_8.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_8.png deleted file mode 100644 index c73723c2c..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_9.png b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_9.png deleted file mode 100644 index 677ef566f..000000000 Binary files a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/meta.txt b/assets/dolphin/external/Sasquach_CloudG0ku_128x64/meta.txt deleted file mode 100644 index cb006d0e0..000000000 --- a/assets/dolphin/external/Sasquach_CloudG0ku_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 47 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 5 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_0.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_0.png deleted file mode 100644 index 18f38e267..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_1.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_1.png deleted file mode 100644 index c47cadc0f..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_10.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_10.png deleted file mode 100644 index a645b9cdd..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_11.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_11.png deleted file mode 100644 index d0a69418c..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_12.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_12.png deleted file mode 100644 index 4983b12cb..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_13.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_13.png deleted file mode 100644 index f3135f3e0..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_14.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_14.png deleted file mode 100644 index bb52a89d7..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_15.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_15.png deleted file mode 100644 index 04420b51d..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_16.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_16.png deleted file mode 100644 index 56facb9a2..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_17.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_17.png deleted file mode 100644 index 2d486ecba..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_18.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_18.png deleted file mode 100644 index 6aef0a443..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_19.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_19.png deleted file mode 100644 index 2b8cab0d3..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_19.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_2.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_2.png deleted file mode 100644 index 0e6ddacad..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_20.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_20.png deleted file mode 100644 index b5fa71646..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_20.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_21.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_21.png deleted file mode 100644 index da14ff61d..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_21.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_22.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_22.png deleted file mode 100644 index eb1820ab3..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_22.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_23.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_23.png deleted file mode 100644 index 5f8ce6aa7..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_23.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_24.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_24.png deleted file mode 100644 index 34104e566..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_24.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_25.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_25.png deleted file mode 100644 index ff7175f1c..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_25.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_26.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_26.png deleted file mode 100644 index 449195e55..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_26.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_27.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_27.png deleted file mode 100644 index 34931ccac..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_27.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_28.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_28.png deleted file mode 100644 index a483ca498..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_28.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_29.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_29.png deleted file mode 100644 index 42b4c3c93..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_29.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_3.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_3.png deleted file mode 100644 index a417ee476..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_4.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_4.png deleted file mode 100644 index 99fae827b..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_5.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_5.png deleted file mode 100644 index f1631a8c4..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_6.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_6.png deleted file mode 100644 index 1bc4bd9d7..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_7.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_7.png deleted file mode 100644 index db3c8d50e..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_8.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_8.png deleted file mode 100644 index 23f0b56d2..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_9.png b/assets/dolphin/external/Sasquach_Narut0_128x64/frame_9.png deleted file mode 100644 index d84ab6684..000000000 Binary files a/assets/dolphin/external/Sasquach_Narut0_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_Narut0_128x64/meta.txt b/assets/dolphin/external/Sasquach_Narut0_128x64/meta.txt deleted file mode 100644 index 7e7e55b26..000000000 --- a/assets/dolphin/external/Sasquach_Narut0_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 30 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_0.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_0.png deleted file mode 100644 index aa66a9921..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_0.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_1.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_1.png deleted file mode 100644 index c65535685..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_1.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_10.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_10.png deleted file mode 100644 index dd27449f5..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_10.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_11.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_11.png deleted file mode 100644 index a2f2136a2..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_11.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_12.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_12.png deleted file mode 100644 index b5dbb2279..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_12.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_13.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_13.png deleted file mode 100644 index cb93f7af9..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_13.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_14.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_14.png deleted file mode 100644 index e937dc6ea..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_14.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_15.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_15.png deleted file mode 100644 index 9e7849137..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_15.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_16.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_16.png deleted file mode 100644 index cc68643c4..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_16.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_17.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_17.png deleted file mode 100644 index ae46a473f..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_17.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_18.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_18.png deleted file mode 100644 index 1e0428cb4..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_18.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_19.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_19.png deleted file mode 100644 index bb9f3471a..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_19.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_2.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_2.png deleted file mode 100644 index 61682d0d3..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_2.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_20.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_20.png deleted file mode 100644 index a7f598223..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_20.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_21.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_21.png deleted file mode 100644 index cf9d8f547..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_21.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_22.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_22.png deleted file mode 100644 index c9f412e39..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_22.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_23.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_23.png deleted file mode 100644 index cf9d8f547..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_23.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_24.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_24.png deleted file mode 100644 index 403188095..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_24.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_25.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_25.png deleted file mode 100644 index 3622e59b8..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_25.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_26.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_26.png deleted file mode 100644 index 593d08d1f..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_26.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_27.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_27.png deleted file mode 100644 index 1a8c9376f..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_27.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_28.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_28.png deleted file mode 100644 index 9c97ced6a..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_28.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_29.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_29.png deleted file mode 100644 index 4f754fcdb..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_29.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_3.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_3.png deleted file mode 100644 index 4d881bc21..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_3.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_30.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_30.png deleted file mode 100644 index a5b1b40f9..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_30.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_31.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_31.png deleted file mode 100644 index 0263ea8fc..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_31.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_32.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_32.png deleted file mode 100644 index 036bf96bd..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_32.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_33.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_33.png deleted file mode 100644 index f477dc3bc..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_33.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_34.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_34.png deleted file mode 100644 index 1320d8be9..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_34.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_35.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_35.png deleted file mode 100644 index fa998160b..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_35.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_36.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_36.png deleted file mode 100644 index b19194efa..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_36.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_37.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_37.png deleted file mode 100644 index 249142655..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_37.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_38.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_38.png deleted file mode 100644 index 49705dc80..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_38.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_4.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_4.png deleted file mode 100644 index 05042411a..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_4.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_5.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_5.png deleted file mode 100644 index 91c2cc2ae..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_5.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_6.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_6.png deleted file mode 100644 index 2a8df7f1b..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_6.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_7.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_7.png deleted file mode 100644 index 95b53497b..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_7.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_8.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_8.png deleted file mode 100644 index 787af7d73..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_8.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_9.png b/assets/dolphin/external/Sasquach_RMCF_128x64/frame_9.png deleted file mode 100644 index f56e685b9..000000000 Binary files a/assets/dolphin/external/Sasquach_RMCF_128x64/frame_9.png and /dev/null differ diff --git a/assets/dolphin/external/Sasquach_RMCF_128x64/meta.txt b/assets/dolphin/external/Sasquach_RMCF_128x64/meta.txt deleted file mode 100644 index b6b3fdf3e..000000000 --- a/assets/dolphin/external/Sasquach_RMCF_128x64/meta.txt +++ /dev/null @@ -1,23 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 100 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 13 14 15 16 17 18 17 18 17 18 19 20 19 20 19 20 19 20 19 20 21 22 21 22 22 22 23 24 25 26 27 28 29 30 31 32 33 0 34 35 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 37 38 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 1 - -Slot: 0 -X: 33 -Y: 35 -Text: I Know \nKung Fu -AlignH: Left -AlignV: Top -StartFrame: 14 -EndFrame: 20 diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_0.png b/assets/dolphin/external/fireplace/frame_0.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_0.png rename to assets/dolphin/external/fireplace/frame_0.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_1.png b/assets/dolphin/external/fireplace/frame_1.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_1.png rename to assets/dolphin/external/fireplace/frame_1.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_2.png b/assets/dolphin/external/fireplace/frame_2.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_2.png rename to assets/dolphin/external/fireplace/frame_2.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_3.png b/assets/dolphin/external/fireplace/frame_3.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_3.png rename to assets/dolphin/external/fireplace/frame_3.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_4.png b/assets/dolphin/external/fireplace/frame_4.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_4.png rename to assets/dolphin/external/fireplace/frame_4.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_5.png b/assets/dolphin/external/fireplace/frame_5.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_5.png rename to assets/dolphin/external/fireplace/frame_5.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_6.png b/assets/dolphin/external/fireplace/frame_6.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_6.png rename to assets/dolphin/external/fireplace/frame_6.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/frame_7.png b/assets/dolphin/external/fireplace/frame_7.png similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/frame_7.png rename to assets/dolphin/external/fireplace/frame_7.png diff --git a/assets/dolphin/external/L3_Fireplace_128x64/meta.txt b/assets/dolphin/external/fireplace/meta.txt similarity index 100% rename from assets/dolphin/external/L3_Fireplace_128x64/meta.txt rename to assets/dolphin/external/fireplace/meta.txt diff --git a/assets/dolphin/external/manifest.txt b/assets/dolphin/external/manifest.txt index 65eef70d5..ebb55a588 100644 --- a/assets/dolphin/external/manifest.txt +++ b/assets/dolphin/external/manifest.txt @@ -1,107 +1,23 @@ Filetype: Flipper Animation Manifest Version: 1 -Name: Kuronons_RMCFW_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Sasquach_Blaster_128x64 +Name: Skynet Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 +Weight: 33 -Name: Sasquach_CloudG0ku_128x64 +Name: fireplace Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 +Weight: 33 -Name: Sasquach_Narut0_128x64 +Name: mods Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 - -Name: Sasquach_RMCF_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: L1_Purple_rain_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Happy_holidays_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 14 - -Name: L1_New_year_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 14 - -Name: L2_FlipperCity_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: L3_FlipperMustache_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 7 - -Name: L3_Fireplace_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 7 - -Name: L1_Mods_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Painting_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L2_Wake_up_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Halloween_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 +Weight: 33 \ No newline at end of file diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_0.png b/assets/dolphin/external/mods/frame_0.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_0.png rename to assets/dolphin/external/mods/frame_0.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_1.png b/assets/dolphin/external/mods/frame_1.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_1.png rename to assets/dolphin/external/mods/frame_1.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_10.png b/assets/dolphin/external/mods/frame_10.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_10.png rename to assets/dolphin/external/mods/frame_10.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_11.png b/assets/dolphin/external/mods/frame_11.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_11.png rename to assets/dolphin/external/mods/frame_11.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_12.png b/assets/dolphin/external/mods/frame_12.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_12.png rename to assets/dolphin/external/mods/frame_12.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_13.png b/assets/dolphin/external/mods/frame_13.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_13.png rename to assets/dolphin/external/mods/frame_13.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_14.png b/assets/dolphin/external/mods/frame_14.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_14.png rename to assets/dolphin/external/mods/frame_14.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_15.png b/assets/dolphin/external/mods/frame_15.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_15.png rename to assets/dolphin/external/mods/frame_15.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_16.png b/assets/dolphin/external/mods/frame_16.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_16.png rename to assets/dolphin/external/mods/frame_16.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_17.png b/assets/dolphin/external/mods/frame_17.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_17.png rename to assets/dolphin/external/mods/frame_17.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_18.png b/assets/dolphin/external/mods/frame_18.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_18.png rename to assets/dolphin/external/mods/frame_18.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_19.png b/assets/dolphin/external/mods/frame_19.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_19.png rename to assets/dolphin/external/mods/frame_19.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_2.png b/assets/dolphin/external/mods/frame_2.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_2.png rename to assets/dolphin/external/mods/frame_2.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_20.png b/assets/dolphin/external/mods/frame_20.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_20.png rename to assets/dolphin/external/mods/frame_20.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_21.png b/assets/dolphin/external/mods/frame_21.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_21.png rename to assets/dolphin/external/mods/frame_21.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_22.png b/assets/dolphin/external/mods/frame_22.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_22.png rename to assets/dolphin/external/mods/frame_22.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_23.png b/assets/dolphin/external/mods/frame_23.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_23.png rename to assets/dolphin/external/mods/frame_23.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_24.png b/assets/dolphin/external/mods/frame_24.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_24.png rename to assets/dolphin/external/mods/frame_24.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_25.png b/assets/dolphin/external/mods/frame_25.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_25.png rename to assets/dolphin/external/mods/frame_25.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_26.png b/assets/dolphin/external/mods/frame_26.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_26.png rename to assets/dolphin/external/mods/frame_26.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_27.png b/assets/dolphin/external/mods/frame_27.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_27.png rename to assets/dolphin/external/mods/frame_27.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_28.png b/assets/dolphin/external/mods/frame_28.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_28.png rename to assets/dolphin/external/mods/frame_28.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_29.png b/assets/dolphin/external/mods/frame_29.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_29.png rename to assets/dolphin/external/mods/frame_29.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_3.png b/assets/dolphin/external/mods/frame_3.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_3.png rename to assets/dolphin/external/mods/frame_3.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_30.png b/assets/dolphin/external/mods/frame_30.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_30.png rename to assets/dolphin/external/mods/frame_30.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_31.png b/assets/dolphin/external/mods/frame_31.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_31.png rename to assets/dolphin/external/mods/frame_31.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_32.png b/assets/dolphin/external/mods/frame_32.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_32.png rename to assets/dolphin/external/mods/frame_32.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_33.png b/assets/dolphin/external/mods/frame_33.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_33.png rename to assets/dolphin/external/mods/frame_33.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_34.png b/assets/dolphin/external/mods/frame_34.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_34.png rename to assets/dolphin/external/mods/frame_34.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_35.png b/assets/dolphin/external/mods/frame_35.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_35.png rename to assets/dolphin/external/mods/frame_35.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_36.png b/assets/dolphin/external/mods/frame_36.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_36.png rename to assets/dolphin/external/mods/frame_36.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_37.png b/assets/dolphin/external/mods/frame_37.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_37.png rename to assets/dolphin/external/mods/frame_37.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_38.png b/assets/dolphin/external/mods/frame_38.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_38.png rename to assets/dolphin/external/mods/frame_38.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_39.png b/assets/dolphin/external/mods/frame_39.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_39.png rename to assets/dolphin/external/mods/frame_39.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_4.png b/assets/dolphin/external/mods/frame_4.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_4.png rename to assets/dolphin/external/mods/frame_4.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_40.png b/assets/dolphin/external/mods/frame_40.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_40.png rename to assets/dolphin/external/mods/frame_40.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_5.png b/assets/dolphin/external/mods/frame_5.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_5.png rename to assets/dolphin/external/mods/frame_5.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_6.png b/assets/dolphin/external/mods/frame_6.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_6.png rename to assets/dolphin/external/mods/frame_6.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_7.png b/assets/dolphin/external/mods/frame_7.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_7.png rename to assets/dolphin/external/mods/frame_7.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_8.png b/assets/dolphin/external/mods/frame_8.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_8.png rename to assets/dolphin/external/mods/frame_8.png diff --git a/assets/dolphin/external/L1_Mods_128x64/frame_9.png b/assets/dolphin/external/mods/frame_9.png similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/frame_9.png rename to assets/dolphin/external/mods/frame_9.png diff --git a/assets/dolphin/external/L1_Mods_128x64/meta.txt b/assets/dolphin/external/mods/meta.txt similarity index 100% rename from assets/dolphin/external/L1_Mods_128x64/meta.txt rename to assets/dolphin/external/mods/meta.txt diff --git a/assets/dolphin/external/skynet/frame_0.png b/assets/dolphin/external/skynet/frame_0.png new file mode 100644 index 000000000..95a8dc37a Binary files /dev/null and b/assets/dolphin/external/skynet/frame_0.png differ diff --git a/assets/dolphin/external/skynet/frame_1.png b/assets/dolphin/external/skynet/frame_1.png new file mode 100644 index 000000000..d1e74b17c Binary files /dev/null and b/assets/dolphin/external/skynet/frame_1.png differ diff --git a/assets/dolphin/external/skynet/frame_10.png b/assets/dolphin/external/skynet/frame_10.png new file mode 100644 index 000000000..bf61abf30 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_10.png differ diff --git a/assets/dolphin/external/skynet/frame_11.png b/assets/dolphin/external/skynet/frame_11.png new file mode 100644 index 000000000..84b138122 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_11.png differ diff --git a/assets/dolphin/external/skynet/frame_12.png b/assets/dolphin/external/skynet/frame_12.png new file mode 100644 index 000000000..e7e63e4cb Binary files /dev/null and b/assets/dolphin/external/skynet/frame_12.png differ diff --git a/assets/dolphin/external/skynet/frame_13.png b/assets/dolphin/external/skynet/frame_13.png new file mode 100644 index 000000000..daadd63bb Binary files /dev/null and b/assets/dolphin/external/skynet/frame_13.png differ diff --git a/assets/dolphin/external/skynet/frame_14.png b/assets/dolphin/external/skynet/frame_14.png new file mode 100644 index 000000000..68a598f0a Binary files /dev/null and b/assets/dolphin/external/skynet/frame_14.png differ diff --git a/assets/dolphin/external/skynet/frame_15.png b/assets/dolphin/external/skynet/frame_15.png new file mode 100644 index 000000000..af3fb0187 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_15.png differ diff --git a/assets/dolphin/external/skynet/frame_16.png b/assets/dolphin/external/skynet/frame_16.png new file mode 100644 index 000000000..a255367e0 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_16.png differ diff --git a/assets/dolphin/external/skynet/frame_17.png b/assets/dolphin/external/skynet/frame_17.png new file mode 100644 index 000000000..0f1b30ecb Binary files /dev/null and b/assets/dolphin/external/skynet/frame_17.png differ diff --git a/assets/dolphin/external/skynet/frame_18.png b/assets/dolphin/external/skynet/frame_18.png new file mode 100644 index 000000000..4200b0979 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_18.png differ diff --git a/assets/dolphin/external/skynet/frame_19.png b/assets/dolphin/external/skynet/frame_19.png new file mode 100644 index 000000000..97de8691a Binary files /dev/null and b/assets/dolphin/external/skynet/frame_19.png differ diff --git a/assets/dolphin/external/skynet/frame_2.png b/assets/dolphin/external/skynet/frame_2.png new file mode 100644 index 000000000..3c59aa99b Binary files /dev/null and b/assets/dolphin/external/skynet/frame_2.png differ diff --git a/assets/dolphin/external/skynet/frame_20.png b/assets/dolphin/external/skynet/frame_20.png new file mode 100644 index 000000000..ffb5816cb Binary files /dev/null and b/assets/dolphin/external/skynet/frame_20.png differ diff --git a/assets/dolphin/external/skynet/frame_21.png b/assets/dolphin/external/skynet/frame_21.png new file mode 100644 index 000000000..ac6641783 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_21.png differ diff --git a/assets/dolphin/external/skynet/frame_22.png b/assets/dolphin/external/skynet/frame_22.png new file mode 100644 index 000000000..b5b4efeaf Binary files /dev/null and b/assets/dolphin/external/skynet/frame_22.png differ diff --git a/assets/dolphin/external/skynet/frame_23.png b/assets/dolphin/external/skynet/frame_23.png new file mode 100644 index 000000000..033d9e35b Binary files /dev/null and b/assets/dolphin/external/skynet/frame_23.png differ diff --git a/assets/dolphin/external/skynet/frame_24.png b/assets/dolphin/external/skynet/frame_24.png new file mode 100644 index 000000000..0898c10e8 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_24.png differ diff --git a/assets/dolphin/external/skynet/frame_25.png b/assets/dolphin/external/skynet/frame_25.png new file mode 100644 index 000000000..805dcdf1d Binary files /dev/null and b/assets/dolphin/external/skynet/frame_25.png differ diff --git a/assets/dolphin/external/skynet/frame_26.png b/assets/dolphin/external/skynet/frame_26.png new file mode 100644 index 000000000..69b981607 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_26.png differ diff --git a/assets/dolphin/external/skynet/frame_27.png b/assets/dolphin/external/skynet/frame_27.png new file mode 100644 index 000000000..f5e23a945 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_27.png differ diff --git a/assets/dolphin/external/skynet/frame_28.png b/assets/dolphin/external/skynet/frame_28.png new file mode 100644 index 000000000..7ded12037 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_28.png differ diff --git a/assets/dolphin/external/skynet/frame_29.png b/assets/dolphin/external/skynet/frame_29.png new file mode 100644 index 000000000..8b3df1eb3 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_29.png differ diff --git a/assets/dolphin/external/skynet/frame_3.png b/assets/dolphin/external/skynet/frame_3.png new file mode 100644 index 000000000..8b8aeb320 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_3.png differ diff --git a/assets/dolphin/external/skynet/frame_30.png b/assets/dolphin/external/skynet/frame_30.png new file mode 100644 index 000000000..e6863cb6f Binary files /dev/null and b/assets/dolphin/external/skynet/frame_30.png differ diff --git a/assets/dolphin/external/skynet/frame_4.png b/assets/dolphin/external/skynet/frame_4.png new file mode 100644 index 000000000..390da382e Binary files /dev/null and b/assets/dolphin/external/skynet/frame_4.png differ diff --git a/assets/dolphin/external/skynet/frame_5.png b/assets/dolphin/external/skynet/frame_5.png new file mode 100644 index 000000000..7577e5f80 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_5.png differ diff --git a/assets/dolphin/external/skynet/frame_6.png b/assets/dolphin/external/skynet/frame_6.png new file mode 100644 index 000000000..970124046 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_6.png differ diff --git a/assets/dolphin/external/skynet/frame_7.png b/assets/dolphin/external/skynet/frame_7.png new file mode 100644 index 000000000..f99445ce4 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_7.png differ diff --git a/assets/dolphin/external/skynet/frame_8.png b/assets/dolphin/external/skynet/frame_8.png new file mode 100644 index 000000000..f951a53a4 Binary files /dev/null and b/assets/dolphin/external/skynet/frame_8.png differ diff --git a/assets/dolphin/external/skynet/frame_9.png b/assets/dolphin/external/skynet/frame_9.png new file mode 100644 index 000000000..94fa16aba Binary files /dev/null and b/assets/dolphin/external/skynet/frame_9.png differ diff --git a/assets/dolphin/external/skynet/meta.txt b/assets/dolphin/external/skynet/meta.txt new file mode 100644 index 000000000..b19892979 --- /dev/null +++ b/assets/dolphin/external/skynet/meta.txt @@ -0,0 +1,14 @@ +Filetype: Flipper Animation +Version: 1 + +Width: 128 +Height: 64 +Passive frames: 6 +Active frames: 48 +Frames order: 0 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 22 23 24 25 26 27 28 29 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 +Active cycles: 1 +Frame rate: 8 +Duration: 3600 +Active cooldown: 1 + +Bubble slots: 0 diff --git a/assets/dolphin/internal/Sasquach_D1g1talRa1n_128x64/meta.txt b/assets/dolphin/internal/Sasquach_D1g1talRa1n_128x64/meta.txt index b8a080c97..7e4117fed 100644 --- a/assets/dolphin/internal/Sasquach_D1g1talRa1n_128x64/meta.txt +++ b/assets/dolphin/internal/Sasquach_D1g1talRa1n_128x64/meta.txt @@ -8,7 +8,7 @@ Active frames: 0 Frames order: 0 1 2 3 4 5 6 7 8 9 10 Active cycles: 0 Frame rate: 7 -Duration: 3600 +Duration: 360 Active cooldown: 0 Bubble slots: 0 diff --git a/assets/icons/Passport/G0ku.png b/assets/icons/Passport/G0ku.png deleted file mode 100644 index 84389c4f4..000000000 Binary files a/assets/icons/Passport/G0ku.png and /dev/null differ diff --git a/assets/icons/Passport/flipper.png b/assets/icons/Passport/flipper.png new file mode 100644 index 000000000..6f39fbe26 Binary files /dev/null and b/assets/icons/Passport/flipper.png differ diff --git a/assets/icons/Passport/g0ku_1.png b/assets/icons/Passport/g0ku_1.png deleted file mode 100644 index 900d5113f..000000000 Binary files a/assets/icons/Passport/g0ku_1.png and /dev/null differ diff --git a/assets/icons/Passport/g0ku_2.png b/assets/icons/Passport/g0ku_2.png deleted file mode 100644 index 202353bb9..000000000 Binary files a/assets/icons/Passport/g0ku_2.png and /dev/null differ diff --git a/assets/icons/Passport/g0ku_3.png b/assets/icons/Passport/g0ku_3.png deleted file mode 100644 index 517c1653f..000000000 Binary files a/assets/icons/Passport/g0ku_3.png and /dev/null differ diff --git a/assets/icons/Passport/passport_DB.png b/assets/icons/Passport/passport_DB.png index 12e0c3dd4..7eef0d18c 100644 Binary files a/assets/icons/Passport/passport_DB.png and b/assets/icons/Passport/passport_DB.png differ diff --git a/assets/icons/Passport/passport_bad1_46x49.png b/assets/icons/Passport/passport_bad1_46x49.png deleted file mode 100644 index 9b0e7c74e..000000000 Binary files a/assets/icons/Passport/passport_bad1_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_bad2_46x49.png b/assets/icons/Passport/passport_bad2_46x49.png deleted file mode 100644 index d11682ab8..000000000 Binary files a/assets/icons/Passport/passport_bad2_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_bad3_46x49.png b/assets/icons/Passport/passport_bad3_46x49.png deleted file mode 100644 index e39e6629d..000000000 Binary files a/assets/icons/Passport/passport_bad3_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_bottom_128x18.png b/assets/icons/Passport/passport_bottom_128x18.png deleted file mode 100644 index 691ed8b4a..000000000 Binary files a/assets/icons/Passport/passport_bottom_128x18.png and /dev/null differ diff --git a/assets/icons/Passport/passport_happy1_46x49.png b/assets/icons/Passport/passport_happy1_46x49.png deleted file mode 100644 index 7e5648364..000000000 Binary files a/assets/icons/Passport/passport_happy1_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_happy2_46x49.png b/assets/icons/Passport/passport_happy2_46x49.png deleted file mode 100644 index 0b32e921b..000000000 Binary files a/assets/icons/Passport/passport_happy2_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_happy3_46x49.png b/assets/icons/Passport/passport_happy3_46x49.png deleted file mode 100644 index a4c6a7612..000000000 Binary files a/assets/icons/Passport/passport_happy3_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_left_6x46.png b/assets/icons/Passport/passport_left_6x46.png deleted file mode 100644 index 17d3ad265..000000000 Binary files a/assets/icons/Passport/passport_left_6x46.png and /dev/null differ diff --git a/assets/icons/Passport/passport_okay1_46x49.png b/assets/icons/Passport/passport_okay1_46x49.png deleted file mode 100644 index 198ba5436..000000000 Binary files a/assets/icons/Passport/passport_okay1_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_okay2_46x49.png b/assets/icons/Passport/passport_okay2_46x49.png deleted file mode 100644 index 34fd3767b..000000000 Binary files a/assets/icons/Passport/passport_okay2_46x49.png and /dev/null differ diff --git a/assets/icons/Passport/passport_okay3_46x49.png b/assets/icons/Passport/passport_okay3_46x49.png deleted file mode 100644 index e65da5b0e..000000000 Binary files a/assets/icons/Passport/passport_okay3_46x49.png and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_0.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_0.bm deleted file mode 100644 index eaff0733e..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_1.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_1.bm deleted file mode 100644 index 17373de60..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_10.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_10.bm deleted file mode 100644 index dac6c610e..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_11.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_11.bm deleted file mode 100644 index 908421664..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_12.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_12.bm deleted file mode 100644 index 436291543..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_13.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_13.bm deleted file mode 100644 index db3d79070..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_14.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_14.bm deleted file mode 100644 index 52da0067b..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_15.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_15.bm deleted file mode 100644 index 76d09146e..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_16.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_16.bm deleted file mode 100644 index c04003c74..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_17.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_17.bm deleted file mode 100644 index 5205d11fa..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_18.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_18.bm deleted file mode 100644 index 56c1bc85c..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_2.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_2.bm deleted file mode 100644 index 0d0158411..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_3.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_3.bm deleted file mode 100644 index 79eee59ba..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_4.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_4.bm deleted file mode 100644 index e4cc8155b..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_5.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_5.bm deleted file mode 100644 index b94348ce3..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_6.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_6.bm deleted file mode 100644 index 8ec9876c8..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_7.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_7.bm deleted file mode 100644 index 0fa6f4e86..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_8.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_8.bm deleted file mode 100644 index da04546e5..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_9.bm b/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_9.bm deleted file mode 100644 index f1eefa0df..000000000 Binary files a/assets/resources/dolphin/Kuronons_RMCFW_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/Kuronons_RMCFW_128x64/meta.txt b/assets/resources/dolphin/Kuronons_RMCFW_128x64/meta.txt deleted file mode 100644 index 3154d0aef..000000000 --- a/assets/resources/dolphin/Kuronons_RMCFW_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 54 -Active frames: 0 -Frames order: 0 0 0 0 1 1 1 2 2 3 4 4 5 6 7 7 8 8 9 10 10 10 11 11 11 11 11 11 12 12 13 13 14 14 15 15 15 15 15 16 16 17 18 18 18 18 18 18 18 18 18 18 18 18 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L1_Halloween_128x64/frame_0.bm b/assets/resources/dolphin/L1_Halloween_128x64/frame_0.bm deleted file mode 100644 index 2d7dbac04..000000000 Binary files a/assets/resources/dolphin/L1_Halloween_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Halloween_128x64/frame_1.bm b/assets/resources/dolphin/L1_Halloween_128x64/frame_1.bm deleted file mode 100644 index 495c3cc8a..000000000 Binary files a/assets/resources/dolphin/L1_Halloween_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Halloween_128x64/frame_2.bm b/assets/resources/dolphin/L1_Halloween_128x64/frame_2.bm deleted file mode 100644 index 91f2de20e..000000000 Binary files a/assets/resources/dolphin/L1_Halloween_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Halloween_128x64/frame_3.bm b/assets/resources/dolphin/L1_Halloween_128x64/frame_3.bm deleted file mode 100644 index 4a914a294..000000000 Binary files a/assets/resources/dolphin/L1_Halloween_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Halloween_128x64/meta.txt b/assets/resources/dolphin/L1_Halloween_128x64/meta.txt deleted file mode 100644 index 6ff707d12..000000000 --- a/assets/resources/dolphin/L1_Halloween_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 4 -Active frames: 0 -Frames order: 0 1 2 3 -Active cycles: 0 -Frame rate: 3 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_0.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_0.bm deleted file mode 100644 index a3731113d..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_1.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_1.bm deleted file mode 100644 index fc0658364..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_10.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_10.bm deleted file mode 100644 index 04984ed0d..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_11.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_11.bm deleted file mode 100644 index c46aac382..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_12.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_12.bm deleted file mode 100644 index d143a91ec..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_2.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_2.bm deleted file mode 100644 index c1b00421a..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_3.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_3.bm deleted file mode 100644 index 63f759d17..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_4.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_4.bm deleted file mode 100644 index 3f2aee1e5..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_5.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_5.bm deleted file mode 100644 index 2d7a83bdd..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_6.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_6.bm deleted file mode 100644 index 88e6814a1..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_7.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_7.bm deleted file mode 100644 index 32758660c..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_8.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_8.bm deleted file mode 100644 index c43447372..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_9.bm b/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_9.bm deleted file mode 100644 index 103fae14a..000000000 Binary files a/assets/resources/dolphin/L1_Happy_holidays_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Happy_holidays_128x64/meta.txt b/assets/resources/dolphin/L1_Happy_holidays_128x64/meta.txt deleted file mode 100644 index 6c50a40ed..000000000 --- a/assets/resources/dolphin/L1_Happy_holidays_128x64/meta.txt +++ /dev/null @@ -1,23 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 18 -Frames order: 0 1 2 1 0 1 2 1 0 1 2 3 4 5 6 5 4 7 2 8 9 10 11 10 9 10 11 12 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 1 - -Slot: 0 -X: 11 -Y: 19 -Text: HAPPY\nHOLIDAYS! -AlignH: Right -AlignV: Center -StartFrame: 22 -EndFrame: 27 diff --git a/assets/resources/dolphin/L1_New_year_128x64/frame_0.bm b/assets/resources/dolphin/L1_New_year_128x64/frame_0.bm deleted file mode 100644 index 17f53095e..000000000 Binary files a/assets/resources/dolphin/L1_New_year_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_New_year_128x64/frame_1.bm b/assets/resources/dolphin/L1_New_year_128x64/frame_1.bm deleted file mode 100644 index a8c1277fe..000000000 Binary files a/assets/resources/dolphin/L1_New_year_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_New_year_128x64/frame_2.bm b/assets/resources/dolphin/L1_New_year_128x64/frame_2.bm deleted file mode 100644 index ca1fa852a..000000000 Binary files a/assets/resources/dolphin/L1_New_year_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_New_year_128x64/frame_3.bm b/assets/resources/dolphin/L1_New_year_128x64/frame_3.bm deleted file mode 100644 index 4b89c67a6..000000000 Binary files a/assets/resources/dolphin/L1_New_year_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_New_year_128x64/meta.txt b/assets/resources/dolphin/L1_New_year_128x64/meta.txt deleted file mode 100644 index 542392c19..000000000 --- a/assets/resources/dolphin/L1_New_year_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 4 -Active frames: 0 -Frames order: 0 1 2 3 -Active cycles: 0 -Frame rate: 2 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_0.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_0.bm deleted file mode 100644 index 2694219ef..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_1.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_1.bm deleted file mode 100644 index 3c9623d4c..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_10.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_10.bm deleted file mode 100644 index 64a750e95..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_11.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_11.bm deleted file mode 100644 index af1503fef..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_2.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_2.bm deleted file mode 100644 index 13916806f..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_3.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_3.bm deleted file mode 100644 index 751fbc3ef..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_4.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_4.bm deleted file mode 100644 index c1135b467..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_5.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_5.bm deleted file mode 100644 index a4681af98..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_6.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_6.bm deleted file mode 100644 index 36f2d084f..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_7.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_7.bm deleted file mode 100644 index 9759e787d..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_8.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_8.bm deleted file mode 100644 index 244adf310..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/frame_9.bm b/assets/resources/dolphin/L1_Painting_128x64/frame_9.bm deleted file mode 100644 index 99ed50717..000000000 Binary files a/assets/resources/dolphin/L1_Painting_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Painting_128x64/meta.txt b/assets/resources/dolphin/L1_Painting_128x64/meta.txt deleted file mode 100644 index 46528d598..000000000 --- a/assets/resources/dolphin/L1_Painting_128x64/meta.txt +++ /dev/null @@ -1,50 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 9 -Active frames: 13 -Frames order: 0 1 2 3 4 5 2 3 4 10 6 7 8 7 8 7 8 7 8 9 10 11 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 2 - -Slot: 0 -X: 57 -Y: 24 -Text: $20 to put this -AlignH: Left -AlignV: Center -StartFrame: 11 -EndFrame: 14 - -Slot: 0 -X: 57 -Y: 21 -Text: in my blowhole -AlignH: Left -AlignV: Center -StartFrame: 15 -EndFrame: 18 - -Slot: 1 -X: 57 -Y: 24 -Text: How many dicks -AlignH: Left -AlignV: Center -StartFrame: 11 -EndFrame: 14 - -Slot: 0 -X: 57 -Y: 21 -Text: we drawing today? -AlignH: Left -AlignV: Center -StartFrame: 15 -EndFrame: 18 diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_0.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_0.bm deleted file mode 100644 index 37ebe0e15..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_1.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_1.bm deleted file mode 100644 index d2f20b34d..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_10.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_10.bm deleted file mode 100644 index 54878228b..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_2.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_2.bm deleted file mode 100644 index 0914affad..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_3.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_3.bm deleted file mode 100644 index d3fd071e7..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_4.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_4.bm deleted file mode 100644 index 59f3a6715..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_5.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_5.bm deleted file mode 100644 index 2018eac7b..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_6.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_6.bm deleted file mode 100644 index 74070c881..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_7.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_7.bm deleted file mode 100644 index f66bdefcf..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_8.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_8.bm deleted file mode 100644 index c7dd073f6..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_9.bm b/assets/resources/dolphin/L1_Purple_rain_128x64/frame_9.bm deleted file mode 100644 index 7c8e1357a..000000000 Binary files a/assets/resources/dolphin/L1_Purple_rain_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L1_Purple_rain_128x64/meta.txt b/assets/resources/dolphin/L1_Purple_rain_128x64/meta.txt deleted file mode 100644 index c60148050..000000000 --- a/assets/resources/dolphin/L1_Purple_rain_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 11 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_0.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_0.bm deleted file mode 100644 index 8da6b45f0..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_1.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_1.bm deleted file mode 100644 index e9597309a..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_2.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_2.bm deleted file mode 100644 index ebd22d637..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_3.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_3.bm deleted file mode 100644 index 4ac97ced6..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_4.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_4.bm deleted file mode 100644 index 41bcf9e29..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_5.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_5.bm deleted file mode 100644 index d394375f6..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_6.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_6.bm deleted file mode 100644 index 082961555..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_7.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_7.bm deleted file mode 100644 index e5780c17c..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_8.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_8.bm deleted file mode 100644 index 112c38f2f..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_9.bm b/assets/resources/dolphin/L2_FlipperCity_128x64/frame_9.bm deleted file mode 100644 index 3d12a0d0d..000000000 Binary files a/assets/resources/dolphin/L2_FlipperCity_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_FlipperCity_128x64/meta.txt b/assets/resources/dolphin/L2_FlipperCity_128x64/meta.txt deleted file mode 100644 index fdddbdb2e..000000000 --- a/assets/resources/dolphin/L2_FlipperCity_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_0.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_0.bm deleted file mode 100644 index 3c59712a8..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_1.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_1.bm deleted file mode 100644 index af7bc519e..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_10.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_10.bm deleted file mode 100644 index f3628db4c..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_11.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_11.bm deleted file mode 100644 index 215b347b7..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_12.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_12.bm deleted file mode 100644 index f2442be9c..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_13.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_13.bm deleted file mode 100644 index 0e5389fd3..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_14.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_14.bm deleted file mode 100644 index a13cda839..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_15.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_15.bm deleted file mode 100644 index 7129cf103..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_16.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_16.bm deleted file mode 100644 index 12a1eaeb2..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_17.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_17.bm deleted file mode 100644 index 5758af24e..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_18.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_18.bm deleted file mode 100644 index 49d7c170d..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_19.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_19.bm deleted file mode 100644 index 0fe840199..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_19.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_2.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_2.bm deleted file mode 100644 index ca17d190b..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_20.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_20.bm deleted file mode 100644 index 4d42a4679..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_20.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_3.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_3.bm deleted file mode 100644 index 847fa6a94..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_4.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_4.bm deleted file mode 100644 index 57321af8c..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_5.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_5.bm deleted file mode 100644 index 32233b0af..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_6.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_6.bm deleted file mode 100644 index ee2ecbebb..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_7.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_7.bm deleted file mode 100644 index 12d90e652..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_8.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_8.bm deleted file mode 100644 index 21b3d8786..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/frame_9.bm b/assets/resources/dolphin/L2_Wake_up_128x64/frame_9.bm deleted file mode 100644 index c88b734a4..000000000 Binary files a/assets/resources/dolphin/L2_Wake_up_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L2_Wake_up_128x64/meta.txt b/assets/resources/dolphin/L2_Wake_up_128x64/meta.txt deleted file mode 100644 index 8ae3b093d..000000000 --- a/assets/resources/dolphin/L2_Wake_up_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 18 -Frames order: 0 1 0 1 0 1 0 2 3 4 0 5 6 7 8 9 10 11 10 12 13 14 15 16 17 18 19 20 -Active cycles: 1 -Frame rate: 2 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_0.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_0.bm deleted file mode 100644 index fdbf0c922..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_1.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_1.bm deleted file mode 100644 index 159fd5f1b..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_10.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_10.bm deleted file mode 100644 index 465759184..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_11.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_11.bm deleted file mode 100644 index f89baa157..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_2.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_2.bm deleted file mode 100644 index 8c59fc403..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_3.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_3.bm deleted file mode 100644 index 2753b8abb..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_4.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_4.bm deleted file mode 100644 index 25471df39..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_5.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_5.bm deleted file mode 100644 index f4982cafa..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_6.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_6.bm deleted file mode 100644 index d98632563..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_7.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_7.bm deleted file mode 100644 index d93803b89..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_8.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_8.bm deleted file mode 100644 index 5c0b2ae22..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_9.bm b/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_9.bm deleted file mode 100644 index 5d0862439..000000000 Binary files a/assets/resources/dolphin/L3_FlipperMustache_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/L3_FlipperMustache_128x64/meta.txt b/assets/resources/dolphin/L3_FlipperMustache_128x64/meta.txt deleted file mode 100644 index 64de3a3df..000000000 --- a/assets/resources/dolphin/L3_FlipperMustache_128x64/meta.txt +++ /dev/null @@ -1,32 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 10 -Active frames: 2 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 -Active cycles: 8 -Frame rate: 3 -Duration: 3600 -Active cooldown: 7 - -Bubble slots: 1 - -Slot: 0 -X: 60 -Y: 30 -Text: Some hack\nwe made -AlignH: Left -AlignV: Center -StartFrame: 10 -EndFrame: 17 - -Slot: 0 -X: 60 -Y: 30 -Text: It's a firmware\nupgrade! -AlignH: Left -AlignV: Center -StartFrame: 18 -EndFrame: 25 diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_0.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_0.bm deleted file mode 100644 index 26ceb2a03..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_1.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_1.bm deleted file mode 100644 index 40a3d0cc6..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_10.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_10.bm deleted file mode 100644 index 725745f2d..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_11.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_11.bm deleted file mode 100644 index afb3371d1..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_12.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_12.bm deleted file mode 100644 index f44a8eba3..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_13.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_13.bm deleted file mode 100644 index 56edda3ae..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_14.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_14.bm deleted file mode 100644 index dda4a03db..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_15.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_15.bm deleted file mode 100644 index 4cae28ee2..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_16.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_16.bm deleted file mode 100644 index ed734f97a..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_17.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_17.bm deleted file mode 100644 index a1b104b61..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_18.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_18.bm deleted file mode 100644 index c2b5ccfac..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_19.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_19.bm deleted file mode 100644 index 4dbe1f5b2..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_19.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_2.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_2.bm deleted file mode 100644 index f648fa701..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_20.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_20.bm deleted file mode 100644 index 8af9496c6..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_20.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_21.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_21.bm deleted file mode 100644 index d2daa0495..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_21.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_22.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_22.bm deleted file mode 100644 index ce5b37e36..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_22.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_23.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_23.bm deleted file mode 100644 index f5c3d7050..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_23.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_24.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_24.bm deleted file mode 100644 index f63ce2f6f..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_24.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_25.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_25.bm deleted file mode 100644 index 943b552e6..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_25.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_26.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_26.bm deleted file mode 100644 index 9ec485d48..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_26.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_27.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_27.bm deleted file mode 100644 index df5e2342b..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_27.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_28.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_28.bm deleted file mode 100644 index 984d2e10b..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_28.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_29.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_29.bm deleted file mode 100644 index 06a9fee75..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_29.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_3.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_3.bm deleted file mode 100644 index 1916ff3a6..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_30.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_30.bm deleted file mode 100644 index 8d16733aa..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_30.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_31.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_31.bm deleted file mode 100644 index dba885d7c..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_31.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_32.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_32.bm deleted file mode 100644 index e3d15b3dc..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_32.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_33.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_33.bm deleted file mode 100644 index cd0336c4d..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_33.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_34.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_34.bm deleted file mode 100644 index a87519097..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_34.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_35.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_35.bm deleted file mode 100644 index 47652cf77..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_35.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_36.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_36.bm deleted file mode 100644 index 532979664..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_36.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_37.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_37.bm deleted file mode 100644 index 4dc494c77..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_37.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_38.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_38.bm deleted file mode 100644 index a6db87dd0..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_38.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_39.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_39.bm deleted file mode 100644 index f6d79cec8..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_39.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_4.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_4.bm deleted file mode 100644 index 93274b2ae..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_40.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_40.bm deleted file mode 100644 index 74d91212c..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_40.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_41.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_41.bm deleted file mode 100644 index 97bb337be..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_41.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_42.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_42.bm deleted file mode 100644 index 5dcd33048..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_42.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_43.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_43.bm deleted file mode 100644 index e54cacc12..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_43.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_44.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_44.bm deleted file mode 100644 index b163792b1..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_44.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_45.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_45.bm deleted file mode 100644 index 03af60f59..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_45.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_46.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_46.bm deleted file mode 100644 index 9fc20edaf..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_46.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_47.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_47.bm deleted file mode 100644 index ae965264e..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_47.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_48.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_48.bm deleted file mode 100644 index e92578443..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_48.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_49.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_49.bm deleted file mode 100644 index 815a6b069..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_49.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_5.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_5.bm deleted file mode 100644 index 3d094a318..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_6.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_6.bm deleted file mode 100644 index 5939bd84f..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_7.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_7.bm deleted file mode 100644 index 07b44007d..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_8.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_8.bm deleted file mode 100644 index b0708dcbd..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_9.bm b/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_9.bm deleted file mode 100644 index 7f6bea16a..000000000 Binary files a/assets/resources/dolphin/Sasquach_Blaster_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Blaster_128x64/meta.txt b/assets/resources/dolphin/Sasquach_Blaster_128x64/meta.txt deleted file mode 100644 index 4d5cb4433..000000000 --- a/assets/resources/dolphin/Sasquach_Blaster_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 50 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_0.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_0.bm deleted file mode 100644 index ee115ab19..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_1.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_1.bm deleted file mode 100644 index ca21389ec..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_10.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_10.bm deleted file mode 100644 index a88a0578a..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_11.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_11.bm deleted file mode 100644 index 5342ba899..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_12.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_12.bm deleted file mode 100644 index 016cf8b32..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_13.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_13.bm deleted file mode 100644 index 33e451b21..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_14.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_14.bm deleted file mode 100644 index 8aac19457..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_15.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_15.bm deleted file mode 100644 index 132639dd9..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_16.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_16.bm deleted file mode 100644 index d15ee3ee1..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_17.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_17.bm deleted file mode 100644 index c096e9f4f..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_18.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_18.bm deleted file mode 100644 index d8cb209b8..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_19.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_19.bm deleted file mode 100644 index 5320555af..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_19.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_2.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_2.bm deleted file mode 100644 index 3e44f75a3..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_20.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_20.bm deleted file mode 100644 index f6cb2ab49..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_20.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_21.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_21.bm deleted file mode 100644 index 17255bf86..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_21.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_22.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_22.bm deleted file mode 100644 index bad4eaf33..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_22.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_23.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_23.bm deleted file mode 100644 index 823c314b1..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_23.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_24.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_24.bm deleted file mode 100644 index 67ee18638..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_24.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_25.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_25.bm deleted file mode 100644 index 12e861bba..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_25.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_26.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_26.bm deleted file mode 100644 index c95161b2e..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_26.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_27.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_27.bm deleted file mode 100644 index dbf89b5fa..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_27.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_28.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_28.bm deleted file mode 100644 index 640f6526e..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_28.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_29.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_29.bm deleted file mode 100644 index 5c80fd63e..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_29.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_3.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_3.bm deleted file mode 100644 index 4a7cf81d4..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_30.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_30.bm deleted file mode 100644 index a3cadf71a..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_30.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_31.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_31.bm deleted file mode 100644 index 00601ce8b..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_31.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_32.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_32.bm deleted file mode 100644 index 9b1866578..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_32.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_33.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_33.bm deleted file mode 100644 index 0997bdd3f..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_33.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_34.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_34.bm deleted file mode 100644 index fa0599e51..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_34.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_35.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_35.bm deleted file mode 100644 index 2f916d472..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_35.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_36.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_36.bm deleted file mode 100644 index a966dd13c..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_36.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_37.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_37.bm deleted file mode 100644 index f8b0203c7..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_37.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_38.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_38.bm deleted file mode 100644 index 195884f75..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_38.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_39.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_39.bm deleted file mode 100644 index a559aec21..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_39.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_4.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_4.bm deleted file mode 100644 index 9630d6484..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_40.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_40.bm deleted file mode 100644 index 3507a9a74..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_40.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_41.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_41.bm deleted file mode 100644 index 4e611bd7c..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_41.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_42.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_42.bm deleted file mode 100644 index bc5399a3a..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_42.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_43.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_43.bm deleted file mode 100644 index 9805e32c8..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_43.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_44.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_44.bm deleted file mode 100644 index a1d6f0509..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_44.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_45.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_45.bm deleted file mode 100644 index 3e8c056ab..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_45.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_46.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_46.bm deleted file mode 100644 index 2373047f6..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_46.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_5.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_5.bm deleted file mode 100644 index c95edacf3..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_6.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_6.bm deleted file mode 100644 index acba2a400..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_7.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_7.bm deleted file mode 100644 index bce38abf3..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_8.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_8.bm deleted file mode 100644 index 8625700a6..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_9.bm b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_9.bm deleted file mode 100644 index 1c0856724..000000000 Binary files a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/meta.txt b/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/meta.txt deleted file mode 100644 index cb006d0e0..000000000 --- a/assets/resources/dolphin/Sasquach_CloudG0ku_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 47 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 5 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_0.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_0.bm deleted file mode 100644 index 3ef2af522..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_1.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_1.bm deleted file mode 100644 index 4cb812985..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_10.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_10.bm deleted file mode 100644 index 031a6ca5c..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_11.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_11.bm deleted file mode 100644 index 0a8df32ba..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_12.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_12.bm deleted file mode 100644 index eec04c0a4..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_13.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_13.bm deleted file mode 100644 index 9e288b113..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_14.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_14.bm deleted file mode 100644 index 337143542..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_15.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_15.bm deleted file mode 100644 index a02d99b99..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_16.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_16.bm deleted file mode 100644 index b5d3c43d5..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_17.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_17.bm deleted file mode 100644 index eb1a572b1..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_18.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_18.bm deleted file mode 100644 index 1b2ebc4df..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_19.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_19.bm deleted file mode 100644 index c85504e90..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_19.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_2.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_2.bm deleted file mode 100644 index b93e56a4b..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_20.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_20.bm deleted file mode 100644 index 9cd1e8c9b..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_20.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_21.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_21.bm deleted file mode 100644 index da849b198..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_21.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_22.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_22.bm deleted file mode 100644 index ec1b7ca21..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_22.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_23.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_23.bm deleted file mode 100644 index 1c074ba84..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_23.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_24.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_24.bm deleted file mode 100644 index e8ed6353d..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_24.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_25.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_25.bm deleted file mode 100644 index 2acd45696..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_25.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_26.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_26.bm deleted file mode 100644 index 37a8b4d72..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_26.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_27.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_27.bm deleted file mode 100644 index 97b556288..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_27.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_28.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_28.bm deleted file mode 100644 index 705f2e8c1..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_28.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_29.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_29.bm deleted file mode 100644 index 27fc18178..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_29.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_3.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_3.bm deleted file mode 100644 index 1e3416feb..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_4.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_4.bm deleted file mode 100644 index 7fdaabade..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_5.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_5.bm deleted file mode 100644 index a5648e81a..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_6.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_6.bm deleted file mode 100644 index df22b4354..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_7.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_7.bm deleted file mode 100644 index 521c97586..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_8.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_8.bm deleted file mode 100644 index ffa810eea..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_9.bm b/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_9.bm deleted file mode 100644 index 60e43fcf5..000000000 Binary files a/assets/resources/dolphin/Sasquach_Narut0_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_Narut0_128x64/meta.txt b/assets/resources/dolphin/Sasquach_Narut0_128x64/meta.txt deleted file mode 100644 index 7e7e55b26..000000000 --- a/assets/resources/dolphin/Sasquach_Narut0_128x64/meta.txt +++ /dev/null @@ -1,14 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 30 -Active frames: 0 -Frames order: 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 -Active cycles: 0 -Frame rate: 6 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 0 diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_0.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_0.bm deleted file mode 100644 index 12674bd19..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_0.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_1.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_1.bm deleted file mode 100644 index ea8fae0a3..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_1.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_10.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_10.bm deleted file mode 100644 index 303d4ed82..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_10.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_11.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_11.bm deleted file mode 100644 index 3a9d3f9c2..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_11.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_12.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_12.bm deleted file mode 100644 index 75ad19937..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_12.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_13.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_13.bm deleted file mode 100644 index 03d3df217..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_13.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_14.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_14.bm deleted file mode 100644 index 999e6b95a..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_14.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_15.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_15.bm deleted file mode 100644 index 10cd983f9..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_15.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_16.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_16.bm deleted file mode 100644 index 4ad45112a..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_16.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_17.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_17.bm deleted file mode 100644 index b33f2d445..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_17.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_18.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_18.bm deleted file mode 100644 index d7c90fc26..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_18.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_19.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_19.bm deleted file mode 100644 index 20a15ba8f..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_19.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_2.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_2.bm deleted file mode 100644 index 17e73e2d6..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_2.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_20.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_20.bm deleted file mode 100644 index 13c97c09b..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_20.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_21.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_21.bm deleted file mode 100644 index 9268dc239..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_21.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_22.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_22.bm deleted file mode 100644 index 20493b321..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_22.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_23.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_23.bm deleted file mode 100644 index 9268dc239..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_23.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_24.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_24.bm deleted file mode 100644 index 75a32c516..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_24.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_25.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_25.bm deleted file mode 100644 index 00c94f05a..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_25.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_26.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_26.bm deleted file mode 100644 index c56e9119d..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_26.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_27.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_27.bm deleted file mode 100644 index 6ffc39466..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_27.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_28.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_28.bm deleted file mode 100644 index 2bd22fd43..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_28.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_29.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_29.bm deleted file mode 100644 index 81cf34ff5..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_29.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_3.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_3.bm deleted file mode 100644 index 0b4041fba..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_3.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_30.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_30.bm deleted file mode 100644 index 4b4b5c37f..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_30.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_31.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_31.bm deleted file mode 100644 index 9e7f4c523..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_31.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_32.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_32.bm deleted file mode 100644 index f483cb0cd..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_32.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_33.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_33.bm deleted file mode 100644 index 29fe3464d..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_33.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_34.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_34.bm deleted file mode 100644 index c28ea59e0..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_34.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_35.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_35.bm deleted file mode 100644 index 41cb9fb8e..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_35.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_36.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_36.bm deleted file mode 100644 index 1451bc996..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_36.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_37.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_37.bm deleted file mode 100644 index eb3d333c3..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_37.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_38.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_38.bm deleted file mode 100644 index b063f4e1c..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_38.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_4.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_4.bm deleted file mode 100644 index 9fa032cbb..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_4.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_5.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_5.bm deleted file mode 100644 index 635ff27b6..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_5.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_6.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_6.bm deleted file mode 100644 index dc89913ec..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_6.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_7.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_7.bm deleted file mode 100644 index bc7886b9d..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_7.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_8.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_8.bm deleted file mode 100644 index 627c71667..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_8.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_9.bm b/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_9.bm deleted file mode 100644 index 175824c2d..000000000 Binary files a/assets/resources/dolphin/Sasquach_RMCF_128x64/frame_9.bm and /dev/null differ diff --git a/assets/resources/dolphin/Sasquach_RMCF_128x64/meta.txt b/assets/resources/dolphin/Sasquach_RMCF_128x64/meta.txt deleted file mode 100644 index b6b3fdf3e..000000000 --- a/assets/resources/dolphin/Sasquach_RMCF_128x64/meta.txt +++ /dev/null @@ -1,23 +0,0 @@ -Filetype: Flipper Animation -Version: 1 - -Width: 128 -Height: 64 -Passive frames: 100 -Active frames: 0 -Frames order: 0 1 2 3 4 5 6 7 8 9 10 11 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 13 14 15 16 17 18 17 18 17 18 19 20 19 20 19 20 19 20 19 20 21 22 21 22 22 22 23 24 25 26 27 28 29 30 31 32 33 0 34 35 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 37 38 -Active cycles: 0 -Frame rate: 4 -Duration: 3600 -Active cooldown: 0 - -Bubble slots: 1 - -Slot: 0 -X: 33 -Y: 35 -Text: I Know \nKung Fu -AlignH: Left -AlignV: Top -StartFrame: 14 -EndFrame: 20 diff --git a/assets/resources/dolphin/Skynet/frame_0.bm b/assets/resources/dolphin/Skynet/frame_0.bm new file mode 100644 index 000000000..5c55b7cdb Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_0.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_1.bm b/assets/resources/dolphin/Skynet/frame_1.bm new file mode 100644 index 000000000..1ae586f6b Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_1.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_10.bm b/assets/resources/dolphin/Skynet/frame_10.bm new file mode 100644 index 000000000..b79abd18f Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_10.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_11.bm b/assets/resources/dolphin/Skynet/frame_11.bm new file mode 100644 index 000000000..635055216 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_11.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_12.bm b/assets/resources/dolphin/Skynet/frame_12.bm new file mode 100644 index 000000000..604814a0f Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_12.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_13.bm b/assets/resources/dolphin/Skynet/frame_13.bm new file mode 100644 index 000000000..f8cdd4f69 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_13.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_14.bm b/assets/resources/dolphin/Skynet/frame_14.bm new file mode 100644 index 000000000..5dd74fb55 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_14.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_15.bm b/assets/resources/dolphin/Skynet/frame_15.bm new file mode 100644 index 000000000..5f2145816 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_15.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_16.bm b/assets/resources/dolphin/Skynet/frame_16.bm new file mode 100644 index 000000000..c427417ed Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_16.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_17.bm b/assets/resources/dolphin/Skynet/frame_17.bm new file mode 100644 index 000000000..a46d0ec08 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_17.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_18.bm b/assets/resources/dolphin/Skynet/frame_18.bm new file mode 100644 index 000000000..5df1c40f2 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_18.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_19.bm b/assets/resources/dolphin/Skynet/frame_19.bm new file mode 100644 index 000000000..3a7516202 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_19.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_2.bm b/assets/resources/dolphin/Skynet/frame_2.bm new file mode 100644 index 000000000..9047776ba Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_2.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_20.bm b/assets/resources/dolphin/Skynet/frame_20.bm new file mode 100644 index 000000000..cbae67bf1 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_20.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_21.bm b/assets/resources/dolphin/Skynet/frame_21.bm new file mode 100644 index 000000000..d07c80c62 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_21.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_22.bm b/assets/resources/dolphin/Skynet/frame_22.bm new file mode 100644 index 000000000..a3d94c368 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_22.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_23.bm b/assets/resources/dolphin/Skynet/frame_23.bm new file mode 100644 index 000000000..4c4314247 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_23.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_24.bm b/assets/resources/dolphin/Skynet/frame_24.bm new file mode 100644 index 000000000..def0f6e72 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_24.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_25.bm b/assets/resources/dolphin/Skynet/frame_25.bm new file mode 100644 index 000000000..5888a6036 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_25.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_26.bm b/assets/resources/dolphin/Skynet/frame_26.bm new file mode 100644 index 000000000..cc2b0d44e Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_26.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_27.bm b/assets/resources/dolphin/Skynet/frame_27.bm new file mode 100644 index 000000000..edf23912f Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_27.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_28.bm b/assets/resources/dolphin/Skynet/frame_28.bm new file mode 100644 index 000000000..0f41c2d36 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_28.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_29.bm b/assets/resources/dolphin/Skynet/frame_29.bm new file mode 100644 index 000000000..ba9815588 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_29.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_3.bm b/assets/resources/dolphin/Skynet/frame_3.bm new file mode 100644 index 000000000..52fcfde05 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_3.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_30.bm b/assets/resources/dolphin/Skynet/frame_30.bm new file mode 100644 index 000000000..d16564385 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_30.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_4.bm b/assets/resources/dolphin/Skynet/frame_4.bm new file mode 100644 index 000000000..92c7bbc8d Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_4.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_5.bm b/assets/resources/dolphin/Skynet/frame_5.bm new file mode 100644 index 000000000..bf2e7f118 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_5.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_6.bm b/assets/resources/dolphin/Skynet/frame_6.bm new file mode 100644 index 000000000..ab0ea10ae Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_6.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_7.bm b/assets/resources/dolphin/Skynet/frame_7.bm new file mode 100644 index 000000000..e9d2b83bf Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_7.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_8.bm b/assets/resources/dolphin/Skynet/frame_8.bm new file mode 100644 index 000000000..ce8fe8eca Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_8.bm differ diff --git a/assets/resources/dolphin/Skynet/frame_9.bm b/assets/resources/dolphin/Skynet/frame_9.bm new file mode 100644 index 000000000..cfba8d2a0 Binary files /dev/null and b/assets/resources/dolphin/Skynet/frame_9.bm differ diff --git a/assets/resources/dolphin/Skynet/meta.txt b/assets/resources/dolphin/Skynet/meta.txt new file mode 100644 index 000000000..9a46da82d --- /dev/null +++ b/assets/resources/dolphin/Skynet/meta.txt @@ -0,0 +1,14 @@ +Filetype: Flipper Animation +Version: 1 + +Width: 128 +Height: 64 +Passive frames: 6 +Active frames: 48 +Frames order: 0 0 0 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 21 22 23 24 25 26 27 28 29 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 +Active cycles: 1 +Frame rate: 8 +Duration: 3600 +Active cooldown: 1 + +Bubble slots: 0 diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_0.bm b/assets/resources/dolphin/fireplace/frame_0.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_0.bm rename to assets/resources/dolphin/fireplace/frame_0.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_1.bm b/assets/resources/dolphin/fireplace/frame_1.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_1.bm rename to assets/resources/dolphin/fireplace/frame_1.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_2.bm b/assets/resources/dolphin/fireplace/frame_2.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_2.bm rename to assets/resources/dolphin/fireplace/frame_2.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_3.bm b/assets/resources/dolphin/fireplace/frame_3.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_3.bm rename to assets/resources/dolphin/fireplace/frame_3.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_4.bm b/assets/resources/dolphin/fireplace/frame_4.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_4.bm rename to assets/resources/dolphin/fireplace/frame_4.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_5.bm b/assets/resources/dolphin/fireplace/frame_5.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_5.bm rename to assets/resources/dolphin/fireplace/frame_5.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_6.bm b/assets/resources/dolphin/fireplace/frame_6.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_6.bm rename to assets/resources/dolphin/fireplace/frame_6.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/frame_7.bm b/assets/resources/dolphin/fireplace/frame_7.bm similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/frame_7.bm rename to assets/resources/dolphin/fireplace/frame_7.bm diff --git a/assets/resources/dolphin/L3_Fireplace_128x64/meta.txt b/assets/resources/dolphin/fireplace/meta.txt similarity index 100% rename from assets/resources/dolphin/L3_Fireplace_128x64/meta.txt rename to assets/resources/dolphin/fireplace/meta.txt diff --git a/assets/resources/dolphin/manifest.txt b/assets/resources/dolphin/manifest.txt index 65eef70d5..e34c7b451 100644 --- a/assets/resources/dolphin/manifest.txt +++ b/assets/resources/dolphin/manifest.txt @@ -1,107 +1,23 @@ Filetype: Flipper Animation Manifest Version: 1 -Name: Kuronons_RMCFW_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Sasquach_Blaster_128x64 +Name: Skynet Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 +Weight: 33 -Name: Sasquach_CloudG0ku_128x64 +Name: fireplace Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 +Weight: 33 -Name: Sasquach_Narut0_128x64 +Name: mods Min butthurt: 0 Max butthurt: 14 Min level: 1 Max level: 30 -Weight: 7 - -Name: Sasquach_RMCF_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: L1_Purple_rain_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Happy_holidays_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 14 - -Name: L1_New_year_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 14 - -Name: L2_FlipperCity_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: L3_FlipperMustache_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 7 - -Name: L3_Fireplace_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 7 - -Name: L1_Mods_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Painting_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L2_Wake_up_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Halloween_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 +Weight: 33 diff --git a/assets/resources/dolphin/manifest.txt.exampleRM b/assets/resources/dolphin/manifest.txt.exampleRM deleted file mode 100644 index e08d267c3..000000000 --- a/assets/resources/dolphin/manifest.txt.exampleRM +++ /dev/null @@ -1,373 +0,0 @@ -Filetype: Flipper Animation Manifest -Version: 1 - -Name: RM_Sail0rM00n_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_BulmFlash_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_Kaz0ku_Haha_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_P3achRun_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_AikaZer0_2_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_AikaZer0_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: RM_Z3lda_0h_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 18 -Max level: 30 -Weight: 0 - -Name: Haseo_Sharingan_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Sasquach_Blaster_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Sasquach_Narut0_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_R0shi_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Tardi5_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Haseo_Lufy_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Haseo_G0ku_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Haseo_Mug1wara_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Init_D_Water_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Hexadecimal_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Kirbs_Confused_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Kirbs_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_OP_G3ar4_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_M3gamanZ3r0_Battle_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: RM_Kam3ham3ha_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: On3_Pi3ce_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Sasquach_G0ku_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Sasquach_CloudG0ku_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Sasquach_RMCF_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Kuronons_RMCFW_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: L3_Fireplace_128x64 -Min butthurt: 0 -Max butthurt: 13 -Min level: 10 -Max level: 30 -Weight: 7 - -Name: L2_FlipperCity_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 7 - -Name: Haseo_80s_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: Sasquach_D1g1talRa1n_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_Purple_rain_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 7 - -Name: L1_New_year_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 14 - -Name: FelixTwoTone_Veemon_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 5 - -Name: L1_NyanCat_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 - -Name: Sasquach_StickFight_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: MjK_Starfield_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: STOPOXY_TLOZ_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 - -Name: STOPOXY_WOT_HEART_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 - -Name: L1_P0liwhirl_128x51 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 4 - -Name: L1_DJ_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: L1_Agumon_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: L1_Mew_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: MjK_Akira_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: L1_Rickroll_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 2 - -Name: L2_Hacking_pc_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 4 - -Name: L3_Hijack_radio_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 4 - -Name: L3_Lab_research_128x54 -Min butthurt: 0 -Max butthurt: 14 -Min level: 3 -Max level: 30 -Weight: 4 - -Name: L2_Soldering_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 2 -Max level: 30 -Weight: 4 - -Name: L1_Waves_128x50 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: L1_Read_books_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 3 - -Name: L1_Painting_128x64 -Min butthurt: 0 -Max butthurt: 14 -Min level: 1 -Max level: 30 -Weight: 5 - -Name: L1_Halloween_128x64 -Min butthurt: 0 -Max butthurt: 13 -Min level: 1 -Max level: 3 -Weight: 8 diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_0.bm b/assets/resources/dolphin/mods/frame_0.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_0.bm rename to assets/resources/dolphin/mods/frame_0.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_1.bm b/assets/resources/dolphin/mods/frame_1.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_1.bm rename to assets/resources/dolphin/mods/frame_1.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_10.bm b/assets/resources/dolphin/mods/frame_10.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_10.bm rename to assets/resources/dolphin/mods/frame_10.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_11.bm b/assets/resources/dolphin/mods/frame_11.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_11.bm rename to assets/resources/dolphin/mods/frame_11.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_12.bm b/assets/resources/dolphin/mods/frame_12.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_12.bm rename to assets/resources/dolphin/mods/frame_12.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_13.bm b/assets/resources/dolphin/mods/frame_13.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_13.bm rename to assets/resources/dolphin/mods/frame_13.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_14.bm b/assets/resources/dolphin/mods/frame_14.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_14.bm rename to assets/resources/dolphin/mods/frame_14.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_15.bm b/assets/resources/dolphin/mods/frame_15.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_15.bm rename to assets/resources/dolphin/mods/frame_15.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_16.bm b/assets/resources/dolphin/mods/frame_16.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_16.bm rename to assets/resources/dolphin/mods/frame_16.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_17.bm b/assets/resources/dolphin/mods/frame_17.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_17.bm rename to assets/resources/dolphin/mods/frame_17.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_18.bm b/assets/resources/dolphin/mods/frame_18.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_18.bm rename to assets/resources/dolphin/mods/frame_18.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_19.bm b/assets/resources/dolphin/mods/frame_19.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_19.bm rename to assets/resources/dolphin/mods/frame_19.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_2.bm b/assets/resources/dolphin/mods/frame_2.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_2.bm rename to assets/resources/dolphin/mods/frame_2.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_20.bm b/assets/resources/dolphin/mods/frame_20.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_20.bm rename to assets/resources/dolphin/mods/frame_20.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_21.bm b/assets/resources/dolphin/mods/frame_21.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_21.bm rename to assets/resources/dolphin/mods/frame_21.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_22.bm b/assets/resources/dolphin/mods/frame_22.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_22.bm rename to assets/resources/dolphin/mods/frame_22.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_23.bm b/assets/resources/dolphin/mods/frame_23.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_23.bm rename to assets/resources/dolphin/mods/frame_23.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_24.bm b/assets/resources/dolphin/mods/frame_24.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_24.bm rename to assets/resources/dolphin/mods/frame_24.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_25.bm b/assets/resources/dolphin/mods/frame_25.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_25.bm rename to assets/resources/dolphin/mods/frame_25.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_26.bm b/assets/resources/dolphin/mods/frame_26.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_26.bm rename to assets/resources/dolphin/mods/frame_26.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_27.bm b/assets/resources/dolphin/mods/frame_27.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_27.bm rename to assets/resources/dolphin/mods/frame_27.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_28.bm b/assets/resources/dolphin/mods/frame_28.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_28.bm rename to assets/resources/dolphin/mods/frame_28.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_29.bm b/assets/resources/dolphin/mods/frame_29.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_29.bm rename to assets/resources/dolphin/mods/frame_29.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_3.bm b/assets/resources/dolphin/mods/frame_3.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_3.bm rename to assets/resources/dolphin/mods/frame_3.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_30.bm b/assets/resources/dolphin/mods/frame_30.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_30.bm rename to assets/resources/dolphin/mods/frame_30.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_31.bm b/assets/resources/dolphin/mods/frame_31.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_31.bm rename to assets/resources/dolphin/mods/frame_31.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_32.bm b/assets/resources/dolphin/mods/frame_32.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_32.bm rename to assets/resources/dolphin/mods/frame_32.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_33.bm b/assets/resources/dolphin/mods/frame_33.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_33.bm rename to assets/resources/dolphin/mods/frame_33.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_34.bm b/assets/resources/dolphin/mods/frame_34.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_34.bm rename to assets/resources/dolphin/mods/frame_34.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_35.bm b/assets/resources/dolphin/mods/frame_35.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_35.bm rename to assets/resources/dolphin/mods/frame_35.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_36.bm b/assets/resources/dolphin/mods/frame_36.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_36.bm rename to assets/resources/dolphin/mods/frame_36.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_37.bm b/assets/resources/dolphin/mods/frame_37.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_37.bm rename to assets/resources/dolphin/mods/frame_37.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_38.bm b/assets/resources/dolphin/mods/frame_38.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_38.bm rename to assets/resources/dolphin/mods/frame_38.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_39.bm b/assets/resources/dolphin/mods/frame_39.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_39.bm rename to assets/resources/dolphin/mods/frame_39.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_4.bm b/assets/resources/dolphin/mods/frame_4.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_4.bm rename to assets/resources/dolphin/mods/frame_4.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_40.bm b/assets/resources/dolphin/mods/frame_40.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_40.bm rename to assets/resources/dolphin/mods/frame_40.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_5.bm b/assets/resources/dolphin/mods/frame_5.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_5.bm rename to assets/resources/dolphin/mods/frame_5.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_6.bm b/assets/resources/dolphin/mods/frame_6.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_6.bm rename to assets/resources/dolphin/mods/frame_6.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_7.bm b/assets/resources/dolphin/mods/frame_7.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_7.bm rename to assets/resources/dolphin/mods/frame_7.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_8.bm b/assets/resources/dolphin/mods/frame_8.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_8.bm rename to assets/resources/dolphin/mods/frame_8.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/frame_9.bm b/assets/resources/dolphin/mods/frame_9.bm similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/frame_9.bm rename to assets/resources/dolphin/mods/frame_9.bm diff --git a/assets/resources/dolphin/L1_Mods_128x64/meta.txt b/assets/resources/dolphin/mods/meta.txt similarity index 100% rename from assets/resources/dolphin/L1_Mods_128x64/meta.txt rename to assets/resources/dolphin/mods/meta.txt diff --git a/assets/slideshow/update_default/frame_00.png b/assets/slideshow/update_default/frame_00.png index fa31c8bd5..f9e18c664 100644 Binary files a/assets/slideshow/update_default/frame_00.png and b/assets/slideshow/update_default/frame_00.png differ diff --git a/assets/slideshow/update_default/frame_01.png b/assets/slideshow/update_default/frame_01.png deleted file mode 100644 index 9a123d1bc..000000000 Binary files a/assets/slideshow/update_default/frame_01.png and /dev/null differ diff --git a/fbt_options.py b/fbt_options.py index dd9987972..d642cc647 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -14,7 +14,7 @@ DEBUG = 0 # Suffix to add to files when building distribution # If OS environment has DIST_SUFFIX set, it will be used instead -DIST_SUFFIX = "RM420FAP" +DIST_SUFFIX = "CC_CL-0003" # Coprocessor firmware COPRO_OB_DATA = "scripts/ob.data"