C :: GPIO Input With Changing States
Feb 4, 2014
I have a GPIO pin(GP4) on a microcontroller with a continuous digital pulse train coming into it. I am writing to it in C and do not have interrupts on this chip. I have been calling my input "#define inputA GP4". In C, I would like to be able to find the positive edge of a pulse and trigger the timer on it. I'm not sure if an XOR will accomplish what I need by storing inputA to another variable at some point. Would it be possible to accomplish this by writing code that acts like a positive-edge triggered flip-flop?
The other problem that I have is I need to be able to do this and not get caught in an infinite loop where I can still do other things sequentially with my code, if for instance, inputA goes to 0 and stays at 0 permanently. This means that my option of using while(inputA=0); is out of the question.
View 2 Replies
ADVERTISEMENT
Feb 12, 2013
So I did read, however it said also that it was memory intensive and I had a question... I also came across this:
Window.pushGLStates();
Window.draw("Sfml Text");
Window.popGLStates();
The problem here is that none of these commands exist!
Window.draw should exist and even though I have all the proper includes I still get it telling me that 'Draw' is not a member of sf::Window
I have encountered that error many times everywhere across my sfml related code, it's not like they removed all those features in the update (Which they did not) but, why then would it not be a member?
View 8 Replies
View Related
Dec 17, 2013
If I was to input for example 'x' into my program, how could I change that to something like 'HuS581' every time that specific character was inputted?
View 2 Replies
View Related
Oct 30, 2013
I was talking to someone earlier about how to change the value of something from a function, and they said what was needed was to use a ** to change something, and was wondering if I could get a walk - through of what happens. I understand a single pointer well enough, but a pointer through a pointer is kind of confusing to me. Here is a simple example.
Code:
#include <stdio.h>
#include <stdlib.h>
#define SIZE 5
int add(int ** TOP, int * stack);
int *stack = NULL;
[Code] ....
Why is it that when the program prints the address of TOP in main, it is different than the address of TOP in the function? Is it because it is a different instance of TOP because it is in the function? When I put the number on *TOP, and come out of the function back to main, it then says the address of TOP is the number entered into *TOP, and am not sure why. And the **TOP ++ at the end I am thinking it increments malloc by 1, therefore bringing the pointer TOP up to point at the next element, or am I completely off base there?
View 7 Replies
View Related
Nov 7, 2013
#include <iostream>
#include <iomanip>
using namespace std;
// cin.get() <-------------- used to let the user read the screen
// Function prototypes
void calcSales(const int [], const double [], double [], int);
void showOrder(const double [], const int [], int);
[Code] ....
How can i change the "const int NUM_PRODS = 12;" from saying id 1, id 2, id 3, etc. to custom product numbers?
View 1 Replies
View Related
Jan 1, 2015
I use miracle library to work with big numbers. I defined a number for example X with 192 bit. at first X= 0 ;I want to change for example 3 bit of it to 1 randomly.as a example:
assume that X has 10 bit :
X=0000000000
random numbers should be :
1000010001
1010100000
1100000100
View 1 Replies
View Related
May 5, 2012
For the following code :
s = 0 ;
for(i=m ; i<=(2*n-1) ; i+=m) {
if(i<=n+1)
{ s+=(i-1)/2 ; }
else
{ s+=(2*n-i+1)/2 ; }
}
I want to change the complexity of the code from O(n) to O(1) . So I wanted to eliminate the for loop . But as the sum "s" stores values like (i-1)/2 or (2*n-i+1)/2 so eliminating the loop involves tedious calculation of floor value of each (i-1)/2 or (2*n-i+1)/2 . It became very difficult for me to do so as I might have derived the wrong formula in sums of floors . Need Changing complexity from O(n) to O(1). Is there any other way to reduce the complexity ? If yes ... then how ?
View 3 Replies
View Related
May 15, 2012
I have this code which previously used the BigInteger library, however now I have GMP installed and I want to use that instead.
I have read the manual but I cannot figure out how to use GMP in this function without getting errors.
Here is the function:
Code:
int lucas(long p){ //p is a number in the range of 2 up to 50,000,000, possibly bigger
int s = 4; //previously assigned as a big integer
int z; //used in the for loop below
int M = 2; //previously assigned as a big integer
for(z = 1; z < p; z++){ //this accomplishes the same as 2 to the power of p, and is stored in M
M *= 2;
}
M--;
[code]....
I can initialize variables using the gmp library, but when I'm trying to use the mpz_pow_ui() function I get errors because it wants me to use long integers, which are too small for the numbers I want to work with.
How can I re-write this function to use GMP?
View 4 Replies
View Related
Jun 11, 2013
Basically, I have a pointer to a C string:
Code: char **objectData and a C string:
Code: char temp[350]; I need to assign the CONTENTS of the temp to the CONTENTS to which objectData points.
Code: *objectData = temp; //this changes the pointer. When temp is deleted, objectData points to some rubbish
**objectData = *temp; //this doesn't seem to be doing anything - the string to which objectData points does not change.
View 3 Replies
View Related
Aug 22, 2014
I was wondering if there was a possible way to change my c program into an application so that i can send the application to another person and not let the other person have access to my codings?
My reasons for asking this question: For the application i want to send there are secrets that are meant to be unraveled by gameplay but i dont want people to look at the codes and know everything.
View 6 Replies
View Related
Mar 13, 2014
SO lets say I have a file that says
10 tennent
9 Eccleston
12 Capaldi
11 Smith
How do I get the number's in order but not changing the name it goes with? SO here is how I started it
# include <iostream>
# include <fstream>
# include <sstream>
# include <set>
# include <list>
# include <string>
# include <cctype>
# include <vector>
[Code] ....
View 12 Replies
View Related
Jun 15, 2013
If I have an array of two columns that have the same values and I want to change only the third column how can I go about doing this. The values of the third column will change based on the values in one of the columns which I plug into a math equation. Also how come I can't show a double value in the array?
#include <iostream>
#include <math.h>
#include<iomanip>
#include <vector>
using namespace std;
[code]...
View 7 Replies
View Related
Apr 28, 2013
I have a problem with my code which I can't work out:
double Mi = 200*pow(10,30);
cout << "
Enter accreted mass increment in solar masses
";
cin >> dm;
cout << "
[Code] ....
Basically the loop works, but gives the wrong results.
I need, at the end of the loop, to sort of "redefine" Mi as "Mi + Macc". I then need it to repeat the loop, and at the end add another Macc so that Mi becomes "Mi + Macc + Macc", etc.
View 5 Replies
View Related
Jan 21, 2015
I want to change string to bool but I'm having trouble doing this.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int check_Pythag(int DIMA, int DIMB, int DIMC) {
[Code] ....
View 2 Replies
View Related
Sep 18, 2013
I want to change the alpha of a sprite without changing any other colours
View 4 Replies
View Related
Apr 17, 2014
For the past couple days I've been making small improvements on a program I made to keep track of a battle count while playing a game. Mainly to reduce the chore of keeping track yourself while you're playing. But it still becomes a hassle to switch back and forth between the program and your game and I was hoping to be able to set focus to the game after the BattleCount method is called.
Currently I am importing a DLL that somebody recommended I use to make a ActiveProcess method that accepts a integer as a parameter which would set the PID but it doesn't seem to be working. The two methods are as follows.
private void countDownClick(object sender, RoutedEventArgs e) {
//Calls a method within my class that subtracts and adds battle values.
counter.CalculateBattles();
//These two change text on my WPF forms with accessor values from my class.
battlesWonText.Text = counter.BattlesWon.ToString();
battlesLeftText.Text = counter.BattlesLeft.ToString();
[Code] ....
This is the C++ code they told me to use to set focus to another application using a PID.
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_SHOWWINDOW = 0x0040;
[Code] ....
I'm simply trying to figure out how to set focus to a foreign program using their PID and a button click event in WPF. I'm using Visual Studio 2012 on Windows 7.
View 4 Replies
View Related
Dec 14, 2014
I'm working on a project where we access a tiny premade database in order to log into and access another page. I got the log in part working right, but the last part of the project asks me to lock out the account after a certain number of failed attempts. I'm not sure if I need a method to do this or if I can do it right there in the button handler. I tried creating a method to use on the object that was already there, but I'm not sure if that's the right way to go about it. It says it locks the account, but the value in the database never changes, and I don't know why.
//from the login button handler
protected void btnLogin_Click(object sender, EventArgs e) {
bool IsFound = false;
clsDataLayer dl = new clsDataLayer();
IsFound = dl.GetUser(Server.MapPath("~/AddressBook.mdb"), txtUserID.Text, txtPassword.Text);
if (IsFound) {
Response.Redirect("~/frmUpdateAddress.aspx");
[code]....
View 14 Replies
View Related
Jul 2, 2014
I have a C-Power5200 driver. I want using the C# language change to the controller's IP address.
Here a link to the website and API.C-POWER 5200
In Annex API controller.
View 7 Replies
View Related
Mar 20, 2013
i had created a client server program in MFC using TCP but by doing this the server can only work on one computer because you have to tell the client the ip address to connect to i.e
Code:
ServerAddr.sin_addr.s_addr = inet_addr("10.13.31.112");
so i want to change my code so that i can use broadcasting but i found out that it only works using UDP. I tried changing the code but the error message "error with sendto: 10047" displays when i run the program.
that error means
Address family not supported by protocol family. An address incompatible with the requested protocol was used. All sockets are created with an associated address family (that is, AF_INET for Internet Protocols) and a generic protocol type (that is, SOCK_STREAM). This error is returned if an incorrect protocol is explicitly requested in the socket call, or if an address of the wrong family is used for a socket, for example, in sendto.
here is the code from server:
Code:
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2), &wsaData);
int port = 7171;
if (param)
port = reinterpret_cast<short>(param);
[code]....
View 1 Replies
View Related
Sep 16, 2013
I haven't actually learned how to use arrays yet but I know the basic principle of it and decided to try and implement one to improve my code. I'm sure the thing is a bug ridden mess but I would particularly like to point your attention to the function sortDenomination(). Is what I am trying to do in the loop possible?
The reason why I want to do it this way and not with if statements for each denomination is because I can then easily apply this to the second part of the assignment which sees us split a double into dollars and cents and then process each separately. All I would have to differ for each is change the money_loop variable to include the last two denominations in the array.
Code:
#include <stdio.h>
/*Reads cents input from the user.*/
void getCents(int &read_cents) {
printf("Please enter the amount of cents between 5-95:
[Code] .....
View 10 Replies
View Related
Jan 12, 2015
I have a 10x10 array, initialized to all zeros. I create 2 random numbers for the purpose of guessing a position in the array.
However, when I print the array, the 0,0 spot keeps shifting to match the 2nd random number generated. Is there something strange about the 0,0 spot?
Here is my code:
Code:
seedrnd();
for (x=0;x<2;x++) {
randArray[x]=rnd(10);
}
for (x=0;x<2;x=x+1)
[Code] .....
The 2nd to last print statement actually prints randColumn. The last print statement correctly prints 0.
View 7 Replies
View Related
Dec 10, 2014
I want to write a programm that will reverse the order of the numbers in an array (e.g. as an input 1,2,3.5,4 and as an output i want 4,3.5,2,1) . But i have to problems:
1) I do not know how to properly change the type of a numbers inside an array from int to float or double, changing int to float in front of the a[10], does not change anything instead the code does not want to compile then.
2) I also want to make an array of a number of elements typed by a user with use of a "do" loop and how to put this parameter in the code.
Here is my code:
Code:
// ConsoleApplication3.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[]) {
int a[10], i, n;
int pom;
do {
printf("number of elements in an array a: n = ");
[Code]...
View 5 Replies
View Related
Jul 28, 2013
I have a small problem with my program. It is kinda a mess but I will try to explain you what I am trying to do. I have some threads. One of it, it attempts to detect a game client. So my code is sort of like that:
DWORD ProcessID; // The process ID of the game client
void test() {
char* text;
[Code]....
So basically, its like the variable changes, but only inside the thread... why does that happen?
View 15 Replies
View Related
Nov 22, 2013
I'm trying building a new macro for change the array size:
#define redim(varname,x) ((sizeof(varname)*) realloc (varname, x * sizeof(varname)));
int b;
redim(b,3);
error message:
"error: expected primary-expression before ')' token"
what isn't right with these macro?
View 10 Replies
View Related
Aug 12, 2014
I'm trying to change a memory block values that is a 2d image. How to change to change scale but it's not working. This is the code
Vivienne
void Image::GenerateGrayScale(void) {
// create temporary area
unsigned char * tempdata_ = new unsigned char[width_ * height_ * depth_*components_];
unsigned char grey;
[Code] ....
I'm trying to employ this method [URL] .....
View 1 Replies
View Related
Feb 13, 2014
The purpose of the code is to read in state names, say california and print CA. However, if it was a state with two words, it would read in only the first letter of each. I.E New Hampshire would be NH.
here's my code:
#include <iostream>
#include <iomanip>
#include <cctype>
[Code].....
I am able to get the one word states and tried getting the two word states but it doesnt work.
View 1 Replies
View Related