PICSimLab - Programmable IC Simulator Laboratory 0.9.3
PICSimLab - API
Loading...
Searching...
No Matches
input_MPU6050.h
1/* ########################################################################
2
3 PICSimLab - Programmable IC Simulator Laboratory
4
5 ########################################################################
6
7 Copyright (c) : 2020-2026 Luis Claudio GambĂ´a Lopes <lcgamboa@yahoo.com>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 For e-mail suggestions : lcgamboa@yahoo.com
24 ######################################################################## */
25
26#ifndef PART_MPU6050_H
27#define PART_MPU6050_H
28
29#include "../lib/part.h"
30
31#include "../devices/sen_mpu6050.h"
32
33#define PART_MPU6050_Name "MPU6050"
34
35class cpart_MPU6050 : public part {
36public:
37 std::string GetAboutInfo(void) override { return "L.C. Gamboa \n <lcgamboa@yahoo.com>"; };
38 cpart_MPU6050(const unsigned x, const unsigned y, const char* name, const char* type, board* pboard_,
39 const int id_);
40 ~cpart_MPU6050(void);
41 void DrawOutput(const unsigned int index) override;
42 void PreProcess(void) override;
43 void Process(void) override;
44 void PostProcess(void) override;
45 void OnMouseButtonPress(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y,
46 unsigned int state) override;
47 void OnMouseButtonRelease(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y,
48 unsigned int state) override;
49 void OnMouseMove(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y,
50 unsigned int state) override;
51 void ConfigurePropertiesWindow(void) override;
52 void ReadPropertiesWindow(void) override;
53 int PreferencesNumberFields(void) override { return 6; };
54 std::string WritePreferences(void) override;
55 int ReadPreferences(std::string value) override;
56 unsigned short GetInputId(char* name) override;
57 unsigned short GetOutputId(char* name) override;
58 void setMpuReg(unsigned char addr, unsigned char val);
59 unsigned char getValues(unsigned char addr);
60
61private:
62 void RegisterRemoteControl(void) override;
63 unsigned char mpu_pins[6];
64 mpu6050_t mpu;
65 unsigned char active[6];
66 double asens;
67 double gsens;
68};
69
70#endif /* PART_MPU6050_H */
Board class.
Definition board.h:114
Definition input_MPU6050.h:35
void DrawOutput(const unsigned int index) override
Called to draw every output.
Definition input_MPU6050.cc:106
void ConfigurePropertiesWindow(void) override
Called to configure the properties window.
Definition input_MPU6050.cc:254
void OnMouseMove(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event handler on the part.
Definition input_MPU6050.cc:474
void OnMouseButtonPress(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event handler on the part.
Definition input_MPU6050.cc:388
int ReadPreferences(std::string value) override
Called whe configuration file load preferences, return the number of preferences processed.
Definition input_MPU6050.cc:246
int PreferencesNumberFields(void) override
Return the number of fields in preferences.
Definition input_MPU6050.h:53
void PreProcess(void) override
Called every start of CPU process.
Definition input_MPU6050.cc:272
void Process(void) override
Called every CPU step.
Definition input_MPU6050.cc:299
void ReadPropertiesWindow(void) override
Called when properties window close.
Definition input_MPU6050.cc:263
std::string GetAboutInfo(void) override
Return the about information of part.
Definition input_MPU6050.h:37
void OnMouseButtonRelease(unsigned int inputId, unsigned int button, unsigned int x, unsigned int y, unsigned int state) override
Event handler on the part.
Definition input_MPU6050.cc:444
void RegisterRemoteControl(void) override
Register remote control variables.
Definition input_MPU6050.cc:79
std::string WritePreferences(void) override
Called to save part preferences in configuration file.
Definition input_MPU6050.cc:237
unsigned short GetOutputId(char *name) override
return the output ids numbers of names used in output map
Definition input_MPU6050.cc:202
unsigned short GetInputId(char *name) override
return the input ids numbers of names used in input map
Definition input_MPU6050.cc:184
void PostProcess(void) override
Called every end of CPU process.
Definition input_MPU6050.cc:307
part(const unsigned x, const unsigned y, const char *name, const char *type, board *pboard_, const int id_, const int fsize=8)
Called once on part creation.
Definition part.cc:30
Definition sen_mpu6050.h:28