本文整理汇总了C++中VideoBuffer::physicalAccel方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoBuffer::physicalAccel方法的具体用法?C++ VideoBuffer::physicalAccel怎么用?C++ VideoBuffer::physicalAccel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoBuffer
的用法示例。
在下文中一共展示了VideoBuffer::physicalAccel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
CubeID cube(0);
VideoBuffer vid;
vid.initMode(BG0);
vid.attach(cube);
for (int x = -1; x < 17; x++) {
drawColumn(vid, x);
}
/*
* Scroll horizontally through our background based on the accelerometer's X axis.
*
* We can scroll with pixel accuracy within a column of tiles via bg0.setPanning().
* When we get to either edge of the currently plotted tiles, draw a new column
* of tiles from the source image.
*
* Because BG0 is 1 tile wider and taller than the viewport itself, we can pre-load
* the next column of tiles into the column at the edge before it comes into view.
*/
float x = 0;
int prev_xt = 0;
for (;;) {
// Scroll based on accelerometer tilt
Int2 accel = vid.physicalAccel().xy();
// Floating point pixels
x += accel.x * (40.0f / 128.0f);
// Integer pixels
int xi = x + 0.5f;
// Integer tiles
int xt = x / 8;
while (prev_xt < xt) {
// Fill in new tiles, just past the right edge of the screen
drawColumn(vid, prev_xt + 17);
prev_xt++;
}
while (prev_xt > xt) {
// Fill in new tiles, just past the left edge
drawColumn(vid, prev_xt - 2);
prev_xt--;
}
// pixel-level scrolling within the current column
vid.bg0.setPanning(vec(xi, 0));
System::paint();
}
}
示例2: writePacket
void writePacket()
{
/*
* This is one way to write packets to the UsbPipe; using reserve()
* and commit(). If you already have a buffer that you want to copy to the
* UsbPipe, you can use write().
*/
if (Usb::isConnected() && usbPipe.writeAvailable()) {
/*
* Access some buffer space for writing the next packet. This
* is the zero-copy API for writing packets. Both reading and writing
* have a traditional (one copy) API and a zero-copy API.
*/
UsbPacket &packet = usbPipe.sendQueue.reserve();
/*
* Fill most of the packet with dummy data
*/
// 28-bit type code, for our own application's use
packet.setType(0x5A);
packet.resize(packet.capacity());
for (unsigned i = 0; i < packet.capacity(); ++i) {
packet.bytes()[i] = 'a' + i;
}
/*
* Fill the first 3 bytes with accelerometer data from Cube 0
*/
Byte3 accel = vid.physicalAccel();
packet.bytes()[0] = accel.x;
packet.bytes()[1] = accel.y;
packet.bytes()[2] = accel.z;
/*
* Log the packet for debugging, and commit it to the FIFO.
* The system will asynchronously send it to our peer.
*/
LOG("Sending: %d bytes, type=%02x, data=%19h\n",
packet.size(), packet.type(), packet.bytes());
usbPipe.sendQueue.commit();
updatePacketCounts(1, 0);
}
}