-
Notifications
You must be signed in to change notification settings - Fork 0
/
U_Adjust.cpp
197 lines (155 loc) · 6.66 KB
/
U_Adjust.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "U_Adjust.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tpanel_adjust_form *panel_adjust_form;
#include "send_slider.h" //thread
#include "comm.h"
TScrollBar *_pScrollBar;
//---------------------------------------------------------------------------
__fastcall Tpanel_adjust_form::Tpanel_adjust_form(TComponent* Owner)
: TForm(Owner)
{
//TSend_Slider *psend_slider_thread;
//psend_slider_thread = new TSend_Slider(false);
_slide_type = 1;
hComm = Open_Comm("COM1");
if(hComm == NULL)
ShowMessage("can not open com1");
TScrollBar *pScrollBar_group[] = {ScrollBar9, ScrollBar10, ScrollBar1, ScrollBar2, ScrollBar3 };
///////////////////////////////////////////////////////
for(int i=0; i<5;i++)
{
pScrollBar_group[i]->SmallChange =1 ;
pScrollBar_group[i]->Max =100;
pScrollBar_group[i]->Min =1;
}
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Scroll_Bar1_Change()
{
//TScrollBar *pScrollBar = _pScroll_bar;;
//_pScroll_bar = NULL;
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button1Click(TObject *Sender)
{
char buf[800] ;
DWORD write_transfered, dwBytesRead;
AnsiString str;
AnsiString str_group[] = { " \> /sys/class/video/brightness\r\n",
" \> /sys/class/video/contrast\r\n",
" \> /sys/class/video/saturation_hue\r\n",
" \> /sys/class/video/saturation_hue\r\n",
" \> /sys/class/video/brightness\r\n"};;
TScrollBar *pScrollBar_group[] = {ScrollBar9, ScrollBar10, ScrollBar1, ScrollBar2, ScrollBar3 };
int i =0;
///////////////////////////////////////////////////////
for(i=0; i<5;i++)
{
if(pScrollBar_group[i] == _pScrollBar)
break;
}
if(hComm != NULL)
{
str = "echo " + IntToStr( (_pScrollBar->Position -50)*2)+ str_group[i];
//memcpy(buf, Edit1->Text.c_str(), Edit1->Text.Length());
memcpy(buf, str.c_str(), str.Length());
WriteFile(hComm, buf , str.Length(), &write_transfered, NULL);
Edit2->Text = IntToStr(write_transfered);
//buf[0] ='\n';
//buf[1] = 0;
//WriteFile(hComm, buf , 2, &write_transfered, NULL);
//replace(buf, '@',' ', dwBytesRead);
//replace(buf, '^',' ', dwBytesRead);
ReadFile(hComm, buf, 800, &dwBytesRead, NULL);
Edit3->Text = IntToStr(dwBytesRead);
if(dwBytesRead)
{
str.sprintf( "%s",(char*)buf);
m_get_data->Lines->Add(str);
}
}
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button2Click(TObject *Sender)
{
AnsiString str= "COM1";
hComm = Open_Comm(str);
if(hComm == NULL)
ShowMessage("can not open " + str);
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button3Click(TObject *Sender)
{
char buf[] ="echo 99 > /sys\/class\/video\/brightness";
DWORD write_transfered;
if(hComm != NULL)
{
WriteFile(hComm, &buf, 200, &write_transfered, NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::ScrollBar9Change(TObject *Sender)
{
TScrollBar *pScrollBar = (TScrollBar *)Sender;
TScrollBar *pScrollBar_group[] = {ScrollBar9, ScrollBar10, ScrollBar1, ScrollBar2, ScrollBar3 };
TEdit *pEdit[] = {Edit4, Edit5, Edit6, Edit7, Edit10};;
int data=pScrollBar->Position ;
_pScrollBar = pScrollBar;
///////////////////////////////////////////////////////
for(int i=0; i<5;i++)
{
if( pScrollBar == pScrollBar_group[i] )
{
pEdit[i]->Text = IntToStr(pScrollBar->Position);
Button1Click(this);
}
}
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button6Click(TObject *Sender)
{
char buf[800] ;
DWORD write_transfered, dwBytesRead;
AnsiString str;
if(hComm != NULL)
{
str = "cat /sys/class/video/brightness\r\n";
//memcpy(buf, Edit1->Text.c_str(), Edit1->Text.Length());
memcpy(buf, str.c_str(), str.Length());
WriteFile(hComm, buf , Edit1->Text.Length(), &write_transfered, NULL);
Edit2->Text = IntToStr(write_transfered);
ReadFile(hComm, buf, 800, &dwBytesRead, NULL);
Edit3->Text = IntToStr(dwBytesRead);
if(dwBytesRead)
{
str.sprintf( "%s",(char*)buf);
m_get_data->Lines->Add(str);
}
}
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button5Click(TObject *Sender)
{
// cat /sys/class/video/axis
AnsiString str = "cat /sys/class/video/axis";
str = write_command_line(hComm, "cat /sys/class/video/axis");
panel_adjust_form->m_get_data->Lines->Add(str);
}
//---------------------------------------------------------------------------
void __fastcall Tpanel_adjust_form::Button4Click(TObject *Sender)
{
// echo 1 > /sys/class/video/screen_mode
// echo h-start v-start h-end v-end > /sys/class/video/axis
AnsiString str ;
str = write_command_line(hComm, "echo 1 > /sys/class/video/screen_mode");
panel_adjust_form->m_get_data->Lines->Add(str);
str = "echo " + Edit8->Text + " " + Edit9->Text + " " + Edit11->Text + " " + Edit12->Text + " > /sys/class/video/axis";
str = write_command_line(hComm, str);
panel_adjust_form->m_get_data->Lines->Add(str);
}
//---------------------------------------------------------------------------