Related
I'd like to know how i can update object in array.
I asked this question before,
and I got the hint at the moment but i can't still figure it out how to update x and y ,
so here is my piece code :
const [data, setdata] = useState([
{ x: 1, y: 2 },
{ x: 1, y: 2 },
{ x: 1, y: 2 },
]);
const x= [3, 4, 5, 6, 7, 8, 9];
const y =[ 1,2,3,4,6,7];
const updateX = () => {
setdata((data) => data.map((d, i) => ({ ...d, x: newData[i] })));
setdata((data) => data.map((d, i) => ({ ...d, y: newData[i] })))
};
/////result ///
{ x: 3, y: 2 },
{ x: 4, y: 2 },
{ x: 5, y: 2 },
/// what i want ///
{ x: 3, y: 1 },
{ x: 4, y: 2 },
{ x: 5, y: 3 },
{ x: 6, y: 4 },
{ x: 7, y: 5 },
{ x: 8, y: 6 },
{ x: 9, y: 7 },
I don't quite understand why you are initializing the data object with those values.
The result you want, you can't get it by iterating the data object that you have initialized with 3 values.
Assuming that the arrays have these values and an equal length, you can try this:
const [data, setdata] = useState([
{ x: 1, y: 2 },
{ x: 1, y: 2 },
{ x: 1, y: 2 }
]);
const x = [3, 4, 5, 6, 7, 8, 9];
const y = [1, 2, 3, 4, 5, 6, 7];
const newData = x.reduce((acc, xVal, index) => {
const obj = { x: xVal, y: y[index] };
acc.push(obj);
return acc;
}, []);
setdata(newData)
I am using chart.js 2.9.3. I have used onClick handler in options as well as getElementAtEvent to achieve what I want but I get the items empty array and the event doesn't have the the information about the area that is clicked. Clicking on each point works fine, but clicking on Area of whole line doesn't give me much information.
Here is the code snippet of my chart.
var chart_canvas = document.getElementById("myChart");
var stackedLine = new Chart(chart_canvas, {
type: 'line',
data: {
labels: ["0.0", "0.2", "0.4", "0.6", "0.8", "1.0"],
fill: true,
datasets: [{
label: 'One',
pointRadius: 3,
data: [.5, .3, .2, .1, .4, .3],
borderWidth: 1
}, {
label: 'Two',
pointRadius: 3,
data: [.0, .1, .2, .4, .1, .4],
borderWidth: 1
}]
},
options: {
responsive: true,
onClick : (event, items) =>{
console.log("event",event);
},
}
});
Finally I tried to solve this using some DOM manipulation to get the information by clicking on area of each filled area of line chart.
Example is here:
https://codepen.io/amiablesyed/pen/RwKxaqE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js#2.9.4/dist/Chart.js"></script>
</head>
<body>
<div style="background-color: gainsboro">
Data:<span id="Data"></span>
</div>
<div style="width: 500px; height: 400px">
<canvas id="mainChart" width="700" height="400"> </canvas>
</div>
<script>
var ctx = document.getElementById("mainChart").getContext("2d");
var myChart = new Chart(ctx, {
type: "line",
data: {
labels: [
"Red",
"Blue",
"Yellow",
"Green",
"Purple",
"Orange",
"Pink",
"Black",
"Grey",
],
datasets: [
{
lineTension: 0,
label: "Data A",
data: [11, 12, 1, 3, 1, 1, 3, 5, 2],
backgroundColor: "#ffe8e8",
borderColor: ["#ffe8e8"],
borderWidth: 1,
},
{
lineTension: 0,
label: "Data B",
data: [12, 17, 3, 5, 2, 3, 6, 8, 4],
backgroundColor: "#e2ffcb",
borderColor: ["#e2ffcb"],
borderWidth: 1,
},
{
lineTension: 0,
label: "Data C",
data: [15, 23, 6, 9, 3, 8, 7, 10, 11],
backgroundColor: "#ffe689",
borderColor: ["#ffe689"],
borderWidth: 1,
},
],
},
});
document
.getElementById("mainChart")
.addEventListener("click", function (e) {
areaClick(e);
});
function areaClick(e) {
if (!myChart.scales["y-axis-0"]._gridLineItems) return;
var gridLineH = myChart.scales["y-axis-0"]._gridLineItems[0];
var lenH = myChart.scales["y-axis-0"]._gridLineItems.length;
var width = gridLineH.x2 - gridLineH.x1;
var yMax = myChart.scales["y-axis-0"].max;
var yMaxPixcel = myChart.scales["y-axis-0"].bottom - gridLineH.y1;
var gridLineV = myChart.scales["x-axis-0"]._gridLineItems[0];
var lenV = myChart.scales["x-axis-0"]._gridLineItems.length;
var height = gridLineV.y2 - gridLineV.y1;
var xMax = myChart.scales["x-axis-0"].maxIndex;
var scaleX = width / (lenV - 1);
var scaleY = height / (lenH - 1);
var yPixcel =
yMaxPixcel - (e.pageY - e.target.offsetTop - gridLineH.y1);
var yVal = yMax * (yPixcel / yMaxPixcel);
console.log(yVal);
var curXPixcel = e.pageX - e.target.offsetLeft - gridLineH.x1;
var xVal = Math.floor(curXPixcel / scaleX);
var xAxis = myChart.scales["x-axis-0"];
var label = "Others";
if (xVal < xAxis.maxIndex && xVal >= xAxis.minIndex) {
var x1x2Pixcels = getx1x2Pixcels(xVal, gridLineH.x1);
document.getElementById("Data").innerText = getDataLable(
xVal,
yVal,
x1x2Pixcels,
curXPixcel
);
}
}
function getx1x2Pixcels(xVal, offset) {
var x1x2 = {};
x1x2.x1 =
myChart.scales["x-axis-0"]._gridLineItems[xVal].x1 - offset + 0.5;
x1x2.x2 =
myChart.scales["x-axis-0"]._gridLineItems[xVal + 1].x1 - offset + 0.5;
return x1x2;
}
function getDataLable(xVal, yVal, x1x2Pixcels, curXPixcel) {
var datasetes = myChart.config.data.datasets;
var dataLable = "";
if (datasetes.length > 1) {
for (var i = datasetes.length; i > 0; i--) {
if (myChart.getDatasetMeta(i - 1).hidden) continue;
var dataA = datasetes[i - 1];
var dataALable = dataA.label;
var y1 = dataA.data[xVal];
var y2 = dataA.data[xVal + 1];
var isBelow = IsBelowTheLine(
curXPixcel,
yVal,
x1x2Pixcels.x1,
y1,
x1x2Pixcels.x2,
y2
);
if (isBelow) {
dataLable = isBelow ? dataALable : dataLable;
if (i == 1) {
var isBelowZeroLine = IsBelowTheLine(
curXPixcel,
yVal,
x1x2Pixcels.x1,
0,
x1x2Pixcels.x2,
0
);
dataLable = isBelowZeroLine ? "" : dataLable;
}
} else break;
}
}
return dataLable;
}
function IsBelowTheLine(x, y, x1, y1, x2, y2) {
var v1 = [x2 - x1, y2 - y1];
var v2 = [x2 - x, y2 - y];
var xp = v1[0] * v2[1] - v1[1] * v2[0];
return xp >= 0;
}
</script>
</body>
</html>
I have a list of objects with this definition:
type MyObject struct {
ID int `json:"id"`
Level int `json:"level"`
CityID int `json:"city_id"`
}
I want to categorize them based on CityID in order to get a list of lists where each inner list's items have the same CityID.
For example, if I have the following list:
[
MyObject {ID: 1, Level: 12, CityID: 7},
MyObject {ID: 2, Level: 15, CityID: 2},
MyObject {ID: 3, Level: 55, CityID: 4},
MyObject {ID: 4, Level: 88, CityID: 7},
MyObject {ID: 5, Level: 11, CityID: 4},
MyObject {ID: 6, Level: 5, CityID: 7},
MyObject {ID: 7, Level: 42, CityID: 2}
]
I need below output:
[
[MyObject {ID: 1, Level: 12, CityID: 7}, MyObject {ID: 4, Level: 88, CityID: 7}, MyObject {ID: 6, Level: 5, CityID: 7}],
[MyObject {ID: 2, Level: 15, CityID: 2}, MyObject {ID: 7, Level: 42, CityID: 2}],
[MyObject {ID: 3, Level: 55, CityID: 4}, MyObject {ID: 5, Level: 11, CityID: 4}]
]
I know it is possible in python using itertools, but I'm new in go and have little knowledge about its libraries. Any help?
EDIT 1:
I am currently using this:
m := make(map[int][]MyObject)
for _, item := range myList {
if val, ok := m[item.CityID]; ok {
m[item.CityID] = append(val, item)
} else {
m[item.CityID] = []MyObject{item, }
}
}
Your current approach is the way to go, but it may be simplified, there is no need to check if a CityID is already in the map, because indexing a map with a key that isn't in it will result in the zero value of the value type, which is nil for slices, and you may append to a nil slice without a problem:
m := make(map[int][]MyObject)
for _, item := range myList {
m[item.CityID] = append(m[item.CityID], item)
}
Complete programme for you
It might be lengthy but working fine, may help if you don't have any other option.
package main
// only needed below for sample processing
type MyObject struct {
ID int `json:"id"`
Level int `json:"level"`
CityID int `json:"city_id"`
}
var listOfID = make([]int, 0)
func main() {
var listMap = make(map[int][]MyObject)
obj := MyObject {ID: 1, Level: 12, CityID: 7}
for i := 0; i < 10; i++ {
listMap = addToList(obj, listMap)
}
obj1 := MyObject {ID: 1, Level: 12, CityID: 8}
for i := 0; i < 10; i++ {
listMap = addToList(obj1, listMap)
}
listOfList := getListOfLists(listMap)
printListOfList(listOfList)
}
func printListOfList(list interface{}) {
// print here
return
}
func getListOfLists(listMap map[int][]MyObject) interface{} {
var listOfLists [][]MyObject
for i:=0; i < len(listOfID); i++ {
innerList := listMap[listOfID[i]]
listOfLists = append(listOfLists, innerList)
}
return listOfLists
}
func addToList(obj MyObject, listMap map[int][]MyObject) map[int][]MyObject {
cityID := obj.CityID
list := listMap[cityID]
if list != nil {
list = append(list, obj)
listMap[cityID] = list
} else {
var newList []MyObject
listOfID = append(listOfID, cityID)
newList = make([]MyObject, 0)
newList = append(newList, obj)
listMap[cityID] = newList
}
return listMap
}
I want to get a constant variable from this static variable.
#define video_mode_count 12
static freenect_frame_mode supported_video_modes[video_mode_count] = {
// reserved, resolution, format, bytes, width, height, data_bits_per_pixel, padding_bits_per_pixel, framerate, is_valid
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_RGB}, 1280*1024*3, 1280, 1024, 24, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_RGB}, 640*480*3, 640, 480, 24, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_BAYER), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_BAYER}, 1280*1024, 1280, 1024, 8, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_BAYER), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_BAYER}, 640*480, 640, 480, 8, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_8BIT), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_8BIT}, 1280*1024, 1280, 1024, 8, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_8BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_8BIT}, 640*488, 640, 488, 8, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_10BIT), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_10BIT}, 1280*1024*2, 1280, 1024, 10, 6, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_10BIT), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_10BIT}, 640*488*2, 640, 488, 10, 6, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_HIGH, FREENECT_VIDEO_IR_10BIT_PACKED), FREENECT_RESOLUTION_HIGH, {FREENECT_VIDEO_IR_10BIT_PACKED}, 1280*1024*10/8, 1280, 1024, 10, 0, 10, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_IR_10BIT_PACKED), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_IR_10BIT_PACKED}, 640*488*10/8, 640, 488, 10, 0, 30, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_YUV_RGB), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_YUV_RGB}, 640*480*3, 640, 480, 24, 0, 15, 1 },
{MAKE_RESERVED(FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_YUV_RAW), FREENECT_RESOLUTION_MEDIUM, {FREENECT_VIDEO_YUV_RAW}, 640*480*2, 640, 480, 16, 0, 15, 1 },};
Now I need to write something
const FREENECT_VIDEO_RGB = [ An instance in the type of freenect_frame_mode ]
How to declare a const var in that format?
The original codes from:
https://github.com/OpenKinect/libfreenect/blob/master/src/cameras.c#L42
And I need to pass a const var freenect_frame_mode into this, and see if it returns -1 or not:
https://github.com/OpenKinect/libfreenect/blob/master/src/cameras.c#L1152
int freenect_set_video_mode(freenect_device* dev, const freenect_frame_mode mode)
{
freenect_context *ctx = dev->parent;
if (dev->video.running) {
FN_ERROR("Tried to set video mode while stream is active\n");
return -1;
}
// Verify that the mode passed in is actually in the supported mode list
int found = 0;
int i;
for(i = 0 ; i < video_mode_count; i++) {
if (supported_video_modes[i].reserved == mode.reserved) {
found = 1;
break;
}
}
if (!found) {
FN_ERROR("freenect_set_video_mode: freenect_frame_mode provided is invalid\n");
return -1;
}
freenect_resolution res = RESERVED_TO_RESOLUTION(mode.reserved);
freenect_video_format fmt = (freenect_video_format)RESERVED_TO_FORMAT(mode.reserved);
dev->video_format = fmt;
dev->video_resolution = res;
// Now that we've changed video format and resolution, we need to update
// registration tables.
freenect_fetch_reg_info(dev);
return 0;
}
I am just stuck with using the function now.
Thanks!
Well, if you want to get an element of an array, you can use the standard syntax array[index].
const freenect_frame_mode FREENECT_VIDEO_RGB = supported_video_modes[5];
for example.
You need to show more code, i.e. the definitions of these symbols, if you want more info.
I have a piece of code that runs on an embedded system. Its job is to convert some ASCII characters into proprietary data. The data is stored in a multi-dimensional array and what appears to be the problem, although I am unable to confirm this with the hardware debugger, is that the bit variable is staying at value 2. This code works the first two times it is run, but on the third run it breaks and returns starts sending wrong data through the UART interface. I though maybe someone else analyzing this might be able to see what I'm missing. This is C99 which I am not too familiar with. Bleow is the entire function, but I think the problem is with the for statement?? Any help would be greatly appreciated!
void simple_uart_putstring(uint8_t *str, uint16_t length)
{
//send data bits
uint_fast8_t index = 0;
uint8_t ch = str[index++];
uint_fast8_t bitCount = 0;
int index2 = 0;
int bit = 0;
if (length > 1)
{
while (length >= index)
{
if (bitCount < 2)
{
if (length < 10)
{
//send sync bits
simple_uart_put(254);
simple_uart_put(223);
bitCount = 2;
} else {
//send sync bits and add scrolling
simple_uart_put(254);
simple_uart_put(222);
bitCount = 2;
}
}
//send each bit for each letter in the string
for (uint_fast8_t i = 0; i < 5; i++)
{
index2 = (int)ch;
bit = (int)i;
simple_uart_put(matrix[index2 - 32][bit]);
bitCount++;
}
ch = str[index++];
}
//the main controller is expecting 150 bits total to continue to send bit until 150
while (bitCount <= 150)
{
simple_uart_put(0);
bitCount++;
if(bitCount >= 150)
{
bitCount = 0;
break;
}
}
bitCount = 0;
}
}
And here is a sample of the array:
const uint8_t matrix[59][5] =
{
{ 0, 0, 0, 0, 0}, //space
{ 0, 125, 0, 0, 0}, //!
{ 0, 112, 0, 112, 0}, //"
{127, 127, 127, 127, 127 }, //#
{ 18, 42, 107, 36, 0}, //$
{ 50, 52, 22, 38, 0}, //%
{ 38, 89, 57, 6, 9}, //&
{ 64, 48, 0, 0, 0}, //'
{ 0, 0, 62, 65, 0}, //(
{ 0, 65, 62, 0, 0}, //)
{ 20, 8, 62, 8, 20}, //*
{ 0, 8, 28, 8, 0}, //+
{ 1, 6, 0, 0, 0}, //,
{ 0, 8, 8, 8, 0}, //-
{ 3, 3, 0, 0, 0}, //.
{ 2, 4, 8, 16, 32}, //
{ 62, 69, 73, 62, 0}, //0
{ 1, 33, 127, 1, 0}, //1
{ 35, 67, 69, 49, 0}, //2
{ 34, 73, 73, 54, 0}, //3
{ 12, 20, 36, 127, 0}, //4
{ 114, 81, 81, 78, 0}, //5
{ 30, 41, 73, 6, 0}, //6
{ 64, 71, 72, 112, 0}, //7
{ 54, 73, 73, 54, 0}, //8
{ 48, 73, 74, 60, 0}, //9
{ 0, 54, 54, 0, 0}, //:
{ 0, 1, 54, 0, 0}, //;
{ 0, 8, 20, 34, 0}, //<
{ 0, 20, 20, 20, 0}, //=
{ 0, 34, 20, 8, 0}, //>
{ 32, 64, 69, 72, 48}, //?
{ 62, 65, 93, 93, 112}, //#
{ 63, 72, 72, 63, 0 }, //a
{ 127, 73, 73, 54, 0 }, //b
{ 62, 65, 65, 34, 0}, //c
{ 127, 65, 34, 28, 0 }, //d
{ 127, 73, 73, 65, 0}, //e
{ 127, 72, 72, 64, 0}, //f
{ 62, 65, 73, 47, 0}, //g
{ 127, 8, 8, 127, 0}, //h
{ 0, 65, 127, 65, 0},//i
{ 6, 65, 126, 64, 0}, //j
{ 127, 8, 20, 99, 0}, //k
{ 127, 1, 1, 1, 0}, //l
{ 127, 32, 24, 32, 127}, //m
{ 127, 16, 8, 127, 0}, //n
{ 62, 65, 65, 62, 0}, //o
{ 127, 72, 72, 48, 0}, //p
{ 60, 70, 66, 61, 0}, //q
{ 127, 76, 74, 49, 0}, //r
{ 50, 73, 73, 38, 0}, //s
{ 0, 64, 127, 64, 0}, //t
{ 126, 1, 1, 126, 0},
{ 127, 1, 2, 124, 0},
{ 126, 1, 6, 1, 126},
{ 99, 28, 28, 99, 0},
{ 112, 8, 8, 127, 0},
{ 71, 73, 81, 97, 0}};
And the uart send method:
void simple_uart_put(uint8_t cr)
{
NRF_UART0->TXD = (uint8_t)cr;
while (NRF_UART0->EVENTS_TXDRDY!=1)
{
// Wait for TXD data to be sent
}
NRF_UART0->EVENTS_TXDRDY=0;
}
An example of this working would be if the input string is "AB" and the length = 2;
It should send the following bytes via UART:
{254, 223, 63, 72, 72, 63, 0, 127, 73, 73, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, etc....}
The first two bytes are sync bytes, the next five come from the array matrix[33][0 to 4] because ASCII 'A' = 65 and 65-32 = 33. Then the next five come from ASCII 'B' = 66 and 66 - 32 = 34 so they are sent from matrix[34][0 to 4]. Then the next n = 150 - bitNumber are sent as 0 because the main controller is expecting 150 bytes always.
See edit at bottom
Without having definitions for all functions, I cannot completely analyze this, however there are a couple of suspicious things:
1) this declaration is odd:
uint_fast8_t index = 0;
uint8_t ch = str[index++]; //always sets ch to first character of input "str" then increments index.
NOTE: corrected comment on previous line.
2) although the comment indicates "each bit for each letter in the string" it only handle 5:
for (uint_fast8_t i = 0; i < 5; i++){...} //what if lenth of input is less than 5?
Suggest changing to:
for (uint_fast8_t i = 0; i < length; i++){...} //used second argument "length"
3) Finally, it seems that null terminating the string should follow the for loop, but: (see comments in line) (Also, input arguments used were "abc", 4)
for (uint_fast8_t i = 0; i < 5; i++)
{
index2 = (int)ch; //ch inits to first char in str, and indexes through
bit = (int)i;
//simple_uart_put(matrix[index2 - 32][bit]);
bitCount++;
}
ch = str[index++]; //terminates in second character of input "b' in this case
//I think this should null terminate with '\0' if it is to be treated as a C string,
//but because, as you say, this is "proprietary", I am not sure.
EDIT
I think the problem may be that you have declared the variable matrix with what looks like sufficient room, but only initialized it with three rows of data:
const uint8_t matrix[59][5] =
{
{ 0, 0, 0, 0, 0}, //space
{ 0, 125, 0, 0, 0}, //!
{ 0, 112, 0, 112, 0}, //"
}; //have only initialized matrix[0], matrix[1] and matrix[2]
The remaining 53 rows of data, although owned by you, have not been initialized that I can see. So, when you say:
the next five come from the array matrix[33][0 to 4] because ASCII 'A' = 65 and 65-32 = 33. Then the next five come from ASCII 'B' = 66 and 66 - 32 = 34 so they are sent from matrix[34][0 to 4]
That suggests what ever random number happens to be occupying those uninitialized memory locations, are what is being written out in the line:
simple_uart_put(matrix[index2 - 32][bit]);
EDIT 2 (See comment to explain)
Here is my main(), and commented simple_uart_putstring():
int main()
{
uint8_t *str;
int len=3;
str = malloc(3); //extra char for terminating null byte
strcpy(str, "AB");
simple_uart_putstring(str, 2);
free(str);
}
void simple_uart_putstring(uint8_t *str, uint16_t length)
{
//send data bits
uint_fast8_t index = 0;
uint8_t ch = str[index++]; //ch inits to first char in str, and indexes through
uint_fast8_t bitCount = 0;
int index2 = 0;
int bit = 0;
if (length > 1)
{
while (length >= index)
{
if (bitCount < 2)
{
if (length < 10)
{
//send sync bits
//simple_uart_put(254);
//simple_uart_put(223);
bitCount = 2;
} else {
//send sync bits and add scrolling
//simple_uart_put(254);
//simple_uart_put(222);
bitCount = 2;
}
}
//send each bit for each letter in the string
for (uint_fast8_t i = 0; i < 5; i++)
{
index2 = (int)ch; //
bit = (int)i;
/*simple_uart_put(*/matrix[index2 - 32][bit];//);break here to view "matrix[index2 - 32][bit]"
bitCount++;
}
ch = str[index++]; //
}
//the main controller is expecting 150 bits total to continue to send bit until 150
while (bitCount <= 150)
{
//simple_uart_put(0);
bitCount++;
if(bitCount >= 150)
{
bitCount = 0;
break;
}
}
bitCount = 0;
}
}